working on batch bug

parent 70aee8d2
......@@ -179,6 +179,7 @@ public class RestapiWrapper {
sparams="";
for (String param : params.keySet()) {
String value = params.get(param);
Log.e(this.getClass().getCanonicalName(),param+"="+value+" total:"+sparams+" json?"+json_params);
if (param.equals("token"))
urlConnection.setRequestProperty("Authorization", "Bearer " + value);
else {
......@@ -249,7 +250,6 @@ public class RestapiWrapper {
// onPostExecute displays the results of the AsyncTask.
@Override
protected void onPostExecute(HttpAsyncTaskParams params) {
Log.i(this.getClass().getCanonicalName(),"PICTO END RESTAPI POSTEXE " +params.url+":"+params.url_params.toString());
try {
//if (params.e)
if(params.result!=null) {
......
......@@ -52,7 +52,7 @@ public abstract class Action {
jsonObject.put(param_id_sup,PCBcontext.getPcbdb().getCurrentUser().get_id_sup());
//TODO Decidir qué almacenar con DEVICE
//if (PCBcontext.getDevice().getDeviceID()!=null)
// jsonObject.put(param_id_dev, PCBcontext.getDevice().getDeviceID());
jsonObject.put(param_id_dev, "-1");
return jsonObject;
}catch(JSONException e) {
......
......@@ -53,10 +53,10 @@ public class ActionLog implements iRestapiListener {
String actions="";
for (JSONObject action: actions_buffer)
actions+=","+action.toString();
actions= "[" + actions.substring(1) + "]";
params.put("actions",actions);
actions= "{actions: [" + actions.substring(1) + "]}";
params.put("json",actions);
Log.i(this.getClass().getCanonicalName()," Sending batch actions: "+url+": "+actions);
PCBcontext.getRestapiWrapper().ask(url, params, "post", this);
PCBcontext.getRestapiWrapper().ask(url, params, "post", true, this);
}
}
......
......@@ -59,7 +59,7 @@ public class PictosAction extends Action {
return null;
}
}
public JSONObject get_json_picto(Picto picto) throws JSONException {
private JSONObject get_json_picto(Picto picto) throws JSONException {
final String param_id_json="id";
final String param_picto="picto";
final String param_attrs="attributes";
......
......@@ -50,14 +50,14 @@ public class Room {
return new JSONObject().put(action_param, action).put(attributes_param, attributes);
}
public void emit(String url, final Action action) {
Log.d(this.getClass().getName(), "Action: " + action.get_type() + " / Attributes emitted: " + action.get_json().toString());
Log.i(this.getClass().getName(), "Action: " + action.get_type() + " / Attributes emitted: " + action.get_json().toString());
try{
this.socket.emit(url, this.common_data(action.get_type(), action.get_json()), new Ack() {
@Override
public void call(Object... args) {
Log.i(this.getClass().getName(), "Ack");
for (Object arg : args)
Log.d(this.getClass().getName(), "Ack messsage:" + arg);
Log.i(this.getClass().getName(), "Ack messsage:" + arg);
}
});
} catch (JSONException e) {
......@@ -85,6 +85,7 @@ public class Room {
*/
public void reconnect() {
final String transport="polling";
if (this.socket!=null) this.socket.destroy();
this.socket=new SailsSocketsIO(PCBcontext.getRestapiWrapper().getServer(), transport, new Emitter.Listener() {
@Override
public void call(Object... args) {
......@@ -96,10 +97,8 @@ public class Room {
}, new Emitter.Listener() {
@Override
public void call(Object... args) {
Log.i(this.getClass().getName(), "Room exit: "+args[0]);
if (args.length>0 && args[0].toString().equals("transport error") ) {
inRoom=false;
}
Log.i(this.getClass().getName(), "Reconnect unsuccesful: "+args[0]);
inRoom=false;
}
});
}
......
......@@ -346,7 +346,6 @@ public class Picto extends Img {
try {
this.attributes.put(JSON_ATTTRS.PCB_STATUS_MODIFICATION, true);
PCBcontext.getPcbdb().modifyPicto(this.get_id(), this.get_json_attrs());
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ALTERATTRS, this));
} catch (JSONException e) {
e.printStackTrace();
Log.e(this.getClass().getCanonicalName(), e.getMessage());
......
......@@ -104,7 +104,11 @@ public class Vocabulary implements Iterable<Picto> {
Log.e(this.getClass().getName(), " Picto json error from local storage: " + e.getMessage());
}
for (Picto picto: this) {
if (picto.status_modified()) new PictoUploader(picto).uploadState();
if (picto.status_modified()) {
new PictoUploader(picto).uploadState();
Log.e(this.getClass().getCanonicalName(), "Picto status modified while offline. Picto: " +
picto.get_translation() + ":" + picto.get_id() + " Current status:" + picto.status_modified());
}
if (picto.get_id() < 0)
try {
new PictoUploader(picto).upload(); //id<0 iif it is a local id
......
......@@ -93,7 +93,7 @@ public class NetService implements Runnable {
PCBcontext.getActionLog().batch();
updated = true;
}
Log.i(this.getClass().getName(), "PCB status checked. Updated? " + updated+ " in room?"+PCBcontext.getRoom().inRoom());
Log.i(this.getClass().getName(), "PCB status checked. Updated? " + updated+ " in Room? "+PCBcontext.getRoom().inRoom());
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment