public static CasData addKeysToDataCas(CasData dataCas, AFrame aFrame) throws Exception {
try {
aFrame = aFrame.fgetAFrame(Constants.KEYS);
int frameCount = aFrame.getKeyValuePairCount();
for (int i = 0; i < frameCount; i++) {
KeyValuePair kvp = aFrame.getKeyValuePair(i);
String featureStructureType = kvp.getKey();
// Convert WF keys from ':' representation to '_colon_'
if (featureStructureType
.indexOf(org.apache.uima.collection.impl.cpm.Constants.SHORT_COLON_TERM) > -1) {
featureStructureType = StringUtils.replaceAll(featureStructureType,
org.apache.uima.collection.impl.cpm.Constants.SHORT_COLON_TERM,
org.apache.uima.collection.impl.cpm.Constants.LONG_COLON_TERM);
}
// Convert WF keys from '-' representation to '_dash_'
if (featureStructureType
.indexOf(org.apache.uima.collection.impl.cpm.Constants.SHORT_DASH_TERM) > -1) {
featureStructureType = StringUtils.replaceAll(featureStructureType,
org.apache.uima.collection.impl.cpm.Constants.SHORT_DASH_TERM,
org.apache.uima.collection.impl.cpm.Constants.LONG_DASH_TERM);
}
FeatureStructure vfs = new FeatureStructureImpl();
vfs.setType(featureStructureType);
FrameLeaf leafFrame = kvp.getValueAsLeaf();
PrimitiveValue pv = new PrimitiveValueImpl(leafFrame.toString());
vfs.setFeatureValue(featureStructureType, pv);
dataCas.addFeatureStructure(vfs);
}