BlipData blipData = new BlipData(); blipData.setBlipId(blipId); blipData.setWaveId(ApiIdSerializer.instance().serialiseWaveId(wavelet.getWaveId())); blipData.setWaveletId(ApiIdSerializer.instance().serialiseWaveletId(wavelet.getWaveletId())); blipData.setParentBlipId(parentBlipId); blipData.setThreadId(thread.getId()); blipData.setCreator(creator); blipData.setLastModifiedTime(lastModifiedTime); blipData.setVersion(version); blipData.setContent(content); blipData.setChildBlipIds(childBlipIds); blipData.setContributors(contributors); blipData.setElements(elements); annotations.add(annotation); blipData.setAnnotations(annotations); replyThreadIds.add(thread.getId()); blipData.setReplyThreadIds(replyThreadIds);
BlipData blipData) { String blipId = blipData.getBlipId(); String parentBlipId = blipData.getParentBlipId(); String threadId = blipData.getThreadId(); String creator = blipData.getCreator(); long lastModifiedTime = blipData.getLastModifiedTime(); long version = blipData.getVersion(); String content = blipData.getContent(); List<String> childBlipIds = blipData.getChildBlipIds(); List<String> replyThreadIds = blipData.getReplyThreadIds(); if (replyThreadIds == null) { replyThreadIds = new ArrayList<String>(); List<String> contributors = blipData.getContributors(); Map<Integer, Element> elements = blipData.getElements(); List<Annotation> annotations = blipData.getAnnotations(); return new Blip(blipId, childBlipIds, content, contributors, creator, lastModifiedTime, version, parentBlipId, threadId, annotations, elements, replyThreadIds, wavelet);
/** * Constructor that extracts {@code waveId}, {@code waveletId}, and * {@code blipId} from the given {@code BlipData}. * * @param method the method or operation to be executed. * See {@link OperationType}. * @param id the id of the request. * @param blipData the {@code BlipData} to extract {@code waveId}, * {@code waveletId}, and {@code blipId} from. * @param parameters additional parameters for this operation. See * {@link ParamsProperty}. */ public OperationRequest(String method, String id, BlipData blipData, Parameter...parameters) { this(method, id, blipData.getWaveId(), blipData.getWaveletId(), blipData.getBlipId(), parameters); }
@Override protected void setUp() { service = ParticipantServices.create(); helper = new OperationServiceHelper(WAVELET_NAME, ROBOT); // BlipData constructor is broken, it doesn't set the blipId passed in the // constructor blipData = new BlipData(s(WAVE_ID), s(WAVELET_ID), TEMP_BLIP_ID, NEW_BLIP_CONTENT); blipData.setBlipId(TEMP_BLIP_ID); }
/** * Implementation for the {@link OperationType#WAVELET_APPEND_BLIP} method. It * appends a blip at the end of the root thread. * * @param operation the operation to execute. * @param context the context of the operation. * @param participant the participant performing this operation. * @param conversation the conversation to operate on. * @throws InvalidRequestException if the operation fails to perform */ private void appendBlip(OperationRequest operation, OperationContext context, ParticipantId participant, ObservableConversation conversation) throws InvalidRequestException { Preconditions.checkArgument( OperationUtil.getOperationType(operation) == OperationType.WAVELET_APPEND_BLIP, "Unsupported operation " + operation); BlipData blipData = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_DATA); ObservableConversationBlip newBlip = conversation.getRootThread().appendBlip(); context.putBlip(blipData.getBlipId(), newBlip); putContentForNewBlip(newBlip, blipData.getContent()); processBlipCreatedEvent(operation, context, participant, conversation, newBlip); }
public void testToBlipData() throws Exception { Wavelet wavelet = mock(Wavelet.class); when(wavelet.getWaveId()).thenReturn(WAVE_ID); when(wavelet.getId()).thenReturn(WAVELET_ID); ConversationBlip blip = conversation.getRootThread().getFirstBlip(); String replyThreadId = blip.addReplyThread(3).getId(); EventDataConverterV22 converter = new EventDataConverterV22(); EventMessageBundle eventMessageBundle = new EventMessageBundle(null, null); BlipData blipData = converter.toBlipData(blip, wavelet, eventMessageBundle); assertEquals(blip.getThread().getId(), blipData.getThreadId()); assertEquals(Lists.newArrayList(replyThreadId), blipData.getReplyThreadIds()); Map<String, BlipThread> threads = eventMessageBundle.getThreads(); assertEquals(1, threads.size()); assertEquals(1, threads.get(replyThreadId).getLocation()); }
public void testToBlipDataHandlesBlipWithEmptyDocument() throws Exception { Blips.init(); Conversation conversation = makeConversation(); Wavelet wavelet = mock(Wavelet.class); when(wavelet.getWaveId()).thenReturn(WAVE_ID); when(wavelet.getId()).thenReturn(WAVELET_ID); EventDataConverterV21 converter = new EventDataConverterV21(); assertEquals("", converter.toBlipData(conversation.getRootThread().getFirstBlip(), wavelet, new EventMessageBundle(null, null)).getContent()); }
@Override protected void setUp() { service = BlipOperationServices.create(); helper = new OperationServiceHelper(WAVELET_NAME, ALEX); // BlipData constructor is broken, it doesn't set the blipId passed in the // constructor blipData = new BlipData(s(WAVE_ID), s(WAVELET_ID), TEMP_BLIP_ID, NEW_BLIP_CONTENT); blipData.setBlipId(TEMP_BLIP_ID); }
/** * Implementation of the {@link OperationType#BLIP_CREATE_CHILD} method. It * appends a new reply thread to the blip specified in the operation. * * @param operation the operation to execute. * @param context the context of the operation. * @param participant the participant performing this operation. * @param conversation the conversation to operate on. * @throws InvalidRequestException if the operation fails to perform */ private void createChild(OperationRequest operation, OperationContext context, ParticipantId participant, ObservableConversation conversation) throws InvalidRequestException { Preconditions.checkArgument( OperationUtil.getOperationType(operation) == OperationType.BLIP_CREATE_CHILD, "Unsupported operation " + operation); BlipData blipData = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_DATA); String parentBlipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID); ConversationBlip parentBlip = context.getBlip(conversation, parentBlipId); ConversationBlip newBlip = parentBlip.addReplyThread().appendBlip(); context.putBlip(blipData.getBlipId(), newBlip); putContentForNewBlip(newBlip, blipData.getContent()); processBlipCreatedEvent(operation, context, participant, conversation, newBlip); }
public void testToBlipData() throws Exception { Wavelet wavelet = mock(Wavelet.class); when(wavelet.getWaveId()).thenReturn(WAVE_ID); when(wavelet.getId()).thenReturn(WAVELET_ID); ConversationBlip blip = conversation.getRootThread().getFirstBlip(); String replyThreadId = blip.addReplyThread(3).getId(); EventDataConverterV22 converter = new EventDataConverterV22(); EventMessageBundle eventMessageBundle = new EventMessageBundle(null, null); BlipData blipData = converter.toBlipData(blip, wavelet, eventMessageBundle); assertEquals(blip.getThread().getId(), blipData.getThreadId()); assertEquals(Lists.newArrayList(replyThreadId), blipData.getReplyThreadIds()); Map<String, BlipThread> threads = eventMessageBundle.getThreads(); assertEquals(1, threads.size()); assertEquals(1, threads.get(replyThreadId).getLocation()); }
public void testToBlipDataHandlesBlipWithEmptyDocument() throws Exception { Blips.init(); Conversation conversation = makeConversation(); Wavelet wavelet = mock(Wavelet.class); when(wavelet.getWaveId()).thenReturn(WAVE_ID); when(wavelet.getId()).thenReturn(WAVELET_ID); EventDataConverterV21 converter = new EventDataConverterV21(); assertEquals("", converter.toBlipData(conversation.getRootThread().getFirstBlip(), wavelet, new EventMessageBundle(null, null)).getContent()); }
for (Annotation annotation : blip.getAnnotations()) { Range range = annotation.getRange(); annotations.add(new Annotation(annotation.getName(), annotation.getValue(), for (Entry<Integer, Element> entry : blip.getElements().entrySet()) { ElementType type = entry.getValue().getType(); Element result = null; creator = blip.getCreator(); childBlipIds = blip.getChildBlipIds(); content = blip.getContent(); contributors = blip.getContributors(); blipId = blip.getBlipId(); lastModifiedTime = blip.getLastModifiedTime(); version = blip.getVersion(); parentBlipId = blip.getParentBlipId(); waveId = blip.getWaveId(); waveletId = blip.getWaveletId(); replyThreadIds = blip.getReplyThreadIds(); threadId = blip.getThreadId();
@Override public BlipData toBlipData(ConversationBlip blip, Wavelet wavelet, EventMessageBundle eventMessageBundle) { ConversationBlip parentBlip = findBlipParent(blip); BlipData blipData = new BlipData(); blipData.setCreator(blip.getAuthorId().getAddress()); blipData.setContributors(idsToParticipantIdList(blip.getContributorIds())); blipData.setBlipId(blip.getId()); blipData.setLastModifiedTime(blip.getLastModifiedTime()); blipData.setVersion(blip.getLastModifiedVersion()); blipData.setParentBlipId(parentBlip == null ? null : parentBlip.getId()); blipData.setWaveId(ApiIdSerializer.instance().serialiseWaveId(wavelet.getWaveId())); blipData.setWaveletId(ApiIdSerializer.instance().serialiseWaveletId(wavelet.getId())); blipData.setChildBlipIds(toBlipIdList(findBlipChildren(blip))); ApiView apiView = new ApiView(blip.getContent(), wavelet); // Set content. blipData.setContent(apiView.apiContents()); // Set Annotations. blipData.setAnnotations(extractAnnotations(blip.getContent(), apiView)); // blip.getContent().rangedAnnotations(0, blip.getContent().size(), null), // Set Form Elements. blipData.setElements(ElementSerializer.serialize(blip.getContent(), wavelet)); return blipData; }
@Override protected void setUp() { service = ParticipantServices.create(); helper = new OperationServiceHelper(WAVELET_NAME, ROBOT); // BlipData constructor is broken, it doesn't set the blipId passed in the // constructor blipData = new BlipData(s(WAVE_ID), s(WAVELET_ID), TEMP_BLIP_ID, NEW_BLIP_CONTENT); blipData.setBlipId(TEMP_BLIP_ID); }
/** * Implementation of the {@link OperationType#BLIP_CONTINUE_THREAD} method. It * appends a new blip to the end of the thread of the blip specified in the * operation. * * @param operation the operation to execute. * @param context the context of the operation. * @param participant the participant performing this operation. * @param conversation the conversation to operate on. * @throws InvalidRequestException if the operation fails to perform */ private void continueThread(OperationRequest operation, OperationContext context, ParticipantId participant, ObservableConversation conversation) throws InvalidRequestException { Preconditions.checkArgument( OperationUtil.getOperationType(operation) == OperationType.BLIP_CONTINUE_THREAD, "Unsupported operation " + operation); BlipData blipData = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_DATA); String parentBlipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID); ConversationBlip parentBlip = context.getBlip(conversation, parentBlipId); ConversationBlip newBlip = parentBlip.getThread().appendBlip(); context.putBlip(blipData.getBlipId(), newBlip); putContentForNewBlip(newBlip, blipData.getContent()); processBlipCreatedEvent(operation, context, participant, conversation, newBlip); }
@Override protected void setUp() { service = BlipOperationServices.create(); helper = new OperationServiceHelper(WAVELET_NAME, ALEX); // BlipData constructor is broken, it doesn't set the blipId passed in the // constructor blipData = new BlipData(s(WAVE_ID), s(WAVELET_ID), TEMP_BLIP_ID, NEW_BLIP_CONTENT); blipData.setBlipId(TEMP_BLIP_ID); }
context.putBlip(blipData.getBlipId(), newBlip); putContentForNewBlip(newBlip, blipData.getContent()); processBlipCreatedEvent(operation, context, participant, conversation, newBlip);
context.putBlip(blipData.getBlipId(), newBlip); putContentForNewBlip(newBlip, blipData.getContent()); processBlipCreatedEvent(operation, context, participant, conversation, newBlip);
context.putBlip(blipData.getBlipId(), newBlip); putContentForNewBlip(newBlip, blipData.getContent()); processBlipCreatedEvent(operation, context, participant, conversation, newBlip);