Package org.apache.uima.resource.metadata

Examples of org.apache.uima.resource.metadata.ConfigurationParameter


  protected void validateConfigurationParameterSettings(NameValuePair[] aNVPs, String aGroupName,
          ConfigurationParameterDeclarations aParamDecls) throws ResourceConfigurationException {
    for (int i = 0; i < aNVPs.length; i++) {
      // look up the parameter info
      String name = aNVPs[i].getName();
      ConfigurationParameter param = aParamDecls.getConfigurationParameter(aGroupName, name);
      if (param == null) {
        if (aGroupName == null) {
          throw new ResourceConfigurationException(
                  ResourceConfigurationException.NONEXISTENT_PARAMETER, new Object[] { name,
                      getName() });
View Full Code Here


                  ResourceInitializationException.INVALID_PARAM_OVERRIDE_NONEXISTENT_DELEGATE,
                  new Object[] { overrides[j], aParams[i].getName(), getMetaData().getName(),
                      delegateKey, getSourceUrlString() });
        }
        if (componentSpecifier instanceof ResourceCreationSpecifier) {
          ConfigurationParameter overriddenParam = null;
          ConfigurationParameterDeclarations delegateParamDecls = ((ResourceCreationSpecifier) componentSpecifier)
                  .getMetaData().getConfigurationParameterDeclarations();
          if (aGroupName == null) // param not in group
          {
            overriddenParam = delegateParamDecls.getConfigurationParameter(null, paramName);
View Full Code Here

  /**
   * A factory method for creating a ConfigurationParameter object.
   */
  public static ConfigurationParameter createPrimitiveParameter(String name, String parameterType,
          String parameterDescription, boolean isMultiValued, boolean isMandatory) {
    ConfigurationParameter param = new ConfigurationParameter_impl();
    param.setName(name);
    param.setType(parameterType);
    param.setDescription(parameterDescription);
    param.setMultiValued(isMultiValued);
    param.setMandatory(isMandatory);
    return param;
  }
View Full Code Here

      if (value == null
              || ExternalResourceFactory.getExternalResourceParameterType(value) != ResourceValueType.NO_RESOURCE) {
        continue;
      }

      ConfigurationParameter param = ConfigurationParameterFactory.createPrimitiveParameter(name,
              value.getClass(), null, false);
      configurationParameters.add(param);
      configurationValues.add(ConfigurationParameterFactory.convertParameterValue(param, value));
    }
    return new ConfigurationData(
View Full Code Here

    Object[] configurationValues = new Object[configurationData.length / 2];

    for (int i = 0; i < configurationValues.length; i++) {
      String name = (String) configurationData[i * 2];
      Object value = configurationData[i * 2 + 1];
      ConfigurationParameter param = ConfigurationParameterFactory.createPrimitiveParameter(name,
              value.getClass(), null, false);
      configurationParameters[i] = param;
      configurationValues[i] = ConfigurationParameterFactory.convertParameterValue(param, value);
    }
    setConfigurationParameters(specifier, configurationParameters, configurationValues);
View Full Code Here

          ConfigurationParameter[] configurationParameters, Object[] configurationValues) {
    ConfigurationParameterDeclarations paramDecls = metaData
            .getConfigurationParameterDeclarations();
    ConfigurationParameterSettings paramSettings = metaData.getConfigurationParameterSettings();
    for (int i = 0; i < configurationParameters.length; i++) {
      ConfigurationParameter decl = paramDecls.getConfigurationParameter(null,
              configurationParameters[i].getName());
      if (paramDecls != null && decl == null) {
        paramDecls.addConfigurationParameter(configurationParameters[i]);
        decl = configurationParameters[i];
      }

      // Upgrade single-value to multi-value if necessary
      Object value = configurationValues[i];
      if ((value != null) && decl.isMultiValued() && !isMultiValue(value)) {
        value = Array.newInstance(value.getClass(), 1);
        Array.set(value, 0, configurationValues[i]);
      }

      paramSettings.setParameterValue(configurationParameters[i].getName(), value);
View Full Code Here

  private void testConfigurationParameter(AnalysisEngineDescription aed, String parameterName,
          String parameterType, boolean mandatory, boolean multiValued, Object parameterValue) {
    ConfigurationParameterDeclarations cpd = aed.getMetaData()
            .getConfigurationParameterDeclarations();
    ConfigurationParameter cp = cpd.getConfigurationParameter(null, parameterName);
    assertNotNull("Parameter [" + parameterName + "] does not exist!", cp);
    assertEquals("Parameter [" + parameterName + "] has wrong name", parameterName, cp.getName());
    assertEquals("Parameter [" + parameterName + "] has wrong type", parameterType, cp.getType());
    assertEquals("Parameter [" + parameterName + "] has wrong mandatory flag", mandatory,
            cp.isMandatory());
    assertEquals("Parameter [" + parameterName + "] has wrong multi-value flag", multiValued,
            cp.isMultiValued());
    ConfigurationParameterSettings cps = aed.getMetaData().getConfigurationParameterSettings();
    Object actualValue = cps.getParameterValue(parameterName);
    if (parameterValue == null) {
      assertNull(actualValue);
    } else if (!multiValued) {
View Full Code Here

            .getMetaData().getConfigurationParameterDeclarations();
    // Get the name of the parameter to find in the component's parameter list
    String param_name = aCPE_nvp.getName().trim();
    // Extract parameter with a matching name from the parameter declaration section of the
    // component's descriptor
    ConfigurationParameter cparam = cpd.getConfigurationParameter(null, param_name);
    if (cparam != null) {
      // Retrieve component's parameter settings from the in-memory descriptor
      ConfigurationParameterSettings cps = ((ResourceCreationSpecifier) aResourceSpecifier)
              .getMetaData().getConfigurationParameterSettings();
      // Determie if it is a multi-value parameter (array)
      boolean isMultiValue = cparam.isMultiValued();
      // Check if there is a match based on param name
      if (cparam.getName().equals(param_name)) {
        boolean mandatory = cparam.isMandatory();
        if (isMultiValue) {
          // Override array with values from the CPE descriptor
          replaceArray(cparam.getType(), mandatory, cps, aCPE_nvp, aComponentName);
        } else {
          // Override primitive parameter with value from the CPE descriptor
          replacePrimitive(cparam.getType(), mandatory, cps, aCPE_nvp,
                  aComponentName);
        }
        return true; // Found a match and did the override
      }
View Full Code Here

      cspec.setUrl("jdbc:db2:MyDatabase");
      ResourceMetaData md = new ResourceMetaData_impl();
      cspec.setMetaData(md);
      md.setName("foo");
      ConfigurationParameterDeclarations decls = new ConfigurationParameterDeclarations_impl();
      ConfigurationParameter param = new ConfigurationParameter_impl();
      param.setName("param");
      param.setType("String");
      decls.addConfigurationParameter(param);
      md.setConfigurationParameterDeclarations(decls);
      ConfigurationParameterSettings settings = new ConfigurationParameterSettings_impl();
      NameValuePair nvp = new NameValuePair_impl();
      nvp.setName("param");
View Full Code Here

      }
    }
  }

  private void addConfigIntParameter(String aParamName, int aParamValue) {
    ConfigurationParameter cp = new ConfigurationParameter_impl();
    cp.setMandatory(false);
    cp.setMultiValued(false);
    cp.setName(aParamName);
    cp.setType("Integer");
    getAnalysisEngineMetadata().getConfigurationParameterDeclarations().addConfigurationParameter(
            cp);
    getAnalysisEngineMetadata().getConfigurationParameterSettings().setParameterValue(aParamName,
            aParamValue);
View Full Code Here

TOP

Related Classes of org.apache.uima.resource.metadata.ConfigurationParameter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.