/** * Adds a thread to this wavelet. * * @param thread the thread to add. */ protected void addThread(BlipThread thread) { threads.put(thread.getId(), thread); }
BlipThread thread = entry.getValue(); threads.put(entry.getKey(), new BlipThread(thread.getId(), thread.getLocation(), thread.getBlipIds(), blips));
for (Entry<String, BlipThread> entry : tempThreads.entrySet()) { BlipThread thread = entry.getValue(); threads.put(entry.getKey(), new BlipThread(thread.getId(), thread.getLocation(), thread.getBlipIds(), blips));
/** * Removes a blip from this wavelet. * * @param blipId the id of the blip to be removed. */ public void delete(String blipId) { operationQueue.deleteBlip(this, blipId); Blip removed = blips.remove(blipId); if (removed != null) { // Remove the blip from the parent blip. Blip parentBlip = removed.getParentBlip(); if (parentBlip != null) { parentBlip.deleteChildBlipId(blipId); } // Remove the blip from the containing thread. BlipThread thread = removed.getThread(); if (thread != null) { thread.removeBlip(removed); } // If the containing thread is now empty, remove it from the parent blip // and from the wavelet. if (thread != null && parentBlip != null && thread.isEmpty()) { parentBlip.removeThread(thread); threads.remove(thread.getId()); } } }
blipData.setWaveletId(ApiIdSerializer.instance().serialiseWaveletId(wavelet.getWaveletId())); blipData.setParentBlipId(parentBlipId); blipData.setThreadId(thread.getId()); blipData.setCreator(creator); blipData.setLastModifiedTime(lastModifiedTime); replyThreads.size()); for (BlipThread thread : inlineReplyThreads.values()) { replyThreadIds.add(thread.getId()); replyThreadIds.add(thread.getId());
/** * Appends a blip to a wavelet. * * @param wavelet the wavelet to append the new blip to. * @param initialContent the initial content of the new blip. * @return an instance of {@link Blip} that represents the new blip. */ public Blip appendBlipToWavelet(Wavelet wavelet, String initialContent) { Blip newBlip = newBlip(wavelet, initialContent, null, generateTempBlipId(wavelet), wavelet.getRootThread().getId()); appendOperation(OperationType.WAVELET_APPEND_BLIP, wavelet, Parameter.of(ParamsProperty.BLIP_DATA, newBlip.serialize())); return newBlip; }
/** * Creates a child blip of another blip. * * @param blip the parent blip. * @return an instance of {@link Blip} that represents the new child blip. */ public Blip createChildOfBlip(Blip blip) { // Create a new thread. String tempBlipId = generateTempBlipId(blip.getWavelet()); Wavelet wavelet = blip.getWavelet(); BlipThread thread = new BlipThread(tempBlipId, -1, new ArrayList<String>(), wavelet.getBlips()); // Add the new thread to the blip and wavelet. blip.addThread(thread); wavelet.addThread(thread); // Create a new blip in the new thread. Blip newBlip = newBlip(blip.getWavelet(), "", blip.getBlipId(), tempBlipId, thread.getId()); appendOperation(OperationType.BLIP_CREATE_CHILD, blip, Parameter.of(ParamsProperty.BLIP_DATA, newBlip.serialize())); return newBlip; }
/** * Appends a new blip to the end of the thread of the given blip. * * @param blip the blip whose thread will be appended. * @return an instance of {@link Blip} that represents the new blip. */ public Blip continueThreadOfBlip(Blip blip) { Blip newBlip = newBlip(blip.getWavelet(), "", blip.getParentBlipId(), generateTempBlipId(blip.getWavelet()), blip.getThread().getId()); appendOperation(OperationType.BLIP_CONTINUE_THREAD, blip, Parameter.of(ParamsProperty.BLIP_DATA, newBlip.serialize())); return newBlip; }
/** * Inserts a new inline blip at a specified location. * * @param blip the blip to anchor this inline blip from. * @param position the position in the given blip to insert this new inline * blip. * @return an instance of {@link Blip} that represents the inline blip. */ public Blip insertInlineBlipToDocument(Blip blip, int position) { // Create a new thread. String tempBlipId = generateTempBlipId(blip.getWavelet()); Wavelet wavelet = blip.getWavelet(); BlipThread thread = new BlipThread(tempBlipId, position, new ArrayList<String>(), wavelet.getBlips()); // Add the new thread to the blip and wavelet. blip.addThread(thread); wavelet.addThread(thread); // Create a new blip in the new thread. Blip inlineBlip = newBlip(blip.getWavelet(), "", blip.getBlipId(), tempBlipId, thread.getId()); appendOperation(OperationType.DOCUMENT_INSERT_INLINE_BLIP, blip, Parameter.of(ParamsProperty.INDEX, position), Parameter.of(ParamsProperty.BLIP_DATA, inlineBlip.serialize())); return inlineBlip; }