@Test public void testGetCriterionTypeFromQuery() { Query query = new Query(); CompoundCriterion compoundCriterion1 = new CompoundCriterion(); CompoundCriterion compoundCriterion2 = new CompoundCriterion(); compoundCriterion1.getCriterionCollection().add(new GeneNameCriterion()); compoundCriterion1.getCriterionCollection().add(compoundCriterion2); compoundCriterion2.getCriterionCollection().add(new SubjectListCriterion()); compoundCriterion2.getCriterionCollection().add(new SubjectListCriterion()); query.setCompoundCriterion(compoundCriterion1); assertEquals(1, QueryUtil.getCriterionTypeFromQuery(query, GeneNameCriterion.class).size()); assertEquals(2, QueryUtil.getCriterionTypeFromQuery(query, SubjectListCriterion.class).size()); assertEquals( 0, QueryUtil.getCriterionTypeFromQuery(query, StringComparisonCriterion.class).size()); }
CriteriaGroup(QueryForm form) { if (form.getQuery() == null || form.getQuery().getCompoundCriterion() == null) { throw new IllegalArgumentException("Argument queryForm requires an initialized query."); } this.form = form; this.compoundCriterion = form.getQuery().getCompoundCriterion(); initializeCriteria( form.getQuery().getSubscription().getStudy(), compoundCriterion.getCriterionCollection()); }
@Test public void testIsCompoundCriterionGenomic() { CompoundCriterion compoundCriterion1 = new CompoundCriterion(); compoundCriterion1.setCriterionCollection(new HashSet<AbstractCriterion>()); CompoundCriterion compoundCriterion2 = new CompoundCriterion(); compoundCriterion2.setCriterionCollection(new HashSet<AbstractCriterion>()); compoundCriterion2.getCriterionCollection().add(new StringComparisonCriterion()); compoundCriterion2.getCriterionCollection().add(new StringComparisonCriterion()); compoundCriterion1.getCriterionCollection().add(compoundCriterion2); assertFalse(QueryUtil.isCompoundCriterionGeneExpression(compoundCriterion1)); assertFalse(QueryUtil.isCompoundCriterionCopyNumber(compoundCriterion1)); GeneNameCriterion geneNameCriterion = new GeneNameCriterion(); compoundCriterion1.getCriterionCollection().add(geneNameCriterion); geneNameCriterion.setGenomicCriterionType(GenomicCriterionTypeEnum.GENE_EXPRESSION); assertTrue(QueryUtil.isCompoundCriterionGeneExpression(compoundCriterion1)); assertFalse(QueryUtil.isCompoundCriterionCopyNumber(compoundCriterion1)); geneNameCriterion.setGenomicCriterionType(GenomicCriterionTypeEnum.COPY_NUMBER); assertFalse(QueryUtil.isCompoundCriterionGeneExpression(compoundCriterion1)); assertTrue(QueryUtil.isCompoundCriterionCopyNumber(compoundCriterion1)); compoundCriterion1.setCriterionCollection(new HashSet<AbstractCriterion>()); compoundCriterion1.getCriterionCollection().add(compoundCriterion2); compoundCriterion1.getCriterionCollection().add(new StringComparisonCriterion()); assertFalse(QueryUtil.isCompoundCriterionGeneExpression(compoundCriterion1)); assertFalse(QueryUtil.isCompoundCriterionCopyNumber(compoundCriterion1)); compoundCriterion2.getCriterionCollection().add(new FoldChangeCriterion()); assertTrue(QueryUtil.isCompoundCriterionGeneExpression(compoundCriterion1)); assertFalse(QueryUtil.isCompoundCriterionCopyNumber(compoundCriterion1)); compoundCriterion1 = new CompoundCriterion(); compoundCriterion1.setCriterionCollection(new HashSet<AbstractCriterion>()); compoundCriterion2 = new CompoundCriterion(); compoundCriterion2.setCriterionCollection(new HashSet<AbstractCriterion>()); compoundCriterion1.getCriterionCollection().add(compoundCriterion2); compoundCriterion1.getCriterionCollection().add(new StringComparisonCriterion()); assertFalse(QueryUtil.isCompoundCriterionGeneExpression(compoundCriterion1)); assertFalse(QueryUtil.isCompoundCriterionCopyNumber(compoundCriterion1)); compoundCriterion2.getCriterionCollection().add(new CopyNumberAlterationCriterion()); assertFalse(QueryUtil.isCompoundCriterionGeneExpression(compoundCriterion1)); assertTrue(QueryUtil.isCompoundCriterionCopyNumber(compoundCriterion1)); compoundCriterion1 = new CompoundCriterion(); compoundCriterion2 = new CompoundCriterion(); CompoundCriterion compoundCriterion3 = new CompoundCriterion(); compoundCriterion1.getCriterionCollection().add(compoundCriterion2); compoundCriterion1.getCriterionCollection().add(compoundCriterion3); compoundCriterion2.getCriterionCollection().add(new StringComparisonCriterion()); compoundCriterion3.getCriterionCollection().add(geneNameCriterion); geneNameCriterion.setGenomicCriterionType(GenomicCriterionTypeEnum.GENE_EXPRESSION); assertTrue(QueryUtil.isCompoundCriterionGeneExpression(compoundCriterion1)); compoundCriterion1 = new CompoundCriterion(); compoundCriterion1.setCriterionCollection(new HashSet<AbstractCriterion>()); compoundCriterion1.getCriterionCollection().add(new ExpressionLevelCriterion()); assertTrue(QueryUtil.isCompoundCriterionGeneExpression(compoundCriterion1)); }
/** @param booleanOperator the booleanOperator to set */ public void setBooleanOperator(BooleanOperatorEnum booleanOperator) { compoundCriterion.setBooleanOperator(booleanOperator); }
/** @return the booleanOperator */ public BooleanOperatorEnum getBooleanOperator() { return compoundCriterion.getBooleanOperator(); }