Search in sources :

Example 56 with QueryFactory

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

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

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

the class ChangeRequestService method markAllAsInvalid.

@Transaction
public void markAllAsInvalid(ServerGeoObjectType type) {
    String reason = LocalizationFacade.localize("changeRequest.invalidate.deleteReferencedGeoObjectType");
    ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
    crq.WHERE(crq.getApprovalStatus().containsExactly(AllGovernanceStatus.PENDING));
    try (OIterator<? extends ChangeRequest> it = crq.getIterator()) {
        for (ChangeRequest cr : it) {
            if (cr.getGeoObjectTypeCode().equals(type.getCode())) {
                cr.invalidate(reason);
            }
        }
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) ChangeRequestQuery(net.geoprism.registry.action.ChangeRequestQuery) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 59 with QueryFactory

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

the class ListTypeService method getPublishJobs.

@Request(RequestType.SESSION)
public JsonObject getPublishJobs(String sessionId, String oid, int pageSize, int pageNumber, String sortAttr, boolean isAscending) {
    QueryFactory qf = new QueryFactory();
    final ListTypeJobQuery query = new ListTypeJobQuery(qf);
    query.WHERE(query.getListType().EQ(oid));
    query.ORDER_BY_DESC(query.getCreateDate());
    // query.ORDER_BY(ihq.get(sortAttr), order);
    query.restrictRows(pageSize, pageNumber);
    try (OIterator<? extends ListTypeJob> it = query.getIterator()) {
        List<JsonSerializable> results = new LinkedList<>(it.getAll());
        return new Page<JsonSerializable>(query.getCount(), query.getPageNumber(), query.getPageSize(), results).toJSON();
    }
}
Also used : ListTypeJobQuery(net.geoprism.registry.etl.ListTypeJobQuery) QueryFactory(com.runwaysdk.query.QueryFactory) JsonSerializable(net.geoprism.registry.view.JsonSerializable) LinkedList(java.util.LinkedList) Request(com.runwaysdk.session.Request)

Example 60 with QueryFactory

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

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