Package org.apache.uima.resource.metadata

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


      AnalysisEngineDescription primitiveDesc = new AnalysisEngineDescription_impl();
      primitiveDesc.setPrimitive(true);
      primitiveDesc.getMetaData().setName("Test Primitive TAE");
      primitiveDesc
              .setAnnotatorImplementationName("org.apache.uima.analysis_engine.impl.TestAnnotator");
      ConfigurationParameter p1 = new ConfigurationParameter_impl();
      p1.setName("StringParam");
      p1.setDescription("parameter with String data type");
      p1.setType(ConfigurationParameter.TYPE_STRING);
      primitiveDesc.getMetaData().getConfigurationParameterDeclarations()
              .setConfigurationParameters(new ConfigurationParameter[] { p1 });
      primitiveDesc.getMetaData().getConfigurationParameterSettings().setParameterSettings(
              new NameValuePair[] { new NameValuePair_impl("StringParam", "Test1") });

      // instantiate TextAnalysisEngine
      PrimitiveAnalysisEngine_impl ae = new PrimitiveAnalysisEngine_impl();
      ae.initialize(primitiveDesc, null);

      // check value of string param (TestAnnotator saves it in a static field)
      assertEquals("Test1", TestAnnotator.stringParamValue);

      // reconfigure
      ae.setConfigParameterValue("StringParam", "Test2");
      ae.reconfigure();

      // test again
      assertEquals("Test2", TestAnnotator.stringParamValue);

      // test aggregate TAE
      AnalysisEngineDescription aggDesc = new AnalysisEngineDescription_impl();
      aggDesc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
      aggDesc.setPrimitive(false);
      aggDesc.getMetaData().setName("Test Aggregate TAE");
      aggDesc.getDelegateAnalysisEngineSpecifiersWithImports().put("Test", primitiveDesc);
      FixedFlow_impl flow = new FixedFlow_impl();
      flow.setFixedFlow(new String[] { "Test" });
      aggDesc.getAnalysisEngineMetaData().setFlowConstraints(flow);
      ConfigurationParameter p2 = new ConfigurationParameter_impl();
      p2.setName("StringParam");
      p2.setDescription("parameter with String data type");
      p2.setType(ConfigurationParameter.TYPE_STRING);
      p2.setOverrides(new String[] {"Test/StringParam"});
      aggDesc.getMetaData().getConfigurationParameterDeclarations().setConfigurationParameters(
              new ConfigurationParameter[] { p2 });
      aggDesc.getMetaData().getConfigurationParameterSettings().setParameterSettings(
              new NameValuePair[] { new NameValuePair_impl("StringParam", "Test3") });
      // instantiate TextAnalysisEngine
View Full Code Here


      // precond1.setPredicate(SimplePrecondition.LANGUAGE_SUBSUMED);
      // cap1.setPreconditions(new Precondition[]{precond1});
      cap1.setLanguagesSupported(new String[] { "en", "de" });
      cap1.setMimeTypesSupported(new String[] { "text/plain" });
      md.setCapabilities(new Capability[] { cap1, cap2 });
      ConfigurationParameter cfgParam1 = new ConfigurationParameter_impl();
      cfgParam1.setName("param1");
      cfgParam1.setDescription("Test Parameter 1");
      cfgParam1.setType("String");
      ConfigurationParameter cfgParam2 = new ConfigurationParameter_impl();
      cfgParam2.setName("param2");
      cfgParam2.setDescription("Test Parameter 2");
      cfgParam2.setType("Integer");
      ConfigurationGroup cfgGrp1 = new ConfigurationGroup_impl();
      cfgGrp1.setNames(new String[] { "cfgGrp1" });
      cfgGrp1.setConfigurationParameters(new ConfigurationParameter[] { cfgParam1, cfgParam2 });
      ConfigurationParameter cfgParam3 = new ConfigurationParameter_impl();
      cfgParam3.setName("param3");
      cfgParam3.setDescription("Test Parameter 3");
      cfgParam3.setType("Float");
      ConfigurationGroup cfgGrp2 = new ConfigurationGroup_impl();
      cfgGrp2.setNames(new String[] { "cfgGrp2a", "cfgGrp2b" });
      cfgGrp2.setConfigurationParameters(new ConfigurationParameter[] { cfgParam3 });
      md.getConfigurationParameterDeclarations().setConfigurationGroups(
              new ConfigurationGroup[] { cfgGrp1, cfgGrp2 });
View Full Code Here

    ConfigGroup group = getCorrespondingModelGroup(delegateGroup);

    if (null == group) {
      group = parmSection.addGroup(delegateGroup);
    }
    ConfigurationParameter parmInGroup;
    String override = key + "/" + parm.getName();
    String overrideParmName;
    if (null != (overrideParmName = getOverridingParmName(override, group))) {
      Utility.popMessage("Only one override allowed",
              "This delegate parameter is currently overridden by '" + overrideParmName
View Full Code Here

        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 parmItem, int overrideIndex) {
    ConfigurationParameter cp = getCorrespondingModelParm(parmItem);
    TreeItem groupItem = parmItem.getParentItem();
    ConfigGroup cg = getCorrespondingModelGroup(groupItem);
   
    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, cg, 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);
      parmItem.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

    commonActionFinish();
  }

  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

      AnalysisEngineDescription primitiveDesc = new AnalysisEngineDescription_impl();
      primitiveDesc.setPrimitive(true);
      primitiveDesc
              .setAnnotatorImplementationName("org.apache.uima.analysis_engine.impl.TestAnnotator");
      primitiveDesc.getMetaData().setName("Reconfigure Test 1");
      ConfigurationParameter p1 = new ConfigurationParameter_impl();
      p1.setName("StringParam");
      p1.setDescription("parameter with String data type");
      p1.setType(ConfigurationParameter.TYPE_STRING);
      primitiveDesc.getMetaData().getConfigurationParameterDeclarations()
              .setConfigurationParameters(new ConfigurationParameter[] { p1 });
      primitiveDesc.getMetaData().getConfigurationParameterSettings().setParameterSettings(
              new NameValuePair[] { new NameValuePair_impl("StringParam", "Test1") });

      // instantiate MultiprocessingTextAnalysisEngine
      MultiprocessingAnalysisEngine_impl tae = new MultiprocessingAnalysisEngine_impl();
      tae.initialize(primitiveDesc, null);

      // check value of string param (TestAnnotator saves it in a static field)
      assertEquals("Test1", TestAnnotator.stringParamValue);

      // reconfigure
      tae.setConfigParameterValue("StringParam", "Test2");
      tae.reconfigure();

      // test again
      assertEquals("Test2", TestAnnotator.stringParamValue);

      // test aggregate TAE
      AnalysisEngineDescription aggDesc = new AnalysisEngineDescription_impl();
      aggDesc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
      aggDesc.setPrimitive(false);
      aggDesc.getDelegateAnalysisEngineSpecifiersWithImports().put("Test", primitiveDesc);
      aggDesc.getMetaData().setName("Reconfigure Test 2");
      FixedFlow_impl flow = new FixedFlow_impl();
      flow.setFixedFlow(new String[] { "Test" });
      aggDesc.getAnalysisEngineMetaData().setFlowConstraints(flow);
      ConfigurationParameter p2 = new ConfigurationParameter_impl();
      p2.setName("StringParam");
      p2.setDescription("parameter with String data type");
      p2.setType(ConfigurationParameter.TYPE_STRING);
      p2.setOverrides(new String[] {"Test/StringParam"});
      aggDesc.getMetaData().getConfigurationParameterDeclarations().setConfigurationParameters(
              new ConfigurationParameter[] { p2 });
      aggDesc.getMetaData().getConfigurationParameterSettings().setParameterSettings(
              new NameValuePair[] { new NameValuePair_impl("StringParam", "Test3") });
      // instantiate TextAnalysisEngine
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.