Search in sources :

Example 21 with ModelVersion

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

the class EntityProxy method isApplicable.

protected boolean isApplicable(NodeDefinition childDefinition) {
    Record record = entity.getRecord();
    ModelVersion version = record.getVersion();
    return version == null || version.isApplicable(childDefinition);
}
Also used : Record(org.openforis.idm.model.Record) ModelVersion(org.openforis.idm.metamodel.ModelVersion)

Example 22 with ModelVersion

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

the class XMLDataImportProcess method createRecordSummary.

protected CollectRecord createRecordSummary(CollectRecord record) {
    CollectSurvey survey = (CollectSurvey) record.getSurvey();
    ModelVersion version = record.getVersion();
    String versionName = version != null ? version.getName() : null;
    CollectRecord result = new CollectRecord(survey, versionName, record.getRootEntity().getName());
    result.setCreatedBy(record.getCreatedBy());
    result.setCreationDate(record.getCreationDate());
    result.setEntityCounts(record.getEntityCounts());
    result.setErrors(record.getErrors());
    result.setId(record.getId());
    result.setMissing(record.getMissing());
    result.setModifiedBy(record.getModifiedBy());
    result.setModifiedDate(record.getModifiedDate());
    result.setRootEntityKeyValues(record.getRootEntityKeyValues());
    result.setSkipped(record.getSkipped());
    result.setState(record.getState());
    result.setStep(record.getStep());
    return result;
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) ModelVersion(org.openforis.idm.metamodel.ModelVersion) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 23 with ModelVersion

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

the class CodeValueFKColumnValueExtractor method extractValue.

@Override
public Object extractValue(Node<?> context) {
    CodeAttributeDefinition defn = (CodeAttributeDefinition) column.getNodeDefinition();
    Node<?> valNode = super.extractValueNode(context);
    if (valNode != null && valNode instanceof CodeAttribute) {
        return extractValue((CodeAttribute) valNode);
    } else if (column.getDefaultCodeValue() != null) {
        ModelVersion version = context.getRecord().getVersion();
        return getDefaultCodeItemId(((CodeAttributeDefinition) defn).getList(), version);
    } else {
        return null;
    }
}
Also used : CodeAttributeDefinition(org.openforis.idm.metamodel.CodeAttributeDefinition) CodeAttribute(org.openforis.idm.model.CodeAttribute) ModelVersion(org.openforis.idm.metamodel.ModelVersion)

Example 24 with ModelVersion

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

the class ModelVersionFormValidator method validateDateUniqueness.

private boolean validateDateUniqueness(ValidationContext ctx) {
    SurveyObjectBaseVM<ModelVersion> viewModel = getVM(ctx);
    ModelVersion editedItem = viewModel.getEditedItem();
    CollectSurvey survey = viewModel.getSurvey();
    Date date = getValue(ctx, DATE_FIELD);
    for (ModelVersion modelVersion : survey.getVersions()) {
        if (modelVersion.getId() != editedItem.getId() && Dates.compareDateOnly(modelVersion.getDate(), date) == 0) {
            String message = Labels.getLabel(ITEM_DATE_ALREADY_DEFINED_MESSAGE_KEY);
            addInvalidMessage(ctx, DATE_FIELD, message);
            return false;
        }
    }
    return true;
}
Also used : ModelVersion(org.openforis.idm.metamodel.ModelVersion) CollectSurvey(org.openforis.collect.model.CollectSurvey) Date(java.util.Date)

Example 25 with ModelVersion

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

the class ModelVersionFormValidator method validateNameUniqueness.

protected boolean validateNameUniqueness(ValidationContext ctx) {
    SurveyObjectBaseVM<ModelVersion> viewModel = getVM(ctx);
    ModelVersion editedItem = viewModel.getEditedItem();
    CollectSurvey survey = viewModel.getSurvey();
    String name = getValue(ctx, NAME_FIELD);
    ModelVersion existingItem = survey.getVersion(name);
    if (existingItem != null && existingItem.getId() != editedItem.getId()) {
        String message = Labels.getLabel(ITEM_NAME_ALREADY_DEFINED_MESSAGE_KEY);
        addInvalidMessage(ctx, NAME_FIELD, message);
        return false;
    } else {
        return true;
    }
}
Also used : ModelVersion(org.openforis.idm.metamodel.ModelVersion) CollectSurvey(org.openforis.collect.model.CollectSurvey)

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