I have a "about what the op should do or how it
should work" question :)

>From [1] I assume that the Document operations signature is like
below:
document.modify(range: Range, index: Integer, modifyQuery:
DocumentModifyQuery, modifyAction: DocumentModifyAction)

First of all I assume that DOCUMENT_INSERT operation is applied to
plain text - is it correct?

So in the context of DOCUMENT_INSERT operation the input is like
follows:

range - not applicable
index - the location to insert the plain text
modifyQuery - should contain the plain text to insert i.e. String text
= OperationUtil.getRequiredParameter(operation,
ParamsProperty.MODIFY_QUERY).getTextMatch();
modifyAction - in this case = INSERT

After looking into other op implementations, I came to conclusion that
DOCUMENT_INSERT op should look like this:

  private void documentInsert(OperationRequest operation,
OperationContext context,
          ParticipantId participant, OpBasedWavelet wavelet,
ObservableConversation conversation)
  throws InvalidRequestException {
      Preconditions.checkArgument(
              OperationUtil.getOperationType(operation) ==
OperationType.DOCUMENT_INSERT,
              "Unsupported operation " + operation);

      String blipId = OperationUtil.getRequiredParameter(operation,
ParamsProperty.BLIP_ID);
      Integer index = OperationUtil.getRequiredParameter(operation,
ParamsProperty.INDEX);
      DocumentModifyQuery documentModifyQuery =
OperationUtil.getRequiredParameter(operation,
ParamsProperty.MODIFY_QUERY);
      ConversationBlip blip = context.getBlip(conversation, blipId);
      if (index <= 0) {
          throw new InvalidRequestException(
                  "Can't insert on position <= 0, got " + index, operation);
      }
      if(documentModifyQuery.getTextMatch() != null){
          blip.getContent().insertText(index,
documentModifyQuery.getTextMatch());
      }
      processDocumentChangedEvent(operation, context, participant,
blipId);
  }

  private void processDocumentChangedEvent(OperationRequest operation,
OperationContext context,
      ParticipantId participant, String blipId)
      throws InvalidRequestException {
      DocumentChangedEvent event =
        new DocumentChangedEvent(null, null, participant.getAddress(),
System.currentTimeMillis(), blipId);
    context.processEvent(operation, event);
  }

Please let me know if this look like anything close to correct
implementation.


On Oct 25, 8:15 pm, Lennard de Rijk <[email protected]> wrote:
> Hi,
>
> On Mon, Oct 25, 2010 at 10:52 AM, Vega <[email protected]> wrote:
> > Are there some example implementations for  Robot API Operation
> > starter project? I would like to contribute, but a bit of explanation
> > of what exactly should be done and a example would make a job a lot
> > easier.
>
> You should be able to take a look at the operations that have been
> implemented under [0]. Pick any operation from the list of operations that
> are to be done, most of them speak for themselves (or find some more info at
> [1]). If there is still a question about what the op should do or how it
> should work just drop us a line on the list :).
>
> Greetings,
> Lennard
>
> [0]http://code.google.com/p/wave-protocol/source/browse/#hg/src/org/wave...
> [1]http://code.google.com/apis/wave/extensions/robots/protocol.html

-- 
You received this message because you are subscribed to the Google Groups "Wave 
Protocol" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/wave-protocol?hl=en.

Reply via email to