当前位置: 首页>>代码示例>>Java>>正文


Java Condition.getCondition方法代码示例

本文整理汇总了Java中org.pentaho.di.core.Condition.getCondition方法的典型用法代码示例。如果您正苦于以下问题:Java Condition.getCondition方法的具体用法?Java Condition.getCondition怎么用?Java Condition.getCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pentaho.di.core.Condition的用法示例。


在下文中一共展示了Condition.getCondition方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: saveCondition

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
public ObjectId saveCondition(Condition condition, ObjectId id_condition_parent) throws KettleException
{
	try
	{
		condition.setObjectId( insertCondition( id_condition_parent, condition ) );
		for (int i=0;i<condition.nrConditions();i++)
		{
			Condition subc = condition.getCondition(i);
			repository.saveCondition(subc, condition.getObjectId());
		}
		
		return condition.getObjectId();
	}
	catch(KettleException dbe)
	{
		throw new KettleException("Error saving condition to the repository.", dbe);
	}
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:19,代码来源:KettleDatabaseRepositoryConditionDelegate.java

示例2: convertConditionToSql

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
protected String convertConditionToSql(Condition condition) throws KettleValueException {
  if (condition.isAtomic()) {
    return convertAtomicConditionToSql(condition);
  }
  StringBuilder sql = new StringBuilder();
  if (condition.isNegated()) {
    sql.append("NOT(");
  }
  for (int i=0;i<condition.nrConditions();i++) {
    Condition c = condition.getCondition(i);
    if (i>0) {
      sql.append(" ").append(c.getOperatorDesc());
    }
    sql.append("(");
    sql.append(convertConditionToSql(c));
    sql.append(")");
  }
  
  if (condition.isNegated()) {
    sql.append(")");
  }
  return sql.toString();
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:24,代码来源:SqlTransExecutor.java

示例3: convertConditionToJson

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
protected String convertConditionToJson(Condition condition) throws KettleValueException {
  if (condition.isAtomic()) {
    return convertAtomicConditionToJson(condition);
  }
  StringBuilder sql = new StringBuilder();
  if (condition.isNegated()) {
    throw new KettleValueException("Negated conditions can't be converted to JSON");
  }

  for (int i=0;i<condition.nrConditions();i++) {
    Condition c = condition.getCondition(i);
    if (i>0) {
      sql.append(", ");
    }
    sql.append(convertConditionToJson(c));
  }
  
  return sql.toString();
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:20,代码来源:SqlTransExecutor.java

示例4: testCondition15

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
public void testCondition15() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "A='Foo' AND B>5";
  
  // Correctness of the next statement is tested in SQLFieldsTest
  //
  SQLFields fields = new SQLFields("Service", rowMeta, fieldsClause);

  SQLCondition sqlCondition = new SQLCondition("Service", conditionClause, rowMeta, fields);
  Condition condition = sqlCondition.getCondition();
  
  assertNotNull(condition);
  assertFalse(condition.isEmpty());
  assertFalse("Non-atomic condition expected", condition.isAtomic());
  assertEquals(2, condition.nrConditions());
  
  Condition one = condition.getCondition(0);
  assertEquals("A", one.getLeftValuename());
  assertEquals("=", one.getFunctionDesc());
  assertEquals("Foo", one.getRightExactString());

  Condition two = condition.getCondition(1);
  assertEquals("B", two.getLeftValuename());
  assertEquals(">", two.getFunctionDesc());
  assertEquals("5", two.getRightExactString());

  assertEquals(Condition.OPERATOR_AND, two.getOperator());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:31,代码来源:SQLConditionTest.java

示例5: testCondition16

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
public void testCondition16() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "( A='Foo' ) AND ( B>5 )";
  
  // Correctness of the next statement is tested in SQLFieldsTest
  //
  SQLFields fields = new SQLFields("Service", rowMeta, fieldsClause);

  SQLCondition sqlCondition = new SQLCondition("Service", conditionClause, rowMeta, fields);
  Condition condition = sqlCondition.getCondition();
  
  assertNotNull(condition);
  assertFalse(condition.isEmpty());
  assertFalse("Non-atomic condition expected", condition.isAtomic());
  assertEquals(2, condition.nrConditions());
  
  Condition one = condition.getCondition(0);
  assertEquals("A", one.getLeftValuename());
  assertEquals("=", one.getFunctionDesc());
  assertEquals("Foo", one.getRightExactString());

  Condition two = condition.getCondition(1);
  assertEquals("B", two.getLeftValuename());
  assertEquals(">", two.getFunctionDesc());
  assertEquals("5", two.getRightExactString());

  assertEquals(Condition.OPERATOR_AND, two.getOperator());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:31,代码来源:SQLConditionTest.java

示例6: testCondition21

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
public void testCondition21() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "A='Foo' AND NOT ( B>5 )";
  
  // Correctness of the next statement is tested in SQLFieldsTest
  //
  SQLFields fields = new SQLFields("Service", rowMeta, fieldsClause);

  SQLCondition sqlCondition = new SQLCondition("Service", conditionClause, rowMeta, fields);
  Condition condition = sqlCondition.getCondition();
  
  assertNotNull(condition);
  assertFalse(condition.isEmpty());
  assertFalse("Non-atomic condition expected", condition.isAtomic());
  assertEquals(2, condition.nrConditions());
  
  Condition one = condition.getCondition(0);
  assertEquals("A", one.getLeftValuename());
  assertEquals("=", one.getFunctionDesc());
  assertEquals("Foo", one.getRightExactString());

  Condition two = condition.getCondition(1);
  assertTrue(two.isNegated());
  assertEquals("B", two.getLeftValuename());
  assertEquals(">", two.getFunctionDesc());
  assertEquals("5", two.getRightExactString());

  assertEquals(Condition.OPERATOR_AND, two.getOperator());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:32,代码来源:SQLConditionTest.java

示例7: testCondition23

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
public void testCondition23() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "( A LIKE '(AND' ) AND ( B>5 )";
  
  // Correctness of the next statement is tested in SQLFieldsTest
  //
  SQLFields fields = new SQLFields("Service", rowMeta, fieldsClause);

  SQLCondition sqlCondition = new SQLCondition("Service", conditionClause, rowMeta, fields);
  Condition condition = sqlCondition.getCondition();
  
  assertNotNull(condition);
  assertFalse(condition.isEmpty());
  assertFalse("Non-atomic condition expected", condition.isAtomic());
  assertEquals(2, condition.nrConditions());
  
  Condition one = condition.getCondition(0);
  assertEquals("A", one.getLeftValuename());
  assertEquals("LIKE", one.getFunctionDesc());
  assertEquals("(AND", one.getRightExactString());

  Condition two = condition.getCondition(1);
  assertEquals("B", two.getLeftValuename());
  assertEquals(">", two.getFunctionDesc());
  assertEquals("5", two.getRightExactString());

  assertEquals(Condition.OPERATOR_AND, two.getOperator());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:31,代码来源:SQLConditionTest.java

示例8: testCondition26

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
public void testCondition26() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "A='Foo' AND B>5 OR PARAMETER('par')='foo'";
  
  // Correctness of the next statement is tested in SQLFieldsTest
  //
  SQLFields fields = new SQLFields("Service", rowMeta, fieldsClause);

  SQLCondition sqlCondition = new SQLCondition("Service", conditionClause, rowMeta, fields);
  Condition condition = sqlCondition.getCondition();
  
  assertNotNull(condition);
  assertFalse(condition.isEmpty());
  assertFalse("Non-atomic condition expected", condition.isAtomic());
  assertEquals(2, condition.nrConditions());
  
  Condition one = condition.getCondition(0);
  assertEquals(2, one.nrConditions());
  
  Condition leftAnd = one.getCondition(0);
  assertEquals("A", leftAnd.getLeftValuename());
  assertEquals("=", leftAnd.getFunctionDesc());
  assertEquals("Foo", leftAnd.getRightExactString());
  Condition rightAnd = one.getCondition(1);
  assertEquals("B", rightAnd.getLeftValuename());
  assertEquals(">", rightAnd.getFunctionDesc());
  assertEquals("5", rightAnd.getRightExactString());
  assertEquals(Condition.OPERATOR_AND, rightAnd.getOperator());

  Condition param = condition.getCondition(1);
  assertTrue(param.isAtomic());
  assertEquals(Condition.OPERATOR_OR, param.getOperator());
  assertEquals(Condition.FUNC_TRUE, param.getFunction());
  assertEquals("par", param.getLeftValuename());
  assertEquals("foo", param.getRightExactString());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:39,代码来源:SQLConditionTest.java

示例9: saveCondition

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
public ObjectId saveCondition( Condition condition, ObjectId id_condition_parent ) throws KettleException {
  try {
    condition.setObjectId( insertCondition( id_condition_parent, condition ) );
    for ( int i = 0; i < condition.nrConditions(); i++ ) {
      Condition subc = condition.getCondition( i );
      repository.saveCondition( subc, condition.getObjectId() );
    }

    return condition.getObjectId();
  } catch ( KettleException dbe ) {
    throw new KettleException( "Error saving condition to the repository.", dbe );
  }
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:14,代码来源:KettleDatabaseRepositoryConditionDelegate.java

示例10: testCondition17

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
public void testCondition17() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B, C, D";
  String conditionClause = "A='Foo' AND B>5 AND C='foo' AND D=123";
  
  // Correctness of the next statement is tested in SQLFieldsTest
  //
  SQLFields fields = new SQLFields("Service", rowMeta, fieldsClause);

  SQLCondition sqlCondition = new SQLCondition("Service", conditionClause, rowMeta, fields);
  Condition condition = sqlCondition.getCondition();
  
  assertNotNull(condition);
  assertFalse(condition.isEmpty());
  assertFalse("Non-atomic condition expected", condition.isAtomic());
  assertEquals(4, condition.nrConditions());
  
  Condition one = condition.getCondition(0);
  assertEquals("A", one.getLeftValuename());
  assertEquals("=", one.getFunctionDesc());
  assertEquals("Foo", one.getRightExactString());

  Condition two = condition.getCondition(1);
  assertEquals("B", two.getLeftValuename());
  assertEquals(">", two.getFunctionDesc());
  assertEquals("5", two.getRightExactString());
  assertEquals(Condition.OPERATOR_AND, two.getOperator());

  Condition three = condition.getCondition(2);
  assertEquals("C", three.getLeftValuename());
  assertEquals("=", three.getFunctionDesc());
  assertEquals("foo", three.getRightExactString());
  assertEquals(Condition.OPERATOR_AND, three.getOperator());

  Condition four = condition.getCondition(3);
  assertEquals("D", four.getLeftValuename());
  assertEquals("=", four.getFunctionDesc());
  assertEquals("123", four.getRightExactString());
  assertEquals(Condition.OPERATOR_AND, four.getOperator());

}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:43,代码来源:SQLConditionTest.java

示例11: testCondition18

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
/**
 * Test precedence.
 * 
 * @throws KettleSQLException
 */
public void testCondition18() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B, C, D";
  String conditionClause = "A='Foo' OR B>5 AND C='foo' OR D=123";
  
  // Correctness of the next statement is tested in SQLFieldsTest
  //
  SQLFields fields = new SQLFields("Service", rowMeta, fieldsClause);

  SQLCondition sqlCondition = new SQLCondition("Service", conditionClause, rowMeta, fields);
  Condition condition = sqlCondition.getCondition();
  
  assertNotNull(condition);
  assertFalse(condition.isEmpty());
  assertFalse("Non-atomic condition expected", condition.isAtomic());
  assertEquals(3, condition.nrConditions());
  
  Condition leftOr = condition.getCondition(0);
  
  assertTrue(leftOr.isAtomic());
  assertEquals("A", leftOr.getLeftValuename());
  assertEquals("=", leftOr.getFunctionDesc());
  assertEquals("Foo", leftOr.getRightExactString());

  Condition middleOr = condition.getCondition(1);
  assertEquals(2, middleOr.nrConditions());
  
  Condition leftAnd = middleOr.getCondition(0);
  assertTrue(leftAnd.isAtomic());
  assertEquals("B", leftAnd.getLeftValuename());
  assertEquals(">", leftAnd.getFunctionDesc());
  assertEquals("5", leftAnd.getRightExactString());
  assertEquals(Condition.OPERATOR_NONE, leftAnd.getOperator());

  Condition rightAnd = middleOr.getCondition(1);
  assertEquals(Condition.OPERATOR_AND, rightAnd.getOperator());
  assertEquals("C", rightAnd.getLeftValuename());
  assertEquals("=", rightAnd.getFunctionDesc());
  assertEquals("foo", rightAnd.getRightExactString());

  Condition rightOr = condition.getCondition(2);
  assertTrue(rightOr.isAtomic());
  assertEquals("D", rightOr.getLeftValuename());
  assertEquals("=", rightOr.getFunctionDesc());
  assertEquals("123", rightOr.getRightExactString());
  assertEquals(Condition.OPERATOR_OR, rightOr.getOperator());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:54,代码来源:SQLConditionTest.java

示例12: testCondition19

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
public void testCondition19() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "A LIKE '%AL%' AND ( B LIKE '15%' OR C IS NULL )";
  
  // Correctness of the next statement is tested in SQLFieldsTest
  //
  SQLFields fields = new SQLFields("Service", rowMeta, fieldsClause);

  SQLCondition sqlCondition = new SQLCondition("Service", conditionClause, rowMeta, fields);
  Condition condition = sqlCondition.getCondition();
  
  assertNotNull(condition);
  assertFalse(condition.isEmpty());
  assertFalse("Non-atomic condition expected", condition.isAtomic());
  assertEquals(2, condition.nrConditions());
  
  Condition leftAnd = condition.getCondition(0);
  
  assertTrue(leftAnd.isAtomic());
  assertEquals("A", leftAnd.getLeftValuename());
  assertEquals("LIKE", leftAnd.getFunctionDesc());
  assertEquals("%AL%", leftAnd.getRightExactString());

  Condition rightBracket = condition.getCondition(1);
  assertEquals(1, rightBracket.nrConditions());
  Condition rightAnd = rightBracket.getCondition(0);
  assertEquals(2, rightAnd.nrConditions());
  
  Condition leftOr = rightAnd.getCondition(0);
  assertTrue(leftOr.isAtomic());
  assertEquals("B", leftOr.getLeftValuename());
  assertEquals("LIKE", leftOr.getFunctionDesc());
  assertEquals("15%", leftOr.getRightExactString());
  assertEquals(Condition.OPERATOR_NONE, leftOr.getOperator());

  Condition rightOr = rightAnd.getCondition(1);
  assertEquals(Condition.OPERATOR_OR, rightOr.getOperator());
  assertEquals("C", rightOr.getLeftValuename());
  assertEquals("IS NULL", rightOr.getFunctionDesc());
  assertNull(rightOr.getRightExactString());

}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:45,代码来源:SQLConditionTest.java

示例13: testCondition22

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
public void testCondition22() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B, C";
  String conditionClause = "A='Foo' AND NOT ( B>5 OR C='AAA' ) ";
  
  // Correctness of the next statement is tested in SQLFieldsTest
  //
  SQLFields fields = new SQLFields("Service", rowMeta, fieldsClause);

  SQLCondition sqlCondition = new SQLCondition("Service", conditionClause, rowMeta, fields);
  Condition condition = sqlCondition.getCondition();
  
  assertNotNull(condition);
  assertFalse(condition.isEmpty());
  assertFalse("Non-atomic condition expected", condition.isAtomic());
  assertEquals(2, condition.nrConditions());
  
  Condition leftAnd = condition.getCondition(0);
  assertEquals("A", leftAnd.getLeftValuename());
  assertEquals("=", leftAnd.getFunctionDesc());
  assertEquals("Foo", leftAnd.getRightExactString());

  Condition rightAnd = condition.getCondition(1);
  assertEquals(1, rightAnd.nrConditions());
  
  Condition notBlock = rightAnd.getCondition(0);
  assertTrue(notBlock.isNegated());
  assertEquals(2, notBlock.nrConditions());
  
  Condition leftOr = notBlock.getCondition(0);
  assertTrue(leftOr.isAtomic());
  assertEquals("B", leftOr.getLeftValuename());
  assertEquals(">", leftOr.getFunctionDesc());
  assertEquals("5", leftOr.getRightExactString());
  assertEquals(Condition.OPERATOR_NONE, leftOr.getOperator());

  Condition rightOr = notBlock.getCondition(1);
  assertEquals(Condition.OPERATOR_OR, rightOr.getOperator());
  assertEquals("C", rightOr.getLeftValuename());
  assertEquals("=", rightOr.getFunctionDesc());
  assertEquals("AAA", rightOr.getRightExactString());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:44,代码来源:SQLConditionTest.java

示例14: testCondition24

import org.pentaho.di.core.Condition; //导入方法依赖的package包/类
public void testCondition24() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "( A LIKE '(AND' ) AND ( ( B>5 ) OR ( B=3 ) )";
  
  // Correctness of the next statement is tested in SQLFieldsTest
  //
  SQLFields fields = new SQLFields("Service", rowMeta, fieldsClause);

  SQLCondition sqlCondition = new SQLCondition("Service", conditionClause, rowMeta, fields);
  Condition condition = sqlCondition.getCondition();
  
  assertNotNull(condition);
  assertFalse(condition.isEmpty());
  assertFalse("Non-atomic condition expected", condition.isAtomic());
  assertEquals(2, condition.nrConditions());
  
  Condition one = condition.getCondition(0);
  assertEquals("A", one.getLeftValuename());
  assertEquals("LIKE", one.getFunctionDesc());
  assertEquals("(AND", one.getRightExactString());

  Condition two = condition.getCondition(1);
  assertEquals(1, two.nrConditions());

  Condition brackets = condition.getCondition(1);
  assertEquals(1, brackets.nrConditions());

  Condition right = brackets.getCondition(0);
  assertEquals(2, right.nrConditions());

  Condition leftOr = right.getCondition(0);
  assertTrue(leftOr.isAtomic());
  assertEquals("B", leftOr.getLeftValuename());
  assertEquals(">", leftOr.getFunctionDesc());
  assertEquals("5", leftOr.getRightExactString());
  assertEquals(Condition.OPERATOR_NONE, leftOr.getOperator());

  Condition rightOr = right.getCondition(1);
  assertEquals(Condition.OPERATOR_OR, rightOr.getOperator());
  assertEquals("B", rightOr.getLeftValuename());
  assertEquals("=", rightOr.getFunctionDesc());
  assertEquals("3", rightOr.getRightExactString());

}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:47,代码来源:SQLConditionTest.java


注:本文中的org.pentaho.di.core.Condition.getCondition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。