use of com.runwaysdk.system.gis.geo.UniversalQuery in project geoprism-registry by terraframe.
the class PatchExistsAndInvalid method getUniversals.
// private void patchMasterlistVersions()
// {
// final Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
//
// MasterListVersionQuery query = new MasterListVersionQuery(new QueryFactory());
//
// try (OIterator<? extends MasterListVersion> it = query.getIterator())
// {
// for (MasterListVersion version : it)
// {
// ServerGeoObjectType type = version.getMasterlist().getGeoObjectType();
//
// // Patch metadata
// AttributeType existsAttr = type.getAttribute(DefaultAttribute.EXISTS.getName()).get();
// MdAttribute existsMdAttr = MasterListVersion.createMdAttributeFromAttributeType(version, type, existsAttr, locales).getPairs().keySet().iterator().next();
//
// AttributeType invalidAttr = type.getAttribute(DefaultAttribute.INVALID.getName()).get();
// MdAttribute invalidMdAttr = MasterListVersion.createMdAttributeFromAttributeType(version, type, invalidAttr, locales).getPairs().keySet().iterator().next();
//
//
//
// // Patch instance data
// MdBusiness table = version.getMdBusiness();
//
// String statement = "UPDATE " + table.getTableName() + " SET " + existsMdAttr.getColumnName() + " = " +
//
// Database.executeStatement(statement);
// }
// }
// }
// private void patchMasterlistVersions(ServerGeoObjectType type)
// {
// AttributeType existsAttr = type.getAttribute(DefaultAttribute.EXISTS.getName()).get();
// MasterList.createMdAttribute(type, existsAttr);
//
// AttributeType invalidAttr = type.getAttribute(DefaultAttribute.INVALID.getName()).get();
// MasterList.createMdAttribute(type, invalidAttr);
// }
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;
}
use of com.runwaysdk.system.gis.geo.UniversalQuery in project geoprism-registry by terraframe.
the class HierarchyExporter method exportHierarchyInstances.
/**
* Exports all instances of Universals, including Leaf Types. If a
* file of the specified filename already exists then the file is overwritten.
*
* @param fileName
* The name of the xml file to create.
* @param schemaLocation
* The location of the schema
* @param _exportOnlyModifiedAttributes
* True if only modified attributes should be exported, false otherwise.
*/
@Request
public static void exportHierarchyInstances(String fileName, String schemaLocation, boolean _exportOnlyModifiedAttributes) {
ExportMetadata exportMetadata = new ExportMetadata();
QueryFactory qf = new QueryFactory();
List<Universal> universalList = new LinkedList<Universal>();
UniversalQuery uQ = new UniversalQuery(qf);
// All of the leaf node types will be last in the query
uQ.ORDER_BY(uQ.getIsLeafType(), OrderBy.SortOrder.ASC);
OIterator<? extends Universal> i = uQ.getIterator();
try {
while (i.hasNext()) {
universalList.add(i.next());
}
} finally {
i.close();
}
for (Universal universal : universalList) {
exportUniversalInstances(exportMetadata, universal);
}
List<MdTermRelationshipDAOIF> geoEntityRelList = getGeoEntityRelationships();
for (MdTermRelationshipDAOIF mdTermRelationshipDAOIF : geoEntityRelList) {
exportMdTermRelInstances(exportMetadata, mdTermRelationshipDAOIF);
}
VersionExporter.export(fileName, schemaLocation, exportMetadata);
}
use of com.runwaysdk.system.gis.geo.UniversalQuery 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.UniversalQuery 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;
}
use of com.runwaysdk.system.gis.geo.UniversalQuery in project geoprism-registry by terraframe.
the class PatchGeoObjectTypeMetadata method doIt.
@Transaction
private void doIt() {
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;
}
GeoObjectTypeMetadataQuery query = new GeoObjectTypeMetadataQuery(new QueryFactory());
query.WHERE(query.getKeyName().EQ(uni.getKey()));
OIterator<? extends GeoObjectTypeMetadata> it2 = query.getIterator();
try {
if (!it2.hasNext()) {
GeoObjectTypeMetadata metadata = new GeoObjectTypeMetadata();
metadata.setUniversal(uni);
metadata.setIsPrivate(false);
metadata.apply();
}
} finally {
it2.close();
}
}
} finally {
it.close();
}
}
Aggregations