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