Search in sources :

Example 1 with DisplayParam

use of org.jaffa.transaction.services.configdomain.DisplayParam 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;
}
Also used : MessageDependency(org.jaffa.qm.apis.data.MessageDependency) TransactionField(org.jaffa.transaction.domain.TransactionField) TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo) MessageField(org.jaffa.qm.apis.data.MessageField) LinkedHashMap(java.util.LinkedHashMap) MessageGraph(org.jaffa.qm.apis.data.MessageGraph) DisplayParam(org.jaffa.transaction.services.configdomain.DisplayParam) TransactionDependency(org.jaffa.transaction.domain.TransactionDependency)

Example 2 with DisplayParam

use of org.jaffa.transaction.services.configdomain.DisplayParam in project jaffa-framework by jaffa-projects.

the class TransactionAdmin method createQueueMetaData.

/**
 * Creates MetaData for the input Type, based on the available fields in the PropertyFilter.
 */
private static QueueMetaData createQueueMetaData(String type, PropertyFilter pf) {
    QueueMetaData qmd = null;
    if (pf.isFieldIncluded("queueMetaData")) {
        qmd = new QueueMetaData();
        if (pf.isFieldIncluded("queueMetaData.queueSystemId")) {
            qmd.setQueueSystemId(QUEUE_SYSTEM_ID);
        }
        if (pf.isFieldIncluded("queueMetaData.type")) {
            qmd.setType(type);
        }
        if (pf.isFieldIncluded("queueMetaData.supportedMessageStatus")) {
            qmd.setSupportedMessageStatus(SUPPORTED_MESSAGE_STATUS);
        }
        if (pf.isFieldIncluded("queueMetaData.supportedApplicationFields")) {
            TypeInfo typeInfo = ConfigurationService.getInstance().getTypeInfo(type);
            if (typeInfo != null && typeInfo.getDisplayParam() != null) {
                Collection<MessageFieldMetaData> supportedApplicationFields = new LinkedList<MessageFieldMetaData>();
                for (DisplayParam displayParam : typeInfo.getDisplayParam()) {
                    MessageFieldMetaData supportedApplicationField = new MessageFieldMetaData();
                    if (pf.isFieldIncluded("queueMetaData.supportedApplicationFields.name")) {
                        supportedApplicationField.setName(displayParam.getName());
                    }
                    if (pf.isFieldIncluded("queueMetaData.supportedApplicationFields.label")) {
                        supportedApplicationField.setLabel(MessageHelper.replaceTokens(displayParam.getLabel()));
                    }
                    supportedApplicationFields.add(supportedApplicationField);
                }
                if (!supportedApplicationFields.isEmpty()) {
                    qmd.setSupportedApplicationFields(supportedApplicationFields.toArray(new MessageFieldMetaData[supportedApplicationFields.size()]));
                }
            }
        }
        if (pf.isFieldIncluded("queueMetaData.supportsTechnicalFields")) {
            qmd.setSupportsTechnicalFields(SUPPORTS_TECHNICAL_FIELDS);
        }
        if (pf.isFieldIncluded("queueMetaData.supportsBusinessEventLogs")) {
            qmd.setSupportsBusinessEventLogs(SUPPORTS_BUSINESS_EVENT_LOGS);
        }
        if (pf.isFieldIncluded("queueMetaData.supportsDependencies")) {
            qmd.setSupportsDependencies(SUPPORTS_DEPENDENCIES);
        }
    }
    return qmd;
}
Also used : MessageFieldMetaData(org.jaffa.qm.apis.data.MessageFieldMetaData) QueueMetaData(org.jaffa.qm.apis.data.QueueMetaData) TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo) DisplayParam(org.jaffa.transaction.services.configdomain.DisplayParam) LinkedList(java.util.LinkedList)

Aggregations

DisplayParam (org.jaffa.transaction.services.configdomain.DisplayParam)2 TypeInfo (org.jaffa.transaction.services.configdomain.TypeInfo)2 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 MessageDependency (org.jaffa.qm.apis.data.MessageDependency)1 MessageField (org.jaffa.qm.apis.data.MessageField)1 MessageFieldMetaData (org.jaffa.qm.apis.data.MessageFieldMetaData)1 MessageGraph (org.jaffa.qm.apis.data.MessageGraph)1 QueueMetaData (org.jaffa.qm.apis.data.QueueMetaData)1 TransactionDependency (org.jaffa.transaction.domain.TransactionDependency)1 TransactionField (org.jaffa.transaction.domain.TransactionField)1