Collection<ProjectGroup> projectGroups = retrieveAllProjectGroups( pmf );
database.setProjectGroups( new ArrayList<ProjectGroup>( projectGroups ) );
database.setSchedules( retrieveAllSchedules( pmf ) );
ContinuumStaxWriter writer = new ContinuumStaxWriter();
backupDirectory.mkdirs();
OutputStream out = new FileOutputStream( new File( backupDirectory, BUILDS_XML ) );
Writer fileWriter = new OutputStreamWriter( out, Charset.forName( database.getModelEncoding() ) );
try
{
writer.write( fileWriter, database );
}
catch ( XMLStreamException e )
{
throw new DataManagementException( "Modello failure: unable to write data to StAX writer", e );
}