Search in sources :

Example 6 with Universal

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

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

the class PatchExistsAndInvalid method enforceInvalidRequired.

private void enforceInvalidRequired() {
    List<Universal> unis = PatchExistsAndInvalid.getUniversals();
    for (Universal uni : unis) {
        ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
        MdGraphClassDAOIF mdClass = type.getMdVertex();
        logger.info("Setting invalid mdAttr to required for class [" + mdClass.getKey() + "].");
        MdAttributeDAO invalidMdAttr = (MdAttributeDAO) mdClass.definesAttribute(DefaultAttribute.INVALID.getName());
        invalidMdAttr.setValue(MdAttributeConcreteInfo.REQUIRED, MdAttributeBooleanInfo.TRUE);
        invalidMdAttr.apply();
    }
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdGraphClassDAOIF(com.runwaysdk.dataaccess.MdGraphClassDAOIF) MdAttributeDAO(com.runwaysdk.dataaccess.metadata.MdAttributeDAO)

Example 8 with Universal

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

the class PatchExistsAndInvalidInstanceData method patchInstanceData.

private void patchInstanceData() {
    List<Universal> unis = PatchExistsAndInvalid.getUniversals();
    int applied = 0;
    for (Universal uni : unis) {
        ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
        MdGraphClassDAOIF mdClass = type.getMdVertex();
        List<VertexServerGeoObject> data = getInstanceData(type, mdClass);
        int current = 0;
        final int size = data.size();
        logger.info("Starting to patch instance data for type [" + mdClass.getDBClassName() + "] with count [" + size + "] ");
        for (VertexServerGeoObject go : data) {
            ValueOverTime defaultExists = go.buildDefaultExists();
            if (defaultExists != null) {
                go.setValue(DefaultAttribute.EXISTS.getName(), Boolean.TRUE, defaultExists.getStartDate(), defaultExists.getEndDate());
                go.setValue(DefaultAttribute.INVALID.getName(), false);
                // This apply method is mega slow due to the SearchService so we're going to just bypass it
                // go.apply(false);
                go.getVertex().setValue(GeoVertex.LASTUPDATEDATE, new Date());
                go.getVertex().apply();
                applied++;
            }
            if (current % 100 == 0) {
                logger.info("Finished record " + current + " of " + size);
            }
            current++;
        }
    }
    logger.info("Applied " + applied + " records across " + unis.size() + " types.");
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) Universal(com.runwaysdk.system.gis.geo.Universal) ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdGraphClassDAOIF(com.runwaysdk.dataaccess.MdGraphClassDAOIF) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Date(java.util.Date)

Example 9 with Universal

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

the class LocalizedValueConverter method populateGeoObjectTypeLabel.

/**
 * Populates the {@link GeoObjectType} display label on the given
 * {@link RegistryRole} object.
 *
 * @param registryRole
 */
public static void populateGeoObjectTypeLabel(RegistryRole registryRole) {
    String geoObjectTypeCode = registryRole.getGeoObjectTypeCode();
    if (geoObjectTypeCode != null && !geoObjectTypeCode.trim().equals("")) {
        Universal universal = Universal.getByKey(geoObjectTypeCode);
        registryRole.setGeoObjectTypeLabel(LocalizedValueConverter.convert(universal.getDisplayLabel()));
    }
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal)

Example 10 with Universal

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

Aggregations

Universal (com.runwaysdk.system.gis.geo.Universal)26 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)8 QueryFactory (com.runwaysdk.query.QueryFactory)7 LinkedList (java.util.LinkedList)7 ServerGeoObjectTypeConverter (net.geoprism.registry.conversion.ServerGeoObjectTypeConverter)6 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)5 UniversalQuery (com.runwaysdk.system.gis.geo.UniversalQuery)5 JsonObject (com.google.gson.JsonObject)3 MdGraphClassDAOIF (com.runwaysdk.dataaccess.MdGraphClassDAOIF)3 MdGeoVertexDAO (com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO)3 JsonArray (com.google.gson.JsonArray)2 Term (com.runwaysdk.business.ontology.Term)2 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)2 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)2 MdAttributeTerm (com.runwaysdk.system.metadata.MdAttributeTerm)2 List (java.util.List)2 Organization (net.geoprism.registry.Organization)2 GeoObjectTypeMetadata (net.geoprism.registry.model.GeoObjectTypeMetadata)2 Term (org.commongeoregistry.adapter.Term)2 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)2