private List<Document> getNewAnnotationList(List<AnnotationSet> annotationSetList, List<VariableSet> variableSetList) { List<Document> annotationList = new ArrayList<>(); Map<String, VariableSet> variableSetMap = new HashMap<>(); for (VariableSet variableSet : variableSetList) { variableSetMap.put(variableSet.getId(), variableSet); } // Convert the annotations to the list of documents for (AnnotationSet annotationSet : annotationSetList) { VariableSet variableSet = variableSetMap.get(annotationSet.getVariableSetId()); annotationList.addAll(annotationConverter.annotationToDB(variableSet, annotationSet)); } return annotationList; }
private Map<String, String> getPrivateVariableMapToSet(List<AnnotationSet> annotationSetList, List<VariableSet> variableSetList) { Map<String, VariableSet> variableSetMap = new HashMap<>(); for (VariableSet variableSet : variableSetList) { variableSetMap.put(variableSet.getId(), variableSet); } Map<String, String> privateVariableMap = new HashMap<>(); for (AnnotationSet annotationSet : annotationSetList) { VariableSet variableSet = variableSetMap.get(annotationSet.getVariableSetId()); privateVariableMap.put(String.valueOf(variableSet.getUid()), variableSet.getId()); } return privateVariableMap; }
public static Map<String, Object> populateAnnotations(Map<String, Map<String, QueryParam.Type>> variableTypeMap, List<AnnotationSet> annotationSets) { Map<String, Object> result = new HashedMap(); if (annotationSets != null) { for (AnnotationSet annotationSet : annotationSets) { for (String annotationKey : annotationSet.getAnnotations().keySet()) { Object value = annotationSet.getAnnotations().get(annotationKey); result.put("annotations" + type(variableTypeMap.get(annotationSet.getVariableSetId()).get(annotationKey)) + annotationSet.getVariableSetId() + "." + annotationKey, value); } } } return result; }
if (!variableSetMap.containsKey(annotationSet.getVariableSetId())) { throw new CatalogException("VariableSetId " + annotationSet.getVariableSetId() + " not found in study " + studyId); VariableSet variableSet = variableSetMap.get(annotationSet.getVariableSetId());
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; }
if (!variableSet.getId().equals(annotationSet.getVariableSetId())) { throw new CatalogException("VariableSet does not match with the AnnotationSet"); if (set.getVariableSetId().equals(annotationSet.getVariableSetId())) { throw new CatalogException("Repeated annotation for a unique VariableSet");
VariableSet variableSet = variableSetMap.get(annotationSet.getVariableSetId()); if (variableSet.isUnique()) { query = new Document() .append(AnnotationSetParams.ANNOTATION_SETS_VARIABLE_SET_ID.key(), annotationSet.getVariableSetId()) .append(PRIVATE_UID, entryId); if (isVersioned) {
} else if (variableSetMap.containsKey(annotationSet.getVariableSetId())) { if (variableSetMap.get(annotationSet.getVariableSetId()).isConfidential()) { if (!confidentialPermissionsChecked) { authorizationManager.checkStudyPermission(resource.getStudy().getUid(), resource.getUser(), AnnotationUtils.checkAnnotationSet(variableSetMap.get(annotationSet.getVariableSetId()), annotationSet, annotationSetList, true); applyAnnotationChanges(storedAnnotationSet, annotationSet, variableSetMap.get(storedAnnotationSet.getVariableSetId()), action); AnnotationUtils.checkAnnotationSet(variableSetMap.get(storedAnnotationSet.getVariableSetId()), storedAnnotationSet, null, false);
.append(AnnotationSetParams.ANNOTATION_SETS_VARIABLE_SET_ID.key(), annotationSet.getVariableSetId()) .append("_id", id)); if (count.first() > 0) {
assertEquals(1, annotationSets.size()); assertEquals("annotName", annotationSets.get(0).getId()); assertEquals(vs.getId(), annotationSets.get(0).getVariableSetId());
@Test public void testLoadPedigreeCatalog() throws Exception { QueryResult<Sample> sampleQueryResult = loader.loadSampleAnnotations(pedFile, null, sessionId); String variableSetId = sampleQueryResult.getResult().get(0).getAnnotationSets().get(0).getVariableSetId(); Query query = new Query(Constants.ANNOTATION, Constants.VARIABLE_SET + "=" + variableSetId + ";family=GB84"); QueryOptions options = new QueryOptions("limit", 2); QueryResult<Sample> allSamples = catalogManager.getSampleManager().get(studyId, query, options, sessionId); Assert.assertNotEquals(0, allSamples.getNumResults()); query = new Query(Constants.ANNOTATION, Constants.VARIABLE_SET + "=" + variableSetId + ";sex=2;Population=ITU"); QueryResult<Sample> femaleIta = catalogManager.getSampleManager().get(studyId, query, options, sessionId); Assert.assertNotEquals(0, femaleIta.getNumResults()); query = new Query(Constants.ANNOTATION, Constants.VARIABLE_SET + "=" + variableSetId + ";sex=1;Population=ITU"); QueryResult<Sample> maleIta = catalogManager.getSampleManager().get(studyId, query, options, sessionId); Assert.assertNotEquals(0, maleIta.getNumResults()); query = new Query(Constants.ANNOTATION, Constants.VARIABLE_SET + "=" + variableSetId + ";Population=ITU"); QueryResult<Sample> ita = catalogManager.getSampleManager().get(studyId, query, options, sessionId); Assert.assertNotEquals(0, ita.getNumResults()); Assert.assertEquals("Fail sample query", ita.getNumTotalResults(), maleIta.getNumTotalResults() + femaleIta.getNumTotalResults()); }