Android Open Source - spotastop Rest Api






From Project

Back to project page spotastop.

License

The source code is released under:

MIT License

If you think the Android project spotastop listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package rest;
/*from ww  w  . j a v  a  2s .com*/
import java.util.ArrayList;

import requests.Criteria;
import requests.EditorRequest;
import requests.Link;
import requests.LinkerRequest;
import requests.LoaderRequest;
import requests.StorerRequest;
import resources.Resource;
import responses.AsyncCallback;
import responses.beContentResponse;
import settings.Settings;

public class RestApi {

  /**
   * Returns all the instances of the resource classified with
   * resourceClassifier and identified as resourceIdentifier
   * 
   * @param resourceClassifier
   * @param resourceIdentifier
   * @return
   */
  public static ArrayList<Resource> requestResource(
      String resourceClassifier, long resourceIdentifier) {

    Criteria requestResourceCriteria = new Criteria();

    requestResourceCriteria.addConstraint("resClass", resourceClassifier);

    requestResourceCriteria.addConstraint("resId",
        String.valueOf(resourceIdentifier));

    LoaderRequest request = new LoaderRequest(requestResourceCriteria, null,null);

    beContentResponse response = request.doSync();

    return response.getResources();
  }

  /**
   * 
   * @param resources
   * @param callback
   */
  public static void storeResourcesAsync(ArrayList<Resource> resources,
      AsyncCallback callback) {
    if (resources.size() > 0) {
      StorerRequest request = new StorerRequest(null, resources,null);
      request.doAsync(callback);
    }
  }

  /**
   * 
   * @param resources
   */
  public static void storeResources(ArrayList<Resource> resources) {
    if (resources.size() > 0) {
      StorerRequest request = new StorerRequest(null, resources,null);
      request.doSync();
    }
  }
  
  /**
   * 
   * @param resources
   * @param callback
   */
  public static void editResourcesAsync(ArrayList<Resource> resources,ArrayList<Link> links,
      AsyncCallback callback) {
    if (resources.size() > 0) {
      EditorRequest request = new EditorRequest(null, resources,links);
      request.doAsync(callback);
    }
  }

  /**
   * 
   * @param resources
   */
  public static void editResources(ArrayList<Resource> resources,ArrayList<Link> links) {
    if (resources.size() > 0) {
      EditorRequest request = new EditorRequest(null, resources,links);
      request.doSync();
    }
  }

  /**
   * 
   * @param masterResource
   * @param slaveResource
   * @param linkProperty
   * @param callback
   */
  public static void linkResourcesAsync(Resource masterResource,
      Resource slaveResource, String linkProperty, AsyncCallback callback) {
    
    Link link=new Link(masterResource, slaveResource, linkProperty);
    ArrayList<Link> links=new ArrayList<Link>();
    links.add(link);
    LinkerRequest req=new LinkerRequest(null,null, links);
    req.doAsync(callback);
  }

  /**
   * 
   * @param masterResource
   * @param slaveResource
   * @param linkProperty
   */
  public static void linkResources(Resource masterResource,
      Resource slaveResource, String linkProperty) {
    Link link=new Link(masterResource, slaveResource, linkProperty);
    ArrayList<Link> links=new ArrayList<Link>();
    links.add(link);
    LinkerRequest req=new LinkerRequest(null,null, links);
    req.doSync();
  }

  /**
   * 
   * @param masterResource
   * @param slaveResource
   * @param linkProperty
   * @param callback
   */
  public static void unlinkResourcesAsync(Resource masterResource,
      Resource slaveResource, String linkProperty, AsyncCallback callback) {

  }

  /**
   * 
   * @param masterResource
   * @param slaveResource
   * @param linkProperty
   */
  public static void unlinkResources(Resource masterResource,
      Resource slaveResource, String linkProperty) {
  }

  /**
   * 
   * @param criteria
   * @param callback
   * @return
   */
  public static ArrayList<Resource> queryResourcesAsync(Criteria criteria,
      AsyncCallback callback) {
    ArrayList<Resource> results = null;
    return results;
  }

  /**
   * 
   * @param criteria
   * @return
   */
  public static ArrayList<Resource> queryResources(Criteria criteria) {
    ArrayList<Resource> results = null;

    LoaderRequest request = new LoaderRequest(criteria,null,null);

    beContentResponse response = request.doSync();

    return response.getResources();
  }

  /**
   * Returns the actually used serverUrl
   * 
   * @return
   */
  public static String getServerUrl() {
    return Settings.getServerUrl();
  }

  /**
   * Allows to configure the actual serverUrl of all requests
   * 
   * @param serverUrl
   */
  public static void setServerUrl(String serverUrl) {
    Settings.setServerUrl(serverUrl);
  }
}




Java Source Code List

.LoaderTester.java
com.cipciop.spotastop.ErrorActivity.java
com.cipciop.spotastop.LoginActivity.java
com.cipciop.spotastop.RegisterActivity.java
com.cipciop.spotastop.SelectBusLine.java
com.cipciop.spotastop.SpotActivity.java
com.cipciop.spotastop.StopSpotApp.java
com.cipciop.spotastop.domain.BusStop.java
com.cipciop.spotastop.domain.GeoPos.java
com.cipciop.spotastop.domain.Line.java
com.cipciop.spotastop.domain.User.java
com.cipciop.spotastop.presentation.BusLineItem.java
com.cipciop.spotastop.services.JarvisDynDnsService.java
com.cipciop.spotastop.services.LoginService.java
com.cipciop.spotastop.services.RegistrationService.java
com.cipciop.spotastop.services.RetrieveLinesListService.java
com.cipciop.spotastop.services.SpotBusStopService.java
com.nicfix.gsoncompatibility.GsonConfigurator.java
requests.CreatorRequest.java
requests.Criteria.java
requests.Data.java
requests.EditorRequest.java
requests.Link.java
requests.LinkerRequest.java
requests.LoaderRequest.java
requests.StorerRequest.java
requests.Unlink.java
requests.beContentRequest.java
resources.Resource.java
resources.ResourcesCache.java
resources.ResourcesMapper.java
responses.AsyncCallback.java
responses.beContentResponse.java
rest.RestApi.java
settings.Settings.java