Search in sources :

Example 86 with CollectSurvey

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

the class SurveyManagerIntegrationTest method publishSurveyTest.

@Test
public void publishSurveyTest() throws SurveyImportException {
    CollectSurvey surveyWork = surveyManager.createTemporarySurveyFromPublished(survey.getUri(), adminUser);
    assertEquals("Archenland NFI", surveyWork.getProjectName());
    surveyWork.setProjectName("en", "New Project Name");
    surveyManager.publish(surveyWork, adminUser);
    CollectSurvey survey = surveyManager.getByUri(surveyWork.getUri());
    assertFalse(survey.isTemporary());
    assertEquals("New Project Name", survey.getProjectName("en"));
}
Also used : CollectSurvey(org.openforis.collect.model.CollectSurvey) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 87 with CollectSurvey

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

the class SurveyManagerIntegrationTest method duplicateSurveySamplingDesignForEditTest.

@Test
public void duplicateSurveySamplingDesignForEditTest() {
    insertTestSamplingDesign();
    CollectSurvey surveyWork = surveyManager.createTemporarySurveyFromPublished(survey.getUri(), adminUser);
    SamplingDesignSummaries summaries = samplingDesignManager.loadBySurvey(surveyWork.getId());
    List<SamplingDesignItem> records = summaries.getRecords();
    assertEquals(3, records.size());
    {
        SamplingDesignItem item = records.get(0);
        assertEquals(Arrays.asList("7_81"), item.getLevelCodes());
        assertEquals("EPSG:21035", item.getSrsId());
        assertEquals(Double.valueOf(792200d), item.getX());
        assertEquals(Double.valueOf(9484420d), item.getY());
    }
    {
        SamplingDesignItem item = records.get(1);
        assertEquals(Arrays.asList("7_81", "2"), item.getLevelCodes());
        assertEquals("EPSG:21035", item.getSrsId());
        assertEquals(Double.valueOf(792200d), item.getX());
        assertEquals(Double.valueOf(9484420d), item.getY());
    }
    {
        SamplingDesignItem item = records.get(2);
        assertEquals(Arrays.asList("7_81", "3"), item.getLevelCodes());
        assertEquals("EPSG:21035", item.getSrsId());
        assertEquals(Double.valueOf(792200d), item.getX());
        assertEquals(Double.valueOf(9484670d), item.getY());
    }
}
Also used : SamplingDesignSummaries(org.openforis.collect.model.SamplingDesignSummaries) CollectSurvey(org.openforis.collect.model.CollectSurvey) SamplingDesignItem(org.openforis.collect.model.SamplingDesignItem) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 88 with CollectSurvey

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

the class SurveyManagerIntegrationTest method createTemporarySurveyFromPublishedTest.

@Test
public void createTemporarySurveyFromPublishedTest() {
    CollectSurvey surveyWork = surveyManager.createTemporarySurveyFromPublished(survey.getUri(), adminUser);
    assertTrue(surveyWork.isTemporary());
    {
        CodeList list = survey.getCodeList("admin_unit");
        List<CodeListItem> rootItems = codeListManager.loadRootItems(list);
        assertEquals(8, rootItems.size());
        List<CodeListItem> childItems = codeListManager.loadChildItems(rootItems.get(0));
        assertEquals(3, childItems.size());
    }
    {
        CodeList list = surveyWork.getCodeList("admin_unit");
        List<CodeListItem> rootItems = codeListManager.loadRootItems(list);
        assertEquals(8, rootItems.size());
        List<CodeListItem> childItems = codeListManager.loadChildItems(rootItems.get(0));
        assertEquals(3, childItems.size());
    }
}
Also used : CodeList(org.openforis.idm.metamodel.CodeList) CodeList(org.openforis.idm.metamodel.CodeList) List(java.util.List) CollectSurvey(org.openforis.collect.model.CollectSurvey) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 89 with CollectSurvey

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

the class SurveyValidatorIntegrationTest method invalidSurveyImportTest.

@Test(expected = SurveyValidationException.class)
public void invalidSurveyImportTest() throws SurveyValidationException, SurveyImportException {
    InputStream is = ClassLoader.getSystemResourceAsStream("invalid.test.idm.xml");
    CollectSurvey survey = surveyManager.importModel(is, "test_survey", true);
    assertNull(survey);
}
Also used : InputStream(java.io.InputStream) CollectSurvey(org.openforis.collect.model.CollectSurvey) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

Example 90 with CollectSurvey

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

the class SurveyValidatorIntegrationTest method validSurveyUnmarshallTest.

@Test
public void validSurveyUnmarshallTest() throws SurveyValidationException, SurveyImportException {
    InputStream is = ClassLoader.getSystemResourceAsStream("test.idm.xml");
    CollectSurvey survey = surveyManager.importModel(is, "test_survey", false);
    assertNotNull(survey);
}
Also used : InputStream(java.io.InputStream) CollectSurvey(org.openforis.collect.model.CollectSurvey) CollectIntegrationTest(org.openforis.collect.CollectIntegrationTest) Test(org.junit.Test)

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