/*
* Copyright 2009-2010 WSO2, Inc. (http://wso2.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.component.mgt.core.query;
import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
import org.eclipse.equinox.internal.provisional.p2.engine.IUProfilePropertyQuery;
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.internal.provisional.p2.query.Collector;
import org.eclipse.equinox.internal.provisional.p2.query.IQueryable;
import org.eclipse.equinox.internal.provisional.p2.query.Query;
import org.wso2.carbon.component.mgt.core.util.ProvisioningUtils;
public class InstalledIUQuery extends IUQuery {
public InstalledIUQuery(QueryContext queryContext) {
super(queryContext);
}
public Collector perform() {
Collector collector = new Collector();
IQueryable queryable = queryContext.getQueryable();
IProfile profile = ProvisioningUtils.getProfile();
Query query = queryContext.getQuery();
if (queryable == null || profile == null) {
return collector;
}
//If the query is not set, return the list of IUs which has the property "org.eclipse.equinox.p2.type.root"
if (query == null) {
query = new IUProfilePropertyQuery(profile, IInstallableUnit.PROP_PROFILE_ROOT_IU,
Boolean.TRUE.toString());
}
return queryable.query(query, collector, null);
}
}