<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">anyone have any thoughts on this?<br><div><div>On Jan 15, 2014, at 3:31 PM, Lucas Holmquist <<a href="mailto:lholmqui@redhat.com">lholmqui@redhat.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">well, i've hacked something together for js here in this branch: <a href="https://github.com/lholmquist/aerogear-js/tree/AGJS-124">https://github.com/lholmquist/aerogear-js/tree/AGJS-124</a><div><br></div><div>it is in no way complete, just some idea's.</div><div><br></div><div>to run the tests here, you need to have dan's server running.</div><div><br></div><div>i'm currently trying out <a href="https://github.com/benjamine/JsonDiffPatch">https://github.com/benjamine/JsonDiffPatch</a> to do the diff/patching during an update conflict, </div><div><br></div><div>Here is a quick and dirty API that i was thinking could be a start, for JS at least</div><div><br></div><div><pre class="line-pre" style="font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 16px; width: 1246px; margin-top: 0px; margin-bottom: 0px; padding: 0px; background-color: rgb(255, 255, 255); position: static; z-index: auto; "><div class="line" id="file-gistfile1-js-LC1"><span class="c1" style="color: rgb(153, 153, 136); font-style: italic;">// Create a New Data Sync Object</span></div><div class="line" id="file-gistfile1-js-LC2"> </div><div class="line" id="file-gistfile1-js-LC3"><span class="kd" style="font-weight: bold;">var</span> <span class="nx">dataSync</span> <span class="o" style="font-weight: bold;">=</span> <span class="nx">AeroGear</span><span class="p">.</span><span class="nx">DataSync</span><span class="p">(</span> <span class="p">{</span> <span class="nx">syncServerUrl</span><span class="o" style="font-weight: bold;">:</span> <span class="s2" style="color: rgb(221, 17, 68);">"<a href="http://localhost:8080/">http://localhost:8080</a>"</span> <span class="p">}</span> <span class="p">);</span></div><div class="line" id="file-gistfile1-js-LC4"> </div><div class="line" id="file-gistfile1-js-LC5"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;">/* possibly more options here, like "auto-merge"</span></div><div class="line" id="file-gistfile1-js-LC6"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> options = {</span></div><div class="line" id="file-gistfile1-js-LC7"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> syncServerUrl: "link_to_sync_server",</span></div><div class="line" id="file-gistfile1-js-LC8"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> autoMerge: false, //optional, defaults to false? Not sure this is the right spot for this, maybe should be in the update call</span></div><div class="line" id="file-gistfile1-js-LC9"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> otheroptions: ....</span></div><div class="line" id="file-gistfile1-js-LC10"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> }</span></div><div class="line" id="file-gistfile1-js-LC11"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;">*/</span></div><div class="line" id="file-gistfile1-js-LC12"> </div><div class="line" id="file-gistfile1-js-LC13"><span class="c1" style="color: rgb(153, 153, 136); font-style: italic;">// Probably have 3 Methods: read, save( Update ), remove</span></div><div class="line" id="file-gistfile1-js-LC14"><span class="c1" style="color: rgb(153, 153, 136); font-style: italic;">// each one has 2 parameters, the "document" and the settings</span></div><div class="line" id="file-gistfile1-js-LC15"> </div><div class="line" id="file-gistfile1-js-LC16"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;">/*</span></div><div class="line" id="file-gistfile1-js-LC17"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> The document here is an object defined like in qmx's sync thought dump</span></div><div class="line" id="file-gistfile1-js-LC18"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> var document = {</span></div><div class="line" id="file-gistfile1-js-LC19"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> id: "123sjf2-i",</span></div><div class="line" id="file-gistfile1-js-LC20"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> content: {</span></div><div class="line" id="file-gistfile1-js-LC21"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> // Some Arbitrary JSON or an array or something serializable into JSON</span></div><div class="line" id="file-gistfile1-js-LC22"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> },</span></div><div class="line" id="file-gistfile1-js-LC23"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> rev: "SOME_REVISION_ID" // or rev_id or revision or revision_id, we can argue over names later</span></div><div class="line" id="file-gistfile1-js-LC24"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> }</span></div><div class="line" id="file-gistfile1-js-LC25"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;">*/</span></div><div class="line" id="file-gistfile1-js-LC26"> </div><div class="line" id="file-gistfile1-js-LC27"><span class="nx">dataSync</span><span class="p">.</span><span class="nx">read</span><span class="p">(</span> <span class="nb" style="color: rgb(0, 134, 179);">document</span><span class="p">,</span> <span class="nx">settings</span> <span class="p">);</span></div><div class="line" id="file-gistfile1-js-LC28"> </div><div class="line" id="file-gistfile1-js-LC29"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;">/*</span></div><div class="line" id="file-gistfile1-js-LC30"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> --READ--</span></div><div class="line" id="file-gistfile1-js-LC31"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> </span></div><div class="line" id="file-gistfile1-js-LC32"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> var settings = {</span></div><div class="line" id="file-gistfile1-js-LC33"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> success: function( document ){}, // GET the document</span></div><div class="line" id="file-gistfile1-js-LC34"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> error: function( error ){} // an error happened GETting the document, like it can't be found or something</span></div><div class="line" id="file-gistfile1-js-LC35"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> }</span></div><div class="line" id="file-gistfile1-js-LC36"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;">*/</span></div><div class="line" id="file-gistfile1-js-LC37"> </div><div class="line" id="file-gistfile1-js-LC38"><span class="nx">dataSync</span><span class="p">.</span><span class="nx">save</span><span class="p">(</span> <span class="nb" style="color: rgb(0, 134, 179);">document</span><span class="p">,</span> <span class="nx">settings</span> <span class="p">);</span></div><div class="line" id="file-gistfile1-js-LC39"> </div><div class="line" id="file-gistfile1-js-LC40"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;">/*</span></div><div class="line" id="file-gistfile1-js-LC41"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> --Save--</span></div><div class="line" id="file-gistfile1-js-LC42"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> document can be either an array or an object</span></div><div class="line" id="file-gistfile1-js-LC43"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> if whatever is passed is in the form of the document specifed above, then save works as an "update"</span></div><div class="line" id="file-gistfile1-js-LC44"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> var settings: {</span></div><div class="line" id="file-gistfile1-js-LC45"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> autoMerge: // not sure if this should be here or in the constructor</span></div><div class="line" id="file-gistfile1-js-LC46"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> success: function( document ){} // successful PUT to create the document or update the document,</span></div><div class="line" id="file-gistfile1-js-LC47"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> conflict: function( error, current_model_from_server, delta_of_current_server_model_and_local_document ) // this delta thing should be nice and user friendly or something</span></div><div class="line" id="file-gistfile1-js-LC48"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> SOME_OTHER_SPECIFIC_CALLBACK: function(){}, // Maybe other callbacks for specific events</span></div><div class="line" id="file-gistfile1-js-LC49"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> error: function( error ){} // an error happened, catch-all ?</span></div><div class="line" id="file-gistfile1-js-LC50"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> }</span></div><div class="line" id="file-gistfile1-js-LC51"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;">*/</span></div><div class="line" id="file-gistfile1-js-LC52"> </div><div class="line" id="file-gistfile1-js-LC53"><span class="nx">dataSync</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span> <span class="nb" style="color: rgb(0, 134, 179);">document</span><span class="p">,</span> <span class="nx">settings</span> <span class="p">);</span></div><div class="line" id="file-gistfile1-js-LC54"> </div><div class="line" id="file-gistfile1-js-LC55"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;">/*</span></div><div class="line" id="file-gistfile1-js-LC56"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;"> TBD</span></div><div class="line" id="file-gistfile1-js-LC57"><span class="cm" style="color: rgb(153, 153, 136); font-style: italic;">*/</span></div></pre><div><br></div></div><div><br></div><div> <br><div><div>On Jan 13, 2014, at 11:56 AM, Matthias Wessendorf <<a href="mailto:matzew@apache.org">matzew@apache.org</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>Hi,<br></div><div><br></div><div>based on the <a href="http://ag.org/">ag.org</a> "sync-branch" (see [1]), I created a SIMPLE first iOS hack of a "document" API with a HTTP client that talks to Dan's Server. </div>
<div><br></div><div>The model ([2]) is quite easy/simple and the HTTP client supports CREATE/READ/REMOVE ([3]), based on the protocol defined on the README of the server.</div><div><br></div><div>The usage is covered in a test (like [4]).</div>
<div><br></div><div>Next: I guess next (if we continue using Dan's Server) is to see how this project can we weaved into the exisiting stores - but first I really wanted to get some client (like Luke's JS client) which executes against our current server draft/implementation.</div>
<div><br></div><div>BTW. the lib is based on AFN2.x (not sure we should use AFN 2.x at THIS point - switching to 1.x should not be that hard)</div><div><br></div><div>-Matthias</div><div><br></div><div>[1] <a href="https://github.com/aerogear/aerogear.org/pull/230">https://github.com/aerogear/aerogear.org/pull/230</a></div>
<div>[2] <a href="https://github.com/matzew/AGSyncKit/blob/master/SyncKit/AGDocument.h">https://github.com/matzew/AGSyncKit/blob/master/SyncKit/AGDocument.h</a></div><div>[3] <a href="https://github.com/matzew/AGSyncKit/blob/master/SyncKit/AGSyncClient.h">https://github.com/matzew/AGSyncKit/blob/master/SyncKit/AGSyncClient.h</a></div>
<div>[4] <a href="https://github.com/matzew/AGSyncKit/blob/master/SyncKitTests/SyncKitTests.m#L37-L61">https://github.com/matzew/AGSyncKit/blob/master/SyncKitTests/SyncKitTests.m#L37-L61</a></div><div><br></div>-- <br>Matthias Wessendorf <br>
<br>blog: <a href="http://matthiaswessendorf.wordpress.com/" target="_blank">http://matthiaswessendorf.wordpress.com/</a><br>sessions: <a href="http://www.slideshare.net/mwessendorf" target="_blank">http://www.slideshare.net/mwessendorf</a><br>
twitter: <a href="http://twitter.com/mwessendorf" target="_blank">http://twitter.com/mwessendorf</a>
</div>
_______________________________________________<br>aerogear-dev mailing list<br><a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></blockquote></div><br></div></div>_______________________________________________<br>aerogear-dev mailing list<br><a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>https://lists.jboss.org/mailman/listinfo/aerogear-dev</blockquote></div><br></body></html>