本文整理汇总了Java中com.healthmarketscience.sqlbuilder.ComboCondition类的典型用法代码示例。如果您正苦于以下问题:Java ComboCondition类的具体用法?Java ComboCondition怎么用?Java ComboCondition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ComboCondition类属于com.healthmarketscience.sqlbuilder包,在下文中一共展示了ComboCondition类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNoConditionsAddedIfNotPartitioning
import com.healthmarketscience.sqlbuilder.ComboCondition; //导入依赖的package包/类
@Test
public void testNoConditionsAddedIfNotPartitioning() throws Exception {
PowerMockito.mockStatic(DriverManager.class);
SelectQuery selectQuery = PowerMockito.mock(SelectQuery.class);
ComboCondition comboCondition = PowerMockito.mock(ComboCondition.class);
when(selectQuery.getWhereClause()).thenReturn(comboCondition);
when(comboCondition.addCondition(any(Condition.class))).thenReturn(comboCondition);
when(config.getDriverClass()).thenReturn(JDBC_CELL_EXTRACTOR_CLASSNAME_CONSTANT);
when(config.getConnectionUrl()).thenReturn(WHATEVER_CONSTANT);
when(config.getUsername()).thenReturn(WHATEVER_CONSTANT);
when(config.getPassword()).thenReturn(WHATEVER_CONSTANT);
when(config.getQuery()).thenReturn(selectQuery);
when(DriverManager.getConnection(anyString(), anyString(), anyString())).thenReturn(conn);
when(conn.createStatement()).thenReturn(statement);
when(statement.executeQuery(anyString())).thenReturn(resultSet);
when(resultSet.next()).thenReturn(true);
JdbcReader reader = new JdbcReader(config);
reader.init(partition);
verify(comboCondition, times(0)).addCondition(any((BinaryCondition.class)));
}
示例2: buildCondition
import com.healthmarketscience.sqlbuilder.ComboCondition; //导入依赖的package包/类
/**
* Build the standard pharmacogenomic condition to be used when retrieving
* variants for any patient's analysis.
* @return the ComboCondition to be used for all analyses
* @deprecated This method creates a mega condition that retrieves all PGx
* variants from the DB. However, as the PGx DB grows, this condition
* will become unreasonably large, and is limited by the
* 'max_allowed_packet' property in MySQL. Replaced by {@link #buildConditionList()}
*/
@Deprecated
private static ComboCondition buildCondition() {
ComboCondition query= new ComboCondition(ComboCondition.Op.OR);
/* Get all relevant genes. */
List<String> genes= new LinkedList<String>();
try {
genes= PGXDBFunctions.getGenes();
} catch (SQLException se) {
se.printStackTrace();
}
/* Get all relevant markers. */
List<String> markers= new LinkedList<String>();
try {
for (String g : genes) {
markers.addAll(PGXDBFunctions.getMarkers(g));
}
} catch (Exception pe) {
pe.printStackTrace();
}
/* Add all markers to the ComboCondition.
* NOTE: this is hardcoded for now, but will need to be changed if the
* dbSNP annotation DB is updated. */
for (String m : markers) {
query.addCondition(
BinaryCondition.equalTo(ts.getDBColumn(columns.get(DBSNP_COLUMN)), m));
}
return query;
}
示例3: buildConditionList
import com.healthmarketscience.sqlbuilder.ComboCondition; //导入依赖的package包/类
/**
* Build the standard pharmacogenomic conditions to be used when retrieving
* variants for any patient's analysis and store these in a list.
* @return a Map of Conditions to be used for all PGx analyses
* @throws SQLException
*/
private static Map<String, Condition> buildConditionList() throws SQLException {
Map<String, Condition> queryMap= new HashMap<String, Condition>();
/* Get all relevant markers for a particular gene and create a
* ComboCondition for that set. Then add it to the List. */
for (String g : PGXDBFunctions.getGenes()) {
// generate a new query for this gene
ComboCondition query= new ComboCondition(ComboCondition.Op.OR);
try {
/* Add all the marker positions for this gene.
* NOTE: You can also search for variants using the dbSNP rsID,
* however, then you rely on the DB to be up-to-date and annotated
* correctly, which is not always the case. It's better to query
* variants by chromosomal coordinates. Original code is commented
* out below. */
for (PGXMarker pgxm : PGXDBFunctions.getMarkerInfo(g)) {
ComboCondition variantCondition= new ComboCondition(ComboCondition.Op.AND);
variantCondition.addCondition(
BinaryCondition.equalTo(ts.getDBColumn(BasicVariantColumns.CHROM), pgxm.chromosome));
variantCondition.addCondition(
BinaryCondition.equalTo(ts.getDBColumn(BasicVariantColumns.START_POSITION), Integer.parseInt(pgxm.position)));
query.addCondition(variantCondition);
}
} catch (Exception e) {
e.printStackTrace();
}
// add this gene-query pair to the list
queryMap.put(g, query);
}
return queryMap;
}
示例4: buildNovelConditionList
import com.healthmarketscience.sqlbuilder.ComboCondition; //导入依赖的package包/类
/**
* Build the standard pharmacogenomic conditions for NOVEL variants.
* @return a List of Conditions to be used for all PGx analyses of novel variants
* @throws SQLException
*/
private static List<Condition> buildNovelConditionList() throws SQLException, RemoteException, SessionExpiredException {
List<Condition> output= new LinkedList<Condition>();
/* Get all genic non-synonymous variants. */
ComboCondition mutationCondition= new ComboCondition(ComboCondition.Op.OR);
for (String mutationEffect : NOVEL_MUTATIONS) {
mutationCondition.addCondition(
BinaryCondition.iLike(ts.getDBColumn(BasicVariantColumns.JANNOVAR_EFFECT), mutationEffect + "%"));
}
output.add(mutationCondition);
/* For each of the allele frequency columns, check if the allele
* frequency is below threshold. If allele frequency at the position
* is null, also report it. */
ComboCondition afCondition= new ComboCondition(ComboCondition.Op.OR);
AnnotationManagerAdapter am= MedSavantClient.AnnotationManagerAdapter;
Map<String, Set<CustomField>> fieldMap=
am.getAnnotationFieldsByTag(LoginController.getInstance().getSessionID(), true);
Set<CustomField> columnNames= fieldMap.get(CustomField.ALLELE_FREQUENCY_TAG);
for (CustomField cf : columnNames) {
DbColumn afColumn= ts.getDBColumn(cf.getColumnName());
// include variant if AF is below threshold
afCondition.addCondition(
BinaryCondition.lessThan(afColumn, AF_THRESHOLD, true));
// include variant even if AF information is missing
afCondition.addCondition(UnaryCondition.isNull(afColumn));
}
output.add(afCondition);
return output;
}
示例5: queryVariants
import com.healthmarketscience.sqlbuilder.ComboCondition; //导入依赖的package包/类
/**
* Get all pharmacogenomic variants for this individual.
*/
private void queryVariants() throws SQLException, RemoteException, SessionExpiredException {
/* Iterate through all gene conditions. */
List<String> allGeneKeys= new ArrayList<String>(standardPGXConditions.keySet());
// Sort the list of genes by gene symbol for convenience later
Collections.sort(allGeneKeys);
for (String geneKey : allGeneKeys) {
/* The variants for this gene. */
PGXGene pgxVariants= new PGXGene(geneKey);
/* Take the standard combocondition and AND it to the DNA ID for this
* individual before submitting for variants. */
ComboCondition query= new ComboCondition(ComboCondition.Op.AND);
query.addCondition(
BinaryCondition.equalTo(ts.getDBColumn(BasicVariantColumns.DNA_ID), dnaID));
query.addCondition(standardPGXConditions.get(geneKey));
/* Once query is built, run it on the remote server. */
List<Variant> retrievedVariants= runRemoteQuery(query);
/* Add variants to the list for this PGx gene. */
for (Variant var : retrievedVariants) {
pgxVariants.addVariant(var);
}
/* Add the current gene-variant object to the list. */
pgxGenes.add(pgxVariants);
/* If analysis has been cancelled, stop querying. */
if (isCancelled) {
return;
}
}
}
示例6: applyFilters
import com.healthmarketscience.sqlbuilder.ComboCondition; //导入依赖的package包/类
private void applyFilters(SelectQuery query) {
if(this.filters != null && this.filters.length > 0) {
ComboCondition comboCondition = new ComboCondition(ComboCondition.Op.AND);
if (filters.length > 0) {
for(int i=0; i<filters.length; i++) {
Filter filter = filters[i];
FilterType filterType = filter.getFilterType();
DbColumn filterColumn = new DbColumn(dbTable, filter.getField(), "",null,null);
if(filterType.equals(FilterType.EQ)) {
comboCondition.addCondition(BinaryCondition.equalTo(filterColumn, filter.getValue()));
} else if(filterType.equals(FilterType.GT)) {
comboCondition.addCondition(BinaryCondition.greaterThan(filterColumn, filter.getValue(), false));
} else if(filterType.equals(FilterType.LT)) {
comboCondition.addCondition(BinaryCondition.lessThan(filterColumn, filter.getValue(), false));
} else if(filterType.equals(FilterType.GTE)) {
comboCondition.addCondition(BinaryCondition.greaterThan(filterColumn, filter.getValue(), true));
} else if(filterType.equals(FilterType.LTE)) {
comboCondition.addCondition(BinaryCondition.lessThan(filterColumn, filter.getValue(), true));
} else if(filterType.equals(FilterType.NEQ)) {
comboCondition.addCondition(BinaryCondition.notEqualTo(filterColumn, filter.getValue()));
} else if(filterType.equals(FilterType.IN)) {
ComboCondition comboConditionOR = new ComboCondition(ComboCondition.Op.OR);
String[] condicion =filter.getValue().toString().split(",");
for (int z=0; z < condicion.length ; z++) {
comboConditionOR.addCondition(BinaryCondition.equalTo(filterColumn, condicion[z]));
}
comboCondition.addCondition(comboConditionOR);
}
else {
throw new UnsupportedOperationException("Currently, the filter operation " + filterType + " is not supported");
}
}
}
query.addCondition(comboCondition);
}
}
示例7: testConditionIsAddedForPartitioning
import com.healthmarketscience.sqlbuilder.ComboCondition; //导入依赖的package包/类
@Test
public void testConditionIsAddedForPartitioning() throws Exception {
PowerMockito.mockStatic(DriverManager.class);
SelectQuery selectQuery = PowerMockito.mock(SelectQuery.class);
ComboCondition comboCondition = PowerMockito.mock(ComboCondition.class);
when(selectQuery.getWhereClause()).thenReturn(comboCondition);
when(comboCondition.addCondition(any(Condition.class))).thenReturn(comboCondition);
when(config.getDriverClass()).thenReturn(JDBC_CELL_EXTRACTOR_CLASSNAME_CONSTANT);
when(config.getConnectionUrl()).thenReturn(WHATEVER_CONSTANT);
when(config.getUsername()).thenReturn(WHATEVER_CONSTANT);
when(config.getPassword()).thenReturn(WHATEVER_CONSTANT);
when(config.getPartitionKey()).thenReturn(PowerMockito.mock(DbColumn.class));
when(config.getNumPartitions()).thenReturn(NUM_PARTITIONS);
when(config.getQuery()).thenReturn(selectQuery);
when(DriverManager.getConnection(anyString(), anyString(), anyString())).thenReturn(conn);
when(partition.lower()).thenReturn(0L);
when(partition.upper()).thenReturn(100L);
when(conn.createStatement()).thenReturn(statement);
when(statement.executeQuery(anyString())).thenReturn(resultSet);
when(resultSet.next()).thenReturn(true);
JdbcReader reader = new JdbcReader(config);
reader.init(partition);
verify(comboCondition, times(2)).addCondition(any((BinaryCondition.class)));
}
示例8: condition
import com.healthmarketscience.sqlbuilder.ComboCondition; //导入依赖的package包/类
public Condition condition() {
if((values==null || values.size()==0) && from_value==null && to_value==null){
if(except==null)
return null;
else
return new NotCondition(except.condition());
}
DimensionTable dim_table = join.getDimensionTable();
SelectQuery dim_query = new SelectQuery().
addFromTable(dim_table.getDbTable()).
addColumns(dim_table.getDbKey());
if(from_value!=null){
dim_query = dim_query.addCondition(BinaryCondition.greaterThan(column.getDbColumn(), from_value, true));
}
if(to_value!=null){
dim_query = dim_query.addCondition(BinaryCondition.lessThan(column.getDbColumn(), to_value, true));
}
if(values!=null && values.size()>0){
if(values.size()==1){
String value = values.iterator().next();
if(LevelMember.NULL_MEMBER.equals(value))
dim_query = dim_query.addCondition(UnaryCondition.isNull(column.getDbColumn()));
else
dim_query = dim_query.addCondition(BinaryCondition.equalTo(column.getDbColumn(), value));
}else{
if(values.contains(LevelMember.NULL_MEMBER)){
Set<String> values_without_null = new HashSet<String>(values);
values_without_null.remove(LevelMember.NULL_MEMBER);
dim_query = dim_query.addCondition(ComboCondition.or(
UnaryCondition.isNull(column.getDbColumn()),
new InCondition(column.getDbColumn(), values_without_null)));
}else{
dim_query = dim_query.addCondition(new InCondition(column.getDbColumn(), values));
}
}
}
Condition myCondition = new InCondition(join.getForeign_key(), new Subquery(dim_query) );
if(except!=null)
myCondition = ComboCondition.and(myCondition, new NotCondition(except.condition()) );
if(exists!=null)
myCondition = ComboCondition.and(myCondition, exists.condition());
return myCondition;
}
示例9: havingCondition
import com.healthmarketscience.sqlbuilder.ComboCondition; //导入依赖的package包/类
public Condition havingCondition(){
if(having_expression==null){
if(except == null || except.having_expression==null)
return null;
else
return new NotCondition(except.havingCondition());
}
Condition myCondition = new CustomCondition(having_expression);
if(except!=null && except.having_expression!=null)
myCondition = ComboCondition.and(myCondition, new NotCondition(except.havingCondition()) );
if(exists!=null && exists.having_expression!=null)
myCondition = ComboCondition.and(myCondition, exists.havingCondition() );
return myCondition;
}
示例10: getNovelVariants
import com.healthmarketscience.sqlbuilder.ComboCondition; //导入依赖的package包/类
/**
* Get all novel and rare pharmacogenomic variants for this individual.
* @precondition pgxGenes must already have been initialized by running queryVariants()
*/
private void getNovelVariants() throws SQLException, RemoteException, SessionExpiredException, PGXException {
/* If analysis has been cancelled, stop. */
if (isCancelled) {
return;
}
/* Iterate through all previously stored PGXGene objects and get all
* low allele frequency variants for these genes. */
for (PGXGene pg : pgxGenes) {
String geneSymbol= pg.getGene();
List<PGXMarker> existingMarkers= PGXDBFunctions.getMarkerInfo(geneSymbol);
ComboCondition query= new ComboCondition(ComboCondition.Op.AND);
/* Get variants for this patient/DNA ID and this PGx gene. */
query.addCondition(
BinaryCondition.equalTo(ts.getDBColumn(BasicVariantColumns.DNA_ID), dnaID));
query.addCondition(
BinaryCondition.iLike(ts.getDBColumn(BasicVariantColumns.JANNOVAR_SYMBOL), geneSymbol + "%"));
/* Ensure that the patient actually has this variant, and is not
* homozygous for the reference. This is important if reference
* positions are reported, which happens in a pgx analysis. In
* general, VCF files do not report homozygous ref positions. */
query.addCondition(
BinaryCondition.notiLike(ts.getDBColumn(BasicVariantColumns.GT), "0%0"));
/* Add all default novel Conditions to this query. */
for (Condition c : novelPGXConditions) {
query.addCondition(c);
}
/* Once query is built, run it on the remote server. */
List<Variant> potentialNovelVariants= runRemoteQuery(query);
/* Check if returned variants are NOT PGx markers and then add to
* the novel variants. */
for (Variant var : potentialNovelVariants) {
if (!isKnownPGXMarker(var.getChromosome(), Long.toString(var.getStart()))) {
pg.addNovelVariant(var);
}
}
}
}