Search in sources :

Example 1 with UniversalQuery

use of com.runwaysdk.system.gis.geo.UniversalQuery 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 2 with UniversalQuery

use of com.runwaysdk.system.gis.geo.UniversalQuery in project geoprism-registry by terraframe.

the class HierarchyExporter method exportHierarchyInstances.

/**
 * Exports all instances of Universals, including Leaf Types. If a
 * file of the specified filename already exists then the file is overwritten.
 *
 * @param fileName
 *            The name of the xml file to create.
 * @param schemaLocation
 *            The location of the schema
 * @param _exportOnlyModifiedAttributes
 *             True if only modified attributes should be exported, false otherwise.
 */
@Request
public static void exportHierarchyInstances(String fileName, String schemaLocation, boolean _exportOnlyModifiedAttributes) {
    ExportMetadata exportMetadata = new ExportMetadata();
    QueryFactory qf = new QueryFactory();
    List<Universal> universalList = new LinkedList<Universal>();
    UniversalQuery uQ = new UniversalQuery(qf);
    // All of the leaf node types will be last in the query
    uQ.ORDER_BY(uQ.getIsLeafType(), OrderBy.SortOrder.ASC);
    OIterator<? extends Universal> i = uQ.getIterator();
    try {
        while (i.hasNext()) {
            universalList.add(i.next());
        }
    } finally {
        i.close();
    }
    for (Universal universal : universalList) {
        exportUniversalInstances(exportMetadata, universal);
    }
    List<MdTermRelationshipDAOIF> geoEntityRelList = getGeoEntityRelationships();
    for (MdTermRelationshipDAOIF mdTermRelationshipDAOIF : geoEntityRelList) {
        exportMdTermRelInstances(exportMetadata, mdTermRelationshipDAOIF);
    }
    VersionExporter.export(fileName, schemaLocation, exportMetadata);
}
Also used : MdTermRelationshipDAOIF(com.runwaysdk.dataaccess.MdTermRelationshipDAOIF) ExportMetadata(com.runwaysdk.dataaccess.io.dataDefinition.ExportMetadata) QueryFactory(com.runwaysdk.query.QueryFactory) Universal(com.runwaysdk.system.gis.geo.Universal) UniversalQuery(com.runwaysdk.system.gis.geo.UniversalQuery) LinkedList(java.util.LinkedList) Request(com.runwaysdk.session.Request)

Example 3 with UniversalQuery

use of com.runwaysdk.system.gis.geo.UniversalQuery in project geoprism-registry by terraframe.

the class RegistryService method refreshMetadataCache.

public void refreshMetadataCache() {
    ServiceFactory.getMetadataCache().rebuild();
    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;
            }
            ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
            ServiceFactory.getMetadataCache().addGeoObjectType(type);
        }
    } finally {
        it.close();
    }
    // We must build the hierarchy types which are inherited first
    // Otherwise you will end up with a NPE when building the hierarchies
    // which inherit the inherited hierarchy if it hasn't been built
    HierarchicalRelationshipType.getInheritedTypes().forEach(relationship -> {
        ServerHierarchyType ht = new ServerHierarchyTypeBuilder().get(relationship, false);
        ServiceFactory.getMetadataCache().addHierarchyType(ht);
    });
    HierarchicalRelationshipType.getAll().forEach(relationship -> {
        ServerHierarchyType ht = new ServerHierarchyTypeBuilder().get(relationship, false);
        if (!ServiceFactory.getMetadataCache().getHierachyType(ht.getCode()).isPresent()) {
            ServiceFactory.getMetadataCache().addHierarchyType(ht);
        }
    });
    try {
        // This is, unfortunately, a big hack. Some patch items need to occur
        // before the organizaiton class is defined
        MdClassDAO.getMdClassDAO(Organization.CLASS);
        OrganizationQuery oQ = new OrganizationQuery(qf);
        OIterator<? extends Organization> it3 = oQ.getIterator();
        try {
            while (it3.hasNext()) {
                Organization organization = it3.next();
                ServiceFactory.getMetadataCache().addOrganization(organization);
            }
        } finally {
            it3.close();
        }
    } catch (com.runwaysdk.dataaccess.cache.DataNotFoundException e) {
    // skip for now
    }
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) QueryFactory(com.runwaysdk.query.QueryFactory) Universal(com.runwaysdk.system.gis.geo.Universal) ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) Organization(net.geoprism.registry.Organization) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) OrganizationQuery(net.geoprism.registry.OrganizationQuery) ServerHierarchyTypeBuilder(net.geoprism.registry.conversion.ServerHierarchyTypeBuilder) UniversalQuery(com.runwaysdk.system.gis.geo.UniversalQuery)

Example 4 with UniversalQuery

use of com.runwaysdk.system.gis.geo.UniversalQuery in project geoprism-registry by terraframe.

the class CRAttributePatch method getUniversals.

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) List(java.util.List) UniversalQuery(com.runwaysdk.system.gis.geo.UniversalQuery)

Example 5 with UniversalQuery

use of com.runwaysdk.system.gis.geo.UniversalQuery 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)

Aggregations

QueryFactory (com.runwaysdk.query.QueryFactory)5 Universal (com.runwaysdk.system.gis.geo.Universal)5 UniversalQuery (com.runwaysdk.system.gis.geo.UniversalQuery)5 LinkedList (java.util.LinkedList)2 List (java.util.List)2 MdTermRelationshipDAOIF (com.runwaysdk.dataaccess.MdTermRelationshipDAOIF)1 ExportMetadata (com.runwaysdk.dataaccess.io.dataDefinition.ExportMetadata)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 MdGeoVertexDAOIF (com.runwaysdk.gis.dataaccess.MdGeoVertexDAOIF)1 Request (com.runwaysdk.session.Request)1 MasterList (net.geoprism.registry.MasterList)1 Organization (net.geoprism.registry.Organization)1 OrganizationQuery (net.geoprism.registry.OrganizationQuery)1 ServerGeoObjectTypeConverter (net.geoprism.registry.conversion.ServerGeoObjectTypeConverter)1 ServerHierarchyTypeBuilder (net.geoprism.registry.conversion.ServerHierarchyTypeBuilder)1 GeoObjectTypeMetadata (net.geoprism.registry.model.GeoObjectTypeMetadata)1 GeoObjectTypeMetadataQuery (net.geoprism.registry.model.GeoObjectTypeMetadataQuery)1 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)1 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)1