コード例 #1
0
  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;
      }
    }
  }
コード例 #2
0
 @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();
 }
コード例 #3
0
 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;
       }
     }
   }
 }
コード例 #4
0
  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;
  }
コード例 #5
0
 public void setCurrentRemedy(Remedy currentRemedy) {
   this.currentRemedy = currentRemedy;
   request = currentRemedy == null ? null : currentRemedy.getRequest();
 }