Search in sources :

Example 1 with DocumentSet

use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.

the class PublishedDatasetVariablesSetResource method importVariables.

@POST
@Path("/documents/_import")
@Consumes(MediaType.TEXT_PLAIN)
public Response importVariables(String body) {
    DocumentSet set = variableSetService.get(id);
    if (Strings.isNullOrEmpty(body))
        return Response.ok().entity(dtos.asDto(set)).build();
    variableSetService.addIdentifiers(id, variableSetService.extractIdentifiers(body));
    return Response.ok().entity(dtos.asDto(variableSetService.get(id))).build();
}
Also used : DocumentSet(org.obiba.mica.core.domain.DocumentSet)

Example 2 with DocumentSet

use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.

the class PublishedDatasetVariablesSetResource method deleteVariables.

@POST
@Path("/documents/_delete")
@Consumes(MediaType.TEXT_PLAIN)
public Response deleteVariables(String body) {
    DocumentSet set = variableSetService.get(id);
    if (Strings.isNullOrEmpty(body))
        return Response.ok().entity(dtos.asDto(set)).build();
    variableSetService.removeIdentifiers(id, variableSetService.extractIdentifiers(body));
    return Response.ok().entity(dtos.asDto(variableSetService.get(id))).build();
}
Also used : DocumentSet(org.obiba.mica.core.domain.DocumentSet)

Example 3 with DocumentSet

use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.

the class DocumentSetService method setIdentifiers.

/**
 * Set the new list of identifiers to a document set and notifies that some of them have been removed (if any).
 *
 * @param id
 * @param identifiers
 * @return
 */
public DocumentSet setIdentifiers(String id, List<String> identifiers) {
    DocumentSet documentSet = get(id);
    Set<String> removedIdentifiers = Sets.difference(documentSet.getIdentifiers(), Sets.newLinkedHashSet(identifiers));
    documentSet.setIdentifiers(identifiers);
    return save(documentSet, removedIdentifiers);
}
Also used : DocumentSet(org.obiba.mica.core.domain.DocumentSet)

Example 4 with DocumentSet

use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.

the class DocumentSetService method save.

private DocumentSet save(DocumentSet documentSet, Set<String> removedIdentifiers) {
    DocumentSet saved = saveInternal(documentSet);
    eventBus.post(new DocumentSetUpdatedEvent(saved, removedIdentifiers));
    return saved;
}
Also used : DocumentSetUpdatedEvent(org.obiba.mica.core.event.DocumentSetUpdatedEvent) DocumentSet(org.obiba.mica.core.domain.DocumentSet)

Example 5 with DocumentSet

use of org.obiba.mica.core.domain.DocumentSet in project mica2 by obiba.

the class PublishedNetworksSetResource 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.NETWORK, query);
    if (result.hasNetworkResultDto() && result.getNetworkResultDto().getTotalHits() > 0) {
        List<String> ids = result.getNetworkResultDto().getExtension(MicaSearch.NetworkResultDto.result).getNetworksList().stream().map(Mica.NetworkDto::getId).collect(Collectors.toList());
        getDocumentSetService().addIdentifiers(id, ids);
        set = getSecuredDocumentSet(id);
    }
    return dtos.asDto(set);
}
Also used : MicaSearch(org.obiba.mica.web.model.MicaSearch) DocumentSet(org.obiba.mica.core.domain.DocumentSet) Mica(org.obiba.mica.web.model.Mica)

Aggregations

DocumentSet (org.obiba.mica.core.domain.DocumentSet)35 Lists (com.google.common.collect.Lists)7 List (java.util.List)7 Map (java.util.Map)6 Collectors (java.util.stream.Collectors)6 Inject (javax.inject.Inject)6 StreamingOutput (javax.ws.rs.core.StreamingOutput)5 VariableSetService (org.obiba.mica.dataset.service.VariableSetService)5 Mica (org.obiba.mica.web.model.Mica)5 MicaSearch (org.obiba.mica.web.model.MicaSearch)5 Component (org.springframework.stereotype.Component)5 Subscribe (com.google.common.eventbus.Subscribe)4 ForbiddenException (javax.ws.rs.ForbiddenException)4 Strings (com.google.common.base.Strings)3 SecurityUtils (org.apache.shiro.SecurityUtils)3 AuthorizationException (org.apache.shiro.authz.AuthorizationException)3 Subject (org.apache.shiro.subject.Subject)3 DocumentSetUpdatedEvent (org.obiba.mica.core.event.DocumentSetUpdatedEvent)3 ReportGenerator (org.obiba.mica.search.reports.ReportGenerator)3 Logger (org.slf4j.Logger)3