Ejemplo n.º 1
0
  public void deleteNote(
      final String canonicalName,
      Note currentNote,
      AssessmentData assessment,
      GenericCallback<String> callback) {

    if (!AuthorizationCache.impl.hasRight(
        SimpleSISClient.currentUser, AuthorizableObject.WRITE, assessment)) {
      WindowUtils.errorAlert(
          "You do not have sufficient permissions to perform " + "this operation.");
      return;
    }

    NativeDocument doc = SimpleSISClient.getHttpBasicNativeDocument();
    String type = AssessmentCache.impl.getCurrentAssessment().getType();
    String url = "/notes/" + type;
    url += "/" + AssessmentCache.impl.getCurrentAssessment().getAssessmentID();
    url += "/" + canonicalName;

    if (type.equals(BaseAssessment.USER_ASSESSMENT_STATUS)) url += "/" + currentNote.getUser();

    removeNoteFromCache(canonicalName, currentNote, assessment);

    doc.post(url + "?option=remove", currentNote.toXML(), callback);
  }
Ejemplo n.º 2
0
  public void fetchNotes(final AssessmentData assessment, final GenericCallback<String> callback) {
    if (!noteMap.containsKey(getNoteMapID(assessment))) {
      final NativeDocument ndoc = SimpleSISClient.getHttpBasicNativeDocument();
      ndoc.get(
          "/notes/" + assessment.getType() + "/" + assessment.getAssessmentID(),
          new GenericCallback<String>() {
            public void onFailure(Throwable caught) {
              callback.onSuccess("OK");
            }

            public void onSuccess(String result) {
              HashMap<String, ArrayList<Note>> assessNotes = new HashMap<String, ArrayList<Note>>();
              NativeNodeList nodeList = ndoc.getDocumentElement().getElementsByTagName("notes");

              for (int i = 0; i < nodeList.getLength(); i++) {
                NativeElement el = nodeList.elementAt(i);
                String canonicalName = el.getAttribute("id");
                assessNotes.put(canonicalName, Note.notesFromXML(el));
              }

              noteMap.put(getNoteMapID(assessment), assessNotes);

              callback.onSuccess(result);
            }
          });
    } else callback.onSuccess("OK");
  }
Ejemplo n.º 3
0
  private void search(String searchQuery) {
    String searchOptions = "";

    if (searchQuery.matches("^[0-9]+$")) {
      SysDebugger.getInstance().println("We gots a number to jump to.....");
      panelManager.taxonomicSummaryPanel.update(searchQuery);
      searchButton.setEnabled(true);
      WindowManager.get().hideAll();
      return;
    }

    final NativeDocument ndoc = SimpleSISClient.getHttpBasicNativeDocument();

    ndoc.post(
        "/search",
        searchToXML(searchQuery),
        new GenericCallback<String>() {
          public void onFailure(Throwable caught) {
            WindowUtils.hideLoadingAlert();
            WindowUtils.errorAlert("Error loading results. Inconsistency in index table.");
          }

          public void onSuccess(String result) {

            currentResults = ndoc.getDocumentElement().getElementsByTagName("result");
            if (currentResults.getLength() > NUMBER_OF_RESULTS) next.setVisible(true);
            expandableResults.setHeading(
                "Search Results [" + currentResults.getLength() + " results]");

            fillTable();

            if (currentResults.getLength() > 0) {
              next.setVisible(true);
              next.setEnabled(true);
              if (!(currentResults.getLength() > NUMBER_OF_RESULTS)) next.setEnabled(false);
              prev.setVisible(true);
              prev.setEnabled(false);
            } else {
              // expandableResults.add(new HTML("No Results."));
              prev.setEnabled(false);
              next.setEnabled(false);
            }

            setSelectionModelForTable();
            searchButton.setEnabled(true);
          }
        });
  }