use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.
the class Transition method createTask.
public void createTask(VertexServerGeoObject source, VertexServerGeoObject target, Date eventDate) {
LocalizedValue dateValue = LocalizedValueConverter.convert(eventDate);
TransitionType transitionType = this.toTransitionType();
ServerGeoObjectType sourceType = source.getType();
ServerGeoObjectType targetType = target.getType();
List<ServerGeoObjectType> types = Arrays.asList(new ServerGeoObjectType[] { sourceType, targetType }).stream().distinct().collect(Collectors.toList());
for (ServerGeoObjectType type : types) {
List<ServerHierarchyType> hierarchies = type.getHierarchies();
for (ServerHierarchyType hierarchy : hierarchies) {
List<ServerGeoObjectType> children = type.getChildren(hierarchy);
for (ServerGeoObjectType child : children) {
List<Roles> roles = Arrays.asList(new String[] { child.getMaintainerRoleName(), child.getAdminRoleName() }).stream().distinct().map(name -> Roles.findRoleByName(name)).collect(Collectors.toList());
HashMap<String, LocalizedValue> values = new HashMap<String, LocalizedValue>();
values.put("1", source.getDisplayLabel());
values.put("2", sourceType.getLabel());
values.put("3", target.getDisplayLabel());
values.put("4", targetType.getLabel());
values.put("5", child.getLabel());
values.put("6", hierarchy.getLabel());
values.put("7", dateValue);
TaskType taskType = Task.TaskType.SPLIT_EVENT_TASK;
if (transitionType.isMerge()) {
taskType = Task.TaskType.MERGE_EVENT_TASK;
} else if (transitionType.isReassign()) {
taskType = Task.TaskType.REASSIGN_EVENT_TASK;
}
Task.createNewTask(roles, taskType, values, this.getOid());
}
}
}
}
use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.
the class LocalizedValueConverter method setOwner.
/**
* Set the owner to the corresponding {@link Organization} role for the given
* code, or if code is null then the owner field is not set.
*
* @param business
* @param organizationCode
*/
protected static void setOwner(Business business, String organizationCode) {
Organization organization = null;
Roles orgRole = null;
if (organizationCode != null && !organizationCode.equals("")) {
organization = Organization.getByKey(organizationCode);
orgRole = organization.getRole();
business.setOwner(orgRole);
}
}
use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.
the class ServerGeoObjectTypeConverter method create_RC_GeoObjectTypeRole.
private void create_RC_GeoObjectTypeRole(MdGeoVertexDAO mdGeoVertexDAO, String organizationCode, String geoObjectTypeCode) {
if (organizationCode != null && !organizationCode.trim().equals("")) {
String rcRoleName = RegistryRole.Type.getRC_RoleName(organizationCode, geoObjectTypeCode);
Locale locale = Session.getCurrentLocale();
String defaultDisplayLabel = mdGeoVertexDAO.getLocalValue(MdGeoVertexInfo.DISPLAY_LABEL, locale) + " Registry Contributor";
Roles rcOrgRole = new Roles();
rcOrgRole.setRoleName(rcRoleName);
rcOrgRole.getDisplayLabel().setDefaultValue(defaultDisplayLabel);
rcOrgRole.apply();
String orgRoleName = RegistryRole.Type.getRootOrgRoleName(organizationCode);
Roles orgRole = Roles.findRoleByName(orgRoleName);
RoleDAO orgRoleDAO = (RoleDAO) BusinessFacade.getEntityDAO(orgRole);
RoleDAO rcOrgRoleDAO = (RoleDAO) BusinessFacade.getEntityDAO(rcOrgRole);
orgRoleDAO.addInheritance(rcOrgRoleDAO);
// Inherit the permissions from the root RC role
RoleDAO rootRC_DAO = (RoleDAO) BusinessFacade.getEntityDAO(Roles.findRoleByName(RegistryConstants.REGISTRY_CONTRIBUTOR_ROLE));
rootRC_DAO.addInheritance(rcOrgRoleDAO);
}
}
use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.
the class ServerGeoObjectTypeConverter method assignSRAPermissions.
public void assignSRAPermissions(MdGeoVertexDAO mdGeoVertexDAO, MdBusiness mdBusiness) {
Roles sraRole = Roles.findRoleByName(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE);
this.assignAllPermissions(mdBusiness, sraRole);
this.assignAllPermissions(mdGeoVertexDAO, sraRole);
}
use of com.runwaysdk.system.Roles in project geoprism-registry by terraframe.
the class ServerGeoObjectTypeConverter method create_AC_GeoObjectTypeRole.
private void create_AC_GeoObjectTypeRole(MdGeoVertexDAO mdGeoVertexDAO, String organizationCode, String geoObjectTypeCode) {
if (organizationCode != null && !organizationCode.trim().equals("")) {
String acRoleName = RegistryRole.Type.getAC_RoleName(organizationCode, geoObjectTypeCode);
Locale locale = Session.getCurrentLocale();
String defaultDisplayLabel = mdGeoVertexDAO.getLocalValue(MdGeoVertexInfo.DISPLAY_LABEL, locale) + " API Consumer";
Roles acOrgRole = new Roles();
acOrgRole.setRoleName(acRoleName);
acOrgRole.getDisplayLabel().setDefaultValue(defaultDisplayLabel);
acOrgRole.apply();
String orgRoleName = RegistryRole.Type.getRootOrgRoleName(organizationCode);
Roles orgRole = Roles.findRoleByName(orgRoleName);
RoleDAO orgRoleDAO = (RoleDAO) BusinessFacade.getEntityDAO(orgRole);
RoleDAO acOrgRoleDAO = (RoleDAO) BusinessFacade.getEntityDAO(acOrgRole);
orgRoleDAO.addInheritance(acOrgRoleDAO);
// Inherit the permissions from the root RC role
RoleDAO rootAC_DAO = (RoleDAO) BusinessFacade.getEntityDAO(Roles.findRoleByName(RegistryConstants.API_CONSUMER_ROLE));
rootAC_DAO.addInheritance(acOrgRoleDAO);
}
}
Aggregations