Search in sources :

Example 1 with RelationshipDAOQuery

use of com.runwaysdk.query.RelationshipDAOQuery 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 2 with RelationshipDAOQuery

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

Aggregations

MdTermRelationshipDAOIF (com.runwaysdk.dataaccess.MdTermRelationshipDAOIF)2 RelationshipDAOIF (com.runwaysdk.dataaccess.RelationshipDAOIF)2 QueryFactory (com.runwaysdk.query.QueryFactory)2 RelationshipDAOQuery (com.runwaysdk.query.RelationshipDAOQuery)2 BusinessDAOIF (com.runwaysdk.dataaccess.BusinessDAOIF)1 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)1 ExportMetadata (com.runwaysdk.dataaccess.io.dataDefinition.ExportMetadata)1 BusinessDAOQuery (com.runwaysdk.query.BusinessDAOQuery)1 Request (com.runwaysdk.session.Request)1