use of org.sagebionetworks.repo.model.AccessApproval in project Synapse-Repository-Services by Sage-Bionetworks.
the class DBOAccessApprovalDAOImpl method getForAccessRequirementsAndPrincipals.
@Override
public List<AccessApproval> getForAccessRequirementsAndPrincipals(Collection<String> accessRequirementIds, Collection<String> principalIds) throws DatastoreException {
List<AccessApproval> dtos = new ArrayList<AccessApproval>();
if (accessRequirementIds.isEmpty() || principalIds.isEmpty())
return dtos;
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue(COL_ACCESS_APPROVAL_REQUIREMENT_ID, accessRequirementIds);
params.addValue(COL_ACCESS_APPROVAL_ACCESSOR_ID, principalIds);
List<DBOAccessApproval> dbos = simpleJdbcTemplate.query(SELECT_FOR_REQUIREMENT_AND_PRINCIPAL_SQL, rowMapper, params);
for (DBOAccessApproval dbo : dbos) {
AccessApproval dto = AccessApprovalUtils.copyDboToDto(dbo);
// validate: The principal ID and accessor ID should each be from the passed in lists
if (!principalIds.contains(dto.getAccessorId()))
throw new IllegalStateException("PrincipalIDs: " + principalIds + " but accessorId: " + dto.getAccessorId());
if (!accessRequirementIds.contains(dto.getRequirementId().toString()))
throw new IllegalStateException("accessRequirementIds: " + accessRequirementIds + " but requirementId: " + dto.getRequirementId());
dtos.add(dto);
}
return dtos;
}
use of org.sagebionetworks.repo.model.AccessApproval in project Synapse-Repository-Services by Sage-Bionetworks.
the class DBOAccessApprovalDAOImpl method getForAccessRequirement.
@Override
public List<AccessApproval> getForAccessRequirement(String accessRequirementId) throws DatastoreException {
List<AccessApproval> dtos = new ArrayList<AccessApproval>();
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue(COL_ACCESS_APPROVAL_REQUIREMENT_ID, accessRequirementId);
List<DBOAccessApproval> dbos = simpleJdbcTemplate.query(SELECT_FOR_REQUIREMENT_SQL, rowMapper, params);
for (DBOAccessApproval dbo : dbos) {
AccessApproval dto = AccessApprovalUtils.copyDboToDto(dbo);
if (!accessRequirementId.equals(dto.getRequirementId().toString()))
throw new IllegalStateException("accessRequirementId: " + accessRequirementId + " but dto.getRequirementId(): " + dto.getRequirementId());
dtos.add(dto);
}
return dtos;
}
use of org.sagebionetworks.repo.model.AccessApproval in project Synapse-Repository-Services by Sage-Bionetworks.
the class DBOAccessApprovalDAOImpl method get.
@Override
public AccessApproval get(String id) throws DatastoreException, NotFoundException {
MapSqlParameterSource param = new MapSqlParameterSource();
param.addValue(COL_ACCESS_APPROVAL_ID.toLowerCase(), id);
DBOAccessApproval dbo = basicDao.getObjectById(DBOAccessApproval.class, param);
AccessApproval dto = AccessApprovalUtils.copyDboToDto(dbo);
return dto;
}
use of org.sagebionetworks.repo.model.AccessApproval in project Synapse-Repository-Services by Sage-Bionetworks.
the class AccessApprovalUtils method copyDboToDto.
public static AccessApproval copyDboToDto(DBOAccessApproval dbo) throws DatastoreException {
AccessApproval dto = copyFromSerializedField(dbo);
dto.setId(dbo.getId());
dto.setEtag(dbo.geteTag());
dto.setCreatedBy(dbo.getCreatedBy().toString());
dto.setCreatedOn(new Date(dbo.getCreatedOn()));
dto.setModifiedBy(dbo.getModifiedBy().toString());
dto.setModifiedOn(new Date(dbo.getModifiedOn()));
dto.setRequirementId(dbo.getRequirementId());
dto.setAccessorId(dbo.getAccessorId().toString());
dto.setEntityType(dbo.getEntityType());
return dto;
}
use of org.sagebionetworks.repo.model.AccessApproval in project Synapse-Repository-Services by Sage-Bionetworks.
the class AccessApprovalManagerImpl method getAccessApprovalsForEntity.
@Override
public QueryResults<AccessApproval> getAccessApprovalsForEntity(UserInfo userInfo, String entityId) throws DatastoreException, NotFoundException, ForbiddenException {
ACTUtils.verifyACTTeamMembershipOrIsAdmin(userInfo, userGroupDAO);
List<AccessRequirement> ars = accessRequirementDAO.getForNode(entityId);
List<AccessApproval> aas = new ArrayList<AccessApproval>();
for (AccessRequirement ar : ars) {
aas.addAll(accessApprovalDAO.getForAccessRequirement(ar.getId().toString()));
}
QueryResults<AccessApproval> result = new QueryResults<AccessApproval>(aas, aas.size());
return result;
}
Aggregations