Search in sources :

Example 1 with MdTermRelationshipDAOIF

use of com.runwaysdk.dataaccess.MdTermRelationshipDAOIF 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 2 with MdTermRelationshipDAOIF

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

the class HierarchyExporter method getGeoEntityRelationships.

/**
 * Returns a list of {@link MdTermRelationshipDAOIF} that defines relationships between geoentities.
 *
 * @return list of {@link MdTermRelationshipDAOIF} that defines relationships between geoentities.
 */
private static List<MdTermRelationshipDAOIF> getGeoEntityRelationships() {
    List<MdTermRelationshipDAOIF> list = new LinkedList<MdTermRelationshipDAOIF>();
    QueryFactory qf = new QueryFactory();
    // Export the MdTermRelationships that involve universals
    MdBusiness geoEntityMdBusiness = MdBusiness.getMdBusiness(GeoEntity.CLASS);
    BusinessDAOQuery trQ = qf.businessDAOQuery(MdTermRelationship.CLASS);
    trQ.WHERE(trQ.get(MdTermRelationship.PARENTMDBUSINESS).EQ(geoEntityMdBusiness.getOid()).AND(trQ.get(MdTermRelationship.CHILDMDBUSINESS).EQ(geoEntityMdBusiness.getOid())));
    OIterator<? extends BusinessDAOIF> mdtrI = trQ.getIterator();
    try {
        while (mdtrI.hasNext()) {
            MdTermRelationshipDAOIF businessDAOIF = (MdTermRelationshipDAOIF) mdtrI.next();
            list.add(businessDAOIF);
        }
    } finally {
        mdtrI.close();
    }
    return list;
}
Also used : MdTermRelationshipDAOIF(com.runwaysdk.dataaccess.MdTermRelationshipDAOIF) QueryFactory(com.runwaysdk.query.QueryFactory) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) BusinessDAOQuery(com.runwaysdk.query.BusinessDAOQuery) LinkedList(java.util.LinkedList)

Example 3 with MdTermRelationshipDAOIF

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

the class HierarchyExporter method exportHierarchyDefinition.

/**
 * Exports the metadata for the hierarchies. 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 exportHierarchyDefinition(String fileName, String schemaLocation, boolean _exportOnlyModifiedAttributes) {
    ExportMetadata exportMetadata = new ExportMetadata();
    QueryFactory qf = new QueryFactory();
    // Export the MdBusinesses that define the hierarchy attributes
    BusinessDAOQuery uQ = qf.businessDAOQuery(Universal.CLASS);
    BusinessDAOQuery mdbQ = qf.businessDAOQuery(MdBusiness.CLASS);
    mdbQ.WHERE(mdbQ.aUUID(MdBusiness.OID).EQ(uQ.aReference(Universal.MDBUSINESS).aUUID(Universal.OID)));
    OIterator<? extends BusinessDAOIF> mdbI = mdbQ.getIterator();
    try {
        while (mdbI.hasNext()) {
            MdBusinessDAOIF mdBusiness = (MdBusinessDAOIF) mdbI.next();
            System.out.println(mdBusiness.getType() + "  " + mdBusiness.getTypeName());
            exportMetadata.addCreateOrUpdate(mdBusiness);
        }
    } finally {
        mdbI.close();
    }
    // Export the Universals
    uQ = qf.businessDAOQuery(Universal.CLASS);
    OIterator<? extends BusinessDAOIF> uQI = uQ.getIterator();
    try {
        while (uQI.hasNext()) {
            BusinessDAOIF businessDAOIF = (BusinessDAOIF) uQI.next();
            System.out.println(businessDAOIF.getType() + "  " + businessDAOIF.getKey());
            exportMetadata.addCreateOrUpdate(businessDAOIF);
        }
    } finally {
        mdbI.close();
    }
    // Export the MdTermRelationships that involve universals
    List<MdTermRelationshipDAOIF> universalRelList = getUniversalRelationships();
    for (MdTermRelationshipDAOIF mdTermRelationshipDAOIF : universalRelList) {
        System.out.println(mdTermRelationshipDAOIF.getType() + "  " + mdTermRelationshipDAOIF.getKey());
        exportMetadata.addCreateOrUpdate(mdTermRelationshipDAOIF);
    }
    // Export the instances of the relationships between the universals.
    for (MdTermRelationshipDAOIF mdTermRelationshipDAOIF : universalRelList) {
        RelationshipDAOQuery relQ = qf.relationshipDAOQuery(mdTermRelationshipDAOIF.definesType());
        OIterator<RelationshipDAOIF> relI = relQ.getIterator();
        try {
            while (relI.hasNext()) {
                RelationshipDAOIF relationshipDAOIF = relI.next();
                exportMetadata.addCreateOrUpdate(relationshipDAOIF);
            }
        } finally {
            relI.close();
        }
    }
    List<MdTermRelationshipDAOIF> geoEntityRelList = getGeoEntityRelationships();
    for (MdTermRelationshipDAOIF mdTermRelationshipDAOIF : geoEntityRelList) {
        System.out.println(mdTermRelationshipDAOIF.getType() + "  " + mdTermRelationshipDAOIF.getKey());
        exportMetadata.addCreateOrUpdate(mdTermRelationshipDAOIF);
    }
    VersionExporter.export(fileName, schemaLocation, exportMetadata);
// FileInstanceExporter.export(fileName, schemaLocation, queries, _exportOnlyModifiedAttributes);
}
Also used : MdTermRelationshipDAOIF(com.runwaysdk.dataaccess.MdTermRelationshipDAOIF) ExportMetadata(com.runwaysdk.dataaccess.io.dataDefinition.ExportMetadata) QueryFactory(com.runwaysdk.query.QueryFactory) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) MdTermRelationshipDAOIF(com.runwaysdk.dataaccess.MdTermRelationshipDAOIF) RelationshipDAOIF(com.runwaysdk.dataaccess.RelationshipDAOIF) RelationshipDAOQuery(com.runwaysdk.query.RelationshipDAOQuery) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) BusinessDAOIF(com.runwaysdk.dataaccess.BusinessDAOIF) BusinessDAOQuery(com.runwaysdk.query.BusinessDAOQuery) Request(com.runwaysdk.session.Request)

Example 4 with MdTermRelationshipDAOIF

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

the class HierarchyExporter method exportMdTermRelInstances.

/**
 * @param mdTermRelationshipDAOIF
 */
private static void exportMdTermRelInstances(ExportMetadata exportMetadata, MdTermRelationshipDAOIF mdTermRelationshipDAOIF) {
    QueryFactory qf = new QueryFactory();
    RelationshipDAOQuery q = qf.relationshipDAOQuery(mdTermRelationshipDAOIF.definesType());
    System.out.println("\nExporting Relationship [" + mdTermRelationshipDAOIF.getTypeName() + "] instances:");
    System.out.println("-----------------------------------------------------------------------");
    int counter = 0;
    OIterator<RelationshipDAOIF> i = q.getIterator();
    try {
        for (RelationshipDAOIF relationshipDAOIF : i) {
            exportMetadata.addCreate(relationshipDAOIF);
            System.out.print(".");
            if (counter % 100 == 0) {
                System.out.println();
            }
            counter++;
        }
    } finally {
        i.close();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) MdTermRelationshipDAOIF(com.runwaysdk.dataaccess.MdTermRelationshipDAOIF) RelationshipDAOIF(com.runwaysdk.dataaccess.RelationshipDAOIF) RelationshipDAOQuery(com.runwaysdk.query.RelationshipDAOQuery)

Example 5 with MdTermRelationshipDAOIF

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

the class HierarchyExporter method getUniversalRelationships.

/**
 * Returns a list of {@link MdTermRelationshipDAOIF} that defines relationships between universals.
 *
 * @return list of {@link MdTermRelationshipDAOIF} that defines relationships between universals.
 */
private static List<MdTermRelationshipDAOIF> getUniversalRelationships() {
    List<MdTermRelationshipDAOIF> list = new LinkedList<MdTermRelationshipDAOIF>();
    QueryFactory qf = new QueryFactory();
    // Export the MdTermRelationships that involve universals
    MdBusiness univMdBusiness = MdBusiness.getMdBusiness(Universal.CLASS);
    BusinessDAOQuery trQ = qf.businessDAOQuery(MdTermRelationship.CLASS);
    trQ.WHERE(trQ.get(MdTermRelationship.PARENTMDBUSINESS).EQ(univMdBusiness.getOid()).AND(trQ.get(MdTermRelationship.CHILDMDBUSINESS).EQ(univMdBusiness.getOid())));
    OIterator<? extends BusinessDAOIF> mdtrI = trQ.getIterator();
    try {
        while (mdtrI.hasNext()) {
            MdTermRelationshipDAOIF businessDAOIF = (MdTermRelationshipDAOIF) mdtrI.next();
            list.add(businessDAOIF);
        }
    } finally {
        mdtrI.close();
    }
    return list;
}
Also used : MdTermRelationshipDAOIF(com.runwaysdk.dataaccess.MdTermRelationshipDAOIF) QueryFactory(com.runwaysdk.query.QueryFactory) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) BusinessDAOQuery(com.runwaysdk.query.BusinessDAOQuery) LinkedList(java.util.LinkedList)

Aggregations

MdTermRelationshipDAOIF (com.runwaysdk.dataaccess.MdTermRelationshipDAOIF)5 QueryFactory (com.runwaysdk.query.QueryFactory)5 BusinessDAOQuery (com.runwaysdk.query.BusinessDAOQuery)3 LinkedList (java.util.LinkedList)3 RelationshipDAOIF (com.runwaysdk.dataaccess.RelationshipDAOIF)2 ExportMetadata (com.runwaysdk.dataaccess.io.dataDefinition.ExportMetadata)2 RelationshipDAOQuery (com.runwaysdk.query.RelationshipDAOQuery)2 Request (com.runwaysdk.session.Request)2 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)2 BusinessDAOIF (com.runwaysdk.dataaccess.BusinessDAOIF)1 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)1 Universal (com.runwaysdk.system.gis.geo.Universal)1 UniversalQuery (com.runwaysdk.system.gis.geo.UniversalQuery)1