Examples of FeatureDescription


Examples of com.avaje.tests.model.basic.FeatureDescription

public class TestL2CacheWithSharedBean extends BaseTestCase {

  @Test
  public void test() {

    FeatureDescription f1 = new FeatureDescription();
    f1.setName("one");
    f1.setDescription(null);

    Ebean.save(f1);

    ServerCache beanCache = Ebean.getServerCacheManager().getBeanCache(FeatureDescription.class);
    beanCache.getStatistics(true);

    OrmQueryDetail tunedDetail = new OrmQueryDetail();
    tunedDetail.select("name");
    TunedQueryInfo tunedInfo = new TunedQueryInfo(null, tunedDetail, 0);

    Query<FeatureDescription> query = Ebean.find(FeatureDescription.class).setId(f1.getId());

    tunedInfo.autoFetchTune((SpiQuery<?>) query);

    query.findUnique(); // PUT into cache

    FeatureDescription fd2 = query.findUnique(); // LOAD cache

    fd2.getDescription(); // invoke lazy load (this fails)

    // load the cache
    FeatureDescription fetchOne = Ebean.find(FeatureDescription.class, f1.getId());
    Assert.assertNotNull(fetchOne);
    Assert.assertEquals(1, beanCache.getStatistics(false).getSize());

    FeatureDescription fetchTwo = Ebean.find(FeatureDescription.class, f1.getId());
    FeatureDescription fetchThree = Ebean.find(FeatureDescription.class, f1.getId());
    Assert.assertSame(fetchTwo, fetchThree);

    String description = fetchThree.getDescription();
    Assert.assertNull(description);
  }
View Full Code Here

Examples of org.apache.uima.lucas.indexer.mapping.FeatureDescription

  }
 
  @Test
  public void testBuildFeatureAnnotationTokenStream() throws Exception{
    annotation1.setFeatureString("token1Feature1");
    annotationDescription.getFeatureDescriptions().add(new FeatureDescription("featureString"));
    AnnotationTokenStream annotationTokenStream = annotationTokenStreamBuilder.createAnnotationTokenStream(cas, annotationDescription);
    assertEquals(annotation1Type, annotationTokenStream.getAnnotationType());
    assertEquals(1, annotationTokenStream.getFeatureNames().size());
    assertEquals(0, annotationTokenStream.getFeatureFormats().size());
    assertEquals("token1Feature1", annotationTokenStream.next(new Token()).term());
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(
View Full Code Here

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

      desc.setAnnotatorImplementationName("org.apache.uima.analysis_engine.impl.TestAnnotator");

      TypeSystemDescription typeSystem = new TypeSystemDescription_impl();
      TypeDescription type1 = typeSystem.addType("Type1", "Test Type One",
              CAS.TYPE_NAME_ANNOTATION);
      FeatureDescription feat1 = new FeatureDescription_impl();
      feat1.setName("Feature1");
      feat1.setRangeTypeName(CAS.TYPE_NAME_INTEGER);
      type1.setFeatures(new FeatureDescription[] { feat1 });
      TypeDescription type2 = typeSystem.addType("Type2", "Test Type Two",
              CAS.TYPE_NAME_ANNOTATION);
      FeatureDescription feat2 = new FeatureDescription_impl();
      feat2.setName("Feature2");
      feat2.setRangeTypeName("EnumType");
      type2.setFeatures(new FeatureDescription[] { feat2 });
      TypeDescription enumType = typeSystem.addType("EnumType", "Test Enumerated Type",
              "uima.cas.String");
      enumType.setAllowedValues(new AllowedValue[] { new AllowedValue_impl("One", "First Value"),
          new AllowedValue_impl("Two", "Second Value") });
View Full Code Here

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

    EList eFeatures = aEClass.getEStructuralFeatures();
    Iterator iter = eFeatures.iterator();
    List uimaFeatures = new ArrayList();
    while (iter.hasNext()) {
      EStructuralFeature eFeat = (EStructuralFeature) iter.next();
      FeatureDescription uimaFeat = eStructuralFeature2UimaFeature(eFeat, aOptions);
      uimaFeatures.add(uimaFeat);
    }
    // copy down features from additional supertypes
    for (int i = 1; i < supertypes.size(); i++) {
      EClass copyFrom = (EClass) supertypes.get(i);
      EList copyFeatures = copyFrom.getEStructuralFeatures();
      Iterator iter2 = copyFeatures.iterator();
      while (iter2.hasNext()) {
        EStructuralFeature eFeat = (EStructuralFeature) iter2.next();
        // do not copy if this feature is a duplicate of one defined on the class
        // or inherited from its primary supertype
        EList locallyDefinedFeatures = aEClass.getEStructuralFeatures();
        EList firstSupertypesFeatures = ((EClass) supertypes.get(0)).getEAllStructuralFeatures();
        if (!containsNamedElement(locallyDefinedFeatures, eFeat.getName())
                && !containsNamedElement(firstSupertypesFeatures, eFeat.getName())) {
          FeatureDescription uimaFeat = eStructuralFeature2UimaFeature(eFeat, aOptions);
          uimaFeatures.add(uimaFeat);
        }
      }
    }
View Full Code Here

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

   * @param attr
   * @return
   */
  private static FeatureDescription eStructuralFeature2UimaFeature(
          EStructuralFeature aStructuralFeature, Map aOptions) throws URISyntaxException {
    FeatureDescription feat = uimaFactory.createFeatureDescription();
    feat.setName(aStructuralFeature.getName());
    String rangeTypeName = null;
    String elementTypeName = null;
    EAnnotation eannot = aStructuralFeature.getEAnnotation("http://uima.apache.org");
    if (eannot != null) {
      feat.setDescription((String) eannot.getDetails().get("description"));
      // the UIMA type name to use may be recorded as an EAnnotation; this is
      // particularly important for arrays and lists, since Ecore doesn't distinguish between
      // these two possible implementations for a multi-valued property
      rangeTypeName = (String) eannot.getDetails().get("uimaType");
      // the elemnt type may also be specified as an EAnnotation; this is
      // used for the case where an FSArray or FSList is NOT represented
      // as a multi-valued property
      elementTypeName = (String) eannot.getDetails().get("elementType");
    }
    EClassifier attrRangeType = aStructuralFeature.getEType();

    // if range type wasn't specified in an EAnnotation, compute it ourselves
    if (rangeTypeName == null) {
      rangeTypeName = getUimaTypeName(attrRangeType, aStructuralFeature.isMany(), aOptions);
    }
    feat.setRangeTypeName(rangeTypeName);

    if (aStructuralFeature.isMany()) {
      // set the element type of the array/list to the EType of the structural feature
      // (except primitive, or TOP, which are assumed)
      String uimaElementType = getUimaTypeName(attrRangeType, false, aOptions);
      if (!CAS.TYPE_NAME_INTEGER.equals(uimaElementType)
              && !CAS.TYPE_NAME_FLOAT.equals(uimaElementType)
              && !CAS.TYPE_NAME_STRING.equals(uimaElementType)
              && !CAS.TYPE_NAME_TOP.equals(uimaElementType)
              && !CAS.TYPE_NAME_BYTE.equals(uimaElementType)
              && !CAS.TYPE_NAME_SHORT.equals(uimaElementType)
              && !CAS.TYPE_NAME_LONG.equals(uimaElementType)
              && !CAS.TYPE_NAME_DOUBLE.equals(uimaElementType)
              && !CAS.TYPE_NAME_BOOLEAN.equals(uimaElementType)) {
        feat.setElementType(uimaElementType);
      }
    } else if (!aStructuralFeature.getEType().equals(EcorePackage.eINSTANCE.getEByteArray())) {
      // if in Ecore we have a single-valued property whose range type is an array or list,
      // we need to set "multiple references allowed" to true in the UIMA type system
      // (exception: don't do this for the EByteArray data type, which is implicilty a
      // multi-valued type)
      if (isArrayOrList(rangeTypeName)) {
        feat.setMultipleReferencesAllowed(Boolean.TRUE);
        // also, set element type if one was contained in the EAnnotation
        feat.setElementType(elementTypeName);
      }
    }
    return feat;
  }
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
   */
  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
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.