use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class ListType method markAsInvalid.
public void markAsInvalid(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()) {
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();
}
}
use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class ListType method parse.
protected void parse(JsonObject object) {
String typeCode = object.get(ListType.TYPE_CODE).getAsString();
ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
this.setUniversal(type.getUniversal());
LocalizedValueConverter.populate(this.getDisplayLabel(), LocalizedValue.fromJSON(object.get(ListType.DISPLAYLABEL).getAsJsonObject()));
LocalizedValueConverter.populate(this.getDescription(), LocalizedValue.fromJSON(object.get(ListType.DESCRIPTION).getAsJsonObject()));
this.setCode(object.get(ListType.CODE).getAsString());
this.setHierarchies(object.get(ListType.HIERARCHIES).getAsJsonArray().toString());
this.setOrganization(Organization.getByCode(object.get(ListType.ORGANIZATION).getAsString()));
if (object.has(ListType.INCLUDELATLONG)) {
this.setIncludeLatLong(object.get(ListType.INCLUDELATLONG).getAsBoolean());
}
if (object.has(ListType.SUBTYPEHIERARCHIES) && !object.get(ListType.SUBTYPEHIERARCHIES).isJsonNull()) {
this.setSubtypeHierarchies(object.get(ListType.SUBTYPEHIERARCHIES).getAsJsonArray().toString());
}
if (object.has(ListType.FILTER) && !object.get(ListType.FILTER).isJsonNull()) {
this.setFilterJson(object.get(ListType.FILTER).getAsJsonArray().toString());
}
// Parse the list metadata
// this.parseMetadata("list", object.get(LIST_METADATA).getAsJsonObject());
// this.parseMetadata("geospatial",
// object.get(GEOSPATIAL_METADATA).getAsJsonObject());
}
use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class ListType method getAncestorMap.
public Map<ServerHierarchyType, List<ServerGeoObjectType>> getAncestorMap(ServerGeoObjectType type) {
Map<ServerHierarchyType, List<ServerGeoObjectType>> map = new HashMap<>();
JsonArray hierarchies = this.getHierarchiesAsJson();
for (int i = 0; i < hierarchies.size(); i++) {
JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
List<String> pCodes = this.getParentCodes(hierarchy);
if (pCodes.size() > 0) {
String hCode = hierarchy.get("code").getAsString();
ServerHierarchyType hierarchyType = ServerHierarchyType.get(hCode);
List<GeoObjectType> dtoAncestors = type.getTypeAncestors(hierarchyType, true);
List<ServerGeoObjectType> ancestors = new LinkedList<ServerGeoObjectType>();
for (GeoObjectType ancestor : dtoAncestors) {
ancestors.add(ServerGeoObjectType.get(ancestor));
}
map.put(hierarchyType, ancestors);
}
}
return map;
}
use of net.geoprism.registry.model.ServerGeoObjectType in project geoprism-registry by terraframe.
the class ListTypeVersion method publishNoAuth.
@Transaction
public String publishNoAuth() {
this.lock();
try {
ListType masterlist = this.getListType();
if (!masterlist.isValid()) {
throw new InvalidMasterListException();
}
// Delete tile cache
ListTileCache.deleteTiles(this);
ListCurationHistory.deleteAll(this);
MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
mdBusiness.deleteAllRecords();
MdAttributeConcreteDAO status = (MdAttributeConcreteDAO) mdBusiness.definesAttribute("status");
if (status != null) {
ListTypeAttributeGroup.remove(status);
status.delete();
}
MdAttributeConcreteDAO statusDefaultLocale = (MdAttributeConcreteDAO) mdBusiness.definesAttribute("statusDefaultLocale");
if (statusDefaultLocale != null) {
ListTypeAttributeGroup.remove(statusDefaultLocale);
statusDefaultLocale.delete();
}
ServerGeoObjectType type = ServerGeoObjectType.get(masterlist.getUniversal());
Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
// Add the type ancestor fields
Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap = masterlist.getAncestorMap(type);
Collection<AttributeType> attributes = type.getAttributeMap().values();
Set<ServerHierarchyType> hierarchiesOfSubTypes = type.getHierarchiesOfSubTypes();
// ServerGeoObjectService service = new ServerGeoObjectService();
// ServerGeoObjectQuery query = service.createQuery(type,
// this.getPeriod());
Date forDate = this.getForDate();
BasicVertexRestriction restriction = masterlist.getRestriction(type, forDate);
BasicVertexQuery query = new BasicVertexQuery(type, forDate);
query.setRestriction(restriction);
Long count = query.getCount();
if (count == null) {
count = 0L;
}
long current = 0;
try {
ProgressService.put(this.getOid(), new Progress(0L, count, ""));
int pageSize = 1000;
long skip = 0;
while (skip < count) {
query = new BasicVertexQuery(type, forDate);
query.setRestriction(restriction);
query.setLimit(pageSize);
query.setSkip(skip);
// List<GeoObjectStatus> validStats = new
// ArrayList<GeoObjectStatus>();
// validStats.add(GeoObjectStatus.ACTIVE);
// validStats.add(GeoObjectStatus.INACTIVE);
// validStats.add(GeoObjectStatus.PENDING);
// validStats.add(GeoObjectStatus.NEW);
// query.setRestriction(new ServerStatusRestriction(validStats,
// this.getForDate(), JoinOp.OR));
List<ServerGeoObjectIF> results = query.getResults();
for (ServerGeoObjectIF result : results) {
Business business = new Business(mdBusiness.definesType());
publish(masterlist, type, result, business, attributes, ancestorMap, hierarchiesOfSubTypes, locales);
Thread.yield();
ProgressService.put(this.getOid(), new Progress(current++, count, ""));
}
skip += pageSize;
}
this.setPublishDate(new Date());
this.apply();
return this.toJSON(true).toString();
} finally {
ProgressService.remove(this.getOid());
}
} finally {
this.unlock();
}
}
use of net.geoprism.registry.model.ServerGeoObjectType 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