isis-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luis Parada <luisparadawag...@gmail.com>
Subject Re: Custom Value Types (VALUE OBJECTS) and the annotation @Value
Date Wed, 18 Sep 2013 12:26:52 GMT
Hi, I´m working on this with Ezequiel and we could persist the Contact VO.
The problem is that we can not show the object in the viewer because the
object is serialized. We found
the public interface EncoderDecoder<T> {} wich implements this method: T
fromEncodedString(String encodedString); so we appreciate any help
explaining us how to use it.

At this moment we have overrided the methods: protected String
doEncode(final Object object) and protected Contact doRestore(final String
data) of ContactoValueSemanticsProvider but is not working yet.

protected String doEncode(final Object object) {
final Contacto contacto = (Contacto) object;
final String valor = String.valueOf(contacto.getDomicilio() + "-" +
contacto.getEmail() + "-" + contacto.getTelefono());
return valor;
}

protected Contacto doRestore(final String data) {
final String[] partes = data.split("-");
final String domicilio = partes[0];
final String correo = partes[1];
final String telefono = partes[2];
return new Contacto(domicilio, correo, telefono);
}
Thank´s.


2013/9/12 Ezequiel Celiz <elceliz@gmail.com>

> Hi community
>
> I'm trying to implement the annotation @Value in my application to use the
> "Value Objects" as defined in the concept of DDD .
>
> I had no success : How I can set my class as a genuine Custom Value Type?
> so that it can be used in the entities that require it.
>
> I want to create the classic VO : "Contact" which consists of the following
> properties ( in my case) :
>
> Address, Telephone and Email.
>
>     @Value ( semanticsProviderName = "
>  ContactValueSemanticsProvider.class " )
>     public class Contact  {
>
>     / *
>     / Need to the builder?
>     /
>     / Public Contact ( String a, String t , String e) {
>     / This.address = a;
>     / This.telephone = t;
>     / This.email = e ;
>     / }
>     /
>     / *
>
>     private String address ;
>
>     public String getAddress ( ) {
>         return address ;
>     }
>
>     public void setAddress (String address) {
>         this.address = address ;
>     }
>
>     private String telephone ;
>
>     getTelephone public String ( ) {
>         return telephone ;
>     }
>
>     public void setTelephone (String telephone) {
>         this.telephone = telephone ;
>     }
>
>     private String email ;
>
>     getEmail public String ( ) {
>         return email ;
>     }
>
>     public void setEmail (String email ) {
>         this.email = email ;
>     }
>
>  }
>
> where ContactValueSemanticsProvider.class :
> public final class ContactValueSemanticsProvider
> extends AbstractValueSemanticsProvider <Conctact> {}
>
> Then I wonder if the entity would have to have an attribute :
>
>     private Contact contact ;
>
>     public GetContact ( ) {
>         return contact ;
>     }
>
> Finally in the service when I creating the entity object :
>
>    SomeEntity public newEntity (
>             @ Optional
>             @ Named ( " Address" ) String address,
>             @ Optional
>             @ Named ( " Telephone" ) String telephone ,
>             @ Optional
>             @ Named ( " email " ) String email
>             ) {
>
>    final Contact contact
>
>             / / The correct way to instantiate is THROUGH
> newTransientInstance ( Contact.class ) ?
>
>             pourContacter (contact) ;
>
>  @ Hidden
>  SomeEntity public pourContacter ( ) (
>             Final Contact Contact
>         ) {
>         SomeEntity end someEntity = newTransientInstance ( SomeEntity.class
> ) ;
>         someEntitity.setContact (contact) ;
>         persistIfNotAlready ( someEntity ) ;
>
>         someEntity return ;
>     }
>
> It is the right way? or the way to work with the Value Object in ISIS is
> another?
>
> I welcome your suggestions
> Thank you very much as always for your attention
> Cheers !
> Ezequiel
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message