/** * Checks if is local type. * * @param typeName the type name * @return true, if is local type */ protected boolean isLocalType(String typeName) { return null != editor.getTypeSystemDescription().getType(typeName); }
/** * Checks if is imported type. * * @param typeName the type name * @return true, if is imported type */ public boolean isImportedType(String typeName) { return null != editor.getImportedTypeSystemDesription().getType(typeName); }
/** * @param tsd * @return a type description instance for document meta-data FS if any, * otherwise - null. */ public static TypeDescription getMetadataTypeDescription(TypeSystemDescription tsd) { return tsd.getType(getMetadataTypeName()); }
/** * Checks if is imported type. * * @param td the td * @return true, if is imported type */ protected boolean isImportedType(TypeDescription td) { return null != editor.getImportedTypeSystemDesription().getType(td.getName()); }
/** * 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()); }
/** * If a new concept name is used in rule file, but not described in xml type descriptor, this method should be called to * generate the new concept class by extending the general Concept class * * @param conceptName new concept type name * @param superTypeName the parent type name where the new concept type derives from */ public void addConceptType(String conceptName, String superTypeName) { conceptName = checkNameSpace(conceptName); if (typeSystemDescription.getType(conceptName) == null || !classLoaded(conceptName)) { addConceptType(conceptName, new ArrayList<>(), superTypeName, new HashMap<>()); } }
public void addConceptType(String conceptName, Collection<String> featureNames, String superTypeName, HashMap<String, String> featureTypes) { conceptName = checkNameSpace(conceptName); superTypeName = DeterminantValueSet.checkNameSpace(superTypeName); if (typeSystemDescription.getType(conceptName) == null || !classLoaded(conceptName)) { typeSystemDescription.addType(conceptName, "an automatic generated concept type", superTypeName); if (featureNames != null && featureNames.size() > 0) { featureNames = filterFeatureNames(superTypeName, featureNames); TypeDescription type = typeSystemDescription.getType(conceptName); FeatureDescription[] aFeatures = new FeatureDescription[featureNames.size()]; int i = 0;
/** * Checks if is imported feature. * * @param name the name * @param td the td * @return true, if is imported feature */ protected boolean isImportedFeature(String name, TypeDescription td) { TypeDescription importedTd = editor.getImportedTypeSystemDesription().getType(td.getName()); if (null == importedTd) return false; return null != getFeatureFromTypeDescription(name, importedTd); }
private void inferFeatureMap(TypeDescription type) { // 1 - Recursively add features of the super type TypeDescription superType = typeSystemDescription.getType(type.getSupertypeName()); if(superType != null) inferFeatureMap(superType); // 2 - Add features of this type for(FeatureDescription feature:type.getFeatures()) { String featureFQN = type.getName() + ":" + feature.getName(); featureMap.put(feature.getName(), featureFQN); featureMap.put(featureFQN, featureFQN); } }
/** * gets a feature description for a type, including supertypes. * * @param td the td * @param featureName the feature name * @return a feature description for a type, including supertypes */ public FeatureDescription getFeature(TypeDescription td, String featureName) { FeatureDescription[] features = td.getFeatures(); String supertypeName; if (null != features) for (int i = 0; i < features.length; i++) { if (featureName.equals(features[i].getName())) return features[i]; } if (null != (supertypeName = td.getSupertypeName())) if (!CAS.TYPE_NAME_TOP.equals(supertypeName)) { TypeDescription supertype = getMergedTypeSystemDescription().getType(supertypeName); if (null == supertype) supertype = (TypeDescription) BuiltInTypes.typeDescriptions.get(supertypeName); return getFeature(supertype, featureName); } return null; }
/** * Checks if is imported allowed value. * * @param td the td * @param av the av * @return true, if is imported allowed value */ protected boolean isImportedAllowedValue(TypeDescription td, AllowedValue av) { TypeDescription importedTd = editor.getImportedTypeSystemDesription().getType(td.getName()); if (null == importedTd) return false; return null != getAllowedValue(av.getString(), importedTd); }
@Override public void exitUseDeclaration(UseDeclarationContext ctx) { String value = ctx.Identifier().getText(); usedType = typeSystemDescription.getType(value); if(usedType == null) throw new AutomataParsingException("No such type in type system: " + value); inferFeatureMap(usedType); }
attributes = new LinkedList<String>(); TypeSystemDescription tsd = TypeSystemDescriptionFactory.createTypeSystemDescription(); typeDescription = tsd.getType(annotationType); String lastAttribute = null; String firstAttribute = null;
@Override public boolean isValid() { if (typeName.length() == 0) return false; if (typeName.charAt(typeName.length() - 1) == '.') { setErrorMessage("Name cannot end with a period (.)"); return false; } if (!typeName.equals(originalTypeName)) { String errMsg = typeSection.checkDuplTypeName(typeName); if (null != errMsg) { setErrorMessage(errMsg); return false; } } if (!typeContainedInTypeSystemInfoList(supertypeName, allTypesList)) { setErrorMessage("SuperType '" + supertypeName + "' is unknown. If this is intended, please define it first."); return false; } TypeDescription importedType = editor.getImportedTypeSystemDesription().getType(typeName); if (null != importedType) { if (!supertypeName.equals(importedType.getSupertypeName())) { setErrorMessage("The supertype specified must be '" + importedType.getSupertypeName() + "' due to merging with imported types. Please change it to this type."); return false; } } return true; }
private OntClass addType(OntModel ontModel, OntClass parent, Type type) { TypeDescription description = descriptions.getType(type.getName()); OntClass ontClass = ontModel.createClass(namespace + type.getShortName()); String comment = description.getDescription(); if (comment != null) { ontClass.addComment(comment, EN); } HashSet<FeatureDescription> features = new HashSet<>(); if (parent != null) { parent.addSubClass(ontClass); features.addAll(Arrays.asList(description.getFeatures())); } else { for (Feature feature : type.getFeatures()) { TypeDescription typeDescription = descriptions.getType(feature.getDomain().getName()); if (typeDescription != null) { features.addAll(Arrays.asList(typeDescription.getFeatures())); } } } for (FeatureDescription feature : features) { if (!ignoreProperties.contains(feature.getName())) { addFeature(ontModel, ontClass, feature); } } for (Type child : typeSystem.getDirectSubtypes(type)) { addType(ontModel, ontClass, child); } return ontClass; }
private OntClass addType(OntModel ontModel, OntClass parent, Type type) { TypeDescription description = descriptions.getType(type.getName()); OntClass ontClass = ontModel.createClass(namespace + type.getShortName()); String comment = description.getDescription(); if (comment != null) { ontClass.addComment(comment, EN); } HashSet<FeatureDescription> features = new HashSet<>(); if (parent != null) { parent.addSubClass(ontClass); features.addAll(Arrays.asList(description.getFeatures())); } else { for (Feature feature : type.getFeatures()) { TypeDescription typeDescription = descriptions.getType(feature.getDomain().getName()); if (typeDescription != null) { features.addAll(Arrays.asList(typeDescription.getFeatures())); } } } for (FeatureDescription feature : features) { if (!ignoreProperties.contains(feature.getName())) { addFeature(ontModel, ontClass, feature); } } for (Type child : typeSystem.getDirectSubtypes(type)) { addType(ontModel, ontClass, child); } return ontClass; }
@Test public void thatCASMetadataIsNotAutodetected() throws Exception { TypeSystemDescription tsd = TypeSystemDescriptionFactory.createTypeSystemDescription(); assertThat(tsd.getType(CASMetadata.class.getName())) .as("CASMetadata is detected by uimaFIT").isNull(); } }
getMergedTypeSystemDescription().getType(td.getName()));