use of org.openforis.idm.metamodel.NodeDefinitionVerifier in project collect by openforis.
the class CodeListManager method isInUse.
public boolean isInUse(final CodeList list) {
Survey survey = list.getSurvey();
Schema schema = survey.getSchema();
NodeDefinition attrDefnUsingCodeList = schema.findNodeDefinition(new NodeDefinitionVerifier() {
@Override
public boolean verify(NodeDefinition definition) {
return definition instanceof CodeAttributeDefinition && ((CodeAttributeDefinition) definition).getList() == list;
}
});
return attrDefnUsingCodeList != null;
}
use of org.openforis.idm.metamodel.NodeDefinitionVerifier in project collect by openforis.
the class UIOptions method getParentEntityForAssignedNodes.
public EntityDefinition getParentEntityForAssignedNodes(final UITab tab) {
UITabSet root = tab.getRootTabSet();
EntityDefinition rootEntity = getRootEntityDefinition(root);
if (tab.getDepth() == 1) {
return rootEntity;
}
EntityDefinition tabEntityDefn = rootEntity.getSchema().findNodeDefinition(new NodeDefinitionVerifier() {
public boolean verify(NodeDefinition nodeDefn) {
if (nodeDefn instanceof EntityDefinition) {
EntityDefinition entityDefn = (EntityDefinition) nodeDefn;
UITab assignedTab = getAssignedTab(entityDefn, false);
return assignedTab == tab;
} else {
return false;
}
}
});
if (tabEntityDefn != null) {
return tabEntityDefn;
} else {
UITabSet parentTab = tab.getParent();
if (parentTab != null && parentTab instanceof UITab) {
return getParentEntityForAssignedNodes((UITab) parentTab);
} else {
throw new IllegalStateException("Parent entity for assigned nodes not found for tab: " + tab.getName());
}
}
}
Aggregations