Search in sources :

Example 1 with AccessApproval

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;
}
Also used : AccessApproval(org.sagebionetworks.repo.model.AccessApproval) DBOAccessApproval(org.sagebionetworks.repo.model.dbo.persistence.DBOAccessApproval) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) ArrayList(java.util.ArrayList) DBOAccessApproval(org.sagebionetworks.repo.model.dbo.persistence.DBOAccessApproval)

Example 2 with AccessApproval

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;
}
Also used : AccessApproval(org.sagebionetworks.repo.model.AccessApproval) DBOAccessApproval(org.sagebionetworks.repo.model.dbo.persistence.DBOAccessApproval) MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) ArrayList(java.util.ArrayList) DBOAccessApproval(org.sagebionetworks.repo.model.dbo.persistence.DBOAccessApproval)

Example 3 with AccessApproval

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;
}
Also used : MapSqlParameterSource(org.springframework.jdbc.core.namedparam.MapSqlParameterSource) AccessApproval(org.sagebionetworks.repo.model.AccessApproval) DBOAccessApproval(org.sagebionetworks.repo.model.dbo.persistence.DBOAccessApproval) DBOAccessApproval(org.sagebionetworks.repo.model.dbo.persistence.DBOAccessApproval)

Example 4 with AccessApproval

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;
}
Also used : DBOAccessApproval(org.sagebionetworks.repo.model.dbo.persistence.DBOAccessApproval) AccessApproval(org.sagebionetworks.repo.model.AccessApproval) Date(java.util.Date)

Example 5 with AccessApproval

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;
}
Also used : TermsOfUseAccessApproval(org.sagebionetworks.repo.model.TermsOfUseAccessApproval) AccessApproval(org.sagebionetworks.repo.model.AccessApproval) ACTAccessApproval(org.sagebionetworks.repo.model.ACTAccessApproval) ArrayList(java.util.ArrayList) QueryResults(org.sagebionetworks.repo.model.QueryResults) TermsOfUseAccessRequirement(org.sagebionetworks.repo.model.TermsOfUseAccessRequirement) AccessRequirement(org.sagebionetworks.repo.model.AccessRequirement) ACTAccessRequirement(org.sagebionetworks.repo.model.ACTAccessRequirement)

Aggregations

AccessApproval (org.sagebionetworks.repo.model.AccessApproval)18 TermsOfUseAccessApproval (org.sagebionetworks.repo.model.TermsOfUseAccessApproval)10 Test (org.junit.Test)6 DBOAccessApproval (org.sagebionetworks.repo.model.dbo.persistence.DBOAccessApproval)6 ArrayList (java.util.ArrayList)4 ACTAccessApproval (org.sagebionetworks.repo.model.ACTAccessApproval)4 AccessRequirement (org.sagebionetworks.repo.model.AccessRequirement)4 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)3 AccessApprovalDAO (org.sagebionetworks.repo.model.AccessApprovalDAO)2 TermsOfUseAccessRequirement (org.sagebionetworks.repo.model.TermsOfUseAccessRequirement)2 UserInfo (org.sagebionetworks.repo.model.UserInfo)2 NotFoundException (org.sagebionetworks.repo.web.NotFoundException)2 Transactional (org.springframework.transaction.annotation.Transactional)2 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 Method (java.lang.reflect.Method)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1