On client-side use AccountInfo instead of Account

AccountInfo is the client side representation of a user; Account is
the entity class for persisting a user.

The AccountInfo is now fetched via REST. As result the account
information in HostPageData is no longer used, and hence it is
removed.

Using AccountInfo instead of Account allows us in a next step to
remove some of the remaining old RPC's and replace them with REST
calls.

Change-Id: I20d72f62beec0e6a65cf792f67be04262be6fdb5
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2015-07-28 11:33:45 +02:00
parent cf77a6955d
commit 7c87d0f929
15 changed files with 113 additions and 72 deletions

View File

@@ -14,15 +14,52 @@
package com.google.gerrit.client.info;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwtjsonrpc.client.impl.ser.JavaSqlTimestamp_JsonSerializer;
import java.sql.Timestamp;
public class AccountInfo extends JavaScriptObject {
public final Account.Id getId() {
return new Account.Id(_accountId());
}
public final native int _accountId() /*-{ return this._account_id || 0; }-*/;
public final native String name() /*-{ return this.name; }-*/;
public final native String email() /*-{ return this.email; }-*/;
public final native String username() /*-{ return this.username; }-*/;
public final Timestamp registeredOn() {
Timestamp ts = _getRegisteredOn();
if (ts == null) {
ts = JavaSqlTimestamp_JsonSerializer.parseTimestamp(registeredOnRaw());
_setRegisteredOn(ts);
}
return ts;
}
private final native String registeredOnRaw() /*-{ return this.registered_on; }-*/;
private final native Timestamp _getRegisteredOn() /*-{ return this._cts; }-*/;
private final native void _setRegisteredOn(Timestamp ts) /*-{ this._cts = ts; }-*/;
public final Timestamp contactFiledOn() {
if (contactFiledOnRaw() != null) {
Timestamp ts = _getContactFiledOn();
if (ts == null) {
ts = JavaSqlTimestamp_JsonSerializer.parseTimestamp(contactFiledOnRaw());
_setContactFiledOn(ts);
}
return ts;
}
return null;
}
private final native String contactFiledOnRaw() /*-{ return this.contact_filed_on; }-*/;
private final native Timestamp _getContactFiledOn() /*-{ return this._cts; }-*/;
private final native void _setContactFiledOn(Timestamp ts) /*-{ this._cts = ts; }-*/;
/**
* @return true if the server supplied avatar information about this account.
* The information may be an empty list, indicating no avatars are
@@ -46,6 +83,10 @@ public class AccountInfo extends JavaScriptObject {
private final native JsArray<AvatarInfo> avatars()
/*-{ return this.avatars }-*/;
public final native void name(String n) /*-{ this.name = n }-*/;
public final native void email(String e) /*-{ this.email = e }-*/;
public final native void username(String n) /*-{ this.username = n }-*/;
public static native AccountInfo create(int id, String name,
String email, String username) /*-{
return {'_account_id': id, 'name': name, 'email': email,