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