use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.
the class GeoObjectImporter method parsePostalCode.
private ServerGeoObjectIF parsePostalCode(FeatureRow feature) {
LocationBuilder builder = PostalCodeFactory.get(this.configuration.getType());
Location location = builder.build(this.configuration.getFunction(GeoObject.CODE));
ShapefileFunction function = location.getFunction();
String code = (String) function.getValue(feature);
if (code != null) {
// Search
ServerGeoObjectQuery query = new ServerGeoObjectService().createQuery(location.getType(), this.configuration.getStartDate());
query.setRestriction(new ServerCodeRestriction(code));
// Assert.assertNull(query.getSingleResult());
ServerGeoObjectIF result = query.getSingleResult();
if (result != null) {
return result;
} else {
PostalCodeLocationException e = new PostalCodeLocationException();
e.setCode(code);
e.setTypeLabel(location.getType().getLabel().getValue());
throw e;
}
}
return null;
}
use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.
the class ServerParentGraphNode method fromJSON.
public static ServerParentGraphNode fromJSON(JsonObject jo) {
ServerGeoObjectIF goif = null;
if (jo.has(TreeNode.JSON_GEO_OBJECT)) {
GeoObject go = GeoObject.fromJSON(ServiceFactory.getAdapter(), jo.get(TreeNode.JSON_GEO_OBJECT).toString());
ServerGeoObjectType type = ServerGeoObjectType.get(go.getType());
ServerGeoObjectStrategyIF strategy = new ServerGeoObjectService().getStrategy(type);
goif = strategy.constructFromGeoObject(go, false);
}
GraphType graphType = null;
if (jo.has("graphType")) {
String graphCode = jo.get("graphType").getAsString();
String graphTypeClass = jo.get("graphTypeClass").getAsString();
graphType = GraphType.getByCode(graphTypeClass, graphCode);
}
Date startDate = null;
if (jo.has("startDate")) {
startDate = GeoRegistryUtil.parseDate(jo.get("startDate").getAsString());
}
Date endDate = null;
if (jo.has("endDate")) {
endDate = GeoRegistryUtil.parseDate(jo.get("startDate").getAsString());
}
String oid = null;
if (jo.has("oid")) {
oid = jo.get("oid").getAsString();
}
ServerParentGraphNode node = new ServerParentGraphNode(goif, graphType, startDate, endDate, oid);
if (jo.has(ParentTreeNode.JSON_PARENTS)) {
JsonArray jaParents = jo.get(ParentTreeNode.JSON_PARENTS).getAsJsonArray();
for (int i = 0; i < jaParents.size(); ++i) {
node.addParent(ServerParentGraphNode.fromJSON(jaParents.get(i).getAsJsonObject()));
}
}
return node;
}
use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.
the class ChangeRequestService method update.
@Request(RequestType.SESSION)
public JsonObject update(String sessionId, String cr) {
JsonObject obj = JsonParser.parseString(cr).getAsJsonObject();
String oid = obj.get("oid").getAsString();
JsonArray actions = obj.get("actions").getAsJsonArray();
String notes = obj.get("contributorNotes").getAsString();
ChangeRequest current = ChangeRequest.get(oid);
ServerGeoObjectService service = new ServerGeoObjectService();
service.updateChangeRequest(current, notes, actions);
return current.getDetails();
}
use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.
the class GraphService method getChildren.
@Request(RequestType.SESSION)
public JsonObject getChildren(String sessionId, String parentCode, String parentGeoObjectTypeCode, String graphTypeCode, Boolean recursive, Date date) {
ServerGeoObjectService service = ServiceFactory.getGeoObjectService();
ServerGeoObjectIF parent = service.getGeoObjectByCode(parentCode, parentGeoObjectTypeCode, true);
GraphType graphType = this.getGraphType(graphTypeCode);
// ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanAddChild(ht.getOrganization().getCode(),
// parent.getType(), child.getType());
ServerGraphNode node = parent.getGraphChildren(graphType, recursive, date);
return node.toJSON();
}
use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.
the class GraphService method removeChild.
@Request(RequestType.SESSION)
public void removeChild(String sessionId, String parentCode, String parentGeoObjectTypeCode, String childCode, String childGeoObjectTypeCode, String graphTypeCode, Date startDate, Date endDate) {
ServerGeoObjectService service = ServiceFactory.getGeoObjectService();
ServerGeoObjectIF parent = service.getGeoObjectByCode(parentCode, parentGeoObjectTypeCode, true);
ServerGeoObjectIF child = service.getGeoObjectByCode(childCode, childGeoObjectTypeCode, true);
GraphType graphType = this.getGraphType(graphTypeCode);
// ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanAddChild(ht.getOrganization().getCode(),
// parent.getType(), child.getType());
parent.removeGraphChild(child, graphType, startDate, endDate);
}
Aggregations