* @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;
}