Search in sources :

Example 11 with Transaction

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();
            }
        }
    }
}
Also used : Locale(java.util.Locale) BusinessQuery(com.runwaysdk.business.BusinessQuery) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) QueryFactory(com.runwaysdk.query.QueryFactory) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) List(java.util.List) LinkedList(java.util.LinkedList) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) Business(com.runwaysdk.business.Business) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 12 with Transaction

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;
}
Also used : TableMetadata(net.geoprism.registry.masterlist.TableMetadata) Entry(java.util.Map.Entry) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdAttribute(com.runwaysdk.system.metadata.MdAttribute) UnsupportedOperationException(com.amazonaws.services.kms.model.UnsupportedOperationException) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 13 with Transaction

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();
    }
}
Also used : MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) GeoserverRemoveWMSCommand(net.geoprism.registry.command.GeoserverRemoveWMSCommand) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 14 with Transaction

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);
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 15 with Transaction

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();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

Transaction (com.runwaysdk.dataaccess.transaction.Transaction)131 QueryFactory (com.runwaysdk.query.QueryFactory)29 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)27 JsonObject (com.google.gson.JsonObject)17 Date (java.util.Date)15 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)15 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)14 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)13 LinkedList (java.util.LinkedList)11 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)11 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)10 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)10 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)10 List (java.util.List)10 ChangeRequest (net.geoprism.registry.action.ChangeRequest)10 VertexObject (com.runwaysdk.business.graph.VertexObject)8 IOException (java.io.IOException)8 GeoObjectImportConfiguration (net.geoprism.registry.io.GeoObjectImportConfiguration)8 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)8 JSONObject (org.json.JSONObject)8