use of net.geoprism.registry.conversion.ServerGeoObjectStrategyIF in project geoprism-registry by terraframe.
the class ServerGeoObjectService method getGeoObjectByCode.
public ServerGeoObjectIF getGeoObjectByCode(String code, ServerGeoObjectType type, boolean throwException) {
this.permissionService.enforceCanRead(type.getOrganization().getCode(), type);
ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
ServerGeoObjectIF geoObject = strategy.getGeoObjectByCode(code);
if (geoObject == null && throwException) {
DataNotFoundException ex = new DataNotFoundException();
ex.setTypeLabel(GeoObjectMetadata.get().getClassDisplayLabel());
ex.setDataIdentifier(code);
ex.setAttributeLabel(GeoObjectMetadata.get().getAttributeDisplayLabel(DefaultAttribute.CODE.getName()));
throw ex;
}
return geoObject;
}
use of net.geoprism.registry.conversion.ServerGeoObjectStrategyIF in project geoprism-registry by terraframe.
the class ServerGeoObjectService method build.
public ServerGeoObjectIF build(ServerGeoObjectType type, String runwayId) {
ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
VertexObject vertex = VertexObject.get(type.getMdVertex(), runwayId);
return strategy.constructFromDB(vertex);
}
use of net.geoprism.registry.conversion.ServerGeoObjectStrategyIF in project geoprism-registry by terraframe.
the class ServerGeoObjectService method apply.
@Transaction
public ServerGeoObjectIF apply(GeoObjectOverTime goTime, boolean isNew, boolean isImport) {
ServerGeoObjectType type = ServerGeoObjectType.get(goTime.getType());
ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
if (isNew) {
permissionService.enforceCanCreate(type.getOrganization().getCode(), type);
} else {
permissionService.enforceCanWrite(type.getOrganization().getCode(), type);
}
ServerGeoObjectIF goServer = strategy.constructFromGeoObjectOverTime(goTime, isNew);
if (!isNew) {
goServer.lock();
}
goServer.populate(goTime);
try {
goServer.apply(isImport);
// Return the refreshed copy of the geoObject
return this.build(type, goServer.getRunwayId());
} catch (DuplicateDataException e) {
VertexServerGeoObject.handleDuplicateDataException(type, e);
throw e;
}
}
use of net.geoprism.registry.conversion.ServerGeoObjectStrategyIF in project geoprism-registry by terraframe.
the class ServerGeoObjectService method split.
@Transaction
public ServerGeoObjectIF split(GeoObjectSplitView view) {
ServerGeoObjectType type = ServerGeoObjectType.get(view.getTypeCode());
ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
final ServerGeoObjectIF source = strategy.getGeoObjectByCode(view.getSourceCode());
source.setDate(view.getDate());
ServerGeoObjectIF target = strategy.newInstance();
target.setDate(view.getDate());
target.populate(source.toGeoObject(view.getDate()), view.getDate(), view.getDate());
target.setCode(view.getTargetCode());
target.setDisplayLabel(view.getLabel());
target.apply(false);
final ServerParentTreeNode sNode = source.getParentGeoObjects(null, false, view.getDate());
final List<ServerParentTreeNode> sParents = sNode.getParents();
for (ServerParentTreeNode sParent : sParents) {
final ServerGeoObjectIF parent = sParent.getGeoObject();
final ServerHierarchyType hierarchyType = sParent.getHierarchyType();
target.addParent(parent, hierarchyType, view.getDate(), null);
}
return target;
}
use of net.geoprism.registry.conversion.ServerGeoObjectStrategyIF in project geoprism-registry by terraframe.
the class ServerChildGraphNode method fromJSON.
public static ServerChildGraphNode 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();
}
ServerChildGraphNode node = new ServerChildGraphNode(goif, graphType, startDate, endDate, oid);
if (jo.has(ChildTreeNode.JSON_CHILDREN)) {
JsonArray jaChildren = jo.get(ChildTreeNode.JSON_CHILDREN).getAsJsonArray();
for (int i = 0; i < jaChildren.size(); ++i) {
node.addChild(ServerChildGraphNode.fromJSON(jaChildren.get(i).getAsJsonObject()));
}
}
return node;
}
Aggregations