void DRCubeDimension::addCube(PServer server, PDatabase database, const Dimension *dimension, bool lookup, IdentifierType *rightsCubeId, bool useDimWorker)
{
	const string cubeName = SystemCube::PREFIX_GROUP_DIMENSION_DATA + dimension->getName();
	if (!lookup || !database->lookupCubeByName(cubeName, false)) {
		PDimension groupDimension = database->findDimensionByName(SystemDatabase::NAME_GROUP_DIMENSION, PUser(), false);
		IdentifiersType dimensions;
		dimensions.push_back(groupDimension->getId());
		dimensions.push_back(dimension->getId());

		PRightsCube cube = PRightsCube(new RightsCube(database, cubeName,  &dimensions));
		cube->setDeletable(false);
		cube->setRenamable(false);

		bool newId = true;
		if (rightsCubeId && *rightsCubeId != NO_IDENTIFIER) {
			cube->setID(*rightsCubeId);
			newId = false;
		}

		database->addCube(server, cube, false, newId, NULL, NULL, NULL, useDimWorker);

		if (rightsCubeId) {
			*rightsCubeId = cube->getId();
		}
	}
}
void AttributedDimension::addDimension(PServer server, PDatabase database, const Dimension *dimension, bool lookup, IdentifierType *attributesDimId, IdentifierType *attributesCubeId, bool useDimWorker)
{
	const string dimName = AttributesDimension::PREFIX_ATTRIBUTE_DIMENSION + dimension->getName() + AttributesDimension::SUFFIX_ATTRIBUTE_DIMENSION;
	PDimension attribDimension;
	if (lookup) {
		attribDimension = database->lookupDimensionByName(dimName, false);
	}
	if (!lookup || !attribDimension) {
		// create attributes dimension
		attribDimension = PAttributesDimension(new AttributesDimension(dimName));
		attribDimension->setDeletable(false);
		attribDimension->setRenamable(false);

		bool newId = true;
		if (attributesDimId && *attributesDimId != NO_IDENTIFIER) {
			attribDimension->setID(*attributesDimId);
			newId = false;
		}

		database->addDimension(server, attribDimension, true, newId, NULL, NULL, NULL, NULL, useDimWorker);

		if (attributesDimId) {
			*attributesDimId = attribDimension->getId();
		}
	}

	const string cubeName = Cube::PREFIX_ATTRIBUTE_CUBE + dimension->getName();
	if (!lookup || !database->lookupCubeByName(cubeName, false)) {
		IdentifiersType dimensions;
		dimensions.push_back(attribDimension->getId());
		dimensions.push_back(dimension->getId());

		PSystemCube attributesCube = PSystemCube(new AttributesCube(database, cubeName, &dimensions, true));
		attributesCube->setDeletable(false);
		attributesCube->setRenamable(false);

		bool newId = true;
		if (attributesCubeId && *attributesCubeId != NO_IDENTIFIER) {
			attributesCube->setID(*attributesCubeId);
			newId = false;
		}

		database->addCube(server, attributesCube, false, newId, NULL, NULL, NULL, useDimWorker);

		if (attributesCubeId) {
			*attributesCubeId = attributesCube->getId();
		}
	}
}
Beispiel #3
0
bool ConfigDatabase::createSystemItems(PServer server, bool forceCreate)
{
	checkCheckedOut();
	bool dbChanged = NormalDatabase::createSystemItems(server, forceCreate);

	if (getName() == Server::NAME_CONFIG_DATABASE) {
		PDatabase db = COMMITABLE_CAST(Database, shared_from_this());

		checkAndCreateDimension(server, db, NAME_CONNECTIONS_DIMENSION, 0, 0, CONNECTIONS_ATTR_ITEMS, CONNECTIONS_ATTR_ITEMS + array_size(CONNECTIONS_ATTR_ITEMS), dbChanged);
		checkAndCreateDimension(server, db, NAME_CONFIG_DIMENSION, CONFIG_ITEMS, CONFIG_ITEMS + array_size(CONFIG_ITEMS), CONFIG_ATTR_ITEMS, CONFIG_ATTR_ITEMS + array_size(CONFIG_ATTR_ITEMS), dbChanged);
		PDimension taskPropsDim = checkAndCreateDimension(server, db, NAME_TASKPROPS_DIMENSION, TASKPROPS_ITEMS, TASKPROPS_ITEMS + array_size(TASKPROPS_ITEMS), dbChanged);
		PDimension notifTypesDim = checkAndCreateDimension(server, db, NAME_NOTIFTYPES_DIMENSION, NOTIFTYPES_ITEMS, NOTIFTYPES_ITEMS + array_size(NOTIFTYPES_ITEMS), dbChanged);
		PDimension tasksDim = checkAndCreateDimension(server, db, NAME_TASKS_DIMENSION, 0, 0, dbChanged);
		checkAndCreateDimension(server, db, NAME_VARSETS_DIMENSION, 0, 0, VARSETS_ATTR_ITEMS, VARSETS_ATTR_ITEMS + array_size(VARSETS_ATTR_ITEMS), dbChanged);
		PDimension etls = checkAndCreateDimension(server, db, NAME_ETLS_DIMENSION, 0, 0, dbChanged);
		PDimension etlprops = checkAndCreateDimension(server, db, NAME_ETLPROPS_DIMENSION, ETLPROPS_ITEMS, ETLPROPS_ITEMS + array_size(ETLPROPS_ITEMS), dbChanged);

		IdentifiersType dims;
		dims.push_back(etls->getId());
		dims.push_back(etlprops->getId());
		checkAndCreateCube(server, db, NAME_ETLS_CUBE, dims, dbChanged);

		dims[0] = tasksDim->getId();
		dims[1] = taskPropsDim->getId();
		checkAndCreateCube(server, db, NAME_TASKS_CUBE, dims, dbChanged);

		PDimension userDim = lookupDimensionByName(SystemDatabase::NAME_USER_DIMENSION, false);
		dims[1] = notifTypesDim->getId();
		dims.push_back(userDim->getId());
		checkAndCreateCube(server, db, NAME_TASKS_NOTIF_CUBE, dims, dbChanged);

		dims[1] = taskPropsDim->getId();
		checkAndCreateCube(server, db, NAME_TASKS_PRIVATE_CUBE, dims, dbChanged);

		checkConfigCube(server, db, dbChanged);

		if (isDeletable()) {
			setDeletable(false);
			dbChanged = true;
		}
		if (isRenamable()) {
			setRenamable(false);
			dbChanged = true;
		}
		protect = true;
	}
	return dbChanged;
}
Beispiel #4
0
void AggregationMap::compactSourceToTarget() {
  targetIdBuffer.clear();
  weightBuffer.clear();
  distributionMap.clear();
  source2TargetMap.clear();
  source2TargetVector.clear();

  for (SourceToTargetMapType::iterator stit = base2ParentMap.begin();
      stit != base2ParentMap.end(); ++stit) {
    IdentifiersType targetIds;
    vector<double> targetWeights;

    for (TargetMapType::const_iterator tmit = stit->second.begin();
        tmit != stit->second.end(); ++tmit) {
      targetIds.push_back(tmit->first);
      targetWeights.push_back(tmit->second);
    }
    SourceToTargetMapType::iterator nit = stit;
    ++nit;
    IdentifierType nextStartId =
        nit == base2ParentMap.end() ? stit->first + 1 : nit->first;
    storeDistributionSequence(stit->first, nextStartId, targetIds,
                              targetWeights);
  }
}
Beispiel #5
0
const IdentifiersType FileReaderTXT::getDataIdentifiers(int num)
{
	const vector<string> stringList = getDataStrings(num, ',');
	IdentifiersType result;
	char *p;

	for (vector<string>::const_iterator i = stringList.begin(); i != stringList.end(); ++i) {
		long li = strtol((*i).c_str(), &p, 10);

		if (*p != '\0') {
			result.push_back(0);
		} else {
			result.push_back(li);
		}
	}

	return result;
}
DimensionBrowserDocumentation::DimensionBrowserDocumentation(PDatabase database, PDimension dimension, const string& message) :
	BrowserDocumentation(message)
{
	defineDatabase(database);
	defineDimension(dimension);

	ElementsType elements = dimension->getElements(PUser(), false);
	IdentifiersType elementIds;
	elementIds.reserve(elements.size());
	for (ElementsType::const_iterator it = elements.begin(); it != elements.end(); ++it) {
		elementIds.push_back((*it)->getIdentifier());
	}
	defineElements(dimension, elementIds.begin(), elementIds.end(), "@element");
}
Beispiel #7
0
PPaths FileReaderTXT::getDataPaths(int num)
{
	vector<string> stringList = getDataStrings(num, ':');
	PPaths result(new vector<IdentifiersType>());

	for (vector<string>::iterator iset = stringList.begin(); iset != stringList.end(); ++iset) {
		vector<string> subsetStrings;
		IdentifiersType subset;
		splitString(*iset, &subsetStrings, ',');

		char *p;
		IdentifiersType path;
		for (vector<string>::const_iterator i = subsetStrings.begin(); i != subsetStrings.end(); ++i) {
			long li = strtol((*i).c_str(), &p, 10);

			if (*p == 0) {
				path.push_back(li);
			}
		}
		result->push_back(path);
	}

	return result;
}