Search in sources :

Example 46 with QueryFactory

use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.

the class ChangeRequestSortingPatch method doIt.

@Transaction
private void doIt() {
    ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
    OIterator<? extends ChangeRequest> it = crq.getIterator();
    for (ChangeRequest cr : it) {
        LocalizedValue goLabel = cr.getGeoObjectDisplayLabel();
        ServerGeoObjectType type = cr.getGeoObjectType();
        cr.appLock();
        cr.getGeoObjectLabel().setLocaleMap(goLabel.getLocaleMap());
        cr.getGeoObjectTypeLabel().setLocaleMap(type.getLabel().getLocaleMap());
        cr.apply();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 47 with QueryFactory

use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.

the class DeleteSyncConfigs method doIt.

@Transaction
private void doIt() {
    SynchronizationConfigQuery query = new SynchronizationConfigQuery(new QueryFactory());
    OIterator<? extends SynchronizationConfig> it = query.getIterator();
    it.forEach(config -> {
        config.delete();
    });
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) SynchronizationConfigQuery(net.geoprism.registry.SynchronizationConfigQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 48 with QueryFactory

use of com.runwaysdk.query.QueryFactory in project geoprism-registry by terraframe.

the class PatchExistsAndInvalid method getUniversals.

// private void patchMasterlistVersions()
// {
// final Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
// 
// MasterListVersionQuery query = new MasterListVersionQuery(new QueryFactory());
// 
// try (OIterator<? extends MasterListVersion> it = query.getIterator())
// {
// for (MasterListVersion version : it)
// {
// ServerGeoObjectType type = version.getMasterlist().getGeoObjectType();
// 
// // Patch metadata
// AttributeType existsAttr = type.getAttribute(DefaultAttribute.EXISTS.getName()).get();
// MdAttribute existsMdAttr = MasterListVersion.createMdAttributeFromAttributeType(version, type, existsAttr, locales).getPairs().keySet().iterator().next();
// 
// AttributeType invalidAttr = type.getAttribute(DefaultAttribute.INVALID.getName()).get();
// MdAttribute invalidMdAttr = MasterListVersion.createMdAttributeFromAttributeType(version, type, invalidAttr, locales).getPairs().keySet().iterator().next();
// 
// 
// 
// // Patch instance data
// MdBusiness table = version.getMdBusiness();
// 
// String statement = "UPDATE " + table.getTableName() + " SET " + existsMdAttr.getColumnName() + " = " +
// 
// Database.executeStatement(statement);
// }
// }
// }
// private void patchMasterlistVersions(ServerGeoObjectType type)
// {
// AttributeType existsAttr = type.getAttribute(DefaultAttribute.EXISTS.getName()).get();
// MasterList.createMdAttribute(type, existsAttr);
// 
// AttributeType invalidAttr = type.getAttribute(DefaultAttribute.INVALID.getName()).get();
// MasterList.createMdAttribute(type, invalidAttr);
// }
public static List<Universal> getUniversals() {
    QueryFactory qf = new QueryFactory();
    UniversalQuery uq = new UniversalQuery(qf);
    @SuppressWarnings("unchecked") List<Universal> unis = (List<Universal>) uq.getIterator().getAll();
    Iterator<Universal> it = unis.iterator();
    while (it.hasNext()) {
        Universal uni = it.next();
        if (uni.getKey().equals(Universal.ROOT_KEY)) {
            it.remove();
            continue;
        }
        MdGeoVertexDAOIF superType = GeoVertexType.getMdGeoVertex(uni.getUniversalId()).getSuperClass();
        if (superType != null && !superType.definesType().equals(GeoVertex.CLASS)) {
            it.remove();
            continue;
        }
    }
    return unis;
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) Universal(com.runwaysdk.system.gis.geo.Universal) MdGeoVertexDAOIF(com.runwaysdk.gis.dataaccess.MdGeoVertexDAOIF) LinkedList(java.util.LinkedList) MasterList(net.geoprism.registry.MasterList) List(java.util.List) UniversalQuery(com.runwaysdk.system.gis.geo.UniversalQuery)

Example 49 with QueryFactory

use of com.runwaysdk.query.QueryFactory 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 50 with QueryFactory

use of com.runwaysdk.query.QueryFactory 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)

Aggregations

QueryFactory (com.runwaysdk.query.QueryFactory)158 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)37 LinkedList (java.util.LinkedList)35 Request (com.runwaysdk.session.Request)31 JsonArray (com.google.gson.JsonArray)19 JsonObject (com.google.gson.JsonObject)19 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)19 SimpleDateFormat (java.text.SimpleDateFormat)15 List (java.util.List)14 Date (java.util.Date)13 ChangeRequest (net.geoprism.registry.action.ChangeRequest)13 OIterator (com.runwaysdk.query.OIterator)12 Universal (com.runwaysdk.system.gis.geo.Universal)12 ChangeRequestQuery (net.geoprism.registry.action.ChangeRequestQuery)12 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)11 BusinessQuery (com.runwaysdk.business.BusinessQuery)10 Session (com.runwaysdk.session.Session)10 GeoprismUser (net.geoprism.GeoprismUser)10 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)9 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)8