Package org.waveprotocol.wave.model.operation.wave

Examples of org.waveprotocol.wave.model.operation.wave.WaveletOperationContext


  /**
   * Builds a no-op client delta.
   */
  public WaveletDelta makeNoOpDelta(HashedVersion targetVersion, long timestamp, int numOps) {
    List<WaveletOperation> ops = CollectionUtils.newArrayList();
    WaveletOperationContext context =
        new WaveletOperationContext(author, Constants.NO_TIMESTAMP, 1);
    for (int i = 0; i < numOps; ++i) {
      ops.add(new NoOp(context));
    }
    return new WaveletDelta(author, targetVersion, ops);
  }
View Full Code Here


  @Override
  public OpBasedBlip createBlip(String id) {
    // Optimistically create the blip assuming this author submits the
    // first operation.
    WaveletOperationContext context = createContext();
    BlipData newBlip = wavelet.createDocument(id, context.getCreator(),
        Collections.singleton(context.getCreator()), EmptyDocument.EMPTY_DOCUMENT,
        Constants.NO_TIMESTAMP, Constants.NO_VERSION);
    return adapt(newBlip);
  }
View Full Code Here

      // As an optimization, since we have composed the operations in the undo
      // stack, replace it with the composed op.
      undoable.add(composed);
    }

    WaveletOperationContext originalContext = op.getContext();
    return transformedNonUndoable.toWaveletOperationsWithVersions(originalContext
        .getVersionIncrement(), originalContext.getHashedVersion());
  }
View Full Code Here

      List<CoreWaveletOperation> coreWaveletOperations = pair.op.toCoreWaveletOperations();

      for (int j = 0; j < coreWaveletOperations.size(); ++j) {
        boolean isLast = isLastOfOuter && (j == coreWaveletOperations.size() - 1);
        WaveletOperationContext opContext =
            contextForCreator(pair.creator, versionIncrement, hashedVersion, isLast);
        WaveletOperation waveletOps =
            coreWaveletOpsToWaveletOps(coreWaveletOperations.get(j), opContext);
        ret.add(waveletOps);
      }
View Full Code Here

   *         creator.
   */
  private WaveletOperationContext contextForCreator(ParticipantId creator, long versionIncrement,
      HashedVersion hashedVersion, boolean isLastOfSeq) {
    if (isLastOfSeq) {
      return new WaveletOperationContext(creator, System.currentTimeMillis(), versionIncrement,
          hashedVersion);
    } else {
      // NOTE(user): The timestamp and version field are not relevant in the
      // client for outgoing ops, but may need to be filled out properly on the
      // server.
      return new WaveletOperationContext(creator, System.currentTimeMillis(), 0L);
    }
  }
View Full Code Here

   * delta.
   */
  public static WaveletDelta deserialize(ProtocolWaveletDelta delta) {
    List<WaveletOperation> ops = Lists.newArrayList();
    for (ProtocolWaveletOperation op : delta.getOperationList()) {
      WaveletOperationContext context = new WaveletOperationContext(
          ParticipantId.ofUnsafe(delta.getAuthor()), Constants.NO_TIMESTAMP, 1);
      ops.add(deserialize(op, context));
    }
    HashedVersion hashedVersion = deserialize(delta.getHashedVersion());
    return new WaveletDelta(new ParticipantId(delta.getAuthor()),
View Full Code Here

    ParticipantId author = ParticipantId.ofUnsafe(delta.getAuthor());
    int count = delta.getOperationCount();
    Preconditions.checkArgument(count > 0, "Cannot deserialize an empty delta");
    List<WaveletOperation> ops = Lists.newArrayListWithCapacity(count);
    if (count > 1) {
      WaveletOperationContext context =
          new WaveletOperationContext(author, applicationTimestamp, 1);
      for (int i = 0; i < count - 1; i++) {
        ProtocolWaveletOperation op = delta.getOperation(i);
        ops.add(deserialize(op, context));
      }
    }
    WaveletOperationContext context =
        new WaveletOperationContext(author, applicationTimestamp, 1, resultingVersion);
    ops.add(deserialize(delta.getOperation(count - 1), context));
    return new TransformedWaveletDelta(author, resultingVersion, applicationTimestamp, ops);
  }
View Full Code Here

        CoreWaveletOperationSerializer.deserialize(delta.getResultingVersion());
    ParticipantId author = ParticipantId.ofUnsafe(delta.getAuthor());
    ImmutableList.Builder<WaveletOperation> operations = ImmutableList.builder();
    int numOperations = delta.getOperationCount();
    for (int i = 0; i < numOperations; i++) {
      WaveletOperationContext context;
      if (i == numOperations - 1) {
        context = new WaveletOperationContext(author, applicationTimestamp, 1, resultingVersion);
      } else {
        context = new WaveletOperationContext(author, applicationTimestamp, 1);
      }
      operations.add(CoreWaveletOperationSerializer.deserialize(delta.getOperation(i), context));
    }
    return new TransformedWaveletDelta(author, resultingVersion, applicationTimestamp, operations.build());
  }
View Full Code Here

   */
  public static TransformedWaveletDelta deserialize(final ProtocolWaveletDelta protocolDelta,
      HashedVersion postVersion) {
    // TODO(anorth): include the application timestamp when it's plumbed
    // through correctly.
    WaveletOperationContext dummy = new WaveletOperationContext(null, 0L, 0L);
    List<WaveletOperation> ops = new ArrayList<WaveletOperation>();
    for (ProtocolWaveletOperation protocolOp : protocolDelta.getOperation()) {
      ops.add(deserialize(protocolOp, dummy));
    }
    // This involves an unnecessary copy of the ops, but avoids repeating
View Full Code Here

  /**
   * Inverts an operation.
   */
  static WaveletOperation invert(WaveletOperation op) {
    WaveletOperationContext forwardContext = op.getContext();
    WaveletOperationContext reverseContext = new WaveletOperationContext( //
        forwardContext.getCreator(),
        // Lie, and keep the same modification time.
        forwardContext.getTimestamp(),
        // Correctly invert the version increment.
        -forwardContext.getVersionIncrement(),
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.model.operation.wave.WaveletOperationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.