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;
}
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);
}
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);
}
}
}
}
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();
}
}
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
}
}
Aggregations