Skip to content

Instantly share code, notes, and snippets.

@magomi
Created February 20, 2011 00:08
Show Gist options
  • Save magomi/835534 to your computer and use it in GitHub Desktop.
Save magomi/835534 to your computer and use it in GitHub Desktop.
everything is fine now
package nl.topicus.onderwijs.dashboard.modules.standard;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import nl.topicus.onderwijs.dashboard.datasources.Commits;
import nl.topicus.onderwijs.dashboard.datatypes.Commit;
import nl.topicus.onderwijs.dashboard.keys.Key;
import nl.topicus.onderwijs.dashboard.modules.DataSource;
import nl.topicus.onderwijs.dashboard.modules.DashboardRepository;
import nl.topicus.onderwijs.dashboard.web.WicketApplication;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CommitSumImpl implements Commits {
private static final Logger log = LoggerFactory.getLogger(CommitSumImpl.class);
public CommitSumImpl() {
}
@Override
public List<Commit> getValue() {
List<Commit> ret = new ArrayList<Commit>();
DashboardRepository repository = WicketApplication.get().getRepository();
for (Key curKey : repository.getKeys(Key.class)) {
log.trace("curKey = {}", curKey);
Collection<DataSource<?>> dataSources = repository.getData(curKey);
for (DataSource<?> curDataSource : dataSources) {
log.trace("curDataSource = {}", curDataSource);
if (curDataSource instanceof CommitSumImpl) {
continue;
}
if (curDataSource instanceof Commits) {
List<Commit> newCommits = ((Commits) curDataSource).getValue();
if (newCommits != null) {
ret.addAll(newCommits);
}
}
}
}
return ret;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment