Example #1
0
  /**
   * Return a link object with the given id and details. If a link with the given id has already
   * been created in this session, update its data and return that, else create a new one, and add
   * it to the list.
   *
   * @param String sLinkID, the unique identifier for this Link.
   * @param java.util.Date dCreationDate, the date the Link was created.
   * @param java.util.Date dModificationDate, the date the link was last modified.
   * @param String sAuthor, the name of the porson who created this Link.
   * @param Stirng sType, the type of this link.
   * @param String sOriginalID, the original ID of this link if/when imported.
   * @param sLabel, the label for this Link.
   */
  public static Link getLink(
      String sLinkID,
      java.util.Date dCreationDate,
      java.util.Date dModificationDate,
      String sAuthor,
      String sType,
      String sOriginalID,
      String sLabel) {

    int i = 0;
    for (i = 0; i < linkSummaryList.size(); i++) {
      if (sLinkID.equals(((Link) linkSummaryList.elementAt(i)).getId())) {
        break;
      }
    }

    Link link = null;
    if (i == linkSummaryList.size()) {
      link =
          new Link(sLinkID, dCreationDate, dModificationDate, sAuthor, sType, sOriginalID, sLabel);
      linkSummaryList.addElement(link);
    } else {
      link = (Link) linkSummaryList.elementAt(i);

      // UPDATE THE DETAILS
      link.setTypeLocal(sType);
      link.setAuthorLocal(sAuthor);
      link.setOriginalIDLocal(sOriginalID);
      link.setLabelLocal(sLabel);
      link.setCreationDateLocal(dCreationDate);
      link.setModificationDateLocal(dModificationDate);
    }
    return link;
  }
Example #2
0
  /**
   * Sets the link type in local data and the database.
   *
   * @param sType, the link type for this link.
   * @exception java.sql.SQLException
   * @exception com.compendium.core.datamodel.ModelSessionException
   */
  public void setType(String sType) throws SQLException, ModelSessionException {

    if (this.sType.equals(sType)) return;

    if (oModel == null) throw new ModelSessionException("Model is null in Link.setType");

    if (oSession == null) throw new ModelSessionException("Session is null in Link.setType");

    // call link service to update database
    ILinkService ls = oModel.getLinkService();
    ls.setType(oSession, sId, this.sType, sType);

    setTypeLocal(sType);
  }