use of org.commongeoregistry.adapter.action.geoobject.CreateGeoObjectActionDTO in project geoprism-registry by terraframe.
the class CreateGeoObjectAction method buildFromDTO.
@Override
protected void buildFromDTO(AbstractActionDTO dto) {
super.buildFromDTO(dto);
CreateGeoObjectActionDTO castedDTO = (CreateGeoObjectActionDTO) dto;
this.setGeoObjectJson(castedDTO.getGeoObject().toString());
}
use of org.commongeoregistry.adapter.action.geoobject.CreateGeoObjectActionDTO 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);
}
Aggregations