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();
}
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();
}
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);
}
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;
}
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);
}
Aggregations