use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.
the class ClassificationType method assignPermissions.
public void assignPermissions() {
MdVertexDAOIF mdVertex = this.mdClassification.getReferenceMdVertexDAO();
MdEdgeDAOIF mdEdge = this.mdClassification.getReferenceMdEdgeDAO();
Roles sraRole = Roles.findRoleByName(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE);
this.assignPermissions(mdVertex, sraRole, true);
this.assignPermissions(mdEdge, sraRole, true);
Roles raRole = Roles.findRoleByName(RegistryConstants.REGISTRY_ADMIN_ROLE);
this.assignPermissions(mdVertex, raRole, false);
this.assignPermissions(mdEdge, raRole, false);
Roles rmRole = Roles.findRoleByName(RegistryConstants.REGISTRY_MAINTAINER_ROLE);
this.assignPermissions(mdVertex, rmRole, false);
this.assignPermissions(mdEdge, rmRole, false);
Roles rcRole = Roles.findRoleByName(RegistryConstants.REGISTRY_CONTRIBUTOR_ROLE);
this.assignPermissions(mdVertex, rcRole, false);
this.assignPermissions(mdEdge, rcRole, false);
Roles acRole = Roles.findRoleByName(RegistryConstants.API_CONSUMER_ROLE);
this.assignPermissions(mdVertex, acRole, false);
this.assignPermissions(mdEdge, acRole, false);
}
use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.
the class ServerGeoObjectType method deleteInTransaction.
@Transaction
private void deleteInTransaction() {
List<ServerHierarchyType> hierarchies = this.getHierarchies(true);
if (hierarchies.size() > 0) {
StringBuilder codes = hierarchies.stream().collect(StringBuilder::new, (x, y) -> x.append(y.getCode()), (a, b) -> a.append(",").append(b));
throw new TypeInUseException("Cannot delete a GeoObjectType used in the hierarchies: " + codes);
}
// for (String hierarchy : hierarchies)
// {
// OIterator<com.runwaysdk.business.ontology.Term> it =
// this.universal.getDirectDescendants(hierarchy);
//
// try
// {
// if (it.hasNext())
// {
// }
// }
// finally
// {
// it.close();
// }
// }
/*
* Delete all subtypes
*/
List<ServerGeoObjectType> subtypes = this.getSubtypes();
for (ServerGeoObjectType subtype : subtypes) {
subtype.deleteInTransaction();
}
/*
* Delete all inherited hierarchies
*/
List<? extends InheritedHierarchyAnnotation> annotations = InheritedHierarchyAnnotation.getByUniversal(getUniversal());
for (InheritedHierarchyAnnotation annotation : annotations) {
annotation.delete();
}
GeoVertexType.remove(this.universal.getUniversalId());
/*
* Delete all Attribute references
*/
// AttributeHierarchy.deleteByUniversal(this.universal);
this.getMetadata().delete();
// This deletes the {@link MdBusiness} as well
this.universal.delete(false);
// Delete the term root
Classifier classRootTerm = TermConverter.buildIfNotExistdMdBusinessClassifier(this.mdBusiness);
classRootTerm.delete();
// roles specified on the super type.
if (this.getSuperType() == null) {
Actor ownerActor = this.universal.getOwner();
if (ownerActor instanceof Roles) {
Roles ownerRole = (Roles) ownerActor;
String roleName = ownerRole.getRoleName();
if (RegistryRole.Type.isOrgRole(roleName)) {
String organizationCode = RegistryRole.Type.parseOrgCode(roleName);
String geoObjectTypeCode = this.type.getCode();
String rmRoleName = RegistryRole.Type.getRM_RoleName(organizationCode, geoObjectTypeCode);
Roles role = Roles.findRoleByName(rmRoleName);
role.delete();
String rcRoleName = RegistryRole.Type.getRC_RoleName(organizationCode, geoObjectTypeCode);
role = Roles.findRoleByName(rcRoleName);
role.delete();
String acRoleName = RegistryRole.Type.getAC_RoleName(organizationCode, geoObjectTypeCode);
role = Roles.findRoleByName(acRoleName);
role.delete();
}
}
}
ListType.markAllAsInvalid(null, this);
new SearchService().clear(this.getCode());
new ChangeRequestService().markAllAsInvalid(this);
// Delete the transition and transition events
TransitionEvent.removeAll(this);
Transition.removeAll(this);
}
use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.
the class ServerGeoObjectType method getOrganization.
/**
* @return The organization associated with this GeoObjectType.
*/
public Organization getOrganization() {
Actor owner = this.universal.getOwner();
if (!(owner instanceof Roles)) {
// If we get here, then the GeoObjectType was not created
return null;
// correctly.
} else {
Roles uniRole = (Roles) owner;
String myOrgCode = RegistryRole.Type.parseOrgCode(uniRole.getRoleName());
return Organization.getByCode(myOrgCode);
}
}
use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.
the class OrganizationAndRoleTest method rm_RoleToRegistryRoleRequest.
@Request
public void rm_RoleToRegistryRoleRequest() {
String rmRoleName = RegistryRole.Type.getRM_RoleName(FastTestDataset.ORG_CGOV.getCode(), FastTestDataset.PROVINCE.getCode());
Roles rmRole = Roles.findRoleByName(rmRoleName);
RegistryRole registryRole = new RegistryRoleConverter().build(rmRole);
Assert.assertEquals(rmRoleName, registryRole.getName());
Assert.assertEquals(FastTestDataset.ORG_CGOV.getCode(), registryRole.getOrganizationCode());
Assert.assertEquals(FastTestDataset.PROVINCE.getCode(), registryRole.getGeoObjectTypeCode());
}
use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.
the class TaskTest method createInstanceData.
@Request(RequestType.SESSION)
private static void createInstanceData(String sessionId) {
final List<Roles> roles = new ArrayList<Roles>();
roles.add(Roles.findRoleByName(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE));
LocalizedValueStore lv = new LocalizedValueStore();
lv.setStoreKey(TestTaskType.TestGeoObjectSplitOrphanedChildren.getTitleKey());
lv.setStoreTag("UIText");
lv.setStructValue(LocalizedValueStore.STOREVALUE, MdAttributeLocalInfo.DEFAULT_LOCALE, "Split Has Orphaned Children");
lv.setStructValue(LocalizedValueStore.STOREVALUE, Locale.CHINESE.toString(), "斯普利特有孤儿");
lv.setStructValue(LocalizedValueStore.STOREVALUE, Locale.KOREAN.toString(), "스 플리트는 고아를 낳았다");
lv.setStructValue(LocalizedValueStore.STOREVALUE, Locale.CANADA.toString(), "Oh no! Split Has Orphaned Children eh.");
lv.apply();
LocalizedValueStore lv2 = new LocalizedValueStore();
lv2.setStoreKey(TestTaskType.TestGeoObjectSplitOrphanedChildren.getTemplateKey());
lv2.setStoreTag("UIText");
lv2.setStructValue(LocalizedValueStore.STOREVALUE, MdAttributeLocalInfo.DEFAULT_LOCALE, "The {typeName} {oldParentName} has split. You must reassign the children with new parents.");
lv2.setStructValue(LocalizedValueStore.STOREVALUE, Locale.CHINESE.toString(), "{typeName} {oldParentName}已拆分。 您必须将孩子重新分配给新父母。");
lv2.setStructValue(LocalizedValueStore.STOREVALUE, Locale.KOREAN.toString(), "{typeName} {oldParentName}이 (가) 분할되었습니다. 새 부모에게 자녀를 재 할당해야합니다.");
lv2.setStructValue(LocalizedValueStore.STOREVALUE, Locale.CANADA.toString(), "Oh no! The {typeName} {oldParentName} has split. You must reassign the children with new parents eh.");
lv2.apply();
Map<String, LocalizedValue> values = new HashMap<String, LocalizedValue>();
LocalizedValue lvTypeName = new LocalizedValue(null);
lvTypeName.setValue(MdAttributeLocalInfo.DEFAULT_LOCALE, "district");
lvTypeName.setValue(Locale.CHINESE, "区");
lvTypeName.setValue(Locale.KOREAN, "지구");
lvTypeName.setValue(Locale.CANADA, "district eh");
values.put("typeName", lvTypeName);
LocalizedValue lvOldParentName = new LocalizedValue(null);
lvOldParentName.setValue(MdAttributeLocalInfo.DEFAULT_LOCALE, "D1");
lvOldParentName.setValue(Locale.CHINESE, "D1 Chinese");
lvOldParentName.setValue(Locale.KOREAN, "D1 Korean");
lvOldParentName.setValue(Locale.CANADA, "D1 Canada");
values.put("oldParentName", lvOldParentName);
Task.createNewTask(roles, TestTaskType.TestGeoObjectSplitOrphanedChildren, values, null);
}
Aggregations