Changeset 30738 in osm for applications/editors/josm/plugins/sds
- Timestamp:
- 2014-10-19T01:27:04+02:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/sds
- Files:
-
- 18 edited
-
.settings/org.eclipse.jdt.core.prefs (modified) (1 diff)
-
src/org/openstreetmap/hot/sds/DetermineSdsModificationsUploadHook.java (modified) (1 diff)
-
src/org/openstreetmap/hot/sds/ReadPostprocessor.java (modified) (1 diff)
-
src/org/openstreetmap/hot/sds/SdsApi.java (modified) (10 diffs)
-
src/org/openstreetmap/hot/sds/SdsConnection.java (modified) (1 diff)
-
src/org/openstreetmap/hot/sds/SdsCredentialAgent.java (modified) (1 diff)
-
src/org/openstreetmap/hot/sds/SdsCredentialDialog.java (modified) (3 diffs)
-
src/org/openstreetmap/hot/sds/SdsDiskAccessAction.java (modified) (3 diffs)
-
src/org/openstreetmap/hot/sds/SdsLoadAction.java (modified) (1 diff)
-
src/org/openstreetmap/hot/sds/SdsMenu.java (modified) (1 diff)
-
src/org/openstreetmap/hot/sds/SdsOsmWriter.java (modified) (2 diffs)
-
src/org/openstreetmap/hot/sds/SdsOsmWriterFactory.java (modified) (1 diff)
-
src/org/openstreetmap/hot/sds/SdsParser.java (modified) (1 diff)
-
src/org/openstreetmap/hot/sds/SdsPluginPreferences.java (modified) (1 diff)
-
src/org/openstreetmap/hot/sds/SdsSaveAction.java (modified) (10 diffs)
-
src/org/openstreetmap/hot/sds/SdsWriter.java (modified) (1 diff)
-
src/org/openstreetmap/hot/sds/SeparateDataStorePlugin.java (modified) (3 diffs)
-
src/org/openstreetmap/hot/sds/WritePostprocessor.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/sds/.settings/org.eclipse.jdt.core.prefs
r30736 r30738 40 40 org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore 41 41 org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled 42 org.eclipse.jdt.core.compiler.problem.missingSerialVersion= warning42 org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore 43 43 org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore 44 44 org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/DetermineSdsModificationsUploadHook.java
r30737 r30738 32 32 public class DetermineSdsModificationsUploadHook implements UploadHook 33 33 { 34 private SeparateDataStorePlugin plugin;34 private SeparateDataStorePlugin plugin; 35 35 36 DetermineSdsModificationsUploadHook(SeparateDataStorePlugin plugin){37 this.plugin = plugin;38 }39 36 DetermineSdsModificationsUploadHook(SeparateDataStorePlugin plugin) { 37 this.plugin = plugin; 38 } 39 40 40 public boolean checkUpload(APIDataSet apiDataSet) { 41 42 ArrayList<OsmPrimitive> droplist = new ArrayList<>();43 44 // check deleted primitives for special tags.45 for (OsmPrimitive del : apiDataSet.getPrimitivesToDelete()) {46 IPrimitive old = plugin.getOriginalPrimitive(del);47 if (hasSpecialTags(old)) {48 // request deletion of all tags for this object on special server.49 plugin.enqueueForUpload(del, new HashMap<String, String>(), false);50 }51 }41 42 ArrayList<OsmPrimitive> droplist = new ArrayList<>(); 43 44 // check deleted primitives for special tags. 45 for (OsmPrimitive del : apiDataSet.getPrimitivesToDelete()) { 46 IPrimitive old = plugin.getOriginalPrimitive(del); 47 if (hasSpecialTags(old)) { 48 // request deletion of all tags for this object on special server. 49 plugin.enqueueForUpload(del, new HashMap<String, String>(), false); 50 } 51 } 52 52 53 // check modified primitives.54 for (OsmPrimitive upd : apiDataSet.getPrimitivesToUpdate()) {55 56 HashSet<String> allKeys = new HashSet<>();57 boolean specialTags = false;58 59 // process tags of new object60 for (String key : upd.keySet()) {61 allKeys.add(key);62 if (!specialTags && isSpecialKey(key)) specialTags = true;63 }64 65 // process tags of old object66 IPrimitive old = plugin.getOriginalPrimitive(upd);67 for (String key : old.keySet()) {68 allKeys.add(key);69 if (!specialTags && isSpecialKey(key)) specialTags = true;70 }53 // check modified primitives. 54 for (OsmPrimitive upd : apiDataSet.getPrimitivesToUpdate()) { 55 56 HashSet<String> allKeys = new HashSet<>(); 57 boolean specialTags = false; 58 59 // process tags of new object 60 for (String key : upd.keySet()) { 61 allKeys.add(key); 62 if (!specialTags && isSpecialKey(key)) specialTags = true; 63 } 64 65 // process tags of old object 66 IPrimitive old = plugin.getOriginalPrimitive(upd); 67 for (String key : old.keySet()) { 68 allKeys.add(key); 69 if (!specialTags && isSpecialKey(key)) specialTags = true; 70 } 71 71 72 // if neither has special tags, done with this object.73 if (!specialTags) continue;74 75 // special tags are involved. find out what, exactly, has changed.76 boolean changeInSpecialTags = false;77 boolean changeInOtherTags = false;78 for (String key : allKeys) {79 if (old.get(key) == null || upd.get(key) == null || !old.get(key).equals(upd.get(key))) {80 if (isSpecialKey(key)) changeInSpecialTags = true; else changeInOtherTags = true;81 if (changeInSpecialTags && changeInOtherTags) break;82 }83 }84 85 // change *only* in standard tags - done with this object.86 if (!changeInSpecialTags) continue;87 88 // assemble new set of special tags. might turn out to be empty.89 HashMap<String, String> newSpecialTags = new HashMap<>();90 for (String key : upd.keySet()) {91 if (isSpecialKey(key)) newSpecialTags.put(key, upd.get(key));92 }93 94 boolean uploadToOsm = changeInOtherTags;95 96 // not done yet: if no changes in standard tags, we need to find out if97 // there were changes in the other properties (node: lat/lon, way/relation:98 // member list). If the answer is no, then the object must be removed from99 // JOSM's normal upload queue, else we would be uploading a non-edit.100 if (!changeInOtherTags) {101 switch(old.getType()) {102 case NODE:103 INode nold = (INode) old;104 INode nupd = (INode) upd;105 uploadToOsm = !(nold.getCoor().equals(nupd.getCoor()));106 break;107 case WAY:108 IWay wold = (IWay) old;109 IWay wupd = (IWay) upd;110 if (wold.getNodesCount() != wupd.getNodesCount()) {111 uploadToOsm = true;112 break;113 }114 for (int i = 0; i < wold.getNodesCount(); i++) {115 if (wold.getNodeId(i) != wupd.getNodeId(i)) {116 uploadToOsm = true;117 break;118 }119 }120 break;121 case RELATION:122 IRelation rold = (IRelation) old;123 IRelation rupd = (IRelation) upd;124 if (rold.getMembersCount()!= rupd.getMembersCount()) {125 uploadToOsm = true;126 break;127 }128 for (int i = 0; i < rold.getMembersCount(); i++) {129 if (rold.getMemberType(i) != rupd.getMemberType(i) ||130 rold.getMemberId(i) != rupd.getMemberId(i)) {131 uploadToOsm = true;132 break;133 }134 }135 break;136 }137 }138 139 // request that new set of special tags be uploaded140 plugin.enqueueForUpload(upd, newSpecialTags, !uploadToOsm);141 142 // we cannot remove from getPrimitivesToUpdate, this would result in a143 // ConcurrentModificationException.144 if (!uploadToOsm) droplist.add(upd);145 146 }147 148 apiDataSet.getPrimitivesToUpdate().removeAll(droplist);149 150 // check added primitives.151 for (OsmPrimitive add : apiDataSet.getPrimitivesToAdd()) {152 // assemble new set of special tags. might turn out to be empty.153 HashMap<String, String> newSpecialTags = new HashMap<>();154 for (String key : add.keySet()) {155 if (isSpecialKey(key)) newSpecialTags.put(key, add.get(key));156 }157 if (!newSpecialTags.isEmpty()) plugin.enqueueForUpload(add, newSpecialTags, false);158 }159 160 // FIXME it is possible that the list of OSM edits is totally empty.161 return true;72 // if neither has special tags, done with this object. 73 if (!specialTags) continue; 74 75 // special tags are involved. find out what, exactly, has changed. 76 boolean changeInSpecialTags = false; 77 boolean changeInOtherTags = false; 78 for (String key : allKeys) { 79 if (old.get(key) == null || upd.get(key) == null || !old.get(key).equals(upd.get(key))) { 80 if (isSpecialKey(key)) changeInSpecialTags = true; else changeInOtherTags = true; 81 if (changeInSpecialTags && changeInOtherTags) break; 82 } 83 } 84 85 // change *only* in standard tags - done with this object. 86 if (!changeInSpecialTags) continue; 87 88 // assemble new set of special tags. might turn out to be empty. 89 HashMap<String, String> newSpecialTags = new HashMap<>(); 90 for (String key : upd.keySet()) { 91 if (isSpecialKey(key)) newSpecialTags.put(key, upd.get(key)); 92 } 93 94 boolean uploadToOsm = changeInOtherTags; 95 96 // not done yet: if no changes in standard tags, we need to find out if 97 // there were changes in the other properties (node: lat/lon, way/relation: 98 // member list). If the answer is no, then the object must be removed from 99 // JOSM's normal upload queue, else we would be uploading a non-edit. 100 if (!changeInOtherTags) { 101 switch(old.getType()) { 102 case NODE: 103 INode nold = (INode) old; 104 INode nupd = (INode) upd; 105 uploadToOsm = !(nold.getCoor().equals(nupd.getCoor())); 106 break; 107 case WAY: 108 IWay wold = (IWay) old; 109 IWay wupd = (IWay) upd; 110 if (wold.getNodesCount() != wupd.getNodesCount()) { 111 uploadToOsm = true; 112 break; 113 } 114 for (int i = 0; i < wold.getNodesCount(); i++) { 115 if (wold.getNodeId(i) != wupd.getNodeId(i)) { 116 uploadToOsm = true; 117 break; 118 } 119 } 120 break; 121 case RELATION: 122 IRelation rold = (IRelation) old; 123 IRelation rupd = (IRelation) upd; 124 if (rold.getMembersCount()!= rupd.getMembersCount()) { 125 uploadToOsm = true; 126 break; 127 } 128 for (int i = 0; i < rold.getMembersCount(); i++) { 129 if (rold.getMemberType(i) != rupd.getMemberType(i) || 130 rold.getMemberId(i) != rupd.getMemberId(i)) { 131 uploadToOsm = true; 132 break; 133 } 134 } 135 break; 136 } 137 } 138 139 // request that new set of special tags be uploaded 140 plugin.enqueueForUpload(upd, newSpecialTags, !uploadToOsm); 141 142 // we cannot remove from getPrimitivesToUpdate, this would result in a 143 // ConcurrentModificationException. 144 if (!uploadToOsm) droplist.add(upd); 145 146 } 147 148 apiDataSet.getPrimitivesToUpdate().removeAll(droplist); 149 150 // check added primitives. 151 for (OsmPrimitive add : apiDataSet.getPrimitivesToAdd()) { 152 // assemble new set of special tags. might turn out to be empty. 153 HashMap<String, String> newSpecialTags = new HashMap<>(); 154 for (String key : add.keySet()) { 155 if (isSpecialKey(key)) newSpecialTags.put(key, add.get(key)); 156 } 157 if (!newSpecialTags.isEmpty()) plugin.enqueueForUpload(add, newSpecialTags, false); 158 } 159 160 // FIXME it is possible that the list of OSM edits is totally empty. 161 return true; 162 162 163 163 } 164 164 165 165 boolean hasSpecialTags(IPrimitive p) { 166 for (String key : p.keySet()) {167 if (isSpecialKey(key)) return true;168 }169 return false;166 for (String key : p.keySet()) { 167 if (isSpecialKey(key)) return true; 168 } 169 return false; 170 170 } 171 171 172 172 boolean isSpecialKey(String key) { 173 return key.startsWith(plugin.getIgnorePrefix());173 return key.startsWith(plugin.getIgnorePrefix()); 174 174 } 175 175 } -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/ReadPostprocessor.java
r30737 r30738 24 24 25 25 public class ReadPostprocessor implements OsmServerReadPostprocessor { 26 27 private ArrayList<Long> nodeList;28 private ArrayList<Long> wayList;29 private ArrayList<Long> relationList;30 31 private SeparateDataStorePlugin plugin;26 27 private ArrayList<Long> nodeList; 28 private ArrayList<Long> wayList; 29 private ArrayList<Long> relationList; 30 31 private SeparateDataStorePlugin plugin; 32 32 33 public ReadPostprocessor(SeparateDataStorePlugin plugin) {34 this.plugin = plugin;35 }36 33 public ReadPostprocessor(SeparateDataStorePlugin plugin) { 34 this.plugin = plugin; 35 } 36 37 37 @Override 38 38 public void postprocessDataSet(DataSet ds, ProgressMonitor progress) { 39 39 40 nodeList = new ArrayList<>();41 wayList = new ArrayList<>();42 relationList = new ArrayList<>();40 nodeList = new ArrayList<>(); 41 wayList = new ArrayList<>(); 42 relationList = new ArrayList<>(); 43 43 44 Visitor adder = new Visitor() {45 @Override46 public void visit(Node n) {47 nodeList.add(n.getId());48 plugin.originalNodes.put(n.getId(), n.save());49 }50 @Override51 public void visit(Way w) {52 wayList.add(w.getId());53 plugin.originalWays.put(w.getId(), w.save());54 }55 @Override56 public void visit(Relation e) {57 relationList.add(e.getId());58 plugin.originalNodes.put(e.getId(), e.save());59 }60 @Override61 public void visit(Changeset cs) {}62 };63 64 for (OsmPrimitive p : ds.allPrimitives()) {65 p.accept(adder);66 }67 68 SdsApi api = SdsApi.getSdsApi();69 String rv = "";70 try {71 rv = api.requestShadowsFromSds(nodeList, wayList, relationList, progress);72 } catch (SdsTransferException e) {73 // TODO Auto-generated catch block74 e.printStackTrace();75 }76 77 // this is slightly inefficient, as we're re-making the string into78 // an input stream when there was an input stream to be had inside the79 // SdsApi already, but this encapsulates things better.44 Visitor adder = new Visitor() { 45 @Override 46 public void visit(Node n) { 47 nodeList.add(n.getId()); 48 plugin.originalNodes.put(n.getId(), n.save()); 49 } 50 @Override 51 public void visit(Way w) { 52 wayList.add(w.getId()); 53 plugin.originalWays.put(w.getId(), w.save()); 54 } 55 @Override 56 public void visit(Relation e) { 57 relationList.add(e.getId()); 58 plugin.originalNodes.put(e.getId(), e.save()); 59 } 60 @Override 61 public void visit(Changeset cs) {} 62 }; 63 64 for (OsmPrimitive p : ds.allPrimitives()) { 65 p.accept(adder); 66 } 67 68 SdsApi api = SdsApi.getSdsApi(); 69 String rv = ""; 70 try { 71 rv = api.requestShadowsFromSds(nodeList, wayList, relationList, progress); 72 } catch (SdsTransferException e) { 73 // TODO Auto-generated catch block 74 e.printStackTrace(); 75 } 76 77 // this is slightly inefficient, as we're re-making the string into 78 // an input stream when there was an input stream to be had inside the 79 // SdsApi already, but this encapsulates things better. 80 80 InputStream xmlStream; 81 try {82 xmlStream = new ByteArrayInputStream(rv.getBytes("UTF-8"));83 InputSource inputSource = new InputSource(xmlStream);84 SAXParserFactory.newInstance().newSAXParser().parse(inputSource, new SdsParser(ds, plugin));85 } catch (UnsupportedEncodingException e1) {86 // TODO Auto-generated catch block87 e1.printStackTrace();88 } catch (SAXException e) {89 // TODO Auto-generated catch block90 e.printStackTrace();91 } catch (IOException e) {92 // TODO Auto-generated catch block93 e.printStackTrace();94 } catch (ParserConfigurationException e) {95 // TODO Auto-generated catch block96 e.printStackTrace();97 }81 try { 82 xmlStream = new ByteArrayInputStream(rv.getBytes("UTF-8")); 83 InputSource inputSource = new InputSource(xmlStream); 84 SAXParserFactory.newInstance().newSAXParser().parse(inputSource, new SdsParser(ds, plugin)); 85 } catch (UnsupportedEncodingException e1) { 86 // TODO Auto-generated catch block 87 e1.printStackTrace(); 88 } catch (SAXException e) { 89 // TODO Auto-generated catch block 90 e.printStackTrace(); 91 } catch (IOException e) { 92 // TODO Auto-generated catch block 93 e.printStackTrace(); 94 } catch (ParserConfigurationException e) { 95 // TODO Auto-generated catch block 96 e.printStackTrace(); 97 } 98 98 99 99 } -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsApi.java
r30737 r30738 34 34 * 35 35 * This is modeled after JOSM's own OsmAPI class. 36 * 36 * 37 37 */ 38 38 public class SdsApi extends SdsConnection { … … 42 42 /** the collection of instantiated OSM APIs */ 43 43 private static HashMap<String, SdsApi> instances = new HashMap<>(); 44 44 45 45 /** 46 46 * replies the {@see OsmApi} for a given server URL … … 123 123 * @param osm the primitive 124 124 * @throws SdsTransferException if something goes wrong 125 125 126 126 public void createPrimitive(IPrimitive osm, ProgressMonitor monitor) throws SdsTransferException { 127 127 String ret = ""; … … 144 144 * @param monitor the progress monitor 145 145 * @throws SdsTransferException if something goes wrong 146 146 147 147 public void modifyPrimitive(IPrimitive osm, ProgressMonitor monitor) throws SdsTransferException { 148 148 String ret = null; … … 165 165 * @param osm the primitive 166 166 * @throws SdsTransferException if something goes wrong 167 167 168 168 public void deletePrimitive(IPrimitive osm, ProgressMonitor monitor) throws SdsTransferException { 169 169 ensureValidChangeset(); … … 182 182 * @param list the list of changed OSM Primitives 183 183 * @param monitor the progress monitor 184 * @return 184 * @return 185 185 * @return list of processed primitives 186 * @throws SdsTransferException 186 * @throws SdsTransferException 187 187 * @throws SdsTransferException if something is wrong 188 188 189 189 public Collection<IPrimitive> uploadDiff(Collection<? extends IPrimitive> list, ProgressMonitor monitor) throws SdsTransferException { 190 190 try { … … 227 227 } 228 228 */ 229 229 230 230 public String requestShadowsFromSds(List<Long> nodes, List<Long> ways, List<Long> relations, ProgressMonitor pm) throws SdsTransferException { 231 232 StringBuilder request = new StringBuilder();233 String delim = "";234 String comma = "";235 236 if (nodes != null && !nodes.isEmpty()) {237 request.append(delim);238 delim = "&";239 comma = "";240 request.append("nodes=");241 for (long i : nodes) {242 request.append(comma);243 comma = ",";244 request.append(i);245 }246 }247 if (ways != null && !ways.isEmpty()) {248 request.append(delim);249 delim = "&";250 comma = "";251 request.append("ways=");252 for (long i : ways) {253 request.append(comma);254 comma = ",";255 request.append(i);256 }257 }258 if (relations != null && !relations.isEmpty()) {259 request.append(delim);260 delim = "&";261 comma = "";262 request.append("relations=");263 for (long i : relations) {264 request.append(comma);265 comma = ",";266 request.append(i);267 }268 }269 270 return sendRequest("POST", "collectshadows", request.toString(), pm ,true);271 231 232 StringBuilder request = new StringBuilder(); 233 String delim = ""; 234 String comma = ""; 235 236 if (nodes != null && !nodes.isEmpty()) { 237 request.append(delim); 238 delim = "&"; 239 comma = ""; 240 request.append("nodes="); 241 for (long i : nodes) { 242 request.append(comma); 243 comma = ","; 244 request.append(i); 245 } 246 } 247 if (ways != null && !ways.isEmpty()) { 248 request.append(delim); 249 delim = "&"; 250 comma = ""; 251 request.append("ways="); 252 for (long i : ways) { 253 request.append(comma); 254 comma = ","; 255 request.append(i); 256 } 257 } 258 if (relations != null && !relations.isEmpty()) { 259 request.append(delim); 260 delim = "&"; 261 comma = ""; 262 request.append("relations="); 263 for (long i : relations) { 264 request.append(comma); 265 comma = ","; 266 request.append(i); 267 } 268 } 269 270 return sendRequest("POST", "collectshadows", request.toString(), pm ,true); 271 272 272 } 273 273 … … 304 304 return sendRequest(requestMethod, urlSuffix, requestBody, monitor, doAuth, false); 305 305 } 306 306 307 307 public boolean updateSds(String message, ProgressMonitor pm) { 308 try {309 sendRequest("POST", "createshadows", message, pm);310 } catch (SdsTransferException e) {311 // TODO Auto-generated catch block312 e.printStackTrace();313 }314 return true;308 try { 309 sendRequest("POST", "createshadows", message, pm); 310 } catch (SdsTransferException e) { 311 // TODO Auto-generated catch block 312 e.printStackTrace(); 313 } 314 return true; 315 315 } 316 316 … … 352 352 activeConnection.setDoOutput(true); 353 353 activeConnection.setRequestProperty("Content-type", "application/x-www-form-urlencoded"); 354 OutputStream out = activeConnection.getOutputStream(); 355 356 // It seems that certain bits of the Ruby API are very unhappy upon 357 // receipt of a PUT/POST message without a Content-length header, 358 // even if the request has no payload. 359 // Since Java will not generate a Content-length header unless 360 // we use the output stream, we create an output stream for PUT/POST 361 // even if there is no payload. 362 if (requestBody != null) { 363 BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(out, "UTF-8")); 364 bwr.write(requestBody); 365 bwr.flush(); 354 try (OutputStream out = activeConnection.getOutputStream()) { 355 356 // It seems that certain bits of the Ruby API are very unhappy upon 357 // receipt of a PUT/POST message without a Content-length header, 358 // even if the request has no payload. 359 // Since Java will not generate a Content-length header unless 360 // we use the output stream, we create an output stream for PUT/POST 361 // even if there is no payload. 362 if (requestBody != null) { 363 BufferedWriter bwr = new BufferedWriter(new OutputStreamWriter(out, "UTF-8")); 364 bwr.write(requestBody); 365 bwr.flush(); 366 } 366 367 } 367 out.close();368 368 } 369 369 … … 442 442 } 443 443 } 444 444 445 445 protected InputStream getInputStream(String urlStr, ProgressMonitor progressMonitor) throws SdsTransferException { 446 446 urlStr = getBaseUrl() + urlStr; 447 try {447 try { 448 448 URL url = null; 449 449 try { -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsConnection.java
r29854 r30738 21 21 */ 22 22 public class SdsConnection { 23 23 24 24 protected boolean cancel = false; 25 25 protected HttpURLConnection activeConnection; -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsCredentialAgent.java
r30737 r30738 120 120 } 121 121 122 @Override123 public void storeOAuthAccessToken(OAuthToken accessToken)124 throws CredentialsAgentException {125 // no-op126 127 }128 122 @Override 123 public void storeOAuthAccessToken(OAuthToken accessToken) 124 throws CredentialsAgentException { 125 // no-op 126 127 } 128 129 129 @Override 130 130 public CredentialsAgentResponse getCredentials(RequestorType requestorType, String host, boolean noSuccessWithLastResponse) throws CredentialsAgentException{ -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsCredentialDialog.java
r28160 r30738 11 11 public class SdsCredentialDialog extends CredentialDialog { 12 12 13 static public SdsCredentialDialog getSdsApiCredentialDialog(String username, String password, String host, String saveUsernameAndPasswordCheckboxText) {13 static public SdsCredentialDialog getSdsApiCredentialDialog(String username, String password, String host, String saveUsernameAndPasswordCheckboxText) { 14 14 SdsCredentialDialog dialog = new SdsCredentialDialog(saveUsernameAndPasswordCheckboxText); 15 15 dialog.prepareForSdsApiCredentials(username, password); … … 21 21 22 22 public SdsCredentialDialog(String saveUsernameAndPasswordCheckboxText) { 23 super(saveUsernameAndPasswordCheckboxText);23 super(saveUsernameAndPasswordCheckboxText); 24 24 } 25 25 26 26 public void prepareForSdsApiCredentials(String username, String password) { 27 27 setTitle(tr("Enter credentials for Separate Data Store API")); … … 33 33 private static class SdsApiCredentialsPanel extends CredentialPanel { 34 34 35 @Override35 @Override 36 36 protected void build() { 37 37 super.build(); -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsDiskAccessAction.java
r30666 r30738 16 16 @SuppressWarnings("serial") 17 17 public abstract class SdsDiskAccessAction extends DiskAccessAction { 18 18 19 19 public SdsDiskAccessAction(String name, String iconName, String tooltip, 20 Shortcut shortcut) {21 super(name, iconName, tooltip, shortcut);22 }20 Shortcut shortcut) { 21 super(name, iconName, tooltip, shortcut); 22 } 23 23 24 public static SwingFileChooser createAndOpenFileChooser(boolean open, boolean multiple, String title) {24 public static SwingFileChooser createAndOpenFileChooser(boolean open, boolean multiple, String title) { 25 25 String curDir = Main.pref.get("lastDirectory"); 26 26 if (curDir.equals("")) { … … 35 35 fc.setMultiSelectionEnabled(multiple); 36 36 fc.setAcceptAllFileFilterUsed(false); 37 37 38 38 fc.setFileFilter(new FileFilter() { 39 public boolean accept(File pathname) { return pathname.getName().endsWith(".sds") || pathname.isDirectory(); }40 public String getDescription() { return (tr("SDS data file")); }39 public boolean accept(File pathname) { return pathname.getName().endsWith(".sds") || pathname.isDirectory(); } 40 public String getDescription() { return (tr("SDS data file")); } 41 41 }); 42 42 … … 83 83 84 84 fc.setFileFilter(new FileFilter() { 85 public boolean accept(File pathname) { return pathname.getName().endsWith(".sds") || pathname.isDirectory(); }86 public String getDescription() { return (tr("SDS data file")); }85 public boolean accept(File pathname) { return pathname.getName().endsWith(".sds") || pathname.isDirectory(); } 86 public String getDescription() { return (tr("SDS data file")); } 87 87 }); 88 88 -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsLoadAction.java
r30737 r30738 26 26 @SuppressWarnings("serial") 27 27 public class SdsLoadAction extends SdsDiskAccessAction { 28 29 private SeparateDataStorePlugin plugin;28 29 private SeparateDataStorePlugin plugin; 30 30 31 31 public SdsLoadAction(SeparateDataStorePlugin p) { 32 32 super(tr("Load..."), "sds_load", tr("Load separate data store data from a file."), null); 33 plugin = p;33 plugin = p; 34 34 } 35 35 -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsMenu.java
r29854 r30738 56 56 57 57 void setEnabledState() { 58 boolean en = (Main.map != null) && (Main.map.mapView != null) && (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer);59 loadItem.setEnabled(en);60 saveItem.setEnabled(en);58 boolean en = (Main.map != null) && (Main.map.mapView != null) && (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer); 59 loadItem.setEnabled(en); 60 saveItem.setEnabled(en); 61 61 } 62 62 63 @Override64 public void activeLayerChange(Layer oldLayer, Layer newLayer) {setEnabledState(); }63 @Override 64 public void activeLayerChange(Layer oldLayer, Layer newLayer) { setEnabledState(); } 65 65 66 @Override67 public void layerAdded(Layer newLayer) { setEnabledState(); }66 @Override 67 public void layerAdded(Layer newLayer) { setEnabledState(); } 68 68 69 @Override70 public void layerRemoved(Layer oldLayer) { setEnabledState(); }69 @Override 70 public void layerRemoved(Layer oldLayer) { setEnabledState(); } 71 71 72 private class SdsAboutAction extends JosmAction {72 private class SdsAboutAction extends JosmAction { 73 73 74 public SdsAboutAction() {75 super(tr("About"), "sds", tr("Information about SDS."), null, true);76 }74 public SdsAboutAction() { 75 super(tr("About"), "sds", tr("Information about SDS."), null, true); 76 } 77 77 78 public void actionPerformed(ActionEvent e) {79 JPanel about = new JPanel();78 public void actionPerformed(ActionEvent e) { 79 JPanel about = new JPanel(); 80 80 81 JTextArea l = new JTextArea();82 l.setLineWrap(true);83 l.setWrapStyleWord(true);84 l.setEditable(false);85 l.setText("Separate Data Store\n\nThis plugin provides access to a \"Separate Data Store\" server. " +86 "Whenever data is loaded from the OSM API, it queries the SDS for additional tags that have been stored for the objects just loaded, " +87 "and adds these tags. When you upload data to JOSM, SDS tags will again be separated and, instead of sending them to OSM, they will be uplaoded to SDS." +88 "\n\n" +89 "This depends on SDS tags starting with a special prefix, which can be configured in the SDS preferences." +90 "\n\n" +91 "Using the SDS server will usually require an account to be set up there, which is completely independent of your OSM account.");92 93 l.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));94 l.setOpaque(false);95 l.setPreferredSize(new Dimension(500,300));96 JScrollPane sp = new JScrollPane(l);97 sp.setBorder(null);98 sp.setOpaque(false);99 100 about.add(sp);101 102 about.setPreferredSize(new Dimension(500,300));81 JTextArea l = new JTextArea(); 82 l.setLineWrap(true); 83 l.setWrapStyleWord(true); 84 l.setEditable(false); 85 l.setText("Separate Data Store\n\nThis plugin provides access to a \"Separate Data Store\" server. " + 86 "Whenever data is loaded from the OSM API, it queries the SDS for additional tags that have been stored for the objects just loaded, " + 87 "and adds these tags. When you upload data to JOSM, SDS tags will again be separated and, instead of sending them to OSM, they will be uplaoded to SDS." + 88 "\n\n" + 89 "This depends on SDS tags starting with a special prefix, which can be configured in the SDS preferences." + 90 "\n\n" + 91 "Using the SDS server will usually require an account to be set up there, which is completely independent of your OSM account."); 92 93 l.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 94 l.setOpaque(false); 95 l.setPreferredSize(new Dimension(500,300)); 96 JScrollPane sp = new JScrollPane(l); 97 sp.setBorder(null); 98 sp.setOpaque(false); 99 100 about.add(sp); 101 102 about.setPreferredSize(new Dimension(500,300)); 103 103 104 JOptionPane.showMessageDialog(Main.parent, about, tr("About SDS..."),105 JOptionPane.INFORMATION_MESSAGE, null);106 }107 }108 109 private class SdsPreferencesAction extends JosmAction implements Runnable {104 JOptionPane.showMessageDialog(Main.parent, about, tr("About SDS..."), 105 JOptionPane.INFORMATION_MESSAGE, null); 106 } 107 } 108 109 private class SdsPreferencesAction extends JosmAction implements Runnable { 110 110 111 private SdsPreferencesAction() {112 super(tr("Preferences..."), "preference", tr("Open a preferences dialog for SDS."),113 null, true);114 putValue("help", ht("/Action/Preferences"));115 }111 private SdsPreferencesAction() { 112 super(tr("Preferences..."), "preference", tr("Open a preferences dialog for SDS."), 113 null, true); 114 putValue("help", ht("/Action/Preferences")); 115 } 116 116 117 /**118 * Launch the preferences dialog.119 */120 public void actionPerformed(ActionEvent e) {121 run();122 }117 /** 118 * Launch the preferences dialog. 119 */ 120 public void actionPerformed(ActionEvent e) { 121 run(); 122 } 123 123 124 public void run() {125 PreferenceDialog pd = new PreferenceDialog(Main.parent);126 // unusual reflection mechanism to cater for older JOSM versions where127 // the selectPreferencesTabByName method was not public128 try {129 Method sptbn = pd.getClass().getMethod("selectPreferencesTabByName", String.class);130 sptbn.invoke(pd, "sds");131 } catch (Exception ex) {132 // ignore133 }134 pd.setVisible(true);135 }136 }124 public void run() { 125 PreferenceDialog pd = new PreferenceDialog(Main.parent); 126 // unusual reflection mechanism to cater for older JOSM versions where 127 // the selectPreferencesTabByName method was not public 128 try { 129 Method sptbn = pd.getClass().getMethod("selectPreferencesTabByName", String.class); 130 sptbn.invoke(pd, "sds"); 131 } catch (Exception ex) { 132 // ignore 133 } 134 pd.setVisible(true); 135 } 136 } 137 137 138 138 -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsOsmWriter.java
r30737 r30738 27 27 public class SdsOsmWriter extends OsmWriter { 28 28 29 private SeparateDataStorePlugin plugin;30 29 private SeparateDataStorePlugin plugin; 30 31 31 public SdsOsmWriter(SeparateDataStorePlugin plugin, PrintWriter out, boolean osmConform, String version) { 32 32 super(out, osmConform, version); … … 43 43 Collections.sort(entries, byKeyComparator); 44 44 for (Entry<String, String> e : entries) { 45 String key = e.getKey();45 String key = e.getKey(); 46 46 if (!(osm instanceof Changeset) && ("created_by".equals(key))) continue; 47 47 if (key.startsWith(plugin.getIgnorePrefix())) continue; -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsOsmWriterFactory.java
r28160 r30738 15 15 public class SdsOsmWriterFactory extends OsmWriterFactory { 16 16 17 SeparateDataStorePlugin plugin;18 19 public SdsOsmWriterFactory(SeparateDataStorePlugin plugin) {20 this.plugin = plugin;21 }22 23 @Override17 SeparateDataStorePlugin plugin; 18 19 public SdsOsmWriterFactory(SeparateDataStorePlugin plugin) { 20 this.plugin = plugin; 21 } 22 23 @Override 24 24 protected OsmWriter createOsmWriterImpl(PrintWriter out, boolean osmConform, String version) { 25 25 return new SdsOsmWriter(plugin, out, osmConform, version); -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsParser.java
r28160 r30738 54 54 { 55 55 String type = atts.getValue("osm_type"); 56 String id = atts.getValue("osm_id"); 56 String id = atts.getValue("osm_id"); 57 57 currentPrimitive = dataSet.getPrimitiveById(Long.parseLong(id), OsmPrimitiveType.fromApiTypeName(type)); 58 58 if (currentPrimitive == null && ensureMatch) { -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsPluginPreferences.java
r28160 r30738 35 35 36 36 public SdsPluginPreferences() { 37 super("sds", tr("Separate Data Store"), tr("Configures access to the Separate Data Store."));37 super("sds", tr("Separate Data Store"), tr("Configures access to the Separate Data Store.")); 38 38 } 39 39 @Override 40 40 public void addGui(final PreferenceTabbedPane gui) { 41 41 final JPanel tab = gui.createPreferenceTab(this); 42 42 43 43 final JPanel access = new JPanel(new GridBagLayout()); 44 44 access.setBorder(BorderFactory.createTitledBorder(tr("Server"))); -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsSaveAction.java
r29854 r30738 6 6 import java.awt.event.ActionEvent; 7 7 import java.io.File; 8 import java.io.FileInputStream;9 import java.io.FileNotFoundException;10 8 import java.io.FileOutputStream; 11 9 import java.io.IOException; … … 21 19 import org.openstreetmap.josm.gui.layer.Layer; 22 20 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 21 import org.openstreetmap.josm.tools.Utils; 23 22 24 @SuppressWarnings("serial")25 23 public class SdsSaveAction extends SdsDiskAccessAction { 26 24 … … 30 28 } 31 29 30 @Override 32 31 public void actionPerformed(ActionEvent e) { 33 32 if (!isEnabled()) … … 40 39 if (Main.isDisplayingMapView() && (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer)) 41 40 layer = Main.map.mapView.getActiveLayer(); 42 41 43 42 if (layer == null) 44 43 return false; … … 64 63 if (file.exists()) { 65 64 tmpFile = new File(file.getPath() + "~"); 66 copy(file, tmpFile);65 Utils.copyFile(file, tmpFile); 67 66 } 68 67 … … 70 69 Writer writer = new OutputStreamWriter(out, "UTF-8"); 71 70 72 SdsWriter w = new SdsWriter(new PrintWriter(writer));73 71 layer.data.getReadLock().lock(); 74 try { 72 try (SdsWriter w = new SdsWriter(new PrintWriter(writer))) { 75 73 w.header(); 76 74 for (IPrimitive p : layer.data.allNonDeletedPrimitives()) { … … 78 76 } 79 77 w.footer(); 80 w.close();81 78 } finally { 82 79 layer.data.getReadLock().unlock(); … … 87 84 } 88 85 } catch (IOException e) { 89 e.printStackTrace();86 Main.error(e); 90 87 JOptionPane.showMessageDialog( 91 88 Main.parent, … … 99 96 // be deleted. So, restore the backup if we made one. 100 97 if (tmpFile != null && tmpFile.exists()) { 101 copy(tmpFile, file);98 Utils.copyFile(tmpFile, file); 102 99 } 103 100 } catch (IOException e2) { 104 e2.printStackTrace();101 Main.error(e2); 105 102 JOptionPane.showMessageDialog( 106 103 Main.parent, … … 113 110 return true; 114 111 } 115 116 private void copy(File src, File dst) throws IOException {117 FileInputStream srcStream;118 FileOutputStream dstStream;119 try {120 srcStream = new FileInputStream(src);121 dstStream = new FileOutputStream(dst);122 } catch (FileNotFoundException e) {123 JOptionPane.showMessageDialog(Main.parent, tr("Could not back up file. Exception is: {0}", e124 .getMessage()), tr("Error"), JOptionPane.ERROR_MESSAGE);125 return;126 }127 byte buf[] = new byte[1 << 16];128 int len;129 while ((len = srcStream.read(buf)) != -1) {130 dstStream.write(buf, 0, len);131 }132 srcStream.close();133 dstStream.close();134 }135 112 } -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SdsWriter.java
r28160 r30738 29 29 30 30 public void write(IPrimitive what, Map<String,String> tags) { 31 out.print("<osm_shadow osm_type=\"");32 out.print(what.getType().getAPIName());33 out.print("\" osm_id=\"");34 out.print(what.getId());35 out.println("\">");31 out.print("<osm_shadow osm_type=\""); 32 out.print(what.getType().getAPIName()); 33 out.print("\" osm_id=\""); 34 out.print(what.getId()); 35 out.println("\">"); 36 36 37 if (tags != null) {38 for(Entry<String,String> e : tags.entrySet()) {39 out.println(" <tag k='"+ XmlWriter.encode(e.getKey()) +40 "' v='"+XmlWriter.encode(e.getValue())+ "' />");41 }42 }43 44 out.println("</osm_shadow>");37 if (tags != null) { 38 for(Entry<String,String> e : tags.entrySet()) { 39 out.println(" <tag k='"+ XmlWriter.encode(e.getKey()) + 40 "' v='"+XmlWriter.encode(e.getValue())+ "' />"); 41 } 42 } 43 44 out.println("</osm_shadow>"); 45 45 } 46 46 -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/SeparateDataStorePlugin.java
r30737 r30738 29 29 { 30 30 31 public HashMap<Long, IPrimitive> originalNodes = new HashMap<>();32 public HashMap<Long, IPrimitive> originalWays = new HashMap<>();33 public HashMap<Long, IPrimitive> originalRelations = new HashMap<>();34 35 public ArrayList<QueueItem> uploadQueue = new ArrayList<>();36 37 private PrimitiveVisitor learnVisitor = new PrimitiveVisitor() {38 public void visit(INode i) { originalNodes.put(i.getId(), i); }39 public void visit(IWay i) { originalWays.put(i.getId(), i); }40 public void visit(IRelation i) { originalRelations.put(i.getId(), i); }41 };42 43 class QueueItem {44 public IPrimitive primitive;45 public HashMap<String,String> tags;46 public boolean sdsOnly;47 public boolean processed;48 public QueueItem(IPrimitive p, HashMap<String,String> t, boolean s) {49 primitive = p;50 tags = t;51 sdsOnly = s;52 processed = false;53 }54 }55 31 public HashMap<Long, IPrimitive> originalNodes = new HashMap<>(); 32 public HashMap<Long, IPrimitive> originalWays = new HashMap<>(); 33 public HashMap<Long, IPrimitive> originalRelations = new HashMap<>(); 34 35 public ArrayList<QueueItem> uploadQueue = new ArrayList<>(); 36 37 private PrimitiveVisitor learnVisitor = new PrimitiveVisitor() { 38 public void visit(INode i) { originalNodes.put(i.getId(), i); } 39 public void visit(IWay i) { originalWays.put(i.getId(), i); } 40 public void visit(IRelation i) { originalRelations.put(i.getId(), i); } 41 }; 42 43 class QueueItem { 44 public IPrimitive primitive; 45 public HashMap<String,String> tags; 46 public boolean sdsOnly; 47 public boolean processed; 48 public QueueItem(IPrimitive p, HashMap<String,String> t, boolean s) { 49 primitive = p; 50 tags = t; 51 sdsOnly = s; 52 processed = false; 53 } 54 } 55 56 56 /** 57 57 * Creates the plugin … … 60 60 { 61 61 super(info); 62 System.out.println("initializing SDS plugin");63 64 // this lets us see what JOSM load from the server, and augment it with our data:62 System.out.println("initializing SDS plugin"); 63 64 // this lets us see what JOSM load from the server, and augment it with our data: 65 65 OsmReader.registerPostprocessor(new ReadPostprocessor(this)); 66 66 … … 79 79 } 80 80 81 public String getIgnorePrefix() {81 public String getIgnorePrefix() { 82 82 return Main.pref.get("sds-server.tag-prefix", "hot:"); 83 }84 85 public IPrimitive getOriginalPrimitive(IPrimitive other) {86 switch (other.getType()) {87 case NODE: return originalNodes.get(other.getId());88 case WAY: return originalWays.get(other.getId());89 case RELATION: return originalRelations.get(other.getId());90 }91 return null;92 }93 94 protected void enqueueForUpload(IPrimitive prim, HashMap<String, String> tags, boolean onlySds) {95 uploadQueue.add(new QueueItem(prim, tags, onlySds));96 }97 98 /**99 * Stores the given primitive in the plugin's cache in order to100 * determine changes later.101 * @param prim102 */103 protected void learn(IPrimitive prim) {104 if (prim instanceof OsmPrimitive) {105 ((OsmPrimitive)prim).save().accept(learnVisitor);106 } else {107 prim.accept(learnVisitor);108 }109 }110 111 /**112 * removes all elements from the upload queue that have the processed flag set.113 */114 protected void clearQueue() {115 ArrayList<QueueItem> newQueue = new ArrayList<>();116 for (QueueItem q : uploadQueue) {117 if (!q.processed) newQueue.add(q);118 }119 uploadQueue = newQueue;120 }121 122 /**123 * reset the processed flag for all elements of the queue.124 */125 protected void resetQueue() {126 for (QueueItem q : uploadQueue) {127 q.processed = false;128 }129 }83 } 84 85 public IPrimitive getOriginalPrimitive(IPrimitive other) { 86 switch (other.getType()) { 87 case NODE: return originalNodes.get(other.getId()); 88 case WAY: return originalWays.get(other.getId()); 89 case RELATION: return originalRelations.get(other.getId()); 90 } 91 return null; 92 } 93 94 protected void enqueueForUpload(IPrimitive prim, HashMap<String, String> tags, boolean onlySds) { 95 uploadQueue.add(new QueueItem(prim, tags, onlySds)); 96 } 97 98 /** 99 * Stores the given primitive in the plugin's cache in order to 100 * determine changes later. 101 * @param prim 102 */ 103 protected void learn(IPrimitive prim) { 104 if (prim instanceof OsmPrimitive) { 105 ((OsmPrimitive)prim).save().accept(learnVisitor); 106 } else { 107 prim.accept(learnVisitor); 108 } 109 } 110 111 /** 112 * removes all elements from the upload queue that have the processed flag set. 113 */ 114 protected void clearQueue() { 115 ArrayList<QueueItem> newQueue = new ArrayList<>(); 116 for (QueueItem q : uploadQueue) { 117 if (!q.processed) newQueue.add(q); 118 } 119 uploadQueue = newQueue; 120 } 121 122 /** 123 * reset the processed flag for all elements of the queue. 124 */ 125 protected void resetQueue() { 126 for (QueueItem q : uploadQueue) { 127 q.processed = false; 128 } 129 } 130 130 131 131 public PreferenceSetting getPreferenceSetting() { -
applications/editors/josm/plugins/sds/src/org/openstreetmap/hot/sds/WritePostprocessor.java
r29854 r30738 13 13 public class WritePostprocessor implements OsmServerWritePostprocessor { 14 14 15 SeparateDataStorePlugin plugin;15 SeparateDataStorePlugin plugin; 16 16 17 public WritePostprocessor(SeparateDataStorePlugin plugin) {18 this.plugin = plugin;19 } 17 public WritePostprocessor(SeparateDataStorePlugin plugin) { 18 this.plugin = plugin; 19 } 20 20 21 @Override 22 public void postprocessUploadedPrimitives(Collection<IPrimitive> primitives, 23 ProgressMonitor progress) { 24 25 StringWriter swriter = new StringWriter(); 26 SdsWriter sdsWriter = new SdsWriter(new PrintWriter(swriter)); 27 sdsWriter.header(); 28 boolean somethingWritten = false; 29 30 for (IPrimitive p : primitives) { 31 for (QueueItem q : plugin.uploadQueue) { 32 if (q.primitive.equals(p) && !q.sdsOnly) { 33 sdsWriter.write(q.primitive, q.tags); 34 somethingWritten = true; 35 q.processed = true; 36 continue; 37 } 38 } 39 } 40 41 for (QueueItem q : plugin.uploadQueue) { 42 if (q.sdsOnly) { 43 sdsWriter.write(q.primitive, q.tags); 44 somethingWritten = true; 45 q.processed = true; 46 } 47 } 21 @Override 22 public void postprocessUploadedPrimitives(Collection<IPrimitive> primitives, ProgressMonitor progress) { 48 23 49 if (somethingWritten) { 50 sdsWriter.footer(); 24 StringWriter swriter = new StringWriter(); 25 try (SdsWriter sdsWriter = new SdsWriter(new PrintWriter(swriter))) { 26 sdsWriter.header(); 27 boolean somethingWritten = false; 51 28 52 SdsApi api = SdsApi.getSdsApi(); 53 System.out.println("sending message:\n" + swriter.toString()); 54 api.updateSds(swriter.toString(), progress); 55 } 56 57 sdsWriter.close();58 59 for (IPrimitive p : primitives) { 60 plugin.learn(p); 61 }29 for (IPrimitive p : primitives) { 30 for (QueueItem q : plugin.uploadQueue) { 31 if (q.primitive.equals(p) && !q.sdsOnly) { 32 sdsWriter.write(q.primitive, q.tags); 33 somethingWritten = true; 34 q.processed = true; 35 continue; 36 } 37 } 38 } 62 39 63 for (QueueItem q : plugin.uploadQueue) { 64 if (q.sdsOnly) { 65 q.primitive.setModified(false); 66 plugin.learn(q.primitive); 67 } 68 } 69 70 plugin.clearQueue(); 71 // TODO: if exception -> resetQueue 72 } 40 for (QueueItem q : plugin.uploadQueue) { 41 if (q.sdsOnly) { 42 sdsWriter.write(q.primitive, q.tags); 43 somethingWritten = true; 44 q.processed = true; 45 } 46 } 47 48 if (somethingWritten) { 49 sdsWriter.footer(); 50 51 SdsApi api = SdsApi.getSdsApi(); 52 System.out.println("sending message:\n" + swriter.toString()); 53 api.updateSds(swriter.toString(), progress); 54 } 55 } 56 57 for (IPrimitive p : primitives) { 58 plugin.learn(p); 59 } 60 61 for (QueueItem q : plugin.uploadQueue) { 62 if (q.sdsOnly) { 63 q.primitive.setModified(false); 64 plugin.learn(q.primitive); 65 } 66 } 67 68 plugin.clearQueue(); 69 // TODO: if exception -> resetQueue 70 } 73 71 74 72 }
Note:
See TracChangeset
for help on using the changeset viewer.
