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; }
@Override public Document convertToStorageType(Family object, List<VariableSet> variableSetList) { Document document = super.convertToStorageType(object, variableSetList); document.remove(FamilyDBAdaptor.QueryParams.ANNOTATION_SETS.key()); document.put("uid", object.getUid()); document.put("studyUid", object.getStudyUid()); validateDocumentToUpdate(document); return document; }
FamilySolrModel familySolrModel = new FamilySolrModel(); familySolrModel.setUid(family.getUid()); familySolrModel.setStudyId(study.getFqn().replace(":", "__"));
authorizationManager.checkFamilyPermission(study.getUid(), family.getUid(), userId, FamilyAclEntry.FamilyPermissions.DELETE); .append(FamilyDBAdaptor.QueryParams.UID.key(), family.getUid()) .append(FamilyDBAdaptor.QueryParams.STUDY_UID.key(), study.getUid()) .append(Constants.ALL_VERSIONS, true); if (update.first() > 0) { numModified += 1; auditManager.recordDeletion(AuditRecord.Resource.family, family.getUid(), userId, null, updateParams, null, null); } else { failedList.add(new WriteResult.Fail(family.getId(), "Unknown reason"));
@Test public void FamilyToSolrTest() { Study study = new Study().setFqn("user@project:study").setAttributes(new HashMap<>()); Family family = new Family("id", "family", null, null, Arrays.asList(new Individual().setId("I1"), new Individual().setId("I2")), "test", 1000, AnnotationHelper.createAnnotation(), null); family.setUid(100).setStatus(new Family.FamilyStatus("READY")).setRelease(1).setVersion(2); FamilySolrModel familySolrModel = new CatalogFamilyToSolrFamilyConverter(study).convertToStorageType(family); assertEquals(familySolrModel.getUid(), family.getUid()); assertEquals(familySolrModel.getStatus(), family.getStatus().getName()); assertEquals(familySolrModel.getNumMembers(), family.getMembers().size()); assertEquals(familySolrModel.getRelease(), family.getRelease()); assertEquals(familySolrModel.getVersion(), family.getVersion()); assertEquals(familySolrModel.getPhenotypes().size(), 0); assertEquals(familySolrModel.getAnnotations().get("annotations__o__annotName.vsId.a.ab2.ab2c1.ab2c1d1"), Arrays.asList(1, 2, 3, 4, 11, 12, 13, 14, 21)); assertEquals(familySolrModel.getAnnotations().get("annotations__o__annotName.vsId.a.ab1.ab1c1"), Arrays.asList(true, false, false)); assertEquals(familySolrModel.getAnnotations().get("annotations__s__annotName.vsId.a.ab1.ab1c2"), "hello world"); assertEquals(familySolrModel.getAnnotations().get("annotations__o__annotName.vsId.a.ab2.ab2c1.ab2c1d2"), Arrays.asList("hello ab2c1d2 1", "hello ab2c1d2 2")); assertEquals(familySolrModel.getAnnotations().get("annotations__o__annotName.vsId.a.ab3.ab3c1.ab3c1d1"), Arrays.asList(Arrays.asList("hello"), Arrays.asList("hello2", "bye2"), Arrays.asList("byeee2", "hellooo2"))); assertEquals(familySolrModel.getAnnotations().get("annotations__o__annotName.vsId.a.ab3.ab3c1.ab3c1d2"), Arrays.asList(2.0, 4.0, 24.0)); assertNull(familySolrModel.getAnnotations().get("nothing")); assertEquals(familySolrModel.getAnnotations().keySet().size(), 6); } }
.append(FamilyDBAdaptor.QueryParams.UID.key(), family.getUid()) .append(FamilyDBAdaptor.QueryParams.STUDY_UID.key(), study.getUid()) .append(Constants.ALL_VERSIONS, true);
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()); } } }
@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()); }
long studyId = getStudyId(familyQueryResult.first().getUid());
String msg = "Can't delete VariableSetId, still in use as \"variableSetId\" of families : ["; for (Family family : families.getResult()) { msg += " { id: " + family.getUid() + ", name: \"" + family.getName() + "\" },";
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());