use of net.geoprism.registry.service.GeoSynonymService 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;
}
Aggregations