if (!x.equals(Inode.class) && !x.equals(Clickstream.class) && !x.equals(ClickstreamRequest.class) && !x.equals(Clickstream404.class))
_tablesToDump.add(x);
}
XStream _xstream = null;
HibernateUtil _dh = null;
List _list = null;
File _writing = null;
BufferedOutputStream _bout = null;
for (Class clazz : _tablesToDump) {
//http://jira.dotmarketing.net/browse/DOTCMS-5031
if(PermissionReference.class.equals(clazz)){
continue;
}
_xstream = new XStream(new DomDriver());
//http://jira.dotmarketing.net/browse/DOTCMS-6059
if(clazz.equals(DashboardSummary404.class) || clazz.equals(DashboardUserPreferences.class)){
_xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.Set.class, java.util.Set.class);
_xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.List.class, java.util.List.class);
_xstream.addDefaultImplementation(com.dotcms.repackage.net.sf.hibernate.collection.Map.class, java.util.Map.class);
Mapper mapper = _xstream.getMapper();
_xstream.registerConverter(new HibernateCollectionConverter(mapper));
_xstream.registerConverter(new HibernateMapConverter(mapper));
}
/*
* String _shortClassName =
* clazz.getName().substring(clazz.getName().lastIndexOf("."),clazz.getName().length());
* xstream.alias(_shortClassName, clazz);
*/
int i= 0;
int step = 1000;
int total =0;
java.text.NumberFormat formatter = new java.text.DecimalFormat("0000000000");
/* we will only export 10,000,000 items of any given type */
for(i=0;i < 10000000;i=i+step){
_dh = new HibernateUtil(clazz);
_dh.setFirstResult(i);
_dh.setMaxResults(step);
//This line was previously like;
//_dh.setQuery("from " + clazz.getName() + " order by 1,2");
//This caused a problem when the database is Oracle because Oracle causes problems when the results are ordered
//by an NCLOB field. In the case of containers table, the second field, CODE, is an NCLOB field. Because of this,
//ordering is done only on the first field for the tables, which is INODE
if(com.dotmarketing.beans.Tree.class.equals(clazz)){
_dh.setQuery("from " + clazz.getName() + " order by parent, child, relation_type");
}
else if(MultiTree.class.equals(clazz)){
_dh.setQuery("from " + clazz.getName() + " order by parent1, parent2, child, relation_type");
}
else if(TagInode.class.equals(clazz)){
_dh.setQuery("from " + clazz.getName() + " order by inode, tag_id");
}
else if(Tag.class.equals(clazz)){
_dh.setQuery("from " + clazz.getName() + " order by tag_id, tagname");
}
else if(CalendarReminder.class.equals(clazz)){
_dh.setQuery("from " + clazz.getName() + " order by user_id, event_id, send_date");
}
else if(Identifier.class.equals(clazz)){
_dh.setQuery("from " + clazz.getName() + " order by parent_path");
} else {
_dh.setQuery("from " + clazz.getName() + " order by 1");
}
_list = _dh.list();
if(_list.size() ==0){
try {
_bout.close();
}
catch( java.lang.NullPointerException npe){}