use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class RemoveChildAction method execute.
@Override
public void execute() {
ServerGeoObjectIF parent = new ServerGeoObjectService(new AllowAllGeoObjectPermissionService()).getGeoObject(this.getParentId(), this.getParentTypeCode());
ServerGeoObjectIF child = new ServerGeoObjectService().getGeoObject(this.getChildId(), this.getChildTypeCode());
ServerHierarchyType ht = ServerHierarchyType.get(this.getHierarchyTypeCode());
ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanRemoveChild(ht.getOrganization().getCode(), parent.getType(), child.getType());
parent.removeChild(child, this.getHierarchyTypeCode(), null, null);
}
use of net.geoprism.registry.model.ServerGeoObjectIF 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.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class ETLService method submitValidationProblemResolutionInTrans.
@Transaction
private JsonObject submitValidationProblemResolutionInTrans(String sessionId, String json) {
JsonObject response = new JsonObject();
JsonObject config = JsonParser.parseString(json).getAsJsonObject();
ValidationProblem problem = ValidationProblem.get(config.get("validationProblemId").getAsString());
ImportHistory hist = problem.getHistory();
hist.getConfig().enforceExecutePermissions();
String resolution = config.get("resolution").getAsString();
if (resolution.equals(ValidationResolution.SYNONYM.name())) {
if (problem instanceof TermReferenceProblem) {
String classifierId = config.get("classifierId").getAsString();
String label = config.get("label").getAsString();
response = JsonParser.parseString(DataUploader.createClassifierSynonym(classifierId, label)).getAsJsonObject();
} else if (problem instanceof ParentReferenceProblem) {
String code = config.get("code").getAsString();
String typeCode = config.get("typeCode").getAsString();
String label = config.get("label").getAsString();
ServerGeoObjectIF go = new ServerGeoObjectService().getGeoObjectByCode(code, typeCode);
response = JsonParser.parseString(new GeoSynonymService().createGeoEntitySynonym(sessionId, typeCode, go.getCode(), label).toString()).getAsJsonObject();
}
problem.appLock();
problem.setResolution(resolution);
problem.apply();
// hist.appLock();
// hist.setErrorResolvedCount(hist.getErrorResolvedCount() + 1);
// hist.apply();
} else if (resolution.equals(ValidationResolution.IGNORE.name())) {
problem.appLock();
problem.setResolution(resolution);
problem.apply();
} else if (resolution.equals(ValidationResolution.CREATE.name())) {
if (problem instanceof TermReferenceProblem) {
String parentTermCode = config.get("parentTermCode").getAsString();
String termJSON = config.get("termJSON").toString();
response = RegistryService.getInstance().createTerm(sessionId, parentTermCode, termJSON).toJSON();
} else if (problem instanceof ParentReferenceProblem) {
// TODO
}
problem.appLock();
problem.setResolution(resolution);
problem.apply();
} else {
throw new UnsupportedOperationException("Invalid import resolution [" + resolution + "].");
}
return response;
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class GeoObjectEditorControllerNoOverTime method applyInTransaction.
@Transaction
private GeoObject applyInTransaction(String sessionId, String sPtn, String sGo, Boolean isNew, String masterListId) {
final Date startDate = new Date();
final Date endDate = ValueOverTime.INFINITY_END_DATE;
GeoObject go;
Map<String, String> roles = Session.getCurrentSession().getUserRoles();
if (roles.keySet().contains(RegistryConstants.REGISTRY_CONTRIBUTOR_ROLE)) {
Instant base = Instant.now();
int sequence = 0;
ChangeRequest request = new ChangeRequest();
request.addApprovalStatus(AllGovernanceStatus.PENDING);
request.apply();
if (!isNew) {
UpdateGeoObjectAction action = new UpdateGeoObjectAction();
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(Date.from(base.plus(sequence++, ChronoUnit.MINUTES)));
action.setGeoObjectJson(sGo);
action.setApiVersion(CGRAdapterProperties.getApiVersion());
action.apply();
request.addAction(action).apply();
} else {
CreateGeoObjectAction action = new CreateGeoObjectAction();
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(Date.from(base.plus(sequence++, ChronoUnit.MINUTES)));
action.setGeoObjectJson(sGo);
action.setApiVersion(CGRAdapterProperties.getApiVersion());
action.apply();
request.addAction(action).apply();
}
ParentTreeNode ptn = ParentTreeNode.fromJSON(sPtn.toString(), ServiceFactory.getAdapter());
applyChangeRequest(sessionId, request, ptn, isNew, base, sequence, startDate, endDate);
} else {
if (!isNew) {
go = RegistryService.getInstance().updateGeoObject(sessionId, sGo.toString(), startDate, endDate);
} else {
go = RegistryService.getInstance().createGeoObject(sessionId, sGo.toString(), startDate, endDate);
}
ParentTreeNode ptn = ParentTreeNode.fromJSON(sPtn.toString(), ServiceFactory.getAdapter());
applyPtn(sessionId, ptn, startDate, endDate);
// Update the master list record
if (masterListId != null) {
ServerGeoObjectService service = new ServerGeoObjectService();
ServerGeoObjectIF geoObject = service.getGeoObject(go);
if (!isNew) {
ListTypeVersion.get(masterListId).updateRecord(geoObject);
} else {
ListTypeVersion.get(masterListId).publishRecord(geoObject);
}
}
return go;
}
return null;
}
use of net.geoprism.registry.model.ServerGeoObjectIF in project geoprism-registry by terraframe.
the class EdgeJsonImporter method importData.
public void importData() throws JsonSyntaxException, IOException {
ServerGeoObjectService service = new ServerGeoObjectService();
JsonObject data = JsonParser.parseString(IOUtils.toString(stream, "UTF-8")).getAsJsonObject();
JsonArray edges = data.get("edges").getAsJsonArray();
logger.info("About to import [" + edges.size() + "] edges as MdEdge [" + this.graphType.getCode() + "].");
for (int i = 0; i < edges.size(); ++i) {
JsonObject joEdge = edges.get(i).getAsJsonObject();
String sourceCode = joEdge.get("source").getAsString();
String sourceTypeCode = joEdge.get("sourceType").getAsString();
String targetCode = joEdge.get("target").getAsString();
String targetTypeCode = joEdge.get("targetType").getAsString();
ServerGeoObjectIF source = service.getGeoObjectByCode(sourceCode, sourceTypeCode);
ServerGeoObjectIF target = service.getGeoObjectByCode(targetCode, targetTypeCode);
source.addGraphChild(target, this.graphType, this.startDate, this.endDate);
}
}
Aggregations