use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class UIOptions method getNodesPerTab.
public List<NodeDefinition> getNodesPerTab(UITab tab, boolean includeDescendants) {
List<NodeDefinition> result = new ArrayList<NodeDefinition>();
UITabSet tabSet = tab.getRootTabSet();
Queue<NodeDefinition> queue = new LinkedList<NodeDefinition>();
EntityDefinition rootEntity = getRootEntityDefinition(tabSet);
queue.addAll(rootEntity.getChildDefinitions());
while (!queue.isEmpty()) {
NodeDefinition defn = queue.remove();
UITab nodeTab = getAssignedTab(defn);
boolean nodeInTab = false;
if (nodeTab != null && nodeTab.equals(tab)) {
result.add(defn);
nodeInTab = true;
}
if (defn instanceof EntityDefinition && (includeDescendants || !nodeInTab)) {
queue.addAll(((EntityDefinition) defn).getChildDefinitions());
}
}
return result;
}
use of org.openforis.idm.metamodel.NodeDefinition 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());
}
}
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class UIOptions method removeTabAssociation.
public void removeTabAssociation(UITab tab) {
Deque<UITab> stack = new LinkedList<UITab>();
stack.push(tab);
while (!stack.isEmpty()) {
UITab currentTab = stack.pop();
List<NodeDefinition> nodesPerTab = getNodesPerTab(currentTab, true);
for (NodeDefinition nodeDefn : nodesPerTab) {
performTabAssociationRemoval(nodeDefn);
}
List<UITab> childTabs = currentTab.getTabs();
stack.addAll(childTabs);
}
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class UIOptionsMigrator method findAssignedEntityDefinition.
// protected void createFormFromFormEntity(UITab parentTab, Form parent, EntityDefinition entityDefn) {
// Form form = parent.createForm();
// copyLabels(entityDefn, form);
// form.setEntityId(entityDefn.getId());
// form.setMultiple(true);
// createMainFormSection(form, parentTab.getUIOptions(), entityDefn.getChildDefinitions());
// createInnerForms(parentTab, form);
// parent.addForm(form);
// }
protected EntityDefinition findAssignedEntityDefinition(UITab tab) {
UIOptions oldUIOptions = tab.getUIOptions();
List<NodeDefinition> nodesPerTab = oldUIOptions.getNodesPerTab(tab, false);
if (nodesPerTab.size() == 1) {
NodeDefinition firstNode = nodesPerTab.get(0);
if (firstNode instanceof EntityDefinition) {
return (EntityDefinition) firstNode;
}
}
return null;
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class UIOptionsMigrator method createTableHeadingComponent.
protected UITableHeadingComponent createTableHeadingComponent(UITableHeadingContainer parent, NodeDefinition nodeDefn) throws UIOptionsMigrationException {
UITableHeadingComponent component;
if (nodeDefn instanceof EntityDefinition) {
EntityDefinition entityDefn = (EntityDefinition) nodeDefn;
if (entityDefn.isMultiple()) {
throw new UIOptionsMigrationException("Nested multiple entity inside table layout entity is not supported: " + nodeDefn.getPath());
}
component = parent.createColumnGroup();
UIColumnGroup columnGroup = (UIColumnGroup) component;
columnGroup.setEntityDefinition(entityDefn);
List<NodeDefinition> innerChildDefns = entityDefn.getChildDefinitions();
for (NodeDefinition innerChildDefn : innerChildDefns) {
UITableHeadingComponent innerComponent = createTableHeadingComponent(columnGroup, innerChildDefn);
columnGroup.addHeadingComponent(innerComponent);
}
} else {
component = parent.createColumn();
((UIColumn) component).setAttributeDefinition((AttributeDefinition) nodeDefn);
}
return component;
}
Aggregations