Search in sources :

Example 6 with TransactionInfo

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

the class TransactionManagerTest method testRegisterTransactionInfo.

/**
 * tests the registerTransactionInfo
 */
@Test
public void testRegisterTransactionInfo() {
    // test
    transactionManager.registerTransactionInfo(new ContextKey("testBean", null, "DEF", "cust-code"), new TransactionInfo());
    // verify
    verify(transactionRepoMock).register(eq(new ContextKey("testBean", null, "DEF", "cust-code")), Matchers.anyObject());
}
Also used : ContextKey(org.jaffa.loader.ContextKey) TransactionInfo(org.jaffa.transaction.services.configdomain.TransactionInfo) Test(org.junit.Test)

Example 7 with TransactionInfo

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

the class TransactionEngine method getAccessibleSubTypeNames.

/**
 * Returns an array of Transaction SubType names, as defined in the configuration file.
 * The array will contain the accessible SubTypes only.
 *
 * @return an array of Transaction SubType names, as defined in the configuration file.
 */
public String[] getAccessibleSubTypeNames() {
    Collection<String> subTypes = new LinkedHashSet<String>();
    TransactionInfo[] allTransactionInfo = ConfigurationService.getInstance().getAllTransactionInfo();
    for (TransactionInfo transactionInfo : allTransactionInfo) {
        if (transactionInfo != null && transactionInfo.getSubType() != null && transactionInfo.getSubType().length() > 0 && hasBrowseAccess(transactionInfo.getType())) {
            subTypes.add(transactionInfo.getSubType());
        }
    }
    return subTypes.toArray(new String[subTypes.size()]);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) TransactionInfo(org.jaffa.transaction.services.configdomain.TransactionInfo)

Example 8 with TransactionInfo

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

the class TransactionManager method getTransactionInfo.

/**
 * Returns the TransactionInfo object for the input dataBeanClass, as defined in the configuration file.
 *
 * @param dataBeanClass the class for a dataBean.
 * @return the TransactionInfo object for the input dataBeanClass, as defined in the configuration file.
 */
public TransactionInfo getTransactionInfo(Class dataBeanClass) {
    final String dataBeanClassName = dataBeanClass.getName();
    TransactionInfo transactionInfo = getTransactionInfo(dataBeanClassName);
    if (transactionInfo == null) {
        // Lookup the class heirarchy. Add a NULL for the dataBeanClassName, even if a TransactionInfo is not found
        ContextKey superClassContextKey = null;
        while (dataBeanClass.getSuperclass() != null) {
            dataBeanClass = dataBeanClass.getSuperclass();
            transactionInfo = getTransactionInfo(dataBeanClass.getName());
            superClassContextKey = getTransactionRepository().findKey(dataBeanClass.getName());
            if (transactionInfo != null)
                break;
        }
        if (superClassContextKey != null) {
            registerTransactionInfo(new ContextKey(transactionInfo.getDataBean(), superClassContextKey.getFileName(), superClassContextKey.getVariation(), superClassContextKey.getPrecedence()), transactionInfo);
        }
    }
    return transactionInfo;
}
Also used : ContextKey(org.jaffa.loader.ContextKey) TransactionInfo(org.jaffa.transaction.services.configdomain.TransactionInfo)

Example 9 with TransactionInfo

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

the class TransactionManager method unregisterResource.

/**
 * {@inheritDoc}
 */
@Override
public void unregisterResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
    Config config = JAXBHelper.unmarshalConfigFile(Config.class, resource, 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(), resource.getURI().toString(), variation, context);
                unregisterTransactionInfo(contextKey);
            } else if (o.getClass() == TypeInfo.class) {
                final TypeInfo typeInfo = (TypeInfo) o;
                ContextKey contextKey = new ContextKey(typeInfo.getName(), resource.getURI().toString(), 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) TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo)

Example 10 with TransactionInfo

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

the class TransactionManager method registerResource.

/**
 * {@inheritDoc}
 */
@Override
public void registerResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
    Config config = JAXBHelper.unmarshalConfigFile(Config.class, resource, 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(), resource.getURI().toString(), variation, context);
                registerTransactionInfo(contextKey, transactionInfo);
            } else if (o.getClass() == TypeInfo.class) {
                final TypeInfo typeInfo = (TypeInfo) o;
                ContextKey contextKey = new ContextKey(typeInfo.getName(), resource.getURI().toString(), variation, context);
                registerTypeInfo(contextKey, typeInfo);
            }
        }
    }
}
Also used : ContextKey(org.jaffa.loader.ContextKey) Config(org.jaffa.transaction.services.configdomain.Config) TransactionInfo(org.jaffa.transaction.services.configdomain.TransactionInfo) TypeInfo(org.jaffa.transaction.services.configdomain.TypeInfo)

Aggregations

TransactionInfo (org.jaffa.transaction.services.configdomain.TransactionInfo)11 ContextKey (org.jaffa.loader.ContextKey)5 TransactionField (org.jaffa.transaction.domain.TransactionField)3 Config (org.jaffa.transaction.services.configdomain.Config)3 TypeInfo (org.jaffa.transaction.services.configdomain.TypeInfo)3 UOW (org.jaffa.persistence.UOW)2 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 ApplicationException (org.jaffa.exceptions.ApplicationException)1 FrameworkException (org.jaffa.exceptions.FrameworkException)1 JaffaMessagingFrameworkException (org.jaffa.modules.messaging.services.JaffaMessagingFrameworkException)1 IllegalPersistentStateRuntimeException (org.jaffa.persistence.exceptions.IllegalPersistentStateRuntimeException)1 PostLoadFailedException (org.jaffa.persistence.exceptions.PostLoadFailedException)1 QueryFailedException (org.jaffa.persistence.exceptions.QueryFailedException)1 Transaction (org.jaffa.transaction.domain.Transaction)1 TransactionPayload (org.jaffa.transaction.domain.TransactionPayload)1