use of net.geoprism.registry.service.LocaleSerializer in project geoprism-registry by terraframe.
the class ListType method toJSON.
public JsonObject toJSON(boolean includeEntries) {
Locale locale = Session.getCurrentLocale();
LocaleSerializer serializer = new LocaleSerializer(locale);
ServerGeoObjectType type = ServerGeoObjectType.get(this.getUniversal());
ServerGeoObjectType superType = type.getSuperType();
Organization org = type.getOrganization();
JsonObject object = new JsonObject();
if (this.isAppliedToDB()) {
object.addProperty(ListType.OID, this.getOid());
}
object.addProperty(ListType.ORGANIZATION, org.getCode());
object.addProperty("write", this.doesActorHaveWritePermission());
object.addProperty("read", this.doesActorHaveReadPermission());
object.addProperty("exploratory", this.doesActorHaveExploratoryPermission());
object.addProperty("typeLabel", type.getLabel().getValue());
object.addProperty("typePrivate", type.getIsPrivate());
object.addProperty(ListType.TYPE_CODE, type.getCode());
object.add(ListType.DISPLAYLABEL, LocalizedValueConverter.convertNoAutoCoalesce(this.getDisplayLabel()).toJSON(serializer));
object.add(ListType.DESCRIPTION, LocalizedValueConverter.convertNoAutoCoalesce(this.getDescription()).toJSON(serializer));
object.addProperty(ListType.CODE, this.getCode());
object.add(ListType.HIERARCHIES, this.getHierarchiesAsJson());
object.add(ListType.SUBTYPEHIERARCHIES, this.getSubtypeHierarchiesAsJson());
if (this.getFilterJson() != null && this.getFilterJson().length() > 0) {
object.add(ListType.FILTER, JsonParser.parseString(this.getFilterJson()).getAsJsonArray());
}
if (type.getGeometryType().equals(GeometryType.MULTIPOINT) || type.getGeometryType().equals(GeometryType.POINT)) {
object.addProperty(ListType.INCLUDELATLONG, this.getIncludeLatLong());
}
if (superType != null) {
object.addProperty("superTypeCode", superType.getCode());
}
// Include the list metadata
object.add(ListType.LIST_METADATA, this.toMetadataJSON("list", serializer));
object.add(ListType.GEOSPATIAL_METADATA, this.toMetadataJSON("geospatial", serializer));
if (includeEntries) {
List<ListTypeEntry> entries = this.getEntries();
JsonArray jEntries = new JsonArray();
for (ListTypeEntry entry : entries) {
jEntries.add(entry.toJSON());
}
object.add("entries", jEntries);
}
return object;
}
use of net.geoprism.registry.service.LocaleSerializer in project geoprism-registry by terraframe.
the class MasterList method toJSON.
public JsonObject toJSON(String versionType) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Locale locale = Session.getCurrentLocale();
LocaleSerializer serializer = new LocaleSerializer(locale);
ServerGeoObjectType type = ServerGeoObjectType.get(this.getUniversal());
JsonObject object = new JsonObject();
if (this.isAppliedToDB()) {
final Organization org = this.getOrganization();
object.addProperty(MasterList.OID, this.getOid());
object.addProperty(MasterList.ORGANIZATION, org.getOid());
} else {
object.addProperty(MasterList.ORGANIZATION, this.getOrganizationOid());
}
object.addProperty("write", this.doesActorHaveWritePermission());
object.addProperty("read", this.doesActorHaveReadPermission());
object.addProperty("exploratory", this.doesActorHaveExploratoryPermission());
object.add("typeLabel", type.getLabel().toJSON(serializer));
object.addProperty(MasterList.TYPE_CODE, type.getCode());
object.add(MasterList.DISPLAYLABEL, LocalizedValueConverter.convertNoAutoCoalesce(this.getDisplayLabel()).toJSON(serializer));
object.addProperty(MasterList.CODE, this.getCode());
object.add(MasterList.DESCRIPTIONLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getDescriptionLocal()).toJSON(serializer));
object.add(MasterList.DESCRIPTIONLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getDescriptionLocal()).toJSON(serializer));
object.add(MasterList.PROCESSLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getProcessLocal()).toJSON(serializer));
object.add(MasterList.PROGRESSLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getProgressLocal()).toJSON(serializer));
object.add(MasterList.ACCESSCONSTRAINTSLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getAccessConstraintsLocal()).toJSON(serializer));
object.add(MasterList.USECONSTRAINTSLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getUseConstraintsLocal()).toJSON(serializer));
object.add(MasterList.ACKNOWLEDGEMENTSLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getAcknowledgementsLocal()).toJSON(serializer));
object.add(MasterList.DISCLAIMERLOCAL, LocalizedValueConverter.convertNoAutoCoalesce(this.getDisclaimerLocal()).toJSON(serializer));
object.addProperty(MasterList.CONTACTNAME, this.getContactName());
object.addProperty(MasterList.TELEPHONENUMBER, this.getTelephoneNumber());
object.addProperty(MasterList.EMAIL, this.getEmail());
object.addProperty(MasterList.FREQUENCY, this.toFrequency().name());
object.addProperty(MasterList.ISMASTER, this.getIsMaster());
object.addProperty(MasterList.VISIBILITY, this.getVisibility());
object.add(MasterList.HIERARCHIES, this.getHierarchiesAsJson());
object.add(MasterList.SUBTYPEHIERARCHIES, this.getSubtypeHierarchiesAsJson());
if (this.getPublishingStartDate() != null) {
object.addProperty(MasterList.PUBLISHINGSTARTDATE, format.format(this.getPublishingStartDate()));
}
if (this.getRepresentativityDate() != null) {
object.addProperty(MasterList.REPRESENTATIVITYDATE, format.format(this.getRepresentativityDate()));
}
if (this.getPublishDate() != null) {
object.addProperty(MasterList.PUBLISHDATE, format.format(this.getPublishDate()));
}
if (versionType != null) {
List<MasterListVersion> versions = this.getVersions(versionType);
JsonArray jVersions = new JsonArray();
for (MasterListVersion version : versions) {
jVersions.add(version.toJSON(false));
}
object.add(MasterList.VERSIONS, jVersions);
}
return object;
}
Aggregations