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) {
if (UIMAFramework.getLogger().isLoggable(Level.FINER)) {
UIMAFramework.getLogger(this.getClass()).logrb(
Level.FINER,
this.getClass().getName(),
"process",
CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_exception__FINER",
new Object[] { Thread.currentThread().getName(), e.getMessage(),
dataFrame.toXML() });
e.printStackTrace();
}
dataFrame.toXML();
}
}
aPT.endEvent(aResourceName, "Vinci Call", "");
if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
"process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_done_analyzing_bundle__FINEST",
new Object[] { Thread.currentThread().getName(), String.valueOf(aCasList.length) });
}
return aCasList;
} catch (ServiceException e) {
if (UIMAFramework.getLogger().isLoggable(Level.SEVERE)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.SEVERE, this.getClass().getName(),
"process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_service_exception__SEVERE",
new Object[] { Thread.currentThread().getName(), e.getMessage() });
}
e.printStackTrace();
throw e;
} catch (ServiceConnectionException e) {
if (UIMAFramework.getLogger().isLoggable(Level.SEVERE)) {
UIMAFramework.getLogger(this.getClass()).logrb(Level.SEVERE, this.getClass().getName(),
"process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
"UIMA_CPM_service_connection_exception__SEVERE",
new Object[] { Thread.currentThread().getName(), e.getMessage() });
}
e.printStackTrace();
throw e;
} catch (Exception ex) {
ex.printStackTrace();
throw new ServiceException(ex.getMessage());
}
}