use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class ListTypeVersionRequiredDefaults method dotItInTrans.
@Transaction
private void dotItInTrans() {
BusinessDAOQuery query = new QueryFactory().businessDAOQuery(ListTypeVersion.CLASS);
query.WHERE(query.aBoolean(ListTypeVersion.WORKING).EQ(true));
query.AND(query.aCharacter(ListTypeVersion.LISTVISIBILITY).EQ((String) null).OR(query.aCharacter(ListTypeVersion.GEOSPATIALVISIBILITY).EQ((String) null)));
logger.info("About to patch " + query.getCount() + " ListTypeVersions with default values for visiblity.");
OIterator<BusinessDAOIF> it = query.getIterator();
try {
while (it.hasNext()) {
BusinessDAO version = (BusinessDAO) it.next();
if (version.getValue(ListTypeVersion.LISTVISIBILITY) == null || version.getValue(ListTypeVersion.LISTVISIBILITY).length() == 0) {
version.setValue(ListTypeVersion.LISTVISIBILITY, ListType.PRIVATE);
}
if (version.getValue(ListTypeVersion.GEOSPATIALVISIBILITY) == null || version.getValue(ListTypeVersion.GEOSPATIALVISIBILITY).length() == 0) {
version.setValue(ListTypeVersion.GEOSPATIALVISIBILITY, ListType.PRIVATE);
}
version.apply();
}
} finally {
it.close();
}
}
use of com.runwaysdk.dataaccess.transaction.Transaction 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();
}
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class PatchGotIntoImportHistory 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;
ServerGeoObjectType type = goConfig.getType();
hist.appLock();
hist.setOrganization(type.getOrganization());
hist.setGeoObjectTypeCode(type.getCode());
hist.apply();
}
} catch (net.geoprism.registry.DataNotFoundException e) {
logger.error("ImportHistory references object which does not exist", e);
}
}
} finally {
it.close();
}
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class PatchTerms method doIt.
@Transaction
private void doIt() {
ClassifierQuery gQuery = new ClassifierQuery(new QueryFactory());
Classifier clazz = this.getByClassifierId("CLASS");
BusinessDAO clazzDAO = BusinessDAO.get(clazz.getOid()).getBusinessDAO();
clazzDAO.setValue(Classifier.CLASSIFIERPACKAGE, RegistryConstants.REGISTRY_PACKAGE);
clazzDAO.setValue(Classifier.KEYNAME, "CLASS");
clazzDAO.apply();
Classifier root = this.getByClassifierId("ROOT");
BusinessDAO rootDAO = BusinessDAO.get(root.getOid()).getBusinessDAO();
rootDAO.setValue(Classifier.CLASSIFIERPACKAGE, "ROOT");
rootDAO.setValue(Classifier.KEYNAME, "ROOT");
rootDAO.apply();
try (OIterator<? extends Classifier> it = gQuery.getIterator()) {
while (it.hasNext()) {
Classifier classifier = it.next();
LinkedList<Term> parents = new LinkedList<>(GeoEntityUtil.getOrderedAncestors(root, classifier, ClassifierIsARelationship.CLASS));
Collections.reverse(parents);
// Root -> Class Root -> Class -> Attribute -> Option
if (parents.size() == 4) {
Iterator<Term> pit = parents.iterator();
// while (pit.hasNext())
// {
// Classifier p = (Classifier) pit.next();
//
// // logger.error("[" + p.getClassifierId() + "]: ");
// System.out.println(" Parent [" + p.getClassifierId() + "]: ");
// }
pit = parents.iterator();
pit.next();
Classifier parent = (Classifier) pit.next();
classifier.appLock();
classifier.setClassifierPackage(parent.getKey());
classifier.setKeyName(Classifier.buildKey(parent.getKey(), classifier.getClassifierId()));
classifier.apply();
} else if (!(classifier.getOid().equals(clazz.getOid()) || classifier.getOid().equals(root.getOid()))) {
classifier.appLock();
classifier.setClassifierPackage(RegistryConstants.REGISTRY_PACKAGE);
classifier.setKeyName(Classifier.buildKey(RegistryConstants.REGISTRY_PACKAGE, classifier.getClassifierId()));
classifier.apply();
}
}
}
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class SearchTablePatch method createRecords.
@Transaction
public void createRecords(SearchService service) {
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
long pageSize = 1000;
long skip = 0;
int count = 0;
do {
StringBuilder builder = new StringBuilder();
builder.append("SELECT FROM " + mdVertex.getDBClassName());
builder.append(" ORDER BY oid");
builder.append(" SKIP " + skip + " LIMIT " + pageSize);
GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(builder.toString());
List<VertexObject> results = query.getResults();
for (VertexObject result : results) {
ServerGeoObjectType type = ServerGeoObjectType.get((MdVertexDAOIF) result.getMdClass());
service.insert(new VertexServerGeoObject(type, result));
}
skip += pageSize;
count = results.size();
} while (count > 0);
}
Aggregations