Search in sources :

Example 46 with ServerGeoObjectType

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

the class ServerGeoObjectService method getGeoObject.

public ServerGeoObjectIF getGeoObject(GeoObject go) {
    ServerGeoObjectType type = ServerGeoObjectType.get(go.getType());
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    return strategy.constructFromGeoObject(go, false);
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF)

Example 47 with ServerGeoObjectType

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

the class ServerGeoObjectService method getGeoObject.

public ServerGeoObjectIF getGeoObject(GeoObjectOverTime timeGO) {
    ServerGeoObjectType type = ServerGeoObjectType.get(timeGO.getType());
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    return strategy.constructFromGeoObjectOverTime(timeGO, false);
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF)

Example 48 with ServerGeoObjectType

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

the class HierarchyService method removeInheritedHierarchy.

/**
 * Modifies a hierarchy to remove inheritance from another hierarchy for the
 * given root
 *
 * @param sessionId
 * @param hierarchyTypeCode
 *          code of the {@link HierarchyType} being modified.
 * @param geoObjectTypeCode
 *          code of the root {@link GeoObjectType}.
 */
@Request(RequestType.SESSION)
public HierarchyType removeInheritedHierarchy(String sessionId, String hierarchyTypeCode, String geoObjectTypeCode) {
    ServerHierarchyType forHierarchy = ServerHierarchyType.get(hierarchyTypeCode);
    ServerGeoObjectType childType = ServerGeoObjectType.get(geoObjectTypeCode);
    ServiceFactory.getGeoObjectTypeRelationshipPermissionService().enforceCanAddChild(forHierarchy, null, childType);
    ServerGeoObjectType type = ServerGeoObjectType.get(geoObjectTypeCode);
    type.removeInheritedHierarchy(forHierarchy);
    forHierarchy.refresh();
    return forHierarchy.toHierarchyType();
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request)

Example 49 with ServerGeoObjectType

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

the class HierarchyService method getHierarchyGroupedTypes.

@Request(RequestType.SESSION)
public JsonArray getHierarchyGroupedTypes(String sessionId) {
    final HierarchyTypePermissionServiceIF hierarchyPermissions = ServiceFactory.getHierarchyPermissionService();
    final GeoObjectTypePermissionServiceIF typePermissions = ServiceFactory.getGeoObjectTypePermissionService();
    final RolePermissionService rps = ServiceFactory.getRolePermissionService();
    final boolean isSRA = rps.isSRA();
    JsonArray allHiers = new JsonArray();
    List<ServerHierarchyType> shts = ServiceFactory.getMetadataCache().getAllHierarchyTypes();
    for (ServerHierarchyType sht : shts) {
        final String htOrgCode = sht.getOrganizationCode();
        if (hierarchyPermissions.canRead(htOrgCode) && (isSRA || rps.isRA(htOrgCode) || rps.isRM(htOrgCode))) {
            JsonObject hierView = new JsonObject();
            hierView.addProperty("code", sht.getCode());
            hierView.addProperty("label", sht.getDisplayLabel().getValue());
            hierView.addProperty("orgCode", sht.getOrganizationCode());
            JsonArray allHierTypes = new JsonArray();
            List<ServerGeoObjectType> types = sht.getAllTypes();
            for (ServerGeoObjectType type : types) {
                final String gotOrgCode = type.getOrganizationCode();
                if (typePermissions.canRead(gotOrgCode, type, type.getIsPrivate()) && (isSRA || rps.isRA(gotOrgCode) || rps.isRM(gotOrgCode, type))) {
                    if (type.getIsAbstract()) {
                        JsonObject superView = new JsonObject();
                        superView.addProperty("code", type.getCode());
                        superView.addProperty("label", type.getLabel().getValue());
                        superView.addProperty("orgCode", type.getOrganizationCode());
                        superView.addProperty("isAbstract", true);
                        List<ServerGeoObjectType> subtypes = type.getSubtypes();
                        for (ServerGeoObjectType subtype : subtypes) {
                            JsonObject typeView = new JsonObject();
                            typeView.addProperty("code", subtype.getCode());
                            typeView.addProperty("label", subtype.getLabel().getValue());
                            typeView.addProperty("orgCode", subtype.getOrganization().getCode());
                            typeView.add("super", superView);
                            allHierTypes.add(typeView);
                        }
                    } else {
                        JsonObject typeView = new JsonObject();
                        typeView.addProperty("code", type.getCode());
                        typeView.addProperty("label", type.getLabel().getValue());
                        typeView.addProperty("orgCode", type.getOrganizationCode());
                        allHierTypes.add(typeView);
                    }
                }
            }
            hierView.add("types", allHierTypes);
            allHiers.add(hierView);
        }
    }
    return allHiers;
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) JsonArray(com.google.gson.JsonArray) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyTypePermissionServiceIF(net.geoprism.registry.permission.HierarchyTypePermissionServiceIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) GeoObjectTypePermissionServiceIF(net.geoprism.registry.permission.GeoObjectTypePermissionServiceIF) Request(com.runwaysdk.session.Request)

Example 50 with ServerGeoObjectType

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

the class HierarchyService method insertBetweenTypes.

/**
 * Inserts the {@link GeoObjectType} 'middleGeoObjectTypeCode' into the
 * hierarchy as the child of 'parentGeoObjectTypeCode' and the new parent for
 * 'youngestGeoObjectTypeCode'. If an existing parent/child relationship
 * already exists between 'youngestGeoObjectTypeCode' and
 * 'parentgeoObjectTypeCode', it will first be removed.
 * youngestGeoObjectTypeCode can also be an array (comma separated list).
 *
 * @param sessionId
 * @param hierarchyTypeCode
 *          code of the {@link HierarchyType}
 * @param parentGeoObjectTypeCode
 *          parent {@link GeoObjectType}.
 * @param middleGeoObjectTypeCode
 *          middle child {@link GeoObjectType} after this method returns
 * @param youngestGeoObjectTypeCode
 *          youngest child {@link GeoObjectType} after this method returns
 */
@Request(RequestType.SESSION)
public HierarchyType insertBetweenTypes(String sessionId, String hierarchyTypeCode, String parentGeoObjectTypeCode, String middleGeoObjectTypeCode, String youngestGeoObjectTypeCode) {
    ServerHierarchyType type = ServerHierarchyType.get(hierarchyTypeCode);
    ServerGeoObjectType parentType = ServerGeoObjectType.get(parentGeoObjectTypeCode);
    ServerGeoObjectType middleType = ServerGeoObjectType.get(middleGeoObjectTypeCode);
    List<ServerGeoObjectType> youngestTypes = Arrays.asList(youngestGeoObjectTypeCode.split(",")).stream().map(code -> ServerGeoObjectType.get(code.trim())).collect(Collectors.toList());
    ServiceFactory.getGeoObjectTypeRelationshipPermissionService().enforceCanAddChild(type, parentType, middleType);
    type.insertBetween(parentType, middleType, youngestTypes);
    return type.toHierarchyType();
}
Also used : JsonObject(com.google.gson.JsonObject) Arrays(java.util.Arrays) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyTypePermissionServiceIF(net.geoprism.registry.permission.HierarchyTypePermissionServiceIF) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime) Collection(java.util.Collection) RequestType(com.runwaysdk.session.RequestType) GeoRegistryUtil(net.geoprism.registry.GeoRegistryUtil) Set(java.util.Set) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Collectors(java.util.stream.Collectors) Request(com.runwaysdk.session.Request) ServiceFactory(net.geoprism.registry.service.ServiceFactory) PermissionContext(net.geoprism.registry.permission.PermissionContext) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) GeoObjectRelationshipPermissionServiceIF(net.geoprism.registry.permission.GeoObjectRelationshipPermissionServiceIF) List(java.util.List) JsonArray(com.google.gson.JsonArray) Organization(net.geoprism.registry.Organization) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) Session(com.runwaysdk.session.Session) GeoObjectTypePermissionServiceIF(net.geoprism.registry.permission.GeoObjectTypePermissionServiceIF) RolePermissionService(net.geoprism.registry.permission.RolePermissionService) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request)

Aggregations

ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)201 Request (com.runwaysdk.session.Request)69 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)57 JsonObject (com.google.gson.JsonObject)48 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)32 JsonArray (com.google.gson.JsonArray)30 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)30 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)27 LinkedList (java.util.LinkedList)27 Test (org.junit.Test)27 VertexObject (com.runwaysdk.business.graph.VertexObject)26 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)26 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)23 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)23 Date (java.util.Date)21 GraphQuery (com.runwaysdk.business.graph.GraphQuery)19 List (java.util.List)18 EdgeObject (com.runwaysdk.business.graph.EdgeObject)17 SimpleDateFormat (java.text.SimpleDateFormat)17 Locale (java.util.Locale)17