}
return response;
}
private CommunicationType getCommunication(Long iid, BpelDAOConnection conn) {
CommunicationType result = CommunicationType.Factory.newInstance();
List<Exchange> list = new ArrayList<Exchange>();
ProcessInstanceDAO instance = conn.getInstance(iid);
if (instance == null)
return result;
result.setProcessType(instance.getProcess().getType());
for (String mexId : instance.getMessageExchangeIds()) {
MessageExchangeDAO mexDao = conn.getMessageExchange(mexId);
Exchange e = Exchange.Factory.newInstance();
list.add(e);
e.setCreateTime(new XmlCalendar(mexDao.getCreateTime()));
e.setOperation(mexDao.getOperation());
try {
e.setIn(XmlObject.Factory.parse(mexDao.getRequest().getData()));
} catch (XmlException e1) {
__log.error("", e1);
}
try {
Status status = Status.valueOf(mexDao.getStatus());
if (status == Status.FAULT) {
FaultType f = e.addNewFault();
f.setType(mexDao.getFault());
f.setExplanation(mexDao.getFaultExplanation());
if (mexDao.getResponse() != null) {
f.setMessage(XmlObject.Factory.parse(mexDao.getResponse().getData()));
}
} else if (status == Status.FAILURE) {
e.addNewFailure().setExplanation(mexDao.getFaultExplanation());
} else {
if (mexDao.getResponse() != null) {
e.setOut(XmlObject.Factory.parse(mexDao.getResponse().getData()));
}
}
} catch (XmlException e1) {
__log.error("", e1);
}
e.setType(ExchangeType.Enum.forString("" + mexDao.getDirection()));
if (__log.isDebugEnabled()) {
__log.debug("---");
__log.debug("" + mexDao.getCallee());
__log.debug("" + mexDao.getChannel());
__log.debug("" + mexDao.getCreateTime());
__log.debug("" + mexDao.getEPR());
__log.debug("" + mexDao.getPortType());
}
if (e.getType() == ExchangeType.P) {
e.setService(mexDao.getPortType());
} else {
e.setService(mexDao.getCallee());
}
}
Collections.sort(list, new Comparator<Exchange>() {
public int compare(Exchange arg0, Exchange arg1) {
return arg0.getCreateTime().compareTo(arg1.getCreateTime());
}
});
for (Exchange e : list) {
result.addNewExchange().set(e);
}
return result;
}