Search in sources :

Example 1 with GeoSynonymService

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;
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) JsonObject(com.google.gson.JsonObject) GeoSynonymService(net.geoprism.registry.service.GeoSynonymService) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

JsonObject (com.google.gson.JsonObject)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)1 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)1 GeoSynonymService (net.geoprism.registry.service.GeoSynonymService)1