Re: [google-appengine] Re: Java GAE/GWT Composite Design Pattern example with Persistence

2011-05-07 Thread Ravi Sharma
What do u want to optimize in Query...
It will be a simple query...
first time when you load you run query like select * from table where
parentid==null/0/or even remove where clause

then when user click on any node on UI tree then u make RPC call to bring
its child.. and load them to tree

and if you really want to bring whole data in one trip in ur admin panel...
then bring everything as simple list of objects...
and for each object create a node and add to tree as par parent key







On Sat, May 7, 2011 at 7:30 PM, RH richkh...@gmail.com wrote:

 h, I think you're right.

 Any ideas on how to optimize the datastore query for a sub branch of
 the tree?

 With this approach I either need to

 a) bring in all items in the app (possibly filtered by owner) across
 the RPC boundary and then structure them in the GWT client
 b) continue to look for child nodes in the tree via parentkey, until
 no children remain (will require a query on each node for the
 children).

 I was hoping to avoid a long, drawn out query...

 RH

 On May 4, 2:37 am, Ravi Sharma ping2r...@gmail.com wrote:
  I will advise you to use unowned relation in this scnerio. Instead of
  Directory entity having childrens...i will put parent information in the
  Directory entity.. this way you can make sure one Directiry can have
  millions of Child directory...as you will not max out the maximum entity
  size.
 
  class Directory {
 public String name;
 public ArrayListDirectory children = new
  ArrayListDirectory();//Delete this
 public Key parentKey;
 
 // could have any other properties or attributes here as well
 Directory(String n){
name = n;
 
 public void Display() {
 System.out.println( name:  + name);
 for(Directory d : children)
 Display();
 }
 
  }
 
  You can write one GWT RPC function like this
  Directory[] getMyChildren(String parentKeyParam){
  //On the server you can query like this
  Select * from Directory where parentKey = parentKeyParam
  and return it back to GWT.
 
 
 
 
 
 
 
  }
  On Wed, May 4, 2011 at 3:47 AM, RH richkh...@gmail.com wrote:
   here would be an example using the heap:
 
   class Directory {
  public String name;
  public ArrayListDirectory children = new
 ArrayListDirectory();
 
  // could have any other properties or attributes here as well
  Directory(String n){
 name = n;
 
  public void Display() {
  System.out.println( name:  + name);
  for(Directory d : children)
  Display();
  }
   }
 
   You should be able to add or remove any object in the tree:
 
   ...
 directoryObject.children.Add(new Directory(new child));
   ...
 
   and you can display the node and any child nodes:
 
   ...
 
   directoryObject.Display();
 
   I want to use the GAE datastore to persist these POJOs (easy enough in
   JDO) but also maintain their structural relationship to each other
   (hard, at least that I can see) - That is, I am trying to persist the
   object instances *and* their relations to each other.
 
   RH
 
   On May 2, 11:37 am, Todd Vierling t...@duh.org wrote:
On Saturday, April 30, 2011 9:06:45 PM UTC-4, RH wrote:
 
 I'm looking for a simple way to persist a set of dynamic Composite
 Design Pattern objects (as described in Design Patterns by Gamma,
 Helm, Johnson, and Vlissides) with either Google's native
 datastore,
 JDO, or JPA, as well as send to and from the client via RPC.
 
Design patterns mean pretty much zero in real-world discussions, so
   example
code would be a lot more helpful. (Or in other words, what does the
   class
you're trying to persist look like?)
 
   --
   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.

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



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



Re: [google-appengine] Re: Java GAE/GWT Composite Design Pattern example with Persistence

2011-05-07 Thread Brandon Donnelson
Good point. One way I do it is walk down the tree with individual rpc calls 
like Ravi said. I try not to take to much data unless its need through rpc.

Brandon
http://gwt-examples.googlecode.com

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



Re: [google-appengine] Re: Java GAE/GWT Composite Design Pattern example with Persistence

2011-05-04 Thread Ravi Sharma
I will advise you to use unowned relation in this scnerio. Instead of
Directory entity having childrens...i will put parent information in the
Directory entity.. this way you can make sure one Directiry can have
millions of Child directory...as you will not max out the maximum entity
size.

class Directory {
   public String name;
   public ArrayListDirectory children = new
ArrayListDirectory();//Delete this
   public Key parentKey;

   // could have any other properties or attributes here as well
   Directory(String n){
  name = n;

   public void Display() {
   System.out.println( name:  + name);
   for(Directory d : children)
   Display();
   }
}


You can write one GWT RPC function like this
Directory[] getMyChildren(String parentKeyParam){
//On the server you can query like this
Select * from Directory where parentKey = parentKeyParam
and return it back to GWT.
}


On Wed, May 4, 2011 at 3:47 AM, RH richkh...@gmail.com wrote:

 here would be an example using the heap:

 class Directory {
public String name;
public ArrayListDirectory children = new ArrayListDirectory();

// could have any other properties or attributes here as well
Directory(String n){
   name = n;

public void Display() {
System.out.println( name:  + name);
for(Directory d : children)
Display();
}
 }

 You should be able to add or remove any object in the tree:

 ...
   directoryObject.children.Add(new Directory(new child));
 ...

 and you can display the node and any child nodes:

 ...

 directoryObject.Display();

 I want to use the GAE datastore to persist these POJOs (easy enough in
 JDO) but also maintain their structural relationship to each other
 (hard, at least that I can see) - That is, I am trying to persist the
 object instances *and* their relations to each other.

 RH



 On May 2, 11:37 am, Todd Vierling t...@duh.org wrote:
  On Saturday, April 30, 2011 9:06:45 PM UTC-4, RH wrote:
 
   I'm looking for a simple way to persist a set of dynamic Composite
   Design Pattern objects (as described in Design Patterns by Gamma,
   Helm, Johnson, and Vlissides) with either Google's native datastore,
   JDO, or JPA, as well as send to and from the client via RPC.
 
  Design patterns mean pretty much zero in real-world discussions, so
 example
  code would be a lot more helpful. (Or in other words, what does the
 class
  you're trying to persist look like?)

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



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