Package ru.org.linux.edithistory

Examples of ru.org.linux.edithistory.EditHistoryDto


   * @param originalMessageText старое содержимое комментария
   * @param comment             изменённый комментарий
   * @param messageText         новое содержимое комментария
   */
  private void addEditHistoryItem(User editor, Comment original, String originalMessageText, Comment comment, String messageText) {
    EditHistoryDto editHistoryDto = new EditHistoryDto();
    editHistoryDto.setMsgid(original.getId());
    editHistoryDto.setObjectType(EditHistoryObjectTypeEnum.COMMENT);
    editHistoryDto.setEditor(editor.getId());

    boolean modified = false;
    if (!original.getTitle().equals(comment.getTitle())) {
      editHistoryDto.setOldtitle(original.getTitle());
      modified = true;
    }

    if (!originalMessageText.equals(messageText)) {
      editHistoryDto.setOldmessage(originalMessageText);
      modified = true;
    }

    if (modified) {
      editHistoryService.insert(editHistoryDto);
View Full Code Here


    return msgid;
  }

  @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
  public boolean updateMessage(Topic oldMsg, Topic msg, User editor, List<String> newTags, String newText) {
    EditHistoryDto editHistoryDto = new EditHistoryDto();

    editHistoryDto.setMsgid(msg.getId());
    editHistoryDto.setObjectType(EditHistoryObjectTypeEnum.TOPIC);
    editHistoryDto.setEditor(editor.getId());

    boolean modified = false;

    String oldText = msgbaseDao.getMessageText(msg.getId()).getText();

    if (!oldText.equals(newText)) {
      editHistoryDto.setOldmessage(oldText);
      modified = true;

      msgbaseDao.updateMessage(msg.getId(), newText);
    }

    if (!oldMsg.getTitle().equals(msg.getTitle())) {
      modified = true;
      editHistoryDto.setOldtitle(oldMsg.getTitle());

      namedJdbcTemplate.update(
        "UPDATE topics SET title=:title WHERE id=:id",
        ImmutableMap.of("title", msg.getTitle(), "id", msg.getId())
      );
    }

    if (!equalStrings(oldMsg.getLinktext(), msg.getLinktext())) {
      modified = true;
      editHistoryDto.setOldlinktext(oldMsg.getLinktext());

      namedJdbcTemplate.update(
        "UPDATE topics SET linktext=:linktext WHERE id=:id",
        ImmutableMap.of("linktext", msg.getLinktext(), "id", msg.getId())
      );
    }

    if (!equalStrings(oldMsg.getUrl(), msg.getUrl())) {
      modified = true;
      editHistoryDto.setOldurl(oldMsg.getUrl());

      namedJdbcTemplate.update(
        "UPDATE topics SET url=:url WHERE id=:id",
        ImmutableMap.of("url", msg.getUrl(), "id", msg.getId())
      );
    }

    if (newTags != null) {
      List<String> oldTags = topicTagService.getTags(msg);

      boolean modifiedTags = topicTagService.updateTags(msg.getId(), oldTags, newTags);

      if (modifiedTags) {
        editHistoryDto.setOldtags(TagService.tagsToString(oldTags));
        modified = true;
      }
    }

    if (oldMsg.isMinor() != msg.isMinor()) {
      namedJdbcTemplate.update("UPDATE topics SET minor=:minor WHERE id=:id",
              ImmutableMap.of("minor", msg.isMinor(), "id", msg.getId()));

      editHistoryDto.setOldminor(oldMsg.isMinor());

      modified = true;
    }

    if (modified) {
View Full Code Here

  @Autowired
  private TopicDao topicDao;

  @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
  public void deleteImage(User editor, Image image) {
    EditHistoryDto info = new EditHistoryDto();

    info.setEditor(editor.getId());
    info.setMsgid(image.getTopicId());
    info.setOldimage(image.getId());
    info.setObjectType(EditHistoryObjectTypeEnum.TOPIC);

    imageDao.deleteImage(image);

    editHistoryService.insert(info);
    topicDao.updateLastmod(image.getTopicId(), false);
View Full Code Here

    boolean publish = request.getParameter("publish") != null;

    List<EditHistoryDto> editInfoList = editHistoryService.getEditInfo(message.getId(), EditHistoryObjectTypeEnum.TOPIC);

    if (!editInfoList.isEmpty()) {
      EditHistoryDto editHistoryDto = editInfoList.get(0);
      params.put("editInfo", editHistoryDto);

      if (lastEdit == null || editHistoryDto.getEditdate().getTime()!=lastEdit) {
        errors.reject(null, "Сообщение было отредактировано независимо");
      }
    }

    boolean commit = request.getParameter("commit") != null;
View Full Code Here

TOP

Related Classes of ru.org.linux.edithistory.EditHistoryDto

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.