use of net.geoprism.registry.view.ServerParentTreeNodeOverTime in project geoprism-registry by terraframe.
the class SetParentAction method apply.
@Override
public void apply() {
// Important to remember that the child may or may not exist at this point (so we can't fetch it from the DB here)
ServerGeoObjectType type = ServiceFactory.getMetadataCache().getGeoObjectType(this.getChildTypeCode()).get();
ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(type, this.getJson());
ptnOt.enforceUserHasPermissionSetParents(this.getChildTypeCode(), true);
super.apply();
}
use of net.geoprism.registry.view.ServerParentTreeNodeOverTime in project geoprism-registry by terraframe.
the class ETLService method submitImportErrorResolutionInTrans.
@Transaction
private void submitImportErrorResolutionInTrans(String sessionId, String json) {
JsonObject config = JsonParser.parseString(json).getAsJsonObject();
ImportHistory hist = ImportHistory.get(config.get("historyId").getAsString());
hist.getConfig().enforceExecutePermissions();
ImportError err = ImportError.get(config.get("importErrorId").getAsString());
String resolution = config.get("resolution").getAsString();
if (resolution.equals(ErrorResolution.APPLY_GEO_OBJECT.name())) {
String parentTreeNode = config.get("parentTreeNode").toString();
String geoObject = config.get("geoObject").toString();
Boolean isNew = config.get("isNew").getAsBoolean();
GeoObjectOverTime go = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), geoObject);
if (isNew) {
go.setUid(RegistryIdService.getInstance().next());
geoObject = go.toJSON().toString();
new ServerGeoObjectService().createGeoObject(sessionId, parentTreeNode, geoObject, null, null);
} else {
ServerGeoObjectService service = new ServerGeoObjectService();
ServerGeoObjectIF serverGO = service.apply(go, isNew, false);
final ServerGeoObjectType type = serverGO.getType();
ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(type, parentTreeNode);
serverGO.setParents(ptnOt);
}
err.appLock();
err.setResolution(resolution);
err.apply();
hist.appLock();
hist.setErrorResolvedCount(hist.getErrorResolvedCount() + 1);
hist.setImportedRecords(hist.getImportedRecords() + 1);
hist.apply();
} else if (resolution.equals(ErrorResolution.IGNORE.name())) {
err.appLock();
err.setResolution(resolution);
err.apply();
} else {
throw new UnsupportedOperationException("Invalid import resolution [" + resolution + "].");
}
}
use of net.geoprism.registry.view.ServerParentTreeNodeOverTime in project geoprism-registry by terraframe.
the class ServerGeoObjectService method createGeoObjectInTrans.
@Transaction
public JsonObject createGeoObjectInTrans(String sPtn, String sTimeGo, String masterListId, String notes) {
GeoObjectOverTime timeGO = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sTimeGo);
ServerGeoObjectType serverGOT = ServerGeoObjectType.get(timeGO.getType());
RolePermissionService perms = ServiceFactory.getRolePermissionService();
final String orgCode = serverGOT.getOrganization().getCode();
if (perms.isSRA() || perms.isRA(orgCode) || perms.isRM(orgCode, serverGOT)) {
ServerGeoObjectService service = new ServerGeoObjectService();
ServerGeoObjectIF serverGO = service.apply(timeGO, true, false);
final ServerGeoObjectType type = serverGO.getType();
if (sPtn != null) {
ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(type, sPtn);
serverGO.setParents(ptnOt);
}
// Update the master list record
if (masterListId != null) {
ListTypeVersion.get(masterListId).publishRecord(serverGO);
}
JsonObject resp = new JsonObject();
resp.addProperty("isChangeRequest", false);
resp.add("geoObject", serverGO.toGeoObjectOverTime().toJSON(ServiceFactory.getRegistryService().serializer(Session.getCurrentSession().getOid())));
return resp;
} else if (ServiceFactory.getRolePermissionService().isRC(orgCode, serverGOT)) {
Instant base = Instant.now();
int sequence = 0;
ChangeRequest request = new ChangeRequest();
request.addApprovalStatus(AllGovernanceStatus.PENDING);
request.setContributorNotes(notes);
request.setGeoObjectCode(timeGO.getCode());
request.setGeoObjectTypeCode(timeGO.getType().getCode());
request.setOrganizationCode(orgCode);
request.apply();
CreateGeoObjectAction action = new CreateGeoObjectAction();
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(Date.from(base.plus(sequence++, ChronoUnit.MINUTES)));
action.setGeoObjectJson(sTimeGo);
action.setParentJson(sPtn);
action.setApiVersion(CGRAdapterProperties.getApiVersion());
action.setContributorNotes(notes);
action.apply();
request.addAction(action).apply();
JsonObject resp = new JsonObject();
resp.addProperty("isChangeRequest", true);
resp.addProperty("changeRequestId", request.getOid());
return resp;
} else {
throw new CGRPermissionException();
}
}
use of net.geoprism.registry.view.ServerParentTreeNodeOverTime in project geoprism-registry by terraframe.
the class VertexServerGeoObject method internalGetParentOverTime.
protected static ServerParentTreeNodeOverTime internalGetParentOverTime(VertexServerGeoObject child, String[] parentTypes, boolean recursive) {
final ServerGeoObjectType cType = child.getType();
final List<ServerHierarchyType> hierarchies = cType.getHierarchies();
ServerParentTreeNodeOverTime response = new ServerParentTreeNodeOverTime(cType);
for (ServerHierarchyType ht : hierarchies) {
response.add(ht);
}
Map<String, Object> parameters = new HashedMap<String, Object>();
parameters.put("rid", child.getVertex().getRID());
StringBuilder statement = new StringBuilder();
statement.append("SELECT EXPAND(inE()");
if (parentTypes != null && parentTypes.length > 0) {
statement.append("[");
for (int i = 0; i < parentTypes.length; i++) {
ServerGeoObjectType type = ServerGeoObjectType.get(parentTypes[i]);
if (i > 0) {
statement.append(" OR ");
}
statement.append("out.@class = :a" + i);
parameters.put("a" + Integer.toString(i), type.getMdVertex().getDBClassName());
}
statement.append("]");
}
statement.append(") FROM :rid");
statement.append(" ORDER BY startDate ASC");
GraphQuery<EdgeObject> query = new GraphQuery<EdgeObject>(statement.toString(), parameters);
List<EdgeObject> edges = query.getResults();
for (EdgeObject edge : edges) {
MdEdgeDAOIF mdEdge = (MdEdgeDAOIF) edge.getMdClass();
if (HierarchicalRelationshipType.isEdgeAHierarchyType(mdEdge)) {
ServerHierarchyType ht = ServerHierarchyType.get(mdEdge);
VertexObject parentVertex = edge.getParent();
MdVertexDAOIF mdVertex = (MdVertexDAOIF) parentVertex.getMdClass();
ServerGeoObjectType parentType = ServerGeoObjectType.get(mdVertex);
Date date = edge.getObjectValue(GeoVertex.START_DATE);
Date endDate = edge.getObjectValue(GeoVertex.END_DATE);
String oid = edge.getObjectValue(GeoVertex.OID);
ServerParentTreeNode tnRoot = new ServerParentTreeNode(child, null, date, null, oid);
tnRoot.setEndDate(endDate);
tnRoot.setOid(oid);
VertexServerGeoObject parent = new VertexServerGeoObject(parentType, parentVertex, date);
ServerParentTreeNode tnParent;
if (recursive) {
tnParent = internalGetParentGeoObjects(parent, parentTypes, recursive, ht, date);
} else {
tnParent = new ServerParentTreeNode(parent, ht, date, null, oid);
}
tnRoot.addParent(tnParent);
response.add(ht, tnRoot);
}
}
return response;
}
use of net.geoprism.registry.view.ServerParentTreeNodeOverTime in project geoprism-registry by terraframe.
the class CreateGeoObjectAction method execute.
@Override
public void execute() {
String sJson = this.getGeoObjectJson();
GeoObjectOverTime geoObject = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sJson);
ServerGeoObjectService service = new ServerGeoObjectService();
service.apply(geoObject, true, false);
ServerGeoObjectIF child = service.getGeoObjectByCode(geoObject.getCode(), geoObject.getType().getCode());
ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(child.getType(), this.getParentJson());
child.setParents(ptnOt);
}
Aggregations