Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java
r15404 r15426 68 68 setEnabled(false); 69 69 } 70 if (isEnabled() && selection. stream().noneMatch(OsmPrimitive::isModified)) {70 if (isEnabled() && selection.parallelStream().noneMatch(OsmPrimitive::isModified)) { 71 71 setEnabled(false); 72 72 } … … 74 74 75 75 protected Set<OsmPrimitive> getDeletedPrimitives(DataSet ds) { 76 return ds.allPrimitives(). stream()76 return ds.allPrimitives().parallelStream() 77 77 .filter(p -> p.isDeleted() && !p.isNew() && p.isVisible() && p.isModified()) 78 78 .collect(Collectors.toSet()); … … 80 80 81 81 protected Set<OsmPrimitive> getModifiedPrimitives(Collection<OsmPrimitive> primitives) { 82 return primitives. stream()82 return primitives.parallelStream() 83 83 .filter(p -> p.isNewOrUndeleted() || (p.isModified() && !p.isIncomplete())) 84 84 .collect(Collectors.toSet()); … … 124 124 */ 125 125 protected boolean hasPrimitivesToDelete(Collection<OsmPrimitive> primitives) { 126 for (OsmPrimitive p: primitives) { 127 if (p.isDeleted() && p.isModified() && !p.isNew()) 128 return true; 129 } 130 return false; 126 return primitives.parallelStream().anyMatch(p -> p.isDeleted() && p.isModified() && !p.isNew()); 131 127 } 132 128 … … 240 236 241 237 /** 242 * 238 * Constructs a new {@code DeletedParentsChecker}. 243 239 * @param layer the data layer for which a collection of selected primitives is uploaded 244 240 * @param toUpload the collection of primitives to upload … … 278 274 */ 279 275 protected Set<OsmPrimitive> getPrimitivesToCheckForParents() { 280 return toUpload. stream().filter(p -> p.isDeleted() && !p.isNewOrUndeleted()).collect(Collectors.toSet());276 return toUpload.parallelStream().filter(p -> p.isDeleted() && !p.isNewOrUndeleted()).collect(Collectors.toSet()); 281 277 } 282 278 … … 291 287 OsmPrimitive current = toCheck.pop(); 292 288 synchronized (this) { 293 reader = new OsmServerBackreferenceReader(current) ;289 reader = new OsmServerBackreferenceReader(current).setAllowIncompleteParentWays(true); 294 290 } 295 291 getProgressMonitor().subTask(tr("Reading parents of ''{0}''", current.getDisplayName(DefaultNameFormatter.getInstance()))); … … 302 298 for (OsmPrimitive p: ds.allPrimitives()) { 303 299 if (canceled) return; 300 if (p instanceof Node || (p instanceof Way && !(current instanceof Node))) continue; 304 301 OsmPrimitive myDeletedParent = layer.data.getPrimitiveById(p); 305 302 // our local dataset includes a deleted parent of a primitive we want -
trunk/src/org/openstreetmap/josm/io/OsmServerBackreferenceReader.java
r14214 r15426 42 42 /** true if this reader should complete incomplete primitives */ 43 43 private boolean readFull; 44 /** true if this reader should allow incomplete parent ways */ 45 private boolean allowIncompleteParentWays; 44 46 45 47 /** … … 113 115 114 116 /** 115 * Set true if this reader should reads immediate children of referring primitives too. False, otherweise. 116 * 117 * @param readFull true if this reader should reads immediate children of referring primitives too. False, otherweise. 118 */ 119 public void setReadFull(boolean readFull) { 117 * Set true if this reader should reads immediate children of referring primitives too. False, otherwise. 118 * 119 * @param readFull true if this reader should reads immediate children of referring primitives too. False, otherwise. 120 * @return {@code this}, for easy chaining 121 * @since 15426 122 */ 123 public OsmServerBackreferenceReader setReadFull(boolean readFull) { 120 124 this.readFull = readFull; 125 return this; 126 } 127 128 /** 129 * Determines if this reader allows to return incomplete parent ways of a node. 130 * @return {@code true} if this reader allows to return incomplete parent ways of a node 131 * @since 15426 132 */ 133 public boolean isAllowIncompleteParentWays() { 134 return allowIncompleteParentWays; 135 } 136 137 /** 138 * Sets whether this reader allows to return incomplete parent ways of a node. 139 * @param allowIncompleteWays {@code true} if this reader allows to return incomplete parent ways of a node 140 * @return {@code this}, for easy chaining 141 * @since 15426 142 */ 143 public OsmServerBackreferenceReader setAllowIncompleteParentWays(boolean allowIncompleteWays) { 144 this.allowIncompleteParentWays = allowIncompleteWays; 145 return this; 121 146 } 122 147 … … 175 200 * <ul> 176 201 * <li>if this reader reads referers for a {@link org.openstreetmap.josm.data.osm.Node}, referring ways are always 177 * read individually from the server</li>202 * read fully, unless {@link #setAllowIncompleteParentWays(boolean)} is set to true.</li> 178 203 * <li>if this reader reads referers for an {@link Way} or a {@link Relation}, referring relations 179 204 * are only read fully if {@link #setReadFull(boolean)} is set to true.</li> … … 191 216 try { 192 217 Collection<Way> waysToCheck = new ArrayList<>(ds.getWays()); 193 if (isReadFull() || primitiveType == OsmPrimitiveType.NODE) {218 if (isReadFull() || (primitiveType == OsmPrimitiveType.NODE && !isAllowIncompleteParentWays())) { 194 219 for (Way way: waysToCheck) { 195 220 if (!way.isNew() && way.hasIncompleteNodes()) { -
trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
r14190 r15426 242 242 assertNotNull(w); 243 243 244 OsmServerBackreferenceReader reader = new OsmServerBackreferenceReader(n); 245 reader.setReadFull(false); 246 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 244 DataSet referers = new OsmServerBackreferenceReader(n).setReadFull(false).parseOsm(NullProgressMonitor.INSTANCE); 247 245 printNumberOfPrimitives(referers); 248 246 … … 298 296 assertNotNull(n); 299 297 300 OsmServerBackreferenceReader reader = new OsmServerBackreferenceReader(n); 301 reader.setReadFull(true); 302 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 298 DataSet referers = new OsmServerBackreferenceReader(n).setReadFull(true).parseOsm(NullProgressMonitor.INSTANCE); 303 299 printNumberOfPrimitives(referers); 304 300 … … 349 345 // 350 346 351 OsmServerBackreferenceReader reader = new OsmServerBackreferenceReader(w); 352 reader.setReadFull(false); 353 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 347 DataSet referers = new OsmServerBackreferenceReader(w).setReadFull(false).parseOsm(NullProgressMonitor.INSTANCE); 354 348 printNumberOfPrimitives(referers); 355 349 … … 394 388 // 395 389 396 OsmServerBackreferenceReader reader = new OsmServerBackreferenceReader(w); 397 reader.setReadFull(true); 398 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 390 DataSet referers = new OsmServerBackreferenceReader(w).setReadFull(true).parseOsm(NullProgressMonitor.INSTANCE); 399 391 assertEquals(6, referers.getWays().size()); // 6 ways referred by two relations 400 392 for (Way w1 : referers.getWays()) { … … 434 426 // 435 427 436 OsmServerBackreferenceReader reader = new OsmServerBackreferenceReader(r); 437 reader.setReadFull(false); 438 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 428 DataSet referers = new OsmServerBackreferenceReader(r).setReadFull(false).parseOsm(NullProgressMonitor.INSTANCE); 439 429 printNumberOfPrimitives(referers); 440 430 … … 554 544 // 555 545 556 OsmServerBackreferenceReader reader = new OsmServerBackreferenceReader(r); 557 reader.setReadFull(true); 558 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 546 DataSet referers = new OsmServerBackreferenceReader(r).setReadFull(true).parseOsm(NullProgressMonitor.INSTANCE); 559 547 560 548 r = lookupRelation(referers, 6);
Note:
See TracChangeset
for help on using the changeset viewer.