Search in sources :

Example 6 with ServerGeoObjectIF

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);
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) AllowAllGeoObjectPermissionService(net.geoprism.registry.permission.AllowAllGeoObjectPermissionService)

Example 7 with ServerGeoObjectIF

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 + "].");
    }
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 8 with ServerGeoObjectIF

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;
}
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)

Example 9 with ServerGeoObjectIF

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;
}
Also used : CreateGeoObjectAction(net.geoprism.registry.action.geoobject.CreateGeoObjectAction) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) UpdateGeoObjectAction(net.geoprism.registry.action.geoobject.UpdateGeoObjectAction) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) Instant(java.time.Instant) ParentTreeNode(org.commongeoregistry.adapter.dataaccess.ParentTreeNode) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 10 with ServerGeoObjectIF

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);
    }
}
Also used : JsonArray(com.google.gson.JsonArray) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) JsonObject(com.google.gson.JsonObject)

Aggregations

ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)106 Request (com.runwaysdk.session.Request)68 Test (org.junit.Test)43 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)28 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)23 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)18 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)18 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)16 Date (java.util.Date)15 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)15 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)13 LinkedList (java.util.LinkedList)11 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)10 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)10 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)10 JsonObject (com.google.gson.JsonObject)9 VertexObject (com.runwaysdk.business.graph.VertexObject)9 ChangeRequest (net.geoprism.registry.action.ChangeRequest)9 ServerParentTreeNode (net.geoprism.registry.model.ServerParentTreeNode)9 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)9