Search in sources :

Example 51 with EntityDefinition

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

the class RecordController method startValidationResportJob.

@RequestMapping(value = "survey/{surveyId}/data/records/validationreport", method = POST)
@ResponseBody
public JobProxy startValidationResportJob(@PathVariable("surveyId") int surveyId) {
    User user = sessionManager.getLoggedUser();
    Locale locale = sessionManager.getSessionState().getLocale();
    CollectSurvey survey = surveyManager.getById(surveyId);
    EntityDefinition rootEntityDef = survey.getSchema().getFirstRootEntityDefinition();
    ValidationReportJob job = jobManager.createJob(ValidationReportJob.class);
    Input input = new Input();
    input.setLocale(locale);
    input.setReportType(ReportType.CSV);
    RecordFilter recordFilter = createRecordFilter(survey, user, userGroupManager, rootEntityDef.getId(), false);
    input.setRecordFilter(recordFilter);
    job.setInput(input);
    this.validationReportJob = job;
    jobManager.start(job);
    return new JobProxy(job);
}
Also used : Locale(java.util.Locale) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Input(org.openforis.collect.manager.ValidationReportJob.Input) CSVDataImportInput(org.openforis.collect.io.data.CSVDataImportJob.CSVDataImportInput) User(org.openforis.collect.model.User) JobProxy(org.openforis.concurrency.proxy.JobProxy) ValidationReportJob(org.openforis.collect.manager.ValidationReportJob) CollectSurvey(org.openforis.collect.model.CollectSurvey) RecordFilter(org.openforis.collect.model.RecordFilter) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 52 with EntityDefinition

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

the class SchemaLayoutSimpleVM method afterCompose.

@AfterCompose
public void afterCompose(@ContextParam(ContextType.VIEW) Component view) {
    // if one root entity is defined, select it
    List<EntityDefinition> rootEntities = getRootEntities();
    if (rootEntities.size() == 1) {
        EntityDefinition mainRootEntity = rootEntities.get(0);
        performNodeTreeFilterChange(mainRootEntity, null);
    }
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) AfterCompose(org.zkoss.bind.annotation.AfterCompose)

Example 53 with EntityDefinition

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

the class SchemaLayoutVM method getRootTabSet.

protected UITabSet getRootTabSet(Treeitem treeItem) {
    if (treeItem != null) {
        TreeNode<NodeDefinition> treeNode = treeItem.getValue();
        NodeDefinition nodeDefn = treeNode.getData();
        UIOptions uiOptions = survey.getUIOptions();
        EntityDefinition rootEntity = nodeDefn.getRootEntity();
        return uiOptions.getAssignedRootTabSet(rootEntity);
    } else {
        return null;
    }
}
Also used : EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) UIOptions(org.openforis.collect.metamodel.ui.UIOptions) NodeDefinition(org.openforis.idm.metamodel.NodeDefinition)

Example 54 with EntityDefinition

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

the class CSVDataImportJobIntegrationTest method validEntityPositionTest.

@Test
public void validEntityPositionTest() throws Exception {
    {
        CollectRecord record = createTestRecord(survey, "10_111");
        recordDao.insert(record);
    }
    {
        CollectRecord record = createTestRecord(survey, "10_114");
        recordDao.insert(record);
    }
    EntityDefinition clusterDefn = survey.getSchema().getRootEntityDefinition("cluster");
    EntityDefinition timeStudyDefn = clusterDefn.getChildDefinition("time_study", EntityDefinition.class);
    CSVDataImportJob process = importCSVFile(VALID_ENTITY_POSITION_TEST_CSV, timeStudyDefn.getId());
    assertEquals(Status.COMPLETED, process.getStatus());
    assertTrue(process.getParsingErrors().isEmpty());
    {
        CollectRecord reloadedRecord = loadRecord("10_111");
        Entity cluster = reloadedRecord.getRootEntity();
        {
            Entity timeStudy = (Entity) cluster.getChild("time_study", 0);
            DateAttribute date = (DateAttribute) timeStudy.getChild("date");
            Date dateVal = date.getValue();
            assertEquals(Integer.valueOf(2013), dateVal.getYear());
            assertEquals(Integer.valueOf(2), dateVal.getMonth());
            assertEquals(Integer.valueOf(24), dateVal.getDay());
        }
        {
            Entity timeStudy = (Entity) cluster.getChild("time_study", 1);
            DateAttribute date = (DateAttribute) timeStudy.getChild("date");
            Date dateVal = date.getValue();
            assertEquals(Integer.valueOf(2013), dateVal.getYear());
            assertEquals(Integer.valueOf(3), dateVal.getMonth());
            assertEquals(Integer.valueOf(15), dateVal.getDay());
        }
    }
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Entity(org.openforis.idm.model.Entity) Date(org.openforis.idm.model.Date) DateAttribute(org.openforis.idm.model.DateAttribute) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 55 with EntityDefinition

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

the class CSVDataImportJobIntegrationTest method nestedEntityTest.

@Test
public void nestedEntityTest() throws Exception {
    CollectRecord record = createTestRecord(survey, "10_114");
    recordDao.insert(record);
    EntityDefinition clusterDefn = survey.getSchema().getRootEntityDefinition("cluster");
    EntityDefinition plotDefn = (EntityDefinition) clusterDefn.getChildDefinition("plot");
    CSVDataImportJob process = importCSVFile(VALID_NESTED_ENTITY_TEST_CSV, plotDefn.getId());
    assertTrue(process.isCompleted());
    assertTrue(process.getParsingErrors().isEmpty());
    CollectRecord reloadedRecord = recordDao.load(survey, record.getId(), Step.ENTRY);
    Entity reloadedCluster = reloadedRecord.getRootEntity();
    {
        Entity plot = reloadedCluster.findChildEntitiesByKeys("plot", "1", "A").get(0);
        CodeAttribute landUse = (CodeAttribute) plot.getChild("land_use");
        assertEquals("2", landUse.getValue().getCode());
    }
    {
        Entity plot = reloadedCluster.findChildEntitiesByKeys("plot", "2", "B").get(0);
        CodeAttribute landUse = (CodeAttribute) plot.getChild("land_use");
        assertEquals("3", landUse.getValue().getCode());
    }
}
Also used : CollectRecord(org.openforis.collect.model.CollectRecord) EntityDefinition(org.openforis.idm.metamodel.EntityDefinition) Entity(org.openforis.idm.model.Entity) CodeAttribute(org.openforis.idm.model.CodeAttribute) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Aggregations

EntityDefinition (org.openforis.idm.metamodel.EntityDefinition)235 NodeDefinition (org.openforis.idm.metamodel.NodeDefinition)70 AttributeDefinition (org.openforis.idm.metamodel.AttributeDefinition)47 Schema (org.openforis.idm.metamodel.Schema)46 ArrayList (java.util.ArrayList)44 Test (org.junit.Test)38 Entity (org.openforis.idm.model.Entity)36 CollectRecord (org.openforis.collect.model.CollectRecord)30 CollectSurvey (org.openforis.collect.model.CollectSurvey)28 CollectIntegrationTest (org.openforis.collect.CollectIntegrationTest)24 CodeAttributeDefinition (org.openforis.idm.metamodel.CodeAttributeDefinition)24 ParsingError (org.openforis.collect.io.metadata.parsing.ParsingError)19 UIOptions (org.openforis.collect.metamodel.ui.UIOptions)18 UITab (org.openforis.collect.metamodel.ui.UITab)16 NumberAttributeDefinition (org.openforis.idm.metamodel.NumberAttributeDefinition)14 NumericAttributeDefinition (org.openforis.idm.metamodel.NumericAttributeDefinition)13 CoordinateAttributeDefinition (org.openforis.idm.metamodel.CoordinateAttributeDefinition)12 RecordFilter (org.openforis.collect.model.RecordFilter)11 SurveyObject (org.openforis.idm.metamodel.SurveyObject)10 BooleanAttributeDefinition (org.openforis.idm.metamodel.BooleanAttributeDefinition)9