@Override
 public Collection<ChangeSet> findAllChangeSets(final LoadTuner loadTuner) {
   Collection<ChangeSet> allChangeSets = changeSetDao.findAllChangeSets();
   for (ChangeSet changeSet : allChangeSets) {
     addMemberObjectsToChangeSet(changeSet, loadTuner);
   }
   return allChangeSets;
 }
 @Override
 public Collection<ChangeSet> findAllChangeSetsByUserGuid(
     final String userGuid, final LoadTuner loadTuner) {
   Collection<ChangeSet> changeSets = changeSetDao.findAllChangeSetsByUserGuid(userGuid);
   for (ChangeSet changeSet : changeSets) {
     addMemberObjectsToChangeSet(changeSet, loadTuner);
   }
   return changeSets;
 }
  @Override
  public Collection<ChangeSet> findByCriteria(
      final ChangeSetSearchCriteria criteria, final LoadTuner loadTuner) {
    Collection<ChangeSet> changeSets = changeSetDao.findByCriteria(criteria);
    for (ChangeSet changeSet : changeSets) {
      addMemberObjectsToChangeSet(changeSet, loadTuner);
    }

    return changeSets;
  }
  @Override
  public void remove(final String objectGroupId) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Remove a change set by objectGroupId: " + objectGroupId);
    }

    checkCanRemove(objectGroupId);

    // remove the change set itself
    changeSetDao.remove(objectGroupId);
  }
  @Override
  public ChangeSet updateState(
      final String changeSetGuid, final ChangeSetStateCode stateCode, final LoadTuner loadTuner) {
    if (StringUtils.isEmpty(changeSetGuid) || stateCode == null) {
      throw new IllegalArgumentException(
          String.format(
              "Must specify change set GUID: %s and a state code: %s",
              new Object[] {changeSetGuid, stateCode}));
    }
    ChangeSet changeSet = changeSetDao.findByGuid(changeSetGuid);
    if (changeSet == null) {
      throw new EpServiceException(
          "No change set with GUID '" + changeSetGuid + "' could be found.");
    }
    changeSet.setStateCode(stateCode);

    final ChangeSet updatedChangedSet = changeSetDao.update(changeSet);

    addMemberObjectsToChangeSet(updatedChangedSet, loadTuner);

    return updatedChangedSet;
  }
  @Override
  public List<ChangeSet> findByCriteria(
      final ChangeSetSearchCriteria criteria,
      final LoadTuner loadTuner,
      final int start,
      final int maxResults) {
    List<ChangeSet> changeSets = changeSetDao.findByCriteria(criteria, start, maxResults);
    for (ChangeSet changeSet : changeSets) {
      addMemberObjectsToChangeSet(changeSet, loadTuner);
    }

    return changeSets;
  }
  @Override
  public ChangeSet get(final String guid, final LoadTuner loadTuner) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Get a change set by GUID: " + guid);
    }

    ChangeSet changeSet = changeSetDao.findByGuid(guid);

    if (changeSet != null) {
      addMemberObjectsToChangeSet(changeSet, loadTuner);
    }

    return changeSet;
  }
  @Override
  public ChangeSet update(final ChangeSet changeSet, final LoadTuner loadTuner) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Update a change set: " + changeSet);
    }

    checkChangeAllowed(changeSet.getGuid());

    ChangeSet updatedChangedSet = changeSetDao.update(changeSet);

    addMemberObjectsToChangeSet(updatedChangedSet, loadTuner);

    return updatedChangedSet;
  }
  @Override
  public ChangeSet add(final ChangeSet changeSet) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Add a change set: " + changeSet);
    }

    String groupId = changeSetMemberDao.generateChangeSetGroupId();
    changeSet.addAssignedUser(changeSet.getCreatedByUserGuid());

    // for consistency, always use the time service to set the created date
    changeSet.setCreatedDate(timeService.getCurrentTime());

    // if no state code was set the default is OPEN
    if (changeSet.getStateCode() == null) {
      changeSet.setStateCode(ChangeSetStateCode.OPEN);
    }

    getChangeSetMutator(changeSet).setObjectGroupId(groupId);
    return changeSetDao.add(changeSet);
  }
 @Override
 public long getCountByCriteria(final ChangeSetSearchCriteria searchCriteria) {
   return changeSetDao.getCountByCriteria(searchCriteria);
 }