@Override public Document convertToStorageType(Project object) { Document document = super.convertToStorageType(object); document.put("uid", document.getInteger("uid").longValue()); return document; } }
@Override public Document convertToStorageType(Dataset object) { Document document = super.convertToStorageType(object); document.put("id", document.getInteger("id").longValue()); return document; }
@Override public Document convertToStorageType(VariableSet object) { Document document = super.convertToStorageType(object); document.put("id", document.getInteger("id").longValue()); return document; } }
@Override public Document convertToStorageType(Study object) { Document document = super.convertToStorageType(object); document.put("uid", document.getInteger("uid").longValue()); return document; } }
@Override public QueryResult updateProjectMetadata(ProjectMetadata projectMetadata, boolean updateCounters) { Document mongo = new GenericDocumentComplexConverter<>(ProjectMetadata.class).convertToStorageType(projectMetadata); // Update field by field, instead of replacing the whole object to preserve existing fields like "_lock" List<Bson> updates = new ArrayList<>(mongo.size()); mongo.forEach((s, o) -> { // Do not update counters if (updateCounters || !s.equals(COUNTERS_FIELD)) { updates.add(new Document("$set", new Document(s, o))); } }); return collection.update(QUERY, Updates.combine(updates), new QueryOptions(UPSERT, true)); }
public Document convertToStorageType(String studyId, VariantFileMetadata object) { Document document = super.convertToStorageType(object); document.append("_id", buildId(studyId, object.getId())); return document; }
@Override public Document convertToStorageType(Panel object) { Document document = super.convertToStorageType(object); document.put("uid", object.getUid()); document.put("studyUid", object.getStudyUid()); return document; }
public Document convertToStorageType(T object, List<VariableSet> variableSetList) { List<Document> documentList = new ArrayList<>(); Document privateVariableSetMap = new Document(); if (variableSetList != null && !variableSetList.isEmpty() && object.getAnnotationSets() != null && !object.getAnnotationSets().isEmpty()) { Map<String, VariableSet> variableSetMap = new HashMap<>(); for (VariableSet variableSet : variableSetList) { variableSetMap.put(variableSet.getId(), variableSet); } for (AnnotationSet annotationSet : object.getAnnotationSets()) { VariableSet variableSet = variableSetMap.get(annotationSet.getVariableSetId()); if (variableSet != null) { documentList.addAll(annotationConverter.annotationToDB(variableSet, annotationSet)); privateVariableSetMap.put(String.valueOf(variableSet.getUid()), variableSet.getId()); } } } object.setAnnotationSets(null); Document document = super.convertToStorageType(object); document.put(ANNOTATION_SETS, documentList); document.put(PRIVATE_VS_MAP, privateVariableSetMap); return document; }
@Override public Document convertToStorageType(ClinicalAnalysis clinicalAnalysis) { Document document = super.convertToStorageType(clinicalAnalysis); document.put("uid", clinicalAnalysis.getUid()); document.put("studyUid", clinicalAnalysis.getStudyUid()); document.put("interpretations", convertInterpretations(clinicalAnalysis.getInterpretations())); validateDocumentToUpdate(document); return document; }
@Override public Document convertToStorageType(Job object) { Document document = super.convertToStorageType(object); document.put("uid", object.getUid()); document.put("studyUid", object.getStudyUid()); document.put("outDir", convertFileToDocument(object.getOutDir())); document.put("input", convertFilesToDocument(object.getInput())); document.put("output", convertFilesToDocument(object.getOutput())); return document; }