コード例 #1
0
ファイル: RegisterNewExecute.java プロジェクト: xdomes/mmiorr
  private void doRegister(MyDialog createPopup, CreateOntologyResult createOntologyResult) {

    createPopup.hide();

    final MyDialog popup = new MyDialog(null);
    popup.addTextArea(null).setText("please wait ...");
    popup.getTextArea().setSize("600", "150");

    Orr.log(CLASS_NAME + ": Registering ontology ...");
    popup.setText("Registering ontology ...");
    popup.center();
    popup.show();

    AsyncCallback<RegisterOntologyResult> callback =
        new AsyncCallback<RegisterOntologyResult>() {
          public void onFailure(Throwable thr) {
            Window.alert(thr.toString());
          }

          public void onSuccess(RegisterOntologyResult result) {
            registrationCompleted(popup, result);
          }
        };

    LoginResult loginResult = PortalControl.getInstance().getLoginResult();
    Orr.service.registerOntology(createOntologyResult, loginResult, callback);
  }
コード例 #2
0
ファイル: RegisterNewExecute.java プロジェクト: xdomes/mmiorr
  /**
   * Call this to review and register an new ontology (not a new version of an existing registered
   * ontology).
   */
  void reviewAndRegisterNewOntology() {
    Map<String, String> newValues = createOntologyInfo.getMetadataValues();

    BaseOntologyInfo ontologyInfo = createOntologyInfo.getBaseOntologyInfo();

    assert !(ontologyInfo instanceof RegisteredOntologyInfo);

    // Ok, put the new values in the ontologyInfo object:
    ontologyInfo.getOntologyMetadata().setNewValues(newValues);

    createOntologyInfo.setUri(ontologyInfo.getUri());

    Orr.log(
        CLASS_NAME
            + ": reviewAndRegisterNewOntology starting.  HostingType: "
            + createOntologyInfo.getHostingType());

    final MyDialog popup = new MyDialog(null);
    popup.addTextArea(null).setSize("600", "150");
    popup.getTextArea().setText("please wait ...");
    PortalControl.getInstance().notifyActivity(true);
    popup.setText("Creating ontology ...");
    popup.center();
    popup.show();

    AsyncCallback<CreateOntologyResult> callback =
        new AsyncCallback<CreateOntologyResult>() {
          public void onFailure(Throwable thr) {
            PortalControl.getInstance().notifyActivity(false);
            Window.alert(thr.toString());
          }

          public void onSuccess(CreateOntologyResult result) {
            Orr.log(CLASS_NAME + ": CreateOntologyResult obtained.");
            PortalControl.getInstance().notifyActivity(false);
            reviewCompleted(popup, result);
          }
        };

    Orr.log(CLASS_NAME + ": Calling service createOntology ...");
    Orr.service.createOntology(createOntologyInfo, callback);
  }
コード例 #3
0
ファイル: MetadataPanel.java プロジェクト: xdomes/mmiorr
  /**
   * Updates the metadata from the given temporary ontology info object, confirming with the user in
   * case of any possible overwriting of attributes.
   */
  public void tempOntologyInfoObtained(TempOntologyInfo tempOntologyInfo) {

    // get the new values from temp file:
    OntologyMetadata ontologyMetadata = tempOntologyInfo.getOntologyMetadata();

    // get current values in the editor:

    Map<String, String> valuesInEditor = new HashMap<String, String>();
    putValues(valuesInEditor, false);

    // and from the file
    Map<String, String> tempValues = ontologyMetadata.getOriginalValues();

    Set<String> commonKeysWithDiffValues = new HashSet<String>();

    // see if there're common attributes with different values in both the editor and the new file
    for (String tempKey : tempValues.keySet()) {
      if (valuesInEditor.keySet().contains(tempKey)) {
        String valueInEditor = valuesInEditor.get(tempKey);
        String valueInTemp = tempValues.get(tempKey);
        if (((valueInEditor == null) ^ (valueInTemp == null))
            || !valueInEditor.equals(valueInTemp)) {
          commonKeysWithDiffValues.add(tempKey);
        }
      }
    }

    if (!commonKeysWithDiffValues.isEmpty()) {

      // prompt the user for the action to take:

      String confirmationMsg =
          "There are different values in the uploaded file for "
              + commonKeysWithDiffValues.size()
              + " of the "
              + "non-empty attributes in the metadata editor. "
              + "Do you want to replace the existing values in the editor with those from the file?\n"
              + "\n"
              + "Select Accept to replace those attributes with values from the file.\n"
              + "\n"
              + "Select Cancel to keep the values in the editor.\n"
              + "\n"
              + "In either case, missing attributes in the editor will be updated with "
              + "available values from the file. \n";

      // add the attribute names for administrators:
      if (PortalControl.getInstance().getLoginResult() != null) {
        LoginResult loginResult = PortalControl.getInstance().getLoginResult();
        if (loginResult.isAdministrator()) {
          confirmationMsg += "\n" + "The attributes are:\n" + commonKeysWithDiffValues;
        }
      }

      if (true) { // this block is just a quick way to open the enclosing DisclosurePanel, if any
        Widget parent = this.getParent();
        while (parent != null) {
          if (parent instanceof DisclosurePanel) {
            ((DisclosurePanel) parent).setOpen(true);
            break;
          }
          parent = parent.getParent();
        }
      }

      if (Window.confirm(confirmationMsg)) {
        // replace common attributes with values from the file.
        // Keep tempValues map as it is. See below.
      } else {
        // keep values in the editor, so remove the corresponding keys from tempValues:
        for (String tempKey : commonKeysWithDiffValues) {
          tempValues.remove(tempKey);
        }
      }

      // use valuesInEditor map to collect the final set of attributes:
      for (String tempKey : tempValues.keySet()) {
        valuesInEditor.put(tempKey, tempValues.get(tempKey));
      }

      // and set the final set of attributes:
      ontologyMetadata.setOriginalValues(valuesInEditor);
    }

    for (int i = 0, c = tabPanel.getWidgetCount(); i < c; i++) {
      Widget w = tabPanel.getWidget(i);
      if (w instanceof MetadataGroupPanel) {
        ((MetadataGroupPanel) w).resetToOriginalOrNewValues(ontologyMetadata, true, false);
      }
    }
  }