Laurent Weichberger

Laurent Weichberger

New York, New York, United States
10K followers 500+ connections

Articles by Laurent

Projects

  • Couchbase Mobile Application with Android and Couchbase Lite SDK

    I am going through and making sure all the lab exercises work for CD257 Developing Couchbase Mobile NoSQL Applications. So far so good. I wrote my first Android android.app.Activity:

    /* Much code not shown. This is the constructor code for Android Activity don't use the normal ctor */
    public void onCreate (Bundle savedInstanceState) {

    super.onCreate(savedInstanceState); //because we are supposed to...
    try…

    I am going through and making sure all the lab exercises work for CD257 Developing Couchbase Mobile NoSQL Applications. So far so good. I wrote my first Android android.app.Activity:

    /* Much code not shown. This is the constructor code for Android Activity don't use the normal ctor */
    public void onCreate (Bundle savedInstanceState) {

    super.onCreate(savedInstanceState); //because we are supposed to...
    try {
    setContentView(R.layout.activity_main); 
    Manager manager = this.getManagerInstance(); //Refactored with Singleton
    Database db = this.getDatabaseInstance(); //Refactored with Singleton
    /* Event constructor:
    * String name, String address, String description, String date,
    * String time, String eventType
    */
    Event myEvent = new Event ("Big Baba Gathering", 
    "88 Grove St., New York, NY 10014",
    "Come one, come all!",
    "15 November 1931",
    "7 pm (EST)",
    "Spiritual, Darshan"
    );

    myEvent.setUrl("http://www.lordmeher.org/rev/index.jsp?" +
    "pageBase=page.jsp&nextPage=1312");

    EventRepository eventRepo = new EventRepository(db);

    Event savedEvent = eventRepo.save(myEvent);

    String docId = savedEvent.get_id();
    boolean itExists = eventRepo.exists(docId);
    Event foundEvent = eventRepo.getById(docId);
    if (foundEvent != null) {
    Log.v("Test EventRepository getById() FOUND: ", foundEvent.getName());
    }
    else {
    Log.v("Test EventRepository getById() Document ID NOT FOUND: " + docId, "ERROR");
    }

    foundEvent.setName("Pacific Northwest Gathering"); //different
    foundEvent.setAddress("Ashland, Oregon"); //different
    foundEvent.setDate("31 January 2015"); //different
    foundEvent.setDescription("Closed Circle"); //different
    Event updatedEvent = eventRepo.update(foundEvent);
    boolean wasDeleted = eventRepo.delete(foundEvent);
    boolean itStillExists = eventRepo.exists(docId);

    }

    Other creators
    See project
  • CD220 Developing Couchbase NoSQL Applications with Couchbase Server 2.5 and Java SDK 1.4

    /* All code by Laurent Weichberger: laurent@couchbase.com */
    package com.couchbase.training.playlist.domain;

    /* imports not shown */

    public class PlayListRepositoryImpl implements PlayListRepository {

    private Gson gson = null;
    private CouchbaseClient client = null;
    private String bucketName = null;

    public PlayListRepositoryImpl(){

    bucketName = "CouchMusic";

    String bucketPassword = "Baba";

    client =…

    /* All code by Laurent Weichberger: laurent@couchbase.com */
    package com.couchbase.training.playlist.domain;

    /* imports not shown */

    public class PlayListRepositoryImpl implements PlayListRepository {

    private Gson gson = null;
    private CouchbaseClient client = null;
    private String bucketName = null;

    public PlayListRepositoryImpl(){

    bucketName = "CouchMusic";

    String bucketPassword = "Baba";

    client = CouchbaseClientFactory.getInstance(bucketName, bucketPassword);

    gson = new Gson();

    }

    private CouchbaseClient getClient(){

    return client;
    }

    @Override
    public <S extends PlayList> S update(S playlist) {

    String key = playlist.getPlayListId();

    String jplay = gson.toJson(playlist);

    OperationFuture<Boolean> wasUpdated = this.getClient().replace(key, jplay);
    try {

    if (!wasUpdated.get().booleanValue()) {

    playlist = null;

    }
    }
    catch (ExecutionException ee) {

    playlist = null;
    ee.printStackTrace();


    }catch (InterruptedException ie) {

    playlist = null;
    ie.printStackTrace();
    }

    return playlist;
    }


    @Override
    public PlayList findOne(String key) {

    PlayList onePlayList = null;
    String jsonPlayList = null;

    try{
    /* This is the MemcachedClient get() method we inherit which returns:
    * the result from the cache (null if there is none) */

    Object obj = getClient().get(key);

    if (obj != null) {

    jsonPlayList = (String) obj;
    }

    }
    catch (OperationTimeoutException e) {

    // if the global operation timeout is exceeded
    e.printStackTrace();
    }
    catch (IllegalStateException e) {

    //in the rare circumstance where queue is too full to accept any more requests
    e.printStackTrace();
    }

    onePlayList = gson.fromJson(jsonPlayList, PlayList.class);

    return onePlayList;

    }

    /*much code not shown */
    }

    See project
  • Cassandra with DataStax DSE :: DAO implementations in Java

    -

    I wrote Java code and a series of blog articles on how to create a Data Access Object (DAO) for Cassandra using DataStax DSE Driver code, culminating in the Working with Cassandra BLOBs article.

  • CassandraDAO

    -

    A small sample Java application implementing the Data Access Object pattern with a sample entity service and a materialized view for Apache Cassandra:

    package com.datastax.training;

    import com.datastax.driver.core.*;
    import java.util.UUID;

    public class PlaylistDAO extends CassandraDAO {

    PlaylistDAO(Session session){

    super(session);
    }
    PlaylistDAO(){

    super();

    }

    public void createTable(){

    String tableCQL =…

    A small sample Java application implementing the Data Access Object pattern with a sample entity service and a materialized view for Apache Cassandra:

    package com.datastax.training;

    import com.datastax.driver.core.*;
    import java.util.UUID;

    public class PlaylistDAO extends CassandraDAO {

    PlaylistDAO(Session session){

    super(session);
    }
    PlaylistDAO(){

    super();

    }

    public void createTable(){

    String tableCQL = "CREATE TABLE audiofile (audioid uuid PRIMARY KEY, artist text, album text, track_title text, " +
    "genre text, language text, track_length int, track_num int, year int, rating int, cover_art blob, audio_actual blob);";

    Query cqlQuery = new SimpleStatement(tableCQL);

    session.execute(tableCQL);

    }
    public void createMaterializedView(){

    String tableCQL = "CREATE TABLE audioByArtist (audioid uuid, artist text, album text, track_title text, " +
    "genre text, language text, track_length int, track_num int, year int, rating int, PRIMARY KEY(artist, audioid));";

    Query cqlQuery = new SimpleStatement(tableCQL);

    session.execute(tableCQL);
    }

    See project

Recommendations received

132 people have recommended Laurent

Join now to view

View Laurent’s full profile

  • See who you know in common
  • Get introduced
  • Contact Laurent directly
Join to view full profile

Other similar profiles

Explore top content on LinkedIn

Find curated posts and insights for relevant topics all in one place.

View top content

Add new skills with these courses