Exemplo n.º 1
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");
  }
Exemplo n.º 2
0
  public void fetchViews(final String schema, final GenericCallback<String> wayback) {
    if (schemaToViews.containsKey(schema)) {
      if (!schema.equals(currentSchema)) resetSchema(schema);

      wayback.onSuccess(null);
    } else {
      final NativeDocument viewsDocument = SISClientBase.getHttpBasicNativeDocument();
      viewsDocument.get(
          UriBase.getInstance().getSISBase() + "/application/schema/" + schema + "/view",
          new GenericCallback<String>() {
            public void onFailure(Throwable arg0) {
              wayback.onFailure(arg0);
            }

            public void onSuccess(String arg0) {
              NativeNodeList viewElements =
                  viewsDocument.getDocumentElement().getElementsByTagName("view");
              Map<String, SISView> views = new LinkedHashMap<String, SISView>();
              for (int i = 0; i < viewElements.getLength(); i++) {
                NativeElement root = viewElements.elementAt(i);
                SISView curView = new SISView();

                curView.setDisplayableTitle(root.getAttribute("title"));
                curView.setId(root.getAttribute("id"));

                NativeNodeList pages = root.getElementsByTagName("page");
                for (int k = 0; k < pages.getLength(); k++) {
                  NativeElement rootPageTag = pages.elementAt(k);
                  // Create new SISPageHolders for each page in the view
                  if (rootPageTag.getNodeName().equalsIgnoreCase("page")) {
                    SISPageHolder curPage =
                        new SISPageHolder(
                            XMLUtils.getXMLAttribute(rootPageTag, "title", null),
                            XMLUtils.getXMLAttribute(rootPageTag, "id"),
                            rootPageTag);

                    curView.addPage(curPage);
                  }
                }

                views.put(curView.getId(), curView);
              }
              schemaToViews.put(schema, views);

              resetSchema(schema);
              wayback.onSuccess(null);
            }
          });
    }
  }