Package org.openstreetmap.josm.data
Class APIDataSet
java.lang.Object
org.openstreetmap.josm.data.APIDataSet
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.- Since:
- 2025
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe type of operation we can perform with OSM API on a primitive.private static classUtility class to sort a collection of new relations with their dependencies topologically. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<OsmPrimitive>private List<OsmPrimitive>private final List<OsmPrimitive> -
Constructor Summary
ConstructorsConstructorDescriptioncreates a new empty data setAPIDataSet(Collection<OsmPrimitive> primitives) initializes the API data set with the primitives inprimitivesAPIDataSet(DataSet ds) initializes the API data set with the modified primitives inds -
Method Summary
Modifier and TypeMethodDescriptionvoidAdjusts the upload order for new relations.Replies the subset of relations inrelationswhich are not referring to any new relationReplies all primitivesReplies the primitives which should be added to the OSM databaseReplies the primitives which should be deleted in the OSM databaseReplies the primitives which should be updated in the OSM databaseintgetSize()Replies the number of objects to uploadfinal voidinit(Collection<OsmPrimitive> primitives) Initializes the API data set with the modified primitives, ignores unmodified primitives.voidinitializes the API data set with the modified primitives indsbooleanisEmpty()Replies true if there are no primitives to uploadbooleanparticipatesInConflict(ConflictCollection conflicts) Replies true if one of the primitives to be updated or to be deleted participates in at least one conflict inconflictsvoidremoveProcessed(Collection<IPrimitive> processed) Removes the given primitives from thisAPIDataSet
-
Field Details
-
toAdd
-
toUpdate
-
toDelete
-
-
Constructor Details
-
APIDataSet
public APIDataSet()creates a new empty data set -
APIDataSet
initializes the API data set with the modified primitives inds- Parameters:
ds- the data set. Ignored, if null.
-
APIDataSet
initializes the API data set with the primitives inprimitives- Parameters:
primitives- the collection of primitives
-
-
Method Details
-
init
initializes the API data set with the modified primitives inds- Parameters:
ds- the data set. Ignored, if null.
-
init
Initializes the API data set with the modified primitives, ignores unmodified primitives.- Parameters:
primitives- the primitives
-
participatesInConflict
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
Replies true if there are no primitives to upload- Returns:
- true if there are no primitives to upload
-
getPrimitivesToAdd
Replies the primitives which should be added to the OSM database- Returns:
- the primitives which should be added to the OSM database
-
getPrimitivesToUpdate
Replies the primitives which should be updated in the OSM database- Returns:
- the primitives which should be updated in the OSM database
-
getPrimitivesToDelete
Replies the primitives which should be deleted in the OSM database- Returns:
- the primitives which should be deleted in the OSM database
-
getPrimitives
Replies all primitives- Returns:
- all primitives
-
getSize
Replies the number of objects to upload- Returns:
- the number of objects to upload
-
removeProcessed
Removes the given primitives from thisAPIDataSet- Parameters:
processed- The primitives to remove
-
adjustRelationUploadOrder
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
Replies the subset of relations inrelationswhich are not referring to any new relation- Parameters:
relations- a list of relations- Returns:
- the subset of relations in
relationswhich are not referring to any new relation
-