Skip to content

Instantly share code, notes, and snippets.

View rominirani's full-sized avatar

Romin Irani rominirani

  • Mumbai
View GitHub Profile
package com.mindstorm.famousquotesandroid;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
package com.mindstorm.famousquotesandroid;
import java.io.IOException;
import java.util.List;
import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.json.gson.GsonFactory;
import com.mindstorm.famousquotes.entity.quoteendpoint.Quoteendpoint;
import com.mindstorm.famousquotes.entity.quoteendpoint.model.CollectionResponseQuote;
import com.mindstorm.famousquotes.entity.quoteendpoint.model.Quote;
package com.mindstorm.famousquotes.entity;
import com.mindstorm.famousquotes.entity.PMF;
import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.ApiNamespace;
import com.google.api.server.spi.response.CollectionResponse;
import com.google.appengine.api.datastore.Cursor;
import com.google.appengine.datanucleus.query.JDOCursorHelper;
package com.mindstorm.famousquotes.entity;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Quote {
package com.mindstorm.famousquotes.service;
import java.util.ArrayList;
import java.util.List;
import com.google.api.server.spi.config.Api;
import com.google.api.server.spi.config.ApiMethod;
import com.google.api.server.spi.config.Named;
import com.google.api.server.spi.response.NotFoundException;
import com.mindstorm.famousquotes.entity.Quote;
package com.mindstorm.famousquotes.service;
import java.util.ArrayList;
import java.util.List;
import com.mindstorm.famousquotes.entity.Quote;
public class QuoteService {
public static List<Quote> quotes = new ArrayList<Quote>();
package com.mindstorm.famousquotes.entity;
public class Quote {
Integer id;
String author;
String message;
public Quote() {
}
/**
* This Java Servlet is the main interaction gateway for the UI. It is primarily invoked from the contacts.jsp page to
* search for Contacts. This Servlet interacts primarily with the App Engine Search API to handle the documents within the Index.
*
* It also functions as a REST API
* - /contactsdirectoryindexservice -> This will retrieve the documents in the index
* - /contactsdirectoryindexservice?searchText=SOME_VALUE -> This will retrieve the documents in the index that match the search term
*
* The API will provide JSON formatted responses
*/
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page isELIgnored="false" %>
<%
String searchText = null;
//Read the searchText Request Parameter
if (request.getParameter("searchText") != null) {
searchText = (String) request.getParameter("searchText");
System.out.println("Search Text : " + searchText);
/**
* This class handles all the interaction with Google AppEngine Search API.
* Currently, it has methods for:
* 1. Index a document i.e. add a document to the existing index
* 2. Retrieve a Document from the Index, provided its Document Id (In our case it is the user id)
* 3. Remove a Document from the Index, provided its Document Id
* 4. Retrieve a List of Documents from the Index that match the Search Term.
*/
package com.mindstorm.employeesdirectory.search;