/**
   * Create a triple for a new node being created.
   *
   * @param oMeetingEvent the event whose data to upload.
   * @param model the model to add the data to.
   */
  private synchronized void addNode(
      MeetingEvent oMeetingEvent, com.hp.hpl.jena.rdf.model.Model model) {

    NodeSummary oNode = oMeetingEvent.getNode();

    if (oNode == null) {
      return;
    }

    String sNodeID = oNode.getId();
    Resource oResNode =
        model.createResource(oMeetingEvent.getMeetingID() + "-" + sNodeID); // $NON-NLS-1$
    Property type = model.createProperty(RDF_NS, "type"); // $NON-NLS-1$
    oResNode.addProperty(type, model.createResource(MEMETIC_NS + "Compendium-Node")); // $NON-NLS-1$

    int nNodeType = oNode.getType();
    String sTripleStoreString = UINodeTypeManager.getTripleStoreDescription(nNodeType);
    oResNode.addProperty(type, model.createResource(MEMETIC_NS + sTripleStoreString));
    if (nNodeType == ICoreConstants.REFERENCE_SHORTCUT) {
      oResNode.addProperty(
          model.createProperty(MEMETIC_NS, "has-reference"), oNode.getSource()); // $NON-NLS-1$
    }

    // ADD LABEL
    oResNode.addProperty(
        model.createProperty(MEMETIC_NS, "has-label"), oNode.getLabel()); // $NON-NLS-1$

    // ADD IF HAS TRIPLESTORE ID
    String sOriginalID = oNode.getOriginalID();

    if (sOriginalID.startsWith("TS:")
        && !(nNodeType == ICoreConstants.REFERENCE
            || nNodeType == ICoreConstants.REFERENCE)) { // $NON-NLS-1$
      int ind = sOriginalID.indexOf(":"); // $NON-NLS-1$
      sOriginalID = sOriginalID.substring(ind + 1);
      Property has_original_id = model.createProperty(MEMETIC_NS, "has-original-id"); // $NON-NLS-1$
      Resource original_id = model.createResource(sOriginalID);
      oResNode.addProperty(has_original_id, original_id);
    }
  }
  /**
   * Create the model and the meeting data for the given meeting id.
   *
   * @param oMeeting the object holding the meeting data.
   * @param model the model to add the data to.
   */
  public synchronized void addMeetingData(Meeting oMeeting, com.hp.hpl.jena.rdf.model.Model model) {

    Resource meeting = model.createResource(oMeeting.getMeetingID());

    meeting.addProperty(
        model.createProperty(MEETING_NS, "has-transcription"),
        model.createResource(
            oMeeting.getMeetingID()
                + "-"
                + oMeeting.getMeetingMapID())); // $NON-NLS-1$ //$NON-NLS-2$

    // Define the map owner, 'person', Reource and add their type, name, and if Compendium created
    // (always 'true').
    UserProfile oUser = oMeeting.getUser();
    if (oUser == null) {
      oUser = ProjectCompendium.APP.getModel().getUserProfile();
    }

    Resource person = model.createResource(MEMETIC_STUB + oUser.getId());
    person.addProperty(
        model.createProperty(RDF_NS, "type"),
        model.createResource(PORTAL_NS + "Person")); // $NON-NLS-1$ //$NON-NLS-2$
    person.addProperty(
        model.createProperty(PORTAL_NS, "full-name"), oUser.getUserName()); // $NON-NLS-1$
    person.addProperty(
        model.createProperty(MEMETIC_NS, "is-compendium-created"),
        "true"); //$NON-NLS-1$ //$NON-NLS-2$

    // UPLOAD THE DATA ABOUT THE MEETING MAP NODE ITSELF
    MeetingEvent oMeetingEvent =
        new MeetingEvent(
            oMeeting.getMeetingID(),
            false,
            MeetingEvent.NODE_ADDED_EVENT,
            (View) oMeeting.getMapNode(),
            oMeeting.getMapNode());
    addNode(oMeetingEvent, model);
  }
  /**
   * Upload the given model to the triplestore
   *
   * @param model, the model to upload.
   * @param sMeetingID the id of the meeting whose data is being uploaded.
   * @throws MalformedURLException if the urls used to create the HttpRemove and HttpAdd is
   *     malformed.
   */
  public void uploadModel(com.hp.hpl.jena.rdf.model.Model oModel, String sMeetingID)
      throws MalformedURLException {

    // System.out.println("About to try and upload: "+oModel.toString());

    com.hp.hpl.jena.rdf.model.Model oInnerModel = ModelFactory.createDefaultModel();
    Resource meeting = oInnerModel.createResource(sMeetingID);
    Property comp_is_proc =
        oInnerModel.createProperty(MEMETIC_NS, "compendium-is-processed"); // $NON-NLS-1$
    meeting.addProperty(comp_is_proc, "true"); // $NON-NLS-1$

    HttpRemove removeOp = new HttpRemove(sUrl);
    removeOp.setModel(oInnerModel);
    removeOp.exec();
    oInnerModel.close();

    HttpAdd addOp = new HttpAdd(sUrl);
    addOp.setModel(oModel);
    addOp.exec();
  }
  /**
   * Create the given event triple.
   *
   * @param oMeetingEvent the event whose data to upload.
   * @param model the model to add the data to.
   */
  public synchronized void addEvent(
      MeetingEvent oMeetingEvent, com.hp.hpl.jena.rdf.model.Model model) {

    int nEventType = oMeetingEvent.getEventType();

    // IF THIS EVENT INDICATES THAT A NEW NODE WAS CREATED,
    // CREATE A NEW NODE OBJECT FOR IT IN THE TRIPLESTORE BEFORE CONTINUING.
    if (nEventType == MeetingEvent.NODE_ADDED_EVENT
        || nEventType == MeetingEvent.NODE_TRANSCLUDED_EVENT) {
      addNode(oMeetingEvent, model);
    }

    String id = com.compendium.core.datamodel.Model.getStaticUniqueID();
    Resource meeting = model.createResource(oMeetingEvent.getMeetingID());
    Resource event = model.createResource(MEMETIC_STUB + id);
    Property type = model.createProperty(RDF_NS, "type"); // $NON-NLS-1$

    event.addProperty(type, model.createResource(MEMETIC_NS + "Compendium-Event")); // $NON-NLS-1$

    Resource oEventType = null;
    String oTagName = ""; // $NON-NLS-1$

    switch (oMeetingEvent.getEventType()) {
      case MeetingEvent.TAG_ADDED_EVENT:
        oEventType = model.createResource(MEMETIC_NS + "Tagging-Compendium-Node"); // $NON-NLS-1$
        oTagName = oMeetingEvent.getCode().getName();
        break;
      case MeetingEvent.TAG_REMOVED_EVENT:
        oEventType = model.createResource(MEMETIC_NS + "Detagging-Compendium-Node"); // $NON-NLS-1$
        oTagName = oMeetingEvent.getCode().getName();
        break;
      case MeetingEvent.NODE_ADDED_EVENT:
      case MeetingEvent.NODE_TRANSCLUDED_EVENT:
        oEventType = model.createResource(MEMETIC_NS + "Creating-Compendium-Node"); // $NON-NLS-1$
        break;
      case MeetingEvent.NODE_REMOVED_EVENT:
        oEventType = model.createResource(MEMETIC_NS + "Deleting-Compendium-Node"); // $NON-NLS-1$
        break;
      case MeetingEvent.VIEW_SELECTED_EVENT:
        oEventType = model.createResource(MEMETIC_NS + "Bringing-Map-To-Front"); // $NON-NLS-1$
        break;
      case MeetingEvent.NODE_FOCUSED_EVENT:
        oEventType = model.createResource(MEMETIC_NS + "Selecting-Compendium-Node"); // $NON-NLS-1$
        break;
      case MeetingEvent.REFERENCE_LAUNCHED_EVENT:
        oEventType = model.createResource(MEMETIC_NS + "Launching-Reference-Node"); // $NON-NLS-1$
        break;
      default:
        break;
    }

    event.addProperty(type, oEventType);

    if (!oTagName.equals("")) { // $NON-NLS-1$
      event.addProperty(model.createProperty(MEMETIC_NS, "has-tag"), oTagName); // $NON-NLS-1$
    }

    event.addProperty(
        model.createProperty(MEMETIC_NS, "has-media-start-time"),
        oMeetingEvent.getMediaIndex()); // $NON-NLS-1$
    event.addProperty(
        model.createProperty(MEMETIC_NS, "has-node"),
        model.createResource(
            oMeetingEvent.getMeetingID()
                + "-"
                + oMeetingEvent.getNodeID())); // $NON-NLS-1$ //$NON-NLS-2$
    event.addProperty(
        model.createProperty(MEMETIC_NS, "has-map"),
        model.createResource(
            oMeetingEvent.getMeetingID()
                + "-"
                + oMeetingEvent.getViewID())); // $NON-NLS-1$ //$NON-NLS-2$
    event.addProperty(
        model.createProperty(PORTAL_NS, "sender-of-information"),
        model.createResource(userURI)); // $NON-NLS-1$
    event.addProperty(
        model.createProperty(MEMETIC_NS, "created-post-meeting"),
        oMeetingEvent.creatingPostMeeting()); // $NON-NLS-1$
    meeting.addProperty(model.createProperty(PORTAL_NS, "has-sub-event"), event); // $NON-NLS-1$
  }