public Map<Integer, BuildResult> getLatestBuildResultsByProjectGroupId( int projectGroupId )
{
PersistenceManager pm = getPersistenceManager();
Transaction tx = pm.currentTransaction();
try
{
tx.begin();
Extent extent = pm.getExtent( BuildResult.class, true );
Query query = pm.newQuery( extent );
String filter = "this.project.latestBuildId == this.id";
if ( projectGroupId > 0 )
{
query.declareParameters( "int projectGroupId" );
filter += " && this.project.projectGroup.id == projectGroupId";
}
query.setFilter( filter );
List<BuildResult> result;
if ( projectGroupId > 0 )
{
result = (List<BuildResult>) query.execute( projectGroupId );
}
else
{
result = (List<BuildResult>) query.execute();
}
result = (List<BuildResult>) pm.detachCopyAll( result );
tx.commit();
if ( result != null && !result.isEmpty() )
{
Map<Integer, BuildResult> builds = new HashMap<Integer, BuildResult>();