Skip to content

Commit 1e9f55a

Browse files
committed
siteID property renamed to blogId to match other similar properties
1 parent c2432c0 commit 1e9f55a

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

WordPress/src/main/java/org/wordpress/android/datasets/PeopleTable.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private static SQLiteDatabase getWritableDb() {
2525
public static void createTables(SQLiteDatabase db) {
2626
db.execSQL("CREATE TABLE " + PEOPLE_TABLE + " ("
2727
+ "person_id INTEGER DEFAULT 0,"
28-
+ "site_id TEXT,"
28+
+ "blog_id TEXT,"
2929
+ "local_blog_id INTEGER DEFAULT 0,"
3030
+ "user_name TEXT,"
3131
+ "first_name TEXT,"
@@ -54,7 +54,7 @@ public static void save(Person person) {
5454
public static void save(Person person, SQLiteDatabase database) {
5555
ContentValues values = new ContentValues();
5656
values.put("person_id", person.getPersonID());
57-
values.put("site_id", person.getSiteID());
57+
values.put("blog_id", person.getBlogId());
5858
values.put("local_blog_id", person.getLocalTableBlogId());
5959
values.put("user_name", person.getUsername());
6060
values.put("first_name", person.getFirstName());
@@ -96,7 +96,7 @@ public static List<Person> getPeople(int localTableBlogId) {
9696

9797
/**
9898
* retrieve a single person
99-
* @param personId - id of a person in a particular site
99+
* @param personId - id of a person in a particular blog
100100
* @param localTableBlogId - the local blog id the user belongs to
101101
* @return Person if found, null otherwise
102102
*/
@@ -115,14 +115,14 @@ public static Person getPerson(long personId, int localTableBlogId) {
115115

116116
private static Person getPersonFromCursor(Cursor c, int localTableBlogId) {
117117
long personId = c.getInt(c.getColumnIndex("person_id"));
118-
String siteId = c.getString(c.getColumnIndex("site_id"));
118+
String blogId = c.getString(c.getColumnIndex("blog_id"));
119119
String username = c.getString(c.getColumnIndex("user_name"));
120120
String firstName = c.getString(c.getColumnIndex("first_name"));
121121
String lastName = c.getString(c.getColumnIndex("last_name"));
122122
String displayName = c.getString(c.getColumnIndex("display_name"));
123123
String avatarUrl = c.getString(c.getColumnIndex("avatar_url"));
124124
String role = c.getString(c.getColumnIndex("role"));
125125

126-
return new Person(personId, siteId, localTableBlogId, username, firstName, lastName, displayName, avatarUrl, role);
126+
return new Person(personId, blogId, localTableBlogId, username, firstName, lastName, displayName, avatarUrl, role);
127127
}
128128
}

WordPress/src/main/java/org/wordpress/android/models/Person.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
public class Person {
1010
private long personID;
11-
private String siteID;
11+
private String blogId;
1212
private int localTableBlogId;
1313

1414
private String username;
@@ -19,7 +19,7 @@ public class Person {
1919
private String role;
2020

2121
public Person(long personID,
22-
String siteID,
22+
String blogId,
2323
int localTableBlogId,
2424
String username,
2525
String firstName,
@@ -28,7 +28,7 @@ public Person(long personID,
2828
String avatarUrl,
2929
String role) {
3030
this.personID = personID;
31-
this.siteID = siteID;
31+
this.blogId = blogId;
3232
this.localTableBlogId = localTableBlogId;
3333
this.username = username;
3434
this.firstName = firstName;
@@ -39,7 +39,7 @@ public Person(long personID,
3939
}
4040

4141
@Nullable
42-
public static Person fromJSON(JSONObject json, String siteID, int localTableBlogId) throws JSONException {
42+
public static Person fromJSON(JSONObject json, String blogId, int localTableBlogId) throws JSONException {
4343
if (json == null) {
4444
return null;
4545
}
@@ -55,7 +55,7 @@ public static Person fromJSON(JSONObject json, String siteID, int localTableBlog
5555
// We don't support multiple roles, so the first role is picked just as it's in Calypso
5656
String role = json.getJSONArray("roles").optString(0);
5757

58-
return new Person(personID, siteID, localTableBlogId, username,
58+
return new Person(personID, blogId, localTableBlogId, username,
5959
firstName, lastName, displayName, avatarUrl, role);
6060
} catch (NumberFormatException e) {
6161
AppLog.e(AppLog.T.PEOPLE, "The ID parsed from the JSON couldn't be converted to long: " + e);
@@ -68,8 +68,8 @@ public long getPersonID() {
6868
return personID;
6969
}
7070

71-
public String getSiteID() {
72-
return siteID;
71+
public String getBlogId() {
72+
return blogId;
7373
}
7474

7575
public int getLocalTableBlogId() {

WordPress/src/main/java/org/wordpress/android/ui/people/utils/PeopleUtils.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
public class PeopleUtils {
1818

19-
public static void fetchUsers(final String siteID, final int localTableBlogId, final FetchUsersCallback callback) {
19+
public static void fetchUsers(final String blogId, final int localTableBlogId, final FetchUsersCallback callback) {
2020
com.wordpress.rest.RestRequest.Listener listener = new RestRequest.Listener() {
2121
@Override
2222
public void onResponse(JSONObject jsonObject) {
2323
if (jsonObject != null && callback != null) {
2424
try {
2525
JSONArray jsonArray = jsonObject.getJSONArray("users");
26-
List<Person> people = peopleListFromJSON(jsonArray, siteID, localTableBlogId);
26+
List<Person> people = peopleListFromJSON(jsonArray, blogId, localTableBlogId);
2727
callback.onSuccess(people);
2828
}
2929
catch (JSONException e) {
@@ -44,18 +44,18 @@ public void onErrorResponse(VolleyError volleyError) {
4444
}
4545
};
4646

47-
String path = String.format("sites/%s/users", siteID);
47+
String path = String.format("sites/%s/users", blogId);
4848
WordPress.getRestClientUtilsV1_1().get(path, listener, errorListener);
4949
}
5050

51-
public static void updateRole(final String siteID, String userID, String newRole, final int localTableBlogId,
51+
public static void updateRole(final String blogId, String userID, String newRole, final int localTableBlogId,
5252
final UpdateUserCallback callback) {
5353
com.wordpress.rest.RestRequest.Listener listener = new RestRequest.Listener() {
5454
@Override
5555
public void onResponse(JSONObject jsonObject) {
5656
if (jsonObject != null && callback != null) {
5757
try {
58-
Person person = Person.fromJSON(jsonObject, siteID, localTableBlogId);
58+
Person person = Person.fromJSON(jsonObject, blogId, localTableBlogId);
5959
if (person != null) {
6060
callback.onSuccess(person);
6161
} else {
@@ -85,7 +85,7 @@ public void onErrorResponse(VolleyError volleyError) {
8585
roles.put(newRole);
8686
jsonObject.put("roles", roles);
8787

88-
String path = String.format("sites/%s/users/%s", siteID, userID);
88+
String path = String.format("sites/%s/users/%s", blogId, userID);
8989
WordPress.getRestClientUtilsV1_1().post(path, jsonObject, null, listener, errorListener);
9090
} catch (JSONException e) {
9191
if (callback != null) {
@@ -94,7 +94,7 @@ public void onErrorResponse(VolleyError volleyError) {
9494
}
9595
}
9696

97-
private static List<Person> peopleListFromJSON(JSONArray jsonArray, String siteID, int localTableBlogId)
97+
private static List<Person> peopleListFromJSON(JSONArray jsonArray, String blogId, int localTableBlogId)
9898
throws JSONException {
9999
if (jsonArray == null) {
100100
return null;
@@ -103,7 +103,7 @@ private static List<Person> peopleListFromJSON(JSONArray jsonArray, String siteI
103103
ArrayList<Person> peopleList = new ArrayList<>(jsonArray.length());
104104

105105
for (int i = 0; i < jsonArray.length(); i++) {
106-
Person person = Person.fromJSON(jsonArray.optJSONObject(i), siteID, localTableBlogId);
106+
Person person = Person.fromJSON(jsonArray.optJSONObject(i), blogId, localTableBlogId);
107107
if (person != null) {
108108
peopleList.add(person);
109109
}

0 commit comments

Comments
 (0)