Search in sources :

Example 6 with ModelVersion

use of org.openforis.idm.metamodel.ModelVersion in project collect by openforis.

the class DataHandler method extractVersionName.

protected String extractVersionName(Attributes attributes) {
    String versionName = null;
    String recordVersionName = attributes.getValue(ATTRIBUTE_VERSION);
    if (StringUtils.isNotBlank(recordVersionName)) {
        ModelVersion recordVersion = recordSurvey.getVersion(recordVersionName);
        if (recordVersion == null) {
            throw new IllegalArgumentException(String.format("Record version with name %s not found in the survey", recordVersionName));
        }
        int versionId = recordVersion.getId();
        ModelVersion version = currentSurvey.getVersionById(versionId);
        if (version == null) {
            throw new IllegalArgumentException(String.format("Record version with id %d not found in the current survey", versionId));
        }
        versionName = version.getName();
    }
    return versionName;
}
Also used : ModelVersion(org.openforis.idm.metamodel.ModelVersion)

Example 7 with ModelVersion

use of org.openforis.idm.metamodel.ModelVersion in project collect by openforis.

the class SchemaLayoutVM method nodeSelected.

@Command
@NotifyChange({ "rootTabSet" })
public void nodeSelected(@BindingParam("node") Treeitem node) {
    List<ModelVersion> versions = survey.getVersions();
    setFormVersion(versions.isEmpty() ? null : versions.get(0));
    UITabSet tabSet = getRootTabSet(node);
    refreshTabSetLayoutPanel(tabSet, false);
    this.rootTabSet = tabSet;
    dispatchTabSetChangedCommand();
}
Also used : UITabSet(org.openforis.collect.metamodel.ui.UITabSet) ModelVersion(org.openforis.idm.metamodel.ModelVersion) NotifyChange(org.zkoss.bind.annotation.NotifyChange) Command(org.zkoss.bind.annotation.Command) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand)

Example 8 with ModelVersion

use of org.openforis.idm.metamodel.ModelVersion in project collect by openforis.

the class RecordUpdaterTest method addModelVersion.

private void addModelVersion(CollectSurvey survey, String name, String date) {
    ModelVersion version = survey.createModelVersion();
    version.setName(name);
    version.setDate(Dates.parseDate(date));
    survey.addVersion(version);
}
Also used : ModelVersion(org.openforis.idm.metamodel.ModelVersion)

Example 9 with ModelVersion

use of org.openforis.idm.metamodel.ModelVersion in project collect by openforis.

the class SurveyEditVM method openPreviewPopUp.

private void openPreviewPopUp() {
    if (isSingleRootEntityDefined() && survey.getVersions().size() <= 1) {
        ModelVersion version = survey.getVersions().isEmpty() ? null : survey.getVersions().get(0);
        openPreviewPopUp(version, survey.getSchema().getFirstRootEntityDefinition());
    } else {
        openPreviewPreferencesPopUp();
    }
}
Also used : ModelVersion(org.openforis.idm.metamodel.ModelVersion)

Example 10 with ModelVersion

use of org.openforis.idm.metamodel.ModelVersion in project collect by openforis.

the class SchemaVM method versionSelected.

@Command
public void versionSelected(@BindingParam("version") Object version) {
    ModelVersion modelVersion;
    if (version == FormObject.VERSION_EMPTY_SELECTION) {
        modelVersion = null;
    } else {
        modelVersion = (ModelVersion) version;
    }
    nodesTreeFilterChanged(selectedRootEntity, modelVersion);
}
Also used : ModelVersion(org.openforis.idm.metamodel.ModelVersion) GlobalCommand(org.zkoss.bind.annotation.GlobalCommand) Command(org.zkoss.bind.annotation.Command)

Aggregations

ModelVersion (org.openforis.idm.metamodel.ModelVersion)40 ArrayList (java.util.ArrayList)9 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)9 Record (org.openforis.idm.model.Record)9 CollectSurvey (org.openforis.collect.model.CollectSurvey)7 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)7 CodeListItem (org.openforis.idm.metamodel.CodeListItem)7 CodeList (org.openforis.idm.metamodel.CodeList)5 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)5 ExternalCodeListItem (org.openforis.idm.metamodel.ExternalCodeListItem)5 PersistedCodeListItem (org.openforis.idm.metamodel.PersistedCodeListItem)5 CodeAttribute (org.openforis.idm.model.CodeAttribute)5 Code (org.openforis.idm.model.Code)4 Entity (org.openforis.idm.model.Entity)4 SessionStatus (org.openforis.collect.designer.session.SessionStatus)2 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)2 Survey (org.openforis.idm.metamodel.Survey)2 NodePointer (org.openforis.idm.model.NodePointer)2 Command (org.zkoss.bind.annotation.Command)2 GlobalCommand (org.zkoss.bind.annotation.GlobalCommand)2