public RemoteProjectRole[] getProjectRoles(User currentUser) throws RemoteException { SimpleErrorCollection errorCollection = new SimpleErrorCollection(); Collection remoteRoles = new ArrayList(); Collection realRoles = projectRoleService.getProjectRoles(currentUser, errorCollection); checkAndThrowErrors("Error getting project role", errorCollection); for (Iterator iterator = realRoles.iterator(); iterator.hasNext();) { ProjectRole projectRole = (ProjectRole) iterator.next(); remoteRoles.add(new RemoteProjectRole(projectRole.getId(), projectRole.getName(), projectRole.getDescription())); } return (RemoteProjectRole[]) remoteRoles.toArray(new RemoteProjectRole[remoteRoles.size()]); }
@Override public ProjectRoleBean shortRoleBean(@Nonnull final ProjectRole projectRole) { final ProjectRoleBean projectRoleBean = new ProjectRoleBean(); projectRoleBean.name = projectRole.getName(); projectRoleBean.id = projectRole.getId(); projectRoleBean.description = projectRole.getDescription(); projectRoleBean.self = UriBuilder.fromPath(jiraBaseUrls.restApi2BaseUrl()) .path("role") .path(projectRoleBean.id.toString()) .build(); return projectRoleBean; } }
public ProjectRole createRole(ProjectRole projectRole) { MockProjectRole role = new MockProjectRole(++idCounter, projectRole.getName(), projectRole.getDescription()); addRole(projectRole); return role; }
public String doDefault() throws Exception { ProjectRole roleType = getRole(); name = roleType.getName(); description = roleType.getDescription(); return super.doDefault(); }
public static Builder from(ProjectRole role) { return new Builder(role.getId(), role.getName(), role.getDescription()); }
@Override public ProjectRoleBean projectRole(@Nonnull final ProjectRole projectRole, final DefaultRoleActors actors) { final ProjectRoleBean projectRoleBean = new ProjectRoleBean(); projectRoleBean.name = projectRole.getName(); projectRoleBean.id = projectRole.getId(); projectRoleBean.description = projectRole.getDescription(); projectRoleBean.self = uriInfo.getBaseUriBuilder().path(RoleResource.class).path(projectRoleBean.id.toString()).build(); if (actors != null && isNotEmpty(actors.getRoleActors())) { projectRoleBean.actors = Transformed.collection(actors.getRoleActors(), new Function<RoleActor, RoleActorBean>() { public RoleActorBean get(RoleActor actor) { return RoleActorBean.convert(actor); } }); } return projectRoleBean; }
public RemoteProjectRole getProjectRole(User currentUser, Long id) throws RemoteException { SimpleErrorCollection errorCollection = new SimpleErrorCollection(); ProjectRole realRole = projectRoleService.getProjectRole(currentUser, id, errorCollection); checkAndThrowErrors("Error getting project role", errorCollection); return new RemoteProjectRole(realRole.getId(), realRole.getName(), realRole.getDescription()); }
public ProjectRole addProjectRole(final ProjectRole projectRole) { try { final GenericValue projectRoleGV = EntityUtils.createValue(ENTITY_NAME, MapBuilder.<String, Object>build(PROJECT_ROLE_FIELD_NAME, projectRole.getName(), PROJECT_ROLE_FIELD_DESCRIPTION, projectRole.getDescription())); return new ProjectRoleImpl(projectRoleGV.getLong(FIELD_ID), projectRoleGV.getString(PROJECT_ROLE_FIELD_NAME), projectRoleGV.getString(PROJECT_ROLE_FIELD_DESCRIPTION)); } catch (final Exception e) { log.error("Unable to store project role, removing any partially stored entity: " + projectRole.getName(), e); throw new DataAccessException(e); } }
public RemoteProjectRole createProjectRole(User currentUser, RemoteProjectRole projectRole) throws RemoteException { SimpleErrorCollection errorCollection = new SimpleErrorCollection(); ProjectRole realRole = getProjectRoleFromRemoteProjectRole(projectRole); realRole = projectRoleService.createProjectRole(currentUser, realRole, errorCollection); checkAndThrowErrors("Error creating project role", errorCollection); return new RemoteProjectRole(realRole.getId(), realRole.getName(), realRole.getDescription()); }
public void updateProjectRole(final ProjectRole projectRole) { try { final GenericValue projectRoleGv = ofBizDelegator.findById(ENTITY_NAME, projectRole.getId()); projectRoleGv.set(PROJECT_ROLE_FIELD_NAME, projectRole.getName()); projectRoleGv.set(PROJECT_ROLE_FIELD_DESCRIPTION, projectRole.getDescription()); projectRoleGv.store(); } catch (final GenericEntityException e) { throw new DataAccessException(e); } }
/** * Returns a json string of [ {id: 1, name: groupName, description: desc}, ... ] */ private String getProjectRolesAsJsonString(final Collection<ProjectRole> projectRoles) { JSONArray root = new JSONArray(); for (ProjectRole projectRole : projectRoles) { JSONObject role = new JSONObject(); try { role.put("id", projectRole.getId()); role.put("name", projectRole.getName()); role.put("description", projectRole.getDescription()); } catch (JSONException e) { log.warn("skipping project role object that could not converted to json: " + projectRole + " - " + e.getMessage()); } root.put(role); } return root.toString(); } }