Search in sources :

Example 36 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.

the class ServerGeoObjectService method updateGeoObjectInTrans.

@Transaction
public JsonObject updateGeoObjectInTrans(String geoObjectCode, String geoObjectTypeCode, String actions, String masterListId, String notes) {
    final RolePermissionService perms = ServiceFactory.getRolePermissionService();
    final ServerGeoObjectType type = ServerGeoObjectType.get(geoObjectTypeCode);
    final String orgCode = type.getOrganization().getCode();
    final VertexServerGeoObject go = (VertexServerGeoObject) new ServerGeoObjectService().getGeoObjectByCode(geoObjectCode, geoObjectTypeCode);
    final JsonArray jaActions = JsonParser.parseString(actions).getAsJsonArray();
    if (perms.isSRA() || perms.isRA(orgCode) || perms.isRM(orgCode, type)) {
        this.executeActions(type, go, jaActions);
        if (masterListId != null) {
            ListTypeVersion.get(masterListId).updateRecord(go);
        }
        JsonObject resp = new JsonObject();
        resp.addProperty("isChangeRequest", false);
        resp.add("geoObject", go.toGeoObjectOverTime().toJSON(ServiceFactory.getRegistryService().serializer(Session.getCurrentSession().getOid())));
        return resp;
    } else if (ServiceFactory.getRolePermissionService().isRC(orgCode, type)) {
        ChangeRequest request = createChangeRequest(geoObjectCode, geoObjectTypeCode, notes, orgCode, jaActions);
        JsonObject resp = new JsonObject();
        resp.addProperty("isChangeRequest", true);
        resp.addProperty("changeRequestId", request.getOid());
        return resp;
    } else {
        throw new CGRPermissionException();
    }
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) JsonArray(com.google.gson.JsonArray) CGRPermissionException(net.geoprism.registry.CGRPermissionException) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 37 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.

the class BasicVertexQuery method getResults.

public List<ServerGeoObjectIF> getResults() {
    List<ServerGeoObjectIF> list = new LinkedList<ServerGeoObjectIF>();
    GraphQuery<VertexObject> query = this.getQuery();
    List<VertexObject> results = query.getResults();
    for (VertexObject result : results) {
        list.add(new VertexServerGeoObject(type, result, this.date));
    }
    return list;
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) VertexObject(com.runwaysdk.business.graph.VertexObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) LinkedList(java.util.LinkedList)

Example 38 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.

the class BasicVertexQuery method getSingleResult.

public ServerGeoObjectIF getSingleResult() {
    GraphQuery<VertexObject> query = this.getQuery();
    VertexObject vertex = query.getSingleResult();
    if (vertex != null) {
        return new VertexServerGeoObject(type, vertex, this.date);
    }
    return null;
}
Also used : VertexObject(com.runwaysdk.business.graph.VertexObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject)

Example 39 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.

the class VertexGeoObjectQuery method getSingleResult.

public ServerGeoObjectIF getSingleResult() {
    GraphQuery<VertexObject> query = this.getQuery();
    VertexObject vertex = query.getSingleResult();
    if (vertex != null) {
        return new VertexServerGeoObject(type, vertex, this.date);
    }
    return null;
}
Also used : VertexObject(com.runwaysdk.business.graph.VertexObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject)

Example 40 with VertexServerGeoObject

use of net.geoprism.registry.model.graph.VertexServerGeoObject in project geoprism-registry by terraframe.

the class LocationService method getLocationInformation.

@Request(RequestType.SESSION)
public LocationInformation getLocationInformation(String sessionId, Date date, String typeCode, String hierarchyCode) {
    LocationInformation information = new LocationInformation();
    HierarchyService hService = ServiceFactory.getHierarchyService();
    HierarchyType[] hierarchies = hService.getHierarchyTypes(sessionId, null, PermissionContext.READ);
    ServerHierarchyType hierarchy = null;
    if (hierarchyCode == null || hierarchyCode.length() == 0) {
        hierarchy = ServerHierarchyType.get(hierarchies[0]);
    } else {
        hierarchy = ServerHierarchyType.get(hierarchyCode);
    }
    List<ServerGeoObjectType> nodes = hierarchy.getDirectRootNodes();
    if (nodes.size() > 0) {
        /*
       * If a typeCode is given and it is an option based on the hierarchy than
       * use that type otherwise use the first type code
       */
        ServerGeoObjectType type = nodes.get(0);
        if (typeCode != null && typeCode.length() > 0) {
            for (ServerGeoObjectType node : nodes) {
                if (node.getCode().equals(typeCode)) {
                    type = ServerGeoObjectType.get(typeCode);
                }
            }
        }
        if (type != null) {
            ServiceFactory.getGeoObjectPermissionService().enforceCanRead(type.getOrganization().getCode(), type);
            information.setChildType(type.getType());
            List<VertexServerGeoObject> children = this.getGeoObjects(type.getCode(), date);
            for (VertexServerGeoObject child : children) {
                information.addChild(child.toGeoObject(date));
            }
        }
    }
    information.setHierarchies(hierarchies);
    information.setHierarchy(hierarchy.getCode());
    information.setChildTypes(nodes);
    return information;
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) LocationInformation(net.geoprism.registry.view.LocationInformation) HierarchyService(net.geoprism.registry.hierarchy.HierarchyService) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Request(com.runwaysdk.session.Request)

Aggregations

VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)51 VertexObject (com.runwaysdk.business.graph.VertexObject)20 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)19 JsonObject (com.google.gson.JsonObject)18 Request (com.runwaysdk.session.Request)13 Date (java.util.Date)12 LinkedList (java.util.LinkedList)11 ChangeRequest (net.geoprism.registry.action.ChangeRequest)11 JsonArray (com.google.gson.JsonArray)10 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)10 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)10 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)9 GraphQuery (com.runwaysdk.business.graph.GraphQuery)8 UpdateAttributeAction (net.geoprism.registry.action.geoobject.UpdateAttributeAction)8 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)8 QueryFactory (com.runwaysdk.query.QueryFactory)6 SimpleDateFormat (java.text.SimpleDateFormat)6 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)6 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)6 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)5