Search in sources :

Example 61 with NodeDefinition

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");
            }
        }
    }
}
Also used : UITab(org.openforis.collect.metamodel.ui.UITab) Treeitem(org.zkoss.zul.Treeitem) HashMap(java.util.HashMap) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) Component(org.zkoss.zk.ui.Component) Listen(org.zkoss.zk.ui.select.annotation.Listen)

Example 62 with NodeDefinition

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;
}
Also used : UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) ArrayList(java.util.ArrayList) ModelVersion(org.openforis.idm.metamodel.ModelVersion)

Example 63 with NodeDefinition

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");
    }
}
Also used : SessionStatus(org.openforis.collect.designer.session.SessionStatus) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) UITabSet(org.openforis.collect.metamodel.ui.UITabSet) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 64 with NodeDefinition

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;
    }
}
Also used : NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 65 with NodeDefinition

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;
}
Also used : Survey(org.openforis.idm.metamodel.Survey) CollectSurvey(org.openforis.collect.model.CollectSurvey) CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) Schema(org.openforis.idm.metamodel.Schema) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition) NodeDefinitionVerifier(org.openforis.idm.metamodel.NodeDefinitionVerifier)

Aggregations

NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)173 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)70 ArrayList (java.util.ArrayList)42 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)27 Schema (org.openforis.idm.metamodel.Schema)24 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)22 CollectSurvey (org.openforis.collect.model.CollectSurvey)20 Entity (org.openforis.idm.model.Entity)19 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)16 NodeDefinitionVisitor (org.openforis.idm.metamodel.NodeDefinitionVisitor)14 UITab (org.openforis.collect.metamodel.ui.UITab)12 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)11 Survey (org.openforis.idm.metamodel.Survey)11 Test (org.junit.Test)10 DateAttributeDefinition (org.openforis.idm.metamodel.DateAttributeDefinition)9 ModelVersion (org.openforis.idm.metamodel.ModelVersion)9 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)8 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)8 NumberAttributeDefinition (org.openforis.idm.metamodel.NumberAttributeDefinition)8 Node (org.openforis.idm.model.Node)8