Search in sources :

Example 16 with DocumentSet

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

the class SetsAggregationMetaDataHelper method getSetIds.

public Map<String, LocalizedMetaData> getSetIds() {
    List<String> locales = micaConfigService.getLocales();
    Map<String, Translator> translators = locales.stream().collect(Collectors.toMap(Function.identity(), locale -> JsonTranslator.buildSafeTranslator(() -> micaConfigService.getTranslations(locale, false))));
    return getDocumentSetService().getAll().stream().collect(Collectors.toMap(DocumentSet::getId, set -> {
        LocalizedString title = new LocalizedString();
        locales.forEach(locale -> {
            String setName = Strings.isNullOrEmpty(set.getName()) ? translators.get(locale).translate("sets.cart.title") : getDocumentSetName(set);
            title.forLanguageTag(locale, setName);
        });
        return new LocalizedMetaData(title, new LocalizedString(), set.getType());
    }));
}
Also used : Strings(com.google.common.base.Strings) JsonTranslator(org.obiba.core.translator.JsonTranslator) Translator(org.obiba.core.translator.Translator) DocumentSet(org.obiba.mica.core.domain.DocumentSet) LocalizedString(org.obiba.mica.core.domain.LocalizedString) DocumentSetService(org.obiba.mica.core.service.DocumentSetService) List(java.util.List) LocalizedMetaData(org.obiba.mica.micaConfig.service.helper.AggregationMetaDataProvider.LocalizedMetaData) MicaConfigService(org.obiba.mica.micaConfig.service.MicaConfigService) Map(java.util.Map) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) JsonTranslator(org.obiba.core.translator.JsonTranslator) Translator(org.obiba.core.translator.Translator) LocalizedMetaData(org.obiba.mica.micaConfig.service.helper.AggregationMetaDataProvider.LocalizedMetaData) LocalizedString(org.obiba.mica.core.domain.LocalizedString) LocalizedString(org.obiba.mica.core.domain.LocalizedString)

Example 17 with DocumentSet

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

the class AbstractPublishedDocumentsSetsResource method importDocuments.

protected Mica.DocumentSetDto importDocuments(String name, String body) {
    ensureUserIsAuthorized(name);
    if (!Strings.isNullOrEmpty(name))
        checkSetsNumberLimit();
    DocumentSet created = getDocumentSetService().create(name, getDocumentSetService().extractIdentifiers(body));
    return dtos.asDto(created);
}
Also used : DocumentSet(org.obiba.mica.core.domain.DocumentSet)

Example 18 with DocumentSet

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

the class AbstractPublishedDocumentsSetsResource method createEmptyDocumentSet.

protected Mica.DocumentSetDto createEmptyDocumentSet(String name) {
    ensureUserIsAuthorized(name);
    if (!Strings.isNullOrEmpty(name))
        checkSetsNumberLimit();
    DocumentSet created = getDocumentSetService().create(name, Lists.newArrayList());
    return dtos.asDto(created);
}
Also used : DocumentSet(org.obiba.mica.core.domain.DocumentSet)

Example 19 with DocumentSet

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

the class NetworkIndexer method documentSetDeleted.

@Async
@Subscribe
public synchronized void documentSetDeleted(DocumentSetDeletedEvent event) {
    if (!networkSetService.isForType(event.getPersistable()))
        return;
    DocumentSet documentSet = event.getPersistable();
    List<Network> toIndex = Lists.newArrayList();
    {
        List<Network> toRemove = networkSetService.getPublishedNetworks(event.getPersistable(), false);
        toRemove.forEach(ntw -> ntw.removeSet(documentSet.getId()));
        toIndex.addAll(toRemove);
    }
    indexer.indexAll(Indexer.PUBLISHED_NETWORK_INDEX, toIndex);
}
Also used : Async(org.springframework.scheduling.annotation.Async) DocumentSetUpdatedEvent(org.obiba.mica.core.event.DocumentSetUpdatedEvent) PersonService(org.obiba.mica.core.service.PersonService) Logger(org.slf4j.Logger) DocumentSetDeletedEvent(org.obiba.mica.core.event.DocumentSetDeletedEvent) LoggerFactory(org.slf4j.LoggerFactory) Membership(org.obiba.mica.core.domain.Membership) Indexer(org.obiba.mica.spi.search.Indexer) org.obiba.mica.network.event(org.obiba.mica.network.event) Collectors(java.util.stream.Collectors) NetworkSetService(org.obiba.mica.network.service.NetworkSetService) Inject(javax.inject.Inject) DocumentSet(org.obiba.mica.core.domain.DocumentSet) Component(org.springframework.stereotype.Component) List(java.util.List) Lists(com.google.common.collect.Lists) Map(java.util.Map) Subscribe(com.google.common.eventbus.Subscribe) Network(org.obiba.mica.network.domain.Network) NetworkService(org.obiba.mica.network.service.NetworkService) Network(org.obiba.mica.network.domain.Network) List(java.util.List) DocumentSet(org.obiba.mica.core.domain.DocumentSet) Async(org.springframework.scheduling.annotation.Async) Subscribe(com.google.common.eventbus.Subscribe)

Example 20 with DocumentSet

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

the class AbstractPublishedDocumentsSetResource method deleteDocuments.

protected Mica.DocumentSetDto deleteDocuments(String id, String body) {
    DocumentSet set = getSecuredDocumentSet(id);
    if (Strings.isNullOrEmpty(body))
        return dtos.asDto(set);
    getDocumentSetService().removeIdentifiers(id, getDocumentSetService().extractIdentifiers(body));
    return dtos.asDto(getDocumentSetService().get(id));
}
Also used : DocumentSet(org.obiba.mica.core.domain.DocumentSet)

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