use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class HierarchicalRelationshipType method removeFromHierarchy.
@Transaction
public void removeFromHierarchy(ServerGeoObjectType parentType, ServerGeoObjectType childType, boolean migrateChildren) {
Universal parent = parentType.getUniversal();
Universal cUniversal = childType.getUniversal();
removeLink(parent, cUniversal, this.getMdTermRelationship().definesType());
if (migrateChildren) {
TermAndRel[] tnrChildren = TermUtil.getDirectDescendants(cUniversal.getOid(), new String[] { this.getMdTermRelationship().definesType() });
if (parent.getKey().equals(Universal.ROOT) && tnrChildren.length > 1) {
MultipleHierarchyRootsException ex = new MultipleHierarchyRootsException();
throw ex;
}
for (TermAndRel tnrChild : tnrChildren) {
Universal child = (Universal) tnrChild.getTerm();
removeLink(cUniversal, child, this.getMdTermRelationship().definesType());
child.addLink(parent, this.getMdTermRelationship().definesType());
}
}
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class IncrementalListType method createEntries.
@Override
@Transaction
public void createEntries(JsonObject metadata) {
if (!this.isValid()) {
throw new InvalidMasterListException();
}
final ServerGeoObjectType objectType = this.getGeoObjectType();
Pair<Date, Date> range = this.getDateRange(objectType);
if (metadata == null) {
List<ListTypeEntry> entries = this.getEntries();
if (entries.size() > 0) {
ListTypeEntry entry = entries.get(0);
ListTypeVersion working = entry.getWorking();
metadata = working.toJSON(false);
}
}
if (range != null) {
Date endDate = range.getSecond();
if (endDate.after(new Date())) {
endDate = new Date();
}
List<Date> dates = this.getFrequencyDates(range.getFirst(), range.getSecond());
for (Date date : dates) {
this.getOrCreateEntry(date, metadata);
}
} else {
throw new EmptyListException();
}
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class ListType method markAllAsInvalid.
@Transaction
public static void markAllAsInvalid(ServerHierarchyType hierarchyType, ServerGeoObjectType type) {
ListTypeQuery query = new ListTypeQuery(new QueryFactory());
query.WHERE(query.getValid().EQ((Boolean) null));
query.OR(query.getValid().EQ(true));
try (OIterator<? extends ListType> iterator = query.getIterator()) {
while (iterator.hasNext()) {
ListType masterlist = iterator.next();
if (hierarchyType != null && type != null) {
masterlist.markAsInvalid(hierarchyType, type);
} else if (hierarchyType != null) {
masterlist.markAsInvalid(hierarchyType);
} else if (type != null) {
masterlist.markAsInvalid(type);
}
}
}
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class ListType method deleteAll.
@Transaction
public static void deleteAll(Universal universal) {
ListTypeQuery query = new ListTypeQuery(new QueryFactory());
query.WHERE(query.getUniversal().EQ(universal));
List<? extends ListType> lists = query.getIterator().getAll();
for (ListType list : lists) {
list.delete();
}
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class ListTypeVersion method publishRecord.
@Transaction
public void publishRecord(ServerGeoObjectIF object) {
// Only working lists can be updated from changes to the graph objects
if (this.getWorking()) {
object.setDate(this.getForDate());
// Delete tile cache
ListTileCache.deleteTiles(this);
ListType masterlist = this.getListType();
MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
// Add the type ancestor fields
ServerGeoObjectType type = ServerGeoObjectType.get(masterlist.getUniversal());
Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap = masterlist.getAncestorMap(type);
Set<ServerHierarchyType> hierarchiesOfSubTypes = type.getHierarchiesOfSubTypes();
Collection<AttributeType> attributes = type.getAttributeMap().values();
Business business = new Business(mdBusiness.definesType());
this.publish(masterlist, type, object, business, attributes, ancestorMap, hierarchiesOfSubTypes, locales);
}
}
Aggregations