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