Changeset 4066 in josm


Ignore:
Timestamp:
2011-05-02T02:48:28+02:00 (13 years ago)
Author:
framm
Message:

add a member variable to User class for storing relicensing status,
allowing us to explicitly set it and not rely on users_agreed.txt;
to be used when relicensing info is loaded from another source.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/User.java

    r4037 r4066  
    6868            userMap.put(user.getId(), user);
    6969        }
    70         user.addName(name);
     70        if (name != null) user.addName(name);
    7171        return user;
    7272    }
     
    175175    /** the user id */
    176176    private final long uid;
    177 
    178     public static final int STATUS_UNKNOWN = 0;
     177    private int relicensingStatus = STATUS_UNKNOWN;
     178
     179    public static final int STATUS_UNKNOWN = -1;
     180    public static final int STATUS_UNDECIDED = 0;
    179181    public static final int STATUS_AGREED = 1;
    180182    public static final int STATUS_NOT_AGREED = 2;
    181183    public static final int STATUS_AUTO_AGREED = 3;
     184    public static final int STATUS_ANONYMOUS = 4;
    182185
    183186    /**
     187    * Finds out this user's relicensing status and saves it for quicker
     188    * access.
    184189    */
    185190    public int getRelicensingStatus() {
    186         if (uid >= 286582) return STATUS_AUTO_AGREED;
     191        if (relicensingStatus != STATUS_UNKNOWN) return relicensingStatus;
     192        if (uid >= 286582) return (relicensingStatus = STATUS_AUTO_AGREED);
    187193        if (relicensingUsers == null) return STATUS_UNKNOWN;
    188194        Long id = new Long(uid);
    189         if (relicensingUsers.contains(id)) return STATUS_AGREED;
     195        if (relicensingUsers.contains(id)) return (relicensingStatus = STATUS_AGREED);
    190196        if (nonRelicensingUsers == null) return STATUS_UNKNOWN;
    191         if (nonRelicensingUsers.contains(id)) return STATUS_NOT_AGREED;
     197        if (nonRelicensingUsers.contains(id)) return (relicensingStatus = STATUS_NOT_AGREED);
    192198        return STATUS_UNKNOWN;
     199    }
     200
     201    /**
     202    * Sets this user's relicensing status. This can be used if relicensing
     203    * information is available from another source so that directly looking
     204    * at the users_agreed/users_not_agreed files it not required.
     205    */
     206    public void setRelicensingStatus(int status) {
     207        relicensingStatus = status;
    193208    }
    194209
Note: See TracChangeset for help on using the changeset viewer.