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);
}
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;
}
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;
}
}
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;
}
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;
}
}
Aggregations