Package org.apache.uima.resource.metadata

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


   * @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

  @Override
  public void execute(RuleMatch match, RuleElement element, RutaStream stream, InferenceCrowd crowd) {
    RutaBlock parent = element.getParent();
    RutaModule thisScript = parent.getScript();
    AnalysisEngine targetEngine = thisScript.getEngine(namespace);
    ConfigurationParameterDeclarations configurationParameterDeclarations = targetEngine
            .getAnalysisEngineMetaData().getConfigurationParameterDeclarations();

    Set<Entry<IStringExpression, IRutaExpression>> entrySet = parameterMap.entrySet();
    for (Entry<IStringExpression, IRutaExpression> entry : entrySet) {
      IStringExpression key = entry.getKey();
      String stringValue = key.getStringValue(parent, match, element, stream);
      ConfigurationParameter configurationParameter = configurationParameterDeclarations
              .getConfigurationParameter(null, stringValue);
      if (configurationParameter != null) {
        IRutaExpression value = entry.getValue();
        String type = configurationParameter.getType();
        if (type.equals("String")) {
View Full Code Here

    // and skip remote service descriptors

    ResourceSpecifier rs = (ResourceSpecifier) entry.getValue();
    if (rs instanceof AnalysisEngineDescription || rs instanceof CasConsumerDescription
            || rs instanceof FlowControllerDescription) {
      ConfigurationParameterDeclarations delegateCpd = ((ResourceCreationSpecifier) rs)
              .getMetaData().getConfigurationParameterDeclarations();
      addSelectedParms(delegateCpd.getCommonParameters(), keyName);

      ConfigurationGroup[] groups = delegateCpd.getConfigurationGroups();
      if (null != groups) {
        for (int i = 0; i < groups.length; i++) {
          addSelectedParms(groups[i].getConfigurationParameters(), keyName);
        }
      }
      addSelectedParms(delegateCpd.getConfigurationParameters(), keyName);
    }
    if (0 < paramsUI.getItemCount()) {
      paramsUI.setSelection(0);
    }
    paramsUI.setRedraw(true);
View Full Code Here

   */
  private boolean overrideParameterIfExists(ResourceSpecifier aResourceSpecifier,
          org.apache.uima.collection.metadata.NameValuePair aCPE_nvp,
          String aComponentName) throws Exception {
    // Retrieve component's parameter settings from the in-memory descriptor
    ConfigurationParameterDeclarations cpd = ((ResourceCreationSpecifier) aResourceSpecifier)
            .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)
View Full Code Here

  }

  public void populate(ResourceMetaData md, CasProcessorConfigurationParameterSettings overrides) {
    metaData = md;

    ConfigurationParameterDeclarations cpd = metaData.getConfigurationParameterDeclarations();

    ConfigurationParameter[] parameters = cpd.getConfigurationParameters();
    ConfigurationParameterSettings cps = metaData.getConfigurationParameterSettings();

    if (parameters == null || cps == null)
      return;
View Full Code Here

      ConfigurableDataResourceSpecifier_impl cspec = new ConfigurableDataResourceSpecifier_impl();
      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");
      nvp.setValue("bar");
View Full Code Here

  // ************
  // * Parameters
  // ************
  public boolean isParmGroup() {
    ConfigurationParameterDeclarations lcpd = getAnalysisEngineMetaData()
            .getConfigurationParameterDeclarations();
    return (lcpd.getCommonParameters() != null && lcpd.getCommonParameters().length > 0)
            || (lcpd.getConfigurationGroups() != null && lcpd.getConfigurationGroups().length > 0);
  }
View Full Code Here

      return null;

    TreeItem item = items[0];
    if (isParameter(item)) {
      TreeItem group = item.getParentItem();
      ConfigurationParameterDeclarations cpds = getConfigurationParameterDeclarations();
      String groupName = (null == group) ? null : getName(group.getText());
      if (NOT_IN_ANY_GROUP.equals(groupName))
        return cpds.getConfigurationParameter(null, getName(item.getText()));
      return cpds.getConfigurationParameter(groupName, getName(item.getText()));
    }
    return null;
  }
View Full Code Here

   *           if the configuration parameter settings are invalid
   *
   * @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
    NameValuePair[] nvps = cfgParamSettings.getParameterSettings();
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.