public AvailableIUQuery(QueryContext queryContext) {
super(queryContext);
}
public Collector perform() {
Collector collector = new Collector();
IQueryable queryable = queryContext.getQueryable();
IProfile profile = ProvisioningUtils.getProfile();
if (queryable == null || profile == null) {
return collector;
}
Query query = new IUPropertyQuery(IInstallableUnit.PROP_TYPE_GROUP, Boolean.TRUE.toString());
if (queryContext.isShowLatestVersionsOnly()) {
query = new CompositeQuery(new Query[]{query, new LatestIUVersionQuery()});
}
collector = queryable.query(query, collector, null);
if (queryContext.isHideAlreadyInstalled()) {
Collector filteredCollection = new Collector();
for (Iterator itr = collector.iterator(); itr.hasNext();) {
IInstallableUnit iu = (IInstallableUnit) itr.next();
Collector tmpCollector = profile.query(new InstallableUnitQuery(iu.getId()), new Collector(), null);
if (tmpCollector.size() == 0) {
filteredCollection.accept(iu);
continue;
}
Iterator iter = tmpCollector.iterator();
while (iter.hasNext()) {
IInstallableUnit installed = (IInstallableUnit) iter.next();
if (installed.getVersion().compareTo(iu.getVersion()) < 0) {
filteredCollection.accept(iu);