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

    logger.info("Updating collaboration <" + collaboration.getName() + "> state to be" + state);
    String domainName = DOMAIN_COLLABORATION;
    String itemName = collaboration.getId();
    List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>();

    replaceableAttributes.add(
        new ReplaceableAttribute(COLLABORATION_ATTRIBUTE_CURRENT_STATE, state, true));

    sdb.putAttributes(new PutAttributesRequest(domainName, itemName, replaceableAttributes));

    logger.debug(LOGPRE + "updateCollaborationState() end" + LOGPRE);
  }
예제 #2
0
  /*
   * (non-Javadoc)
   *
   * @see ca.unb.cs.pcsf.db.DBAccessService#deleteCollaboration(ca.unb.cs.pcsf.db.Collaboration)
   */
  public void deleteCollaboration(Collaboration collaboration) {
    logger.debug(LOGPRE + "deleteCollaboration() start" + LOGPRE);

    if (isCollaborationExist(collaboration.getName())) {
      logger.info("Deleting participants...");
      List<Participant> participants = collaboration.getParticipants();
      for (Participant p : participants) {
        sdb.deleteAttributes(new DeleteAttributesRequest(DOMAIN_PARTICIPANT, p.getId()));
      }
      sdb.deleteAttributes(
          new DeleteAttributesRequest(DOMAIN_COLLABORATION, collaboration.getId()));

      logger.info("Delete Done!");
      logger.debug(LOGPRE + "deleteCollaboration() end" + LOGPRE);
    }
  }
예제 #3
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;
  }
예제 #4
0
  /*
   * (non-Javadoc)
   *
   * @see ca.unb.cs.pcsf.db.DBAccessService#update(java.lang.Object)
   */
  public void update(Object o) {
    logger.debug(LOGPRE + "update() start" + LOGPRE);

    if (o instanceof Collaboration) {
      Collaboration collaboration = (Collaboration) o;
      logger.info("Updating Collaboration <" + collaboration.getName() + ">...");

      String domainName = DOMAIN_COLLABORATION;
      String itemName = collaboration.getId();
      List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>();

      replaceableAttributes.add(
          new ReplaceableAttribute(COLLABORATION_ATTRIBUTE_NAME, collaboration.getName(), true));
      for (Participant s : collaboration.getParticipants())
        replaceableAttributes.add(
            new ReplaceableAttribute(COLLABORATION_ATTRIBUTE_PARTICIPANT, s.getName(), true));

      sdb.putAttributes(new PutAttributesRequest(domainName, itemName, replaceableAttributes));
    }

    if (o instanceof Participant) {
      Participant participant = (Participant) o;
      logger.info("Updating participant <" + participant.getName() + ">...");

      String domainName = DOMAIN_PARTICIPANT;
      String itemName = participant.getId();
      List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>();

      replaceableAttributes.add(
          new ReplaceableAttribute(PARTICIPANT_ATTRIBUTE_IS_REG, participant.getIsReg(), true));

      sdb.putAttributes(new PutAttributesRequest(domainName, itemName, replaceableAttributes));
    }

    logger.debug(LOGPRE + "update() end" + LOGPRE);
  }
예제 #5
0
  /*
   * (non-Javadoc)
   *
   * @see ca.unb.cs.pcsf.db.DBAccessService#putDataIntoDomain(java.lang.Object)
   */
  public void putDataIntoDomain(Object object) {
    logger.debug(LOGPRE + "putDataIntoDomain() start" + LOGPRE);

    if (object instanceof Participant) {
      Participant participant = (Participant) object;
      List<ReplaceableItem> items = new ArrayList<ReplaceableItem>();
      items.add(
          new ReplaceableItem(participant.getId())
              .withAttributes(
                  new ReplaceableAttribute(PARTICIPANT_ATTRIBUTE_NAME, participant.getName(), true),
                  new ReplaceableAttribute(
                      PARTICIPANT_ATTRIBUTE_EMAIL, participant.getEmail(), true),
                  new ReplaceableAttribute(
                      PARTICIPANT_ATTRIBUTE_COLLABORATION_ID,
                      participant.getCollaborationId(),
                      false),
                  new ReplaceableAttribute(
                      PARTICIPANT_ATTRIBUTE_IS_REG, participant.getIsReg(), true)));

      logger.info("Putting participant <" + participant.getName() + "> into domain...");
      sdb.batchPutAttributes(new BatchPutAttributesRequest(DOMAIN_PARTICIPANT, items));
    }

    if (object instanceof Creator) {
      Creator creator = (Creator) object;
      if (!isCreatorExist(creator.getName())) {
        List<ReplaceableItem> items = new ArrayList<ReplaceableItem>();
        items.add(
            new ReplaceableItem(creator.getId())
                .withAttributes(
                    new ReplaceableAttribute(CREATOR_ATTRIBUTE_NAME, creator.getName(), true),
                    new ReplaceableAttribute(
                        CREATOR_ATTRIBUTE_PASSWORD, creator.getPassword(), true),
                    new ReplaceableAttribute(CREATOR_ATTRIBUTE_EMAIL, creator.getEmail(), true)));

        logger.info("Putting creator <" + creator.getName() + "> into domain...");
        sdb.batchPutAttributes(new BatchPutAttributesRequest(DOMAIN_CREATOR, items));
      }
    }

    if (object instanceof Collaboration) {
      Collaboration collaboration = (Collaboration) object;

      if (!isCollaborationExist(collaboration.getName())) {
        List<ReplaceableItem> items = new ArrayList<ReplaceableItem>();
        ReplaceableItem item = new ReplaceableItem(collaboration.getId());
        item.withAttributes(
            new ReplaceableAttribute(COLLABORATION_ATTRIBUTE_NAME, collaboration.getName(), true),
            new ReplaceableAttribute(
                COLLABORATION_ATTRIBUTE_CREATOR_ID, collaboration.getCreatorId(), true),
            new ReplaceableAttribute(
                COLLABORATION_ATTRIBUTE_CURRENT_STATE, collaboration.getCurrentState(), true),
            new ReplaceableAttribute(
                COLLABORATION_ATTRIBUTE_WORKFLOW_MODEL, collaboration.getWorkflowModel(), true));

        List<Participant> participants = collaboration.getParticipants();
        for (Participant participant : participants)
          item.withAttributes(
              new ReplaceableAttribute(
                  COLLABORATION_ATTRIBUTE_PARTICIPANT, participant.getName(), true));

        items.add(item);

        logger.info("Putting collaboration <" + collaboration.getName() + "> into domain...");
        sdb.batchPutAttributes(new BatchPutAttributesRequest(DOMAIN_COLLABORATION, items));
      }
    }

    logger.debug(LOGPRE + "putDataIntoDomain() end" + LOGPRE);
  }