public List<QueryResult<FamilyAclEntry>> getAcls(String studyStr, List<String> familyList, String member, boolean silent, String sessionId) throws CatalogException { List<QueryResult<FamilyAclEntry>> familyAclList = new ArrayList<>(familyList.size()); for (String family : familyList) { try { MyResource<Family> resource = getUid(family, studyStr, sessionId); QueryResult<FamilyAclEntry> allFamilyAcls; if (StringUtils.isNotEmpty(member)) { allFamilyAcls = authorizationManager.getFamilyAcl(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser(), member); } else { allFamilyAcls = authorizationManager.getAllFamilyAcls(resource.getStudy().getUid(), resource.getResource().getUid(), resource.getUser()); } allFamilyAcls.setId(family); familyAclList.add(allFamilyAcls); } catch (CatalogException e) { if (silent) { familyAclList.add(new QueryResult<>(family, 0, 0, 0, "", e.toString(), new ArrayList<>(0))); } else { throw e; } } } return familyAclList; }
private void validateFamilyAndProband(ClinicalAnalysis clinicalAnalysis, Study study, String sessionId) throws CatalogException { if (clinicalAnalysis.getFamily() != null && StringUtils.isNotEmpty(clinicalAnalysis.getFamily().getId())) { MyResource<Family> familyResource = catalogManager.getFamilyManager().getUid(clinicalAnalysis.getFamily().getId(), study.getFqn(), sessionId); clinicalAnalysis.setFamily(familyResource.getResource()); // Check the proband is an actual member of the family Query query = new Query() .append(FamilyDBAdaptor.QueryParams.UID.key(), familyResource.getResource().getUid()) .append(FamilyDBAdaptor.QueryParams.MEMBER_UID.key(), clinicalAnalysis.getProband().getUid()); QueryResult<Family> count = catalogManager.getFamilyManager().count(study.getFqn(), query, sessionId); if (count.getNumTotalResults() == 0) { throw new CatalogException("The member " + clinicalAnalysis.getProband().getId() + " does not belong to the family " + clinicalAnalysis.getFamily().getId()); } } }
options = ParamUtils.defaultObject(options, QueryOptions::new); MyResource resource = getUid(entryStr, studyStr, sessionId); long familyId = resource.getResource().getUid();
@Test public void updateSubjectsAndFamilyTest() throws CatalogException { createDummyEnvironment(false); ObjectMap params = new ObjectMap() .append(ClinicalAnalysisDBAdaptor.QueryParams.PROBAND.key(), new Individual().setId("child1").setSamples(Arrays.asList(new Sample().setId("sample2")))) .append(ClinicalAnalysisDBAdaptor.QueryParams.FAMILY.key(), new Family().setId("family")); QueryResult<ClinicalAnalysis> updateResult = catalogManager.getClinicalAnalysisManager().update(STUDY, "analysis", params, QueryOptions.empty(), sessionIdUser); assertEquals(1, updateResult.getNumResults()); assertEquals(0, updateResult.first().getInterpretations().size()); assertEquals(catalogManager.getFamilyManager().getUid("family", STUDY, sessionIdUser).getResource().getUid(), updateResult.first().getFamily().getUid()); assertEquals(catalogManager.getIndividualManager().getUid("child1", STUDY, sessionIdUser).getResource().getUid(), updateResult.first().getProband().getUid()); assertEquals(1, updateResult.first().getProband().getSamples().size()); assertEquals(catalogManager.getSampleManager().getUid("sample2", STUDY, sessionIdUser).getResource().getUid(), updateResult.first().getProband().getSamples().get(0).getUid()); }
private void fixQueryObject(Query query, Study study, String sessionId) throws CatalogException { if (query.containsKey(ClinicalAnalysisDBAdaptor.QueryParams.FAMILY.key())) { MyResource<Family> familyResource = catalogManager.getFamilyManager() .getUid(query.getString(ClinicalAnalysisDBAdaptor.QueryParams.FAMILY.key()), study.getFqn(), sessionId); query.put(ClinicalAnalysisDBAdaptor.QueryParams.FAMILY_UID.key(), familyResource.getResource().getUid()); query.remove(ClinicalAnalysisDBAdaptor.QueryParams.FAMILY.key());