Expand my Community achievements bar.

Are people using assemblers?

Avatar

Level 1
I've been working with flex for a couple of weeks now. The
application I'm writing is built on top of a EJB3 application.

I have number of entity beans in my system and they all have
relationships to each other. many-to-one, one-to-many, one-to one
etc.

Example:

class Group {

public int getId(){...}

public String getGroupName(){...}

public List<Member> getMember(){...}

......

}

class Member {

public int getId(){...}

public String getFirstname(){...}

public String getLastname(){...}

public String getUsername(){...}

public Group getGroup(){...}

}



In my EJB3 layer I have two session beans: GroupManager and
MemberManager.

The MemberManager looks like this:



interface MemberManager {

public Member getMember(int id);

public Member getMemberByUsername(String username);

public List<Member> getMembers();

public Member save(Member member);

public void delete(Member member);

....and a few more

}



Ther GroupManager looks similair

interface GroupManager {

public List<Group> getGroups();

public Group getGroup(id);

public void delete(Group group)

public Group save(Group group)

}



As far as I know there are two ways to write a flex
application for administrating my Groups and Members: RemoteObject
and Assemblers.



What I have read in the docs, assemblers is what I should use
for this kind of situations.

I would then write two assemblers: GroupAssembler and
MemberAssembler.



something like this:

class GroupAssembler extends AbstractAssembler {

GroupManager gm;

public List<Group> fill(List params) {

..

..

return aListOfGroups; (with or without it's containing
members?)

}



public Group getItem(Map idMap) {

id = idMap.get("id");

// ask the GroupManager for a group with the id read from
the idMap

return theGroup;

}



publiv void delete(....)

public Group createItem(....)

}



and the MemberAssembler would look soemthing like this:



class MemberAssembler {

List<Member> fill(...) {

....

...

return aListOfMembers

}



Member getItem(Map idMap) {

...

...

}

deleteItem(...)

createItem(...)

updateItem(..)...

}



Now, what about my MemberManager.getMemberByUsername().

In all examples I have seen and in all documentations I have
read I havn't found one single example describing this issue.

the AbstractAssembler's getItem(Map idMap) method is not
designed to let me implement that fuctionality.

Each assembler has ONE getItem() method and there is no way
for me to determine is the client asks for member by id or members
by username.



Have I missed something fundamental here? Is there a way to
have more than one getItem method or a way to implement the getItem
in a way so that it knows that the flex client is asking "by
username " or "by id"?



Another aproach to this problem to use RemoteObject instead
of assemblers but than I'd loose the other nice functionality

that I'd have to implement myself. Like
DataService.getItem(id, member) which instead of returning a new
instance of Member updates all properties of my member object.



I don't think my situation is unique and lots of other people
working with assemblers (if there are any) should have seen the
problem and hopefully solved it.



So my questions are: Is there a solution for my problem above
and are there any other people than me working with assemblers?



Regards

Jonathan
0 Replies