Search in sources :

Example 1 with TypeInfo

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

the class TransactionManager method unregisterXML.

/**
 * unregisters all the transactions and typeInfo in the xml from the repository
 * @param uri for the xml location
 */
public void unregisterXML(String uri, String context, String variation) throws JAXBException, SAXException, IOException {
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    Config config = JAXBHelper.unmarshalConfigFile(Config.class, resolver.getResource(uri), CONFIGURATION_SCHEMA_FILE);
    if (config.getTransactionOrType() != null) {
        for (final Object o : config.getTransactionOrType()) {
            if (o.getClass() == TransactionInfo.class) {
                final TransactionInfo transactionInfo = (TransactionInfo) o;
                ContextKey contextKey = new ContextKey(transactionInfo.getDataBean(), uri, variation, context);
                unregisterTransactionInfo(contextKey);
            } else if (o.getClass() == TypeInfo.class) {
                final TypeInfo typeInfo = (TypeInfo) o;
                ContextKey contextKey = new ContextKey(typeInfo.getName(), uri, variation, context);
                unregisterTypeInfo(contextKey);
            }
        }
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Config(org.jaffa.transaction.services.configdomain.Config) TransactionInfo(org.jaffa.transaction.services.configdomain.TransactionInfo) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo)

Example 2 with TypeInfo

use of org.jaffa.transaction.services.configdomain.TypeInfo 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 3 with TypeInfo

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

the class TransactionEngine method getAccessibleTypeNamesWithLabels.

/**
 * Returns an array of Transaction Types with Labels, as defined in the configuration file.
 * The array will contain the accessible Types only.
 *
 * @return an array of Transaction Type names, as defined in the configuration file.
 */
public String[] getAccessibleTypeNamesWithLabels() {
    String[] typeNames = ConfigurationService.getInstance().getTypeNames();
    if (typeNames != null && typeNames.length > 0) {
        List<String> accessibleTypeNames = new LinkedList<String>();
        for (String typeName : typeNames) {
            TypeInfo typeInfo = ConfigurationService.getInstance().getTypeInfo(typeName);
            if (hasBrowseAccess(typeInfo)) {
                accessibleTypeNames.add(typeInfo.getLabel() + "=" + typeName);
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("No browse access to " + typeName);
                }
            }
        }
        typeNames = accessibleTypeNames.toArray(new String[accessibleTypeNames.size()]);
    }
    return typeNames;
}
Also used : TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo) LinkedList(java.util.LinkedList)

Example 4 with TypeInfo

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

the class TransactionEngine method getAccessibleTypeNames.

/**
 * Returns an array of Transaction Type names, as defined in the configuration file.
 * The array will contain the accessible Types only.
 *
 * @return an array of Transaction Type names, as defined in the configuration file.
 */
public String[] getAccessibleTypeNames() {
    String[] typeNames = ConfigurationService.getInstance().getTypeNames();
    if (typeNames != null && typeNames.length > 0) {
        List<String> accessibleTypeNames = new LinkedList<String>();
        for (String typeName : typeNames) {
            TypeInfo typeInfo = ConfigurationService.getInstance().getTypeInfo(typeName);
            if (hasBrowseAccess(typeInfo)) {
                accessibleTypeNames.add(typeName);
            } else {
                if (log.isDebugEnabled()) {
                    log.debug("No browse access to " + typeName);
                }
            }
        }
        typeNames = accessibleTypeNames.toArray(new String[accessibleTypeNames.size()]);
    }
    return typeNames;
}
Also used : TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo) LinkedList(java.util.LinkedList)

Example 5 with TypeInfo

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

the class TransactionManagerTest method testUnRegisterTypeInfo.

/**
 * tests the unregisterTypeInfo
 */
@Test
public void testUnRegisterTypeInfo() {
    // initialize
    TypeInfo typeInfo = new TypeInfo();
    typeInfo.setName("typeInfoName");
    ContextKey key = new ContextKey("typeInfoName", null, "DEF", "cust-code");
    // test
    transactionManager.unregisterTypeInfo(key);
    // verify
    verify(typeInfoRepoMock).unregister(eq(key));
}
Also used : ContextKey(org.jaffa.loader.ContextKey) TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo) Test(org.junit.Test)

Aggregations

TypeInfo (org.jaffa.transaction.services.configdomain.TypeInfo)9 ContextKey (org.jaffa.loader.ContextKey)5 LinkedList (java.util.LinkedList)3 Config (org.jaffa.transaction.services.configdomain.Config)3 TransactionInfo (org.jaffa.transaction.services.configdomain.TransactionInfo)3 DisplayParam (org.jaffa.transaction.services.configdomain.DisplayParam)2 Test (org.junit.Test)2 LinkedHashMap (java.util.LinkedHashMap)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 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)1