org.apache.uima.resource.metadata.TypeDescription Java Examples
The following examples show how to use
org.apache.uima.resource.metadata.TypeDescription.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AgreementTestUtils.java From webanno with Apache License 2.0 | 6 votes |
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSystem(String... aFeatures) throws Exception { List<TypeSystemDescription> typeSystems = new ArrayList<>(); TypeSystemDescription tsd = new TypeSystemDescription_impl(); // Link type TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP); linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING); linkTD.addFeature("target", "", CAS.TYPE_NAME_ANNOTATION); // Link host TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION); hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false); for (String feature : aFeatures) { hostTD.addFeature(feature, "", CAS.TYPE_NAME_STRING); } typeSystems.add(tsd); typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription()); return CasCreationUtils.mergeTypeSystems(typeSystems); }
Example #2
Source File: CasCreationUtils.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Determines whether one type subsumes another. * * @param aType1Name * name of first type * @param aType2Name * name of second type * @param aNameMap * Map from type names to TypeDescriptions * * @return true if and only if the type named <code>aType1Name</code> subsumes the type named * <code>aType2Name</code> according to the information given in the * <code>aNameMap</code>. */ protected static boolean subsumes(String aType1Name, String aType2Name, Map<String, ? extends TypeDescription> aNameMap) { // Top type subsumes everything if (CAS.TYPE_NAME_TOP.equals(aType1Name)) { return true; } // "walk up the tree" from aType2Name until we reach aType1Name or null String current = aType2Name; while (current != null && !current.equals(aType1Name)) { TypeDescription curType = aNameMap.get(current); if (curType == null) current = null; else current = curType.getSupertypeName(); } return (current != null); }
Example #3
Source File: TypeSystemUtil.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Convert a {@link TypeSystem} to an equivalent {@link TypeSystemDescription}. * * @param aTypeSystem * type system object to convert * @return a TypeSystemDescription that is equivalent to <code>aTypeSystem</code> */ public static TypeSystemDescription typeSystem2TypeSystemDescription(TypeSystem aTypeSystem) { ResourceSpecifierFactory fact = UIMAFramework.getResourceSpecifierFactory(); TypeSystemDescription tsDesc = fact.createTypeSystemDescription(); Iterator<Type> typeIter = aTypeSystem.getTypeIterator(); List<TypeDescription> typeDescs = new ArrayList<>(); while (typeIter.hasNext()) { Type type = typeIter.next(); if (!type.getName().startsWith("uima.cas") && !type.getName().equals("uima.tcas.Annotation") && !type.isArray()) { typeDescs.add(type2TypeDescription(type, aTypeSystem)); } } TypeDescription[] typeDescArr = new TypeDescription[typeDescs.size()]; typeDescs.toArray(typeDescArr); tsDesc.setTypes(typeDescArr); return tsDesc; }
Example #4
Source File: CasCreationUtils.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Utility method for populating the aOutputMergedTypes argument in the mergeTypeSystems method. * * @param aOutputMergedTypes * Map to populate * @param currentType * TypeDescription currently being processed * @param existingType * TypeDescription that already existed for the same name */ private static void reportMerge(Map<String, Set<String>> aOutputMergedTypes, TypeDescription currentType, TypeDescription existingType) { if (aOutputMergedTypes != null) { String typeName = currentType.getName(); Set<String> descriptorUrls = aOutputMergedTypes.get(typeName); if (descriptorUrls == null) { descriptorUrls = new TreeSet<>(); descriptorUrls.add(existingType.getSourceUrlString()); descriptorUrls.add(currentType.getSourceUrlString()); aOutputMergedTypes.put(typeName, descriptorUrls); } else { descriptorUrls.add(currentType.getSourceUrlString()); } } }
Example #5
Source File: TypeSection.java From uima-uimaj with Apache License 2.0 | 6 votes |
@Override public void refresh() { super.refresh(); tt.removeAll(); TypeSystemDescription tsdFull = getMergedTypeSystemDescription(); TypeDescription[] tdsFull = tsdFull.getTypes(); if (null != tdsFull) { for (int i = 0; i < tdsFull.length; i++) { addTypeToGUI(tdsFull[i]); } } if (tt.getItemCount() > 0) tt.setSelection(tt.getItems()[0]); packTree(tt); enable(); }
Example #6
Source File: DiffTestUtils.java From webanno with Apache License 2.0 | 6 votes |
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSytem(String... aFeatures) throws Exception { List<TypeSystemDescription> typeSystems = new ArrayList<>(); TypeSystemDescription tsd = new TypeSystemDescription_impl(); // Link type TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP); linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING); linkTD.addFeature("target", "", Token.class.getName()); // Link host TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION); hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false); for (String feature : aFeatures) { hostTD.addFeature(feature, "", CAS.TYPE_NAME_STRING); } typeSystems.add(tsd); typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription()); return CasCreationUtils.mergeTypeSystems(typeSystems); }
Example #7
Source File: TypeSection.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Update gui feature. * * @param fItem the f item * @param fd the fd * @param td the td */ private void updateGuiFeature(TreeItem fItem, FeatureDescription fd, TypeDescription td) { String rangeType; fItem.setText(NAME_COL, fd.getName()); fItem.setText(RANGE_COL, formatName(rangeType = fd.getRangeTypeName())); fItem.setData(fd); setItemColor(fItem, null != getLocalFeatureDefinition(td, fd)); if (isArrayOrListType(rangeType)) { Boolean mra = fd.getMultipleReferencesAllowed(); fItem.setImage(MULTIPLE_REF_OK_COL, (null != mra && mra) ? TAEConfiguratorPlugin .getImage(TAEConfiguratorPlugin.IMAGE_MREFOK) : TAEConfiguratorPlugin .getImage(TAEConfiguratorPlugin.IMAGE_NOMREF)); } else { fItem.setImage(MULTIPLE_REF_OK_COL, null); } String ert = fd.getElementType(); fItem.setText(ELEMENT_TYPE_COL, (isFSArrayOrListType(rangeType) && ert != null) ? formatName(ert) : ""); }
Example #8
Source File: TypeSection.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Handle hover. * * @param event the event */ public void handleHover(Event event) { // next getItem call requires that table have SWT.FULL_SELECTION Style TreeItem item = tt.getItem(new Point(event.x, event.y)); if (null != item) { Object o = item.getData(); if (null == o) 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) ? "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(""); }
Example #9
Source File: AgreementTestUtils.java From webanno with Apache License 2.0 | 6 votes |
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSytem() throws Exception { List<TypeSystemDescription> typeSystems = new ArrayList<>(); TypeSystemDescription tsd = new TypeSystemDescription_impl(); // Link type TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP); linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING); linkTD.addFeature("target", "", Token.class.getName()); // Link host TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION); hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false); typeSystems.add(tsd); typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription()); return CasCreationUtils.mergeTypeSystems(typeSystems); }
Example #10
Source File: AgreementTestUtils.java From webanno with Apache License 2.0 | 6 votes |
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSytem(String... aFeatures) throws Exception { List<TypeSystemDescription> typeSystems = new ArrayList<>(); TypeSystemDescription tsd = new TypeSystemDescription_impl(); // Link type TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP); linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING); linkTD.addFeature("target", "", Token.class.getName()); // Link host TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION); hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false); for (String feature : aFeatures) { hostTD.addFeature(feature, "", CAS.TYPE_NAME_STRING); } typeSystems.add(tsd); typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription()); return CasCreationUtils.mergeTypeSystems(typeSystems); }
Example #11
Source File: TypeSystemAnalysis.java From webanno with Apache License 2.0 | 6 votes |
private void analyzeFeatures(AnnotationLayer aLayer, TypeSystem aTS, TypeDescription aTD, Optional<? extends LayerDetails> aDetails) { Type type = aTS.getType(aTD.getName()); for (FeatureDescription fd : aTD.getFeatures()) { Feature feat = type.getFeatureByBaseName(fd.getName()); // We do not need to set up built-in features if (isBuiltInFeature(feat)) { continue; } if (aDetails.isPresent() && aDetails.get().isHiddenFeature(feat)) { continue; } AnnotationFeature f = analyzeFeature(aTS, fd, feat); features.put(aLayer.getName(), f); } }
Example #12
Source File: TypeSystemUtilTest.java From uima-uimaj with Apache License 2.0 | 6 votes |
public void testTypeSystem2TypeSystemDescription() throws Exception { //create a CAS with example type system File typeSystemFile = JUnitExtension.getFile("ExampleCas/testTypeSystem.xml"); TypeSystemDescription tsDesc = UIMAFramework.getXMLParser().parseTypeSystemDescription( new XMLInputSource(typeSystemFile)); //add an example type to test FSArrays with and without elementTypes TypeDescription type = tsDesc.addType("example.TestType", "", "uima.tcas.Annotation"); type.addFeature("testFeat", "", "uima.cas.FSArray","uima.tcas.Annotation", null); TypeDescription type2 = tsDesc.addType("example.TestType2", "", "uima.tcas.Annotation"); type2.addFeature("testFeat", "", "uima.cas.FSArray"); CAS cas = CasCreationUtils.createCas(tsDesc, null, null); //convert that CAS's type system back to a TypeSystemDescription TypeSystemDescription tsDesc2 = TypeSystemUtil.typeSystem2TypeSystemDescription(cas.getTypeSystem()); //test that this is valid by creating a new CAS CasCreationUtils.createCas(tsDesc2, null, null); // Check that can be written (without cluttering up the console) StringWriter out = new StringWriter(); tsDesc2.toXML(out); }
Example #13
Source File: CurationTestUtils.java From webanno with Apache License 2.0 | 6 votes |
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSytem() throws Exception { List<TypeSystemDescription> typeSystems = new ArrayList<>(); TypeSystemDescription tsd = new TypeSystemDescription_impl(); // Link type TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP); linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING); linkTD.addFeature("target", "", CAS.TYPE_NAME_ANNOTATION); // Link host TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION); hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false); typeSystems.add(tsd); typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription()); return CasCreationUtils.mergeTypeSystems(typeSystems); }
Example #14
Source File: TypeSection.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Edits the allowed value. * * @param item the item * @param parent the parent */ private void editAllowedValue(TreeItem item, TreeItem parent) { TypeDescription td = getTypeDescriptionFromTableTreeItem(parent); AllowedValue av = getAllowedValueFromTableTreeItem(item); AllowedValue localAv = getLocalAllowedValue(td, av); // must use unmodified value of "av" AddAllowedValueDialog dialog = new AddAllowedValueDialog(this, av); if (dialog.open() == Window.CANCEL) return; allowedValueUpdate(av, dialog); allowedValueUpdate(localAv, dialog); if (!valueChanged) return; // update the GUI item.setText(AV_COL, av.getString()); editor.addDirtyTypeName(td.getName()); finishActionPack(); }
Example #15
Source File: TypeSection.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * verify a new or edited feature is valid. For new features: The name must be unique locally. It * may duplicate a non-local feature that isn't also built-in. (We presume built-in features are * fixed). (We allow dupl non-local feature in case this type system is used without the import, * in some other context?) We don't use the TCas because it isn't necessarily being updated * * For edited features: If the name changed, do "new" test above on new name If the name changed, * do "remove" test on old name: If used in an index or capability, but merged/built-in name not * still there, warn about index being invalidated (not done here - done during feature update * itself). If name used in index, and range is not indexable - error * * @param dialog the dialog * @param td the td * @param oldFd the old fd * @return error message or null */ public String checkFeature(AddFeatureDialog dialog, TypeDescription td, FeatureDescription oldFd) { if (null == oldFd) { // adding new feature return newFeatureTests(td, dialog); } String errMsg = null; // modifying existing feature if (!oldFd.getName().equals(dialog.featureName)) { // name changed errMsg = newFeatureTests(td, dialog); if (null != errMsg) return errMsg; return null; } // Note: this test is different from above: it tests current name, not old name if (isFeatureUsedInIndex(td, dialog.featureName)) if (!isIndexableRange(dialog.featureRangeName)) return ("This feature is used in an index - it must have an indexable Range"); return null; }
Example #16
Source File: RecommenderTestHelper.java From inception with Apache License 2.0 | 6 votes |
public static void addScoreFeature(CAS aCas, String aTypeName, String aFeatureName) throws IOException, UIMAException { String scoreFeatureName = aFeatureName + FEATURE_NAME_SCORE_SUFFIX; String scoreExplanationFeatureName = aFeatureName + FEATURE_NAME_SCORE_EXPLANATION_SUFFIX; TypeSystemDescription tsd = typeSystem2TypeSystemDescription(aCas.getTypeSystem()); TypeDescription typeDescription = tsd.getType(aTypeName); typeDescription.addFeature(scoreFeatureName, "Confidence feature", TYPE_NAME_DOUBLE); typeDescription.addFeature(scoreExplanationFeatureName, "Confidence explanation feature", TYPE_NAME_STRING); typeDescription.addFeature(FEATURE_NAME_IS_PREDICTION, "Is prediction", TYPE_NAME_BOOLEAN); AnnotationSchemaService schemaService = new AnnotationSchemaServiceImpl(); schemaService.upgradeCas(aCas, tsd); }
Example #17
Source File: TypeSection.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Handle remove allowed value. * * @param item the item */ private void handleRemoveAllowedValue(TreeItem item) { TypeDescription td = getTypeDescriptionFromTableTreeItem(item.getParentItem()); AllowedValue av = getAllowedValueFromTableTreeItem(item); // guaranteed non-null -otherwise remove button disabled removeAllowedValue(getLocalTypeDefinition(td), av); if (!isImportedAllowedValue(td, av)) { removeAllowedValue(td, av); // update GUI setSelectionOneUp(tt, item); item.dispose(); } else { refresh(); } editor.addDirtyTypeName(td.getName()); finishAction(); }
Example #18
Source File: DefinedTypesWithSupers.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Update. */ private void update() { cachedResult.clear(); // for aggregates, this is the fully-merged type system // for all systems, it is the type system with imports resolved TypeSystemDescription typeSystemDescription = modelRoot.getMergedTypeSystemDescription(); if (typeSystemDescription == null) return; // cleared table TypeDescription[] types = typeSystemDescription.getTypes(); TypeSystem typeSystem = modelRoot.descriptorCAS.get().getTypeSystem(); String typeName; Map allTypes = modelRoot.allTypes.get(); for (int i = 0; i < types.length; i++) { cachedResult.add(typeName = types[i].getName()); Type nextType = (Type) allTypes.get(typeName); while (nextType != null) { nextType = typeSystem.getParent(nextType); if (nextType != null) cachedResult.add(nextType.getName()); } } }
Example #19
Source File: CurationTestUtils.java From webanno with Apache License 2.0 | 6 votes |
public static TypeSystemDescription createMultiLinkWithRoleTestTypeSystem(String... aFeatures) throws Exception { List<TypeSystemDescription> typeSystems = new ArrayList<>(); TypeSystemDescription tsd = new TypeSystemDescription_impl(); // Link type TypeDescription linkTD = tsd.addType(LINK_TYPE, "", CAS.TYPE_NAME_TOP); linkTD.addFeature("role", "", CAS.TYPE_NAME_STRING); linkTD.addFeature("target", "", CAS.TYPE_NAME_ANNOTATION); // Link host TypeDescription hostTD = tsd.addType(HOST_TYPE, "", CAS.TYPE_NAME_ANNOTATION); hostTD.addFeature("links", "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false); for (String feature : aFeatures) { hostTD.addFeature(feature, "", CAS.TYPE_NAME_STRING); } typeSystems.add(tsd); typeSystems.add(TypeSystemDescriptionFactory.createTypeSystemDescription()); return CasCreationUtils.mergeTypeSystems(typeSystems); }
Example #20
Source File: TypeSection.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Type requires type. * * @param upstreamType the upstream type * @param typeName the type name * @return true, if successful */ private boolean typeRequiresType(TypeDescription upstreamType, String typeName) { if (null == typeName) return false; if (typeName.equals(upstreamType.getSupertypeName())) { return true; } FeatureDescription[] features = upstreamType.getFeatures(); if (features == null) { return false; } for (int i = 0; i < features.length; i++) { if (typeName.equals(features[i].getRangeTypeName())) { return true; } } return false; }
Example #21
Source File: Ecore2UimaTypeSystem.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Eenum 2 uima type. * * @param aEEnum the a E enum * @param aUimaNamespace the a uima namespace * @param aOptions the a options * @return the type description * @throws URISyntaxException the URI syntax exception */ private static TypeDescription eenum2UimaType(EEnum aEEnum, String aUimaNamespace, Map aOptions) throws URISyntaxException { TypeDescription type = uimaFactory.createTypeDescription(); // set name if (aUimaNamespace != null) { type.setName(aUimaNamespace + "." + aEEnum.getName()); } else { type.setName(aEEnum.getName()); } // set supetype to String type.setSupertypeName(CAS.TYPE_NAME_STRING); // try to get desecription from EAnnotation EAnnotation eannot = aEEnum.getEAnnotation("http://uima.apache.org"); if (eannot != null) { type.setDescription((String) eannot.getDetails().get("description")); } // set allowed values EList literals = aEEnum.getELiterals(); AllowedValue[] vals = new AllowedValue[literals.size()]; for (int i = 0; i < literals.size(); i++) { EEnumLiteral literal = (EEnumLiteral) literals.get(i); vals[i] = uimaFactory.createAllowedValue(); vals[i].setString(literal.getName()); EAnnotation literalAnnot = literal.getEAnnotation("http://uima.apache.org"); if (literalAnnot != null) { vals[i].setDescription((String) literalAnnot.getDetails().get("description")); } } type.setAllowedValues(vals); return type; }
Example #22
Source File: CasCreationUtils.java From uima-uimaj with Apache License 2.0 | 5 votes |
private static AllowedValue[] getAllowedValues(TypeDescription type) { AllowedValue[] r = type.getAllowedValues(); if (r == null) { return EMPTY_ALLOWED_VALUE_ARRAY; } return r; }
Example #23
Source File: Jg.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Gets the java pkg. * * @param td the td * @return the java pkg */ String getJavaPkg(TypeDescription td) { TypeInfo bi = Jg.builtInTypes.get(td.getName()); if (null == bi) return getPkg(td); return getPkg(bi.javaNameWithPkg); }
Example #24
Source File: TypeSystemDescription_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * @see TypeSystemDescription#getType(java.lang.String) */ public TypeDescription getType(String aTypeName) { for (int i = 0; i < mTypes.length; i++) { if (aTypeName.equals(mTypes[i].getName())) return mTypes[i]; } return null; }
Example #25
Source File: AbstractImportablePartSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * returns null if no feature by this name. * * @param name the name * @param td the td * @return the feature from type description */ public FeatureDescription getFeatureFromTypeDescription(String name, TypeDescription td) { FeatureDescription[] fds = td.getFeatures(); if (fds == null) return null; for (int i = 0; i < fds.length; i++) { if (name.equals(fds[i].getName())) return fds[i]; } return null; }
Example #26
Source File: Jg.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Generate type classes from the specified templates. * * @param td TypeDescription object * @param outputDirectory output directory * @param jcasTypeInstance Template instance used to generate class * @return void * @throws IOException - */ private void generateClassesFromTemplate(TypeDescription td, String outputDirectory, IJCasTypeTemplate jcasTypeInstance) throws IOException { simpleClassName = removePkg(getJavaName(td)); generateClass(progressMonitor, outputDirectory, td, jcasTypeInstance.generate(new Object[] { this, td }), getJavaName(td), merger); // simpleClassName = removePkg(getJavaName_Type(td)); // generateClass(progressMonitor, outputDirectory, td, jcas_TypeInstance.generate(new Object[] { // this, td }), getJavaName_Type(td), merger); }
Example #27
Source File: TypeSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Handle add type. */ public void handleAddType() { AddTypeDialog dialog = new AddTypeDialog(this); if (dialog.open() == Window.CANCEL) return; TypeSystemDescription tsd = getMergedTypeSystemDescription(); TypeSystemDescription localTsd = getTypeSystemDescription(); TypeDescription td = localTsd.addType(dialog.typeName, multiLineFix(dialog.description), dialog.supertypeName); if (!isImportedType(dialog.typeName)) { td = tsd.addType(dialog.typeName, multiLineFix(dialog.description), dialog.supertypeName); addTypeToGUI(td); } else { rebuildMergedTypeSystem(); } if (isImportedType(dialog.typeName) || isBuiltInType(dialog.typeName)) { refresh(); selectTypeInGui(td); } editor.addDirtyTypeName(dialog.typeName); finishActionPack(); }
Example #28
Source File: AbstractImportablePartSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Gets the local type definition. * * @param td the td * @return the local type definition */ protected TypeDescription getLocalTypeDefinition(TypeDescription td) { TypeSystemDescription tsdLocal = getTypeSystemDescription(); if (null == tsdLocal) return null; return tsdLocal.getType(td.getName()); }
Example #29
Source File: AbstractImportablePartSection.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Gets the allowed value. * * @param value the value * @param td the td * @return the allowed value */ public AllowedValue getAllowedValue(String value, TypeDescription td) { AllowedValue[] avs = td.getAllowedValues(); if (null == avs) return null; for (int i = 0; i < avs.length; i++) { if (value.equals(avs[i].getString())) return avs[i]; } return null; }
Example #30
Source File: SubjectObjectFeatureSupport.java From inception with Apache License 2.0 | 5 votes |
@Override public void generateFeature(TypeSystemDescription aTSD, TypeDescription aTD, AnnotationFeature aFeature) { // Link type TypeDescription linkTD = aTSD.addType(aFeature.getLinkTypeName(), "", CAS.TYPE_NAME_TOP); linkTD.addFeature(aFeature.getLinkTypeRoleFeatureName(), "", CAS.TYPE_NAME_STRING); linkTD.addFeature(aFeature.getLinkTypeTargetFeatureName(), "", aFeature.getType()); // Link feature aTD.addFeature(aFeature.getName(), "", CAS.TYPE_NAME_FS_ARRAY, linkTD.getName(), false); }