Esempio n. 1
0
 public IStatus uninstall(String id, String feature, IProgressMonitor monitor) {
   IProfile profile = registry.getProfile(id);
   if (profile == null)
     return new Status(
         IStatus.ERROR, LogUtility.getStatusId(this), "Cannot find profile for: " + id);
   IInstallableUnit unit = findFeature(feature);
   if (unit == null)
     return new Status(
         IStatus.ERROR, LogUtility.getStatusId(this), "Cannot find feature : " + feature);
   IProfileChangeRequest request = planner.createChangeRequest(profile);
   request.remove(unit);
   return performOperation(profile, request, monitor);
 }
  private void computeRemedyDetails(Remedy remedy) {
    ArrayList<String> updateIds = new ArrayList<String>();
    for (IInstallableUnit addedIU : remedy.getRequest().getAdditions()) {
      for (IInstallableUnit removedIU : remedy.getRequest().getRemovals()) {
        if (removedIU.getId().equals(addedIU.getId())) {
          createModificationRemedyDetail(addedIU, removedIU, remedy);
          updateIds.add(addedIU.getId());
          break;
        }
      }
      if (!updateIds.contains(addedIU.getId())) {
        createAdditionRemedyDetail(addedIU, remedy);
      }
    }

    for (IInstallableUnit removedIU : remedy.getRequest().getRemovals()) {
      if (!updateIds.contains(removedIU.getId())) {
        createRemovalRemedyDetail(removedIU, remedy);
      }
    }

    for (IInstallableUnit addedIUinOriginalRequest : originalRequest.getAdditions()) {
      boolean found = false;
      for (IInstallableUnit addedIU : remedy.getRequest().getAdditions()) {
        if (addedIU.getId().equals(addedIUinOriginalRequest.getId())) {
          found = true;
          break;
        }
      }
      if (!found) {
        createNotAddedRemedyDetail(addedIUinOriginalRequest, remedy);
        found = false;
      }
    }
  }
Esempio n. 3
0
  public void testGreedy() throws ProvisionException, OperationCanceledException {
    URI heliosRepo = getTestData("helios", "testData/bug306279/repo/helios").toURI();
    URI rienaRepo2 =
        getTestData("rienatoolbox-a", "testData/bug306279/repo/rienatoolbox-a").toURI();
    IMetadataRepository repo1 = getMetadataRepositoryManager().loadRepository(heliosRepo, null);
    assertFalse(
        repo1
            .query(
                QueryUtil.createIUQuery("org.eclipse.rap.jface.databinding"),
                new NullProgressMonitor())
            .isEmpty());
    IMetadataRepository repo2 = getMetadataRepositoryManager().loadRepository(rienaRepo2, null);

    IPlanner planner = getPlanner(getAgent());
    IProfile profile = createProfile(getName());
    IProfileChangeRequest request = new ProfileChangeRequest(profile);
    Set<IInstallableUnit> ius =
        repo2
            .query(
                QueryUtil.createIUQuery("org.eclipse.riena.toolbox.feature.feature.group"),
                new NullProgressMonitor())
            .toUnmodifiableSet();
    request.addAll(ius);
    ProvisioningContext ctx = new ProvisioningContext(getAgent());
    ctx.setMetadataRepositories(new URI[] {heliosRepo, rienaRepo2});
    IProvisioningPlan plan = planner.getProvisioningPlan(request, ctx, new NullProgressMonitor());

    assertOK("resolution failed", plan.getStatus());
    assertEquals(
        0,
        plan.getAdditions()
            .query(
                QueryUtil.createIUQuery("org.eclipse.rap.jface.databinding"),
                new NullProgressMonitor())
            .toUnmodifiableSet()
            .size());
    System.out.println(plan);
  }
 private Version searchInOriginalRequest(String id) {
   for (IInstallableUnit iu : originalRequest.getAdditions()) {
     if (iu.getId() == id) return iu.getVersion();
   }
   return null;
 }