use of jgnash.engine.xstream.LocalDateConverter 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;
}
Aggregations