Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2011-02-05 05:07:50 +0000
committerPascal Rapicault2011-02-05 05:07:50 +0000
commit35f252c4748e35ef2a3cd0db393496658fed68ae (patch)
tree7478dd18f71e51147b1b570092dae5e401188de9 /bundles/org.eclipse.equinox.p2.director.app
parent975d5dd7507064d2dc7be54456ecee41c79d3a50 (diff)
downloadrt.equinox.p2-35f252c4748e35ef2a3cd0db393496658fed68ae.tar.gz
rt.equinox.p2-35f252c4748e35ef2a3cd0db393496658fed68ae.tar.xz
rt.equinox.p2-35f252c4748e35ef2a3cd0db393496658fed68ae.zip
Support for listing groups from a repository and using queries in -list
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.director.app')
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF1
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java52
-rw-r--r--bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/PrettyQuery.java43
3 files changed, 75 insertions, 21 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF
index 6515e7544..99d0b36e8 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.director.app/META-INF/MANIFEST.MF
@@ -20,6 +20,7 @@ Import-Package: org.eclipse.equinox.app,
org.eclipse.equinox.p2.engine;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.engine.query;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.metadata;version="[2.0.0,3.0.0)",
+ org.eclipse.equinox.p2.metadata.expression;version="2.0.0",
org.eclipse.equinox.p2.planner;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.query;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository;version="[2.0.0,3.0.0)",
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
index 93aca0d75..76ec0df3c 100644
--- a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/DirectorApplication.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -140,6 +140,9 @@ public class DirectorApplication implements IApplication {
static private final String NO_ARTIFACT_REPOSITORIES_AVAILABLE = "noArtifactRepositoriesAvailable"; //$NON-NLS-1$
private static final String FOLLOW_ARTIFACT_REPOSITORY_REFERENCES = "org.eclipse.equinox.p2.director.followArtifactRepositoryReferences"; //$NON-NLS-1$
+ private static final String LIST_GROUPS_SHORTCUT = "Q:GROUP"; //$NON-NLS-1$
+ private static final String QUERY_SEPARATOR = "Q:"; //$NON-NLS-1$
+ private static final String QUERY_SEPARATOR_SMALL = "q:"; //$NON-NLS-1$
public static final String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
@@ -181,10 +184,23 @@ public class DirectorApplication implements IApplication {
return null;
}
- private static void parseIUsArgument(List<IVersionedId> vnames, String arg) {
+ private static void parseIUsArgument(List<IQuery<IInstallableUnit>> vnames, String arg) {
String[] roots = StringHelper.getArrayFromString(arg, ',');
- for (int i = 0; i < roots.length; ++i)
- vnames.add(VersionedId.parse(roots[i]));
+ for (int i = 0; i < roots.length; ++i) {
+ if (roots[i].equalsIgnoreCase(LIST_GROUPS_SHORTCUT)) {
+ vnames.add(new PrettyQuery<IInstallableUnit>(QueryUtil.createIUGroupQuery(), "All groups")); //$NON-NLS-1$
+ continue;
+ }
+ if (roots[i].startsWith(QUERY_SEPARATOR) || roots[i].startsWith(QUERY_SEPARATOR_SMALL)) {
+ String queryString = roots[i].substring(2);
+ vnames.add(new PrettyQuery<IInstallableUnit>(QueryUtil.createQuery(queryString, new Object[0]), queryString));
+ continue;
+ }
+ IVersionedId vId = VersionedId.parse(roots[i]);
+ Version v = vId.getVersion();
+ IQuery<IInstallableUnit> query = new PrettyQuery<IInstallableUnit>(QueryUtil.createIUQuery(vId.getId(), Version.emptyVersion.equals(v) ? VersionRange.emptyRange : new VersionRange(v, true, v, true)), roots[i]);
+ vnames.add(query);
+ }
}
private static File processFileArgument(String arg) {
@@ -203,9 +219,9 @@ public class DirectorApplication implements IApplication {
private final List<URI> artifactRepositoryLocations = new ArrayList<URI>();
private final List<URI> metadataRepositoryLocations = new ArrayList<URI>();
- private final List<IVersionedId> rootsToInstall = new ArrayList<IVersionedId>();
- private final List<IVersionedId> rootsToUninstall = new ArrayList<IVersionedId>();
- private final List<IVersionedId> rootsToList = new ArrayList<IVersionedId>();
+ private final List<IQuery<IInstallableUnit>> rootsToInstall = new ArrayList<IQuery<IInstallableUnit>>();
+ private final List<IQuery<IInstallableUnit>> rootsToUninstall = new ArrayList<IQuery<IInstallableUnit>>();
+ private final List<IQuery<IInstallableUnit>> rootsToList = new ArrayList<IQuery<IInstallableUnit>>();
private File bundlePool = null;
private File destination;
@@ -218,7 +234,7 @@ public class DirectorApplication implements IApplication {
private String revertToPreviousState = NOTHING_TO_REVERT_TO;
private static String NOTHING_TO_REVERT_TO = "-1"; //$NON-NLS-1$
- private static String REVERT_TO_PREVIOUS = "0"; //$NON-NLS-2$
+ private static String REVERT_TO_PREVIOUS = "0"; //$NON-NLS-1$
private boolean verifyOnly = false;
private boolean roamingProfile = false;
private boolean purgeRegistry = false;
@@ -277,23 +293,19 @@ public class DirectorApplication implements IApplication {
return QueryUtil.compoundQueryable(locationQueryables).query(query, nullMonitor);
}
- private Collection<IInstallableUnit> collectRoots(IProfile profile, List<IVersionedId> rootNames, boolean forInstall) throws CoreException {
+ private Collection<IInstallableUnit> collectRoots(IProfile profile, List<IQuery<IInstallableUnit>> rootNames, boolean forInstall) throws CoreException {
ArrayList<IInstallableUnit> allRoots = new ArrayList<IInstallableUnit>();
- int top = rootNames.size();
- for (int i = 0; i < top; ++i) {
- IVersionedId rootName = rootNames.get(i);
- Version v = rootName.getVersion();
- IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(rootName.getId(), Version.emptyVersion.equals(v) ? VersionRange.emptyRange : new VersionRange(v, true, v, true));
+ for (IQuery<IInstallableUnit> rootQuery : rootNames) {
IQueryResult<IInstallableUnit> roots = null;
if (forInstall)
- roots = collectRootIUs(QueryUtil.createLatestQuery(query));
+ roots = collectRootIUs(QueryUtil.createLatestQuery(rootQuery));
if (roots == null || roots.isEmpty())
- roots = profile.query(query, new NullProgressMonitor());
+ roots = profile.query(rootQuery, new NullProgressMonitor());
Iterator<IInstallableUnit> itor = roots.iterator();
if (!itor.hasNext())
- throw new CoreException(new Status(IStatus.ERROR, org.eclipse.equinox.internal.p2.director.app.Activator.ID, NLS.bind(Messages.Missing_IU, rootName)));
+ throw new CoreException(new Status(IStatus.ERROR, org.eclipse.equinox.internal.p2.director.app.Activator.ID, NLS.bind(Messages.Missing_IU, rootQuery)));
do {
allRoots.add(itor.next());
} while (itor.hasNext());
@@ -529,10 +541,8 @@ public class DirectorApplication implements IApplication {
while (roots.hasNext())
allRoots.add(roots.next());
} else {
- for (IVersionedId rootName : rootsToList) {
- Version v = rootName.getVersion();
- IQuery<IInstallableUnit> query = QueryUtil.createIUQuery(rootName.getId(), Version.emptyVersion.equals(v) ? VersionRange.emptyRange : new VersionRange(v, true, v, true));
- Iterator<IInstallableUnit> roots = collectRootIUs(query).iterator();
+ for (IQuery<IInstallableUnit> root : rootsToList) {
+ Iterator<IInstallableUnit> roots = collectRootIUs(root).iterator();
while (roots.hasNext())
allRoots.add(roots.next());
}
diff --git a/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/PrettyQuery.java b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/PrettyQuery.java
new file mode 100644
index 000000000..3dd931aa7
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.director.app/src/org/eclipse/equinox/internal/p2/director/app/PrettyQuery.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Sonatype, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Sonatype, Inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.director.app;
+
+import java.util.Iterator;
+import org.eclipse.equinox.p2.metadata.expression.IExpression;
+import org.eclipse.equinox.p2.query.IQuery;
+import org.eclipse.equinox.p2.query.IQueryResult;
+
+/*
+ * This class is used to keep pretty print a normal query using the information passed in.
+ */
+public class PrettyQuery<T> implements IQuery<T> {
+ private IQuery<T> decorated;
+ private String userString;
+
+ public PrettyQuery(IQuery<T> toDecorate, String userReadable) {
+ decorated = toDecorate;
+ userString = userReadable;
+ }
+
+ public IQueryResult<T> perform(Iterator<T> iterator) {
+ return decorated.perform(iterator);
+ }
+
+ public IExpression getExpression() {
+ return decorated.getExpression();
+ }
+
+ public String toString() {
+ if (userString != null)
+ return userString;
+ return decorated.toString();
+ }
+}

Back to the top