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


Java Condition类代码示例

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


Condition类属于org.pentaho.di.core包,在下文中一共展示了Condition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: testSqlField13Alias_Function

import org.pentaho.di.core.Condition; //导入依赖的package包/类
public void testSqlField13Alias_Function() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest2RowMeta();
  
  String fieldClause= "IIF( Service.B>50, 'high', 'low' ) as nrSize";
  
  SQLField field = new SQLField("Service", fieldClause, rowMeta);
  assertEquals("IIF( Service.B>50, 'high', 'low' )", field.getName());
  assertEquals("nrSize", field.getAlias());
  assertNull("The service data type was discovered", field.getValueMeta());
  
  assertNotNull(field.getIif());
  Condition condition = field.getIif().getSqlCondition().getCondition();
  assertNotNull(condition);
  assertFalse(condition.isEmpty());
  assertTrue(condition.isAtomic());
  assertEquals("B", condition.getLeftValuename());
  assertEquals(">", condition.getFunctionDesc());
  assertEquals("50", condition.getRightExactString());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:20,代码来源:SQLFieldTest.java

示例3: test

import org.pentaho.di.core.Condition; //导入依赖的package包/类
@Test
public void test() throws Exception {

  check( "SEND_FALSE_STEP", new StringGetter() {
    public String get() {
      return meta.getFalseStepname();
    }
  } );

  check( "SEND_TRUE_STEP", new StringGetter() {
    public String get() {
      return meta.getTrueStepname();
    }
  } );

  check( "CONDITION", new StringGetter() {
    public String get() {
      return meta.getConditionXML();
    }
  }, new Condition().getXML() );
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:22,代码来源:FilterRowsMetaInjectionTest.java

示例4: testIifFunction01

import org.pentaho.di.core.Condition; //导入依赖的package包/类
public void testIifFunction01() throws Exception {
  
  RowMetaInterface serviceFields = generateTestRowMeta();
  
  String conditionClause = "B>5000";
  String trueValueString= "'Big'";
  String falseValueString= "'Small'";

  IifFunction function = new IifFunction("Service", conditionClause, trueValueString, falseValueString, serviceFields);
  assertNotNull(function.getSqlCondition());
  Condition condition = function.getSqlCondition().getCondition();
  assertNotNull(condition);
  assertTrue(condition.isAtomic());
  assertEquals("B", condition.getLeftValuename());
  assertEquals(">", condition.getFunctionDesc());
  assertEquals("5000", condition.getRightExactString());
  
  // test the value data type determination
  //
  assertNotNull(function.getTrueValue());
  assertEquals(ValueMetaInterface.TYPE_STRING, function.getTrueValue().getValueMeta().getType());
  assertEquals("Big", function.getTrueValue().getValueData());
  assertNotNull(function.getFalseValue());
  assertEquals(ValueMetaInterface.TYPE_STRING, function.getFalseValue().getValueMeta().getType());
  assertEquals("Small", function.getFalseValue().getValueData());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:27,代码来源:IifFunctionTest.java

示例5: createStepMeta1

import org.pentaho.di.core.Condition; //导入依赖的package包/类
protected StepMeta createStepMeta1( final TransMeta transMeta, final DatabaseMeta dbMeta, final Condition condition )
  throws Exception {
  TransStepAttributeTesterTransStep step1 = new TransStepAttributeTesterTransStep();
  step1.setDatabaseMeta( dbMeta );
  step1.setCondition( condition );
  StepMeta stepMeta1 = new StepMeta( EXP_TRANS_STEP_1_NAME, step1 );
  StepErrorMeta stepErrorMeta1 = new StepErrorMeta( transMeta, stepMeta1 );
  stepErrorMeta1.setEnabled( EXP_TRANS_STEP_ERROR_META_1_ENABLED );
  stepErrorMeta1.setNrErrorsValuename( EXP_TRANS_STEP_ERROR_META_1_NR_ERRORS_VALUE_NAME );
  stepErrorMeta1.setErrorDescriptionsValuename( EXP_TRANS_STEP_ERROR_META_1_DESC_VALUE_NAME );
  stepErrorMeta1.setErrorFieldsValuename( EXP_TRANS_STEP_ERROR_META_1_FIELDS_VALUE_NAME );
  stepErrorMeta1.setErrorCodesValuename( EXP_TRANS_STEP_ERROR_META_1_CODES_VALUE_NAME );
  stepErrorMeta1.setMaxErrors( EXP_TRANS_STEP_ERROR_META_1_MAX_ERRORS );
  stepErrorMeta1.setMaxPercentErrors( EXP_TRANS_STEP_ERROR_META_1_MAX_PERCENT_ERRORS );
  stepErrorMeta1.setMinPercentRows( EXP_TRANS_STEP_ERROR_META_1_MIN_PERCENT_ROWS );
  stepMeta1.setStepErrorMeta( stepErrorMeta1 );
  return stepMeta1;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:19,代码来源:RepositoryTestBase.java

示例6: convertAtomicConditionToSql

import org.pentaho.di.core.Condition; //导入依赖的package包/类
private String convertAtomicConditionToSql(Condition atomicCondition) throws KettleValueException {
  StringBuilder sql = new StringBuilder();
  
  String fieldName = atomicCondition.getLeftValuename();
  FieldVariableMapping mapping = FieldVariableMapping.findFieldVariableMappingByFieldName(service.getFieldVariableMappings(), atomicCondition.getLeftValuename());
  if (mapping!=null) {
    fieldName=mapping.getTargetName();
  }
  sql.append(fieldName).append(" ");
  
  switch(atomicCondition.getFunction()) {
  case Condition.FUNC_EQUAL: sql.append("="); break;
  case Condition.FUNC_NOT_EQUAL: sql.append("<>"); break;
  case Condition.FUNC_LARGER: sql.append(">"); break;
  case Condition.FUNC_LARGER_EQUAL: sql.append(">="); break;
  case Condition.FUNC_SMALLER: sql.append("<"); break;
  case Condition.FUNC_SMALLER_EQUAL: sql.append("<="); break;
  case Condition.FUNC_NULL: sql.append("IS NULL"); break;
  case Condition.FUNC_NOT_NULL: sql.append("IS NOT NULL"); break;
  case Condition.FUNC_CONTAINS: sql.append("LIKE"); break;
  }
  sql.append(" ");
  sql.append(getAtomicConditionRightSql(atomicCondition));
  
  return sql.toString();
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:27,代码来源:SqlTransExecutor.java

示例7: 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

示例8: getOrphanFields

import org.pentaho.di.core.Condition; //导入依赖的package包/类
/**
 * Get non-existing referenced input fields
 * @param condition
 * @param prev
 * @return
 */
public List<String> getOrphanFields( Condition condition, RowMetaInterface prev ) {
  List<String> orphans = new ArrayList<String>(  );
  if ( condition == null || prev == null ) {
    return orphans;
  }
  String[] key = condition.getUsedFields();
  for ( int i = 0; i < key.length; i++ ) {
    if ( Utils.isEmpty( key[i] ) ) {
      continue;
    }
    ValueMetaInterface v = prev.searchValueMeta( key[i] );
    if ( v == null ) {
      orphans.add( key[i] );
    }
  }
  return orphans;
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:24,代码来源:FilterRowsMeta.java

示例9: testCondition03

import org.pentaho.di.core.Condition; //导入依赖的package包/类
public void testCondition03() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "B < 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());
  assertTrue(condition.isAtomic());
  assertEquals("B", condition.getLeftValuename());
  assertEquals("<", condition.getFunctionDesc());
  assertEquals("123", condition.getRightExactString());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:21,代码来源:SQLConditionTest.java

示例10: testCondition04

import org.pentaho.di.core.Condition; //导入依赖的package包/类
public void testCondition04() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "B >= 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());
  assertTrue(condition.isAtomic());
  assertEquals("B", condition.getLeftValuename());
  assertEquals(">=", condition.getFunctionDesc());
  assertEquals("123", condition.getRightExactString());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:21,代码来源:SQLConditionTest.java

示例11: testCondition06

import org.pentaho.di.core.Condition; //导入依赖的package包/类
public void testCondition06() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "B <= 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());
  assertTrue(condition.isAtomic());
  assertEquals("B", condition.getLeftValuename());
  assertEquals("<=", condition.getFunctionDesc());
  assertEquals("123", condition.getRightExactString());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:21,代码来源:SQLConditionTest.java

示例12: testCondition07

import org.pentaho.di.core.Condition; //导入依赖的package包/类
public void testCondition07() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "B >= 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());
  assertTrue(condition.isAtomic());
  assertEquals("B", condition.getLeftValuename());
  assertEquals(">=", condition.getFunctionDesc());
  assertEquals("123", condition.getRightExactString());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:21,代码来源:SQLConditionTest.java

示例13: testSqlField12_Function

import org.pentaho.di.core.Condition; //导入依赖的package包/类
public void testSqlField12_Function() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest2RowMeta();
  
  String fieldClause= "IIF( B>5000, 'Big', 'Small' ) as \"Sales size\"";
  
  SQLField field = new SQLField("Service", fieldClause, rowMeta);
  assertEquals("IIF( B>5000, 'Big', 'Small' )", field.getName());
  assertEquals("Sales size", field.getAlias());
  assertNull("The service data type was discovered", field.getValueMeta());
  
  assertNotNull(field.getIif());
  Condition condition = field.getIif().getSqlCondition().getCondition();
  assertNotNull(condition);
  assertFalse(condition.isEmpty());
  assertTrue(condition.isAtomic());
  assertEquals("B", condition.getLeftValuename());
  assertEquals(">", condition.getFunctionDesc());
  assertEquals("5000", condition.getRightExactString());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:20,代码来源:SQLFieldTest.java

示例14: testCondition13

import org.pentaho.di.core.Condition; //导入依赖的package包/类
public void testCondition13() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "A LIKE '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());
  assertTrue(condition.isAtomic());
  assertEquals("A", condition.getLeftValuename());
  assertEquals("LIKE", condition.getFunctionDesc());
  assertEquals("foo%", condition.getRightExactString());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:21,代码来源:SQLConditionTest.java

示例15: testCondition14

import org.pentaho.di.core.Condition; //导入依赖的package包/类
public void testCondition14() throws KettleSQLException {
  RowMetaInterface rowMeta = SQLTest.generateTest4RowMeta();
  
  String fieldsClause= "A, B";
  String conditionClause = "A LIKE 'foo??bar'";
  
  // 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());
  assertTrue(condition.isAtomic());
  assertEquals("A", condition.getLeftValuename());
  assertEquals("LIKE", condition.getFunctionDesc());
  assertEquals("foo??bar", condition.getRightExactString());
}
 
开发者ID:jjeb,项目名称:kettle-trunk,代码行数:21,代码来源:SQLConditionTest.java


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