org.openstreetmap.josm.data
Class APIDataSet

java.lang.Object
  extended by org.openstreetmap.josm.data.APIDataSet

public class APIDataSet
extends java.lang.Object

Represents a collection of OsmPrimitives which should be uploaded to the API. The collection is derived from the modified primitives of an DataSet and it provides methods for sorting the objects in upload order.


Nested Class Summary
private static class APIDataSet.RelationUploadDependencyGraph
          Utility class to sort a collection of new relations with their dependencies topologically.
 
Field Summary
private  java.util.LinkedList<OsmPrimitive> toAdd
           
private  java.util.LinkedList<OsmPrimitive> toDelete
           
private  java.util.LinkedList<OsmPrimitive> toUpdate
           
 
Constructor Summary
APIDataSet()
          creates a new empty data set
APIDataSet(java.util.Collection<OsmPrimitive> primitives)
          initializes the API data set with the primitives in primitives
APIDataSet(DataSet ds)
          initializes the API data set with the modified primitives in ds
 
Method Summary
 void adjustRelationUploadOrder()
          Adjusts the upload order for new relations.
protected  java.util.List<Relation> filterRelationsNotReferringToNewRelations(java.util.Collection<Relation> relations)
          Replies the subset of relations in relations which are not referring to any new relation
 java.util.List<OsmPrimitive> getPrimitives()
          Replies all primitives
 java.util.List<OsmPrimitive> getPrimitivesToAdd()
          Replies the primitives which should be added to the OSM database
 java.util.List<OsmPrimitive> getPrimitivesToDelete()
          Replies the primitives which should be deleted in the OSM database
 java.util.List<OsmPrimitive> getPrimitivesToUpdate()
          Replies the primitives which should be updated in the OSM database
 int getSize()
          Replies the number of objects to upload
 void init(DataSet ds)
          initializes the API data set with the modified primitives in ds
 boolean isEmpty()
          Replies true if there are no primitives to upload
 boolean participatesInConflict(Conflict<?> conflict)
          Replies true if one of the primitives to be updated or to be deleted participates in the conflict conflict
 boolean participatesInConflict(ConflictCollection conflicts)
          Replies true if one of the primitives to be updated or to be deleted participates in at least one conflict in conflicts
 void removeProcessed(java.util.Collection<IPrimitive> processed)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

toAdd

private java.util.LinkedList<OsmPrimitive> toAdd

toUpdate

private java.util.LinkedList<OsmPrimitive> toUpdate

toDelete

private java.util.LinkedList<OsmPrimitive> toDelete
Constructor Detail

APIDataSet

public APIDataSet()
creates a new empty data set


APIDataSet

public APIDataSet(DataSet ds)
initializes the API data set with the modified primitives in ds

Parameters:
ds - the data set. Ignored, if null.

APIDataSet

public APIDataSet(java.util.Collection<OsmPrimitive> primitives)
initializes the API data set with the primitives in primitives

Parameters:
primitives - the collection of primitives
Method Detail

init

public void init(DataSet ds)
initializes the API data set with the modified primitives in ds

Parameters:
ds - the data set. Ignored, if null.

participatesInConflict

public boolean participatesInConflict(Conflict<?> conflict)
Replies true if one of the primitives to be updated or to be deleted participates in the conflict conflict

Parameters:
conflict - the conflict
Returns:
true if one of the primitives to be updated or to be deleted participates in the conflict conflict

participatesInConflict

public boolean participatesInConflict(ConflictCollection conflicts)
Replies true if one of the primitives to be updated or to be deleted participates in at least one conflict in conflicts

Parameters:
conflicts - the collection of conflicts
Returns:
true if one of the primitives to be updated or to be deleted participates in at least one conflict in conflicts

isEmpty

public boolean isEmpty()
Replies true if there are no primitives to upload

Returns:
true if there are no primitives to upload

getPrimitivesToAdd

public java.util.List<OsmPrimitive> getPrimitivesToAdd()
Replies the primitives which should be added to the OSM database

Returns:
the primitives which should be added to the OSM database

getPrimitivesToUpdate

public java.util.List<OsmPrimitive> getPrimitivesToUpdate()
Replies the primitives which should be updated in the OSM database

Returns:
the primitives which should be updated in the OSM database

getPrimitivesToDelete

public java.util.List<OsmPrimitive> getPrimitivesToDelete()
Replies the primitives which should be deleted in the OSM database

Returns:
the primitives which should be deleted in the OSM database

getPrimitives

public java.util.List<OsmPrimitive> getPrimitives()
Replies all primitives

Returns:
all primitives

getSize

public int getSize()
Replies the number of objects to upload

Returns:
the number of objects to upload

removeProcessed

public void removeProcessed(java.util.Collection<IPrimitive> processed)

adjustRelationUploadOrder

public void adjustRelationUploadOrder()
                               throws CyclicUploadDependencyException
Adjusts the upload order for new relations. Child relations are uploaded first, parent relations second. This method detects cyclic dependencies in new relation. Relations with cyclic dependencies can't be uploaded.

Throws:
CyclicUploadDependencyException - thrown, if a cyclic dependency is detected

filterRelationsNotReferringToNewRelations

protected java.util.List<Relation> filterRelationsNotReferringToNewRelations(java.util.Collection<Relation> relations)
Replies the subset of relations in relations which are not referring to any new relation

Parameters:
relations - a list of relations
Returns:
the subset of relations in relations which are not referring to any new relation


JOSM