use of org.obiba.mica.core.domain.DocumentSet 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;
}
use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.
the class PublishedStudiesSetResource method reportStudies.
@GET
@Path("/documents/_report")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response reportStudies(@PathParam("id") String id, @QueryParam("locale") @DefaultValue("en") String locale) {
DocumentSet documentSet = getSecuredDocumentSet(id);
ReportGenerator reporter = new StudyCsvReportGenerator(studySetService.getPublishedStudies(documentSet, true), locale, personService);
StreamingOutput stream = reporter::write;
return Response.ok(stream).header("Content-Disposition", "attachment; filename=\"Studies.zip\"").build();
}
use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.
the class PublishedStudiesSetResource method importQueryDocuments.
private Mica.DocumentSetDto importQueryDocuments(String id, String query) {
DocumentSet set = getSecuredDocumentSet(id);
if (Strings.isNullOrEmpty(query))
return dtos.asDto(set);
MicaSearch.JoinQueryResultDto result = makeQuery(QueryType.STUDY, query);
if (result.hasStudyResultDto() && result.getStudyResultDto().getTotalHits() > 0) {
List<String> ids = result.getStudyResultDto().getExtension(MicaSearch.StudyResultDto.result).getSummariesList().stream().map(Mica.StudySummaryDto::getId).collect(Collectors.toList());
getDocumentSetService().addIdentifiers(id, ids);
set = getSecuredDocumentSet(id);
}
return dtos.asDto(set);
}
use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.
the class PublishedDatasetVariablesSetResource method reportVariables.
@GET
@Path("/documents/_report")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response reportVariables(@PathParam("id") String id, @QueryParam("locale") @DefaultValue("en") String locale) {
DocumentSet documentSet = getSecuredDocumentSet(id);
ReportGenerator reporter = new DatasetVariableCsvReportGenerator(variableSetService.getVariables(documentSet, false), locale);
StreamingOutput stream = reporter::write;
return Response.ok(stream).header("Content-Disposition", "attachment; filename=\"Variables.zip\"").build();
}
use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.
the class PublishedDatasetVariablesSetResource method createOpalViewsGet.
@GET
@Path("/documents/_opal")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response createOpalViewsGet(@PathParam("id") String id, @QueryParam("ids") String identifiers) {
DocumentSet set = getSecuredDocumentSet(id);
if (!subjectAclService.isAdministrator() && !subjectAclService.isDataAccessOfficer())
throw new AuthorizationException();
StreamingOutput streamingOutput;
if (!Strings.isNullOrEmpty(identifiers)) {
streamingOutput = stream -> variableSetService.createOpalViewsZip(variableSetService.getVariables(Sets.newHashSet(identifiers.split(","))), micaConfigService.getConfig().getOpalViewsGrouping(), new BufferedOutputStream(stream));
} else {
streamingOutput = stream -> variableSetService.createOpalViewsZip(variableSetService.getVariables(set), micaConfigService.getConfig().getOpalViewsGrouping(), new BufferedOutputStream(stream));
}
return Response.ok(streamingOutput, MediaType.APPLICATION_OCTET_STREAM).header("Content-Disposition", "attachment; filename=\"opal-views-" + id + ".zip\"").build();
}
Aggregations