Exemplo n.º 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;
  }
Exemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see ca.unb.cs.pcsf.db.DBAccessService#getCollaborationsByCreatorId(java.lang.String)
   */
  public List<Collaboration> getCollaborationsByCreatorId(String creatorId) {
    logger.debug(LOGPRE + "getCollaborationsByCreatorId() start" + LOGPRE);

    List<Collaboration> collaborations = new ArrayList<Collaboration>();
    String selectExpression =
        "select * from `"
            + DOMAIN_COLLABORATION
            + "` where "
            + COLLABORATION_ATTRIBUTE_CREATOR_ID
            + "='"
            + creatorId
            + "'";
    List<Item> items = this.getDataFromDomain(selectExpression);

    if (!items.isEmpty()) {
      for (Item item : items) {
        Collaboration collaboration = new Collaboration();
        List<String> users = new ArrayList<String>();
        List<Participant> participants = new ArrayList<Participant>();
        collaboration.setId(item.getName());
        for (Attribute attribute : item.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))
            users.add(attribute.getValue());
          if (attribute.getName().equals(COLLABORATION_ATTRIBUTE_WORKFLOW_MODEL))
            collaboration.setWorkflowModel(attribute.getValue());
        }

        for (String user : users) {
          Participant p = this.getParticipantByNameAndCollaborationId(user, collaboration.getId());
          participants.add(p);
        }

        collaboration.setParticipants(participants);
        collaborations.add(collaboration);
      }
    }

    logger.debug(LOGPRE + "getCollaborationsByCreatorId() end" + LOGPRE);
    return collaborations;
  }
Exemplo n.º 3
0
  /*
   * (non-Javadoc)
   *
   * @see ca.unb.cs.pcsf.db.PcsfSimpleDBAccess#getCollaborationByName(java.lang.String)
   */
  @Override
  public Collaboration getCollaborationByName(String collaborationName) {
    logger.debug(LOGPRE + "getCollaborationByName() start" + LOGPRE);

    Collaboration collaboration = new Collaboration();
    String selectExpression =
        "select * from `"
            + DOMAIN_COLLABORATION
            + "` where "
            + COLLABORATION_ATTRIBUTE_NAME
            + "='"
            + collaborationName
            + "'";
    Item findItem = this.getDataFromDomain(selectExpression).get(0);

    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());
    }

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

    collaboration.setParticipants(participants);

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