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