@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); } }
public QueryResult<Family> create(String studyStr, Family family, QueryOptions options, String sessionId) throws CatalogException { String userId = catalogManager.getUserManager().getUserId(sessionId); Study study = catalogManager.getStudyManager().resolveId(studyStr, userId); authorizationManager.checkStudyPermission(study.getUid(), userId, StudyAclEntry.StudyPermissions.WRITE_FAMILIES); ParamUtils.checkObj(family, "family"); ParamUtils.checkAlias(family.getId(), "id"); family.setName(ParamUtils.defaultObject(family.getName(), family.getId())); family.setMembers(ParamUtils.defaultObject(family.getMembers(), Collections.emptyList())); family.setPhenotypes(ParamUtils.defaultObject(family.getPhenotypes(), Collections.emptyList())); family.setDisorders(ParamUtils.defaultObject(family.getDisorders(), Collections.emptyList())); family.setCreationDate(TimeUtils.getTime()); family.setDescription(ParamUtils.defaultString(family.getDescription(), "")); family.setStatus(new Family.FamilyStatus()); family.setAnnotationSets(ParamUtils.defaultObject(family.getAnnotationSets(), Collections.emptyList())); family.setRelease(catalogManager.getStudyManager().getCurrentRelease(study, userId)); family.setVersion(1); family.setAttributes(ParamUtils.defaultObject(family.getAttributes(), Collections.emptyMap())); List<VariableSet> variableSetList = validateNewAnnotationSetsAndExtractVariableSets(study.getUid(), family.getAnnotationSets()); autoCompleteFamilyMembers(family, study, sessionId); validateFamily(family); validateMultiples(family); validatePhenotypes(family); validateDisorders(family); createMissingMembers(family, study, sessionId); options = ParamUtils.defaultObject(options, QueryOptions::new); family.setUuid(UUIDUtils.generateOpenCGAUUID(UUIDUtils.Entity.FAMILY)); QueryResult<Family> queryResult = familyDBAdaptor.insert(study.getUid(), family, variableSetList, options); auditManager.recordCreation(AuditRecord.Resource.family, queryResult.first().getId(), userId, queryResult.first(), null, null); return queryResult; }