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