You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@polygene.apache.org by Niclas Hedhman <ni...@hedhman.org> on 2015/05/14 06:50:42 UTC

toValue() and toEntity()

Rickard added the support for handling Associations in Values, and we also
now have the full support of sharing super-types between Entities and
Values.

So, it would make sense that if I declare the assembly;

    module.entities( Person.class );
    module.values( Person.class );

that I could do;

    Person entity = ...;
    Person value = api.toValue( Person,class, entity );

as well as the other way around;

    Person value = ...;
    Person entity = api.toEntity( Person.class, entity );

The implementation of this is fairly small and straight forward, and I have
most of it in place in my project already, but I think it really belongs in
the API itself, as this would be super-neat for Rest APIs and other work
outside of UnitOfWorks.

WDYT?


Cheers
-- 
Niclas Hedhman, Software Developer
http://zest.apache.org - New Energy for Java

Re: toValue() and toEntity()

Posted by Niclas Hedhman <ni...@hedhman.org>.
Yes, kind of... The conversion library is more lenient (@Unqualified), as
well as somewhat more complex, since can't access the internal runtime's
state.

The proposed change is strict, but fully bi-directional and relying on the
fact that I can register the same type as both a Entity as well as a Value.
When the Conversion library was originally created, that feature didn't
exist, and it had to do name matching instead.

So, Conversion library is not as clean as this proposal, and perhaps that
is wanted at times. I can also imagine expanding the conversion library
into the "POJO" space, i.e. back-forth between values and getter/setter
styled classes.

Cheers
Niclas

On Sat, May 16, 2015 at 4:11 AM, Jiri Jetmar <ju...@gmail.com>
wrote:

> "Is this close to what the `conversion` library does?"
>
> This was also my question. We are using that library to convert Entities to
> Values, when we are executing e.g. queries "ByValue"..
>
> The interesting point is how the PersonValue is defined ? We are deriving
> the Values from the Entities to keep them synchronous to each other.
>
> Cheers ,
> jj
>
> 2015-05-15 19:48 GMT+02:00 Paul Merlin <pa...@nosphere.org>:
>
> > Niclas Hedhman a écrit :
> > > Rickard added the support for handling Associations in Values, and we
> > also
> > > now have the full support of sharing super-types between Entities and
> > > Values.
> > >
> > > So, it would make sense that if I declare the assembly;
> > >
> > >     module.entities( Person.class );
> > >     module.values( Person.class );
> > >
> > > that I could do;
> > >
> > >     Person entity = ...;
> > >     Person value = api.toValue( Person,class, entity );
> > >
> > > as well as the other way around;
> > >
> > >     Person value = ...;
> > >     Person entity = api.toEntity( Person.class, entity );
> > >
> > > The implementation of this is fairly small and straight forward, and I
> > have
> > > most of it in place in my project already, but I think it really
> belongs
> > in
> > > the API itself, as this would be super-neat for Rest APIs and other
> work
> > > outside of UnitOfWorks.
> > >
> > > WDYT?
> > Is this close to what the `conversion` library does?
> > I added Value -> Entity conversion in there lately (develop branch,
> > QI-414).
> >
> > Cheers
> >
> >
>



-- 
Niclas Hedhman, Software Developer
http://zest.apache.org - New Energy for Java

Re: toValue() and toEntity()

Posted by Jiri Jetmar <ju...@gmail.com>.
"Is this close to what the `conversion` library does?"

This was also my question. We are using that library to convert Entities to
Values, when we are executing e.g. queries "ByValue"..

The interesting point is how the PersonValue is defined ? We are deriving
the Values from the Entities to keep them synchronous to each other.

Cheers ,
jj

2015-05-15 19:48 GMT+02:00 Paul Merlin <pa...@nosphere.org>:

> Niclas Hedhman a écrit :
> > Rickard added the support for handling Associations in Values, and we
> also
> > now have the full support of sharing super-types between Entities and
> > Values.
> >
> > So, it would make sense that if I declare the assembly;
> >
> >     module.entities( Person.class );
> >     module.values( Person.class );
> >
> > that I could do;
> >
> >     Person entity = ...;
> >     Person value = api.toValue( Person,class, entity );
> >
> > as well as the other way around;
> >
> >     Person value = ...;
> >     Person entity = api.toEntity( Person.class, entity );
> >
> > The implementation of this is fairly small and straight forward, and I
> have
> > most of it in place in my project already, but I think it really belongs
> in
> > the API itself, as this would be super-neat for Rest APIs and other work
> > outside of UnitOfWorks.
> >
> > WDYT?
> Is this close to what the `conversion` library does?
> I added Value -> Entity conversion in there lately (develop branch,
> QI-414).
>
> Cheers
>
>

Re: toValue() and toEntity()

Posted by Paul Merlin <pa...@nosphere.org>.
Niclas Hedhman a écrit :
> Rickard added the support for handling Associations in Values, and we also
> now have the full support of sharing super-types between Entities and
> Values.
>
> So, it would make sense that if I declare the assembly;
>
>     module.entities( Person.class );
>     module.values( Person.class );
>
> that I could do;
>
>     Person entity = ...;
>     Person value = api.toValue( Person,class, entity );
>
> as well as the other way around;
>
>     Person value = ...;
>     Person entity = api.toEntity( Person.class, entity );
>
> The implementation of this is fairly small and straight forward, and I have
> most of it in place in my project already, but I think it really belongs in
> the API itself, as this would be super-neat for Rest APIs and other work
> outside of UnitOfWorks.
>
> WDYT?
Is this close to what the `conversion` library does?
I added Value -> Entity conversion in there lately (develop branch, QI-414).

Cheers