Search in sources :

Example 6 with Transaction

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());
        }
    }
}
Also used : MultipleHierarchyRootsException(net.geoprism.registry.graph.MultipleHierarchyRootsException) Universal(com.runwaysdk.system.gis.geo.Universal) TermAndRel(com.runwaysdk.business.ontology.TermAndRel) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 7 with Transaction

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();
    }
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Date(java.util.Date) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 8 with Transaction

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

Example 9 with Transaction

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

Example 10 with Transaction

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);
    }
}
Also used : Locale(java.util.Locale) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) 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)

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