use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class EditableListOfNodesVM method listOfNodesDropHandler.
@Listen("onDrop = listbox#listOfNodesListbox")
public void listOfNodesDropHandler(DropEvent evt) {
Component dragged = evt.getDragged();
if (dragged instanceof Treeitem) {
Treeitem draggedTreeItem = (Treeitem) dragged;
TreeNode<?> value = draggedTreeItem.getValue();
Object data = value.getData();
if (data instanceof NodeDefinition) {
NodeDefinition nodeDefn = (NodeDefinition) data;
UIOptions uiOpts = getUIOptions();
if (uiOpts.isAssignableTo(nodeDefn, tab)) {
UITab oldTab = uiOpts.getAssignedTab(nodeDefn);
uiOpts.assignToTab(nodeDefn, tab);
Map<String, Object> args = new HashMap<String, Object>();
args.put("oldTab", oldTab);
args.put("newTab", tab);
BindUtils.postGlobalCommand(null, null, "nodeAssignedToTab", args);
} else {
MessageUtil.showWarning("survey.layout.cannot_add_node_to_tab");
}
}
}
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class TabsGroupPanelVM method getNodesPerTab.
public List<NodeDefinition> getNodesPerTab() {
UIOptions uiOpts = getUIOptions();
List<NodeDefinition> result = new ArrayList<NodeDefinition>();
List<NodeDefinition> nodesPerTab = uiOpts.getNodesPerTab(tab, false);
ModelVersion version = getFormVersion();
for (NodeDefinition nodeDefn : nodesPerTab) {
if (version == null || version.isApplicable(nodeDefn)) {
result.add(nodeDefn);
}
}
return result;
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class TabsGroupVM method removeTab.
@Command
@NotifyChange({ "tabs" })
public void removeTab(@BindingParam("tab") UITab tab) {
if (tab.getTabs().isEmpty()) {
SessionStatus sessionStatus = getSessionStatus();
CollectSurvey survey = sessionStatus.getSurvey();
UIOptions uiOpts = survey.getUIOptions();
List<NodeDefinition> nodesPerTab = uiOpts.getNodesPerTab(tab, false);
if (nodesPerTab.isEmpty()) {
UITabSet parent = tab.getParent();
parent.removeTab(tab);
postTabChangedCommand(parent);
} else {
MessageUtil.showWarning("survey.layout.tab.remove.error.associated_nodes_present");
}
} else {
MessageUtil.showWarning("survey.layout.tab.remove.error.nested_tabs_present");
}
}
use of org.openforis.idm.metamodel.NodeDefinition in project collect by openforis.
the class ValidationReportProcess method writeValidationReportLine.
protected void writeValidationReportLine(CollectRecord record, RecordValidationReportItem item) {
String recordKey = validationMessageBuilder.getRecordKey(record);
String phase = record.getStep().name();
String absolutePath = Path.getAbsolutePath(item.getPath());
NodeDefinition nodeDef = record.getSurvey().getSchema().getDefinitionByPath(absolutePath);
String[] line = new String[] { recordKey, phase, nodeDef.getPath(), item.getPath(), item.getPrettyFormatPath(), item.getMessage() };
switch(reportType) {
case CSV:
csvWriter.writeNext(line);
break;
}
}
use of org.openforis.idm.metamodel.NodeDefinition 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;
}
Aggregations