Examples of FeatureDescription


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

   * @param aFeature
   *          feature object to convert
   * @return a FeatureDescription that is equivalent to <code>aFeature</code>
   */
  public static FeatureDescription feature2FeatureDescription(Feature aFeature) {
    FeatureDescription featDesc = UIMAFramework.getResourceSpecifierFactory()
            .createFeatureDescription();
    featDesc.setName(aFeature.getShortName());
    if (aFeature.isMultipleReferencesAllowed()) {
      featDesc.setMultipleReferencesAllowed(true);
    }
    Type rangeType = aFeature.getRange();
    //special check for array range types, which are represented in the CAS as
    //elementType[] but in the descriptor as an FSArray with an <elementType>
    if (rangeType.isArray() && !rangeType.getComponentType().isPrimitive()) {
      featDesc.setRangeTypeName(CAS.TYPE_NAME_FS_ARRAY);
      String elementTypeName = rangeType.getComponentType().getName();
      if (!CAS.TYPE_NAME_TOP.equals(elementTypeName)) {
        featDesc.setElementType(elementTypeName);
      }
    }
    else {
      featDesc.setRangeTypeName(rangeType.getName());
    }
    return featDesc;
  }
View Full Code Here

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

   * @see TypeDescription#addFeature(String, String, String, String, Boolean)
   */
  public FeatureDescription addFeature(String aFeatureName, String aDescription,
          String aRangeTypeName, String aElementTypeName, Boolean aMultipleReferencesAllowed) {
    // create new feature description
    FeatureDescription newFeature = new FeatureDescription_impl(aFeatureName, aDescription,
            aRangeTypeName, aElementTypeName, aMultipleReferencesAllowed);

    // add to array
    FeatureDescription[] features = getFeatures();
    if (features == null) {
View Full Code Here

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

      String rangeTypeName = aFeatures[i].getRangeTypeName();
      String elementTypeName = aFeatures[i].getElementType();
      Boolean multiRefsAllowed = aFeatures[i].getMultipleReferencesAllowed();

      // see if a feature already exists with this name
      FeatureDescription feat = null;
      for (int j = 0; j < existingFeatures.length; j++) {
        if (existingFeatures[j].getName().equals(featName)) {
          feat = existingFeatures[j];
          break;
        }
      }

      if (feat == null) {
        // doesn't exist; add it
        FeatureDescription featDesc = aType.addFeature(featName, aFeatures[i].getDescription(),
            rangeTypeName, elementTypeName, multiRefsAllowed);
        featDesc.setSourceUrl(aFeatures[i].getSourceUrl());
      } else {// feature does exist
        // check that the range types match
        if (!feat.getRangeTypeName().equals(rangeTypeName)) {
          throw new ResourceInitializationException(
              ResourceInitializationException.INCOMPATIBLE_RANGE_TYPES, new Object[] {
View Full Code Here

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

        throw new InternalErrorCDE("invalid state");

      if (o instanceof TypeDescription) {
        setToolTipText(tt, ((TypeDescription) o).getDescription());
      } else if (o instanceof FeatureDescription) {
        FeatureDescription fd = (FeatureDescription) o;
        if (item.getBounds(MULTIPLE_REF_OK_COL).contains(event.x, event.y)
                && isArrayOrListType(fd.getRangeTypeName())) {
          Boolean mra = fd.getMultipleReferencesAllowed();
          setToolTipText(tt, (mra != null && mra.booleanValue()) ? "Multiple References Allowed"
                  : "Multiple References Not Allowed");
        } else
          setToolTipText(tt, fd.getDescription());
      } else if (o instanceof AllowedValue) {
        setToolTipText(tt, ((AllowedValue) o).getDescription());
      }
    } else
      tt.setToolTipText("");
View Full Code Here

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

    AddFeatureDialog dialog = new AddFeatureDialog(this, td, null);
    if (dialog.open() == Window.CANCEL) {
      return;
    }

    FeatureDescription fd = localTd.addFeature(null, null, null);
    featureUpdate(fd, dialog);

    editor.addDirtyTypeName(td.getName());

    // update the GUI
View Full Code Here

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

  private void editFeature(TableTreeItem item, TableTreeItem parent) {
    boolean remergeNeeded = false;
    boolean refreshNeeded = false;
    TypeDescription td = getTypeDescriptionFromTableTreeItem(parent);
    FeatureDescription fd = getFeatureDescriptionFromTableTreeItem(item);
    FeatureDescription localFd = getLocalFeatureDefinition(td, fd);
    String oldFeatureName = fd.getName();
    AddFeatureDialog dialog = new AddFeatureDialog(this, td, fd);
    if (dialog.open() == Window.CANCEL)
      return;
View Full Code Here

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

   * @param td
   * @param dialog
   * @return error message or null
   */
  private String newFeatureTests(TypeDescription td, AddFeatureDialog dialog) {
    FeatureDescription fd;

    if (isLocalFeature(dialog.featureName, td))
      return "Duplicate Feature Name in this Descriptor";
    if (isBuiltInFeature(dialog.featureName, td))
      return "Feature Name duplicates built-in feature for this type";

    if (null != (fd = getFeature(td, dialog.featureName)))
      // verify the range is the same
      if (!fd.getRangeTypeName().equals(dialog.featureRangeName))
        return "Range Name not the same as the range from an imported type/feature description";
    return null;
  }
View Full Code Here

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

  // cases: removing a feature which is merged with an identical named imported feature
  // same - for built-in <could be created outside of the CDE>
  private void handleRemoveFeature(TableTreeItem item) {
    TypeDescription td = getTypeDescriptionFromTableTreeItem(item.getParentItem());
    FeatureDescription fd = getFeatureDescriptionFromTableTreeItem(item);

    String featureName = fd.getName();

    boolean bFeatureInUseElsewhere = isFeatureInUseElsewhere(td, featureName);
    if (bFeatureInUseElsewhere) {
      String sCascadeDeleteTitle = CASCADE_DELETE_WARNING;
      String sCascadeDeleteMessage = CASCADE_MESSAGE;
      boolean bContinue = MessageDialog.openConfirm(getSection().getShell(), sCascadeDeleteTitle,
              sCascadeDeleteMessage);
      if (!bContinue)
        return;
    }
    TypeDescription localTd = getLocalTypeDefinition(td);
    FeatureDescription localFd = getLocalFeatureDefinition(td, fd);

    removeFeature(localTd, localFd);
    if (isImportedFeature(featureName, td))
      refresh(); // don't remove from merged set
    else {
View Full Code Here

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

        } else {
          td.setSupertypeName(newTypeName);
          updateGuiType(tt.getItems()[i], td);
        }
      }
      FeatureDescription fds[] = td.getFeatures();
      FeatureDescription localFds[] = (null == localTd) ? null : localTd.getFeatures();
      if (null != fds) {
        for (int j = 0; j < fds.length; j++) {
          FeatureDescription fd = fds[j];
          if (oldTypeName.equals(fd.getRangeTypeName())) {
            if (warnAndSkipIfImported(typeName))
              continue; // skipped if feature not present in local td, or no local td.

            setNamedFeatureDescriptionRange(localFds, fd.getName(), newTypeName);
            if (isImportedType(typeName)) {
              remergeNeeded = true;
              refreshNeeded = true;
            } else {
              fd.setRangeTypeName(newTypeName);
              updateGuiFeature(tt.getItems()[i].getItems()[j], fd, td);
            }
          }
        }
      }
View Full Code Here

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

  // this function to set the corresponding feature in the "local" type's fd array
  private void setNamedFeatureDescriptionRange(FeatureDescription[] localFds, String featureName,
          final String rangeName) {
    if (null != localFds) {
      for (int i = 0; i < localFds.length; i++) {
        FeatureDescription fd = localFds[i];
        if (fd.getName().equals(featureName)) {
          fd.setRangeTypeName(rangeName);
          return;
        }
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.