Ignore:
Timestamp:
2011-12-11T04:08:26+01:00 (13 years ago)
Author:
frederik
Message:

the license change plugin now uses a different interface on wtfe.gryph.de; the old
interface will be discontinued soon.

new, simpler colour scheme: red = creator has not agreed; orange = someone else has not
agreed; yellow = someone has not agreed but the edit is harmless/negligible.

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  
    55
    66import java.util.Arrays;
     7import java.util.Map.Entry;
     8import java.util.HashMap;
    79import java.util.Collections;
    810import java.util.List;
     
    2527    @Override public void visit(Node n)
    2628    {
    27         List<User> users = plugin.getUsers(n);
     29        HashMap<User,Severity> users = plugin.getUsers(n);
    2830        doCheck(n, users);
    2931    }
    3032    @Override public void visit(Way w)
    3133    {
    32         List<User> users = plugin.getUsers(w);
     34        HashMap<User, Severity> users = plugin.getUsers(w);
    3335        doCheck(w, users);
    3436    }
    3537    @Override public void visit(Relation r)
    3638    {
    37         List<User> users = plugin.getUsers(r);
     39        HashMap<User, Severity> users = plugin.getUsers(r);
    3840        doCheck(r, users);
    3941    }
    4042
    41     private void doCheck(OsmPrimitive n, List<User> users)
     43    private void doCheck(OsmPrimitive n, HashMap<User, Severity> users)
    4244    {
    4345        Severity sev = null;
    4446        if ((users != null) && (n.getUser() != null))
    4547        {
    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            }
    4756            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");
    7063            }
    7164
  • applications/editors/josm/plugins/licensechange/src/org/openstreetmap/josm/plugins/licensechange/LicenseChangePlugin.java

    r27161 r27206  
    7474
    7575    /** 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()); }
    8383
    8484    /**
     
    150150    private class QhsParser extends DefaultHandler
    151151    {
    152         List<User> theList = null;
     152        HashMap<User, Severity> theMap = null;
    153153
    154154        @Override
     
    160160            if ("node".equals(qName) || "way".equals(qName) || "relation".equals(qName))
    161161            {
    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;
    163163                 // 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>());
    165165            }
    166166            else if ("user".equals(qName))
     
    169169                String i = atts.getValue("id");
    170170                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";
    171176                User u = User.createOsmUser(Long.parseLong(i), null);
    172                 if ("first".equals(v)) theList.add(0, u); else theList.add(u);
    173177                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);
    182186            }
    183187        }
     
    218222
    219223        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");
    221225            HttpURLConnection activeConnection = (HttpURLConnection)qhs.openConnection();
    222226            activeConnection.setRequestMethod("POST");
  • applications/editors/josm/plugins/licensechange/src/org/openstreetmap/josm/plugins/licensechange/Severity.java

    r26377 r27206  
    1313
    1414    /** Error messages */
    15     DATA_LOSS(tr("Data loss"), "error",                     
     15    FIRST(tr("data loss"), "error",                     
    1616        Main.pref.getColor(marktr("license check error"), Color.RED)),
    1717
    1818    /** Warning messages */
    19     POSSIBLE_DATA_LOSS(tr("Possible data loss"), "warning",
     19    NORMAL(tr("possible data loss"), "warning",
    2020        Main.pref.getColor(marktr("license check warning"), Color.ORANGE)),
    2121
    2222    /** 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));
    2529
    2630    /** Description of the severity code */
Note: See TracChangeset for help on using the changeset viewer.