Hey,

I'm starting to do the real StreamFlow model, and some of the first 
parts involve the classical "contact has phone/email/address". My 
current approach is to do all of that in one value object on the Entity, 
meaning, in my Contact Entity state I will have:
    interface State
       extends PhoneState, EmailState, AddressState,...
    {
       @UseDefaults
       Property<String> name();
       ...
    }
with:
public interface PhoneState
{
    @UseDefaults
    Property<PhoneValue> phone();
}
which holds a list of phone numbers:
public interface PhoneValue
    extends ValueComposite
{
    @UseDefaults
    Property<List<ContactPhoneValue>> phoneNumbers();
}
each of which is defined as:
public interface ContactPhoneValue
         extends ValueComposite
{
    public enum ContactType
    {
       HOME, WORK, MOBILE, OTHER
    }

    @UseDefaults
    Property<ContactType> contactType();

    @UseDefaults
    Property<String> phoneNumber();
}
---
And that would be it. Rinse and repeat for email and address. With this 
approach I would for viewing get the root PhoneValue, and then to edit I 
would have to copy it (with the whole structure), and add/replace/remove 
a ContactPhoneValue, and then write it back using phone().set(newValue);

To get this to work there's a bunch of things that needs to be fixed:
* I have set @UseDefaults on a List Property. This would imply creating 
an empty ArrayList as default value.
* I have set @UseDefaults on an enum. This would imply setting it to the 
first value in the defined enum.
* EntityStores have to be able to store hierarchical ValueComposites
* Indexing/querying for all of it.

That should be it. Does this seem like a good way to do it? Viewing this 
structure should be straightforward, but I can see that we'd probably 
need some way to easily modify the values, or it's going to be rather 
tricky...

/Rickard

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to