// Produces KEY Frames and ads them to a given dataFrame
// produceXCASRequestFrame(aCasList[i], dataFrame);
if (System.getProperty("SHOWKEYS") != null) {
Iterator it = aCasList[i].getFeatureStructures();
while (it.hasNext()) {
FeatureStructure fs = (FeatureStructure) it.next();
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST,
this.getClass().getName(), "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_dump_casdata__FINEST",
new Object[] { Thread.currentThread().getName(), fs.getType() });
}
}
}
if (DATACasUtils.isCasEmpty(aCasList[i])) {
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
"process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_no_cas__FINEST",
new Object[] { Thread.currentThread().getName() });
}
continue;
}
long sTime = uimaTimer.getTimeInMillis();
// Different serializer object is used for WF. It seems to perform better
if (System.getProperty("WF_SERIALIZER") != null) {
produceXCASRequestFrame(aCasList[i], dataFrame, keys2Drop);
} else {
vinciCasDataConverter.casDataToVinciFrame(aCasList[i], dataFrame);
dropNamedTypes(dataFrame.fgetAFrame("KEYS"), keys2Drop);
}
totalSerializeTime += (uimaTimer.getTimeInMillis() - sTime);
query.fadd(Constants.DATA, dataFrame);
}
if (serviceName != null && System.getProperty("SHOW_NAME") != null)
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
"process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_send_casdata_to_service__FINEST",
new Object[] { Thread.currentThread().getName(), serviceName });
}
if (System.getProperty("SHOW_REQFRAME") != null) {
UIMAFramework.getLogger(this.getClass()).log(Level.INFO, " queryFrame-" + query.toXML());
}
long t = uimaTimer.getTimeInMillis();
AFrame responseFrame = sendAndReceive(query);
// no longer need the query object
query = null;
totalRoundTripTime += (uimaTimer.getTimeInMillis() - t);
if ((responseFrame != null) && (responseFrame.fgetString("Error") != null)) {
throw new ServiceException(responseFrame.fgetString("Error"));
}
if (System.getProperty("SHOW_RAW_RESPFRAME") != null) {
UIMAFramework.getLogger(this.getClass()).log(Level.INFO,
" responseFrame from service::" + serviceName + "\n" + responseFrame.toXML());
}
if (responseFrame.fgetAFrame("DATA") == null) {
// No annotations found in reply so just leave
return aCasList;
}
ArrayList d = responseFrame.fget("DATA");
int instanceCount = 0;
// Process response, DATA frame at a time. Each DATA frame corresponds to an instance of
// CasData
AFrame dataFrame = null;
while (!(d.isEmpty())) {
dataFrame = (AFrame) d.remove(0);
try {
if (System.getProperty("SHOW_RESPFRAME") != null) {
UIMAFramework.getLogger(this.getClass()).log(Level.INFO,
" Converting XCAS in responseFrame to CasData.XCAS=" + dataFrame.toXML());
}
long eTime = uimaTimer.getTimeInMillis();
// When configured use WF serializer which is faster than the alternative SAX based one
if (System.getProperty("WF_SERIALIZER") != null) {
addKeysToDataCas(aCasList[instanceCount], dataFrame);
} else {
// We will call vinciCasDataConverter to convert response frame to a new
// CasData. BUT, we also need to preserve the document text from the request,
// since it may not be echoed by the service.
CasData newCasData = new CasDataImpl();
FeatureStructure casDataFs = this.getDocTextFeatureStructure(aCasList[instanceCount]);
if (casDataFs != null) {
newCasData.addFeatureStructure(casDataFs);
}
vinciCasDataConverter.appendVinciFrameToCasData(dataFrame.fgetAFrame("KEYS"),
newCasData);
aCasList[instanceCount] = newCasData;
}
totalDeSerializeTime += (uimaTimer.getTimeInMillis() - eTime);
if (System.getProperty("SHOWFRAME") != null) {
UIMAFramework.getLogger(this.getClass()).log(Level.INFO, " dumping CasData-\n");
dumpFeatures(aCasList[instanceCount]);
}
if (dataFrame != null) {
FeatureStructure vfs = new FeatureStructureImpl();
vfs.setType(org.apache.uima.collection.impl.cpm.Constants.STAT_FEATURE);
String frame2CasTime = dataFrame.fgetString(Constants.FRAME_TO_CAS_TIME);
if (frame2CasTime != null) {
PrimitiveValue pv = new PrimitiveValueImpl(frame2CasTime);
vfs.setFeatureValue(Constants.FRAME_TO_CAS_TIME, pv);
}
String annotationTime = dataFrame.fgetString(Constants.ANNOTATION_TIME);
if (annotationTime != null) {
PrimitiveValue pv = new PrimitiveValueImpl(annotationTime);
vfs.setFeatureValue(Constants.ANNOTATION_TIME, pv);
}
String cas2FrameTime = dataFrame.fgetString(Constants.CAS_TO_FRAME_TIME);
if (cas2FrameTime != null) {
PrimitiveValue pv = new PrimitiveValueImpl(cas2FrameTime);
vfs.setFeatureValue(Constants.CAS_TO_FRAME_TIME, pv);
}
aCasList[instanceCount].addFeatureStructure(vfs);
}
instanceCount++;
} catch (Exception e) {