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;
      }
    }
  }
 private void createAdditionRemedyDetail(IInstallableUnit iu, Remedy remedy) {
   RemedyIUDetail iuDetail = new RemedyIUDetail(iu);
   iuDetail.setStatus(RemedyIUDetail.STATUS_ADDED);
   iuDetail.setBeingInstalledVersion(iu.getVersion());
   iuDetail.setRequestedVersion(searchInOriginalRequest(iu.getId()));
   remedy.addRemedyIUDetail(iuDetail);
 }
 private void createModificationRemedyDetail(
     IInstallableUnit beingInstalledIU, IInstallableUnit installedIU, Remedy remedy) {
   RemedyIUDetail iuDetail = new RemedyIUDetail(beingInstalledIU);
   iuDetail.setStatus(RemedyIUDetail.STATUS_CHANGED);
   iuDetail.setBeingInstalledVersion(beingInstalledIU.getVersion());
   iuDetail.setInstalledVersion(installedIU.getVersion());
   iuDetail.setRequestedVersion(searchInOriginalRequest(beingInstalledIU.getId()));
   remedy.addRemedyIUDetail(iuDetail);
 }
 @Override
 protected void computeProfileChangeRequest(MultiStatus status, IProgressMonitor monitor) {
   SubMonitor sub = SubMonitor.convert(monitor, 1);
   if (currentRemedy != null) {
     request = currentRemedy.getRequest();
     sub.worked(1);
     return;
   }
   try {
     status.add(computeAllRemediations(sub.newChild(1)));
   } catch (OperationCanceledException e) {
     status.add(Status.CANCEL_STATUS);
   }
   determineBestSolutions();
 }
 private void determineBestSolutions() {
   int beingInstalledWeight = 0;
   int installationWeight = 0;
   for (Iterator<Remedy> iterator = remedies.iterator(); iterator.hasNext(); ) {
     Remedy remedy = iterator.next();
     if (remedy.getRequest() != null) {
       if (remedy.getBeingInstalledRelaxedWeight() > beingInstalledWeight
           && remedy.getInstallationRelaxedWeight() == 0) {
         bestSolutionChangingTheRequest = remedy;
         beingInstalledWeight = remedy.getBeingInstalledRelaxedWeight();
         continue;
       }
       if (remedy.getInstallationRelaxedWeight() > installationWeight
           && remedy.getBeingInstalledRelaxedWeight() == 0) {
         bestSolutionChangingWhatIsInstalled = remedy;
         installationWeight = remedy.getInstallationRelaxedWeight();
         continue;
       }
     }
   }
 }
 public void setCurrentRemedy(Remedy currentRemedy) {
   this.currentRemedy = currentRemedy;
   request = currentRemedy == null ? null : currentRemedy.getRequest();
 }
 private void createRemovalRemedyDetail(IInstallableUnit iu, Remedy remedy) {
   RemedyIUDetail iuDetail = new RemedyIUDetail(iu);
   iuDetail.setStatus(RemedyIUDetail.STATUS_REMOVED);
   iuDetail.setInstalledVersion(iu.getVersion());
   remedy.addRemedyIUDetail(iuDetail);
 }
 private void createNotAddedRemedyDetail(IInstallableUnit iu, Remedy remedy) {
   RemedyIUDetail iuDetail = new RemedyIUDetail(iu);
   iuDetail.setStatus(RemedyIUDetail.STATUS_NOT_ADDED);
   iuDetail.setRequestedVersion(iu.getVersion());
   remedy.addRemedyIUDetail(iuDetail);
 }
  private Remedy computeRemedy(RemedyConfig configuration, IProgressMonitor monitor) {
    Remedy remedy = new Remedy(originalRequest);
    remedy.setConfig(configuration);
    IPlanner planner = session.getPlanner();
    RequestFlexer av = new RequestFlexer(planner);
    av.setAllowDifferentVersion(configuration.allowDifferentVersion);
    av.setAllowInstalledElementChange(configuration.allowInstalledUpdate);
    av.setAllowInstalledElementRemoval(configuration.allowInstalledRemoval);
    av.setAllowPartialInstall(configuration.allowPartialInstall);
    av.setProvisioningContext(getProvisioningContext());
    remedy.setRequest(
        (ProfileChangeRequest)
            av.getChangeRequest(
                originalRequest, ((ProfileChangeRequest) originalRequest).getProfile(), monitor));
    if (remedy.getRequest() == null) return null;

    if (configuration.allowInstalledUpdate && !configuration.allowInstalledRemoval) {
      remedy.setInstallationRelaxedWeight(HIGH_WEIGHT);
    } else if (!configuration.allowInstalledUpdate && configuration.allowInstalledRemoval) {
      remedy.setInstallationRelaxedWeight(MEDIUM_WEIGHT);
    } else if (configuration.allowInstalledUpdate && configuration.allowInstalledRemoval) {
      remedy.setInstallationRelaxedWeight(LOW_WEIGHT);
    } else remedy.setInstallationRelaxedWeight(ZERO_WEIGHT);

    if (configuration.allowDifferentVersion && !configuration.allowPartialInstall) {
      remedy.setBeingInstalledRelaxedWeight(HIGH_WEIGHT);
    } else if (!configuration.allowDifferentVersion && configuration.allowPartialInstall) {
      remedy.setBeingInstalledRelaxedWeight(MEDIUM_WEIGHT);
    } else if (configuration.allowDifferentVersion && configuration.allowPartialInstall) {
      remedy.setBeingInstalledRelaxedWeight(LOW_WEIGHT);
    } else {
      remedy.setBeingInstalledRelaxedWeight(ZERO_WEIGHT);
    }
    computeRemedyDetails(remedy);
    return remedy;
  }