Search in sources :

Example 46 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class AttributeDefinitionFormValidator method validateReferencedAttribute.

private void validateReferencedAttribute(ValidationContext ctx) {
    String referencedAttributePath = getValue(ctx, REFERENCED_ATTRIBUTE_PATH_FIELD, false);
    if (StringUtils.isNotBlank(referencedAttributePath)) {
        AttributeDefinition attrDef = (AttributeDefinition) getEditedNode(ctx);
        CollectSurvey survey = attrDef.getSurvey();
        AttributeDefinition referencedAttribute = (AttributeDefinition) survey.getSchema().getDefinitionByPath(referencedAttributePath);
        if (referencedAttribute == null) {
            addInvalidMessage(ctx, REFERENCED_ATTRIBUTE_PATH_FIELD, Labels.getLabel(REFERENCED_ATTRIBUTE_DELETED_MESSAGE_KEY));
        } else {
            SurveyValidationResult validationResult = new SurveyValidator().validateReferencedKeyAttribute(attrDef, referencedAttribute);
            if (validationResult.getFlag() == Flag.ERROR) {
                addInvalidMessage(ctx, REFERENCED_ATTRIBUTE_PATH_FIELD, Labels.getLabel(validationResult.getMessageKey(), validationResult.getMessageArgs()));
            }
        }
    }
}
Also used : SurveyValidationResult(org.openforis.collect.manager.validation.SurveyValidator.SurveyValidationResult) SurveyValidator(org.openforis.collect.manager.validation.SurveyValidator) AttributeDefinition(org.openforis.idm.metamodel.AttributeDefinition) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 47 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class SRSFormValidator method validateWKT.

private boolean validateWKT(ValidationContext ctx) {
    String wkt = (String) getValue(ctx, WKT_FIELD);
    CollectSurvey survey = getSurvey(ctx);
    SurveyContext context = survey.getContext();
    CoordinateOperations coordinateOperations = context.getCoordinateOperations();
    try {
        coordinateOperations.validateWKT(wkt);
        return true;
    } catch (Exception e) {
        String message = Labels.getLabel("survey.srs.validation.error.invalid_wkt", new String[] { e.getMessage() });
        addInvalidMessage(ctx, WKT_FIELD, message);
        return false;
    }
}
Also used : CoordinateOperations(org.openforis.idm.geospatial.CoordinateOperations) CollectSurvey(org.openforis.collect.model.CollectSurvey) SurveyContext(org.openforis.idm.metamodel.SurveyContext)

Example 48 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class SurveyFileFormValidator method loadSurveyFilesDifferentFromThis.

private List<SurveyFile> loadSurveyFilesDifferentFromThis(ValidationContext ctx) {
    List<SurveyFile> result = new ArrayList<SurveyFile>();
    SurveyFileVM vm = getVM(ctx);
    CollectSurvey survey = vm.getSurvey();
    SurveyManager surveyManager = getSurveyManager(ctx);
    List<SurveyFile> surveyFiles = surveyManager.loadSurveyFileSummaries(survey);
    SurveyFile editedSurveyFile = vm.getEditedItem();
    for (SurveyFile surveyFile : surveyFiles) {
        if (!surveyFile.getId().equals(editedSurveyFile.getId())) {
            result.add(surveyFile);
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) SurveyFile(org.openforis.collect.model.SurveyFile) SurveyFileVM(org.openforis.collect.designer.viewmodel.SurveyFileVM) CollectSurvey(org.openforis.collect.model.CollectSurvey) SurveyManager(org.openforis.collect.manager.SurveyManager)

Example 49 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class UnitFormValidator method validateNameUniqueness.

protected boolean validateNameUniqueness(ValidationContext ctx) {
    SurveyObjectBaseVM<Unit> viewModel = getVM(ctx);
    Unit editedItem = viewModel.getEditedItem();
    CollectSurvey survey = viewModel.getSurvey();
    String name = (String) getValue(ctx, NAME_FIELD);
    Unit existingItem = survey.getUnit(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 : Unit(org.openforis.idm.metamodel.Unit) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Example 50 with CollectSurvey

use of org.openforis.collect.model.CollectSurvey in project collect by openforis.

the class NodeDefinitionFormObject method getUIOptions.

protected UIOptions getUIOptions(NodeDefinition nodeDefn) {
    CollectSurvey survey = (CollectSurvey) nodeDefn.getSurvey();
    UIOptions uiOptions = survey.getUIOptions();
    return uiOptions;
}
Also used : UIOptions(org.openforis.collect.metamodel.ui.UIOptions) CollectSurvey(org.openforis.collect.model.CollectSurvey)

Aggregations

CollectSurvey (org.openforis.collect.model.CollectSurvey)329 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)53 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)40 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)38 CollectRecord (org.openforis.collect.model.CollectRecord)30 RecordFilter (org.openforis.collect.model.RecordFilter)27 Transactional (org.springframework.transaction.annotation.Transactional)26 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)25 ArrayList (java.util.ArrayList)23 File (java.io.File)21 CollectAnnotations (org.openforis.collect.metamodel.CollectAnnotations)21 Secured (org.springframework.security.access.annotation.Secured)20 User (org.openforis.collect.model.User)19 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)19 SessionState (org.openforis.collect.web.session.SessionState)18 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)17 Test (org.junit.Test)16 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)15 CodeList (org.openforis.idm.metamodel.CodeList)15 Schema (org.openforis.idm.metamodel.Schema)15