summary.setCreatedTime(driftChangeSet.getCtime());
if (version > 0) {
for (FileEntry entry : reader) {
boolean addToList = storeBinaryContent || !DriftUtil.isBinaryFile(entry.getFile());
JPADriftFile oldDriftFile = getDriftFile(entry.getOldSHA(), driftFilesToRequest, addToList);
JPADriftFile newDriftFile = getDriftFile(entry.getNewSHA(), driftFilesToRequest, addToList);
// TODO Figure out an efficient way to save coverage change sets.
// The initial/coverage change set could contain hundreds or even thousands
// of entries. We probably want to consider doing some kind of batch insert
//
// jsanda
// use a path with only forward slashing to ensure consistent paths across reports
String path = FileUtil.useForwardSlash(entry.getFile());
JPADrift drift = new JPADrift(driftChangeSet, path, entry.getType(), oldDriftFile,
newDriftFile);
entityManager.persist(drift);
// we are taking advantage of the fact that we know the summary is only used by the server
// if the change set is a DRIFT report. If its a coverage report, it is not used (we do
// not alert on coverage reports) - so don't waste memory by collecting all the paths
// when we know they aren't going to be used anyway.
if (category == DriftChangeSetCategory.DRIFT) {
summary.addDriftPathname(path);
}
}
} else {
summary.setInitialChangeSet(true);
JPADriftSet driftSet = new JPADriftSet();
for (FileEntry entry : reader) {
boolean addToList = storeBinaryContent || !DriftUtil.isBinaryFile(entry.getFile());
JPADriftFile newDriftFile = getDriftFile(entry.getNewSHA(), driftFilesToRequest, addToList);
String path = FileUtil.useForwardSlash(entry.getFile());
// A Drift always has a changeSet. Note that in this code section the changeset is
// always going to be set to a DriftDefinition's changeSet. But that is not always the
// case, it could also be set to a DriftDefinitionTemplate's changeSet.
driftSet.addDrift(new JPADrift(driftChangeSet, path, entry.getType(), null, newDriftFile));