Search in sources :

Example 1 with CurationService

use of net.geoprism.registry.curation.CurationService in project geoprism-registry by terraframe.

the class ListTypeVersion method toJSON.

public JsonObject toJSON(boolean includeAttribute) {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    String filename = this.getOid() + ".zip";
    ListType masterlist = this.getListType();
    final File directory = masterlist.getShapefileDirectory();
    final File file = new File(directory, filename);
    ServerGeoObjectType type = ServerGeoObjectType.get(masterlist.getUniversal());
    boolean isMember = Organization.isMember(masterlist.getOrganization());
    JsonObject object = new JsonObject();
    if (this.isAppliedToDB()) {
        object.addProperty(ListTypeVersion.OID, this.getOid());
    }
    object.addProperty(ListType.DISPLAYLABEL, masterlist.getDisplayLabel().getValue());
    object.addProperty(ListTypeVersion.TYPE_CODE, type.getCode());
    object.addProperty(ListTypeVersion.ORG_CODE, type.getOrganization().getCode());
    object.addProperty(ListTypeVersion.LISTTYPE, masterlist.getOid());
    object.addProperty(ListTypeVersion.FORDATE, format.format(this.getForDate()));
    object.addProperty(ListTypeVersion.CREATEDATE, format.format(this.getCreateDate()));
    object.addProperty(ListTypeVersion.VERSIONNUMBER, this.getVersionNumber());
    object.addProperty(ListTypeVersion.WORKING, this.getWorking());
    object.addProperty("isGeometryEditable", type.isGeometryEditable());
    object.addProperty("isAbstract", type.getIsAbstract());
    object.addProperty("shapefile", file.exists());
    object.addProperty("isMember", isMember);
    object.add(ListTypeVersion.PERIOD, masterlist.formatVersionLabel(this));
    object.add(ListType.LIST_METADATA, this.toMetadataJSON("list"));
    object.add(ListType.GEOSPATIAL_METADATA, this.toMetadataJSON("geospatial"));
    Progress progress = ProgressService.get(this.getOid());
    if (progress != null) {
        object.add("refreshProgress", progress.toJson());
    }
    if (type.getSuperType() != null) {
        object.addProperty("superTypeCode", type.getSuperType().getCode());
    }
    if (type.getIsAbstract()) {
        JsonArray subtypes = new JsonArray();
        for (ServerGeoObjectType subtype : type.getSubtypes()) {
            JsonObject jo = new JsonObject();
            jo.addProperty("code", subtype.getCode());
            jo.addProperty("label", subtype.getLabel().getValue());
            subtypes.add(jo);
        }
        object.add("subtypes", subtypes);
    }
    if (this.getPublishDate() != null) {
        object.addProperty(ListTypeVersion.PUBLISHDATE, format.format(this.getPublishDate()));
    }
    if (includeAttribute) {
        object.add(ListTypeVersion.ATTRIBUTES, this.getAttributesAsJson());
    }
    if (this.getWorking() && masterlist.doesActorHaveWritePermission()) {
        object.add("curation", new CurationService().getListCurationInfo(this));
    } else {
        object.add("curation", new JsonObject());
    }
    return object;
}
Also used : JsonArray(com.google.gson.JsonArray) Progress(net.geoprism.registry.progress.Progress) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) CurationService(net.geoprism.registry.curation.CurationService) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File)

Aggregations

JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 MdAttributeLineString (com.runwaysdk.system.gis.metadata.MdAttributeLineString)1 MdAttributeMultiLineString (com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString)1 File (java.io.File)1 SimpleDateFormat (java.text.SimpleDateFormat)1 CurationService (net.geoprism.registry.curation.CurationService)1 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)1 Progress (net.geoprism.registry.progress.Progress)1