use of com.runwaysdk.dataaccess.transaction.Transaction 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 com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class ETLService method reImportInTrans.
@Transaction
public void reImportInTrans(MultipartFileParameter file, String json) {
ImportConfiguration config = ImportConfiguration.build(json);
ImportHistory hist = ImportHistory.get(config.getHistoryId());
hist.getConfig().enforceExecutePermissions();
VaultFile vf = VaultFile.get(config.getVaultFileId());
vf.delete();
VaultFile vf2 = null;
try (InputStream is = file.getInputStream()) {
vf2 = VaultFile.createAndApply(file.getFilename(), is);
} catch (IOException e) {
throw new RuntimeException(e);
}
config.setVaultFileId(vf2.getOid());
config.setFileName(file.getFilename());
hist = ImportHistory.lock(config.getHistoryId());
hist.setImportFile(vf2);
hist.setConfigJson(config.toJSON().toString());
hist.apply();
}
use of com.runwaysdk.dataaccess.transaction.Transaction 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 com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class GeoVertexSynonym method createSynonym.
@Transaction
public static JSONObject createSynonym(String typeCode, String code, String label) {
ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
VertexGeoObjectStrategy strategy = new VertexGeoObjectStrategy(type);
VertexServerGeoObject object = strategy.getGeoObjectByCode(code);
final String oid = object.addSynonym(label);
JSONObject jObject = new JSONObject();
jObject.put("synonymId", oid);
jObject.put("label", object.getDisplayLabel().getValue());
// jObject.put("ancestors", object.getA new
// JSONArray(GeoEntityUtil.getAncestorsAsJSON(code)));
JSONObject response = new JSONObject(jObject);
response.put("vOid", oid);
return response;
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class TransitionEvent method removeAll.
@Transaction
public static void removeAll(ServerGeoObjectType type) {
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(TransitionEvent.CLASS);
MdAttributeDAOIF beforeTypeCode = mdVertex.definesAttribute(TransitionEvent.BEFORETYPECODE);
MdAttributeDAOIF afterTypeCode = mdVertex.definesAttribute(TransitionEvent.AFTERTYPECODE);
StringBuilder statement = new StringBuilder();
statement.append("SELECT FROM " + mdVertex.getDBClassName());
statement.append(" WHERE " + beforeTypeCode.getColumnName() + " = :typeCode OR " + afterTypeCode.getColumnName() + " = :typeCode");
GraphQuery<TransitionEvent> query = new GraphQuery<TransitionEvent>(statement.toString());
query.setParameter("typeCode", type.getCode());
List<TransitionEvent> results = query.getResults();
results.forEach(event -> event.delete());
}
Aggregations