Ejemplo n.º 1
0
  public String upsertTheRemoteDBWithGet(WCHectare hectare) {

    //		upsert/{databaseName}/{id}/{nodeId}/{parcelId}/{status}/{transactionTime}
    //		Calendar.getInstance().getTime()
    //		upsert/farm3/6/1/1/0/2013-09-15%2019:26:12

    resource =
        client.resource(
            WebServicePaths.upsertHectare
                + UserConstants.getSessionUser().getFarm()
                + hectare.getId()
                + "/"
                + hectare.getNodeID()
                + "/"
                + hectare.getParcelID()
                + "/"
                + hectare.getStatus()
                + "/"
                + DateConverter.now().replace(" ", "%20"));

    String webServiceHectareResult = resource.get(String.class);

    System.out.println(webServiceHectareResult);

    return "nice";
  }
Ejemplo n.º 2
0
  public WCHectare getHectareById(int id) {

    resource =
        client.resource(
            WebServicePaths.getHectareById + UserConstants.getSessionUser().getFarm() + id);
    WebServiceHectare webServiceHectare = resource.get(WebServiceHectare.class);

    return (WCHectare) ObjectConverter.convertWebObjectToNormalObject(webServiceHectare);
  }
Ejemplo n.º 3
0
  public String upsertTheRemoteDB(WCHectare hectare) {

    WebServiceHectare webServiceHectare =
        (WebServiceHectare) ObjectConverter.convertNormalObjectToWebObject(hectare);
    resource =
        client.resource(WebServicePaths.upsertHectare + UserConstants.getSessionUser().getFarm());
    clientResponse =
        resource.type(MediaType.APPLICATION_XML).post(ClientResponse.class, webServiceHectare);

    return "success";
  }
Ejemplo n.º 4
0
  public List<WCHectare> getAllHectares() {

    List<WCHectare> hectares = new ArrayList<WCHectare>();

    resource =
        client.resource(WebServicePaths.getHectares + UserConstants.getSessionUser().getFarm());
    WebServiceHectare[] hectareArray = resource.get(WebServiceHectare[].class);

    List<WebServiceHectare> hectareList = Arrays.asList(hectareArray);

    WCHectare hectare = new WCHectare();
    for (WebServiceHectare webServiceHectare : hectareList) {

      hectare = (WCHectare) ObjectConverter.convertWebObjectToNormalObject(webServiceHectare);
      hectares.add(hectare);
    }

    return hectares;
  }