use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class ListTypeVersion method updateRecord.
@Transaction
public void updateRecord(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());
Set<ServerHierarchyType> hierarchiesOfSubTypes = type.getHierarchiesOfSubTypes();
Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap = masterlist.getAncestorMap(type);
Collection<AttributeType> attributes = type.getAttributeMap().values();
BusinessQuery query = new QueryFactory().businessQuery(mdBusiness.definesType());
query.WHERE(query.aCharacter(DefaultAttribute.CODE.getName()).EQ(object.getCode()));
List<Business> records = query.getIterator().getAll();
for (Business record : records) {
try {
record.appLock();
this.publish(masterlist, type, object, record, attributes, ancestorMap, hierarchiesOfSubTypes, locales);
} finally {
record.unlock();
}
}
}
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class ListTypeVersion method create.
@Transaction
public static ListTypeVersion create(ListTypeEntry listEntry, boolean working, int versionNumber, JsonObject metadata) {
ListType listType = listEntry.getListType();
ListTypeVersion version = new ListTypeVersion();
version.setEntry(listEntry);
version.setListType(listType);
version.setForDate(listEntry.getForDate());
version.setVersionNumber(versionNumber);
version.setWorking(working);
if (metadata != null) {
version.parse(metadata);
}
ServerGeoObjectType type = listType.getGeoObjectType();
if (type.getIsPrivate() && (version.getListVisibility().equals(ListType.PUBLIC) || version.getGeospatialVisibility().equals(ListType.PUBLIC))) {
throw new UnsupportedOperationException("A list version cannot be public if the Geo-Object Type is private");
}
TableMetadata tableMetadata = null;
tableMetadata = version.createTable();
version.setMdBusiness(tableMetadata.getMdBusiness());
version.apply();
if (tableMetadata != null) {
Map<MdAttribute, MdAttribute> pairs = tableMetadata.getPairs();
Set<Entry<MdAttribute, MdAttribute>> entries = pairs.entrySet();
for (Entry<MdAttribute, MdAttribute> entry : entries) {
ListTypeAttributeGroup.create(version, entry.getValue(), entry.getKey());
}
}
ListTypeVersion.assignDefaultRolePermissions(version.getMdBusiness());
return version;
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class ListTypeVersion method delete.
@Override
@Transaction
public void delete() {
// Delete all jobs
// List<ExecutableJob> jobs = this.getJobs();
//
// for (ExecutableJob job : jobs)
// {
// job.delete();
// }
// Delete tile cache
ListTileCache.deleteTiles(this);
ListTypeAttributeGroup.deleteAll(this);
MdBusiness mdTable = this.getMdBusiness();
super.delete();
if (mdTable != null) {
MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
mdBusiness.deleteAllRecords();
mdTable.delete();
}
if (this.getGeospatialVisibility().equals(ListType.PUBLIC)) {
new GeoserverRemoveWMSCommand(this).doIt();
}
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class MasterList method getOrCreateVersion.
@Transaction
public MasterListVersion getOrCreateVersion(Date forDate, String versionType) {
if (!this.isValid()) {
throw new InvalidMasterListException();
}
MasterListVersionQuery query = new MasterListVersionQuery(new QueryFactory());
query.WHERE(query.getMasterlist().EQ(this));
query.AND(query.getForDate().EQ(forDate));
query.AND(query.getVersionType().EQ(versionType));
try (OIterator<? extends MasterListVersion> it = query.getIterator()) {
if (it.hasNext()) {
return it.next();
}
}
return MasterListVersion.create(this, forDate, versionType);
}
use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.
the class MasterList method deleteAll.
@Transaction
public static void deleteAll(Universal universal) {
MasterListQuery query = new MasterListQuery(new QueryFactory());
query.WHERE(query.getUniversal().EQ(universal));
List<? extends MasterList> lists = query.getIterator().getAll();
for (MasterList list : lists) {
list.delete();
}
}
Aggregations