Пример #1
0
  // Adds to each service template the general requirements for the CSA
  // (if a part of the CSA does not fulfill the requirement the whole will not fullfill it either)
  private void generalizeCSARequirements() {
    ArrayList<ServiceTemplate> comps = new ArrayList<ServiceTemplate>();
    ArrayList<Requirement> reqs = new ArrayList<Requirement>();

    comps = this.data.getServiceTemplates();
    reqs = this.data.getRequirements();

    for (ServiceTemplate c : comps) {
      for (Requirement r : reqs) {
        Requirement temp = new Requirement();
        try {
          BeanUtils.copyProperties(temp, r);
          // System.out.println(r.toString());
          // System.out.println(temp.toString());
          c.addReq(temp);
        } catch (IllegalAccessException | InvocationTargetException e) {
          e.printStackTrace();
        }
      }
    }
  }
Пример #2
0
  // Adds to each Service template the general criteria for the CSA
  // (each service template can have is own set of criteria, but if a global criteria is defined
  // each component must use it.)
  private void generalizeCSACriteria() {
    ArrayList<ServiceTemplate> comps = new ArrayList<ServiceTemplate>();
    ArrayList<Criterion> crit = new ArrayList<Criterion>();

    comps = this.data.getServiceTemplates();
    crit = this.data.getCriteria();

    for (ServiceTemplate c : comps) {
      for (Criterion cr : crit) {
        try {
          Criterion temp = (Criterion) BeanUtils.cloneBean(cr);
          c.addCrit(temp);
        } catch (IllegalAccessException
            | InstantiationException
            | InvocationTargetException
            | NoSuchMethodException e) {
          e.printStackTrace();
        }
      }
    }
  }
Пример #3
0
  private void normalizeCriteriaWeights() {

    // normalize the general criteria
    System.out.println("SYSTEM: Normalizing general criteria");
    double total = 0;
    for (Criterion crit : data.getCriteria()) {
      total = total + crit.getWeight();
    }

    for (Criterion crit : data.getCriteria()) {
      double res = crit.getWeight() / total;
      System.out.println(
          "SYSTEM: Total: " + total + " || value: " + crit.getWeight() + "|| res: " + res);
      crit.setWeight(res);
    }

    // normalize each of the Service Templates
    for (ServiceTemplate template : data.getServiceTemplates()) {
      System.out.println(
          "SYSTEM: Normalizing criteria of the serviceTemplate: " + template.getId());
      double templateTotal = 0;
      for (Criterion crit : template.getCriteria()) {
        templateTotal = templateTotal + crit.getWeight();
      }

      for (Criterion crit : template.getCriteria()) {
        double res = crit.getWeight() / templateTotal;
        System.out.println(
            "SYSTEM: Total: "
                + templateTotal
                + " || value: "
                + crit.getWeight()
                + "|| res: "
                + res);
        crit.setWeight(res);
      }
    }
  }
Пример #4
0
  private void normalizeServiceTemplateWeights() {

    // normalize the general criteria
    System.out.println("SYSTEM: Normalizing Service Template Weights");
    double total = 0;
    for (ServiceTemplate template : data.getServiceTemplates()) {
      total = total + template.getWeight();
    }

    for (ServiceTemplate template : data.getServiceTemplates()) {
      double res = template.getWeight() / total;
      System.out.println(
          "SYSTEM: Total: " + total + " || value: " + template.getWeight() + "|| res: " + res);
      template.setWeight((float) res);
    }
  }
Пример #5
0
  private void convertReqsInCriterions() {
    // convert the general requirements
    ArrayList<Criterion> criteria = this.data.getCriteria();

    for (Requirement req : this.data.getRequirements()) {
      if (req.isCriterion()) {
        // create new criterion
        Criterion crit = new Criterion();
        if (req.getQuantType() != null) crit.setName(req.getQuantType().getValue());
        else if (req.getQualType() != null) crit.setName(req.getQualType().getValue());
        else
          // this is a price requirement
          crit.setName("price");

        String[] msg = {crit.getName(), "General"};
        if (this.methodID == CloudAid.SAW) {
          Float weight = Float.parseFloat(CloudAid.askData(CloudAid.GET_WEIGHT, msg, null));
          crit.setWeight(weight);
        }
        // get the criterion preference direction
        String res = CloudAid.askData(CloudAid.GET_PREFERENCE_DIRECTION, msg, null);
        if (res.equalsIgnoreCase("y")) {
          crit.setPreferenceDirection("max");
        } else if (res.equalsIgnoreCase("n")) {
          crit.setPreferenceDirection("min");
        }

        criteria.add(crit);
      }
    }
    this.data.setCriteria(criteria);

    // convert each serpiceTemplate requirements
    for (ServiceTemplate template : this.data.getServiceTemplates()) {
      ArrayList<Criterion> templateCriteria = template.getCriteria();
      for (Requirement req : template.getRequirements()) {
        if (req.isCriterion()) {
          // create new criterion
          Criterion crit = new Criterion();
          if (req.getQuantType() != null) crit.setName(req.getQuantType().getValue());
          else if (req.getQualType() != null) crit.setName(req.getQualType().getValue());
          else
            // this is a price requirement
            crit.setName("price");

          String[] msg = {crit.getName(), template.getType()};
          if (this.methodID == CloudAid.SAW) {
            Float weight = Float.parseFloat(CloudAid.askData(CloudAid.GET_WEIGHT, msg, null));
            crit.setWeight(weight);
          }

          // get the criterion preference direction
          String res = CloudAid.askData(CloudAid.GET_PREFERENCE_DIRECTION, msg, null);
          if (res.equalsIgnoreCase("y")) {
            crit.setPreferenceDirection("max");
          } else if (res.equalsIgnoreCase("n")) {
            crit.setPreferenceDirection("min");
          }

          templateCriteria.add(crit);
        }
      }
      template.setCriteria(templateCriteria);
    }
  }