use of com.runwaysdk.dataaccess.transaction.Transaction 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.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class PatchLastUpdateDate method doIt.
@Transaction
private void doIt() {
Date date = new Date();
MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
MdAttributeDAOIF mdAttribute = mdVertex.definesAttribute(GeoVertex.LASTUPDATEDATE);
MdAttributeDAOIF createDate = mdVertex.definesAttribute(GeoVertex.CREATEDATE);
long pageSize = 1000;
long count = 0;
do {
StringBuilder builder = new StringBuilder();
builder.append("SELECT FROM " + mdVertex.getDBClassName());
builder.append(" WHERE " + mdAttribute.getColumnName() + " IS NULL");
builder.append(" OR " + createDate.getColumnName() + " IS NULL");
builder.append(" ORDER BY oid");
builder.append(" SKIP " + 0 + " LIMIT " + pageSize);
GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(builder.toString());
List<VertexObject> results = query.getResults();
for (VertexObject result : results) {
result.setValue(GeoVertex.LASTUPDATEDATE, date);
result.setValue(GeoVertex.CREATEDATE, date);
result.apply();
}
count = this.getCount();
} while (count > 0);
}
use of com.runwaysdk.dataaccess.transaction.Transaction 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();
}
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class SearchTablePatch method doIt.
@Transaction
private void doIt() {
SearchService service = new SearchService();
service.createSearchTable();
createRecords(service);
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class UserInfoPatch method doIt.
@Transaction
private void doIt() {
UserInfoQuery query = new UserInfoQuery(new QueryFactory());
try (OIterator<? extends UserInfo> it = query.getIterator()) {
while (it.hasNext()) {
UserInfo info = it.next();
info.appLock();
info.apply();
}
}
// Ensure all geoprism users have a user info
GeoprismUserQuery gQuery = new GeoprismUserQuery(new QueryFactory());
try (OIterator<? extends GeoprismUser> it = gQuery.getIterator()) {
while (it.hasNext()) {
GeoprismUser user = it.next();
UserInfo info = UserInfo.getByUser(user);
if (info == null) {
info = new UserInfo();
info.setGeoprismUser(user);
info.apply();
}
}
}
}
Aggregations