Package org.apache.uima.resource.metadata

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


    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) {
      if (parameterType.equals(ConfigurationParameter.TYPE_FLOAT)) {
        assertEquals(((Float) parameterValue).floatValue(), ((Float) actualValue).floatValue(),
View Full Code Here


      List<String> flowNames) throws Exception {

    ConfigurationParameterDeclarations aggregateDeclarations = desc
        .getAnalysisEngineMetaData()
        .getConfigurationParameterDeclarations();
    ConfigurationParameterSettings aggregateSetttings = desc
        .getAnalysisEngineMetaData()
        .getConfigurationParameterSettings();
    int indx = 0;
    for (List<String> componentOverrides : overrides) {
      if ( specifiers[indx] instanceof ResourceCreationSpecifier ) {
View Full Code Here

    }
    ResourceSpecifier crrs = xmlParser.parseCollectionReaderDescription(in);
    // CR overrides - throw up if trying to override an undefined parameter
        ResourceCreationSpecifier specifier = (ResourceCreationSpecifier) crrs;
        ConfigurationParameterDeclarations configurationParameterDeclarations = specifier.getMetaData().getConfigurationParameterDeclarations();
        ConfigurationParameterSettings cps = specifier.getMetaData().getConfigurationParameterSettings();
        if(crOverrides != null) {
            // Tokenize override assignments on whitespace, honoring but stripping quotes
            // Then create a map from all of them
            ArrayList<String> toks = QuotedOptions.tokenizeList(crOverrides, true);
            Map<String,String> map = QuotedOptions.parseAssignments(toks, false);
            for (Entry<String, String> ent : map.entrySet()) {
                String name = ent.getKey();
                String value = ent.getValue();
                String message = "config param: "+name+" = '"+value+"'";
                mh.frameworkDebug(cid, mid, message);
                ConfigurationParameter configurationParameter = UimaUtils.findConfigurationParameter(configurationParameterDeclarations, name);
                if (configurationParameter == null) {
                    throw new ResourceConfigurationException(
                                    ResourceConfigurationException.NONEXISTENT_PARAMETER, new Object[] { name, "CollectionReader" });
                }
                Object object = UimaUtils.getOverrideValueObject(configurationParameter, value);
                cps.setParameterValue(name, object);
            }
        }
        cr = UIMAFramework.produceCollectionReader(crrs);
        // Change the heap size to reduce CAS size. The size here depends on what we intend to put into the CAS.
        // If its just a pointer to data (like question id), the size of the heap can be reduced even more.
View Full Code Here

        duccOut.debug(location, job.getDuccId(), crcfg);
        // CR overrides
        ResourceCreationSpecifier specifier = (ResourceCreationSpecifier) crrs;
        ConfigurationParameterDeclarations configurationParameterDeclarations = specifier.getMetaData().getConfigurationParameterDeclarations();
        ConfigurationParameterSettings cps = specifier.getMetaData().getConfigurationParameterSettings();
        if(crcfg!= null) {
            // Tokenize override assignments on whitespace, honoring but stripping quotes
            // Then create a map from all of them
            ArrayList<String> toks = QuotedOptions.tokenizeList(crcfg, true);
            Map<String,String> map = QuotedOptions.parseAssignments(toks, false);
            for (Entry<String, String> ent : map.entrySet()) {
                String name = ent.getKey();
                String value = ent.getValue();
                duccOut.debug(location, job.getDuccId(), "config param name:"+name+" "+"value:"+value);
                ConfigurationParameter configurationParameter = UimaUtils.findConfigurationParameter(configurationParameterDeclarations, name);
                if (configurationParameter == null) {
                    throw new ResourceConfigurationException(
                                    ResourceConfigurationException.NONEXISTENT_PARAMETER, new Object[] { name, "CollectionReader" });
                }
                Object object = UimaUtils.getOverrideValueObject(configurationParameter, value);
                cps.setParameterValue(name, object);
            }
        }
        // CR
        duccOut.debug(location, job.getDuccId(), "CR creation...");
        cr = UIMAFramework.produceCollectionReader(crrs);
View Full Code Here

  public void reconfigure() {
    // destroy engine; it will be reinitialized on next call to process
    destroy();
    engine = null;
    // get new config. settings
    ConfigurationParameterSettings settings = ae.getUimaContextAdmin().getConfigurationManager()
            .getCurrentConfigParameterSettings(ae.getUimaContextAdmin().getQualifiedContextName());
    resourceDescription.getMetaData().setConfigurationParameterSettings(settings);
  }
View Full Code Here

    // Iterate through all declared parameters, calling abstract method to allow
    // concrete ConfigurationManager implementations to set up data structures to
    // provide access to the parameter values
    ConfigurationParameterDeclarations paramDecls = aResourceMetaData
            .getConfigurationParameterDeclarations();
    ConfigurationParameterSettings settings = aResourceMetaData.getConfigurationParameterSettings();

    // parameters in no group
    ConfigurationParameter[] paramsInNoGroup = paramDecls.getConfigurationParameters();
    if (paramsInNoGroup.length > 0) // group-less parameters
    {
View Full Code Here

  public ConfigurationParameterSettings getCurrentConfigParameterSettings(String aContextName) {
    // get declarations
    ConfigurationParameterDeclarations decls = (ConfigurationParameterDeclarations) mContextNameToParamDeclsMap
            .get(aContextName);

    ConfigurationParameterSettings settings = UIMAFramework.getResourceSpecifierFactory()
            .createConfigurationParameterSettings();

    ConfigurationParameter[] paramsInNoGroup = decls.getConfigurationParameters();
    if (paramsInNoGroup.length > 0) // no groups declared
    {
      settings.setParameterSettings(getParamSettings(null, paramsInNoGroup, aContextName));
    } else
    // groups declared
    {
      ConfigurationGroup[] groups = decls.getConfigurationGroups();
      if (groups != null) {
        for (int i = 0; i < groups.length; i++) {
          String[] names = groups[i].getNames();
          {
            for (int j = 0; j < names.length; j++) {
              // common params
              NameValuePair[] commonParamSettings = getParamSettings(names[j], decls
                      .getCommonParameters(), aContextName);
              NameValuePair[] specificParamSettings = getParamSettings(names[j], groups[i]
                      .getConfigurationParameters(), aContextName);
              NameValuePair[] mergedSettings = new NameValuePair[commonParamSettings.length
                      + specificParamSettings.length];
              System.arraycopy(commonParamSettings, 0, mergedSettings, 0,
                      commonParamSettings.length);
              System.arraycopy(specificParamSettings, 0, mergedSettings,
                      commonParamSettings.length, specificParamSettings.length);
              settings.getSettingsForGroups().put(names[j], mergedSettings);
            }
          }
        }
      }
    }
View Full Code Here

   *
   * @see ResourceMetaData#validateConfigurationParameterSettings()
   */
  public void validateConfigurationParameterSettings() throws ResourceConfigurationException {
    ConfigurationParameterDeclarations cfgParamDecls = getConfigurationParameterDeclarations();
    ConfigurationParameterSettings cfgParamSettings = getConfigurationParameterSettings();

    // check that all settings refer to declared parameters and are of the correct data type
    // Must check both the group-less ones AND any group ones'
    // For backwards compatibility (see Jira 3123) if have some group-less settings and
    // if special environment variable is set then ignore any errors in group parameter settings.
    // NOTE - for 2.4.1 act as if backwards compatibility is enabled.
    boolean support240bug = false;
    NameValuePair[] nvps = cfgParamSettings.getParameterSettings();
    if (nvps.length > 0) {
      validateConfigurationParameterSettings(nvps, null, cfgParamDecls);
      support240bug = true; // System.getenv("UIMA_Jira3123") != null;  // restore this post 2.4.1
    }
   
    try {
      Map<String, NameValuePair[]> settingsForGroups = cfgParamSettings.getSettingsForGroups();
      Set<Map.Entry<String, NameValuePair[]>> entrySet = settingsForGroups.entrySet();
      Iterator<Entry<String, NameValuePair[]>> it = entrySet.iterator();
      while (it.hasNext()) {
        Map.Entry<String, NameValuePair[]> entry = it.next();
        String groupName = entry.getKey();
View Full Code Here

    // 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)) {
View Full Code Here

      NameValuePair nvp1 = new NameValuePair_impl("param1", "test");
      NameValuePair nvp2 = new NameValuePair_impl("param2", Integer.valueOf("42"));
      NameValuePair nvp3a = new NameValuePair_impl("param3", Float.valueOf("2.718281828459045"));
      NameValuePair nvp3b = new NameValuePair_impl("param3", Float.valueOf("3.1415927"));
      ConfigurationParameterSettings settings = md.getConfigurationParameterSettings();
      settings.getSettingsForGroups().put("cfgGrp1", new NameValuePair[] { nvp1, nvp2 });
      settings.getSettingsForGroups().put("cfgGrp2a", new NameValuePair[] { nvp3a });
      settings.getSettingsForGroups().put("cfgGrp2b", new NameValuePair[] { nvp3b });

      // create aggregate AE description
      aggregateDesc = new AnalysisEngineDescription_impl();
      aggregateDesc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
      aggregateDesc.setPrimitive(false);
View Full Code Here

TOP

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

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.