Search in sources :

Example 66 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class RegistryService method deleteTerm.

/**
 * Deletes the {@link Term} with the given code. All children codoe will be
 * deleted.
 *
 * @param sessionId
 * @param parentTermCode
 *          TODO
 * @param geoObjectTypeCode
 * @param attributeTypeJSON
 */
@Request(RequestType.SESSION)
public void deleteTerm(String sessionId, String parentTermCode, String termCode) {
    String parentClassifierKey = TermConverter.buildClassifierKeyFromTermCode(parentTermCode);
    Classifier parent = Classifier.getByKey(parentClassifierKey);
    TermConverter.enforceTermPermissions(parent, CGRPermissionAction.DELETE);
    String classifierKey = Classifier.buildKey(parent.getKey(), termCode);
    Classifier classifier = Classifier.getByKey(classifierKey);
    List<MdAttributeConcrete> mdAttrList = this.findRootClassifier(classifier);
    classifier.delete();
    this.refreshAttributeTermTypeInCache(mdAttrList);
}
Also used : Classifier(net.geoprism.ontology.Classifier) MdAttributeConcrete(com.runwaysdk.system.metadata.MdAttributeConcrete) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 67 with Request

use of com.runwaysdk.session.Request 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 68 with Request

use of com.runwaysdk.session.Request 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)

Example 69 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class ShapefileService method cancelImport.

@Request(RequestType.SESSION)
public void cancelImport(String sessionId, String json) {
    ImportConfiguration config = ImportConfiguration.build(json);
    String id = config.getVaultFileId();
    VaultFile.get(id).delete();
}
Also used : ImportConfiguration(net.geoprism.registry.etl.upload.ImportConfiguration) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) Request(com.runwaysdk.session.Request)

Example 70 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class SynchronizationConfigService method getJobs.

@Request(RequestType.SESSION)
public JsonObject getJobs(String sessionId, String configId, Integer pageSize, Integer pageNumber) {
    QueryFactory qf = new QueryFactory();
    DataExportJobQuery jQuery = new DataExportJobQuery(qf);
    jQuery.WHERE(jQuery.getConfig().EQ(configId));
    ExportHistoryQuery ihq = new ExportHistoryQuery(qf);
    ihq.WHERE(ihq.job(jQuery));
    ihq.restrictRows(pageSize, pageNumber);
    ihq.ORDER_BY_DESC(ihq.getCreateDate());
    try (OIterator<? extends ExportHistory> it = ihq.getIterator()) {
        LinkedList<JsonWrapper> results = new LinkedList<JsonWrapper>();
        while (it.hasNext()) {
            ExportHistory hist = it.next();
            DataExportJob job = (DataExportJob) hist.getAllJob().getAll().get(0);
            GeoprismUser user = GeoprismUser.get(job.getRunAsUser().getOid());
            results.add(new JsonWrapper(serializeHistory(hist, user, job)));
        }
        return new Page<JsonWrapper>(ihq.getCount(), pageNumber, pageSize, results).toJSON();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) JsonWrapper(net.geoprism.registry.view.JsonWrapper) ExportHistoryQuery(net.geoprism.registry.etl.export.ExportHistoryQuery) ExportHistory(net.geoprism.registry.etl.export.ExportHistory) GeoprismUser(net.geoprism.GeoprismUser) DataExportJobQuery(net.geoprism.registry.etl.export.DataExportJobQuery) LinkedList(java.util.LinkedList) DataExportJob(net.geoprism.registry.etl.export.DataExportJob) Request(com.runwaysdk.session.Request)

Aggregations

Request (com.runwaysdk.session.Request)340 Test (org.junit.Test)145 JsonObject (com.google.gson.JsonObject)85 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)73 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)73 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)53 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)40 JsonArray (com.google.gson.JsonArray)36 Date (java.util.Date)33 ChangeRequest (net.geoprism.registry.action.ChangeRequest)32 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)31 QueryFactory (com.runwaysdk.query.QueryFactory)30 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)26 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)22 ListType (net.geoprism.registry.ListType)21 SimpleDateFormat (java.text.SimpleDateFormat)19 Classification (net.geoprism.registry.model.Classification)19 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)19 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)17 TransitionEvent (net.geoprism.registry.graph.transition.TransitionEvent)17