Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2009-12-17 11:14:51 +0000
committerPascal Rapicault2009-12-17 11:14:51 +0000
commit04f5301650b6282ba510b3d490dc1f185d842ff0 (patch)
treeec54bac18c227a08376be5d4a073aec810320efa
parent2558a989918a2e74f8f94380e56c4bc7494a58e3 (diff)
downloadrt.equinox.p2-04f5301650b6282ba510b3d490dc1f185d842ff0.tar.gz
rt.equinox.p2-04f5301650b6282ba510b3d490dc1f185d842ff0.tar.xz
rt.equinox.p2-04f5301650b6282ba510b3d490dc1f185d842ff0.zip
Get rid of the usage of operands where we can
-rw-r--r--bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java9
-rw-r--r--bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java18
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java40
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOrbit.java27
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateManagerCompatibility.java19
-rw-r--r--bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java13
9 files changed, 36 insertions, 96 deletions
diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java
index 7d2ca9d08..7df20f566 100644
--- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java
+++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java
@@ -18,11 +18,10 @@ import org.eclipse.core.runtime.jobs.*;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.engine.PhaseSet;
import org.eclipse.equinox.internal.p2.operations.*;
-import org.eclipse.equinox.internal.p2.operations.Messages;
import org.eclipse.equinox.internal.provisional.configurator.Configurator;
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
import org.eclipse.equinox.internal.provisional.p2.director.IPlanner;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
import org.eclipse.equinox.p2.core.IAgentLocation;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.*;
@@ -163,7 +162,7 @@ public class ProvisioningSession {
// If there is nothing to size, return 0
if (plan == null)
return SIZE_NOTAPPLICABLE;
- if (plan.getOperands().length == 0)
+ if (countPlanElements(plan) == 0)
return 0;
long installPlanSize = 0;
SubMonitor mon = SubMonitor.convert(monitor, 300);
@@ -182,6 +181,10 @@ public class ProvisioningSession {
return SIZE_UNAVAILABLE;
}
+ private int countPlanElements(IProvisioningPlan plan) {
+ return new CompoundQueryable(new IQueryable[] {plan.getAdditions(), plan.getRemovals()}).query(InstallableUnitQuery.ANY, null).size();
+ }
+
/**
* Perform the specified provisioning plan.
*
diff --git a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
index a6e29e93f..7d3317abd 100644
--- a/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
+++ b/bundles/org.eclipse.equinox.p2.reconciler.dropins/src/org/eclipse/equinox/internal/p2/reconciler/dropins/ProfileSynchronizer.java
@@ -100,8 +100,7 @@ public class ProfileSynchronizer {
if (status.getSeverity() == IStatus.ERROR || status.getSeverity() == IStatus.CANCEL)
return status;
- Operand[] operands = plan.getOperands();
- if (operands.length == 0 || containsOnlyInstallableUnitPropertyOperandAdditions(operands)) {
+ if (plan.getAdditions().query(InstallableUnitQuery.ANY, null).size() + plan.getRemovals().query(InstallableUnitQuery.ANY, null).size() == 0) {
writeTimestamps();
return status;
}
@@ -119,21 +118,6 @@ public class ProfileSynchronizer {
}
}
- // This is a special case that occurs where all IUs being installed are not compatible with the profile so
- // the operands will have no affect if executed on the profile.
- private boolean containsOnlyInstallableUnitPropertyOperandAdditions(Operand[] operands) {
- for (int i = 0; i < operands.length; i++) {
- if (!(operands[i] instanceof InstallableUnitPropertyOperand))
- return false;
-
- InstallableUnitPropertyOperand iuPropertyOperand = (InstallableUnitPropertyOperand) operands[i];
- //check if this is a removal or update
- if (iuPropertyOperand.first() != null)
- return false;
- }
- return true;
- }
-
private void writeTimestamps() {
timestamps.clear();
timestamps.put(PROFILE_TIMESTAMP, Long.toString(profile.getTimestamp()));
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
index c4df72a39..83a23c6ac 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java
@@ -27,7 +27,7 @@ import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEv
import org.eclipse.equinox.internal.provisional.p2.director.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.*;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
import org.eclipse.equinox.p2.core.IAgentLocation;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.engine.*;
@@ -901,40 +901,18 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
protected static void assertInstallOperand(IProvisioningPlan plan, IInstallableUnit iu) {
- Operand[] ops = plan.getOperands();
- for (int i = 0; i < ops.length; i++) {
- if (ops[i] instanceof InstallableUnitOperand) {
- InstallableUnitOperand iuOp = (InstallableUnitOperand) ops[i];
- if (iu.equals(iuOp.second()))
- return;
- }
- }
- fail("Can't find " + iu + " in the plan");
+ if (plan.getAdditions().query(new InstallableUnitQuery(iu), null).size() == 0)
+ fail("Can't find " + iu + " in the plan");
}
protected static void assertUninstallOperand(IProvisioningPlan plan, IInstallableUnit iu) {
- Operand[] ops = plan.getOperands();
- for (int i = 0; i < ops.length; i++) {
- if (ops[i] instanceof InstallableUnitOperand) {
- InstallableUnitOperand iuOp = (InstallableUnitOperand) ops[i];
- if (iu.equals(iuOp.first()))
- return;
- }
- }
- fail("Can't find " + iu + " in the plan");
+ if (plan.getRemovals().query(new InstallableUnitQuery(iu), null).size() == 0)
+ fail("Can't find " + iu + " in the plan");
}
protected static void assertNoOperand(IProvisioningPlan plan, IInstallableUnit iu) {
- Operand[] ops = plan.getOperands();
- for (int i = 0; i < ops.length; i++) {
- if (ops[i] instanceof InstallableUnitOperand) {
- InstallableUnitOperand iuOp = (InstallableUnitOperand) ops[i];
- if (iuOp.second() != null && iuOp.second().equals(iu))
- fail(iu + " should not be present in this plan.");
- if (iuOp.first() != null && iuOp.first().equals(iu))
- fail(iu + " should not be present in this plan.");
- }
- }
+ if (plan.getRemovals().query(new InstallableUnitQuery(iu), null).size() + plan.getAdditions().query(new InstallableUnitQuery(iu), null).size() != 0)
+ fail(iu + " should not be present in this plan.");
}
protected void setUp() throws Exception {
@@ -1385,4 +1363,8 @@ public abstract class AbstractProvisioningTest extends TestCase {
}
return count;
}
+
+ public int countPlanElements(IProvisioningPlan plan) {
+ return new CompoundQueryable(new IQueryable[] {plan.getAdditions(), plan.getRemovals()}).query(InstallableUnitQuery.ANY, null).size();
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOrbit.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOrbit.java
index 95731154d..912ebc660 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOrbit.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/AllOrbit.java
@@ -15,7 +15,7 @@ import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper;
import org.eclipse.equinox.internal.p2.metadata.repository.MetadataRepositoryManager;
import org.eclipse.equinox.internal.provisional.p2.director.*;
-import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.*;
import org.eclipse.equinox.p2.engine.*;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.query.IQueryResult;
@@ -50,13 +50,6 @@ public class AllOrbit extends AbstractProvisioningTest {
req1.setInstallableUnitInclusionRules(iu, PlannerHelper.createOptionalInclusionRule(iu));
}
IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null);
- Operand[] ops = plan1.getOperands();
- int count = 0;
- for (int i = 0; i < ops.length; i++) {
- if (ops[i] instanceof InstallableUnitOperand) {
- count++;
- }
- }
assertEquals(IStatus.OK, plan1.getStatus().getSeverity());
}
@@ -76,14 +69,7 @@ public class AllOrbit extends AbstractProvisioningTest {
req1.addInstallableUnits((IInstallableUnit[]) toInstall.toArray(new IInstallableUnit[toInstall.size()]));
IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null);
- Operand[] ops = plan1.getOperands();
- int count = 0;
- for (int i = 0; i < ops.length; i++) {
- if (ops[i] instanceof InstallableUnitOperand) {
- count++;
- }
- }
- assertEquals(178, count);
+ assertEquals(178, countPlanElements(plan1));
assertEquals(IStatus.OK, plan1.getStatus().getSeverity());
}
@@ -104,14 +90,7 @@ public class AllOrbit extends AbstractProvisioningTest {
req1.addInstallableUnits((IInstallableUnit[]) toInstall.toArray(new IInstallableUnit[toInstall.size()]));
IProvisioningPlan plan1 = planner.getProvisioningPlan(req1, null, null);
- Operand[] ops = plan1.getOperands();
- int count = 0;
- for (int i = 0; i < ops.length; i++) {
- if (ops[i] instanceof InstallableUnitOperand) {
- count++;
- }
- }
- assertEquals(178, count);
+ assertEquals(178, countPlanElements(plan1));
assertEquals(IStatus.OK, plan1.getStatus().getSeverity());
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java
index 988d43004..da7f482d4 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest1.java
@@ -57,6 +57,6 @@ public class SDKPatchingTest1 extends AbstractProvisioningTest {
IPlanner planner = createPlanner();
IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor());
assertOK("Installation plan", plan.getStatus());
- assertEquals(4, plan.getOperands().length);
+ assertEquals(3, countPlanElements(plan));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java
index b1fcd457d..582213706 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SDKPatchingTest2.java
@@ -77,6 +77,6 @@ public class SDKPatchingTest2 extends AbstractProvisioningTest {
IPlanner planner = createPlanner();
IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor());
assertOK("Installation plan", plan.getStatus());
- assertEquals(8, plan.getOperands().length);
+ assertEquals(6, countPlanElements(plan));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java
index 595140efe..6d2d20e17 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/SimulatedSharedInstallTest.java
@@ -112,6 +112,6 @@ public class SimulatedSharedInstallTest extends AbstractProvisioningTest {
assertEquals(IStatus.OK, plan.getStatus().getSeverity());
//expect to have both (a1+inclusion rule) and b1 added
- assertEquals(3, plan.getOperands().length);
+ assertEquals(2, countPlanElements(plan));
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateManagerCompatibility.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateManagerCompatibility.java
index 3444980e0..e7fc91c60 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateManagerCompatibility.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateManagerCompatibility.java
@@ -13,13 +13,14 @@ package org.eclipse.equinox.internal.p2.ui;
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Vector;
+import java.util.*;
import javax.xml.parsers.*;
import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
-import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
+import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.query.IQueryResult;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
@@ -170,13 +171,11 @@ public class UpdateManagerCompatibility {
}
public static boolean requiresInstallHandlerSupport(IProvisioningPlan plan) {
- Operand[] operands = plan.getOperands();
- for (int i = 0; i < operands.length; i++) {
- if (operands[i] instanceof InstallableUnitOperand) {
- IInstallableUnit iu = ((InstallableUnitOperand) operands[i]).second();
- if (iu != null && iu.getProperty(ECLIPSE_INSTALL_HANDLER_PROP) != null)
- return true;
- }
+ IQueryResult result = plan.getAdditions().query(InstallableUnitQuery.ANY, null);
+ for (Iterator iterator = result.iterator(); iterator.hasNext();) {
+ IInstallableUnit iu = (IInstallableUnit) iterator.next();
+ if (iu != null && iu.getProperty(ECLIPSE_INSTALL_HANDLER_PROP) != null)
+ return true;
}
return false;
diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java
index 28e3c81fb..9c575c982 100644
--- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java
+++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/p2/ui/AcceptLicensesWizardPage.java
@@ -19,9 +19,10 @@ import org.eclipse.equinox.internal.p2.ui.ProvUIMessages;
import org.eclipse.equinox.internal.p2.ui.dialogs.ILayoutConstants;
import org.eclipse.equinox.internal.p2.ui.viewers.IUColumnConfig;
import org.eclipse.equinox.internal.provisional.p2.metadata.ILicense;
+import org.eclipse.equinox.internal.provisional.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.common.LicenseManager;
import org.eclipse.equinox.p2.common.TranslationSupport;
-import org.eclipse.equinox.p2.engine.*;
+import org.eclipse.equinox.p2.engine.IProvisioningPlan;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.operations.ProfileChangeOperation;
import org.eclipse.jface.dialogs.Dialog;
@@ -379,15 +380,7 @@ public class AcceptLicensesWizardPage extends WizardPage {
private void findUnacceptedLicenses(IInstallableUnit[] selectedIUs, IProvisioningPlan plan) {
IInstallableUnit[] iusToCheck = selectedIUs;
if (plan != null) {
- List allIUs = new ArrayList();
- Operand[] operands = plan.getOperands();
- for (int i = 0; i < operands.length; i++)
- if (operands[i] instanceof InstallableUnitOperand) {
- IInstallableUnit addedIU = ((InstallableUnitOperand) operands[i]).second();
- if (addedIU != null)
- allIUs.add(addedIU);
- }
- iusToCheck = (IInstallableUnit[]) allIUs.toArray(new IInstallableUnit[allIUs.size()]);
+ iusToCheck = (IInstallableUnit[]) plan.getAdditions().query(InstallableUnitQuery.ANY, null).toArray(IInstallableUnit.class);
}
// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=218532

Back to the top