コード例 #1
0
  /*
   * (non-Javadoc)
   *
   * @see ca.unb.cs.pcsf.db.DBAccessService#getParticipantById(java.lang.String)
   */
  public Participant getParticipantById(String participantId) {
    logger.debug(LOGPRE + "getParticipantById() start" + LOGPRE);

    Participant participant = new Participant();
    String selectRequest = "select * from `" + DOMAIN_PARTICIPANT + "`";
    List<Item> items = this.getDataFromDomain(selectRequest);
    Item findItem = new Item();

    if (!items.isEmpty()) {
      for (Item item : items) {
        if (item.getName().equals(participantId)) {
          findItem = item;
          break;
        }
      }
    }

    if (findItem != null) {
      participant.setId(findItem.getName());
      for (Attribute attribute : findItem.getAttributes()) {
        if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_NAME))
          participant.setName(attribute.getValue());
        if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_EMAIL))
          participant.setEmail(attribute.getValue());
        if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_COLLABORATION_ID))
          participant.setCollaborationId(attribute.getValue());
        if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_IS_REG))
          participant.setIsReg(attribute.getValue());
      }
    }

    logger.debug(LOGPRE + "getParticipantById() end" + LOGPRE);
    return participant;
  }
コード例 #2
0
  /**
   * Get a participant record from the data base by name and collaboration id.
   *
   * @param participantName
   * @param collaborationId
   * @return a participant
   */
  private Participant getParticipantByNameAndCollaborationId(
      String participantName, String collaborationId) {
    logger.debug(LOGPRE + "getParticipantByNameAndCollaborationId() start" + LOGPRE);

    Participant participant = new Participant();
    String selectRequest =
        "select * from `"
            + DOMAIN_PARTICIPANT
            + "` where "
            + PARTICIPANT_ATTRIBUTE_NAME
            + " = '"
            + participantName
            + "' AND "
            + PARTICIPANT_ATTRIBUTE_COLLABORATION_ID
            + "='"
            + collaborationId
            + "'";
    List<Item> items = this.getDataFromDomain(selectRequest);

    if (items != null) {
      Item item = items.get(0);
      participant.setId(item.getName());
      for (Attribute attribute : item.getAttributes()) {
        if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_NAME))
          participant.setName(attribute.getValue());
        if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_EMAIL))
          participant.setEmail(attribute.getValue());
        if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_COLLABORATION_ID))
          participant.setCollaborationId(attribute.getValue());
        if (attribute.getName().equals(PARTICIPANT_ATTRIBUTE_IS_REG))
          participant.setIsReg(attribute.getValue());
      }
    }

    logger.debug(LOGPRE + "getParticipantByNameAndCollaborationId() end" + LOGPRE);
    return participant;
  }