use of net.geoprism.registry.model.ServerGeoObjectIF 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.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class ServerGeoObjectService method getGeoObject.
public ServerGeoObjectIF getGeoObject(String uid, String typeCode) {
ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
this.permissionService.enforceCanRead(type.getOrganization().getCode(), type);
ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
ServerGeoObjectIF object = strategy.getGeoObjectByUid(uid);
if (object == null) {
InvalidRegistryIdException ex = new InvalidRegistryIdException();
ex.setRegistryId(uid);
throw ex;
}
return object;
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class ServerGeoObjectService method apply.
@Transaction
public ServerGeoObjectIF apply(GeoObject object, Date startDate, Date endDate, boolean isNew, boolean isImport) {
ServerGeoObjectType type = ServerGeoObjectType.get(object.getType());
ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
if (isNew) {
permissionService.enforceCanCreate(type.getOrganization().getCode(), type);
} else {
permissionService.enforceCanWrite(type.getOrganization().getCode(), type);
}
ServerGeoObjectIF geoObject = strategy.constructFromGeoObject(object, isNew);
geoObject.setDate(startDate);
if (!isNew) {
geoObject.lock();
}
geoObject.populate(object, startDate, endDate);
try {
geoObject.apply(isImport);
// Return the refreshed copy of the geoObject
return this.build(type, geoObject.getRunwayId());
} catch (DuplicateDataException e) {
VertexServerGeoObject.handleDuplicateDataException(type, e);
throw e;
}
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class VertexServerGeoObject method setParents.
@Override
public void setParents(ServerParentTreeNodeOverTime parentsOverTime) {
parentsOverTime.enforceUserHasPermissionSetParents(this.getType().getCode(), false);
final Collection<ServerHierarchyType> hierarchyTypes = parentsOverTime.getHierarchies();
for (ServerHierarchyType hierarchyType : hierarchyTypes) {
final List<ServerParentTreeNode> entries = parentsOverTime.getEntries(hierarchyType);
this.removeAllEdges(hierarchyType);
final TreeSet<EdgeObject> edges = new TreeSet<EdgeObject>(new EdgeComparator());
for (ServerParentTreeNode entry : entries) {
final ServerGeoObjectIF parent = entry.getGeoObject();
EdgeObject newEdge = this.getVertex().addParent(((VertexComponent) parent).getVertex(), hierarchyType.getMdEdge());
newEdge.setValue(GeoVertex.START_DATE, entry.getStartDate());
newEdge.setValue(GeoVertex.END_DATE, entry.getEndDate());
edges.add(newEdge);
}
for (EdgeObject e : edges) {
e.apply();
}
}
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class VertexGeoObjectQuery method getResults.
public List<ServerGeoObjectIF> getResults() {
List<ServerGeoObjectIF> list = new LinkedList<ServerGeoObjectIF>();
GraphQuery<VertexObject> query = this.getQuery();
List<VertexObject> results = query.getResults();
for (VertexObject result : results) {
list.add(new VertexServerGeoObject(type, result, this.date));
}
return list;
}
Aggregations