import net.java.ao.Entity; //导入依赖的package包/类
@Override
public Void call()
{
try
{
long startTime = System.currentTimeMillis();
log.debug("Running SmartcommitOperation ... ");
changesetDao.forEachLatestChangesetsAvailableForSmartcommitDo(repository.getId(),
new String[] {ID, MESSAGE, NODE, AUTHOR_EMAIL, DATE}, // the columns used in the closure below
new ForEachChangesetClosure()
{
@Override
public void execute(Entity mapping)
{
ChangesetMapping changesetMapping = (ChangesetMapping) mapping;
log.debug("Processing message \n {} \n for smartcommits. Changeset id = {} node = {}.", new Object[]
{changesetMapping.getMessage(), changesetMapping.getID(), changesetMapping.getNode()});
// first mark as processed
changesetDao.markSmartcommitAvailability(changesetMapping.getID(), false);
// parse message
CommitCommands commands = commitMessageParser.parseCommitComment(changesetMapping.getMessage());
commands.setCommitDate(changesetMapping.getDate());
commands.setAuthorEmail(changesetMapping.getAuthorEmail());
// do commands
if (CollectionUtils.isNotEmpty(commands.getCommands()))
{
final CommandsResults commandsResults = smartcommitsService.doCommands(commands);
if (commandsResults.hasErrors())
{
Changeset changeset = changesetDao.getByNode(repository.getId(), changesetMapping.getNode());
if (changeset != null)
{
final String commitUrl = changesetService.getCommitUrl(repository, changeset);
List smartCommitErrors = new ArrayList();
for (String error : commandsResults.getAllErrors())
{
SmartCommitError sce = new SmartCommitError(changeset.getNode(), commitUrl, error);
smartCommitErrors.add(sce);
}
if (progress != null)
{
progress.setSmartCommitErrors(smartCommitErrors);
}
}
}
}
}
});
log.debug("Smartcommits for repository {} were processed in {} ms", repository.getId(), System.currentTimeMillis() - startTime);
}
catch (Exception e)
{
log.warn("Failed to process smartcommit operation. Cause = " + e.getClass() + " : " + e.getMessage());
}
return null;
}