use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class HierarchicalRelationshipType method getChildren.
public List<ServerGeoObjectType> getChildren(ServerGeoObjectType parent) {
Universal universal = parent.getUniversal();
List<ServerGeoObjectType> children = new LinkedList<>();
String mdRelationshipType = this.getMdTermRelationship().definesType();
try (OIterator<? extends Business> iterator = universal.getDirectDescendants(mdRelationshipType)) {
while (iterator.hasNext()) {
Universal cUniversal = (Universal) iterator.next();
children.add(ServerGeoObjectType.get(cUniversal));
}
}
return children;
}
use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class IncrementalListType method createEntries.
@Override
@Transaction
public void createEntries(JsonObject metadata) {
if (!this.isValid()) {
throw new InvalidMasterListException();
}
final ServerGeoObjectType objectType = this.getGeoObjectType();
Pair<Date, Date> range = this.getDateRange(objectType);
if (metadata == null) {
List<ListTypeEntry> entries = this.getEntries();
if (entries.size() > 0) {
ListTypeEntry entry = entries.get(0);
ListTypeVersion working = entry.getWorking();
metadata = working.toJSON(false);
}
}
if (range != null) {
Date endDate = range.getSecond();
if (endDate.after(new Date())) {
endDate = new Date();
}
List<Date> dates = this.getFrequencyDates(range.getFirst(), range.getSecond());
for (Date date : dates) {
this.getOrCreateEntry(date, metadata);
}
} else {
throw new EmptyListException();
}
}
use of net.geoprism.registry.model.ServerGeoObjectType 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.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class ListType method listForType.
public static JsonObject listForType(String typeCode) {
ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
Organization org = type.getOrganization();
final boolean isMember = Organization.isMember(org);
ListTypeQuery query = new ListTypeQuery(new QueryFactory());
query.WHERE(query.getUniversal().EQ(type.getUniversal()));
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
final JsonArray lists = new JsonArray();
try (OIterator<? extends ListType> it = query.getIterator()) {
it.getAll().stream().sorted((a, b) -> {
return a.getDisplayLabel().getValue().compareTo(b.getDisplayLabel().getValue());
}).filter(f -> {
return true;
}).forEach(list -> {
// JsonObject object = new JsonObject();
// object.addProperty("label", list.getDisplayLabel().getValue());
// object.addProperty("oid", list.getOid());
// object.addProperty("createDate",
// format.format(list.getCreateDate()));
// object.addProperty("lasteUpdateDate",
// format.format(list.getLastUpdateDate()));
// object.addProperty("write", list.doesActorHaveWritePermission());
// object.addProperty("read", list.doesActorHaveReadPermission());
//
lists.add(list.toJSON());
});
}
JsonObject object = new JsonObject();
object.addProperty("orgCode", org.getCode());
object.addProperty("orgLabel", org.getDisplayLabel().getValue());
object.addProperty("typeCode", type.getCode());
object.addProperty("typeLabel", type.getLabel().getValue());
object.addProperty("geometryType", type.getGeometryType().name());
object.addProperty("write", doesActorHaveWritePermissions(type));
object.add("lists", lists);
return object;
}
use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class ListType method markAsInvalid.
public void markAsInvalid(ServerHierarchyType hierarchyType, ServerGeoObjectType type) {
boolean isValid = true;
JsonArray hierarchies = this.getHierarchiesAsJson();
ServerGeoObjectType masterlistType = this.getGeoObjectType();
for (int i = 0; i < hierarchies.size(); i++) {
JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
String hCode = hierarchy.get("code").getAsString();
Optional<ServerHierarchyType> ht = ServiceFactory.getMetadataCache().getHierachyType(hCode);
if (ht.isPresent()) {
ServerHierarchyType actualHierarchy = masterlistType.findHierarchy(ht.get(), type);
if (hCode.equals(hierarchyType.getCode()) || actualHierarchy.getCode().equals(hierarchyType.getCode())) {
List<String> pCodes = this.getParentCodes(hierarchy);
if (pCodes.contains(type.getCode()) || type.getCode().equals(masterlistType.getCode())) {
isValid = false;
}
}
} else {
isValid = false;
}
}
if (!isValid) {
this.appLock();
this.setValid(false);
this.apply();
}
}
Aggregations