Changeset 27206 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-12-11T04:08:26+01:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/licensechange/src/org/openstreetmap/josm/plugins/licensechange
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/licensechange/src/org/openstreetmap/josm/plugins/licensechange/BasicLicenseCheck.java
r26260 r27206 5 5 6 6 import java.util.Arrays; 7 import java.util.Map.Entry; 8 import java.util.HashMap; 7 9 import java.util.Collections; 8 10 import java.util.List; … … 25 27 @Override public void visit(Node n) 26 28 { 27 List<User> users = plugin.getUsers(n);29 HashMap<User,Severity> users = plugin.getUsers(n); 28 30 doCheck(n, users); 29 31 } 30 32 @Override public void visit(Way w) 31 33 { 32 List<User> users = plugin.getUsers(w);34 HashMap<User, Severity> users = plugin.getUsers(w); 33 35 doCheck(w, users); 34 36 } 35 37 @Override public void visit(Relation r) 36 38 { 37 List<User> users = plugin.getUsers(r);39 HashMap<User, Severity> users = plugin.getUsers(r); 38 40 doCheck(r, users); 39 41 } 40 42 41 private void doCheck(OsmPrimitive n, List<User> users)43 private void doCheck(OsmPrimitive n, HashMap<User, Severity> users) 42 44 { 43 45 Severity sev = null; 44 46 if ((users != null) && (n.getUser() != null)) 45 47 { 46 int u0 = users.get(0).getRelicensingStatus(); 48 for (Entry<User, Severity> e : users.entrySet()) 49 { 50 // larger sev value = less important 51 if ((sev == null) || (sev.compareTo(e.getValue()) > 0)) 52 { 53 sev = e.getValue(); 54 } 55 } 47 56 String msg = null; 48 if (u0 == User.STATUS_NOT_AGREED || u0 == User.STATUS_ANONYMOUS) 49 { 50 sev = Severity.DATA_LOSS; 51 msg = (u0 == User.STATUS_NOT_AGREED) ? tr("Creator has rejected CT") : tr("Creator unknown"); 52 } 53 else if (u0 == User.STATUS_UNDECIDED) 54 { 55 sev = Severity.POSSIBLE_DATA_LOSS; 56 msg = tr("Creator has not (yet) accepted CT"); 57 } 58 else 59 { 60 for (int i=1; i<users.size(); i++) 61 { 62 int ux = users.get(i).getRelicensingStatus(); 63 if (ux == User.STATUS_NOT_AGREED || ux == User.STATUS_ANONYMOUS || ux == User.STATUS_UNDECIDED) 64 { 65 sev = Severity.DATA_REDUCTION; 66 msg = tr("Object modified by user(s) who have rejected, or not agreed to, CT"); 67 break; 68 } 69 } 57 if (sev == Severity.FIRST) { 58 msg = tr("Creator has not agreed to CT"); 59 } else if (sev == Severity.NORMAL) { 60 msg = tr("Object modified by user(s) who have rejected, or not agreed to, CT"); 61 } else { 62 msg = tr("minor issue"); 70 63 } 71 64 -
applications/editors/josm/plugins/licensechange/src/org/openstreetmap/josm/plugins/licensechange/LicenseChangePlugin.java
r27161 r27206 74 74 75 75 /** Database of users who have edited something. */ 76 private final Map<Long, List<User>> nodeUsers = new HashMap<Long, List<User>>();77 private final Map<Long, List<User>> wayUsers = new HashMap<Long, List<User>>();78 private final Map<Long, List<User>> relationUsers = new HashMap<Long, List<User>>();79 80 public List<User> getUsers(Node n) { return nodeUsers.get(n.getId()); }81 public List<User> getUsers(Way n) { return wayUsers.get(n.getId()); }82 public List<User> getUsers(Relation n) { return relationUsers.get(n.getId()); }76 private final HashMap<Long, HashMap<User, Severity>> nodeUsers = new HashMap<Long, HashMap<User, Severity>>(); 77 private final HashMap<Long, HashMap<User, Severity>> wayUsers = new HashMap<Long, HashMap<User, Severity>>(); 78 private final HashMap<Long, HashMap<User, Severity>> relationUsers = new HashMap<Long, HashMap<User, Severity>>(); 79 80 public HashMap<User, Severity> getUsers(Node n) { return nodeUsers.get(n.getId()); } 81 public HashMap<User, Severity> getUsers(Way n) { return wayUsers.get(n.getId()); } 82 public HashMap<User, Severity> getUsers(Relation n) { return relationUsers.get(n.getId()); } 83 83 84 84 /** … … 150 150 private class QhsParser extends DefaultHandler 151 151 { 152 List<User> theList= null;152 HashMap<User, Severity> theMap = null; 153 153 154 154 @Override … … 160 160 if ("node".equals(qName) || "way".equals(qName) || "relation".equals(qName)) 161 161 { 162 Map<Long, List<User>> theMap = ("node".equals(qName)) ? nodeUsers : ("way".equals(qName)) ? wayUsers : relationUsers;162 HashMap<Long, HashMap<User, Severity>> userMap = ("node".equals(qName)) ? nodeUsers : ("way".equals(qName)) ? wayUsers : relationUsers; 163 163 // we always overwrite a list that might already exist 164 theMap.put(Long.decode(atts.getValue("id")), theList = new ArrayList<User>());164 userMap.put(Long.decode(atts.getValue("id")), theMap = new HashMap<User, Severity>()); 165 165 } 166 166 else if ("user".equals(qName)) … … 169 169 String i = atts.getValue("id"); 170 170 String d = atts.getValue("decision"); 171 String s = atts.getValue("severity"); 172 173 if (!"undecided".equals(d) && !"no".equals(d)) return; 174 175 if ("normal".equals(s) && "first".equals(v)) s = "first"; 171 176 User u = User.createOsmUser(Long.parseLong(i), null); 172 if ("first".equals(v)) theList.add(0, u); else theList.add(u);173 177 u.setRelicensingStatus( 174 "undecided".equals(d) ? User.STATUS_UNDECIDED :175 "auto".equals(d) ? User.STATUS_AUTO_AGREED :176 "yes".equals(d) ? User.STATUS_AGREED :177 "override".equals(d) ? User.STATUS_AGREED :178 "pd".equals(d) ? User.STATUS_AGREED:179 "no".equals(d) ? User.STATUS_NOT_AGREED:180 "anonymous".equals(d) ? User.STATUS_ANONYMOUS :181 User.STATUS_UNKNOWN);178 "undecided".equals(d) ? User.STATUS_UNDECIDED : 179 "no".equals(d) ? User.STATUS_NOT_AGREED : 180 User.STATUS_UNKNOWN); 181 theMap.put(u, 182 "first".equals(s) ? Severity.FIRST : 183 "normal".equals(s) ? Severity.NORMAL : 184 "harmless".equals(s) ? Severity.HARMLESS : 185 Severity.NONE); 182 186 } 183 187 } … … 218 222 219 223 try { 220 URL qhs = new URL("http://wtfe.gryph.de/api/0.6/ userlist");224 URL qhs = new URL("http://wtfe.gryph.de/api/0.6/problems"); 221 225 HttpURLConnection activeConnection = (HttpURLConnection)qhs.openConnection(); 222 226 activeConnection.setRequestMethod("POST"); -
applications/editors/josm/plugins/licensechange/src/org/openstreetmap/josm/plugins/licensechange/Severity.java
r26377 r27206 13 13 14 14 /** Error messages */ 15 DATA_LOSS(tr("Data loss"), "error",15 FIRST(tr("data loss"), "error", 16 16 Main.pref.getColor(marktr("license check error"), Color.RED)), 17 17 18 18 /** Warning messages */ 19 POSSIBLE_DATA_LOSS(tr("Possible data loss"), "warning",19 NORMAL(tr("possible data loss"), "warning", 20 20 Main.pref.getColor(marktr("license check warning"), Color.ORANGE)), 21 21 22 22 /** Other messages */ 23 DATA_REDUCTION(tr("Data reduction"), "other", 24 Main.pref.getColor(marktr("license check notice"), Color.YELLOW)); 23 HARMLESS(tr("harmless data loss"), "other", 24 Main.pref.getColor(marktr("license check notice"), Color.YELLOW)), 25 26 /** Other messages */ 27 NONE(tr("no data loss"), "other", 28 Main.pref.getColor(marktr("license check info"), Color.GRAY)); 25 29 26 30 /** Description of the severity code */
Note:
See TracChangeset
for help on using the changeset viewer.