org.talend.daikon.properties.property.Property.getPossibleValues()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(16.2k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中org.talend.daikon.properties.property.Property.getPossibleValues()方法的一些代码示例,展示了Property.getPossibleValues()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Property.getPossibleValues()方法的具体详情如下:
包路径:org.talend.daikon.properties.property.Property
类名称:Property
方法名:getPossibleValues

Property.getPossibleValues介绍

[英]Return a list of possible values for this property. If the property is a simple type or an enum this will return a list of element with the same type as the Property. But for convenience if this Property is a collection type such as Map this is used to simply return a list of T and not a List>. This will not be enforced at all, just a convention.
[中]返回此属性可能值的列表。如果属性是简单类型或枚举,则将返回与属性类型相同的元素列表。但是为了方便起见,如果这个属性是一个集合类型,比如Map,那么它只用于返回一个T列表,而不是一个列表>。这根本不会被执行,只是一个惯例。

代码示例

代码示例来源:origin: org.talend.daikon/daikon

protected boolean isAPossibleValue(Object possibleValue) {
  if (getPossibleValues() != null) {
    return getPossibleValues().contains(possibleValue);
  } // no possible values so this should not be called, return false.
  return false;
}

代码示例来源:origin: org.talend.daikon/daikon

private void addEnumsToProperty(ArrayNode enumList, ArrayNode enumNames, Property property) {
  List possibleValues = property.getPossibleValues();
  for (Object possibleValue : possibleValues) {
    String value = possibleValue.toString();
    if (NamedThing.class.isAssignableFrom(possibleValue.getClass())) {
      value = ((NamedThing) possibleValue).getName();
    }
    enumList.add(value);
    enumNames.add(property.getPossibleValuesDisplayName(possibleValue));
  }
}

代码示例来源:origin: Talend/components

private void updatePossibleValues(){
  this.column.setPossibleValues(columnPossibleValues);
  if(columnPossibleValues.isEmpty()){
    dbtype.setValue(null);
  }
  if(this.dbtype.getPossibleValues() == null || this.dbtype.getPossibleValues().isEmpty()){
    this.dbtype.setPossibleValues(dbTypePossibleValues);
  }
}

代码示例来源:origin: org.talend.daikon/daikon

private void resolveEnum(ObjectNode schema, Property property) {
  schema.put(JsonSchemaConstants.TAG_TYPE, JsonSchemaConstants.TYPE_STRING);
  ArrayNode enumNames = schema.putArray(JsonSchemaConstants.TAG_ENUM_NAMES);
  ArrayNode enumValues = schema.putArray(JsonSchemaConstants.TAG_ENUM);
  List possibleValues = property.getPossibleValues();
  for (Object possibleValue : possibleValues) {
    enumValues.add(possibleValue.toString());
    enumNames.add(property.getPossibleValuesDisplayName(possibleValue));
  }
}

代码示例来源:origin: org.talend.components/components-snowflake-definition

private void updatePossibleValues(){
  this.column.setPossibleValues(columnPossibleValues);
  if(columnPossibleValues.isEmpty()){
    dbtype.setValue(null);
  }
  if(this.dbtype.getPossibleValues() == null || this.dbtype.getPossibleValues().isEmpty()){
    this.dbtype.setPossibleValues(dbTypePossibleValues);
  }
}

代码示例来源:origin: Talend/components

public void afterDatastoreRef() {
  //the current method is called at some strange place, need to skip it if bucket list have been set
  if(!this.bucket.getPossibleValues().isEmpty()) {
    return;
  }
  S3DatasetDefinition definition = new S3DatasetDefinition();
  RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
  try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
    IS3DatasetRuntime runtime = (IS3DatasetRuntime) sandboxedInstance.getInstance();
    runtime.initialize(null, this);
    this.bucket.setPossibleValues(new ArrayList<String>(runtime.listBuckets()));
  } catch (Exception e) {
    //TalendRuntimeException.build(ComponentsErrorCode.IO_EXCEPTION, e).throwIt();
    //ignore the exception here, as the trigger method should not block to save the data set properties action. 
    //And as the current after data store trigger method is called at some strange place, the exception should not break something.
    LOGGER.warn(e.getClass() + " : " + e.getMessage());
  }
}

代码示例来源:origin: org.talend.components/simplefileio-definition

public void afterDatastoreRef() {
  //the current method is called at some strange place, need to skip it if bucket list have been set
  if(!this.bucket.getPossibleValues().isEmpty()) {
    return;
  }
  S3DatasetDefinition definition = new S3DatasetDefinition();
  RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
  try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
    IS3DatasetRuntime runtime = (IS3DatasetRuntime) sandboxedInstance.getInstance();
    runtime.initialize(null, this);
    this.bucket.setPossibleValues(new ArrayList<String>(runtime.listBuckets()));
  } catch (Exception e) {
    //TalendRuntimeException.build(ComponentsErrorCode.IO_EXCEPTION, e).throwIt();
    //ignore the exception here, as the trigger method should not block to save the data set properties action. 
    //And as the current after data store trigger method is called at some strange place, the exception should not break something.
    LOGGER.warn(e.getClass() + " : " + e.getMessage());
  }
}

代码示例来源:origin: org.talend.daikon/daikon

private ObjectNode processTProperty(Property property) {
  ObjectNode schema = JsonNodeFactory.instance.objectNode();
  schema.put(JsonSchemaConstants.TAG_TITLE, property.getDisplayName());
  if (!property.getPossibleValues().isEmpty()) {
    if (property instanceof EnumProperty) {
      resolveEnum(schema, property);
    } else if (property instanceof EnumListProperty) {
      resolveList(schema, property);
    } else {
      resolveDefault(schema, property);
    }
  } else if (isListClass(property.getType())) {
    resolveList(schema, property);
  } else {
    schema.put(JsonSchemaConstants.TAG_TYPE, JsonSchemaConstants.getTypeMapping().get(property.getType()));
    if (Date.class.getName().equals(property.getType())) {
      schema.put(JsonSchemaConstants.TAG_FORMAT, "date-time");// Do not support other format for date till
      // Property
      // support it
    }
  }
  return schema;
}

代码示例来源:origin: org.talend.daikon/daikon

Collection values = ((Property) n).getPossibleValues();
if (values != null) {
  sb.append(" Values: " + values);

代码示例来源:origin: org.talend.components/components-azurestorage

@Override
public ValidationResult validate(RuntimeContainer container) {
  ValidationResult validationResult = super.validate(container);
  if (validationResult.getStatus() == ValidationResult.Result.ERROR) {
    return validationResult;
  }
  this.tableOutputProperties = (TAzureStorageOutputTableProperties) properties;
  
  tableOutputProperties.updatePartitionKeyAndRowKey();
  
  if (!tableOutputProperties.partitionKey.getPossibleValues().contains(tableOutputProperties.partitionKey.getStringValue())
      || !tableOutputProperties.rowKey.getPossibleValues().contains(tableOutputProperties.rowKey.getStringValue())) {
    return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.invalidPartitionOrRowKey"));
  }
  if (tableOutputProperties.partitionKey.getStringValue().equals(tableOutputProperties.rowKey.getStringValue())) {
    return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.equalPartitionOrRowKey"));
  }
  return ValidationResult.OK;
}

代码示例来源:origin: Talend/components

@Override
public ValidationResult validate(RuntimeContainer container) {
  ValidationResult validationResult = super.validate(container);
  if (validationResult.getStatus() == ValidationResult.Result.ERROR) {
    return validationResult;
  }
  this.tableOutputProperties = (TAzureStorageOutputTableProperties) properties;
  
  tableOutputProperties.updatePartitionKeyAndRowKey();
  
  if (!tableOutputProperties.partitionKey.getPossibleValues().contains(tableOutputProperties.partitionKey.getStringValue())
      || !tableOutputProperties.rowKey.getPossibleValues().contains(tableOutputProperties.rowKey.getStringValue())) {
    return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.invalidPartitionOrRowKey"));
  }
  if (tableOutputProperties.partitionKey.getStringValue().equals(tableOutputProperties.rowKey.getStringValue())) {
    return new ValidationResult(ValidationResult.Result.ERROR, i18nMessages.getMessage("error.equalPartitionOrRowKey"));
  }
  return ValidationResult.OK;
}

代码示例来源:origin: org.talend.components/components-netsuite-definition

/**
   * Performs initialization of {@link #apiVersion} property for old components
   * that didn't have this property.
   */
  private void migrateApiVersion() {
    if (apiVersion.getValue() == null) {
      if (endpoint.getValue() != null) {
        String endpointUrl = endpoint.getStringValue();
        try {
          NetSuiteVersion nsVersion = NetSuiteVersion.detectVersion(endpointUrl);
          apiVersion.setValue(nsVersion.getMajorAsString("."));
        } catch (IllegalArgumentException e) {
          // API version couldn't be detected, use default version
          apiVersion.setValue(DEFAULT_API_VERSION.getMajorAsString("."));
        } catch (Exception e) {
          // do nothing
        }
      }
    }
    // Initialize possible values for apiVersion property.
    if (apiVersion.getPossibleValues().isEmpty()) {
      apiVersion.setPossibleValues(API_VERSIONS);
    }
  }
}

代码示例来源:origin: org.talend.components/components-salesforce

@Override
public ComponentProperties getOutputComponentProperties() {
  TSalesforceBulkExecProperties bulkExecProperties = new TSalesforceBulkExecProperties("bulkExecProperties");
  bulkExecProperties.init();
  bulkExecProperties.copyValuesFrom(this, true, true);
  // we need to pass also the possible values, only way from the studio to know it comes from a combo box (need to
  // add quotes for generation)
  bulkExecProperties.upsertRelationTable.columnName.setPossibleValues(upsertRelationTable.columnName.getPossibleValues());
  bulkExecProperties.connection.referencedComponent.componentInstanceId.setTaggedValue(UpsertRelationTable.ADD_QUOTES,
      true);
  bulkExecProperties.module.connection.referencedComponent.componentInstanceId
      .setTaggedValue(UpsertRelationTable.ADD_QUOTES, true);
  for (Form form : bulkExecProperties.getForms()) {
    bulkExecProperties.refreshLayout(form);
  }
  return bulkExecProperties;
}

代码示例来源:origin: Talend/components

/**
   * Performs initialization of {@link #apiVersion} property for old components
   * that didn't have this property.
   */
  private void migrateApiVersion() {
    if (apiVersion.getValue() == null) {
      if (endpoint.getValue() != null) {
        String endpointUrl = endpoint.getStringValue();
        try {
          NetSuiteVersion nsVersion = NetSuiteVersion.detectVersion(endpointUrl);
          apiVersion.setValue(nsVersion.getMajorAsString("."));
        } catch (IllegalArgumentException e) {
          // API version couldn't be detected, use default version
          apiVersion.setValue(DEFAULT_API_VERSION.getMajorAsString("."));
        } catch (Exception e) {
          // do nothing
        }
      }
    }
    // Initialize possible values for apiVersion property.
    if (apiVersion.getPossibleValues().isEmpty()) {
      apiVersion.setPossibleValues(API_VERSIONS);
    }
  }
}

代码示例来源:origin: Talend/components

@Test
public void testGetSchemaNames() throws Exception {
  JDBCDatastoreProperties properties = new JDBCDatastoreProperties("input");
  properties.init();
  List<?> dbTypes = properties.dbTypes.getPossibleValues();
  assertTrue("the list should not be empty", dbTypes != null && !dbTypes.isEmpty());
  assertTrue("The size of list is not right", dbTypes.size() == 3);
  assertTrue("The first element is not right", "MYSQL".equals(dbTypes.get(0)));
  assertTrue("The second element is not right", "DERBY".equals(dbTypes.get(1)));
  assertTrue("The default value is not right", "MYSQL".equals(properties.dbTypes.getValue()));
  AllSetting setting = properties.getRuntimeSetting();
  assertTrue("the driver class is not right : " + setting.getDriverClass(),
      "org.gjt.mm.mysql.Driver".equals(setting.getDriverClass()));
  assertTrue("the driver paths is not right : " + setting.getDriverPaths(), setting.getDriverPaths() != null
      && !setting.getDriverPaths().isEmpty()
      && "mvn:org.talend.libraries/mysql-connector-java-5.1.30-bin/6.0.0/jar".equals(setting.getDriverPaths().get(0)));
  properties.dbTypes.setValue("DERBY");
  properties.afterDbTypes();
  setting = properties.getRuntimeSetting();
  assertTrue("the driver class is not right : " + setting.getDriverClass(),
      "org.apache.derby.jdbc.ClientDriver".equals(setting.getDriverClass()));
  assertTrue("the driver paths is not right : " + setting.getDriverPaths(),
      setting.getDriverPaths() != null && !setting.getDriverPaths().isEmpty()
          && "mvn:org.apache.derby/derby/10.12.1.1".equals(setting.getDriverPaths().get(0)));
}

代码示例来源:origin: Talend/components

@Override
public ComponentProperties getOutputComponentProperties() {
  TSalesforceBulkExecProperties bulkExecProperties = new TSalesforceBulkExecProperties("bulkExecProperties");
  bulkExecProperties.init();
  bulkExecProperties.copyValuesFrom(this, true, true);
  // we need to pass also the possible values, only way from the studio to know it comes from a combo box (need to
  // add quotes for generation)
  bulkExecProperties.upsertRelationTable.columnName
      .setPossibleValues(upsertRelationTable.columnName.getPossibleValues());
  bulkExecProperties.connection.referencedComponent.componentInstanceId
      .setTaggedValue(UpsertRelationTable.ADD_QUOTES, true);
  bulkExecProperties.module.connection.referencedComponent.componentInstanceId
      .setTaggedValue(UpsertRelationTable.ADD_QUOTES, true);
  // Seems that properties copy can't copy the reference properties
  if (isUseExistConnection()) {
    bulkExecProperties.connection.referencedComponent
        .setReference(connection.getReferencedConnectionProperties());
  }
  for (Form form : bulkExecProperties.getForms()) {
    bulkExecProperties.refreshLayout(form);
  }
  return bulkExecProperties;
}

代码示例来源:origin: org.talend.components/components-salesforce-definition

@Override
public ComponentProperties getOutputComponentProperties() {
  TSalesforceBulkExecProperties bulkExecProperties = new TSalesforceBulkExecProperties("bulkExecProperties");
  bulkExecProperties.init();
  bulkExecProperties.copyValuesFrom(this, true, true);
  // we need to pass also the possible values, only way from the studio to know it comes from a combo box (need to
  // add quotes for generation)
  bulkExecProperties.upsertRelationTable.columnName
      .setPossibleValues(upsertRelationTable.columnName.getPossibleValues());
  bulkExecProperties.connection.referencedComponent.componentInstanceId
      .setTaggedValue(UpsertRelationTable.ADD_QUOTES, true);
  bulkExecProperties.module.connection.referencedComponent.componentInstanceId
      .setTaggedValue(UpsertRelationTable.ADD_QUOTES, true);
  // Seems that properties copy can't copy the reference properties
  if (isUseExistConnection()) {
    bulkExecProperties.connection.referencedComponent
        .setReference(connection.getReferencedConnectionProperties());
  }
  for (Form form : bulkExecProperties.getForms()) {
    bulkExecProperties.refreshLayout(form);
  }
  return bulkExecProperties;
}

代码示例来源:origin: Talend/components

@Test
public void testProperties() throws Throwable {
  FormatPropertiesProvider<AbstractTestFormatProperties> propertiesProvider = new FormatPropertiesProvider<AbstractTestFormatProperties>(
      "propertiesProvider", AbstractTestFormatDefinition.class) {
  };
  DefinitionRegistry reg = new DefinitionRegistry();
  TestFormatDefinition1Impl def1 = new TestFormatDefinition1Impl();
  TestFormatDefinition2Impl def2 = new TestFormatDefinition2Impl();
  reg.registerDefinition(Arrays.asList(def1, def2));
  reg.injectDefinitionRegistry(propertiesProvider);
  propertiesProvider.init();
  // Check that possible format values include both of registered definitions
  Assert.assertEquals(propertiesProvider.format.getPossibleValues().size(), 2);
  // Set the format value to first registered definition
  propertiesProvider.format.setValue(def1.getName());
  PropertiesDynamicMethodHelper.afterProperty(propertiesProvider, propertiesProvider.format.getName());
  AbstractTestFormatProperties formatProperties = propertiesProvider.getFormatProperties();
  Assert.assertNotEquals(def2.getName(), propertiesProvider.format.getValue());
  Assert.assertEquals(def1.getName(), propertiesProvider.format.getValue());
  // Format properties class in PropertiesProvider should be the same as properties class for definition
  Assert.assertEquals(def1.getPropertiesClass(), formatProperties.getClass());
  propertiesProvider.format.setValue(def2.getName());
  PropertiesDynamicMethodHelper.afterProperty(propertiesProvider, propertiesProvider.format.getName());
  formatProperties = propertiesProvider.getFormatProperties();
  Assert.assertNotEquals(def1.getName(), propertiesProvider.format.getValue());
  Assert.assertEquals(def2.getName(), propertiesProvider.format.getValue());
  Assert.assertEquals(TestFormatProperties2Impl.class, formatProperties.getClass());
}

代码示例来源:origin: org.talend.components/components-salesforce

outputBulkProperties.upsertRelationTable.columnName.setPossibleValues(upsertRelationTable.columnName.getPossibleValues());
outputBulkProperties.upsertRelationTable.columnName.setStoredValue(upsertRelationTable.columnName.getStoredValue());
outputBulkProperties.upsertRelationTable.columnName.setValueEvaluator(upsertRelationTable.columnName.getValueEvaluator());

代码示例来源:origin: org.talend.components/components-salesforce-definition

.setPossibleValues(upsertRelationTable.columnName.getPossibleValues());
outputBulkProperties.upsertRelationTable.columnName
    .setStoredValue(upsertRelationTable.columnName.getStoredValue());

相关文章