use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class ChangeRequestSortingPatch method doIt.
@Transaction
private void doIt() {
ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
OIterator<? extends ChangeRequest> it = crq.getIterator();
for (ChangeRequest cr : it) {
LocalizedValue goLabel = cr.getGeoObjectDisplayLabel();
ServerGeoObjectType type = cr.getGeoObjectType();
cr.appLock();
cr.getGeoObjectLabel().setLocaleMap(goLabel.getLocaleMap());
cr.getGeoObjectTypeLabel().setLocaleMap(type.getLabel().getLocaleMap());
cr.apply();
}
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class DeleteSyncConfigs method doIt.
@Transaction
private void doIt() {
SynchronizationConfigQuery query = new SynchronizationConfigQuery(new QueryFactory());
OIterator<? extends SynchronizationConfig> it = query.getIterator();
it.forEach(config -> {
config.delete();
});
}
use of com.runwaysdk.query.QueryFactory 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.query.QueryFactory in project geoprism-registry by terraframe.
the class PatchInheritedAnnotation method transaction.
@Transaction
private void transaction() {
InheritedHierarchyAnnotationQuery query = new InheritedHierarchyAnnotationQuery(new QueryFactory());
query.ORDER_BY(query.getForHierarchicalRelationshipType(), SortOrder.DESC);
query.ORDER_BY(query.getCreateDate(), SortOrder.DESC);
try (OIterator<? extends InheritedHierarchyAnnotation> iterator = query.getIterator()) {
InheritedHierarchyAnnotation prev = null;
while (iterator.hasNext()) {
InheritedHierarchyAnnotation annotation = iterator.next();
if (prev != null && prev.getForHierarchicalRelationshipTypeOid().equals(annotation.getForHierarchicalRelationshipTypeOid())) {
annotation.delete();
} else if (annotation.getForHierarchicalRelationshipTypeOid() == null || annotation.getForHierarchicalRelationshipTypeOid().length() == 0) {
annotation.delete();
} else {
// Determine if the inherited hierarchy and for hierarchy have the
// same root
ServerGeoObjectType inheritedNode = ServerGeoObjectType.get(annotation.getUniversal());
HierarchicalRelationshipType inheritedHierarchicalType = annotation.getInheritedHierarchicalRelationshipType();
ServerHierarchyType inheritedHierarchy = new ServerHierarchyTypeBuilder().get(inheritedHierarchicalType);
Set<String> rootCodes = inheritedHierarchy.getRootGeoObjectTypes().stream().map(type -> type.getGeoObjectType().getCode()).collect(Collectors.toSet());
if (rootCodes.contains(inheritedNode.getCode())) {
annotation.delete();
} else {
prev = annotation;
}
}
}
}
}
use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.
the class PatchOrgIntoImportHistory method doIt.
@Transaction
private void doIt() {
ImportHistoryQuery ihq = new ImportHistoryQuery(new QueryFactory());
OIterator<? extends ImportHistory> it = ihq.getIterator();
try {
for (ImportHistory hist : it) {
try {
ImportConfiguration config = hist.getConfig();
if (config instanceof GeoObjectImportConfiguration) {
GeoObjectImportConfiguration goConfig = (GeoObjectImportConfiguration) config;
Organization org = goConfig.getType().getOrganization();
hist.appLock();
hist.setOrganization(org);
hist.apply();
}
} catch (net.geoprism.registry.DataNotFoundException e) {
logger.error("ImportHistory references object which does not exist", e);
}
}
} finally {
it.close();
}
}
Aggregations