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

2013-08-09 Thread Vinny P
On Fri, Aug 9, 2013 at 2:28 PM, VB  wrote:

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


If the code is being automatically generated by App Engine's endpoint
services, then it's good.

I wonder if your client is successfully pushing the messages to the server;
do you see any requests recorded in GAE's server logs? You can also try
installing appstats (
https://developers.google.com/appengine/docs/java/tools/appstats ), it
records all calls to the datastore so you can see if any entities are being
stored.


-
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

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


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

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

2013-08-06 Thread Vinny P
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 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());
>  }
> }
>



Well, that looks like Android + Endpoints client code, so there's nothing
to debug in regards to the datastore. What code are you using server-side
to interact with the datastore?


-
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

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




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

2013-08-06 Thread Lekh Raj
Hi Vinny,

Thanks for your reply.
Yes I am trying to save a Note entity into the datastore by the below code.
I am not able to see any error when I click on the send button.

Is there any other way to debug this and identify what might be going wrong?

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());
 }
}

On Wednesday, August 7, 2013 8:19:24 AM UTC+5:30, Vinny P wrote:
>
> On Tue, Aug 6, 2013 at 5:03 AM, VB wrote:
>
>> 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?
>>
>  
>  
>  
>  Sometimes that error appears when the datastore viewer is having 
> difficulty accessing your entities. Just try accessing it again after a few 
> minutes. 
>  
> However, most of the time that message simply means that there aren't any 
> entities saved in your datastore. Do you have anything saved within your 
> datastore?
>   
>  
> -
> -Vinny P
> Technology & Media Advisor
> Chicago, IL
>
> App Engine Code Samples: http://www.learntogoogleit.com
>   
>  
>
>

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




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

2013-08-06 Thread Vinny P
 On Tue, Aug 6, 2013 at 5:03 AM, VB  wrote:

> 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?
>



 Sometimes that error appears when the datastore viewer is having
difficulty accessing your entities. Just try accessing it again after a few
minutes.

However, most of the time that message simply means that there aren't any
entities saved in your datastore. Do you have anything saved within your
datastore?


-
-Vinny P
Technology & Media Advisor
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com

-- 
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] 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.