Package org.openstreetmap.josm.data
Class APIDataSet
- java.lang.Object
-
- org.openstreetmap.josm.data.APIDataSet
-
public class APIDataSet extends java.lang.Object
Represents a collection ofOsmPrimitive
s which should be uploaded to the API. The collection is derived from the modified primitives of anDataSet
and it provides methods for sorting the objects in upload order.- Since:
- 2025
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
APIDataSet.APIOperation
The type of operation we can perform with OSM API on a primitive.private static class
APIDataSet.RelationUploadDependencyGraph
Utility class to sort a collection of new relations with their dependencies topologically.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<OsmPrimitive>
toAdd
private java.util.List<OsmPrimitive>
toDelete
private java.util.List<OsmPrimitive>
toUpdate
-
Constructor Summary
Constructors Constructor Description APIDataSet()
creates a new empty data setAPIDataSet(java.util.Collection<OsmPrimitive> primitives)
initializes the API data set with the primitives inprimitives
APIDataSet(DataSet ds)
initializes the API data set with the modified primitives inds
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 inrelations
which are not referring to any new relationjava.util.List<OsmPrimitive>
getPrimitives()
Replies all primitivesjava.util.List<OsmPrimitive>
getPrimitivesToAdd()
Replies the primitives which should be added to the OSM databasejava.util.List<OsmPrimitive>
getPrimitivesToDelete()
Replies the primitives which should be deleted in the OSM databasejava.util.List<OsmPrimitive>
getPrimitivesToUpdate()
Replies the primitives which should be updated in the OSM databaseint
getSize()
Replies the number of objects to uploadvoid
init(java.util.Collection<OsmPrimitive> primitives)
Initializes the API data set with the modified primitives, ignores unmodified primitives.void
init(DataSet ds)
initializes the API data set with the modified primitives inds
boolean
isEmpty()
Replies true if there are no primitives to uploadboolean
participatesInConflict(ConflictCollection conflicts)
Replies true if one of the primitives to be updated or to be deleted participates in at least one conflict inconflicts
void
removeProcessed(java.util.Collection<IPrimitive> processed)
Removes the given primitives from thisAPIDataSet
-
-
-
Field Detail
-
toAdd
private java.util.List<OsmPrimitive> toAdd
-
toUpdate
private final java.util.List<OsmPrimitive> toUpdate
-
toDelete
private java.util.List<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 inds
- Parameters:
ds
- the data set. Ignored, if null.
-
APIDataSet
public APIDataSet(java.util.Collection<OsmPrimitive> primitives)
initializes the API data set with the primitives inprimitives
- Parameters:
primitives
- the collection of primitives
-
-
Method Detail
-
init
public void init(DataSet ds)
initializes the API data set with the modified primitives inds
- Parameters:
ds
- the data set. Ignored, if null.
-
init
public final void init(java.util.Collection<OsmPrimitive> primitives)
Initializes the API data set with the modified primitives, ignores unmodified primitives.- Parameters:
primitives
- the primitives
-
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 inconflicts
- 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)
Removes the given primitives from thisAPIDataSet
- Parameters:
processed
- The primitives to remove
-
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
- if a cyclic dependency is detected
-
filterRelationsNotReferringToNewRelations
protected java.util.List<Relation> filterRelationsNotReferringToNewRelations(java.util.Collection<Relation> relations)
Replies the subset of relations inrelations
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
-
-