Announcement Announcement Module
Collapse
No announcement yet.
How do I express this in my entities? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I express this in my entities?

    Hi guys,
    I'm starting a new app and of course I want to use Roo for it. So just two quick questions for my entities:

    How do I express a dictionary? In my case, I want a translatable text, so I've done this:

    Code:
    entity --class ~.data.entities.WrittenLanguage
    field string --fieldName name
    
    entity --class ~.data.entities.TranslateableText
    field other --type java.util.HashMap<WrittenLanguage, String> --fieldName text
    This is wrong, but how should I express a dictionary correctly?



    The second question is that I want to have a set of permissions, so I define the following:

    Code:
    enum type --class ~.data.enums.Permission
    enum constant --name UPDATE_ELEMENT
    enum constant --name DELETE_ELEMENT
    enum constant --name CREATE_ELEMENT
    enum constant --name ADD_USER
    enum constant --name BAN_USER
    
    entity --class ~.data.entities.Person --extends Super
    field string --fieldName username
    field string --fieldName password
    field string --fieldName email
    field string --fieldName name
    field set --fieldName permissions --element ~.data.enums.Permission
    Roo is shocked that I even dare think this and quickly says: "The field set command is only applicable to JPA @Entity elements" I disagree, there are ways of expressing this, such as AND'ing the enums together and expressing it as an Integer or something. What is the correct way of doing this with Roo?

    Cheers

    Nik

  • #2
    The "field" commands don't accept parameterised maps. You'll need to edit the .java file by hand to add the map.

    Re the enum question, you create them with "enum type". Then to add the field to your entity you need to use the "field enum" command. See the clinic.roo sample for an example.

    Comment


    • #3
      Thanks a lot, Ben, I'll be sure to edit my map. I was just under the impression that I should use Roo to set up that type so that I could easily regenerate the entity setup afterwards, but I don't have much of a reason to regenerate, so this is fine. :-)

      With regards to the Enum, "field enum" gives me a single enum, right? What I would like is a set of enums so that a user can have multiple non-overlapping permissions.

      Cheers

      Nik

      Comment

      Working...
      X