/** * Copies the contents of a conversational wavelet to another wavelet, * first clearing any documents in the destination document. * * @param sourceWavelet the source wavelet * @param destWavelet the destination wavelet */ public static void clearAndCopyWaveletContents(Wavelet sourceWavelet, Wavelet destWavelet) { clearWaveletContents(destWavelet); copyWaveletContents(sourceWavelet, destWavelet); }
/** * Clears the content of each document / blip on the provided wavelet. * * @param wavelet the wavelet to clear */ public static void clearWaveletContents(Wavelet wavelet) { Set<String> docIds = wavelet.getDocumentIds(); for (String docId : docIds) { if (!IdUtil.isManifestDocument(docId)) { clearDocument(wavelet, docId); } } clearDocument(wavelet, IdUtil.MANIFEST_DOCUMENT_ID); } }
/** * Copy the contents of a conversational wavelet to another wavelet, appending * the contents to any destination documents which already exist. * * @param sourceWavelet the source wavelet * @param destWavelet the destination wavelet */ public static void copyWaveletContents(Wavelet sourceWavelet, Wavelet destWavelet) { Set<String> docIds = sourceWavelet.getDocumentIds(); Preconditions.checkArgument(docIds.contains(IdUtil.MANIFEST_DOCUMENT_ID), "Wavelet is not conversational."); for (String docId : docIds) { if (!IdUtil.isManifestDocument(docId)) { copyDocument(sourceWavelet, destWavelet, docId); } } copyDocument(sourceWavelet, destWavelet, IdUtil.MANIFEST_DOCUMENT_ID); }
/** * Tests copy of an empty wavelet. */ public void testEmptyWaveletCopy() { ConversationCopier.copyWaveletContents(sourceWavelet, destWavelet); compareWavelets(sourceWavelet, destWavelet); }
/** * Tests copy of an empty wavelet. */ public void testEmptyWaveletCopy() { ConversationCopier.copyWaveletContents(sourceWavelet, destWavelet); compareWavelets(sourceWavelet, destWavelet); }
/** * Tests copying of a wavelet with a single blip containing some content. */ public void testSingleBlip() { WaveletBasedConversationBlip blip = source.getRootThread().appendBlip(); Document doc = blip.getContent(); LineContainers.appendToLastLine(doc, XmlStringBuilder.createText(SAMPLE_TEXT)); ConversationCopier.copyWaveletContents(sourceWavelet, destWavelet); compareWavelets(sourceWavelet, destWavelet); }
/** * Tests copying of a wavelet with a single blip containing some content. */ public void testSingleBlip() { WaveletBasedConversationBlip blip = source.getRootThread().appendBlip(); Document doc = blip.getContent(); LineContainers.appendToLastLine(doc, XmlStringBuilder.createText(SAMPLE_TEXT)); ConversationCopier.copyWaveletContents(sourceWavelet, destWavelet); compareWavelets(sourceWavelet, destWavelet); }
/** * Tests copying of a wavelet with a root thread and a reply thread. */ public void testReplyThreadCopy() { WaveletBasedConversationBlip blip = source.getRootThread().appendBlip(); WaveletBasedConversationThread conversationThread = blip.addReplyThread(); Document doc = conversationThread.appendBlip().getContent(); LineContainers.appendToLastLine(doc, XmlStringBuilder.createText(SAMPLE_TEXT)); ConversationCopier.copyWaveletContents(sourceWavelet, destWavelet); compareWavelets(sourceWavelet, destWavelet); }
/** * Tests copying of a wavelet with a root thread and a reply thread. */ public void testReplyThreadCopy() { WaveletBasedConversationBlip blip = source.getRootThread().appendBlip(); WaveletBasedConversationThread conversationThread = blip.addReplyThread(); Document doc = conversationThread.appendBlip().getContent(); LineContainers.appendToLastLine(doc, XmlStringBuilder.createText(SAMPLE_TEXT)); ConversationCopier.copyWaveletContents(sourceWavelet, destWavelet); compareWavelets(sourceWavelet, destWavelet); }