Search in sources :

Example 36 with Transaction

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;
                }
            }
        }
    }
}
Also used : InheritedHierarchyAnnotationQuery(net.geoprism.registry.InheritedHierarchyAnnotationQuery) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) QueryFactory(com.runwaysdk.query.QueryFactory) Set(java.util.Set) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) InheritedHierarchyAnnotation(net.geoprism.registry.InheritedHierarchyAnnotation) HierarchicalRelationshipType(net.geoprism.registry.HierarchicalRelationshipType) ServerHierarchyTypeBuilder(net.geoprism.registry.conversion.ServerHierarchyTypeBuilder) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 37 with Transaction

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);
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery) Date(java.util.Date) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 38 with Transaction

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();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) Organization(net.geoprism.registry.Organization) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) ImportConfiguration(net.geoprism.registry.etl.upload.ImportConfiguration) ImportHistoryQuery(net.geoprism.registry.etl.ImportHistoryQuery) ImportHistory(net.geoprism.registry.etl.ImportHistory) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 39 with Transaction

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);
}
Also used : SearchService(net.geoprism.registry.service.SearchService) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 40 with Transaction

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();
            }
        }
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) GeoprismUserQuery(net.geoprism.GeoprismUserQuery) UserInfo(net.geoprism.registry.UserInfo) GeoprismUser(net.geoprism.GeoprismUser) UserInfoQuery(net.geoprism.registry.UserInfoQuery) 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