Package com.chap.links.client.DataConnector

Examples of com.chap.links.client.DataConnector.Response


    }
   
    @Override
    public void getItems(int index, int num,
        final AsyncCallback<Response> callback) {
      final Response response = Response.create();
      response.setTotalItems(trucks.size());
     
      // append the requested trucks
      for (int i = 0; i < Math.min(num, trucks.size()); i++) {
        Truck truck = trucks.get(index + i);
        response.addItem(truck.toJSON().getJavaScriptObject());
      }
     
      callback.onSuccess(response);
    }
View Full Code Here


    }

    @Override
    public void getChanges(int index, int num, JavaScriptObject items, 
        AsyncCallback<Response> callback) {
      Response response = Response.create();
      response.setTotalItems(this.trucks.size());

      JSONArray array = new JSONArray(items);
      for (int i = 0; i < array.size(); i++) {
        Truck truck = trucks.get(index + i);

        Truck checkTruck = null;
        JSONValue value = array.get(i);
        JSONObject item = null;
        if (value != null) {
          item = value.isObject();
        }
        if (item != null) {
          checkTruck = new Truck(item);
        }
       
        if (truck != null && checkTruck != null &&
            !checkTruck._uuid.equals(truck._uuid)) {
          // truck found and at the same index.
          // Check the update sequence
          if (truck._updateSeq > checkTruck._updateSeq) {
            // the checkTruck is outdated
            response.addItem(checkTruck.toJSON().getJavaScriptObject());
          }
        }
        else {
          // truck not found. Apperently removed.
          if (checkTruck != null) {
            response.addItem(checkTruck.toJSON().getJavaScriptObject());
          }
        }
      }
     
      callback.onSuccess(response);
View Full Code Here

TOP

Related Classes of com.chap.links.client.DataConnector.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.