Search in sources :

Example 1 with UpdateGeoObjectActionDTO

use of org.commongeoregistry.adapter.action.geoobject.UpdateGeoObjectActionDTO in project geoprism-registry by terraframe.

the class UpdateGeoObjectAction method buildFromDTO.

@Override
protected void buildFromDTO(AbstractActionDTO dto) {
    super.buildFromDTO(dto);
    UpdateGeoObjectActionDTO castedDTO = (UpdateGeoObjectActionDTO) dto;
    this.setGeoObjectJson(castedDTO.getGeoObject().toString());
}
Also used : UpdateGeoObjectActionDTO(org.commongeoregistry.adapter.action.geoobject.UpdateGeoObjectActionDTO)

Example 2 with UpdateGeoObjectActionDTO

use of org.commongeoregistry.adapter.action.geoobject.UpdateGeoObjectActionDTO in project geoprism-registry by terraframe.

the class ChangeRequestTestDataGenerator method genChangeRequest.

@Transaction
private static void genChangeRequest(String genKey, Instant when, boolean includeRemove, boolean includeAdd) {
    ServerGeoObjectService service = new ServerGeoObjectService(new AllowAllGeoObjectPermissionService());
    GeoObject goNewChild = ServiceFactory.getAdapter().newGeoObjectInstance("Cambodia_District");
    goNewChild.setCode(genKey + "_CODE");
    goNewChild.setDisplayLabel(LocalizedValue.DEFAULT_LOCALE, genKey + "_LABEL");
    goNewChild.setWKTGeometry("MULTIPOLYGON (((10000 10000, 12300 40000, 16800 50000, 12354 60000, 13354 60000, 17800 50000, 13300 40000, 11000 10000, 10000 10000)))");
    ServerGeoObjectIF testAddChildParent = service.getGeoObjectByCode("855 01", "Cambodia_Province");
    ServerGeoObjectIF testAddChild = service.getGeoObjectByCode("855 0109", "Cambodia_District");
    List<AbstractActionDTO> actions = new ArrayList<AbstractActionDTO>();
    /*
     * Remove Child
     */
    if (includeRemove) {
        RemoveChildActionDTO removeChild = new RemoveChildActionDTO();
        removeChild.setChildCode(testAddChild.getUid());
        removeChild.setChildTypeCode(testAddChild.getType().getCode());
        removeChild.setParentCode(testAddChildParent.getUid());
        removeChild.setParentTypeCode(testAddChildParent.getType().getCode());
        removeChild.setHierarchyCode(LocatedIn.class.getSimpleName());
        removeChild.setCreateActionDate(Date.from(when.minus(9, ChronoUnit.HOURS)));
        removeChild.setContributorNotes("Removing the village from the district");
        actions.add(removeChild);
    }
    /*
     * Add Child
     */
    if (includeAdd) {
        AddChildActionDTO addChild = new AddChildActionDTO();
        addChild.setChildCode(testAddChild.getUid());
        addChild.setChildTypeCode(testAddChild.getType().getCode());
        addChild.setParentCode(testAddChildParent.getUid());
        addChild.setParentTypeCode(testAddChildParent.getType().getCode());
        addChild.setHierarchyCode(LocatedIn.class.getSimpleName());
        addChild.setCreateActionDate(Date.from(when.minus(10, ChronoUnit.HOURS)));
        addChild.setContributorNotes("Adding the village as a child of the district");
        actions.add(addChild);
    }
    /*
     * Create a new GeoObject
     */
    CreateGeoObjectActionDTO create = new CreateGeoObjectActionDTO();
    create.setGeoObject(goNewChild.toJSON());
    create.setCreateActionDate(Date.from(when.minus(8, ChronoUnit.HOURS)));
    create.setContributorNotes("Creating a new village");
    actions.add(create);
    /*
     * Update the previously created GeoObject
     */
    final String NEW_DISPLAY_LABEL = genKey + "_NEW_DISPLAY_LABEL";
    goNewChild.setDisplayLabel(LocalizedValue.DEFAULT_LOCALE, NEW_DISPLAY_LABEL);
    UpdateGeoObjectActionDTO update = new UpdateGeoObjectActionDTO();
    update.setGeoObject(goNewChild.toJSON());
    update.setCreateActionDate(Date.from(when.minus(7, ChronoUnit.HOURS)));
    update.setContributorNotes("Updating the village. Adding a better name and stuff");
    actions.add(update);
    // Serialize the actions
    String sActions = AbstractActionDTO.serializeActions(actions).toString();
    submitChangeRequest(sActions);
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) RemoveChildActionDTO(org.commongeoregistry.adapter.action.tree.RemoveChildActionDTO) UpdateGeoObjectActionDTO(org.commongeoregistry.adapter.action.geoobject.UpdateGeoObjectActionDTO) LocatedIn(com.runwaysdk.system.gis.geo.LocatedIn) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ArrayList(java.util.ArrayList) AbstractActionDTO(org.commongeoregistry.adapter.action.AbstractActionDTO) AddChildActionDTO(org.commongeoregistry.adapter.action.tree.AddChildActionDTO) CreateGeoObjectActionDTO(org.commongeoregistry.adapter.action.geoobject.CreateGeoObjectActionDTO) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) AllowAllGeoObjectPermissionService(net.geoprism.registry.permission.AllowAllGeoObjectPermissionService) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 3 with UpdateGeoObjectActionDTO

use of org.commongeoregistry.adapter.action.geoobject.UpdateGeoObjectActionDTO in project geoprism-registry by terraframe.

the class GovernanceTest method testActionSerialization.

/**
 * Tests serialization on the DTOs and also conversion to/from DTO
 */
@Test
public void testActionSerialization() {
    TestGeoObjectInfo testGo = FastTestDataset.CAMBODIA;
    // GeoObjectOverTime go = testGo.asGeoObject();
    GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.CAMBODIA.getCode(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
    testGo.setRegistryId(goTime.getUid());
    /*
     * UpdateGeoObject
     */
    UpdateGeoObjectActionDTO updateDTO = new UpdateGeoObjectActionDTO();
    updateDTO.setGeoObject(goTime.toJSON());
    updateDTO.setCreateActionDate(Date.from(Instant.now().minus(6, ChronoUnit.HOURS)));
    updateDTO.setContributorNotes("UPDATE_CONTRIB_NOTES");
    updateDTO.setMaintainerNotes("UPDATE_MAINTAIN_NOTES");
    String updateJson = updateDTO.toJSON().toString();
    String updateJson2 = AbstractActionDTO.parseAction(updateJson).toJSON().toString();
    Assert.assertEquals(updateJson, updateJson2);
    UpdateGeoObjectAction updateRA = (UpdateGeoObjectAction) AbstractAction.dtoToRegistry(updateDTO);
    GeoObjectOverTime updateRAGO = GeoObjectOverTime.fromJSON(testData.adapter, updateRA.getGeoObjectJson());
    // testGo.assertEquals(updateRAGO);
    Assert.assertEquals(updateDTO.getContributorNotes(), updateRA.getContributorNotes());
    Assert.assertEquals(updateDTO.getMaintainerNotes(), updateRA.getMaintainerNotes());
    Assert.assertEquals(updateDTO.getApiVersion(), updateRA.getApiVersion());
// Assert.assertEquals(updateDTO.getCreateActionDate().getTime(),
// updateRA.getCreateActionDate().getTime()); // TODO : Runway dates are
// accurate to the second, but epoch is accurate to the milisecond.
/*
     * TODO : The rest of the supported actions
     */
}
Also used : UpdateGeoObjectActionDTO(org.commongeoregistry.adapter.action.geoobject.UpdateGeoObjectActionDTO) UpdateGeoObjectAction(net.geoprism.registry.action.geoobject.UpdateGeoObjectAction) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) TestGeoObjectInfo(net.geoprism.registry.test.TestGeoObjectInfo) Test(org.junit.Test)

Example 4 with UpdateGeoObjectActionDTO

use of org.commongeoregistry.adapter.action.geoobject.UpdateGeoObjectActionDTO in project geoprism-registry by terraframe.

the class GovernanceTest method testUpdateAction.

@Test
public void testUpdateAction() {
    Date startDate = new Date();
    Date endDate = new Date();
    GeoObjectOverTime goTime = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.CAMBODIA.getCode(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
    goTime.setDisplayLabel(new LocalizedValue("test 123"), startDate, endDate);
    UpdateGeoObjectActionDTO updateDTO = new UpdateGeoObjectActionDTO();
    updateDTO.setGeoObject(goTime.toJSON());
    updateDTO.setCreateActionDate(Date.from(Instant.now().minus(6, ChronoUnit.HOURS)));
    updateDTO.setContributorNotes("UPDATE_CONTRIB_NOTES");
    updateDTO.setMaintainerNotes("UPDATE_MAINTAIN_NOTES");
    UpdateGeoObjectAction updateRA = (UpdateGeoObjectAction) AbstractAction.dtoToRegistry(updateDTO);
    execute(updateRA);
    GeoObjectOverTime goTime2 = testData.adapter.getGeoObjectOverTimeByCode(FastTestDataset.CAMBODIA.getCode(), FastTestDataset.CAMBODIA.getGeoObjectType().getCode());
    Assert.assertEquals("test 123", goTime2.getDisplayLabel(startDate).getValue());
}
Also used : UpdateGeoObjectActionDTO(org.commongeoregistry.adapter.action.geoobject.UpdateGeoObjectActionDTO) UpdateGeoObjectAction(net.geoprism.registry.action.geoobject.UpdateGeoObjectAction) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) Date(java.util.Date) Test(org.junit.Test)

Aggregations

UpdateGeoObjectActionDTO (org.commongeoregistry.adapter.action.geoobject.UpdateGeoObjectActionDTO)4 UpdateGeoObjectAction (net.geoprism.registry.action.geoobject.UpdateGeoObjectAction)2 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)2 Test (org.junit.Test)2 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 LocatedIn (com.runwaysdk.system.gis.geo.LocatedIn)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)1 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)1 AllowAllGeoObjectPermissionService (net.geoprism.registry.permission.AllowAllGeoObjectPermissionService)1 TestGeoObjectInfo (net.geoprism.registry.test.TestGeoObjectInfo)1 AbstractActionDTO (org.commongeoregistry.adapter.action.AbstractActionDTO)1 CreateGeoObjectActionDTO (org.commongeoregistry.adapter.action.geoobject.CreateGeoObjectActionDTO)1 AddChildActionDTO (org.commongeoregistry.adapter.action.tree.AddChildActionDTO)1 RemoveChildActionDTO (org.commongeoregistry.adapter.action.tree.RemoveChildActionDTO)1 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)1 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)1