use of com.runwaysdk.session.Request 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);
}
use of com.runwaysdk.session.Request 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.session.Request in project geoprism-registry by terraframe.
the class LocalizationService method exportSpreadsheetInRequest.
@Request(RequestType.SESSION)
public InputStreamResponse exportSpreadsheetInRequest(String sessionId) {
ServiceFactory.getRolePermissionService().enforceSRA();
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
BufferedOutputStream buffer = new BufferedOutputStream(bytes);
LocalizationExcelExporter exporter = new LocalizationExcelExporter(buildConfig(), buffer);
exporter.export();
ByteArrayInputStream is = new ByteArrayInputStream(bytes.toByteArray());
return new InputStreamResponse(is, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "localization.xlsx");
}
use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.
the class LocalizationService method importSpreadsheetInRequest.
@Request(RequestType.SESSION)
public void importSpreadsheetInRequest(String sessionId, MultipartFileParameter file) {
ServiceFactory.getRolePermissionService().enforceSRA();
try {
LocalizationExcelImporter importer = new LocalizationExcelImporter(buildConfig(), file.getInputStream());
importer.doImport();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.
the class AccountService method getRolesForUser.
/**
* @param organizationCodes
* comma delimited list of registry codes. Returns all registry roles
* if empty.
*
* @return all of the roles are set to assigned equals false
*/
@Request(RequestType.SESSION)
public RegistryRole[] getRolesForUser(String sessionId, String userOID) {
GeoprismUser geoPrismUser = GeoprismUser.get(userOID);
List<RegistryRole> registryRoles = new LinkedList<RegistryRole>();
Set<String> roleNameSet = new HashSet<String>();
OIterator<? extends com.runwaysdk.system.Roles> roleIterator = geoPrismUser.getAllAssignedRole();
for (Roles role : roleIterator) {
RegistryRole registryRole = new RegistryRoleConverter().build(role);
if (registryRole != null) {
registryRole.setAssigned(true);
LocalizedValueConverter.populateOrganizationDisplayLabel(registryRole);
LocalizedValueConverter.populateGeoObjectTypeLabel(registryRole);
registryRoles.add(registryRole);
roleNameSet.add(registryRole.getName());
}
}
// Add the registry roles that the user can be a member of based on their
// organization affiliation
OIterator<? extends Business> organizationIterators = geoPrismUser.getParents(OrganizationUser.CLASS);
for (Business business : organizationIterators) {
Organization organization = (Organization) business;
List<RegistryRole> orgRoleIterator = this.getRolesForOrganization(organization.getCode());
for (RegistryRole registryRole : orgRoleIterator) {
if (!roleNameSet.contains(registryRole.getName())) {
registryRoles.add(registryRole);
}
}
}
if (!roleNameSet.contains(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE)) {
Roles sra = Roles.findRoleByName(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE);
RegistryRole rrSRA = new RegistryRoleConverter().build(sra);
rrSRA.setAssigned(false);
registryRoles.add(rrSRA);
}
return registryRoles.stream().sorted(Comparator.comparing(RegistryRole::getOrganizationCode).thenComparing(RegistryRole::getGeoObjectTypeCode)).toArray(size -> new RegistryRole[size]);
}
Aggregations