Search in sources :

Example 1 with DataAccessEntity

use of org.obiba.mica.access.domain.DataAccessEntity in project mica2 by obiba.

the class DataAccessEntityResource method review.

protected Response review(String id) {
    DataAccessEntity request = getService().findById(id);
    boolean fromConditionallyApproved = request.getStatus() == DataAccessEntityStatus.CONDITIONALLY_APPROVED;
    if (fromConditionallyApproved) {
        restoreDaoActions(id);
    }
    return updateStatus(id, DataAccessEntityStatus.REVIEWED);
}
Also used : DataAccessEntity(org.obiba.mica.access.domain.DataAccessEntity)

Example 2 with DataAccessEntity

use of org.obiba.mica.access.domain.DataAccessEntity in project mica2 by obiba.

the class DataAccessEntityResource method createOrUpdateVariablesSet.

// 
// Private methods
// 
/**
 * Create or update a variables set from user's cart.
 *
 * @param entity
 * @return
 */
protected DocumentSet createOrUpdateVariablesSet(DataAccessEntity entity) {
    DocumentSet set;
    DocumentSet cart = variableSetService.getCartCurrentUser();
    String setId = String.format("dar:%s", entity.getId());
    Optional<DocumentSet> setOpt = variableSetService.getAllCurrentUser().stream().filter(docset -> setId.equals(docset.getName())).findFirst();
    if (setOpt.isPresent()) {
        // reuse and append an existing set with same name
        set = variableSetService.addIdentifiers(setId, Lists.newArrayList(cart.getIdentifiers()));
    } else {
        // create a new one
        set = variableSetService.create(setId, Lists.newArrayList(cart.getIdentifiers()));
    }
    // case an administrator is by-passing the flow
    if (!DataAccessEntityStatus.OPENED.equals(entity.getStatus())) {
        variableSetService.setLock(set, true);
    }
    return set;
}
Also used : SubjectAclService(org.obiba.mica.security.service.SubjectAclService) ForbiddenException(javax.ws.rs.ForbiddenException) VariableSetService(org.obiba.mica.dataset.service.VariableSetService) DataAccessConfigUpdatedEvent(org.obiba.mica.micaConfig.event.DataAccessConfigUpdatedEvent) Roles(org.obiba.mica.security.Roles) DataAccessEntity(org.obiba.mica.access.domain.DataAccessEntity) Collectors(java.util.stream.Collectors) DataAccessEntityService(org.obiba.mica.access.service.DataAccessEntityService) FileStoreService(org.obiba.mica.file.FileStoreService) DocumentSet(org.obiba.mica.core.domain.DocumentSet) List(java.util.List) Lists(com.google.common.collect.Lists) Stream(java.util.stream.Stream) DataAccessEntityStatus(org.obiba.mica.access.domain.DataAccessEntityStatus) Response(javax.ws.rs.core.Response) DataAccessConfigService(org.obiba.mica.micaConfig.service.DataAccessConfigService) Optional(java.util.Optional) Subscribe(com.google.common.eventbus.Subscribe) BadRequestException(javax.ws.rs.BadRequestException) SecurityUtils(org.apache.shiro.SecurityUtils) DocumentSet(org.obiba.mica.core.domain.DocumentSet)

Example 3 with DataAccessEntity

use of org.obiba.mica.access.domain.DataAccessEntity in project mica2 by obiba.

the class DataAccessEntityResource method conditionallyApprove.

protected Response conditionallyApprove(String id) {
    DataAccessEntity request = getService().findById(id);
    restoreApplicantActions(id, request.getApplicant());
    return updateStatus(id, DataAccessEntityStatus.CONDITIONALLY_APPROVED);
}
Also used : DataAccessEntity(org.obiba.mica.access.domain.DataAccessEntity)

Aggregations

DataAccessEntity (org.obiba.mica.access.domain.DataAccessEntity)3 Lists (com.google.common.collect.Lists)1 Subscribe (com.google.common.eventbus.Subscribe)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 BadRequestException (javax.ws.rs.BadRequestException)1 ForbiddenException (javax.ws.rs.ForbiddenException)1 Response (javax.ws.rs.core.Response)1 SecurityUtils (org.apache.shiro.SecurityUtils)1 DataAccessEntityStatus (org.obiba.mica.access.domain.DataAccessEntityStatus)1 DataAccessEntityService (org.obiba.mica.access.service.DataAccessEntityService)1 DocumentSet (org.obiba.mica.core.domain.DocumentSet)1 VariableSetService (org.obiba.mica.dataset.service.VariableSetService)1 FileStoreService (org.obiba.mica.file.FileStoreService)1 DataAccessConfigUpdatedEvent (org.obiba.mica.micaConfig.event.DataAccessConfigUpdatedEvent)1 DataAccessConfigService (org.obiba.mica.micaConfig.service.DataAccessConfigService)1 Roles (org.obiba.mica.security.Roles)1 SubjectAclService (org.obiba.mica.security.service.SubjectAclService)1