use of org.apache.commons.collections.Closure in project gocd by gocd.
the class BuildAssignmentService method pipelineConfigChangedListener.
protected EntityConfigChangedListener<PipelineConfig> pipelineConfigChangedListener() {
return new EntityConfigChangedListener<PipelineConfig>() {
@Override
public void onEntityConfigChange(PipelineConfig pipelineConfig) {
LOGGER.info("[Configuration Changed] Removing deleted jobs for pipeline {}.", pipelineConfig.name());
synchronized (BuildAssignmentService.this) {
List<JobPlan> jobsToRemove = new ArrayList<>();
for (JobPlan jobPlan : jobPlans) {
if (pipelineConfig.name().equals(new CaseInsensitiveString(jobPlan.getPipelineName()))) {
StageConfig stageConfig = pipelineConfig.findBy(new CaseInsensitiveString(jobPlan.getStageName()));
if (stageConfig != null) {
JobConfig jobConfig = stageConfig.jobConfigByConfigName(new CaseInsensitiveString(jobPlan.getName()));
if (jobConfig == null) {
jobsToRemove.add(jobPlan);
}
} else {
jobsToRemove.add(jobPlan);
}
}
}
forAllDo(jobsToRemove, new Closure() {
@Override
public void execute(Object o) {
removeJob((JobPlan) o);
}
});
}
}
};
}
use of org.apache.commons.collections.Closure in project opencast by opencast.
the class DublinCoreCatalog method get.
@Override
@SuppressWarnings("unchecked")
public List<String> get(EName property, final String language) {
RequireUtil.notNull(property, "property");
RequireUtil.notNull(language, "language");
if (LANGUAGE_ANY.equals(language)) {
return (List<String>) CollectionUtils.collect(getValuesAsList(property), new Transformer() {
@Override
public Object transform(Object o) {
return ((CatalogEntry) o).getValue();
}
});
} else {
final List<String> values = new ArrayList<String>();
final boolean langUndef = LANGUAGE_UNDEFINED.equals(language);
CollectionUtils.forAllDo(getValuesAsList(property), new Closure() {
@Override
public void execute(Object o) {
CatalogEntry c = (CatalogEntry) o;
String lang = c.getAttribute(XML_LANG_ATTR);
if ((langUndef && lang == null) || (language.equals(lang)))
values.add(c.getValue());
}
});
return values;
}
}
Aggregations