Search in sources :

Example 16 with Network

use of org.obiba.mica.network.domain.Network in project mica2 by obiba.

the class Mica2Upgrade method migrateNetworks.

private void migrateNetworks() {
    List<Network> networksWithoutModel = networkRepository.findWithoutModel();
    if (!networksWithoutModel.isEmpty()) {
        logger.info("Migrating networks from 1.x to 2.x: START");
        for (Network networkWithoutModel : networksWithoutModel) {
            networkWithoutModel.getModel();
            networkRepository.save(networkWithoutModel);
        }
        logger.info("Migrating networks: END");
    }
}
Also used : Network(org.obiba.mica.network.domain.Network)

Example 17 with Network

use of org.obiba.mica.network.domain.Network in project mica2 by obiba.

the class NetworkService method delete.

/**
 * Delete a {@link Network}.
 *
 * @param id
 * @throws NoSuchNetworkException
 */
public void delete(@NotNull String id) throws NoSuchNetworkException {
    Network network = findById(id);
    checkConstraints(network);
    networkRepository.deleteWithReferences(network);
    if (network.getLogo() != null)
        fileStoreService.delete(network.getLogo().getId());
    fileSystemService.delete(FileUtils.getEntityPath(network));
    networkStateRepository.delete(id);
    gitService.deleteGitRepository(network);
    eventBus.post(new NetworkDeletedEvent(network));
}
Also used : Network(org.obiba.mica.network.domain.Network) NetworkDeletedEvent(org.obiba.mica.network.event.NetworkDeletedEvent)

Example 18 with Network

use of org.obiba.mica.network.domain.Network in project mica2 by obiba.

the class StudyPackageImportServiceImpl method importZip.

@Override
public void importZip(InputStream inputStream, boolean publish) throws IOException {
    final StudyPackage studyPackage = new StudyPackage(inputStream);
    if (studyPackage.study != null) {
        Map<String, ByteSource> dict = studyPackage.attachments.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
        Optional.ofNullable(studyPackage.study.getLogo()).ifPresent(a -> saveAttachmentTempFile(dict, a));
        Set<String> attachmentIds = Sets.newHashSet();
        studyPackage.studyAttachments.forEach(a -> {
            if (attachmentIds.contains(a.getId())) {
                String origId = a.getId();
                a.setId(new ObjectId().toString());
                saveAttachmentTempFile(dict, a, origId);
            } else {
                saveAttachmentTempFile(dict, a);
                attachmentIds.add(a.getId());
            }
        });
        importStudy(studyPackage.study, studyPackage.studyAttachments, publish);
        for (Network net : studyPackage.networks) {
            importNetwork(net, publish, studyPackage);
        }
        studyPackage.datasets.forEach(ds -> importDataset(ds, publish));
    }
}
Also used : ObjectId(org.bson.types.ObjectId) Network(org.obiba.mica.network.domain.Network) ByteSource(com.google.common.io.ByteSource) LocalizedString(org.obiba.mica.core.domain.LocalizedString) Map(java.util.Map)

Example 19 with Network

use of org.obiba.mica.network.domain.Network in project mica2 by obiba.

the class VariableQuery method processHits.

@Override
protected void processHits(MicaSearch.QueryResultDto.Builder builder, Searcher.DocumentResults results, QueryScope scope, CountStatsData counts) throws IOException {
    MicaSearch.DatasetVariableResultDto.Builder resBuilder = MicaSearch.DatasetVariableResultDto.newBuilder();
    Map<String, BaseStudy> studyMap = Maps.newHashMap();
    Map<String, Network> networkMap = Maps.newHashMap();
    for (Searcher.DocumentResult result : results.getDocuments()) {
        if (result.hasSource()) {
            DatasetVariable.IdResolver resolver = DatasetVariable.IdResolver.from(result.getId());
            DatasetVariable variable = objectMapper.readValue(result.getSourceInputStream(), DatasetVariable.class);
            resBuilder.addSummaries(processHit(resolver, variable, studyMap, networkMap));
        }
    }
    builder.setExtension(MicaSearch.DatasetVariableResultDto.result, resBuilder.build());
}
Also used : DatasetVariable(org.obiba.mica.dataset.domain.DatasetVariable) Network(org.obiba.mica.network.domain.Network) BaseStudy(org.obiba.mica.study.domain.BaseStudy)

Aggregations

Network (org.obiba.mica.network.domain.Network)19 NetworkState (org.obiba.mica.network.domain.NetworkState)6 Map (java.util.Map)5 Inject (javax.inject.Inject)5 Logger (org.slf4j.Logger)5 LoggerFactory (org.slf4j.LoggerFactory)5 Maps (com.google.common.collect.Maps)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 Strings (com.google.common.base.Strings)3 Sets (com.google.common.collect.Sets)3 Set (java.util.Set)3 NotNull (javax.validation.constraints.NotNull)3 NoSuchEntityException (org.obiba.mica.NoSuchEntityException)3 LocalizedString (org.obiba.mica.core.domain.LocalizedString)3 Attachment (org.obiba.mica.file.Attachment)3 NetworkService (org.obiba.mica.network.service.NetworkService)3 SubjectAclService (org.obiba.mica.security.service.SubjectAclService)3 BaseStudy (org.obiba.mica.study.domain.BaseStudy)3 Component (org.springframework.stereotype.Component)3