use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class RegistryService method refreshMetadataCache.
public void refreshMetadataCache() {
ServiceFactory.getMetadataCache().rebuild();
QueryFactory qf = new QueryFactory();
UniversalQuery uq = new UniversalQuery(qf);
OIterator<? extends Universal> it = uq.getIterator();
try {
while (it.hasNext()) {
Universal uni = it.next();
if (uni.getKey().equals(Universal.ROOT_KEY)) {
continue;
}
ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
ServiceFactory.getMetadataCache().addGeoObjectType(type);
}
} finally {
it.close();
}
// We must build the hierarchy types which are inherited first
// Otherwise you will end up with a NPE when building the hierarchies
// which inherit the inherited hierarchy if it hasn't been built
HierarchicalRelationshipType.getInheritedTypes().forEach(relationship -> {
ServerHierarchyType ht = new ServerHierarchyTypeBuilder().get(relationship, false);
ServiceFactory.getMetadataCache().addHierarchyType(ht);
});
HierarchicalRelationshipType.getAll().forEach(relationship -> {
ServerHierarchyType ht = new ServerHierarchyTypeBuilder().get(relationship, false);
if (!ServiceFactory.getMetadataCache().getHierachyType(ht.getCode()).isPresent()) {
ServiceFactory.getMetadataCache().addHierarchyType(ht);
}
});
try {
// This is, unfortunately, a big hack. Some patch items need to occur
// before the organizaiton class is defined
MdClassDAO.getMdClassDAO(Organization.CLASS);
OrganizationQuery oQ = new OrganizationQuery(qf);
OIterator<? extends Organization> it3 = oQ.getIterator();
try {
while (it3.hasNext()) {
Organization organization = it3.next();
ServiceFactory.getMetadataCache().addOrganization(organization);
}
} finally {
it3.close();
}
} catch (com.runwaysdk.dataaccess.cache.DataNotFoundException e) {
// skip for now
}
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class TestGeoObjectTypeInfo method getServerObject.
public ServerGeoObjectType getServerObject(boolean forceFetch) {
if (this.serverObject != null && !forceFetch) {
return this.serverObject;
} else {
Optional<ServerGeoObjectType> got = ServiceFactory.getMetadataCache().getGeoObjectType(code);
if (got.isPresent()) {
this.serverObject = got.get();
return this.serverObject;
} else {
Universal uni = TestDataSet.getUniversalIfExist(getCode());
if (uni == null) {
return null;
}
this.serverObject = new ServerGeoObjectTypeConverter().build(uni);
return this.serverObject;
}
}
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class MasterList method create.
@Transaction
public static MasterList create(JsonObject object) {
MasterList list = MasterList.fromJSON(object);
if (Session.getCurrentSession() != null && Session.getCurrentSession().getUser() != null) {
list.enforceActorHasPermission(Operation.CREATE);
}
if (list.getIsMaster() != null && list.getIsMaster()) {
Universal universal = list.getUniversal();
MasterListQuery query = new MasterListQuery(new QueryFactory());
query.WHERE(query.getUniversal().EQ(universal));
query.AND(query.getOrganization().EQ(list.getOrganization()));
query.AND(query.getIsMaster().EQ(true));
if (!list.isNew()) {
query.AND(query.getOid().NE(list.getOid()));
}
if (query.getCount() > 0) {
DuplicateMasterListException ex = new DuplicateMasterListException();
ex.setGeoObjectType(universal.getDisplayLabel().getValue());
throw ex;
}
}
list.apply();
return list;
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class GeoObjectTypeMetadata method isReferencedInPublicListTypes.
private boolean isReferencedInPublicListTypes() {
Universal uni = this.getUniversal();
ServerGeoObjectType type = this.getServerType();
QueryFactory qf = new QueryFactory();
ListTypeVersionQuery versionQuery = new ListTypeVersionQuery(qf);
versionQuery.WHERE(versionQuery.getListVisibility().EQ(ListType.PUBLIC));
versionQuery.OR(versionQuery.getGeospatialVisibility().EQ(ListType.PUBLIC));
ListTypeQuery mlq = new ListTypeQuery(qf);
mlq.WHERE(mlq.EQ(versionQuery.getListType()));
OIterator<? extends ListType> it = mlq.getIterator();
while (it.hasNext()) {
ListType list = it.next();
if (list.getUniversal().getOid().equals(uni.getOid())) {
PrivateTypeIsReferencedInPublicMasterLists ex = new PrivateTypeIsReferencedInPublicMasterLists();
ex.setTypeLabel(this.getServerType().getLabel().getValue());
throw ex;
} else {
JsonArray hierarchies = list.getHierarchiesAsJson();
for (int i = 0; i < hierarchies.size(); i++) {
JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
JsonArray parents = hierarchy.get("parents").getAsJsonArray();
for (int j = 0; j < parents.size(); ++j) {
JsonObject parent = parents.get(j).getAsJsonObject();
if (parent.has("selected") && parent.get("selected").getAsBoolean()) {
if (parent.has("code") && parent.get("code").getAsString().equals(type.getCode())) {
return true;
}
}
}
}
}
}
return false;
}
use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.
the class CRAttributePatch method getUniversals.
public static List<Universal> getUniversals() {
QueryFactory qf = new QueryFactory();
UniversalQuery uq = new UniversalQuery(qf);
@SuppressWarnings("unchecked") List<Universal> unis = (List<Universal>) uq.getIterator().getAll();
Iterator<Universal> it = unis.iterator();
while (it.hasNext()) {
Universal uni = it.next();
if (uni.getKey().equals(Universal.ROOT_KEY)) {
it.remove();
continue;
}
// MdGeoVertexDAOIF superType = GeoVertexType.getMdGeoVertex(uni.getUniversalId()).getSuperClass();
//
// if (superType != null && !superType.definesType().equals(GeoVertex.CLASS))
// {
// it.remove();
// continue;
// }
}
return unis;
}
Aggregations