Search in sources :

Example 16 with ParsingError

use of org.openforis.collect.io.metadata.parsing.ParsingError in project collect by openforis.

the class SamplingDesignImportTask method validateLine.

protected boolean validateLine(SamplingDesignLine line) throws ParsingException {
    SamplingDesignLineValidator validator = SamplingDesignLineValidator.createInstance(survey);
    validator.validate(line);
    List<ParsingError> errors = validator.getErrors();
    for (ParsingError error : errors) {
        addParsingError(error);
    }
    checkDuplicateLine(line);
    return true;
}
Also used : ParsingError(org.openforis.collect.io.metadata.parsing.ParsingError)

Example 17 with ParsingError

use of org.openforis.collect.io.metadata.parsing.ParsingError in project collect by openforis.

the class SamplingDesignLineValidator method validateSrsId.

protected void validateSrsId(SamplingDesignLine line) {
    String srsId = line.getSrsId();
    SpatialReferenceSystem srs = survey.getSpatialReferenceSystem(srsId);
    if (srs == null) {
        ParsingError error = new ParsingError(ErrorType.INVALID_VALUE, line.getLineNumber(), SamplingDesignFileColumn.SRS_ID.getColumnName(), INVALID_SRS_ID_MESSAGE_KEY);
        error.setMessageArgs(new String[] { srsId });
        errors.add(error);
    }
}
Also used : ParsingError(org.openforis.collect.io.metadata.parsing.ParsingError) SpatialReferenceSystem(org.openforis.idm.metamodel.SpatialReferenceSystem)

Example 18 with ParsingError

use of org.openforis.collect.io.metadata.parsing.ParsingError in project collect by openforis.

the class ParsingErrorProxy method fromList.

public static List<ParsingErrorProxy> fromList(List<ParsingError> items) {
    List<ParsingErrorProxy> result = new ArrayList<ParsingErrorProxy>();
    if (items != null) {
        for (ParsingError item : items) {
            ParsingErrorProxy proxy = new ParsingErrorProxy(item);
            result.add(proxy);
        }
    }
    return result;
}
Also used : ParsingError(org.openforis.collect.io.metadata.parsing.ParsingError) ArrayList(java.util.ArrayList)

Example 19 with ParsingError

use of org.openforis.collect.io.metadata.parsing.ParsingError in project collect by openforis.

the class SpeciesImportProcess method throwDuplicateRowParsingException.

protected void throwDuplicateRowParsingException(SpeciesLine line, SpeciesFileColumn column, Node foundNode) throws ParsingException {
    ParsingError error = new ParsingError(ErrorType.DUPLICATE_VALUE, line.getLineNumber(), column.getColumnName());
    error.setMessageArgs(new String[] { foundNode.getMetadata(LINE_NUMBER_TREE_NODE_METADATA).toString() });
    throw new ParsingException(error);
}
Also used : ParsingError(org.openforis.collect.io.metadata.parsing.ParsingError) ParsingException(org.openforis.collect.io.exception.ParsingException)

Example 20 with ParsingError

use of org.openforis.collect.io.metadata.parsing.ParsingError in project collect by openforis.

the class SpeciesImportProcess method createTaxonGenus.

protected Taxon createTaxonGenus(SpeciesLine line) throws ParsingException {
    String genus = line.getGenus();
    if (genus == null) {
        ParsingError error = new ParsingError(ErrorType.INVALID_VALUE, line.getLineNumber(), SpeciesFileColumn.SCIENTIFIC_NAME.getColumnName(), INVALID_GENUS_NAME_ERROR_MESSAGE_KEY);
        throw new ParsingException(error);
    }
    Taxon taxonFamily = createTaxonFamily(line);
    String normalizedScientificName = StringUtils.join(genus, " ", GENUS_SUFFIX);
    return createTaxon(line, GENUS, taxonFamily, normalizedScientificName);
}
Also used : ParsingError(org.openforis.collect.io.metadata.parsing.ParsingError) ParsingException(org.openforis.collect.io.exception.ParsingException) Taxon(org.openforis.idm.model.species.Taxon)

Aggregations

ParsingError (org.openforis.collect.io.metadata.parsing.ParsingError)46 EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)19 Test (org.junit.Test)17 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)17 CollectRecord (org.openforis.collect.model.CollectRecord)12 ParsingException (org.openforis.collect.io.exception.ParsingException)9 Entity (org.openforis.idm.model.Entity)9 CollectSurvey (org.openforis.collect.model.CollectSurvey)5 RealAttribute (org.openforis.idm.model.RealAttribute)5 DataParsingError (org.openforis.collect.io.data.CSVDataImportJob.DataParsingError)4 RealValue (org.openforis.idm.model.RealValue)4 IOException (java.io.IOException)3 NodeChangeSet (org.openforis.collect.model.NodeChangeSet)3 Survey (org.openforis.idm.metamodel.Survey)3 ArrayList (java.util.ArrayList)2 SpeciesImportProcess (org.openforis.collect.manager.speciesimport.SpeciesImportProcess)2 SpeciesImportStatus (org.openforis.collect.manager.speciesimport.SpeciesImportStatus)2 CollectRecordSummary (org.openforis.collect.model.CollectRecordSummary)2 CodeListItem (org.openforis.idm.metamodel.CodeListItem)2 SpatialReferenceSystem (org.openforis.idm.metamodel.SpatialReferenceSystem)2