Search in sources :

Example 1 with HibernatePersistentMapConverter

use of com.thoughtworks.xstream.hibernate.converter.HibernatePersistentMapConverter in project jgnash by ccavanaugh.

the class AbstractXStreamContainer method configureXStream.

static XStream configureXStream(final XStream xstream) {
    // gracefully ignore fields in the file that do not have object members
    xstream.ignoreUnknownElements();
    xstream.setMode(XStream.ID_REFERENCES);
    xstream.alias("Decimal", BigDecimal.class);
    xstream.alias("Account", Account.class);
    xstream.alias("RootAccount", RootAccount.class);
    xstream.alias("Budget", Budget.class);
    xstream.alias("BudgetGoal", BudgetGoal.class);
    xstream.alias("Config", Config.class);
    xstream.alias("CurrencyNode", CurrencyNode.class);
    xstream.alias("ExchangeRate", ExchangeRate.class);
    xstream.alias("ExchangeRateHistoryNode", ExchangeRateHistoryNode.class);
    xstream.alias("InvestmentTransaction", InvestmentTransaction.class);
    xstream.alias("BudgetPeriod", Period.class);
    xstream.alias("SecurityNode", SecurityNode.class);
    xstream.alias("SecurityHistoryNode", SecurityHistoryNode.class);
    xstream.alias("SecurityHistoryEvent", SecurityHistoryEvent.class);
    xstream.alias("Transaction", Transaction.class);
    xstream.alias("TransactionEntry", TransactionEntry.class);
    xstream.alias("TransactionEntryAddX", TransactionEntryAddX.class);
    xstream.alias("TransactionEntryBuyX", TransactionEntryBuyX.class);
    xstream.alias("TransactionEntryDividendX", TransactionEntryDividendX.class);
    xstream.alias("TransactionEntryMergeX", TransactionEntryMergeX.class);
    xstream.alias("TransactionEntryReinvestDivX", TransactionEntryReinvestDivX.class);
    xstream.alias("TransactionEntryRemoveX", TransactionEntryRemoveX.class);
    xstream.alias("TransactionEntrySellX", TransactionEntrySellX.class);
    xstream.alias("TransactionEntrySplitX", TransactionEntrySplitX.class);
    xstream.useAttributeFor(Account.class, "placeHolder");
    xstream.useAttributeFor(Account.class, "locked");
    xstream.useAttributeFor(Account.class, "visible");
    xstream.useAttributeFor(Account.class, "name");
    xstream.useAttributeFor(Account.class, "description");
    xstream.useAttributeFor(Budget.class, "description");
    xstream.useAttributeFor(Budget.class, "name");
    xstream.useAttributeFor(CommodityNode.class, "symbol");
    xstream.useAttributeFor(CommodityNode.class, "scale");
    xstream.useAttributeFor(CommodityNode.class, "prefix");
    xstream.useAttributeFor(CommodityNode.class, "suffix");
    xstream.useAttributeFor(CommodityNode.class, "description");
    xstream.useAttributeFor(SecurityHistoryNode.class, "date");
    xstream.useAttributeFor(SecurityHistoryNode.class, "price");
    xstream.useAttributeFor(SecurityHistoryNode.class, "high");
    xstream.useAttributeFor(SecurityHistoryNode.class, "low");
    xstream.useAttributeFor(SecurityHistoryNode.class, "volume");
    xstream.useAttributeFor(SecurityHistoryEvent.class, "date");
    xstream.useAttributeFor(SecurityHistoryEvent.class, "type");
    xstream.useAttributeFor(SecurityHistoryEvent.class, "value");
    xstream.useAttributeFor(StoredObject.class, "uuid");
    xstream.omitField(StoredObject.class, "markedForRemoval");
    // Ignore fields required for JPA
    xstream.omitField(StoredObject.class, "version");
    xstream.omitField(AmortizeObject.class, "id");
    xstream.omitField(BudgetGoal.class, "id");
    xstream.omitField(TransactionEntry.class, "id");
    xstream.omitField(ExchangeRateHistoryNode.class, "id");
    xstream.omitField(SecurityHistoryNode.class, "id");
    xstream.omitField(SecurityHistoryEvent.class, "id");
    // Filters out the hibernate
    xstream.registerConverter(new HibernateProxyConverter());
    xstream.registerConverter(new HibernatePersistentCollectionConverter(xstream.getMapper()));
    xstream.registerConverter(new HibernatePersistentMapConverter(xstream.getMapper()));
    xstream.registerConverter(new HibernatePersistentSortedMapConverter(xstream.getMapper()));
    xstream.registerConverter(new HibernatePersistentSortedSetConverter(xstream.getMapper()));
    // Converters for new Java time API
    xstream.registerConverter(new LocalDateConverter());
    xstream.registerConverter(new LocalDateTimeConverter());
    return xstream;
}
Also used : HibernatePersistentCollectionConverter(com.thoughtworks.xstream.hibernate.converter.HibernatePersistentCollectionConverter) HibernatePersistentSortedMapConverter(com.thoughtworks.xstream.hibernate.converter.HibernatePersistentSortedMapConverter) HibernatePersistentSortedSetConverter(com.thoughtworks.xstream.hibernate.converter.HibernatePersistentSortedSetConverter) HibernatePersistentMapConverter(com.thoughtworks.xstream.hibernate.converter.HibernatePersistentMapConverter) HibernateProxyConverter(com.thoughtworks.xstream.hibernate.converter.HibernateProxyConverter)

Example 2 with HibernatePersistentMapConverter

use of com.thoughtworks.xstream.hibernate.converter.HibernatePersistentMapConverter in project jgnash by ccavanaugh.

the class AccountTreeXMLFactory method getStream.

private static XStream getStream() {
    final XStream xstream = new XStream(new PureJavaReflectionProvider(), new KXml2Driver()) {

        @Override
        protected MapperWrapper wrapMapper(final MapperWrapper next) {
            return new HibernateMapper(next);
        }
    };
    // gracefully ignore fields in the file that do not have object members
    xstream.ignoreUnknownElements();
    xstream.setMode(XStream.ID_REFERENCES);
    xstream.alias("Account", Account.class);
    xstream.alias("RootAccount", RootAccount.class);
    xstream.alias("CurrencyNode", CurrencyNode.class);
    xstream.alias("SecurityNode", SecurityNode.class);
    xstream.useAttributeFor(Account.class, "placeHolder");
    xstream.useAttributeFor(Account.class, "locked");
    xstream.useAttributeFor(Account.class, "visible");
    xstream.useAttributeFor(Account.class, "name");
    xstream.useAttributeFor(Account.class, "description");
    xstream.useAttributeFor(CommodityNode.class, "symbol");
    xstream.useAttributeFor(CommodityNode.class, "scale");
    xstream.useAttributeFor(CommodityNode.class, "prefix");
    xstream.useAttributeFor(CommodityNode.class, "suffix");
    xstream.useAttributeFor(CommodityNode.class, "description");
    xstream.omitField(StoredObject.class, "uuid");
    xstream.omitField(StoredObject.class, "markedForRemoval");
    // Ignore fields required for JPA
    xstream.omitField(StoredObject.class, "version");
    xstream.omitField(Account.class, "transactions");
    xstream.omitField(Account.class, "accountBalance");
    xstream.omitField(Account.class, "reconciledBalance");
    xstream.omitField(Account.class, "attributes");
    xstream.omitField(Account.class, "propertyMap");
    xstream.omitField(Account.class, "amortizeObject");
    xstream.omitField(SecurityNode.class, "historyNodes");
    xstream.omitField(SecurityNode.class, "securityHistoryEvents");
    // Filters out the hibernate
    xstream.registerConverter(new HibernateProxyConverter());
    xstream.registerConverter(new HibernatePersistentCollectionConverter(xstream.getMapper()));
    xstream.registerConverter(new HibernatePersistentMapConverter(xstream.getMapper()));
    xstream.registerConverter(new HibernatePersistentSortedMapConverter(xstream.getMapper()));
    xstream.registerConverter(new HibernatePersistentSortedSetConverter(xstream.getMapper()));
    // Converters for new Java time API
    xstream.registerConverter(new LocalDateConverter());
    xstream.registerConverter(new LocalDateTimeConverter());
    return xstream;
}
Also used : HibernatePersistentCollectionConverter(com.thoughtworks.xstream.hibernate.converter.HibernatePersistentCollectionConverter) MapperWrapper(com.thoughtworks.xstream.mapper.MapperWrapper) LocalDateConverter(jgnash.engine.xstream.LocalDateConverter) KXml2Driver(com.thoughtworks.xstream.io.xml.KXml2Driver) HibernatePersistentSortedMapConverter(com.thoughtworks.xstream.hibernate.converter.HibernatePersistentSortedMapConverter) HibernatePersistentSortedSetConverter(com.thoughtworks.xstream.hibernate.converter.HibernatePersistentSortedSetConverter) XStream(com.thoughtworks.xstream.XStream) HibernateMapper(com.thoughtworks.xstream.hibernate.mapper.HibernateMapper) HibernatePersistentMapConverter(com.thoughtworks.xstream.hibernate.converter.HibernatePersistentMapConverter) PureJavaReflectionProvider(com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider) HibernateProxyConverter(com.thoughtworks.xstream.hibernate.converter.HibernateProxyConverter) LocalDateTimeConverter(jgnash.engine.xstream.LocalDateTimeConverter)

Aggregations

HibernatePersistentCollectionConverter (com.thoughtworks.xstream.hibernate.converter.HibernatePersistentCollectionConverter)2 HibernatePersistentMapConverter (com.thoughtworks.xstream.hibernate.converter.HibernatePersistentMapConverter)2 HibernatePersistentSortedMapConverter (com.thoughtworks.xstream.hibernate.converter.HibernatePersistentSortedMapConverter)2 HibernatePersistentSortedSetConverter (com.thoughtworks.xstream.hibernate.converter.HibernatePersistentSortedSetConverter)2 HibernateProxyConverter (com.thoughtworks.xstream.hibernate.converter.HibernateProxyConverter)2 XStream (com.thoughtworks.xstream.XStream)1 PureJavaReflectionProvider (com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider)1 HibernateMapper (com.thoughtworks.xstream.hibernate.mapper.HibernateMapper)1 KXml2Driver (com.thoughtworks.xstream.io.xml.KXml2Driver)1 MapperWrapper (com.thoughtworks.xstream.mapper.MapperWrapper)1 LocalDateConverter (jgnash.engine.xstream.LocalDateConverter)1 LocalDateTimeConverter (jgnash.engine.xstream.LocalDateTimeConverter)1