Package org.apache.uima.resource.metadata

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


        alterExistingConfigurationParameter(dialog, editItem);
        // TODO consequences of changes in rest of model?
        commonActionFinishDirtyIfChange();
      } else if (isParameter(editItem) && isAggregate()) {
        // can edit name and description, but not Type (set from override)
        ConfigurationParameter existingCP = getCorrespondingModelParm(editItem);

        AddParameterDialog dialog = new AddParameterDialog(this, existingCP);
        if (dialog.open() == Window.CANCEL)
          return;
        alterExistingConfigurationParameter(dialog, editItem);
View Full Code Here


    }
    enable();
  }

  private void addOrEditOverride(TreeItem parent, int overrideIndex) {
    ConfigurationParameter cp = getCorrespondingModelParm(parent);

    Map delegateMap1 = editor.getResolvedDelegates();
    Map delegateMap = null;
    if (null != delegateMap1) {
      delegateMap = new HashMap(delegateMap1.size());
      delegateMap.putAll(delegateMap1);
      FlowControllerDeclaration fcd = editor.getResolvedFlowControllerDeclaration();
      if (null != fcd) {
        delegateMap.put(fcd.getKey(), fcd.getSpecifier());
      }
    }
    // only picks one override key - but code is from earlier design where multiple keys were
    // possible
    PickOverrideKeysAndParmName dialog = new PickOverrideKeysAndParmName(this, delegateMap,
            "Override Keys and Parameter Name Selection", cp, cpd, overrideIndex == -1);

    dialog.setTitle("Delegate Keys and Parameter Name Selection");
    dialog
            .setMessage("Select the override key path from the left panel, and the overridden parameter from the right panel.\nOnly valid parameters will be shown.");
    if (dialog.open() == Window.CANCEL)
      return;

    String delegateKeyName = dialog.delegateKeyName;
    String delegateParameterName = dialog.delegateParameterName;
    // update the existing item
    // have to do a 3 step update because the getOverrides returns a
    // cloned array
    valueChanged = false;
    String overrideSpec = delegateKeyName + '/' + delegateParameterName;
    // updateOneOverride(cp, overrideIndex, dialog.overrideSpec);
    if (overrideIndex < 0) {
      addOverride(cp, overrideSpec);
      valueChanged = true;
    } else {
      String[] overrides = cp.getOverrides();
      overrides[overrideIndex] = setValueChanged(overrideSpec, overrides[overrideIndex]);
      cp.setOverrides(overrides);
      parent.getItems()[overrideIndex].setText(OVERRIDE_HEADER + overrideSpec);
    }
    // TODO consequences of changes in rest of model?
    commonActionFinishDirtyIfChange();
  }
View Full Code Here

      } else if (isParameter(itemsToRemove[i])) { // just a plain parameter being
        // removed
        removeParameter(itemsToRemove[i], namesToRemove[i]);
      } else if (isOverride(itemsToRemove[i])) {
        TreeItem parentItem = itemsToRemove[i].getParentItem();
        ConfigurationParameter cp = getCorrespondingModelParm(parentItem);
        cp.setOverrides(removeOverride(cp, getItemIndex(parentItem, itemsToRemove[i])));
        itemsToRemove[i].dispose();
        if (cp.getOverrides().length == 0) {
          removeParameter(parentItem, getName(parentItem));
        }
      } else
        throw new InternalErrorCDE("Invalid state");
    }
View Full Code Here

    dialog.description = modelParm.getDescription();
    dialog.mandatory = modelParm.isMandatory();
    dialog.multiValue = modelParm.isMultiValued();
    dialog.parmType = modelParm.getType();
    // dialog.overrideSpec = override;
    ConfigurationParameter parmInGroup = addNewConfigurationParameter(dialog, parentGroup);
    addOverride(parmInGroup, override);
    parentGroup.setExpanded(true);
    commonActionFinish();
  }
View Full Code Here

    parent.setExpanded(true);
  }

  private void alterExistingConfigurationParameter(AddParameterDialog dialog,
          TreeItem existingTreeItem) {
    ConfigurationParameter existingCP = getCorrespondingModelParm(existingTreeItem);
    ConfigurationParameter previousCP = existingCP;
    previousCP = (ConfigurationParameter) previousCP.clone();
    fillModelParm(dialog, existingCP);
    fillParmItem(existingTreeItem, existingCP);

    // the following may have changed in an existing param spec, that could
    // affect the setting:
    // 1) the name, 2) the type, 3) the multi-value aspect
    // Description or mandatory changes have no effect on the settings

    // If the multi-value aspect changes, drop all the settings
    // If the type changes, drop all the settings
    // If the name changes, change existing settings for that parm name in all groups

    if ((!previousCP.getType().equals(existingCP.getType()))
            || (previousCP.isMultiValued() != existingCP.isMultiValued())) {
      removeParmSettingFromMultipleGroups(existingTreeItem, !REMOVE_FROM_GUI);
    }

    commonParmUpdate(existingTreeItem, existingCP, previousCP.getName());
  }
View Full Code Here

   * @param group
   * @return
   */
  private ConfigurationParameter addNewConfigurationParameter(AddParameterDialog dialog,
          TreeItem group) {
    ConfigurationParameter newCP = new ConfigurationParameter_impl();
    fillModelParm(dialog, newCP);

    if (null != group) {
      String groupName = getName(group.getText());
      if (groupName.equals(COMMON_GROUP)) {
View Full Code Here

    Set<Entry<StringExpression, RutaExpression>> entrySet = parameterMap.entrySet();
    for (Entry<StringExpression, RutaExpression> entry : entrySet) {
      StringExpression key = entry.getKey();
      String stringValue = key.getStringValue(parent, match, element, stream);
      ConfigurationParameter configurationParameter = configurationParameterDeclarations
              .getConfigurationParameter(null, stringValue);
      if (configurationParameter != null) {
        RutaExpression value = entry.getValue();
        String type = configurationParameter.getType();
        if (type.equals("String")) {
          if (configurationParameter.isMultiValued()) {
            if (value instanceof StringListExpression) {
              StringListExpression sle = (StringListExpression) value;
              List<String> list = sle.getList(parent, stream);
              targetEngine.setConfigParameterValue(stringValue, list.toArray());
            } else if (value instanceof TypeListExpression) {
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

      ConfigurationParameter[] params = getConfigurationParameters();
      return _getConfigurationParameter(params, aParamName);
    } else {
      // look in common parameters
      ConfigurationParameter[] commonParams = getCommonParameters();
      ConfigurationParameter p = _getConfigurationParameter(commonParams, aParamName);
      if (p == null) {
        // find group
        ConfigurationGroup[] groups = getConfigurationGroupDeclarations(aGroupName);
        for (int i = 0; i < groups.length; i++) {
          ConfigurationParameter[] paramsInGroup = groups[i].getConfigurationParameters();
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);

      // initialize a DataResource
      ConfigurableDataResource_impl cdr = new ConfigurableDataResource_impl();
      cdr.initialize(cspec, Collections.EMPTY_MAP);
      assertEquals(new URI("jdbc:db2:MyDatabase"), cdr.getUri());
      assertEquals("foo", cdr.getMetaData().getName());
      ConfigurationParameter param0 = cdr.getMetaData().getConfigurationParameterDeclarations()
              .getConfigurationParameters()[0];
      assertEquals("param", param0.getName());
      assertEquals("String", param0.getType());

    } catch (Exception e) {
      JUnitExtension.handleException(e);
    }
  }
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.