Search in sources :

Example 91 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class ListTypeVersionRequiredDefaults method dotItInTrans.

@Transaction
private void dotItInTrans() {
    BusinessDAOQuery query = new QueryFactory().businessDAOQuery(ListTypeVersion.CLASS);
    query.WHERE(query.aBoolean(ListTypeVersion.WORKING).EQ(true));
    query.AND(query.aCharacter(ListTypeVersion.LISTVISIBILITY).EQ((String) null).OR(query.aCharacter(ListTypeVersion.GEOSPATIALVISIBILITY).EQ((String) null)));
    logger.info("About to patch " + query.getCount() + " ListTypeVersions with default values for visiblity.");
    OIterator<BusinessDAOIF> it = query.getIterator();
    try {
        while (it.hasNext()) {
            BusinessDAO version = (BusinessDAO) it.next();
            if (version.getValue(ListTypeVersion.LISTVISIBILITY) == null || version.getValue(ListTypeVersion.LISTVISIBILITY).length() == 0) {
                version.setValue(ListTypeVersion.LISTVISIBILITY, ListType.PRIVATE);
            }
            if (version.getValue(ListTypeVersion.GEOSPATIALVISIBILITY) == null || version.getValue(ListTypeVersion.GEOSPATIALVISIBILITY).length() == 0) {
                version.setValue(ListTypeVersion.GEOSPATIALVISIBILITY, ListType.PRIVATE);
            }
            version.apply();
        }
    } finally {
        it.close();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) BusinessDAO(com.runwaysdk.dataaccess.BusinessDAO) BusinessDAOIF(com.runwaysdk.dataaccess.BusinessDAOIF) BusinessDAOQuery(com.runwaysdk.query.BusinessDAOQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 92 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class PatchGeoObjectTypeMetadata method doIt.

@Transaction
private void doIt() {
    QueryFactory qf = new QueryFactory();
    UniversalQuery uq = new UniversalQuery(qf);
    OIterator<? extends Universal> it = uq.getIterator();
    try {
        while (it.hasNext()) {
            Universal uni = it.next();
            if (uni.getKey().equals(Universal.ROOT_KEY)) {
                continue;
            }
            GeoObjectTypeMetadataQuery query = new GeoObjectTypeMetadataQuery(new QueryFactory());
            query.WHERE(query.getKeyName().EQ(uni.getKey()));
            OIterator<? extends GeoObjectTypeMetadata> it2 = query.getIterator();
            try {
                if (!it2.hasNext()) {
                    GeoObjectTypeMetadata metadata = new GeoObjectTypeMetadata();
                    metadata.setUniversal(uni);
                    metadata.setIsPrivate(false);
                    metadata.apply();
                }
            } finally {
                it2.close();
            }
        }
    } finally {
        it.close();
    }
}
Also used : GeoObjectTypeMetadata(net.geoprism.registry.model.GeoObjectTypeMetadata) QueryFactory(com.runwaysdk.query.QueryFactory) Universal(com.runwaysdk.system.gis.geo.Universal) UniversalQuery(com.runwaysdk.system.gis.geo.UniversalQuery) GeoObjectTypeMetadataQuery(net.geoprism.registry.model.GeoObjectTypeMetadataQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 93 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class PatchGotIntoImportHistory 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;
                    ServerGeoObjectType type = goConfig.getType();
                    hist.appLock();
                    hist.setOrganization(type.getOrganization());
                    hist.setGeoObjectTypeCode(type.getCode());
                    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) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) 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 94 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class PatchTerms method doIt.

@Transaction
private void doIt() {
    ClassifierQuery gQuery = new ClassifierQuery(new QueryFactory());
    Classifier clazz = this.getByClassifierId("CLASS");
    BusinessDAO clazzDAO = BusinessDAO.get(clazz.getOid()).getBusinessDAO();
    clazzDAO.setValue(Classifier.CLASSIFIERPACKAGE, RegistryConstants.REGISTRY_PACKAGE);
    clazzDAO.setValue(Classifier.KEYNAME, "CLASS");
    clazzDAO.apply();
    Classifier root = this.getByClassifierId("ROOT");
    BusinessDAO rootDAO = BusinessDAO.get(root.getOid()).getBusinessDAO();
    rootDAO.setValue(Classifier.CLASSIFIERPACKAGE, "ROOT");
    rootDAO.setValue(Classifier.KEYNAME, "ROOT");
    rootDAO.apply();
    try (OIterator<? extends Classifier> it = gQuery.getIterator()) {
        while (it.hasNext()) {
            Classifier classifier = it.next();
            LinkedList<Term> parents = new LinkedList<>(GeoEntityUtil.getOrderedAncestors(root, classifier, ClassifierIsARelationship.CLASS));
            Collections.reverse(parents);
            // Root -> Class Root -> Class -> Attribute -> Option
            if (parents.size() == 4) {
                Iterator<Term> pit = parents.iterator();
                // while (pit.hasNext())
                // {
                // Classifier p = (Classifier) pit.next();
                // 
                // // logger.error("[" + p.getClassifierId() + "]: ");
                // System.out.println(" Parent [" + p.getClassifierId() + "]: ");
                // }
                pit = parents.iterator();
                pit.next();
                Classifier parent = (Classifier) pit.next();
                classifier.appLock();
                classifier.setClassifierPackage(parent.getKey());
                classifier.setKeyName(Classifier.buildKey(parent.getKey(), classifier.getClassifierId()));
                classifier.apply();
            } else if (!(classifier.getOid().equals(clazz.getOid()) || classifier.getOid().equals(root.getOid()))) {
                classifier.appLock();
                classifier.setClassifierPackage(RegistryConstants.REGISTRY_PACKAGE);
                classifier.setKeyName(Classifier.buildKey(RegistryConstants.REGISTRY_PACKAGE, classifier.getClassifierId()));
                classifier.apply();
            }
        }
    }
}
Also used : ClassifierQuery(net.geoprism.ontology.ClassifierQuery) QueryFactory(com.runwaysdk.query.QueryFactory) BusinessDAO(com.runwaysdk.dataaccess.BusinessDAO) Classifier(net.geoprism.ontology.Classifier) Term(com.runwaysdk.business.ontology.Term) LinkedList(java.util.LinkedList) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 95 with Transaction

use of com.runwaysdk.dataaccess.transaction.Transaction in project geoprism-registry by terraframe.

the class SearchTablePatch method createRecords.

@Transaction
public void createRecords(SearchService service) {
    MdVertexDAOIF mdVertex = MdVertexDAO.getMdVertexDAO(GeoVertex.CLASS);
    long pageSize = 1000;
    long skip = 0;
    int count = 0;
    do {
        StringBuilder builder = new StringBuilder();
        builder.append("SELECT FROM " + mdVertex.getDBClassName());
        builder.append(" ORDER BY oid");
        builder.append(" SKIP " + skip + " LIMIT " + pageSize);
        GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(builder.toString());
        List<VertexObject> results = query.getResults();
        for (VertexObject result : results) {
            ServerGeoObjectType type = ServerGeoObjectType.get((MdVertexDAOIF) result.getMdClass());
            service.insert(new VertexServerGeoObject(type, result));
        }
        skip += pageSize;
        count = results.size();
    } while (count > 0);
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery) 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