Examples of ChangeContainer


Examples of org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer

    simplifier.setChangeSink(new NullChangeWriter());
    simplifier.initialize(new HashMap<String, Object>());
    Node node;

    node = new Node(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 2), 1, 1);
    simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));

    try {
      node = new Node(new CommonEntityData(1, 2, new Date(), OsmUser.NONE, 1), 1, 1);
      simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
    } catch (OsmosisRuntimeException e) {
      if (e.getMessage().startsWith("Pipeline entities are not sorted")) {
        return;
      }
      throw e;
View Full Code Here

Examples of org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer

    simplifier.initialize(new HashMap<String, Object>());
    Node node;
    Way way;
   
    way = new Way(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 2));
    simplifier.process(new ChangeContainer(new WayContainer(way), ChangeAction.Modify));

    try {
      node = new Node(new CommonEntityData(1, 2, new Date(), OsmUser.NONE, 1), 1, 1);
      simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
    } catch (OsmosisRuntimeException e) {
      if (e.getMessage().startsWith("Pipeline entities are not sorted")) {
        return;
      }
      throw e;
View Full Code Here

Examples of org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer

   
    /**
     * {@inheritDoc}
     */
    public void process(EntityContainer entityContainer) {
      changeSink.process(new ChangeContainer(entityContainer, action));
    }
View Full Code Here

Examples of org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer

   * {@inheritDoc}
   */
  public boolean hasNext() {
    while (!nextValueLoaded && sourceIterator.hasNext()) {
      List<ChangeContainer> changeList;
      ChangeContainer changeContainer;
     
      // Get the next change list from the underlying stream.
      changeList = sourceIterator.next();
     
      // Loop until all history values for the current element are exhausted and get the
      // latest version of the entity that fits within the snapshot timestamp.
      changeContainer = null;
      for (ChangeContainer tmpChangeContainer : changeList) {
       
        // We're only interested in elements prior or equal to the snapshot point.
        if (tmpChangeContainer.getEntityContainer().getEntity()
            .getTimestamp().compareTo(snapshotInstant) <= 0) {
          // Replace the current change container with the later version.
          changeContainer = tmpChangeContainer;
        }
      }
     
      // We are not interested in items created after the snapshot timestamp (ie. null) or deleted items.
      if (changeContainer != null && !ChangeAction.Delete.equals(changeContainer.getAction())) {
        nextValue = changeContainer.getEntityContainer();
        nextValueLoaded = true;
      }
    }
   
    return nextValueLoaded;
View Full Code Here

Examples of org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer

        action = ChangeAction.Modify;
      }
     
      // Create a change record which data derived from the
      // replication sequence number itself.
      ChangeContainer change = new ChangeContainer(new NodeContainer(new Node(new CommonEntityData(10,
          (int) state.getSequenceNumber(), new Date(state.getSequenceNumber() * 1000), new OsmUser(11,
              "test"), state.getSequenceNumber() * 2), state.getSequenceNumber() * 3,
          state.getSequenceNumber() * 4)), action);
     
      // Send the record downstream.
View Full Code Here

Examples of org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer

    entity = writeableContainer.getEntity();
    sortedTags = sortTags(entity.getTags());
    entity.getTags().clear();
    entity.getTags().addAll(sortedTags);
   
    changeSink.process(new ChangeContainer(writeableContainer, changeContainer.getAction()));
  }
View Full Code Here

Examples of org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer

        if (comparisonResult < 0) {
          // The from entity doesn't exist on the to source therefore
          // has been deleted. We don't know when the entity was
          // deleted so set the delete time to the current time.
          changeSink.process(
              new ChangeContainer(
                  timestampSetter.updateTimestamp(fromEntityContainer),
                  ChangeAction.Delete));
          fromEntityContainer = null;
        } else if (comparisonResult > 0) {
          // The to entity doesn't exist on the from source therefore has
          // been created.
          changeSink.process(new ChangeContainer(toEntityContainer, ChangeAction.Create));
          toEntityContainer = null;
        } else {
          // The entity exists on both sources, therefore we must
          // compare
          // the entities directly. If there is a difference, the
          // entity has been modified.
          if (!fromEntityContainer.getEntity().equals(toEntityContainer.getEntity())) {
            changeSink.process(new ChangeContainer(toEntityContainer, ChangeAction.Modify));
          }
          fromEntityContainer = null;
          toEntityContainer = null;
        }
      }
     
      // Any remaining "from" entities are deletes.
      while (fromEntityContainer != null || fromPostbox.hasNext()) {
        if (fromEntityContainer == null) {
          fromEntityContainer = fromPostbox.getNext();
        }

        // The from entity doesn't exist on the to source therefore
        // has been deleted. We don't know when the entity was
        // deleted so set the delete time to the current time.
        changeSink.process(
            new ChangeContainer(
                timestampSetter.updateTimestamp(fromEntityContainer),
                ChangeAction.Delete));
        fromEntityContainer = null;
      }
      // Any remaining "to" entities are creates.
      while (toEntityContainer != null || toPostbox.hasNext()) {
        if (toEntityContainer == null) {
          toEntityContainer = toPostbox.getNext();
        }
        changeSink.process(new ChangeContainer(toEntityContainer, ChangeAction.Create));
        toEntityContainer = null;
      }
     
      changeSink.complete();
      fromPostbox.outputComplete();
View Full Code Here

Examples of org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer

    currentChanges = new ArrayList<ChangeContainer>();
  }
 
 
  private void flushCurrentChanges() {
    ChangeContainer changeBegin;
    ChangeContainer changeEnd;
    ChangeAction actionBegin;
    ChangeAction actionEnd;
    ChangeAction actionResult;
   
    changeBegin = currentChanges.get(0);
    changeEnd = currentChanges.get(currentChanges.size() - 1);
   
    actionBegin = changeBegin.getAction();
    actionEnd = changeEnd.getAction();
   
    // If the final action is a delete we'll send a delete action regardless of whether the
    // first action was a create just in case the create should have been a modify.
    // If the first action is a create, then the result is always a create (except for delete
    // case above).
    // Everything else is treated as a modify.
    if (actionEnd.equals(ChangeAction.Delete)) {
      actionResult = ChangeAction.Delete;
    } else if (actionBegin.equals(ChangeAction.Create)) {
      actionResult = ChangeAction.Create;
    } else {
      actionResult = ChangeAction.Modify;
    }
   
    changeSink.process(new ChangeContainer(changeEnd.getEntityContainer(), actionResult));
   
    currentChanges.clear();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.