Skip to content

Instantly share code, notes, and snippets.

View secondsun's full-sized avatar
🎩
Happy Saturday!

Hoyt Summers Pittman secondsun

🎩
Happy Saturday!
View GitHub Profile
@secondsun
secondsun / gist:4078711
Created November 15, 2012 13:40 — forked from mstruk/gist:4074544
PipeConfig Ergonomics

Currently, when creating a new PipeConfig we use a constructor and specify a rootUrl:

    URL rootUrl = new URL("http://todo-aerogear.rhcloud.com/todo-server");

    Pipeline pipeline = new Pipeline(rootUrl);
    PipeConfig config = new PipeConfig(rootUrl, Project.class);

    Pipe<Project> projects = pipeline.pipe(Project.class, config);

In Main.java

Pipeline pipeline = new Pipeline(baseEarl);
PipeConfig<Data> config = new PipeConfig<>(Data.class); //config.baseUrl is null
Pipe<Data> pipe = pipeline(config);

In Pipeline.java

package net.saga.android.orienttests;
import net.saga.android.orienttests.vo.Person;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import com.orientechnologies.orient.object.db.OObjectDatabaseTx;
import java.util.List;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
@secondsun
secondsun / Pipe.java
Created January 11, 2013 16:13
A brainstorm for fetching MetaData results for paging from a Pipe
public interface Pipe<T> {
//snip
/**
* These methods MUST add a result to a Map so that a paging context can be looked up
*/
public List<T> read();
public List<T> readWithFilter(ReadFilter filter);

Client Paging

This document describes the client side interfaces which a developer can use to Query and Page through data obtained from remote rest services. This document describes both how to interact with the Aerogear-Controller based paging as well how to extend the libraries and APIs to support most other restful services. It is currently Java centric, but this should be fixed up in the future.

At a high level, Paging and Querying is supported though the Pipe.readWithFilter(ReadFilter, Callback) method. A ReadFilter object will set the current page, number of results perPage, and a where property. The Pipe implementation will be responsible for processing a request along with any paging data and sending the appropriate headers, data, and query parameters to the server. Once the response has been received, the Pipe implementation will provide a List of objects to the supplied callback. If this call used paging, the List will be an instance of PagedList.

PagedList will be a List of results f

Below is a comparison of the method usage proposed by each lib for handling paged resources.

Read Next Page

Android

ReadFilter filter = new ReadFilter();
filter.setLimit(5);

AbstractPageRequestHandler.java

abstact class AbstractPageRequestHandler() {
    public List<Pair<String, String>>  getPagingHeaders(ReadFilter filter){
       List<Pair<String, String>> toReturn = new ArrayList<>();
       return toReturn;
    }
    
    public byte[] appendToBody(ReadFilter filter, byte[] body){
 return body;
#!/bin/bash
#
# Derived from -
# Joshua Davis
# http://shrubbery.mynetgear.net/c/display/W/Java+Daemon+Startup+Script
#
# This is a modification of the original script (which lets you run a java program as a deamon.
# look bellow for more information) that lets you run a groovy script as a deamon.
#
# ============== OLD SCRIPT TEXT ==============
public class MyApplication extends Application {
public Registrar registrar;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Registrar r = new Registrar(PUSH_REGISTRATION_URL);
PushConfig config = new PushConfig(GCM_APP_ID);
config.setMobileVariantId(AG_PUSH_VARIANT_ID);
r.register(getApplicationContext(), config, new Callback<Void>() {

M1 - Basic revision Control, Data Model, Change Management, Server <->

Client Contract

  • We seem to be in agreement on a basic set of metadata to be kept for each object. [objectId, revision, object].
  • We should have a basic server definition which supports CRUD and keeps our revision numbers in check. This may not be a server product but just a spec that can be implemented by anything at this point.
  • We should have basic client code which keeps up with revisions, can check the server for new revisions, and alert the user if there is a