예제 #1
0
  /*
   * (non-Javadoc)
   *
   * @see ca.unb.cs.pcsf.db.DBAccessService#getCollaborationById(java.lang.String)
   */
  public Collaboration getCollaborationById(String collaborationId) {
    logger.debug(LOGPRE + "getCollaborationById() start" + LOGPRE);

    Collaboration collaboration = new Collaboration();
    String selectRequest = "select * from `" + DOMAIN_COLLABORATION + "`";
    List<Item> items = this.getDataFromDomain(selectRequest);
    Item findItem = new Item();

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

    if (findItem != null) {
      List<String> participantNames = new ArrayList<String>();
      List<Participant> participants = new ArrayList<Participant>();

      collaboration.setId(findItem.getName());
      for (Attribute attribute : findItem.getAttributes()) {
        if (attribute.getName().equals(COLLABORATION_ATTRIBUTE_NAME))
          collaboration.setName(attribute.getValue());
        if (attribute.getName().equals(COLLABORATION_ATTRIBUTE_CREATOR_ID))
          collaboration.setCreatorId(attribute.getValue());
        if (attribute.getName().equals(COLLABORATION_ATTRIBUTE_CURRENT_STATE))
          collaboration.setCurrentState(attribute.getValue());
        if (attribute.getName().equals(COLLABORATION_ATTRIBUTE_PARTICIPANT))
          participantNames.add(attribute.getValue());
        if (attribute.getName().equals(COLLABORATION_ATTRIBUTE_WORKFLOW_MODEL))
          collaboration.setWorkflowModel(attribute.getValue());
        if (attribute.getName().equals(COLLABORATION_ATTRIBUTE_PROCESS_DEFINITION_ID))
          collaboration.setProcessDefId(attribute.getValue());
      }

      for (String s : participantNames) {
        Participant p = this.getParticipantByNameAndCollaborationId(s, findItem.getName());
        participants.add(p);
      }

      collaboration.setParticipants(participants);
    }

    logger.debug(LOGPRE + "getCollaborationById() end" + LOGPRE);
    return collaboration;
  }