r688 - in trunk: faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities faxtomail-persistence/src/main/xmi faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action
Author: kmorin Date: 2014-11-17 13:30:11 +0000 (Mon, 17 Nov 2014) New Revision: 688 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/688 Log: fixes #6109 Import Archives : les collections ne sont pas li?\195?\169es aux emails Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailImpl.java trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java Modified: trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailImpl.java =================================================================== --- trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailImpl.java 2014-11-17 07:21:06 UTC (rev 687) +++ trunk/faxtomail-persistence/src/main/java/com/franciaflex/faxtomail/persistence/entities/EmailImpl.java 2014-11-17 13:30:11 UTC (rev 688) @@ -169,7 +169,7 @@ } @Override - public void setHistory(List<History> history) { + public void setHistory(Collection<History> history) { firstOpeningHistory = null; lastModificationHistory = null; lastAttachmentOpeningInFolderHistory = null; Modified: trunk/faxtomail-persistence/src/main/xmi/faxtomail.zargo =================================================================== (Binary files differ) Modified: trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java =================================================================== --- trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-11-17 07:21:06 UTC (rev 687) +++ trunk/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/service/EmailServiceImpl.java 2014-11-17 13:30:11 UTC (rev 688) @@ -172,7 +172,7 @@ //Hibernate.initialize(email.getTakenBy()); Hibernate.initialize(email.getReplies()); Hibernate.initialize(email.getAttachment()); - List<History> histories = email.getHistory(); + Collection<History> histories = email.getHistory(); if (histories != null) { for (History history : histories) { Hibernate.initialize(history.getFaxToMailUser()); @@ -331,12 +331,14 @@ if (fieldSet.contains(Email.PROPERTY_ARCHIVE_DATE)) { history = historyDao.create(History.PROPERTY_TYPE, HistoryType.ARCHIVED, History.PROPERTY_FAX_TO_MAIL_USER, user, - History.PROPERTY_MODIFICATION_DATE, now); + History.PROPERTY_MODIFICATION_DATE, now, + History.PROPERTY_EMAIL, email); } else if (fieldSet.contains(Email.PROPERTY_MAIL_FOLDER)) { history = historyDao.create(History.PROPERTY_TYPE, HistoryType.TRANSMISSION, History.PROPERTY_FAX_TO_MAIL_USER, user, - History.PROPERTY_MODIFICATION_DATE, now); + History.PROPERTY_MODIFICATION_DATE, now, + History.PROPERTY_EMAIL, email); } else { if (email.getTakenBy() == null && @@ -349,8 +351,9 @@ if (historyEmpty || !fieldSet.isEmpty()) { history = historyDao.create(History.PROPERTY_TYPE, historyEmpty ? HistoryType.CREATION : HistoryType.MODIFICATION, History.PROPERTY_FAX_TO_MAIL_USER, user, - History.PROPERTY_MODIFICATION_DATE, now); - history.setFields(fieldSet); + History.PROPERTY_MODIFICATION_DATE, now, + History.PROPERTY_EMAIL, email, + History.PROPERTY_FIELDS_JSON, AbstractFaxToMailTopiaDao.GSON_INSTANCE.toJson(fieldSet)); } } if (history != null) { @@ -394,11 +397,12 @@ AttachmentTopiaDao attachmentTopiaDao = getPersistenceContext().getAttachmentDao(); HistoryTopiaDao historyTopiaDao = getPersistenceContext().getHistoryDao(); - List<Attachment> currentAttachments = attachmentTopiaDao.forTopiaIdIn(email.getAttachmentTopiaIds()).findAll(); + List<Attachment> currentAttachments = attachmentTopiaDao.forEmailEquals(email).findAll(); if (currentAttachments == null) { currentAttachments = new ArrayList<>(); } - Map<String, Attachment> currentAttachmentIndex = new HashMap<>(Maps.uniqueIndex(currentAttachments, TopiaEntities.getTopiaIdFunction())); + Map<String, Attachment> currentAttachmentIndex = new HashMap<>(Maps.uniqueIndex(currentAttachments, + TopiaEntities.getTopiaIdFunction())); Set<String> newFiles = new HashSet<>(); @@ -430,6 +434,7 @@ // copy new data attachmentBinder.copyExcluding(attachment, currentAttachment, + Attachment.PROPERTY_EMAIL, Attachment.PROPERTY_EDITED_FILE, Attachment.PROPERTY_EDITED_FILE_NAME, Attachment.PROPERTY_ORIGINAL_FILE, @@ -438,6 +443,7 @@ Attachment.PROPERTY_TOPIA_ID, Attachment.PROPERTY_TOPIA_VERSION); + currentAttachment.setEmail(email); currentAttachment.setEditedFile(editedFile); currentAttachment.setOriginalFile(originalFile); @@ -465,15 +471,20 @@ if (!currentAttachment.isPersisted()) { // persist using cascade + currentAttachment = attachmentTopiaDao.create(currentAttachment); currentAttachments.add(currentAttachment); + + } else { + attachmentTopiaDao.update(currentAttachment); } } if (!newFiles.isEmpty()) { History history = historyTopiaDao.create(History.PROPERTY_TYPE, HistoryType.ATTACHMENT_ADDITION, History.PROPERTY_FAX_TO_MAIL_USER, user, - History.PROPERTY_MODIFICATION_DATE, new Date()); - history.setFields(newFiles); + History.PROPERTY_MODIFICATION_DATE, new Date(), + History.PROPERTY_EMAIL, email, + History.PROPERTY_FIELDS_JSON, AbstractFaxToMailTopiaDao.GSON_INSTANCE.toJson(newFiles)); email.addHistory(history); } @@ -507,7 +518,8 @@ if (BooleanUtils.isTrue(ediTranfer)) { // ajout d'un historique transmissionToEdi = historyDao.create(History.PROPERTY_TYPE, HistoryType.TRANSMISSION_TO_EDI, - History.PROPERTY_MODIFICATION_DATE, new Date()); + History.PROPERTY_MODIFICATION_DATE, new Date(), + History.PROPERTY_EMAIL, email); email.addHistory(transmissionToEdi); // changement du status @@ -517,7 +529,8 @@ } else { // TODO echatellier : pas sur qu'il faille l'ajouter tout le temps, mais sinon, le transfer se reproduira transmissionToEdi = historyDao.create(History.PROPERTY_TYPE, HistoryType.TRANSMISSION_TO_EDI, - History.PROPERTY_MODIFICATION_DATE, new Date()); + History.PROPERTY_MODIFICATION_DATE, new Date(), + History.PROPERTY_EMAIL, email); email.addHistory(transmissionToEdi); // passage en status @@ -530,7 +543,8 @@ // TODO echatellier : pas sur qu'il faille l'ajouter tout le temps, mais sinon, le transfer se reproduira transmissionToEdi = historyDao.create(History.PROPERTY_TYPE, HistoryType.TRANSMISSION_TO_EDI, - History.PROPERTY_MODIFICATION_DATE, new Date()); + History.PROPERTY_MODIFICATION_DATE, new Date(), + History.PROPERTY_EMAIL, email); email.addHistory(transmissionToEdi); // passage en status @@ -814,8 +828,9 @@ HistoryTopiaDao historyDao = getPersistenceContext().getHistoryDao(); History history = historyDao.create(History.PROPERTY_TYPE, type, History.PROPERTY_FAX_TO_MAIL_USER, user, - History.PROPERTY_MODIFICATION_DATE, date); - history.setFields(Sets.newHashSet(fields)); + History.PROPERTY_MODIFICATION_DATE, date, + History.PROPERTY_EMAIL, email, + History.PROPERTY_FIELDS_JSON, AbstractFaxToMailTopiaDao.GSON_INSTANCE.toJson(fields)); email.addHistory(history); @@ -847,13 +862,17 @@ HistoryTopiaDao historyDao = getPersistenceContext().getHistoryDao(); History history = historyDao.create(History.PROPERTY_TYPE, HistoryType.OPENING, History.PROPERTY_FAX_TO_MAIL_USER, user, - History.PROPERTY_MODIFICATION_DATE, new Date()); + History.PROPERTY_MODIFICATION_DATE, new Date(), + History.PROPERTY_EMAIL, email); email.addHistory(history); if (takeEmail) { + + String jsonFields = AbstractFaxToMailTopiaDao.GSON_INSTANCE.toJson(Sets.newHashSet(Email.PROPERTY_TAKEN_BY)); history = historyDao.create(History.PROPERTY_TYPE, HistoryType.MODIFICATION, History.PROPERTY_FAX_TO_MAIL_USER, user, - History.PROPERTY_MODIFICATION_DATE, new Date()); - history.setFields(Sets.newHashSet(Email.PROPERTY_TAKEN_BY)); + History.PROPERTY_MODIFICATION_DATE, new Date(), + History.PROPERTY_EMAIL, email, + History.PROPERTY_FIELDS_JSON, jsonFields); email.addHistory(history); email.setTakenBy(user); } @@ -1072,18 +1091,21 @@ HistoryTopiaDao historyDao = getPersistenceContext().getHistoryDao(); Date now = new Date(); + String jsonFields = AbstractFaxToMailTopiaDao.GSON_INSTANCE.toJson(Sets.newHashSet(email2.getObject())); History history = historyDao.create(History.PROPERTY_TYPE, HistoryType.GROUP, History.PROPERTY_FAX_TO_MAIL_USER, user, - History.PROPERTY_MODIFICATION_DATE, now); - history.setFields(Sets.newHashSet(email2.getObject())); + History.PROPERTY_MODIFICATION_DATE, now, + History.PROPERTY_EMAIL, email1, + History.PROPERTY_FIELDS_JSON, jsonFields); email1.addHistory(history); - Email result = emailDao.update(email1); + jsonFields = AbstractFaxToMailTopiaDao.GSON_INSTANCE.toJson(Sets.newHashSet(email1.getObject())); History history2 = historyDao.create(History.PROPERTY_TYPE, HistoryType.GROUP, History.PROPERTY_FAX_TO_MAIL_USER, user, - History.PROPERTY_MODIFICATION_DATE, now); - history2.setFields(Sets.newHashSet(email1.getObject())); + History.PROPERTY_MODIFICATION_DATE, now, + History.PROPERTY_EMAIL, email2, + History.PROPERTY_FIELDS_JSON, jsonFields); email2.addHistory(history2); emailDao.update(email2); @@ -1183,7 +1205,8 @@ HistoryTopiaDao historyDao = getPersistenceContext().getHistoryDao(); History history = historyDao.create(History.PROPERTY_TYPE, HistoryType.REPLY, History.PROPERTY_FAX_TO_MAIL_USER, user, - History.PROPERTY_MODIFICATION_DATE, now); + History.PROPERTY_MODIFICATION_DATE, now, + History.PROPERTY_EMAIL, email); email.addHistory(history); Client client = email.getClient(); @@ -1205,7 +1228,8 @@ History history = historyDao.create(History.PROPERTY_TYPE, HistoryType.TRANSMISSION, History.PROPERTY_FAX_TO_MAIL_USER, currentUser, - History.PROPERTY_MODIFICATION_DATE, new Date()); + History.PROPERTY_MODIFICATION_DATE, new Date(), + History.PROPERTY_EMAIL, email); email.addHistory(history); } @@ -1611,16 +1635,18 @@ Client client = getClientService().getClientForCode(archiveBean.getClientCode(), company); email.setClient(client); + // persist it + email.setTopiaId(getTopiaId(Email.class, email)); + statelessSession.insert(email); + History history = historyDao.newInstance(); history.setType(HistoryType.ARCHIVED); history.setModificationDate(new Date()); + history.setEmail(email); history.setTopiaId(getTopiaId(History.class, history)); statelessSession.insert(history); - email.addHistory(history); - // persist it - email.setTopiaId(getTopiaId(Email.class, email)); - statelessSession.insert(email); +// email.addHistory(history); // manage attachments if (archiveBean.getAttachmentPaths() != null) { @@ -1638,6 +1664,8 @@ } Attachment attachment = attachmentDao.newInstance(); + attachment.setEmail(email); + AttachmentFile attachmentFile = attachmentFileDao.newInstance(); attachmentFile.setFilename(attFile.getName()); @@ -1655,7 +1683,7 @@ attachment.setTopiaId(getTopiaId(Attachment.class, attachment)); statelessSession.insert(attachment); - email.addAttachment(attachment); +// email.addAttachment(attachment); } statelessSession.update(email); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-11-17 07:21:06 UTC (rev 687) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-11-17 13:30:11 UTC (rev 688) @@ -504,12 +504,12 @@ return editObject.getReference(); } - public void setHistory(List<History> history) { + public void setHistory(Collection<History> history) { editObject.setHistory(history); firePropertyChanged(Email.PROPERTY_HISTORY, null, history); } - public List<History> getHistory() { + public Collection<History> getHistory() { return editObject.getHistory(); } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java 2014-11-17 07:21:06 UTC (rev 687) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/replies/DemandRepliesUIHandler.java 2014-11-17 13:30:11 UTC (rev 688) @@ -305,7 +305,9 @@ fileName = fileName.replaceFirst("^<(.*)>$", "$1"); } fileName = MimeUtility.decodeText(fileName); - log.info("FileName : " + fileName); + if (log.isDebugEnabled()) { + log.debug("FileName : " + fileName); + } /*File dir = new File(FileUtils.getTempDirectory(), topiaId); if (!dir.exists()) { Modified: trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java =================================================================== --- trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java 2014-11-17 07:21:06 UTC (rev 687) +++ trunk/faxtomail-ui-web/src/main/java/com/franciaflex/faxtomail/web/action/SearchAction.java 2014-11-17 13:30:11 UTC (rev 688) @@ -311,11 +311,11 @@ break; case ATTACHMENT: - List<Attachment> attachments = email.getAttachment(); + Collection<Attachment> attachments = email.getAttachment(); if (CollectionUtils.isNotEmpty(attachments)) { final Decorator<Attachment> decorator = decoratorService.getDecoratorByType(Attachment.class); - List<String> attachmentNames = Lists.transform(attachments, new Function<Attachment, String>() { + Collection<String> attachmentNames = Collections2.transform(attachments, new Function<Attachment, String>() { @Override public String apply(Attachment attachment) { String name = decorator.toString(attachment);
participants (1)
-
kmorin@users.forge.codelutin.com