Re: [google-appengine] Not Able to view my entities in DataStore

2013-08-09 Thread VB
Hi Vinny,

thanks again for your reply.
well my understanding is that the code written in Noteendpoint.java (that 
was automatically generated from the Note.java on selecting Create 
Endpoint) is actually doing the writing part to the datastore.

Below is the code for the Noteendpoint.java that was generated.
As seen in the my code inside the EndpointsTask class, it invokes 
Noteendpoint.insertNote (highlighted in Bold below) to do the insertion of 
Note into the datastore.

package com.cloudnotes;

import com.cloudnotes.EMF;

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.JPACursorHelper;

import java.util.List;

import javax.annotation.Nullable;
import javax.inject.Named;
import javax.persistence.EntityExistsException;
import javax.persistence.EntityNotFoundException;
import javax.persistence.EntityManager;
import javax.persistence.Query;

@Api(name = "noteendpoint", namespace = @ApiNamespace(ownerDomain = 
"cloudnotes.com", ownerName = "cloudnotes.com", packagePath = ""))
public class NoteEndpoint {

/**
 * This method lists all the entities inserted in datastore.
 * It uses HTTP GET method and paging support.
 *
 * @return A CollectionResponse class containing the list of all entities
 * persisted and a cursor to the next page.
 */
@SuppressWarnings({ "unchecked", "unused" })
@ApiMethod(name = "listNote")
public CollectionResponse listNote(
@Nullable @Named("cursor") String cursorString,
@Nullable @Named("limit") Integer limit) {

EntityManager mgr = null;
Cursor cursor = null;
List execute = null;

try {
mgr = getEntityManager();
Query query = mgr.createQuery("select from Note as Note");
if (cursorString != null && cursorString != "") {
cursor = Cursor.fromWebSafeString(cursorString);
query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
}

if (limit != null) {
query.setFirstResult(0);
query.setMaxResults(limit);
}

execute = (List) query.getResultList();
cursor = JPACursorHelper.getCursor(execute);
if (cursor != null)
cursorString = cursor.toWebSafeString();

// Tight loop for fetching all entities from datastore and accomodate
// for lazy fetch.
for (Note obj : execute)
;
} finally {
mgr.close();
}

return CollectionResponse. builder().setItems(execute)
.setNextPageToken(cursorString).build();
}

/**
 * This method gets the entity having primary key id. It uses HTTP GET 
method.
 *
 * @param id the primary key of the java bean.
 * @return The entity with primary key id.
 */
@ApiMethod(name = "getNote")
public Note getNote(@Named("id") String id) {
EntityManager mgr = getEntityManager();
Note note = null;
try {
note = mgr.find(Note.class, id);
} finally {
mgr.close();
}
return note;
}

*/***
* * This inserts a new entity into App Engine datastore. If the entity 
already*
* * exists in the datastore, an exception is thrown.*
* * It uses HTTP POST method.*
* **
* * @param note the entity to be inserted.*
* * @return The inserted entity.*
* */*
* @ApiMethod(name = "insertNote")*
* public Note insertNote(Note note) {*
* System.out.println("inserting note - "+note);*
* EntityManager mgr = getEntityManager();*
* try {*
* if (containsNote(note)) {*
* throw new EntityExistsException("Object already exists");*
* }*
* mgr.persist(note);*
* } finally {*
* mgr.close();*
* }*
* return note;*
* }*

/**
 * This method is used for updating an existing entity. If the entity does 
not
 * exist in the datastore, an exception is thrown.
 * It uses HTTP PUT method.
 *
 * @param note the entity to be updated.
 * @return The updated entity.
 */
@ApiMethod(name = "updateNote")
public Note updateNote(Note note) {
EntityManager mgr = getEntityManager();
try {
if (!containsNote(note)) {
throw new EntityNotFoundException("Object does not exist");
}
mgr.persist(note);
} finally {
mgr.close();
}
return note;
}

/**
 * This method removes the entity with primary key id.
 * It uses HTTP DELETE method.
 *
 * @param id the primary key of the entity to be deleted.
 */
@ApiMethod(name = "removeNote")
public void removeNote(@Named("id") String id) {
EntityManager mgr = getEntityManager();
try {
Note note = mgr.find(Note.class, id);
mgr.remove(note);
} finally {
mgr.close();
}
}

private boolean containsNote(Note note) {
EntityManager mgr = getEntityManager();
boolean contains = true;
try {
Note item = mgr.find(Note.class, note.getId());
if (item == null) {
contains = false;
}
} finally {
mgr.close();
}
return contains;
}

private static EntityManager getEntityManager() {
return EMF.get().createEntityManager();
}

}




On Wednesday, August 7, 2013 12:06:40 PM UTC+5:30, Vinny P wrote:
>
> On Wed, Aug 7, 2013 at 12:13 AM, Lekh Raj 
> > wrote:
>
>> Is there any other way to debug this and identify what might be going 
>> wrong?
>>
>> public void sendMsg(View view) {
>>  EditText ms

[google-appengine] Not Able to view my entities in DataStore

2013-08-06 Thread VB
Hi - I followed the article (
https://developers.google.com/eclipse/docs/endpoints-testdeploy) to:
1. Create a simple Note entity.
2. Then as explained I generated the endpoint.
3. Then I generated the cloud endpoint library.
4. Then I created an Application cloudnotes2013vip and then using Eclipse I 
deployed the app to App-Engine.

Application is deployed successfully.

Then in my main activity I have simply created a EditText & a Send button. 
I am trying to see if I enter some message and click on Send button whether 
the msg gets stored in the DataStore.

I am using Emulator and I have set target to Google API 18.

When I click on send i don't see any error message, but I am able to see 
the entity I tried to add in the DataStore Viewer.

When I click on DataStore Viewer it says -

Oops! We couldn't retrieve your list of Kinds.
Please Try again.

Can someone throw some light as to what wrong is happening here?

Below is the piece of code in my MainActivity - 



package com.cloudnotes;

import java.io.IOException;
import java.util.Date;

import android.app.Activity;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

import com.cloudnotes.noteendpoint.Noteendpoint;
import com.cloudnotes.noteendpoint.model.Note;
import com.google.api.client.extensions.android.http.AndroidHttp;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.json.jackson.JacksonFactory;

public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

  //new EndpointsTask().execute(getApplicationContext());
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

public void sendMsg(View view) {
EditText msgTxt = (EditText) findViewById(R.id.editText1);
String msg = msgTxt.getText().toString();
System.out.println("Note to be inserted - " + msg);

if (msg.length() > 0){
new EndpointsTask().execute(getApplicationContext());
}
}

public class EndpointsTask extends AsyncTask {
protected Long doInBackground(Context... contexts) {
System.out.println("Entered doInBackground");
  Noteendpoint.Builder endpointBuilder = new Noteendpoint.Builder(
  AndroidHttp.newCompatibleTransport(),
  new JacksonFactory(),
  new HttpRequestInitializer() {
  public void initialize(HttpRequest httpRequest) { }
  });
  Noteendpoint endpoint = CloudEndpointUtils.updateBuilder(
  endpointBuilder).build();
  try {
  Note note = new Note().setDescription("Note Description");
  String noteID = new Date().toString();
  note.setId(noteID);

  note.setEmailAddress("E-Mail Address");  
  Note result = endpoint.insertNote(note).execute();
  System.out.println("Entered doInBackground:result - "+result);
  } catch (IOException e) {
e.printStackTrace();
  }
  return (long) 0;
}
}
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.




[google-appengine] Google Cloud Messaging for Android subpackag - Is it Deprecated ?

2013-08-06 Thread VB
Hi,

I am trying to a simple Android app that can save few text values to the 
DataStore and then read from it.
While searching on internet I found the below link for Android Mobile 
Backend Starter -
https://developers.google.com/cloud/samples/mbs/getting_started

Here they have given a sample Android app that shows how to do so.
In the requirements section it is mentioned that we need to deploy the 
below package from Extras -
- the *Extras* package, particularly the *Google Cloud Messaging for Android
* subpackage

But when I launch my SDK Manager from Eclipse it shows that this subpackage 
has been Deprecated.
So are we suppose to use this or not. Is there anything else that we can 
use.

Because my project it not compiling without this.
It fails in the below import statements for example. I am assuming this 
must be in that above subpackage.
import com.google.cloud.backend.android.mobilebackend.Mobilebackend;
import com.google.cloud.backend.android.mobilebackend.model.EntityDto;
import com.google.cloud.backend.android.mobilebackend.model.EntityListDto;
import com.google.cloud.backend.android.mobilebackend.model.QueryDto;


Can someone throw more light on this. Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/groups/opt_out.




[google-appengine] Form support on a PDA/Smart Phone

2009-01-27 Thread vb

Hi,

Is it possible to access an application created in AppEngine through
PDA/Smart Phones.
Is there any support for certain versions of Smart Phones.

Thanks & Regards,
Vignesh.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~--~~~~--~~--~--~---