Search in sources :

Example 71 with ServerGeoObjectType

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

the class RegistryService method getAncestors.

@Request(RequestType.SESSION)
public List<GeoObjectType> getAncestors(String sessionId, String code, String hierarchyCode, Boolean includeInheritedTypes, Boolean includeChild) {
    ServerGeoObjectType child = ServerGeoObjectType.get(code);
    ServerHierarchyType hierarchyType = ServerHierarchyType.get(hierarchyCode);
    List<GeoObjectType> ancestors = child.getTypeAncestors(hierarchyType, includeInheritedTypes);
    if (includeChild) {
        ancestors.add(child.getType());
    }
    return ancestors;
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 72 with ServerGeoObjectType

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

the class RegistryService method createGeoObjectType.

/**
 * Creates a {@link GeoObjectType} from the given JSON.
 *
 * @param sessionId
 * @param gtJSON
 *          JSON of the {@link GeoObjectType} to be created.
 * @return newly created {@link GeoObjectType}
 */
@Request(RequestType.SESSION)
public GeoObjectType createGeoObjectType(String sessionId, String gtJSON) {
    ServerGeoObjectType type = null;
    type = new ServerGeoObjectTypeConverter().create(gtJSON);
    ((Session) Session.getCurrentSession()).reloadPermissions();
    // If this did not error out then add to the cache
    ServiceFactory.getMetadataCache().addGeoObjectType(type);
    NotificationFacade.queue(new GlobalNotificationMessage(MessageType.TYPE_CACHE_CHANGE, null));
    return type.getType();
}
Also used : ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage) Session(com.runwaysdk.session.Session) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 73 with ServerGeoObjectType

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

the class RegistryService method updateAttributeType.

/**
 * Updates an attribute in the given {@link GeoObjectType}.
 *
 * @pre given {@link GeoObjectType} must already exist.
 *
 * @param sessionId
 * @param geoObjectTypeCode
 *          string of the {@link GeoObjectType} to be updated.
 * @param attributeTypeJSON
 *          AttributeType to be added to the GeoObjectType
 * @return updated {@link AttributeType}
 */
@Request(RequestType.SESSION)
public AttributeType updateAttributeType(String sessionId, String geoObjectTypeCode, String attributeTypeJSON) {
    ServerGeoObjectType got = ServerGeoObjectType.get(geoObjectTypeCode);
    ServiceFactory.getGeoObjectTypePermissionService().enforceCanWrite(got.getOrganization().getCode(), got, got.getIsPrivate());
    AttributeType attrType = got.updateAttributeType(attributeTypeJSON);
    return attrType;
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 74 with ServerGeoObjectType

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

the class RegistryService method createAttributeType.

/**
 * Adds an attribute to the given {@link GeoObjectType}.
 *
 * @pre given {@link GeoObjectType} must already exist.
 *
 * @param sessionId
 *
 * @param geoObjectTypeCode
 *          string of the {@link GeoObjectType} to be updated.
 * @param attributeTypeJSON
 *          AttributeType to be added to the GeoObjectType
 * @return updated {@link GeoObjectType}
 */
@Request(RequestType.SESSION)
public AttributeType createAttributeType(String sessionId, String geoObjectTypeCode, String attributeTypeJSON) {
    ServerGeoObjectType got = ServerGeoObjectType.get(geoObjectTypeCode);
    ServiceFactory.getGeoObjectTypePermissionService().enforceCanWrite(got.getOrganization().getCode(), got, got.getIsPrivate());
    AttributeType attrType = got.createAttributeType(attributeTypeJSON);
    return attrType;
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 75 with ServerGeoObjectType

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

the class ShapefileService method getShapefileConfiguration.

@Request(RequestType.SESSION)
public JSONObject getShapefileConfiguration(String sessionId, String type, Date startDate, Date endDate, String fileName, InputStream fileStream, ImportStrategy strategy, Boolean copyBlank) {
    // Save the file to the file system
    try {
        ServerGeoObjectType geoObjectType = ServerGeoObjectType.get(type);
        VaultFile vf = VaultFile.createAndApply(fileName, fileStream);
        try (CloseableFile dbf = ShapefileImporter.getShapefileFromResource(vf, "dbf")) {
            SimpleDateFormat format = new SimpleDateFormat(GeoObjectImportConfiguration.DATE_FORMAT);
            format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
            JSONObject object = new JSONObject();
            object.put(GeoObjectImportConfiguration.TYPE, this.getType(geoObjectType));
            object.put(GeoObjectImportConfiguration.SHEET, this.getSheetInformation(dbf));
            object.put(ImportConfiguration.VAULT_FILE_ID, vf.getOid());
            object.put(ImportConfiguration.FILE_NAME, fileName);
            object.put(GeoObjectImportConfiguration.HAS_POSTAL_CODE, PostalCodeFactory.isAvailable(geoObjectType));
            object.put(ImportConfiguration.IMPORT_STRATEGY, strategy.name());
            object.put(ImportConfiguration.FORMAT_TYPE, FormatImporterType.SHAPEFILE.name());
            object.put(ImportConfiguration.OBJECT_TYPE, ObjectImporterFactory.ObjectImportType.GEO_OBJECT.name());
            object.put(ImportConfiguration.COPY_BLANK, copyBlank);
            if (startDate != null) {
                object.put(GeoObjectImportConfiguration.START_DATE, format.format(startDate));
            }
            if (endDate != null) {
                object.put(GeoObjectImportConfiguration.END_DATE, format.format(endDate));
            }
            return object;
        }
    } catch (RunwayException | SmartException e) {
        throw e;
    } catch (Exception e) {
        throw new ProgrammingErrorException(e);
    }
}
Also used : JSONObject(org.json.JSONObject) SmartException(com.runwaysdk.business.SmartException) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VaultFile(com.runwaysdk.system.VaultFile) CloseableFile(com.runwaysdk.resource.CloseableFile) SimpleDateFormat(java.text.SimpleDateFormat) RunwayException(com.runwaysdk.RunwayException) SmartException(com.runwaysdk.business.SmartException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) RunwayException(com.runwaysdk.RunwayException) ShapefileFormatException(net.geoprism.registry.etl.ShapefileFormatException) IOException(java.io.IOException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) 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