SlideShare ist ein Scribd-Unternehmen logo
1 von 49
CouchDB on Android
about
Sven Haiges, hybris GmbH
  Twitter @hansamann

    Android, HTML5,
    Groovy & Grails


 sven.haiges@hybris.de
about
Sven Haiges, hybris GmbH
  Twitter @hansamann

    Android, HTML5,
    Groovy & Grails


 sven.haiges@hybris.de
CouchDB
Erlang on
                                     Android!
Source: http://couchdb.apache.org/
sync
CouchDB
• document-based, RESTful HTTP API
• replication built-in
• both database and web server
• no locks, uses multi-version concurrency
  control
• Map & Reduce Functions = Views
CouchDB on Android
<host>/_utils = Futon Admin
Mobile Futon
CouchDB on Android
Accessing
your couch
adb forward tcp:5999 tcp:33595
CouchDB on Android
CouchDB on Android
build your own
#1 new android
    project
CouchDB on Android
#2 add couchbase.zip
http://www.couchbase.org/get/couchbase-mobile-for-
                 android/current
CouchDB on Android
#3 run as Ant file
CouchDB on Android
done...
AndroidManifest.xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
	   package="de.flavor.relax" android:versionCode="1" android:versionName="1.0">
	   <uses-sdk android:minSdkVersion="10" />

	   <application android:icon="@drawable/icon" android:label="@string/app_name">
	   	   <activity android:name=".RelaxActivity" android:label="@string/app_name">
	   	   	    <intent-filter>
	   	   	    	   <action android:name="android.intent.action.MAIN" />
	   	   	    	   <category android:name="android.intent.category.LAUNCHER" />
	   	   	    </intent-filter>
	   	   </activity>

	   	    <service android:exported="false" android:enabled="true"
	   	    	   android:name="com.couchbase.android.CouchbaseService" />
	   </application>
	   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
	   <uses-permission android:name="android.permission.INTERNET" />
	   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
in your Activity...
private final ICouchbaseDelegate mDelegate = new ICouchbaseDelegate() {

     public void couchbaseStarted(String host, int port) {
     	
     Toast.makeText(RelaxActivity.this, host + ":" + port, Toast.LENGTH_LONG).show();
     }

     public void installing(int completed, int total) {
     	
     Log.d("demo", "Installing... " + completed + "/" + total);
     }

     public void exit(String error) {
     	
     Log.d("demo", error);
     }
};
in your Activity...

@Override
protected void onResume() {
	   super.onResume();
	   CouchbaseMobile couch = new CouchbaseMobile(getBaseContext(), mDelegate);
	   couchServiceConnection = couch.startCouchbase();
}
ektorp
AndCouch
AndCouch

• https://github.com/daleharvey/Android-
  MobileFuton
• Just a quick HTTP wrapper, but gets the job
  done!
• CouchDemo App...
CouchDB on Android
CouchDB on Android
CouchDB on Android
CouchDB on Android
CouchDB on Android
CouchDB on Android
CouchDB on Android
CouchDB on Android
Todo.java
public class Todo {
	
	   private String id;
	   private String rev;
	   private String text;
	   private long timestamp;
	
	   public Todo(String id, String rev, String text, long timestamp) {
	   	    super();
	   	    this.id = id;
	   	    this.rev = rev;
	   	    this.text = text;
	   	    this.timestamp = timestamp;
	   }
	   ...
}
Creating
String value = input.getText().toString();

JSONObject obj = new JSONObject();

try   {
	     obj.put("type", "todo");
	     obj.put("text", value);
	     obj.put("timestamp", new Date().getTime());

	     JSONObject result = AndCouch.put(baseURL
	     	   	    + DB_NAME + "/"
	     	   	    + UUID.randomUUID().toString(),
	     	   	    obj.toString()).json;

	   if (result.getBoolean("ok") == true)
	   	    refreshTodos();
} catch (JSONException e) {
	   e.printStackTrace();
}
Reading (all)
try {
	   todos.clear();

	   JSONObject json = AndCouch.get(baseURL + DB_NAME + "/_design/todo/_view/all").json;
	   JSONArray rows = json.getJSONArray("rows");

	   for   (int i = 0; i < rows.length(); i++) {
	   	     JSONObject todoObj = rows.getJSONObject(i);
	   	     JSONArray value = todoObj.getJSONArray("value");
	   	     todos.add(new Todo(todoObj.getString("id"), value.getString(1),
	   	     	    	   value.getString(0), todoObj.getLong("key")));
	   }

	   todos.notifyDataSetChanged();

} catch (JSONException e) {
	   e.printStackTrace();
}
Reading (all)
try {
	   todos.clear();

	   JSONObject json = AndCouch.get(baseURL + DB_NAME + "/_design/todo/_view/all").json;
	   JSONArray rows = json.getJSONArray("rows");

	   for   (int i = 0; i < rows.length(); i++) {
	   	     JSONObject todoObj = rows.getJSONObject(i);
	   	     JSONArray value = todoObj.getJSONArray("value");
	   	     todos.add(new Todo(todoObj.getString("id"), value.getString(1),
	   	     	    	   value.getString(0), todoObj.getLong("key")));
	   }

	   todos.notifyDataSetChanged();

} catch (JSONException e) {
	   e.printStackTrace();
}
Design Documents

• normal json documents, but ids begin with
  _design/, e.g. _design/myapp (no %2F :-)
• contain views (Map & Reduce functions) as
  well as other application functions
  (validation, show/list)
Simple Design Doc

{
	    "_id":"_design/todo",
	    "views" : {
	    	    "all" : {
	    	    	   "map": "function(doc) { if (doc.type && doc.type === 'todo')
{   emit(doc.timestamp, [doc.text, doc._rev]); }};"
	    	    }
	    }
}
Deleting
SparseBooleanArray spar = getListView().getCheckedItemPositions();

for   (int i = 0; i < todos.getCount(); i++) {
	     if (spar.get(i)) {
	     	    Todo todo = todos.getItem(i);
	     	    getListView().setItemChecked(i, false); 	

	   	    try {
	   	    	   AndCouch.httpRequest("DELETE", baseURL + DB_NAME + "/" + todo.getId() + "?
rev=" + todo.getRev(),
	   	    	   null, new String[][] {});
	   	    } catch (JSONException e) {
	   	    	   e.printStackTrace();
	   	    }
	   }
}

refreshTodos();
Remote Push
JSONObject obj = new JSONObject();

try   {
	     obj.put("create_target", true);
	     obj.put("source", baseURL + DB_NAME);
	     obj.put("target",
	     	   	    "http://	hansamann.iriscouch.com/todo");

	   JSONObject result = AndCouch.post(baseURL + "_replicate",
	   	    	   obj.toString()).json;
} catch (JSONException e) {
	   // TODO Auto-generated catch block
	   e.printStackTrace();
}
CouchApps
CouchApps
• JavaScript and HTML5 apps served from
  CouchDB
• No middle tier, Couch is DB + application
  server
• CouchApp.org hosts the CouchApp
  development tool that pushes changes to a
  Couch instance
about
Sven Haiges, hybris GmbH
  Twitter @hansamann

    Android, HTML5,
    Groovy & Grails


 sven.haiges@hybris.de
about
Sven Haiges, hybris GmbH
  Twitter @hansamann

    Android, HTML5,
    Groovy & Grails


 sven.haiges@hybris.de

                           NFC

Weitere ähnliche Inhalte

Was ist angesagt?

Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...MongoDB
 
はじめてのMongoDB
はじめてのMongoDBはじめてのMongoDB
はじめてのMongoDBTakahiro Inoue
 
20110514 mongo dbチューニング
20110514 mongo dbチューニング20110514 mongo dbチューニング
20110514 mongo dbチューニングYuichi Matsuo
 
NoSQL & MongoDB
NoSQL & MongoDBNoSQL & MongoDB
NoSQL & MongoDBShuai Liu
 
MongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your DataMongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your DataMongoDB
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMongoDB
 
MongoDB World 2016: Deciphering .explain() Output
MongoDB World 2016: Deciphering .explain() OutputMongoDB World 2016: Deciphering .explain() Output
MongoDB World 2016: Deciphering .explain() OutputMongoDB
 
神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)guregu
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETTomas Jansson
 
7주 JavaScript 실습
7주 JavaScript 실습7주 JavaScript 실습
7주 JavaScript 실습지수 윤
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Groupkchodorow
 
Getting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSGetting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSMongoDB
 
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram VaswaniHigh Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswanivvaswani
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! aleks-f
 
Mongoose and MongoDB 101
Mongoose and MongoDB 101Mongoose and MongoDB 101
Mongoose and MongoDB 101Will Button
 
Backbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserHoward Lewis Ship
 
Mongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsMongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsPallavi Srivastava
 

Was ist angesagt? (20)

Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
 
Indexing
IndexingIndexing
Indexing
 
はじめてのMongoDB
はじめてのMongoDBはじめてのMongoDB
はじめてのMongoDB
 
20110514 mongo dbチューニング
20110514 mongo dbチューニング20110514 mongo dbチューニング
20110514 mongo dbチューニング
 
NoSQL & MongoDB
NoSQL & MongoDBNoSQL & MongoDB
NoSQL & MongoDB
 
Elastic search 검색
Elastic search 검색Elastic search 검색
Elastic search 검색
 
MongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your DataMongoDB World 2018: Using Change Streams to Keep Up with Your Data
MongoDB World 2018: Using Change Streams to Keep Up with Your Data
 
Mythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDBMythbusting: Understanding How We Measure the Performance of MongoDB
Mythbusting: Understanding How We Measure the Performance of MongoDB
 
MongoDB World 2016: Deciphering .explain() Output
MongoDB World 2016: Deciphering .explain() OutputMongoDB World 2016: Deciphering .explain() Output
MongoDB World 2016: Deciphering .explain() Output
 
神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)神に近づくx/net/context (Finding God with x/net/context)
神に近づくx/net/context (Finding God with x/net/context)
 
Getting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NETGetting started with Elasticsearch and .NET
Getting started with Elasticsearch and .NET
 
7주 JavaScript 실습
7주 JavaScript 실습7주 JavaScript 실습
7주 JavaScript 실습
 
San Francisco Java User Group
San Francisco Java User GroupSan Francisco Java User Group
San Francisco Java User Group
 
Getting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJSGetting Started with MongoDB and NodeJS
Getting Started with MongoDB and NodeJS
 
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram VaswaniHigh Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
High Performance XQuery Processing in PHP with Zorba by Vikram Vaswani
 
MongoDB
MongoDBMongoDB
MongoDB
 
Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! Look Ma, “update DB to HTML5 using C++”, no hands! 
Look Ma, “update DB to HTML5 using C++”, no hands! 
 
Mongoose and MongoDB 101
Mongoose and MongoDB 101Mongoose and MongoDB 101
Mongoose and MongoDB 101
 
Backbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The BrowserBackbone.js: Run your Application Inside The Browser
Backbone.js: Run your Application Inside The Browser
 
Mongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node jsMongoose getting started-Mongo Db with Node js
Mongoose getting started-Mongo Db with Node js
 

Ähnlich wie CouchDB on Android

Paris js extensions
Paris js extensionsParis js extensions
Paris js extensionserwanl
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QAAlban Gérôme
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineRicardo Silva
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineAndy McKay
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology updateDoug Domeny
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomerzefhemel
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourPeter Friese
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajaxbaygross
 
mobl - model-driven engineering lecture
mobl - model-driven engineering lecturemobl - model-driven engineering lecture
mobl - model-driven engineering lecturezefhemel
 
Full Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLFull Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLAll Things Open
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Matthew Groves
 
API Days Paris - Automatic Testing of (RESTful) API Documentation
API Days Paris - Automatic Testing of (RESTful) API DocumentationAPI Days Paris - Automatic Testing of (RESTful) API Documentation
API Days Paris - Automatic Testing of (RESTful) API DocumentationRouven Weßling
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyHuiyi Yan
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCpootsbook
 
Mongo+java (1)
Mongo+java (1)Mongo+java (1)
Mongo+java (1)MongoDB
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 

Ähnlich wie CouchDB on Android (20)

Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
mobl
moblmobl
mobl
 
huhu
huhuhuhu
huhu
 
Spicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QASpicy javascript: Create your first Chrome extension for web analytics QA
Spicy javascript: Create your first Chrome extension for web analytics QA
 
Event-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 EngineEvent-driven IO server-side JavaScript environment based on V8 Engine
Event-driven IO server-side JavaScript environment based on V8 Engine
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
Html5 and web technology update
Html5 and web technology updateHtml5 and web technology update
Html5 and web technology update
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomer
 
CouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 HourCouchDB Mobile - From Couch to 5K in 1 Hour
CouchDB Mobile - From Couch to 5K in 1 Hour
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 
Week 4 - jQuery + Ajax
Week 4 - jQuery + AjaxWeek 4 - jQuery + Ajax
Week 4 - jQuery + Ajax
 
mobl - model-driven engineering lecture
mobl - model-driven engineering lecturemobl - model-driven engineering lecture
mobl - model-driven engineering lecture
 
Full Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQLFull Stack Development with Node.js and NoSQL
Full Stack Development with Node.js and NoSQL
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
API Days Paris - Automatic Testing of (RESTful) API Documentation
API Days Paris - Automatic Testing of (RESTful) API DocumentationAPI Days Paris - Automatic Testing of (RESTful) API Documentation
API Days Paris - Automatic Testing of (RESTful) API Documentation
 
jQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journeyjQuery Data Manipulate API - A source code dissecting journey
jQuery Data Manipulate API - A source code dissecting journey
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
Mongo+java (1)
Mongo+java (1)Mongo+java (1)
Mongo+java (1)
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 

Mehr von Sven Haiges

NFC and Commerce combined
NFC and Commerce combinedNFC and Commerce combined
NFC and Commerce combinedSven Haiges
 
End to End Realtime Communication using Mobiel Devices and the Web
End to End Realtime Communication using Mobiel Devices and the WebEnd to End Realtime Communication using Mobiel Devices and the Web
End to End Realtime Communication using Mobiel Devices and the WebSven Haiges
 
NFC Android Introduction
NFC Android IntroductionNFC Android Introduction
NFC Android IntroductionSven Haiges
 
Gesture-controlled web-apps
Gesture-controlled web-appsGesture-controlled web-apps
Gesture-controlled web-appsSven Haiges
 
NFC on Android - Near Field Communication
NFC on Android - Near Field CommunicationNFC on Android - Near Field Communication
NFC on Android - Near Field CommunicationSven Haiges
 
Grails @ Java User Group Silicon Valley
Grails @ Java User Group Silicon ValleyGrails @ Java User Group Silicon Valley
Grails @ Java User Group Silicon ValleySven Haiges
 
Grails 0.3-SNAPSHOT Presentation WJAX 2006 English
Grails 0.3-SNAPSHOT Presentation WJAX 2006 EnglishGrails 0.3-SNAPSHOT Presentation WJAX 2006 English
Grails 0.3-SNAPSHOT Presentation WJAX 2006 EnglishSven Haiges
 
Grails 0.3-SNAPSHOT Presentation WJAX 2006
Grails 0.3-SNAPSHOT Presentation WJAX 2006Grails 0.3-SNAPSHOT Presentation WJAX 2006
Grails 0.3-SNAPSHOT Presentation WJAX 2006Sven Haiges
 

Mehr von Sven Haiges (11)

NFC and Commerce combined
NFC and Commerce combinedNFC and Commerce combined
NFC and Commerce combined
 
End to End Realtime Communication using Mobiel Devices and the Web
End to End Realtime Communication using Mobiel Devices and the WebEnd to End Realtime Communication using Mobiel Devices and the Web
End to End Realtime Communication using Mobiel Devices and the Web
 
NFC Android Introduction
NFC Android IntroductionNFC Android Introduction
NFC Android Introduction
 
Gesture-controlled web-apps
Gesture-controlled web-appsGesture-controlled web-apps
Gesture-controlled web-apps
 
NFC on Android - Near Field Communication
NFC on Android - Near Field CommunicationNFC on Android - Near Field Communication
NFC on Android - Near Field Communication
 
Android UI
Android UIAndroid UI
Android UI
 
Html5
Html5Html5
Html5
 
Grails @ Java User Group Silicon Valley
Grails @ Java User Group Silicon ValleyGrails @ Java User Group Silicon Valley
Grails @ Java User Group Silicon Valley
 
Grails and Dojo
Grails and DojoGrails and Dojo
Grails and Dojo
 
Grails 0.3-SNAPSHOT Presentation WJAX 2006 English
Grails 0.3-SNAPSHOT Presentation WJAX 2006 EnglishGrails 0.3-SNAPSHOT Presentation WJAX 2006 English
Grails 0.3-SNAPSHOT Presentation WJAX 2006 English
 
Grails 0.3-SNAPSHOT Presentation WJAX 2006
Grails 0.3-SNAPSHOT Presentation WJAX 2006Grails 0.3-SNAPSHOT Presentation WJAX 2006
Grails 0.3-SNAPSHOT Presentation WJAX 2006
 

Kürzlich hochgeladen

UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemAsko Soukka
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.YounusS2
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1DianaGray10
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024D Cloud Solutions
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDELiveplex
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-pyJamie (Taka) Wang
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 

Kürzlich hochgeladen (20)

UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.Basic Building Blocks of Internet of Things.
Basic Building Blocks of Internet of Things.
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1Secure your environment with UiPath and CyberArk technologies - Session 1
Secure your environment with UiPath and CyberArk technologies - Session 1
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
201610817 - edge part1
201610817 - edge part1201610817 - edge part1
201610817 - edge part1
 
Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024Artificial Intelligence & SEO Trends for 2024
Artificial Intelligence & SEO Trends for 2024
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDEADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
ADOPTING WEB 3 FOR YOUR BUSINESS: A STEP-BY-STEP GUIDE
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
20230202 - Introduction to tis-py
20230202 - Introduction to tis-py20230202 - Introduction to tis-py
20230202 - Introduction to tis-py
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 

CouchDB on Android

  • 2. about Sven Haiges, hybris GmbH Twitter @hansamann Android, HTML5, Groovy & Grails sven.haiges@hybris.de
  • 3. about Sven Haiges, hybris GmbH Twitter @hansamann Android, HTML5, Groovy & Grails sven.haiges@hybris.de
  • 5. Erlang on Android! Source: http://couchdb.apache.org/
  • 7. CouchDB • document-based, RESTful HTTP API • replication built-in • both database and web server • no locks, uses multi-version concurrency control • Map & Reduce Functions = Views
  • 13. adb forward tcp:5999 tcp:33595
  • 17. #1 new android project
  • 21. #3 run as Ant file
  • 24. AndroidManifest.xml <?xml version="1.0" encoding="UTF-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.flavor.relax" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="10" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".RelaxActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <service android:exported="false" android:enabled="true" android:name="com.couchbase.android.CouchbaseService" /> </application> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> </manifest>
  • 25. in your Activity... private final ICouchbaseDelegate mDelegate = new ICouchbaseDelegate() { public void couchbaseStarted(String host, int port) { Toast.makeText(RelaxActivity.this, host + ":" + port, Toast.LENGTH_LONG).show(); } public void installing(int completed, int total) { Log.d("demo", "Installing... " + completed + "/" + total); } public void exit(String error) { Log.d("demo", error); } };
  • 26. in your Activity... @Override protected void onResume() { super.onResume(); CouchbaseMobile couch = new CouchbaseMobile(getBaseContext(), mDelegate); couchServiceConnection = couch.startCouchbase(); }
  • 29. AndCouch • https://github.com/daleharvey/Android- MobileFuton • Just a quick HTTP wrapper, but gets the job done! • CouchDemo App...
  • 38. Todo.java public class Todo { private String id; private String rev; private String text; private long timestamp; public Todo(String id, String rev, String text, long timestamp) { super(); this.id = id; this.rev = rev; this.text = text; this.timestamp = timestamp; } ... }
  • 39. Creating String value = input.getText().toString(); JSONObject obj = new JSONObject(); try { obj.put("type", "todo"); obj.put("text", value); obj.put("timestamp", new Date().getTime()); JSONObject result = AndCouch.put(baseURL + DB_NAME + "/" + UUID.randomUUID().toString(), obj.toString()).json; if (result.getBoolean("ok") == true) refreshTodos(); } catch (JSONException e) { e.printStackTrace(); }
  • 40. Reading (all) try { todos.clear(); JSONObject json = AndCouch.get(baseURL + DB_NAME + "/_design/todo/_view/all").json; JSONArray rows = json.getJSONArray("rows"); for (int i = 0; i < rows.length(); i++) { JSONObject todoObj = rows.getJSONObject(i); JSONArray value = todoObj.getJSONArray("value"); todos.add(new Todo(todoObj.getString("id"), value.getString(1), value.getString(0), todoObj.getLong("key"))); } todos.notifyDataSetChanged(); } catch (JSONException e) { e.printStackTrace(); }
  • 41. Reading (all) try { todos.clear(); JSONObject json = AndCouch.get(baseURL + DB_NAME + "/_design/todo/_view/all").json; JSONArray rows = json.getJSONArray("rows"); for (int i = 0; i < rows.length(); i++) { JSONObject todoObj = rows.getJSONObject(i); JSONArray value = todoObj.getJSONArray("value"); todos.add(new Todo(todoObj.getString("id"), value.getString(1), value.getString(0), todoObj.getLong("key"))); } todos.notifyDataSetChanged(); } catch (JSONException e) { e.printStackTrace(); }
  • 42. Design Documents • normal json documents, but ids begin with _design/, e.g. _design/myapp (no %2F :-) • contain views (Map & Reduce functions) as well as other application functions (validation, show/list)
  • 43. Simple Design Doc { "_id":"_design/todo", "views" : { "all" : { "map": "function(doc) { if (doc.type && doc.type === 'todo') { emit(doc.timestamp, [doc.text, doc._rev]); }};" } } }
  • 44. Deleting SparseBooleanArray spar = getListView().getCheckedItemPositions(); for (int i = 0; i < todos.getCount(); i++) { if (spar.get(i)) { Todo todo = todos.getItem(i); getListView().setItemChecked(i, false); try { AndCouch.httpRequest("DELETE", baseURL + DB_NAME + "/" + todo.getId() + "? rev=" + todo.getRev(), null, new String[][] {}); } catch (JSONException e) { e.printStackTrace(); } } } refreshTodos();
  • 45. Remote Push JSONObject obj = new JSONObject(); try { obj.put("create_target", true); obj.put("source", baseURL + DB_NAME); obj.put("target", "http:// hansamann.iriscouch.com/todo"); JSONObject result = AndCouch.post(baseURL + "_replicate", obj.toString()).json; } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); }
  • 47. CouchApps • JavaScript and HTML5 apps served from CouchDB • No middle tier, Couch is DB + application server • CouchApp.org hosts the CouchApp development tool that pushes changes to a Couch instance
  • 48. about Sven Haiges, hybris GmbH Twitter @hansamann Android, HTML5, Groovy & Grails sven.haiges@hybris.de
  • 49. about Sven Haiges, hybris GmbH Twitter @hansamann Android, HTML5, Groovy & Grails sven.haiges@hybris.de NFC

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n