Hi,
I am using the book created by Mr. Shai as a base to carry out my development and I clarify that I do not know anything about Spring Boot, JPA, Jersey, etc. I am trying to login but I have encountered a problem that for many will be trivial.
On the server I have an entity that represents the users with the following information:
@Entity
public class Usuario {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "usr_usuario_id")
private Long usuarioId;
@Column(name = "usr_usuario")
private String usuario;
@Column(name = "usr_correo")
private String correo;
@Column(name = "usr_contrasena")
private String contrasena;
@Column(name = "usr_nombre")
private String nombre;
@Column(unique=true, name = "usr_token")
private String token;
@JoinColumn(name = "usr_dispositivo_id", referencedColumnName = "dis_dispositivo_id")
@ManyToOne
private Dispositivo dispositivoId;
// Getting and Setting
}
In the client, create the class with the information of the user that implements the PropertyBusinessObject API:
public class Usuario implements PropertyBusinessObject {
public final LongProperty<Usuario> usuarioId = new LongProperty<>("usuarioId");
public final Property<String, Usuario> usuario = new Property<>("usuario");
public final Property<String, Usuario> correo = new Property<>("correo");
public final Property<String, Usuario> contrasena = new Property<>("contrasena");
public final Property<String, Usuario> nombre = new Property<>("nombre");
public final Property<String, Usuario> token = new Property<>("token");
// public final LongProperty<Usuario> dispositivo = new LongProperty<>("dispositivoId");
private final PropertyIndex idx = new PropertyIndex(this, "Usuario", usuarioId, usuario, nombre,
correo, contrasena, dispositivo, tipo, token, estado);
@Override
public PropertyIndex getPropertyIndex() {
return idx;
}
The code to do the login in the client is the following:
public static void login(String usr, String contrasena, final SuccessCallback<Usuario> onSuccess, final FailureCallback<Object> onError) {
Rest.get(SERVER_URL + "usuario/login").
acceptJson().
queryParam("contrasena", contrasena).
queryParam("usr", usr).
getAsJsonMapAsync(new Callback<Response<Map>>() {
@Override
public void onSucess(Response<Map> value) {
me = new Usuario();
me.getPropertyIndex().populateFromMap(value.getResponseData());
Preferences.set("token", me.token.get());
PreferencesObject.create(me).bind();
onSuccess.onSucess(me);
}
@Override
public void onError(Object sender, Throwable err, int errorCode, String errorMessage) {
onError.onError(null, err, errorCode, errorMessage);
}
});
}
The returned value contains the information of the "User" and the information of the "Devices". How do I receive the information of the "Devices" ?.