Package org.apache.uima.resource.metadata

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


   *
   * @see org.apache.uima.resource.ConfigurationManager#getConfigParameterValue(java.lang.String,java.lang.String)
   */
  public Object getConfigParameterValue(String aQualifiedParameterName, String aGroupName) {
    // get parameter search strategy for this context
    ConfigurationParameterDeclarations decls = (ConfigurationParameterDeclarations) mContextNameToParamDeclsMap
            .get(computeParentContextName(aQualifiedParameterName));
    if (decls != null) {
      return getConfigParameterValue(aQualifiedParameterName, aGroupName,
              decls.getSearchStrategy(), decls.getDefaultGroupName());
    } else {
      return getConfigParameterValue(aQualifiedParameterName, aGroupName, null, null);
    }
  }
View Full Code Here


   * @see org.apache.uima.resource.ConfigurationManager#getCurrentConfigParameterSettings(java.lang.String,
   *      org.apache.uima.resource.metadata.ConfigurationParameterDeclarations)
   */
  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];
View Full Code Here

   *           if the configuration parameter settings are invalid
   */
  private void validateConfigurationParameterSettings(String aContext)
          throws ResourceConfigurationException {
    // get declarations
    ConfigurationParameterDeclarations decls = (ConfigurationParameterDeclarations) mContextNameToParamDeclsMap
            .get(aContext);
    // check that all required parameters have values
    ConfigurationParameter[] params = decls.getConfigurationParameters();
    if (params.length > 0) {
      // check for mandatory values
      validateConfigurationParameterSettings(aContext, params, null);
    } else {
      ConfigurationParameter[] commonParams = decls.getCommonParameters();
      ConfigurationGroup[] groups = decls.getConfigurationGroups();
      if (groups != null) {
        for (int i = 0; i < groups.length; i++) {
          // check for mandatory values
          ConfigurationParameter[] paramsInGroup = groups[i].getConfigurationParameters();
          String[] names = groups[i].getNames();
View Full Code Here

   *
   * @throws ResourceInitializationException
   *           if the configuration parameters are invalid
   */
  protected void validateConfigurationParameters(ResourceManager aResourceManager) throws ResourceInitializationException {
    ConfigurationParameterDeclarations cfgParamDecls = getMetaData()
            .getConfigurationParameterDeclarations();
    ConfigurationParameter[] params = cfgParamDecls.getConfigurationParameters();
    if (params.length > 0) {
      // check for duplicate names
      checkForDuplicateParameterNames(params);
      checkForInvalidParameterOverrides(params, null, aResourceManager);
    } else {
      ConfigurationParameter[] commonParams = cfgParamDecls.getCommonParameters();
      // check for duplicates in common params
      Set<String> commonParamNames = new HashSet<String>();
      if (commonParams != null) {
        for (int i = 0; i < commonParams.length; i++) {
          if (!commonParamNames.add(commonParams[i].getName())) {
            throw new ResourceInitializationException(
                    ResourceInitializationException.DUPLICATE_CONFIGURATION_PARAMETER_NAME,
                    new Object[] { commonParams[i].getName(), getMetaData().getName(),
                        commonParams[i].getSourceUrlString() });
          }
        }
      }
      // check for duplicates in groups
      ConfigurationGroup[] groups = cfgParamDecls.getConfigurationGroups();
      if (groups != null) {
        Map<String, Set<String>> groupToParamSetMap = new HashMap<String, Set<String>>(); // map from group name to HashSet of param names
        // in that group
        for (int i = 0; i < groups.length; i++) {
          String[] names = groups[i].getNames();
View Full Code Here

      d.setExpanded(true);
    }
  }

  private void addDelegateGroupsToGUI(TreeItem parent, ResourceCreationSpecifier delegate) {
    ConfigurationParameterDeclarations cpd1 = delegate.getMetaData()
            .getConfigurationParameterDeclarations();
    // if (delegate instanceof AnalysisEngineDescription)
    // cpd1 = ((AnalysisEngineDescription)delegate)
    // .getAnalysisEngineMetaData().getConfigurationParameterDeclarations();
    // else if (delegate instanceof CasConsumerDescription)
    // cpd1 = ((CasConsumerDescription)delegate)
    // .getMetaData().getConfigurationParameterDeclarations();
    // else
    // throw new InternalErrorCDE("Invalid state");

    ConfigGroup noGroup = new ConfigGroup(cpd1, ConfigGroup.NOT_IN_ANY_GROUP);
    ConfigGroup commonGroup = new ConfigGroup(cpd1, ConfigGroup.COMMON);

    addDelegateGroupToGUI(parent, noGroup);
    addDelegateGroupToGUI(parent, commonGroup);
    ConfigurationGroup[] cgs = cpd1.getConfigurationGroups();
    if (cgs != null) {
      for (int i = 0; i < cgs.length; i++) {
        addDelegateGroupToGUI(parent, new ConfigGroup(cpd1, cgs[i]));
      }
    }
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());
View Full Code Here

  private static void addOverrides(List<List<String>> overrides,
      AnalysisEngineDescription desc, ResourceSpecifier[] specifiers,
      List<String> flowNames) throws Exception {

    ConfigurationParameterDeclarations aggregateDeclarations = desc
        .getAnalysisEngineMetaData()
        .getConfigurationParameterDeclarations();
    ConfigurationParameterSettings aggregateSetttings = desc
        .getAnalysisEngineMetaData()
        .getConfigurationParameterSettings();
View Full Code Here

      // each override is expressed as <name>=<value> pair, so split on
      // the first '=' found ... in case the value contains an '='
      String[] nvp = cmOverride.split("=", 2);
      // Fetch component parameter declarations to get the primitive type
      // of the parameter
      ConfigurationParameterDeclarations componentParameterDeclarations = specifier
          .getMetaData().getConfigurationParameterDeclarations();
      // Iterate over component parameter declarations looking to find one
      // with the same name
      // as provided in the override. On match, add an override to the
      // aggregate and preserve
      // the type defined for the parameter in the component descriptor.
      // If no match, throw
      // an exception
      boolean found = false;
      for (ConfigurationParameter parameter : componentParameterDeclarations
          .getConfigurationParameters()) {
        if (nvp[0].equals(parameter.getName())) {
          addParam(key, nvp, parameter, aggregateDeclarations);
          addParamValue(nvp, parameter, aggregateSetttings);
          found = true;
View Full Code Here

      throw e;
    }
    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);
View Full Code Here

        ResourceSpecifier crrs = xmlParser.parseCollectionReaderDescription(in);

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

TOP

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

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.