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