use of org.openforis.idm.metamodel.Schema in project collect by openforis.
the class NumericAttributeVM method getOldNodeDefinition.
protected NodeDefinition getOldNodeDefinition() {
SessionStatus sessionStatus = getSessionStatus();
Integer publishedSurveyId = sessionStatus.getPublishedSurveyId();
if (publishedSurveyId != null) {
CollectSurvey publishedSurvey = surveyManager.getById(publishedSurveyId);
Schema schema = publishedSurvey.getSchema();
int nodeId = editedItem.getId();
NodeDefinition oldDefn = schema.getDefinitionById(nodeId);
return oldDefn;
} else {
return null;
}
}
use of org.openforis.idm.metamodel.Schema in project collect by openforis.
the class PreviewPreferencesVM method getRootEntities.
public List<EntityDefinition> getRootEntities() {
CollectSurvey survey = getSurvey();
if (survey == null) {
// TODO session expired...?
return null;
} else {
Schema schema = survey.getSchema();
List<EntityDefinition> result = schema.getRootEntityDefinitions();
return result;
}
}
use of org.openforis.idm.metamodel.Schema in project collect by openforis.
the class NodeDefinitionFormValidator method isNameUnique.
protected boolean isNameUnique(ValidationContext ctx, NodeDefinition defn, String name) {
EntityDefinition parentDefn = getParentEntity(ctx);
NodeDefinition nodeInPath = null;
try {
if (parentDefn != null) {
nodeInPath = parentDefn.getChildDefinition(name);
} else {
Schema schema = defn.getSchema();
nodeInPath = schema.getRootEntityDefinition(name);
}
} catch (IllegalArgumentException e) {
// sibling not found
}
return nodeInPath == null || nodeInPath.getId() == defn.getId();
}
use of org.openforis.idm.metamodel.Schema in project collect by openforis.
the class SurveyController method createEmptySurvey.
private CollectSurvey createEmptySurvey(String name, String langCode) {
// create empty survey
CollectSurvey survey = surveyManager.createTemporarySurvey(name, langCode);
// add default root entity
Schema schema = survey.getSchema();
EntityDefinition rootEntity = schema.createEntityDefinition();
rootEntity.setMultiple(true);
rootEntity.setName(DEFAULT_ROOT_ENTITY_NAME);
schema.addRootEntityDefinition(rootEntity);
// create root tab set
UIOptions uiOptions = survey.getUIOptions();
UITabSet rootTabSet = uiOptions.createRootTabSet((EntityDefinition) rootEntity);
UITab mainTab = uiOptions.getMainTab(rootTabSet);
mainTab.setLabel(langCode, DEFAULT_MAIN_TAB_LABEL);
SurveyObjectsGenerator surveyObjectsGenerator = new SurveyObjectsGenerator();
surveyObjectsGenerator.addPredefinedObjects(survey);
return survey;
}
use of org.openforis.idm.metamodel.Schema in project collect by openforis.
the class RecordIndexManager method hasIndexableNodes.
public boolean hasIndexableNodes(Survey survey) {
Schema schema = survey.getSchema();
List<EntityDefinition> rootEntityDefinitions = schema.getRootEntityDefinitions();
for (EntityDefinition entityDefn : rootEntityDefinitions) {
boolean hasIndexableNodes = hasIndexableNodes(entityDefn);
if (hasIndexableNodes) {
return true;
}
}
return false;
}
Aggregations