コード例 #1
0
  String text(ResourceSettingInstance ele) {
    String assigns = "";

    if ((ele.getAssignSetting() != null) && (ele.getAssignSetting().size() > 0)) {
      for (int ixAssignedSettings = 0;
          ixAssignedSettings < ele.getAssignSetting().size();
          ixAssignedSettings++) {
        SettingInstance assignedSetting = ele.getAssignSetting().get(ixAssignedSettings);
        assigns +=
            "\""
                + ((ResourceRequest) assignedSetting.eContainer()).getName()
                + // hardcode here the _1 . A more sofisticated way should be implemented.eg now we
                  // suppose that a group of services is connected to 1 setting... maybe we have
                  // more complex scenarios
                assignedSetting.getName()
                + "\","; // Assignments work differently from VCT tool. in vct tool the arrows are
                         // references.. where assign means that the assigned value is the source
                         // and the element is the target
      }
      assigns = assigns.substring(0, assigns.length() - 1);
      return ele.getName() + " <- " + assigns;

    } else {
      return ele.getName() + " = \"" + ele.getStaticValue() + "\"";
    }
  }
コード例 #2
0
  public boolean resourceRequestHasAllAssignementsResolved(
      RequestedFederationScenario scenario, ResourceRequest resReq) {

    for (ResourceSettingInstance s : resReq.getReqResourceSettings()) {
      if (s.getAssignSetting().size() > 0) {
        String value = null;
        for (SettingInstance assignedSetting : s.getAssignSetting()) {
          ResourceRequest assignedResource =
              (ResourceRequest) ((ResourceSettingInstance) assignedSetting).eContainer();
          value =
              getStaticValueOfAssignedSetting(
                  scenario, assignedResource, (ResourceSettingInstance) assignedSetting);
          if ((value == null)) {
            System.out.println(
                "Setting:"
                    + s.getName()
                    + " of resource "
                    + resReq.getName()
                    + " has assigned value to:"
                    + assignedSetting.getName()
                    + " which cannot be resolved yet!");
            return false; // exit immediately. We currently cannot resolve this
          }
          value = value + ",";
        }

        value = value.substring(0, value.length() - 1); // to cut the last comma
        s.setStaticValue(value);
        s.getAssignSetting().clear(); // if came here then it is ok and everything assigned
      }
    }

    // check now if everything is OK to go
    for (ResourceSettingInstance s : resReq.getReqResourceSettings()) {
      if (s.getRefResourceSetting().isWritable())
        if ((s.getStaticValue() == null) || (s.getAssignSetting().size() > 0)) {
          System.out.println(
              "Setting:"
                  + s.getName()
                  + " of resource "
                  + resReq.getName()
                  + " cannot be resolved yet!");
          return false;
        }
    }

    return true; // everything is resolved..so go
  }