use of org.jaffa.qm.apis.data.MessageDependency in project jaffa-framework by jaffa-projects.
the class TransactionAdmin method createMessageGraph.
/**
* Molds the input Transaction into a MessageGraph.
*/
private static MessageGraph createMessageGraph(Transaction transaction, PropertyFilter pf) throws FrameworkException {
MessageGraph graph = new MessageGraph();
graph.setQueueMetaData(createQueueMetaData(transaction.getSubType(), pf));
if (pf.isFieldIncluded("type")) {
graph.setType(transaction.getType());
}
if (pf.isFieldIncluded("subType")) {
graph.setSubType(transaction.getSubType());
}
if (pf.isFieldIncluded("messageId")) {
graph.setMessageId(transaction.getId());
}
if (pf.isFieldIncluded("direction")) {
graph.setDirection(transaction.getDirection());
}
if (pf.isFieldIncluded("status")) {
graph.setStatus(transactionToMessageStatus(transaction.getStatus()));
}
if (pf.isFieldIncluded("createdOn")) {
graph.setCreatedOn(transaction.getCreatedOn());
}
if (pf.isFieldIncluded("createdBy")) {
graph.setCreatedBy(transaction.getCreatedBy());
}
if (pf.isFieldIncluded("lastChangedOn")) {
graph.setLastChangedOn(transaction.getLastChangedOn());
}
if (pf.isFieldIncluded("lastChangedBy")) {
graph.setLastChangedBy(transaction.getLastChangedBy());
}
if (pf.isFieldIncluded("errorMessage")) {
graph.setErrorMessage(transaction.getErrorMessage());
}
if (pf.isFieldIncluded("payload")) {
graph.setPayload(transaction.getTransactionPayloadObject() != null ? transaction.getTransactionPayloadObject().returnInternalPayload() : null);
}
if (pf.isFieldIncluded("hasAdminAccess")) {
graph.setHasAdminAccess(TransactionEngine.getInstance().hasAdminAccess(transaction.getType()));
}
if (pf.isFieldIncluded("applicationFields")) {
Map<String, MessageField> applicationFields = new LinkedHashMap<String, MessageField>();
TransactionField[] transactionFields = transaction.getTransactionFieldArray();
if (transactionFields != null && transactionFields.length > 0) {
for (int i = 0; i < transactionFields.length; i++) {
TransactionField transactionField = transactionFields[i];
MessageField applicationField = new MessageField();
applicationField.setName(transactionField.getFieldName());
applicationField.setValue(transactionField.getValue());
applicationFields.put(applicationField.getName(), applicationField);
}
}
// Add labels to the application-fields from the configuration-file
TypeInfo typeInfo = ConfigurationService.getInstance().getTypeInfo(transaction.getType());
if (typeInfo != null && typeInfo.getDisplayParam() != null) {
for (DisplayParam displayParam : typeInfo.getDisplayParam()) {
if (displayParam.getLabel() != null && applicationFields.containsKey(displayParam.getName())) {
applicationFields.get(displayParam.getName()).setLabel(MessageHelper.replaceTokens(displayParam.getLabel()));
}
}
}
if (!applicationFields.isEmpty()) {
graph.setApplicationFields(applicationFields.values().toArray(new MessageField[applicationFields.size()]));
}
}
if (pf.isFieldIncluded("messageDependencies")) {
TransactionDependency[] transactionDependencies = transaction.getTransactionDependencyArray();
if (transactionDependencies != null && transactionDependencies.length > 0) {
MessageDependency[] messageDependencies = new MessageDependency[transactionDependencies.length];
for (int i = 0; i < transactionDependencies.length; i++) {
TransactionDependency transactionDependency = transactionDependencies[i];
MessageDependency messageDependency = new MessageDependency();
messageDependency.setDependsOnId(transactionDependency.getDependsOnId());
if (transactionDependency.getStatus() != null) {
MessageDependency.Status messageDependencyStatus = null;
TransactionDependency.Status transactionDependencyStatus = TransactionDependency.Status.valueOf(transactionDependency.getStatus());
switch(transactionDependencyStatus) {
case O:
messageDependencyStatus = MessageDependency.Status.OPEN;
break;
case S:
messageDependencyStatus = MessageDependency.Status.SUCCESS;
break;
}
messageDependency.setStatus(messageDependencyStatus);
}
messageDependencies[i] = messageDependency;
}
graph.setMessageDependencies(messageDependencies);
}
}
return graph;
}
Aggregations