You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Stephen Cameron <st...@gmail.com> on 2015/09/16 06:18:13 UTC

Automatic created-by and modified-by property updates

Hi,

Could someone please assist me in adding this capability, to automate the
creation and update of values in these standard fields

created_by
created_on
modified_by
modified_on

That is I need to set the first two on creating a new object, and the last
two on modifying an object.

Thanks
Steve Cameron

Re: Automatic created-by and modified-by property updates

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 16 September 2015 at 07:29, Stephen Cameron <st...@gmail.com>
wrote:

> Thanks again Dan,
>
> Just making good use of the 'poly' module/addon for my notes functionality,
> via a wee bit of 'editor inheritance' :)
>

Glad to hear that's working for you... it's not the simplest pattern to
wrap one's head around....

Cheers
Dan

Re: Automatic created-by and modified-by property updates

Posted by Stephen Cameron <st...@gmail.com>.
Thanks again Dan,

Just making good use of the 'poly' module/addon for my notes functionality,
via a wee bit of 'editor inheritance' :)

On Wed, Sep 16, 2015 at 4:04 PM, Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> As a follow-up, here's a very similar service that's in our Neo4J demo app:
>
>
> https://github.com/isisaddons/isis-app-neoapp/blob/master/dom/src/main/java/neoapp/dom/services/titling/TitlingService.java
>
>
> On 16 September 2015 at 07:02, Dan Haywood <da...@haywood-associates.co.uk>
> wrote:
>
> > Hi Steve,
> >
> > Although there isn't any direct support for this, it's should be
> > relatively easy to do by using the underlying JDO API.
> >
> > As a quick code sketch:
> >
> > public interface CreateTrackingEntity {
> >     void setCreatedBy(String createdBy);
> >     void setCreatedOn(DateTime createdOn);
> > }
> >
> > public interface ModifyTrackingEntity {
> >     void setModifiedBy(String username);
> >     void setModifiedOn(DateTime modifiedOn);
> > }
> >
> >
> > Your entity should implement one or both of the above.
> >
> > Then, define a service such as:
> >
> > @RequestScoped
> > @DomainService(nature=NatureOfService.DOMAIN)
> > public class UpdateableEntityServices implements
> > javax.jdo.listener.StoreLifecycleListener {
> >
> >     @PostConstruct
> >     public void open() {
> >
> >
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
> >     }
> >
> >     @PreDestroy
> >     public void close() {
> >
> >
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
> >     }
> >
> >     @Programmatic
> >     public void preStore (InstanceLifecycleEvent event) {
> >
> >         final Object pi = event.getPersistentInstance();
> >
> >         if(pi instanceof org.datanucleus.enhancement.Persistable) {
> >             boolean isPersistent =
> > ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
> >
> >             if(!isPersistent) {
> >                 if(pi instanceof CreateTrackingEntity) {
> >
> >  ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
> >
> >  ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
> >                 }
> >             } else {
> >                 if(pi instanceof ModifyTrackingEntity) {
> >
> >  ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
> >
> >  ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
> >                 }
> >             }
> >         }
> >     }
> >
> >     @Programmatic
> >     public void postStore (InstanceLifecycleEvent event) {
> >         // no-op
> >     }
> >
> >     @Inject
> >     private DomainObjectContainer container;
> >
> >     @Inject
> >     private ClockService clockService;
> >
> >     @Inject
> >     private IsisJdoSupport isisJdoSupport;
> > }
> >
> >
> >
> > ~~~~~~~~~~~~
> > There is actually a ticket in JIRA for this [1], so I'll formalize this
> as
> > a service in Isis 1.10.0.
> >
> > HTH
> > Dan
> >
> > [1] https://issues.apache.org/jira/browse/ISIS-867
> >
> >
> > On 16 September 2015 at 05:18, Stephen Cameron <
> steve.cameron.62@gmail.com
> > > wrote:
> >
> >> Hi,
> >>
> >> Could someone please assist me in adding this capability, to automate
> the
> >> creation and update of values in these standard fields
> >>
> >> created_by
> >> created_on
> >> modified_by
> >> modified_on
> >>
> >> That is I need to set the first two on creating a new object, and the
> last
> >> two on modifying an object.
> >>
> >> Thanks
> >> Steve Cameron
> >>
> >
> >
>

Re: Automatic created-by and modified-by property updates

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
As a follow-up, here's a very similar service that's in our Neo4J demo app:

https://github.com/isisaddons/isis-app-neoapp/blob/master/dom/src/main/java/neoapp/dom/services/titling/TitlingService.java


On 16 September 2015 at 07:02, Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> Hi Steve,
>
> Although there isn't any direct support for this, it's should be
> relatively easy to do by using the underlying JDO API.
>
> As a quick code sketch:
>
> public interface CreateTrackingEntity {
>     void setCreatedBy(String createdBy);
>     void setCreatedOn(DateTime createdOn);
> }
>
> public interface ModifyTrackingEntity {
>     void setModifiedBy(String username);
>     void setModifiedOn(DateTime modifiedOn);
> }
>
>
> Your entity should implement one or both of the above.
>
> Then, define a service such as:
>
> @RequestScoped
> @DomainService(nature=NatureOfService.DOMAIN)
> public class UpdateableEntityServices implements
> javax.jdo.listener.StoreLifecycleListener {
>
>     @PostConstruct
>     public void open() {
>
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
>     }
>
>     @PreDestroy
>     public void close() {
>
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
>     }
>
>     @Programmatic
>     public void preStore (InstanceLifecycleEvent event) {
>
>         final Object pi = event.getPersistentInstance();
>
>         if(pi instanceof org.datanucleus.enhancement.Persistable) {
>             boolean isPersistent =
> ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
>
>             if(!isPersistent) {
>                 if(pi instanceof CreateTrackingEntity) {
>
>  ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
>
>  ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
>                 }
>             } else {
>                 if(pi instanceof ModifyTrackingEntity) {
>
>  ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
>
>  ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
>                 }
>             }
>         }
>     }
>
>     @Programmatic
>     public void postStore (InstanceLifecycleEvent event) {
>         // no-op
>     }
>
>     @Inject
>     private DomainObjectContainer container;
>
>     @Inject
>     private ClockService clockService;
>
>     @Inject
>     private IsisJdoSupport isisJdoSupport;
> }
>
>
>
> ~~~~~~~~~~~~
> There is actually a ticket in JIRA for this [1], so I'll formalize this as
> a service in Isis 1.10.0.
>
> HTH
> Dan
>
> [1] https://issues.apache.org/jira/browse/ISIS-867
>
>
> On 16 September 2015 at 05:18, Stephen Cameron <steve.cameron.62@gmail.com
> > wrote:
>
>> Hi,
>>
>> Could someone please assist me in adding this capability, to automate the
>> creation and update of values in these standard fields
>>
>> created_by
>> created_on
>> modified_by
>> modified_on
>>
>> That is I need to set the first two on creating a new object, and the last
>> two on modifying an object.
>>
>> Thanks
>> Steve Cameron
>>
>
>

Re: Automatic created-by and modified-by property updates

Posted by Stephen Cameron <st...@gmail.com>.
Oh great, I have been unable to get this to work!

Thinking logically, one should use the audit module I have to admit. But
this provides a little convenience, or maybe reassurance.

Thanks





On Wed, Oct 21, 2015 at 6:56 PM, Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> Just to close off this thread... in 1.10.0-SNAPSHOT there is built-in
> support for this feature... just implement Timetstampable [1]
>
> Cheers
> Dan
>
> [1] http://isis.apache.org/guides/rg.html#_rg_classes_roles
>
> On 28 September 2015 at 04:01, Stephen Cameron <steve.cameron.62@gmail.com
> >
> wrote:
>
> > Hi Dan,
> >
> > I tried this and its not correct, I get the open and close methods being
> > called over and over whenever I open and close an object in the UI. but
> the
> > jdo listener method preStore (InstanceLifecycleEvent event) never gets
> > called.
> >
> > I pictured open()  and close() being called just once as the DOMAIN
> service
> > singleton is created by Isis and then it listens on the JDO events as
> each
> > entity goes through its lifecycle.
> >
> >  I will put this aside as its not the main priority. I'll read up and
> > understand the jdo events to find an answer, this must be close to
> correct.
> >
> >
> > On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood <
> dan@haywood-associates.co.uk
> > >
> > wrote:
> >
> > > Hi Steve,
> > >
> > > Although there isn't any direct support for this, it's should be
> > relatively
> > > easy to do by using the underlying JDO API.
> > >
> > > As a quick code sketch:
> > >
> > > public interface CreateTrackingEntity {
> > >     void setCreatedBy(String createdBy);
> > >     void setCreatedOn(DateTime createdOn);
> > > }
> > >
> > > public interface ModifyTrackingEntity {
> > >     void setModifiedBy(String username);
> > >     void setModifiedOn(DateTime modifiedOn);
> > > }
> > >
> > >
> > > Your entity should implement one or both of the above.
> > >
> > > Then, define a service such as:
> > >
> > > @RequestScoped
> > > @DomainService(nature=NatureOfService.DOMAIN)
> > > public class UpdateableEntityServices implements
> > > javax.jdo.listener.StoreLifecycleListener {
> > >
> > >     @PostConstruct
> > >     public void open() {
> > >
> > >
> > >
> >
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
> > >     }
> > >
> > >     @PreDestroy
> > >     public void close() {
> > >
> > >
> > >
> >
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
> > >     }
> > >
> > >     @Programmatic
> > >     public void preStore (InstanceLifecycleEvent event) {
> > >
> > >         final Object pi = event.getPersistentInstance();
> > >
> > >         if(pi instanceof org.datanucleus.enhancement.Persistable) {
> > >             boolean isPersistent =
> > > ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
> > >
> > >             if(!isPersistent) {
> > >                 if(pi instanceof CreateTrackingEntity) {
> > >
> > >  ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
> > >
> > >  ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
> > >                 }
> > >             } else {
> > >                 if(pi instanceof ModifyTrackingEntity) {
> > >
> > >  ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
> > >
> > >  ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
> > >                 }
> > >             }
> > >         }
> > >     }
> > >
> > >     @Programmatic
> > >     public void postStore (InstanceLifecycleEvent event) {
> > >         // no-op
> > >     }
> > >
> > >     @Inject
> > >     private DomainObjectContainer container;
> > >
> > >     @Inject
> > >     private ClockService clockService;
> > >
> > >     @Inject
> > >     private IsisJdoSupport isisJdoSupport;
> > > }
> > >
> > >
> > >
> > > ~~~~~~~~~~~~
> > > There is actually a ticket in JIRA for this [1], so I'll formalize this
> > as
> > > a service in Isis 1.10.0.
> > >
> > > HTH
> > > Dan
> > >
> > > [1] https://issues.apache.org/jira/browse/ISIS-867
> > >
> > >
> > > On 16 September 2015 at 05:18, Stephen Cameron <
> > steve.cameron.62@gmail.com
> > > >
> > > wrote:
> > >
> > > > Hi,
> > > >
> > > > Could someone please assist me in adding this capability, to automate
> > the
> > > > creation and update of values in these standard fields
> > > >
> > > > created_by
> > > > created_on
> > > > modified_by
> > > > modified_on
> > > >
> > > > That is I need to set the first two on creating a new object, and the
> > > last
> > > > two on modifying an object.
> > > >
> > > > Thanks
> > > > Steve Cameron
> > > >
> > >
> >
>

RE: Automatic created-by and modified-by property updates

Posted by Cesar Lugo <ce...@sisorg.com.mx>.
Great!

-----Original Message-----
From: Dan Haywood [mailto:dan@haywood-associates.co.uk] 
Sent: Wednesday, October 21, 2015 2:57 AM
To: users
Subject: Re: Automatic created-by and modified-by property updates

Just to close off this thread... in 1.10.0-SNAPSHOT there is built-in support for this feature... just implement Timetstampable [1]

Cheers
Dan

[1] http://isis.apache.org/guides/rg.html#_rg_classes_roles

On 28 September 2015 at 04:01, Stephen Cameron <st...@gmail.com>
wrote:

> Hi Dan,
>
> I tried this and its not correct, I get the open and close methods 
> being called over and over whenever I open and close an object in the 
> UI. but the jdo listener method preStore (InstanceLifecycleEvent 
> event) never gets called.
>
> I pictured open()  and close() being called just once as the DOMAIN 
> service singleton is created by Isis and then it listens on the JDO 
> events as each entity goes through its lifecycle.
>
>  I will put this aside as its not the main priority. I'll read up and 
> understand the jdo events to find an answer, this must be close to correct.
>
>
> On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood 
> <dan@haywood-associates.co.uk
> >
> wrote:
>
> > Hi Steve,
> >
> > Although there isn't any direct support for this, it's should be
> relatively
> > easy to do by using the underlying JDO API.
> >
> > As a quick code sketch:
> >
> > public interface CreateTrackingEntity {
> >     void setCreatedBy(String createdBy);
> >     void setCreatedOn(DateTime createdOn); }
> >
> > public interface ModifyTrackingEntity {
> >     void setModifiedBy(String username);
> >     void setModifiedOn(DateTime modifiedOn); }
> >
> >
> > Your entity should implement one or both of the above.
> >
> > Then, define a service such as:
> >
> > @RequestScoped
> > @DomainService(nature=NatureOfService.DOMAIN)
> > public class UpdateableEntityServices implements
> > javax.jdo.listener.StoreLifecycleListener {
> >
> >     @PostConstruct
> >     public void open() {
> >
> >
> >
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
> >     }
> >
> >     @PreDestroy
> >     public void close() {
> >
> >
> >
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
> >     }
> >
> >     @Programmatic
> >     public void preStore (InstanceLifecycleEvent event) {
> >
> >         final Object pi = event.getPersistentInstance();
> >
> >         if(pi instanceof org.datanucleus.enhancement.Persistable) {
> >             boolean isPersistent =
> > ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
> >
> >             if(!isPersistent) {
> >                 if(pi instanceof CreateTrackingEntity) {
> >
> >  ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
> >
> >  ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
> >                 }
> >             } else {
> >                 if(pi instanceof ModifyTrackingEntity) {
> >
> >  ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
> >
> >  ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
> >                 }
> >             }
> >         }
> >     }
> >
> >     @Programmatic
> >     public void postStore (InstanceLifecycleEvent event) {
> >         // no-op
> >     }
> >
> >     @Inject
> >     private DomainObjectContainer container;
> >
> >     @Inject
> >     private ClockService clockService;
> >
> >     @Inject
> >     private IsisJdoSupport isisJdoSupport;
> > }
> >
> >
> >
> > ~~~~~~~~~~~~
> > There is actually a ticket in JIRA for this [1], so I'll formalize this
> as
> > a service in Isis 1.10.0.
> >
> > HTH
> > Dan
> >
> > [1] https://issues.apache.org/jira/browse/ISIS-867
> >
> >
> > On 16 September 2015 at 05:18, Stephen Cameron <
> steve.cameron.62@gmail.com
> > >
> > wrote:
> >
> > > Hi,
> > >
> > > Could someone please assist me in adding this capability, to automate
> the
> > > creation and update of values in these standard fields
> > >
> > > created_by
> > > created_on
> > > modified_by
> > > modified_on
> > >
> > > That is I need to set the first two on creating a new object, and the
> > last
> > > two on modifying an object.
> > >
> > > Thanks
> > > Steve Cameron
> > >
> >
>


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


Re: Automatic created-by and modified-by property updates

Posted by Stephen Cameron <st...@gmail.com>.
Yes it was a domain service, specifically:

https://github.com/Stephen-Cameron-Data-Services/isis-chats/blob/master/dom/src/main/java/au/com/scds/chats/dom/module/attendance/AttendanceLists.java

I've added the missing constructor now. I know that the Isis version of
JMock would inject that container dependancy, but I read that after
creating these DI constructors.

The error message was'nt very helpful id did not say that the class had no
constructor specifically, but it was clear that that class had a problem, I
should have checked my assumptions first up, then I would have found it was
only that class and seen the error.

thanks for the Eclipse tips though.

On Mon, Oct 26, 2015 at 9:53 PM, Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> Glad you sorted it.
>
> Which class was it - presumably a domain service?  If so, I wonder if we
> could add something in Isis to provide better diagnostics?
>
> Dan
>
> On 25 October 2015 at 20:59, Stephen Cameron <st...@gmail.com>
> wrote:
>
> > Ironic, in writing tests I added a constructor to inject the container
> but
> > forgot to add the default constructor to that one class. Feeling pleased
> > with myself at my use of TDD I then assumed it was going to
> 1.10.0-SNAPSHOT
> > that was the source of the error.
> >
> > On Mon, Oct 26, 2015 at 7:51 AM, Stephen Cameron <
> > steve.cameron.62@gmail.com
> > > wrote:
> >
> > > Oops, embarrasement++ No public no-args constructor!
> > >
> > > On Sun, Oct 25, 2015 at 10:09 PM, Stephen Cameron <
> > > steve.cameron.62@gmail.com> wrote:
> > >
> > >> Just removing the 'offending' class allows the webapp to run... Will
> try
> > >> to figure out what it might be that is offensive tomorrow.
> > >>
> > >> On Sun, Oct 25, 2015 at 7:05 AM, Stephen Cameron <
> > >> steve.cameron.62@gmail.com> wrote:
> > >>
> > >>> Seems its not a classpath issue, the built jetty-console jar has the
> > >>> same problem, that has the app dom jar inside it. Not solved but I
> > looking
> > >>> for an answer in the wrong place it appears.
> > >>>
> > >>> On Sat, Oct 24, 2015 at 9:32 PM, Dan Haywood <
> > >>> dan@haywood-associates.co.uk> wrote:
> > >>>
> > >>>> With Eclipse (as I'm sure you know) the m2e plugin generates the
> > >>>> .project
> > >>>> and .classpath files from the maven pom.xml files.  Doing an update
> > >>>> project
> > >>>> from the context menu of the package explorer view is generally
> pretty
> > >>>> reliable.  Thereafter Eclipse just uses its .classpath and .project.
> > >>>>
> > >>>> Another thing to do is to look at the dependency tree tab of the
> > >>>> pom.xml,
> > >>>> check it looks correct.  It's also possible to view the dependencies
> > as
> > >>>> per
> > >>>> the .classpath file, by viewing the build path, eg [1]
> > >>>>
> > >>>> When you run the app up, the Debug view (IIRC) shows the actual Java
> > >>>> command that Eclipse constructs, along with all the JARs constructed
> > >>>> from
> > >>>> the classpath.  That might also provide some clues.
> > >>>>
> > >>>> HTH
> > >>>> Dan
> > >>>>
> > >>>>
> > >>>> [1]
> http://www.tutorialspoint.com/eclipse/eclipse_java_build_path.htm
> > >>>>
> > >>>> On 24 October 2015 at 11:27, Stephen Cameron <
> > >>>> steve.cameron.62@gmail.com>
> > >>>> wrote:
> > >>>>
> > >>>> > Hi
> > >>>> >
> > >>>> > I'll have another go tomorrow, I am using Eclipse and can get the
> > >>>> simpleapp
> > >>>> > on Isis 1.10.0 imported and webapp starting fine, its just when I
> > try
> > >>>> to go
> > >>>> > from there by adding my dom classes and changing the dom module
> > >>>> 'marker'
> > >>>> > class something breaks, also going from a fresh install of my app
> > and
> > >>>> > updating the poms from the simpleapp too.
> > >>>> >
> > >>>> > I assume if Guice cannot find a class file it gives that error, so
> > its
> > >>>> > seems my classes are not be on the classpath, but as to why is
> where
> > >>>> my
> > >>>> > knowledge is not very good. I was just hoping someone else might
> > have
> > >>>> had
> > >>>> > the same thing happen.
> > >>>> >
> > >>>> > On Sat, Oct 24, 2015 at 9:16 PM, Jeroen van der Wal <
> > >>>> jeroen@stromboli.it>
> > >>>> > wrote:
> > >>>> >
> > >>>> > > And removing ~/,m2/repository/org/apache/isis before mvn clean
> > >>>> install is
> > >>>> > > also worth trying.
> > >>>> > >
> > >>>> > > On 24 October 2015 at 12:13, Jeroen van der Wal <
> > >>>> jeroen@stromboli.it>
> > >>>> > > wrote:
> > >>>> > >
> > >>>> > > > You could try a mvn clean install and reimport the project
> into
> > >>>> > Intellij.
> > >>>> > > >
> > >>>> > > > On 24 October 2015 at 03:01, Stephen Cameron <
> > >>>> > steve.cameron.62@gmail.com
> > >>>> > > >
> > >>>> > > > wrote:
> > >>>> > > >
> > >>>> > > >> What do I have to change to go from 1.9.0 to 1.10.0-SNAPSHOT?
> > >>>> > > >>
> > >>>> > > >>  I just changed version number in pom.xml but then I get the
> > >>>> dreaded
> > >>>> > > guice
> > >>>> > > >> cannot instantiate class ... error, last time I fixed this by
> > >>>> updating
> > >>>> > > >> simpleapp with my classes.  Now it looks like the same thing
> is
> > >>>> > required
> > >>>> > > >> again to get a working version :(
> > >>>> > > >>
> > >>>> > > >>
> > >>>> > > >>
> > >>>> > > >> On Thu, Oct 22, 2015 at 12:44 AM, Cesar Lugo <
> > >>>> > cesar.lugo@sisorg.com.mx>
> > >>>> > > >> wrote:
> > >>>> > > >>
> > >>>> > > >> > Great!
> > >>>> > > >> >
> > >>>> > > >> > -----Original Message-----
> > >>>> > > >> > From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
> > >>>> > > >> > Sent: Wednesday, October 21, 2015 2:57 AM
> > >>>> > > >> > To: users
> > >>>> > > >> > Subject: Re: Automatic created-by and modified-by property
> > >>>> updates
> > >>>> > > >> >
> > >>>> > > >> > Just to close off this thread... in 1.10.0-SNAPSHOT there
> is
> > >>>> > built-in
> > >>>> > > >> > support for this feature... just implement Timetstampable
> [1]
> > >>>> > > >> >
> > >>>> > > >> > Cheers
> > >>>> > > >> > Dan
> > >>>> > > >> >
> > >>>> > > >> > [1]
> http://isis.apache.org/guides/rg.html#_rg_classes_roles
> > >>>> > > >> >
> > >>>> > > >> > On 28 September 2015 at 04:01, Stephen Cameron <
> > >>>> > > >> steve.cameron.62@gmail.com
> > >>>> > > >> > >
> > >>>> > > >> > wrote:
> > >>>> > > >> >
> > >>>> > > >> > > Hi Dan,
> > >>>> > > >> > >
> > >>>> > > >> > > I tried this and its not correct, I get the open and
> close
> > >>>> methods
> > >>>> > > >> > > being called over and over whenever I open and close an
> > >>>> object in
> > >>>> > > the
> > >>>> > > >> > > UI. but the jdo listener method preStore
> > >>>> (InstanceLifecycleEvent
> > >>>> > > >> > > event) never gets called.
> > >>>> > > >> > >
> > >>>> > > >> > > I pictured open()  and close() being called just once as
> > the
> > >>>> > DOMAIN
> > >>>> > > >> > > service singleton is created by Isis and then it listens
> on
> > >>>> the
> > >>>> > JDO
> > >>>> > > >> > > events as each entity goes through its lifecycle.
> > >>>> > > >> > >
> > >>>> > > >> > >  I will put this aside as its not the main priority. I'll
> > >>>> read up
> > >>>> > > and
> > >>>> > > >> > > understand the jdo events to find an answer, this must be
> > >>>> close to
> > >>>> > > >> > correct.
> > >>>> > > >> > >
> > >>>> > > >> > >
> > >>>> > > >> > > On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood
> > >>>> > > >> > > <dan@haywood-associates.co.uk
> > >>>> > > >> > > >
> > >>>> > > >> > > wrote:
> > >>>> > > >> > >
> > >>>> > > >> > > > Hi Steve,
> > >>>> > > >> > > >
> > >>>> > > >> > > > Although there isn't any direct support for this, it's
> > >>>> should be
> > >>>> > > >> > > relatively
> > >>>> > > >> > > > easy to do by using the underlying JDO API.
> > >>>> > > >> > > >
> > >>>> > > >> > > > As a quick code sketch:
> > >>>> > > >> > > >
> > >>>> > > >> > > > public interface CreateTrackingEntity {
> > >>>> > > >> > > >     void setCreatedBy(String createdBy);
> > >>>> > > >> > > >     void setCreatedOn(DateTime createdOn); }
> > >>>> > > >> > > >
> > >>>> > > >> > > > public interface ModifyTrackingEntity {
> > >>>> > > >> > > >     void setModifiedBy(String username);
> > >>>> > > >> > > >     void setModifiedOn(DateTime modifiedOn); }
> > >>>> > > >> > > >
> > >>>> > > >> > > >
> > >>>> > > >> > > > Your entity should implement one or both of the above.
> > >>>> > > >> > > >
> > >>>> > > >> > > > Then, define a service such as:
> > >>>> > > >> > > >
> > >>>> > > >> > > > @RequestScoped
> > >>>> > > >> > > > @DomainService(nature=NatureOfService.DOMAIN)
> > >>>> > > >> > > > public class UpdateableEntityServices implements
> > >>>> > > >> > > > javax.jdo.listener.StoreLifecycleListener {
> > >>>> > > >> > > >
> > >>>> > > >> > > >     @PostConstruct
> > >>>> > > >> > > >     public void open() {
> > >>>> > > >> > > >
> > >>>> > > >> > > >
> > >>>> > > >> > > >
> > >>>> > > >> > >
> > >>>> > > >> >
> > >>>> > > >>
> > >>>> > >
> > >>>> >
> > >>>>
> >
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
> > >>>> > > >> > > >     }
> > >>>> > > >> > > >
> > >>>> > > >> > > >     @PreDestroy
> > >>>> > > >> > > >     public void close() {
> > >>>> > > >> > > >
> > >>>> > > >> > > >
> > >>>> > > >> > > >
> > >>>> > > >> > >
> > >>>> > > >> >
> > >>>> > > >>
> > >>>> > >
> > >>>> >
> > >>>>
> >
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
> > >>>> > > >> > > >     }
> > >>>> > > >> > > >
> > >>>> > > >> > > >     @Programmatic
> > >>>> > > >> > > >     public void preStore (InstanceLifecycleEvent
> event) {
> > >>>> > > >> > > >
> > >>>> > > >> > > >         final Object pi =
> event.getPersistentInstance();
> > >>>> > > >> > > >
> > >>>> > > >> > > >         if(pi instanceof
> > >>>> > org.datanucleus.enhancement.Persistable)
> > >>>> > > {
> > >>>> > > >> > > >             boolean isPersistent =
> > >>>> > > >> > > >
> > >>>> ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
> > >>>> > > >> > > >
> > >>>> > > >> > > >             if(!isPersistent) {
> > >>>> > > >> > > >                 if(pi instanceof CreateTrackingEntity)
> {
> > >>>> > > >> > > >
> > >>>> > > >> > > >
> > >>>> > ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
> > >>>> > > >> > > >
> > >>>> > > >> > > >
> > >>>> > > >>
> > >>>>
> ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
> > >>>> > > >> > > >                 }
> > >>>> > > >> > > >             } else {
> > >>>> > > >> > > >                 if(pi instanceof ModifyTrackingEntity)
> {
> > >>>> > > >> > > >
> > >>>> > > >> > > >
> > >>>> > >
> ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
> > >>>> > > >> > > >
> > >>>> > > >> > > >
> > >>>> > > >>
> > >>>>
> ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
> > >>>> > > >> > > >                 }
> > >>>> > > >> > > >             }
> > >>>> > > >> > > >         }
> > >>>> > > >> > > >     }
> > >>>> > > >> > > >
> > >>>> > > >> > > >     @Programmatic
> > >>>> > > >> > > >     public void postStore (InstanceLifecycleEvent
> event)
> > {
> > >>>> > > >> > > >         // no-op
> > >>>> > > >> > > >     }
> > >>>> > > >> > > >
> > >>>> > > >> > > >     @Inject
> > >>>> > > >> > > >     private DomainObjectContainer container;
> > >>>> > > >> > > >
> > >>>> > > >> > > >     @Inject
> > >>>> > > >> > > >     private ClockService clockService;
> > >>>> > > >> > > >
> > >>>> > > >> > > >     @Inject
> > >>>> > > >> > > >     private IsisJdoSupport isisJdoSupport;
> > >>>> > > >> > > > }
> > >>>> > > >> > > >
> > >>>> > > >> > > >
> > >>>> > > >> > > >
> > >>>> > > >> > > > ~~~~~~~~~~~~
> > >>>> > > >> > > > There is actually a ticket in JIRA for this [1], so
> I'll
> > >>>> > formalize
> > >>>> > > >> this
> > >>>> > > >> > > as
> > >>>> > > >> > > > a service in Isis 1.10.0.
> > >>>> > > >> > > >
> > >>>> > > >> > > > HTH
> > >>>> > > >> > > > Dan
> > >>>> > > >> > > >
> > >>>> > > >> > > > [1] https://issues.apache.org/jira/browse/ISIS-867
> > >>>> > > >> > > >
> > >>>> > > >> > > >
> > >>>> > > >> > > > On 16 September 2015 at 05:18, Stephen Cameron <
> > >>>> > > >> > > steve.cameron.62@gmail.com
> > >>>> > > >> > > > >
> > >>>> > > >> > > > wrote:
> > >>>> > > >> > > >
> > >>>> > > >> > > > > Hi,
> > >>>> > > >> > > > >
> > >>>> > > >> > > > > Could someone please assist me in adding this
> > >>>> capability, to
> > >>>> > > >> automate
> > >>>> > > >> > > the
> > >>>> > > >> > > > > creation and update of values in these standard
> fields
> > >>>> > > >> > > > >
> > >>>> > > >> > > > > created_by
> > >>>> > > >> > > > > created_on
> > >>>> > > >> > > > > modified_by
> > >>>> > > >> > > > > modified_on
> > >>>> > > >> > > > >
> > >>>> > > >> > > > > That is I need to set the first two on creating a new
> > >>>> object,
> > >>>> > > and
> > >>>> > > >> the
> > >>>> > > >> > > > last
> > >>>> > > >> > > > > two on modifying an object.
> > >>>> > > >> > > > >
> > >>>> > > >> > > > > Thanks
> > >>>> > > >> > > > > Steve Cameron
> > >>>> > > >> > > > >
> > >>>> > > >> > > >
> > >>>> > > >> > >
> > >>>> > > >> >
> > >>>> > > >> >
> > >>>> > > >> > ---
> > >>>> > > >> > This email has been checked for viruses by Avast antivirus
> > >>>> software.
> > >>>> > > >> > https://www.avast.com/antivirus
> > >>>> > > >> >
> > >>>> > > >> >
> > >>>> > > >>
> > >>>> > > >
> > >>>> > > >
> > >>>> > >
> > >>>> >
> > >>>>
> > >>>
> > >>>
> > >>
> > >
> >
>

Re: Automatic created-by and modified-by property updates

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Glad you sorted it.

Which class was it - presumably a domain service?  If so, I wonder if we
could add something in Isis to provide better diagnostics?

Dan

On 25 October 2015 at 20:59, Stephen Cameron <st...@gmail.com>
wrote:

> Ironic, in writing tests I added a constructor to inject the container but
> forgot to add the default constructor to that one class. Feeling pleased
> with myself at my use of TDD I then assumed it was going to 1.10.0-SNAPSHOT
> that was the source of the error.
>
> On Mon, Oct 26, 2015 at 7:51 AM, Stephen Cameron <
> steve.cameron.62@gmail.com
> > wrote:
>
> > Oops, embarrasement++ No public no-args constructor!
> >
> > On Sun, Oct 25, 2015 at 10:09 PM, Stephen Cameron <
> > steve.cameron.62@gmail.com> wrote:
> >
> >> Just removing the 'offending' class allows the webapp to run... Will try
> >> to figure out what it might be that is offensive tomorrow.
> >>
> >> On Sun, Oct 25, 2015 at 7:05 AM, Stephen Cameron <
> >> steve.cameron.62@gmail.com> wrote:
> >>
> >>> Seems its not a classpath issue, the built jetty-console jar has the
> >>> same problem, that has the app dom jar inside it. Not solved but I
> looking
> >>> for an answer in the wrong place it appears.
> >>>
> >>> On Sat, Oct 24, 2015 at 9:32 PM, Dan Haywood <
> >>> dan@haywood-associates.co.uk> wrote:
> >>>
> >>>> With Eclipse (as I'm sure you know) the m2e plugin generates the
> >>>> .project
> >>>> and .classpath files from the maven pom.xml files.  Doing an update
> >>>> project
> >>>> from the context menu of the package explorer view is generally pretty
> >>>> reliable.  Thereafter Eclipse just uses its .classpath and .project.
> >>>>
> >>>> Another thing to do is to look at the dependency tree tab of the
> >>>> pom.xml,
> >>>> check it looks correct.  It's also possible to view the dependencies
> as
> >>>> per
> >>>> the .classpath file, by viewing the build path, eg [1]
> >>>>
> >>>> When you run the app up, the Debug view (IIRC) shows the actual Java
> >>>> command that Eclipse constructs, along with all the JARs constructed
> >>>> from
> >>>> the classpath.  That might also provide some clues.
> >>>>
> >>>> HTH
> >>>> Dan
> >>>>
> >>>>
> >>>> [1] http://www.tutorialspoint.com/eclipse/eclipse_java_build_path.htm
> >>>>
> >>>> On 24 October 2015 at 11:27, Stephen Cameron <
> >>>> steve.cameron.62@gmail.com>
> >>>> wrote:
> >>>>
> >>>> > Hi
> >>>> >
> >>>> > I'll have another go tomorrow, I am using Eclipse and can get the
> >>>> simpleapp
> >>>> > on Isis 1.10.0 imported and webapp starting fine, its just when I
> try
> >>>> to go
> >>>> > from there by adding my dom classes and changing the dom module
> >>>> 'marker'
> >>>> > class something breaks, also going from a fresh install of my app
> and
> >>>> > updating the poms from the simpleapp too.
> >>>> >
> >>>> > I assume if Guice cannot find a class file it gives that error, so
> its
> >>>> > seems my classes are not be on the classpath, but as to why is where
> >>>> my
> >>>> > knowledge is not very good. I was just hoping someone else might
> have
> >>>> had
> >>>> > the same thing happen.
> >>>> >
> >>>> > On Sat, Oct 24, 2015 at 9:16 PM, Jeroen van der Wal <
> >>>> jeroen@stromboli.it>
> >>>> > wrote:
> >>>> >
> >>>> > > And removing ~/,m2/repository/org/apache/isis before mvn clean
> >>>> install is
> >>>> > > also worth trying.
> >>>> > >
> >>>> > > On 24 October 2015 at 12:13, Jeroen van der Wal <
> >>>> jeroen@stromboli.it>
> >>>> > > wrote:
> >>>> > >
> >>>> > > > You could try a mvn clean install and reimport the project into
> >>>> > Intellij.
> >>>> > > >
> >>>> > > > On 24 October 2015 at 03:01, Stephen Cameron <
> >>>> > steve.cameron.62@gmail.com
> >>>> > > >
> >>>> > > > wrote:
> >>>> > > >
> >>>> > > >> What do I have to change to go from 1.9.0 to 1.10.0-SNAPSHOT?
> >>>> > > >>
> >>>> > > >>  I just changed version number in pom.xml but then I get the
> >>>> dreaded
> >>>> > > guice
> >>>> > > >> cannot instantiate class ... error, last time I fixed this by
> >>>> updating
> >>>> > > >> simpleapp with my classes.  Now it looks like the same thing is
> >>>> > required
> >>>> > > >> again to get a working version :(
> >>>> > > >>
> >>>> > > >>
> >>>> > > >>
> >>>> > > >> On Thu, Oct 22, 2015 at 12:44 AM, Cesar Lugo <
> >>>> > cesar.lugo@sisorg.com.mx>
> >>>> > > >> wrote:
> >>>> > > >>
> >>>> > > >> > Great!
> >>>> > > >> >
> >>>> > > >> > -----Original Message-----
> >>>> > > >> > From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
> >>>> > > >> > Sent: Wednesday, October 21, 2015 2:57 AM
> >>>> > > >> > To: users
> >>>> > > >> > Subject: Re: Automatic created-by and modified-by property
> >>>> updates
> >>>> > > >> >
> >>>> > > >> > Just to close off this thread... in 1.10.0-SNAPSHOT there is
> >>>> > built-in
> >>>> > > >> > support for this feature... just implement Timetstampable [1]
> >>>> > > >> >
> >>>> > > >> > Cheers
> >>>> > > >> > Dan
> >>>> > > >> >
> >>>> > > >> > [1] http://isis.apache.org/guides/rg.html#_rg_classes_roles
> >>>> > > >> >
> >>>> > > >> > On 28 September 2015 at 04:01, Stephen Cameron <
> >>>> > > >> steve.cameron.62@gmail.com
> >>>> > > >> > >
> >>>> > > >> > wrote:
> >>>> > > >> >
> >>>> > > >> > > Hi Dan,
> >>>> > > >> > >
> >>>> > > >> > > I tried this and its not correct, I get the open and close
> >>>> methods
> >>>> > > >> > > being called over and over whenever I open and close an
> >>>> object in
> >>>> > > the
> >>>> > > >> > > UI. but the jdo listener method preStore
> >>>> (InstanceLifecycleEvent
> >>>> > > >> > > event) never gets called.
> >>>> > > >> > >
> >>>> > > >> > > I pictured open()  and close() being called just once as
> the
> >>>> > DOMAIN
> >>>> > > >> > > service singleton is created by Isis and then it listens on
> >>>> the
> >>>> > JDO
> >>>> > > >> > > events as each entity goes through its lifecycle.
> >>>> > > >> > >
> >>>> > > >> > >  I will put this aside as its not the main priority. I'll
> >>>> read up
> >>>> > > and
> >>>> > > >> > > understand the jdo events to find an answer, this must be
> >>>> close to
> >>>> > > >> > correct.
> >>>> > > >> > >
> >>>> > > >> > >
> >>>> > > >> > > On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood
> >>>> > > >> > > <dan@haywood-associates.co.uk
> >>>> > > >> > > >
> >>>> > > >> > > wrote:
> >>>> > > >> > >
> >>>> > > >> > > > Hi Steve,
> >>>> > > >> > > >
> >>>> > > >> > > > Although there isn't any direct support for this, it's
> >>>> should be
> >>>> > > >> > > relatively
> >>>> > > >> > > > easy to do by using the underlying JDO API.
> >>>> > > >> > > >
> >>>> > > >> > > > As a quick code sketch:
> >>>> > > >> > > >
> >>>> > > >> > > > public interface CreateTrackingEntity {
> >>>> > > >> > > >     void setCreatedBy(String createdBy);
> >>>> > > >> > > >     void setCreatedOn(DateTime createdOn); }
> >>>> > > >> > > >
> >>>> > > >> > > > public interface ModifyTrackingEntity {
> >>>> > > >> > > >     void setModifiedBy(String username);
> >>>> > > >> > > >     void setModifiedOn(DateTime modifiedOn); }
> >>>> > > >> > > >
> >>>> > > >> > > >
> >>>> > > >> > > > Your entity should implement one or both of the above.
> >>>> > > >> > > >
> >>>> > > >> > > > Then, define a service such as:
> >>>> > > >> > > >
> >>>> > > >> > > > @RequestScoped
> >>>> > > >> > > > @DomainService(nature=NatureOfService.DOMAIN)
> >>>> > > >> > > > public class UpdateableEntityServices implements
> >>>> > > >> > > > javax.jdo.listener.StoreLifecycleListener {
> >>>> > > >> > > >
> >>>> > > >> > > >     @PostConstruct
> >>>> > > >> > > >     public void open() {
> >>>> > > >> > > >
> >>>> > > >> > > >
> >>>> > > >> > > >
> >>>> > > >> > >
> >>>> > > >> >
> >>>> > > >>
> >>>> > >
> >>>> >
> >>>>
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
> >>>> > > >> > > >     }
> >>>> > > >> > > >
> >>>> > > >> > > >     @PreDestroy
> >>>> > > >> > > >     public void close() {
> >>>> > > >> > > >
> >>>> > > >> > > >
> >>>> > > >> > > >
> >>>> > > >> > >
> >>>> > > >> >
> >>>> > > >>
> >>>> > >
> >>>> >
> >>>>
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
> >>>> > > >> > > >     }
> >>>> > > >> > > >
> >>>> > > >> > > >     @Programmatic
> >>>> > > >> > > >     public void preStore (InstanceLifecycleEvent event) {
> >>>> > > >> > > >
> >>>> > > >> > > >         final Object pi = event.getPersistentInstance();
> >>>> > > >> > > >
> >>>> > > >> > > >         if(pi instanceof
> >>>> > org.datanucleus.enhancement.Persistable)
> >>>> > > {
> >>>> > > >> > > >             boolean isPersistent =
> >>>> > > >> > > >
> >>>> ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
> >>>> > > >> > > >
> >>>> > > >> > > >             if(!isPersistent) {
> >>>> > > >> > > >                 if(pi instanceof CreateTrackingEntity) {
> >>>> > > >> > > >
> >>>> > > >> > > >
> >>>> > ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
> >>>> > > >> > > >
> >>>> > > >> > > >
> >>>> > > >>
> >>>> ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
> >>>> > > >> > > >                 }
> >>>> > > >> > > >             } else {
> >>>> > > >> > > >                 if(pi instanceof ModifyTrackingEntity) {
> >>>> > > >> > > >
> >>>> > > >> > > >
> >>>> > > ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
> >>>> > > >> > > >
> >>>> > > >> > > >
> >>>> > > >>
> >>>> ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
> >>>> > > >> > > >                 }
> >>>> > > >> > > >             }
> >>>> > > >> > > >         }
> >>>> > > >> > > >     }
> >>>> > > >> > > >
> >>>> > > >> > > >     @Programmatic
> >>>> > > >> > > >     public void postStore (InstanceLifecycleEvent event)
> {
> >>>> > > >> > > >         // no-op
> >>>> > > >> > > >     }
> >>>> > > >> > > >
> >>>> > > >> > > >     @Inject
> >>>> > > >> > > >     private DomainObjectContainer container;
> >>>> > > >> > > >
> >>>> > > >> > > >     @Inject
> >>>> > > >> > > >     private ClockService clockService;
> >>>> > > >> > > >
> >>>> > > >> > > >     @Inject
> >>>> > > >> > > >     private IsisJdoSupport isisJdoSupport;
> >>>> > > >> > > > }
> >>>> > > >> > > >
> >>>> > > >> > > >
> >>>> > > >> > > >
> >>>> > > >> > > > ~~~~~~~~~~~~
> >>>> > > >> > > > There is actually a ticket in JIRA for this [1], so I'll
> >>>> > formalize
> >>>> > > >> this
> >>>> > > >> > > as
> >>>> > > >> > > > a service in Isis 1.10.0.
> >>>> > > >> > > >
> >>>> > > >> > > > HTH
> >>>> > > >> > > > Dan
> >>>> > > >> > > >
> >>>> > > >> > > > [1] https://issues.apache.org/jira/browse/ISIS-867
> >>>> > > >> > > >
> >>>> > > >> > > >
> >>>> > > >> > > > On 16 September 2015 at 05:18, Stephen Cameron <
> >>>> > > >> > > steve.cameron.62@gmail.com
> >>>> > > >> > > > >
> >>>> > > >> > > > wrote:
> >>>> > > >> > > >
> >>>> > > >> > > > > Hi,
> >>>> > > >> > > > >
> >>>> > > >> > > > > Could someone please assist me in adding this
> >>>> capability, to
> >>>> > > >> automate
> >>>> > > >> > > the
> >>>> > > >> > > > > creation and update of values in these standard fields
> >>>> > > >> > > > >
> >>>> > > >> > > > > created_by
> >>>> > > >> > > > > created_on
> >>>> > > >> > > > > modified_by
> >>>> > > >> > > > > modified_on
> >>>> > > >> > > > >
> >>>> > > >> > > > > That is I need to set the first two on creating a new
> >>>> object,
> >>>> > > and
> >>>> > > >> the
> >>>> > > >> > > > last
> >>>> > > >> > > > > two on modifying an object.
> >>>> > > >> > > > >
> >>>> > > >> > > > > Thanks
> >>>> > > >> > > > > Steve Cameron
> >>>> > > >> > > > >
> >>>> > > >> > > >
> >>>> > > >> > >
> >>>> > > >> >
> >>>> > > >> >
> >>>> > > >> > ---
> >>>> > > >> > This email has been checked for viruses by Avast antivirus
> >>>> software.
> >>>> > > >> > https://www.avast.com/antivirus
> >>>> > > >> >
> >>>> > > >> >
> >>>> > > >>
> >>>> > > >
> >>>> > > >
> >>>> > >
> >>>> >
> >>>>
> >>>
> >>>
> >>
> >
>

Re: Automatic created-by and modified-by property updates

Posted by Stephen Cameron <st...@gmail.com>.
Ironic, in writing tests I added a constructor to inject the container but
forgot to add the default constructor to that one class. Feeling pleased
with myself at my use of TDD I then assumed it was going to 1.10.0-SNAPSHOT
that was the source of the error.

On Mon, Oct 26, 2015 at 7:51 AM, Stephen Cameron <steve.cameron.62@gmail.com
> wrote:

> Oops, embarrasement++ No public no-args constructor!
>
> On Sun, Oct 25, 2015 at 10:09 PM, Stephen Cameron <
> steve.cameron.62@gmail.com> wrote:
>
>> Just removing the 'offending' class allows the webapp to run... Will try
>> to figure out what it might be that is offensive tomorrow.
>>
>> On Sun, Oct 25, 2015 at 7:05 AM, Stephen Cameron <
>> steve.cameron.62@gmail.com> wrote:
>>
>>> Seems its not a classpath issue, the built jetty-console jar has the
>>> same problem, that has the app dom jar inside it. Not solved but I looking
>>> for an answer in the wrong place it appears.
>>>
>>> On Sat, Oct 24, 2015 at 9:32 PM, Dan Haywood <
>>> dan@haywood-associates.co.uk> wrote:
>>>
>>>> With Eclipse (as I'm sure you know) the m2e plugin generates the
>>>> .project
>>>> and .classpath files from the maven pom.xml files.  Doing an update
>>>> project
>>>> from the context menu of the package explorer view is generally pretty
>>>> reliable.  Thereafter Eclipse just uses its .classpath and .project.
>>>>
>>>> Another thing to do is to look at the dependency tree tab of the
>>>> pom.xml,
>>>> check it looks correct.  It's also possible to view the dependencies as
>>>> per
>>>> the .classpath file, by viewing the build path, eg [1]
>>>>
>>>> When you run the app up, the Debug view (IIRC) shows the actual Java
>>>> command that Eclipse constructs, along with all the JARs constructed
>>>> from
>>>> the classpath.  That might also provide some clues.
>>>>
>>>> HTH
>>>> Dan
>>>>
>>>>
>>>> [1] http://www.tutorialspoint.com/eclipse/eclipse_java_build_path.htm
>>>>
>>>> On 24 October 2015 at 11:27, Stephen Cameron <
>>>> steve.cameron.62@gmail.com>
>>>> wrote:
>>>>
>>>> > Hi
>>>> >
>>>> > I'll have another go tomorrow, I am using Eclipse and can get the
>>>> simpleapp
>>>> > on Isis 1.10.0 imported and webapp starting fine, its just when I try
>>>> to go
>>>> > from there by adding my dom classes and changing the dom module
>>>> 'marker'
>>>> > class something breaks, also going from a fresh install of my app and
>>>> > updating the poms from the simpleapp too.
>>>> >
>>>> > I assume if Guice cannot find a class file it gives that error, so its
>>>> > seems my classes are not be on the classpath, but as to why is where
>>>> my
>>>> > knowledge is not very good. I was just hoping someone else might have
>>>> had
>>>> > the same thing happen.
>>>> >
>>>> > On Sat, Oct 24, 2015 at 9:16 PM, Jeroen van der Wal <
>>>> jeroen@stromboli.it>
>>>> > wrote:
>>>> >
>>>> > > And removing ~/,m2/repository/org/apache/isis before mvn clean
>>>> install is
>>>> > > also worth trying.
>>>> > >
>>>> > > On 24 October 2015 at 12:13, Jeroen van der Wal <
>>>> jeroen@stromboli.it>
>>>> > > wrote:
>>>> > >
>>>> > > > You could try a mvn clean install and reimport the project into
>>>> > Intellij.
>>>> > > >
>>>> > > > On 24 October 2015 at 03:01, Stephen Cameron <
>>>> > steve.cameron.62@gmail.com
>>>> > > >
>>>> > > > wrote:
>>>> > > >
>>>> > > >> What do I have to change to go from 1.9.0 to 1.10.0-SNAPSHOT?
>>>> > > >>
>>>> > > >>  I just changed version number in pom.xml but then I get the
>>>> dreaded
>>>> > > guice
>>>> > > >> cannot instantiate class ... error, last time I fixed this by
>>>> updating
>>>> > > >> simpleapp with my classes.  Now it looks like the same thing is
>>>> > required
>>>> > > >> again to get a working version :(
>>>> > > >>
>>>> > > >>
>>>> > > >>
>>>> > > >> On Thu, Oct 22, 2015 at 12:44 AM, Cesar Lugo <
>>>> > cesar.lugo@sisorg.com.mx>
>>>> > > >> wrote:
>>>> > > >>
>>>> > > >> > Great!
>>>> > > >> >
>>>> > > >> > -----Original Message-----
>>>> > > >> > From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
>>>> > > >> > Sent: Wednesday, October 21, 2015 2:57 AM
>>>> > > >> > To: users
>>>> > > >> > Subject: Re: Automatic created-by and modified-by property
>>>> updates
>>>> > > >> >
>>>> > > >> > Just to close off this thread... in 1.10.0-SNAPSHOT there is
>>>> > built-in
>>>> > > >> > support for this feature... just implement Timetstampable [1]
>>>> > > >> >
>>>> > > >> > Cheers
>>>> > > >> > Dan
>>>> > > >> >
>>>> > > >> > [1] http://isis.apache.org/guides/rg.html#_rg_classes_roles
>>>> > > >> >
>>>> > > >> > On 28 September 2015 at 04:01, Stephen Cameron <
>>>> > > >> steve.cameron.62@gmail.com
>>>> > > >> > >
>>>> > > >> > wrote:
>>>> > > >> >
>>>> > > >> > > Hi Dan,
>>>> > > >> > >
>>>> > > >> > > I tried this and its not correct, I get the open and close
>>>> methods
>>>> > > >> > > being called over and over whenever I open and close an
>>>> object in
>>>> > > the
>>>> > > >> > > UI. but the jdo listener method preStore
>>>> (InstanceLifecycleEvent
>>>> > > >> > > event) never gets called.
>>>> > > >> > >
>>>> > > >> > > I pictured open()  and close() being called just once as the
>>>> > DOMAIN
>>>> > > >> > > service singleton is created by Isis and then it listens on
>>>> the
>>>> > JDO
>>>> > > >> > > events as each entity goes through its lifecycle.
>>>> > > >> > >
>>>> > > >> > >  I will put this aside as its not the main priority. I'll
>>>> read up
>>>> > > and
>>>> > > >> > > understand the jdo events to find an answer, this must be
>>>> close to
>>>> > > >> > correct.
>>>> > > >> > >
>>>> > > >> > >
>>>> > > >> > > On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood
>>>> > > >> > > <dan@haywood-associates.co.uk
>>>> > > >> > > >
>>>> > > >> > > wrote:
>>>> > > >> > >
>>>> > > >> > > > Hi Steve,
>>>> > > >> > > >
>>>> > > >> > > > Although there isn't any direct support for this, it's
>>>> should be
>>>> > > >> > > relatively
>>>> > > >> > > > easy to do by using the underlying JDO API.
>>>> > > >> > > >
>>>> > > >> > > > As a quick code sketch:
>>>> > > >> > > >
>>>> > > >> > > > public interface CreateTrackingEntity {
>>>> > > >> > > >     void setCreatedBy(String createdBy);
>>>> > > >> > > >     void setCreatedOn(DateTime createdOn); }
>>>> > > >> > > >
>>>> > > >> > > > public interface ModifyTrackingEntity {
>>>> > > >> > > >     void setModifiedBy(String username);
>>>> > > >> > > >     void setModifiedOn(DateTime modifiedOn); }
>>>> > > >> > > >
>>>> > > >> > > >
>>>> > > >> > > > Your entity should implement one or both of the above.
>>>> > > >> > > >
>>>> > > >> > > > Then, define a service such as:
>>>> > > >> > > >
>>>> > > >> > > > @RequestScoped
>>>> > > >> > > > @DomainService(nature=NatureOfService.DOMAIN)
>>>> > > >> > > > public class UpdateableEntityServices implements
>>>> > > >> > > > javax.jdo.listener.StoreLifecycleListener {
>>>> > > >> > > >
>>>> > > >> > > >     @PostConstruct
>>>> > > >> > > >     public void open() {
>>>> > > >> > > >
>>>> > > >> > > >
>>>> > > >> > > >
>>>> > > >> > >
>>>> > > >> >
>>>> > > >>
>>>> > >
>>>> >
>>>> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
>>>> > > >> > > >     }
>>>> > > >> > > >
>>>> > > >> > > >     @PreDestroy
>>>> > > >> > > >     public void close() {
>>>> > > >> > > >
>>>> > > >> > > >
>>>> > > >> > > >
>>>> > > >> > >
>>>> > > >> >
>>>> > > >>
>>>> > >
>>>> >
>>>> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
>>>> > > >> > > >     }
>>>> > > >> > > >
>>>> > > >> > > >     @Programmatic
>>>> > > >> > > >     public void preStore (InstanceLifecycleEvent event) {
>>>> > > >> > > >
>>>> > > >> > > >         final Object pi = event.getPersistentInstance();
>>>> > > >> > > >
>>>> > > >> > > >         if(pi instanceof
>>>> > org.datanucleus.enhancement.Persistable)
>>>> > > {
>>>> > > >> > > >             boolean isPersistent =
>>>> > > >> > > >
>>>> ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
>>>> > > >> > > >
>>>> > > >> > > >             if(!isPersistent) {
>>>> > > >> > > >                 if(pi instanceof CreateTrackingEntity) {
>>>> > > >> > > >
>>>> > > >> > > >
>>>> > ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
>>>> > > >> > > >
>>>> > > >> > > >
>>>> > > >>
>>>> ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
>>>> > > >> > > >                 }
>>>> > > >> > > >             } else {
>>>> > > >> > > >                 if(pi instanceof ModifyTrackingEntity) {
>>>> > > >> > > >
>>>> > > >> > > >
>>>> > > ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
>>>> > > >> > > >
>>>> > > >> > > >
>>>> > > >>
>>>> ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
>>>> > > >> > > >                 }
>>>> > > >> > > >             }
>>>> > > >> > > >         }
>>>> > > >> > > >     }
>>>> > > >> > > >
>>>> > > >> > > >     @Programmatic
>>>> > > >> > > >     public void postStore (InstanceLifecycleEvent event) {
>>>> > > >> > > >         // no-op
>>>> > > >> > > >     }
>>>> > > >> > > >
>>>> > > >> > > >     @Inject
>>>> > > >> > > >     private DomainObjectContainer container;
>>>> > > >> > > >
>>>> > > >> > > >     @Inject
>>>> > > >> > > >     private ClockService clockService;
>>>> > > >> > > >
>>>> > > >> > > >     @Inject
>>>> > > >> > > >     private IsisJdoSupport isisJdoSupport;
>>>> > > >> > > > }
>>>> > > >> > > >
>>>> > > >> > > >
>>>> > > >> > > >
>>>> > > >> > > > ~~~~~~~~~~~~
>>>> > > >> > > > There is actually a ticket in JIRA for this [1], so I'll
>>>> > formalize
>>>> > > >> this
>>>> > > >> > > as
>>>> > > >> > > > a service in Isis 1.10.0.
>>>> > > >> > > >
>>>> > > >> > > > HTH
>>>> > > >> > > > Dan
>>>> > > >> > > >
>>>> > > >> > > > [1] https://issues.apache.org/jira/browse/ISIS-867
>>>> > > >> > > >
>>>> > > >> > > >
>>>> > > >> > > > On 16 September 2015 at 05:18, Stephen Cameron <
>>>> > > >> > > steve.cameron.62@gmail.com
>>>> > > >> > > > >
>>>> > > >> > > > wrote:
>>>> > > >> > > >
>>>> > > >> > > > > Hi,
>>>> > > >> > > > >
>>>> > > >> > > > > Could someone please assist me in adding this
>>>> capability, to
>>>> > > >> automate
>>>> > > >> > > the
>>>> > > >> > > > > creation and update of values in these standard fields
>>>> > > >> > > > >
>>>> > > >> > > > > created_by
>>>> > > >> > > > > created_on
>>>> > > >> > > > > modified_by
>>>> > > >> > > > > modified_on
>>>> > > >> > > > >
>>>> > > >> > > > > That is I need to set the first two on creating a new
>>>> object,
>>>> > > and
>>>> > > >> the
>>>> > > >> > > > last
>>>> > > >> > > > > two on modifying an object.
>>>> > > >> > > > >
>>>> > > >> > > > > Thanks
>>>> > > >> > > > > Steve Cameron
>>>> > > >> > > > >
>>>> > > >> > > >
>>>> > > >> > >
>>>> > > >> >
>>>> > > >> >
>>>> > > >> > ---
>>>> > > >> > This email has been checked for viruses by Avast antivirus
>>>> software.
>>>> > > >> > https://www.avast.com/antivirus
>>>> > > >> >
>>>> > > >> >
>>>> > > >>
>>>> > > >
>>>> > > >
>>>> > >
>>>> >
>>>>
>>>
>>>
>>
>

Re: Automatic created-by and modified-by property updates

Posted by Stephen Cameron <st...@gmail.com>.
Oops, embarrasement++ No public no-args constructor!

On Sun, Oct 25, 2015 at 10:09 PM, Stephen Cameron <
steve.cameron.62@gmail.com> wrote:

> Just removing the 'offending' class allows the webapp to run... Will try
> to figure out what it might be that is offensive tomorrow.
>
> On Sun, Oct 25, 2015 at 7:05 AM, Stephen Cameron <
> steve.cameron.62@gmail.com> wrote:
>
>> Seems its not a classpath issue, the built jetty-console jar has the same
>> problem, that has the app dom jar inside it. Not solved but I looking for
>> an answer in the wrong place it appears.
>>
>> On Sat, Oct 24, 2015 at 9:32 PM, Dan Haywood <
>> dan@haywood-associates.co.uk> wrote:
>>
>>> With Eclipse (as I'm sure you know) the m2e plugin generates the .project
>>> and .classpath files from the maven pom.xml files.  Doing an update
>>> project
>>> from the context menu of the package explorer view is generally pretty
>>> reliable.  Thereafter Eclipse just uses its .classpath and .project.
>>>
>>> Another thing to do is to look at the dependency tree tab of the pom.xml,
>>> check it looks correct.  It's also possible to view the dependencies as
>>> per
>>> the .classpath file, by viewing the build path, eg [1]
>>>
>>> When you run the app up, the Debug view (IIRC) shows the actual Java
>>> command that Eclipse constructs, along with all the JARs constructed from
>>> the classpath.  That might also provide some clues.
>>>
>>> HTH
>>> Dan
>>>
>>>
>>> [1] http://www.tutorialspoint.com/eclipse/eclipse_java_build_path.htm
>>>
>>> On 24 October 2015 at 11:27, Stephen Cameron <steve.cameron.62@gmail.com
>>> >
>>> wrote:
>>>
>>> > Hi
>>> >
>>> > I'll have another go tomorrow, I am using Eclipse and can get the
>>> simpleapp
>>> > on Isis 1.10.0 imported and webapp starting fine, its just when I try
>>> to go
>>> > from there by adding my dom classes and changing the dom module
>>> 'marker'
>>> > class something breaks, also going from a fresh install of my app and
>>> > updating the poms from the simpleapp too.
>>> >
>>> > I assume if Guice cannot find a class file it gives that error, so its
>>> > seems my classes are not be on the classpath, but as to why is where my
>>> > knowledge is not very good. I was just hoping someone else might have
>>> had
>>> > the same thing happen.
>>> >
>>> > On Sat, Oct 24, 2015 at 9:16 PM, Jeroen van der Wal <
>>> jeroen@stromboli.it>
>>> > wrote:
>>> >
>>> > > And removing ~/,m2/repository/org/apache/isis before mvn clean
>>> install is
>>> > > also worth trying.
>>> > >
>>> > > On 24 October 2015 at 12:13, Jeroen van der Wal <jeroen@stromboli.it
>>> >
>>> > > wrote:
>>> > >
>>> > > > You could try a mvn clean install and reimport the project into
>>> > Intellij.
>>> > > >
>>> > > > On 24 October 2015 at 03:01, Stephen Cameron <
>>> > steve.cameron.62@gmail.com
>>> > > >
>>> > > > wrote:
>>> > > >
>>> > > >> What do I have to change to go from 1.9.0 to 1.10.0-SNAPSHOT?
>>> > > >>
>>> > > >>  I just changed version number in pom.xml but then I get the
>>> dreaded
>>> > > guice
>>> > > >> cannot instantiate class ... error, last time I fixed this by
>>> updating
>>> > > >> simpleapp with my classes.  Now it looks like the same thing is
>>> > required
>>> > > >> again to get a working version :(
>>> > > >>
>>> > > >>
>>> > > >>
>>> > > >> On Thu, Oct 22, 2015 at 12:44 AM, Cesar Lugo <
>>> > cesar.lugo@sisorg.com.mx>
>>> > > >> wrote:
>>> > > >>
>>> > > >> > Great!
>>> > > >> >
>>> > > >> > -----Original Message-----
>>> > > >> > From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
>>> > > >> > Sent: Wednesday, October 21, 2015 2:57 AM
>>> > > >> > To: users
>>> > > >> > Subject: Re: Automatic created-by and modified-by property
>>> updates
>>> > > >> >
>>> > > >> > Just to close off this thread... in 1.10.0-SNAPSHOT there is
>>> > built-in
>>> > > >> > support for this feature... just implement Timetstampable [1]
>>> > > >> >
>>> > > >> > Cheers
>>> > > >> > Dan
>>> > > >> >
>>> > > >> > [1] http://isis.apache.org/guides/rg.html#_rg_classes_roles
>>> > > >> >
>>> > > >> > On 28 September 2015 at 04:01, Stephen Cameron <
>>> > > >> steve.cameron.62@gmail.com
>>> > > >> > >
>>> > > >> > wrote:
>>> > > >> >
>>> > > >> > > Hi Dan,
>>> > > >> > >
>>> > > >> > > I tried this and its not correct, I get the open and close
>>> methods
>>> > > >> > > being called over and over whenever I open and close an
>>> object in
>>> > > the
>>> > > >> > > UI. but the jdo listener method preStore
>>> (InstanceLifecycleEvent
>>> > > >> > > event) never gets called.
>>> > > >> > >
>>> > > >> > > I pictured open()  and close() being called just once as the
>>> > DOMAIN
>>> > > >> > > service singleton is created by Isis and then it listens on
>>> the
>>> > JDO
>>> > > >> > > events as each entity goes through its lifecycle.
>>> > > >> > >
>>> > > >> > >  I will put this aside as its not the main priority. I'll
>>> read up
>>> > > and
>>> > > >> > > understand the jdo events to find an answer, this must be
>>> close to
>>> > > >> > correct.
>>> > > >> > >
>>> > > >> > >
>>> > > >> > > On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood
>>> > > >> > > <dan@haywood-associates.co.uk
>>> > > >> > > >
>>> > > >> > > wrote:
>>> > > >> > >
>>> > > >> > > > Hi Steve,
>>> > > >> > > >
>>> > > >> > > > Although there isn't any direct support for this, it's
>>> should be
>>> > > >> > > relatively
>>> > > >> > > > easy to do by using the underlying JDO API.
>>> > > >> > > >
>>> > > >> > > > As a quick code sketch:
>>> > > >> > > >
>>> > > >> > > > public interface CreateTrackingEntity {
>>> > > >> > > >     void setCreatedBy(String createdBy);
>>> > > >> > > >     void setCreatedOn(DateTime createdOn); }
>>> > > >> > > >
>>> > > >> > > > public interface ModifyTrackingEntity {
>>> > > >> > > >     void setModifiedBy(String username);
>>> > > >> > > >     void setModifiedOn(DateTime modifiedOn); }
>>> > > >> > > >
>>> > > >> > > >
>>> > > >> > > > Your entity should implement one or both of the above.
>>> > > >> > > >
>>> > > >> > > > Then, define a service such as:
>>> > > >> > > >
>>> > > >> > > > @RequestScoped
>>> > > >> > > > @DomainService(nature=NatureOfService.DOMAIN)
>>> > > >> > > > public class UpdateableEntityServices implements
>>> > > >> > > > javax.jdo.listener.StoreLifecycleListener {
>>> > > >> > > >
>>> > > >> > > >     @PostConstruct
>>> > > >> > > >     public void open() {
>>> > > >> > > >
>>> > > >> > > >
>>> > > >> > > >
>>> > > >> > >
>>> > > >> >
>>> > > >>
>>> > >
>>> >
>>> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
>>> > > >> > > >     }
>>> > > >> > > >
>>> > > >> > > >     @PreDestroy
>>> > > >> > > >     public void close() {
>>> > > >> > > >
>>> > > >> > > >
>>> > > >> > > >
>>> > > >> > >
>>> > > >> >
>>> > > >>
>>> > >
>>> >
>>> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
>>> > > >> > > >     }
>>> > > >> > > >
>>> > > >> > > >     @Programmatic
>>> > > >> > > >     public void preStore (InstanceLifecycleEvent event) {
>>> > > >> > > >
>>> > > >> > > >         final Object pi = event.getPersistentInstance();
>>> > > >> > > >
>>> > > >> > > >         if(pi instanceof
>>> > org.datanucleus.enhancement.Persistable)
>>> > > {
>>> > > >> > > >             boolean isPersistent =
>>> > > >> > > >
>>> ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
>>> > > >> > > >
>>> > > >> > > >             if(!isPersistent) {
>>> > > >> > > >                 if(pi instanceof CreateTrackingEntity) {
>>> > > >> > > >
>>> > > >> > > >
>>> > ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
>>> > > >> > > >
>>> > > >> > > >
>>> > > >>
>>> ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
>>> > > >> > > >                 }
>>> > > >> > > >             } else {
>>> > > >> > > >                 if(pi instanceof ModifyTrackingEntity) {
>>> > > >> > > >
>>> > > >> > > >
>>> > > ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
>>> > > >> > > >
>>> > > >> > > >
>>> > > >>
>>> ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
>>> > > >> > > >                 }
>>> > > >> > > >             }
>>> > > >> > > >         }
>>> > > >> > > >     }
>>> > > >> > > >
>>> > > >> > > >     @Programmatic
>>> > > >> > > >     public void postStore (InstanceLifecycleEvent event) {
>>> > > >> > > >         // no-op
>>> > > >> > > >     }
>>> > > >> > > >
>>> > > >> > > >     @Inject
>>> > > >> > > >     private DomainObjectContainer container;
>>> > > >> > > >
>>> > > >> > > >     @Inject
>>> > > >> > > >     private ClockService clockService;
>>> > > >> > > >
>>> > > >> > > >     @Inject
>>> > > >> > > >     private IsisJdoSupport isisJdoSupport;
>>> > > >> > > > }
>>> > > >> > > >
>>> > > >> > > >
>>> > > >> > > >
>>> > > >> > > > ~~~~~~~~~~~~
>>> > > >> > > > There is actually a ticket in JIRA for this [1], so I'll
>>> > formalize
>>> > > >> this
>>> > > >> > > as
>>> > > >> > > > a service in Isis 1.10.0.
>>> > > >> > > >
>>> > > >> > > > HTH
>>> > > >> > > > Dan
>>> > > >> > > >
>>> > > >> > > > [1] https://issues.apache.org/jira/browse/ISIS-867
>>> > > >> > > >
>>> > > >> > > >
>>> > > >> > > > On 16 September 2015 at 05:18, Stephen Cameron <
>>> > > >> > > steve.cameron.62@gmail.com
>>> > > >> > > > >
>>> > > >> > > > wrote:
>>> > > >> > > >
>>> > > >> > > > > Hi,
>>> > > >> > > > >
>>> > > >> > > > > Could someone please assist me in adding this capability,
>>> to
>>> > > >> automate
>>> > > >> > > the
>>> > > >> > > > > creation and update of values in these standard fields
>>> > > >> > > > >
>>> > > >> > > > > created_by
>>> > > >> > > > > created_on
>>> > > >> > > > > modified_by
>>> > > >> > > > > modified_on
>>> > > >> > > > >
>>> > > >> > > > > That is I need to set the first two on creating a new
>>> object,
>>> > > and
>>> > > >> the
>>> > > >> > > > last
>>> > > >> > > > > two on modifying an object.
>>> > > >> > > > >
>>> > > >> > > > > Thanks
>>> > > >> > > > > Steve Cameron
>>> > > >> > > > >
>>> > > >> > > >
>>> > > >> > >
>>> > > >> >
>>> > > >> >
>>> > > >> > ---
>>> > > >> > This email has been checked for viruses by Avast antivirus
>>> software.
>>> > > >> > https://www.avast.com/antivirus
>>> > > >> >
>>> > > >> >
>>> > > >>
>>> > > >
>>> > > >
>>> > >
>>> >
>>>
>>
>>
>

Re: Automatic created-by and modified-by property updates

Posted by Stephen Cameron <st...@gmail.com>.
Just removing the 'offending' class allows the webapp to run... Will try to
figure out what it might be that is offensive tomorrow.

On Sun, Oct 25, 2015 at 7:05 AM, Stephen Cameron <steve.cameron.62@gmail.com
> wrote:

> Seems its not a classpath issue, the built jetty-console jar has the same
> problem, that has the app dom jar inside it. Not solved but I looking for
> an answer in the wrong place it appears.
>
> On Sat, Oct 24, 2015 at 9:32 PM, Dan Haywood <dan@haywood-associates.co.uk
> > wrote:
>
>> With Eclipse (as I'm sure you know) the m2e plugin generates the .project
>> and .classpath files from the maven pom.xml files.  Doing an update
>> project
>> from the context menu of the package explorer view is generally pretty
>> reliable.  Thereafter Eclipse just uses its .classpath and .project.
>>
>> Another thing to do is to look at the dependency tree tab of the pom.xml,
>> check it looks correct.  It's also possible to view the dependencies as
>> per
>> the .classpath file, by viewing the build path, eg [1]
>>
>> When you run the app up, the Debug view (IIRC) shows the actual Java
>> command that Eclipse constructs, along with all the JARs constructed from
>> the classpath.  That might also provide some clues.
>>
>> HTH
>> Dan
>>
>>
>> [1] http://www.tutorialspoint.com/eclipse/eclipse_java_build_path.htm
>>
>> On 24 October 2015 at 11:27, Stephen Cameron <st...@gmail.com>
>> wrote:
>>
>> > Hi
>> >
>> > I'll have another go tomorrow, I am using Eclipse and can get the
>> simpleapp
>> > on Isis 1.10.0 imported and webapp starting fine, its just when I try
>> to go
>> > from there by adding my dom classes and changing the dom module 'marker'
>> > class something breaks, also going from a fresh install of my app and
>> > updating the poms from the simpleapp too.
>> >
>> > I assume if Guice cannot find a class file it gives that error, so its
>> > seems my classes are not be on the classpath, but as to why is where my
>> > knowledge is not very good. I was just hoping someone else might have
>> had
>> > the same thing happen.
>> >
>> > On Sat, Oct 24, 2015 at 9:16 PM, Jeroen van der Wal <
>> jeroen@stromboli.it>
>> > wrote:
>> >
>> > > And removing ~/,m2/repository/org/apache/isis before mvn clean
>> install is
>> > > also worth trying.
>> > >
>> > > On 24 October 2015 at 12:13, Jeroen van der Wal <je...@stromboli.it>
>> > > wrote:
>> > >
>> > > > You could try a mvn clean install and reimport the project into
>> > Intellij.
>> > > >
>> > > > On 24 October 2015 at 03:01, Stephen Cameron <
>> > steve.cameron.62@gmail.com
>> > > >
>> > > > wrote:
>> > > >
>> > > >> What do I have to change to go from 1.9.0 to 1.10.0-SNAPSHOT?
>> > > >>
>> > > >>  I just changed version number in pom.xml but then I get the
>> dreaded
>> > > guice
>> > > >> cannot instantiate class ... error, last time I fixed this by
>> updating
>> > > >> simpleapp with my classes.  Now it looks like the same thing is
>> > required
>> > > >> again to get a working version :(
>> > > >>
>> > > >>
>> > > >>
>> > > >> On Thu, Oct 22, 2015 at 12:44 AM, Cesar Lugo <
>> > cesar.lugo@sisorg.com.mx>
>> > > >> wrote:
>> > > >>
>> > > >> > Great!
>> > > >> >
>> > > >> > -----Original Message-----
>> > > >> > From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
>> > > >> > Sent: Wednesday, October 21, 2015 2:57 AM
>> > > >> > To: users
>> > > >> > Subject: Re: Automatic created-by and modified-by property
>> updates
>> > > >> >
>> > > >> > Just to close off this thread... in 1.10.0-SNAPSHOT there is
>> > built-in
>> > > >> > support for this feature... just implement Timetstampable [1]
>> > > >> >
>> > > >> > Cheers
>> > > >> > Dan
>> > > >> >
>> > > >> > [1] http://isis.apache.org/guides/rg.html#_rg_classes_roles
>> > > >> >
>> > > >> > On 28 September 2015 at 04:01, Stephen Cameron <
>> > > >> steve.cameron.62@gmail.com
>> > > >> > >
>> > > >> > wrote:
>> > > >> >
>> > > >> > > Hi Dan,
>> > > >> > >
>> > > >> > > I tried this and its not correct, I get the open and close
>> methods
>> > > >> > > being called over and over whenever I open and close an object
>> in
>> > > the
>> > > >> > > UI. but the jdo listener method preStore
>> (InstanceLifecycleEvent
>> > > >> > > event) never gets called.
>> > > >> > >
>> > > >> > > I pictured open()  and close() being called just once as the
>> > DOMAIN
>> > > >> > > service singleton is created by Isis and then it listens on the
>> > JDO
>> > > >> > > events as each entity goes through its lifecycle.
>> > > >> > >
>> > > >> > >  I will put this aside as its not the main priority. I'll read
>> up
>> > > and
>> > > >> > > understand the jdo events to find an answer, this must be
>> close to
>> > > >> > correct.
>> > > >> > >
>> > > >> > >
>> > > >> > > On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood
>> > > >> > > <dan@haywood-associates.co.uk
>> > > >> > > >
>> > > >> > > wrote:
>> > > >> > >
>> > > >> > > > Hi Steve,
>> > > >> > > >
>> > > >> > > > Although there isn't any direct support for this, it's
>> should be
>> > > >> > > relatively
>> > > >> > > > easy to do by using the underlying JDO API.
>> > > >> > > >
>> > > >> > > > As a quick code sketch:
>> > > >> > > >
>> > > >> > > > public interface CreateTrackingEntity {
>> > > >> > > >     void setCreatedBy(String createdBy);
>> > > >> > > >     void setCreatedOn(DateTime createdOn); }
>> > > >> > > >
>> > > >> > > > public interface ModifyTrackingEntity {
>> > > >> > > >     void setModifiedBy(String username);
>> > > >> > > >     void setModifiedOn(DateTime modifiedOn); }
>> > > >> > > >
>> > > >> > > >
>> > > >> > > > Your entity should implement one or both of the above.
>> > > >> > > >
>> > > >> > > > Then, define a service such as:
>> > > >> > > >
>> > > >> > > > @RequestScoped
>> > > >> > > > @DomainService(nature=NatureOfService.DOMAIN)
>> > > >> > > > public class UpdateableEntityServices implements
>> > > >> > > > javax.jdo.listener.StoreLifecycleListener {
>> > > >> > > >
>> > > >> > > >     @PostConstruct
>> > > >> > > >     public void open() {
>> > > >> > > >
>> > > >> > > >
>> > > >> > > >
>> > > >> > >
>> > > >> >
>> > > >>
>> > >
>> >
>> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
>> > > >> > > >     }
>> > > >> > > >
>> > > >> > > >     @PreDestroy
>> > > >> > > >     public void close() {
>> > > >> > > >
>> > > >> > > >
>> > > >> > > >
>> > > >> > >
>> > > >> >
>> > > >>
>> > >
>> >
>> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
>> > > >> > > >     }
>> > > >> > > >
>> > > >> > > >     @Programmatic
>> > > >> > > >     public void preStore (InstanceLifecycleEvent event) {
>> > > >> > > >
>> > > >> > > >         final Object pi = event.getPersistentInstance();
>> > > >> > > >
>> > > >> > > >         if(pi instanceof
>> > org.datanucleus.enhancement.Persistable)
>> > > {
>> > > >> > > >             boolean isPersistent =
>> > > >> > > >
>> ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
>> > > >> > > >
>> > > >> > > >             if(!isPersistent) {
>> > > >> > > >                 if(pi instanceof CreateTrackingEntity) {
>> > > >> > > >
>> > > >> > > >
>> > ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
>> > > >> > > >
>> > > >> > > >
>> > > >>
>> ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
>> > > >> > > >                 }
>> > > >> > > >             } else {
>> > > >> > > >                 if(pi instanceof ModifyTrackingEntity) {
>> > > >> > > >
>> > > >> > > >
>> > > ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
>> > > >> > > >
>> > > >> > > >
>> > > >>
>> ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
>> > > >> > > >                 }
>> > > >> > > >             }
>> > > >> > > >         }
>> > > >> > > >     }
>> > > >> > > >
>> > > >> > > >     @Programmatic
>> > > >> > > >     public void postStore (InstanceLifecycleEvent event) {
>> > > >> > > >         // no-op
>> > > >> > > >     }
>> > > >> > > >
>> > > >> > > >     @Inject
>> > > >> > > >     private DomainObjectContainer container;
>> > > >> > > >
>> > > >> > > >     @Inject
>> > > >> > > >     private ClockService clockService;
>> > > >> > > >
>> > > >> > > >     @Inject
>> > > >> > > >     private IsisJdoSupport isisJdoSupport;
>> > > >> > > > }
>> > > >> > > >
>> > > >> > > >
>> > > >> > > >
>> > > >> > > > ~~~~~~~~~~~~
>> > > >> > > > There is actually a ticket in JIRA for this [1], so I'll
>> > formalize
>> > > >> this
>> > > >> > > as
>> > > >> > > > a service in Isis 1.10.0.
>> > > >> > > >
>> > > >> > > > HTH
>> > > >> > > > Dan
>> > > >> > > >
>> > > >> > > > [1] https://issues.apache.org/jira/browse/ISIS-867
>> > > >> > > >
>> > > >> > > >
>> > > >> > > > On 16 September 2015 at 05:18, Stephen Cameron <
>> > > >> > > steve.cameron.62@gmail.com
>> > > >> > > > >
>> > > >> > > > wrote:
>> > > >> > > >
>> > > >> > > > > Hi,
>> > > >> > > > >
>> > > >> > > > > Could someone please assist me in adding this capability,
>> to
>> > > >> automate
>> > > >> > > the
>> > > >> > > > > creation and update of values in these standard fields
>> > > >> > > > >
>> > > >> > > > > created_by
>> > > >> > > > > created_on
>> > > >> > > > > modified_by
>> > > >> > > > > modified_on
>> > > >> > > > >
>> > > >> > > > > That is I need to set the first two on creating a new
>> object,
>> > > and
>> > > >> the
>> > > >> > > > last
>> > > >> > > > > two on modifying an object.
>> > > >> > > > >
>> > > >> > > > > Thanks
>> > > >> > > > > Steve Cameron
>> > > >> > > > >
>> > > >> > > >
>> > > >> > >
>> > > >> >
>> > > >> >
>> > > >> > ---
>> > > >> > This email has been checked for viruses by Avast antivirus
>> software.
>> > > >> > https://www.avast.com/antivirus
>> > > >> >
>> > > >> >
>> > > >>
>> > > >
>> > > >
>> > >
>> >
>>
>
>

Re: Automatic created-by and modified-by property updates

Posted by Stephen Cameron <st...@gmail.com>.
Seems its not a classpath issue, the built jetty-console jar has the same
problem, that has the app dom jar inside it. Not solved but I looking for
an answer in the wrong place it appears.

On Sat, Oct 24, 2015 at 9:32 PM, Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> With Eclipse (as I'm sure you know) the m2e plugin generates the .project
> and .classpath files from the maven pom.xml files.  Doing an update project
> from the context menu of the package explorer view is generally pretty
> reliable.  Thereafter Eclipse just uses its .classpath and .project.
>
> Another thing to do is to look at the dependency tree tab of the pom.xml,
> check it looks correct.  It's also possible to view the dependencies as per
> the .classpath file, by viewing the build path, eg [1]
>
> When you run the app up, the Debug view (IIRC) shows the actual Java
> command that Eclipse constructs, along with all the JARs constructed from
> the classpath.  That might also provide some clues.
>
> HTH
> Dan
>
>
> [1] http://www.tutorialspoint.com/eclipse/eclipse_java_build_path.htm
>
> On 24 October 2015 at 11:27, Stephen Cameron <st...@gmail.com>
> wrote:
>
> > Hi
> >
> > I'll have another go tomorrow, I am using Eclipse and can get the
> simpleapp
> > on Isis 1.10.0 imported and webapp starting fine, its just when I try to
> go
> > from there by adding my dom classes and changing the dom module 'marker'
> > class something breaks, also going from a fresh install of my app and
> > updating the poms from the simpleapp too.
> >
> > I assume if Guice cannot find a class file it gives that error, so its
> > seems my classes are not be on the classpath, but as to why is where my
> > knowledge is not very good. I was just hoping someone else might have had
> > the same thing happen.
> >
> > On Sat, Oct 24, 2015 at 9:16 PM, Jeroen van der Wal <jeroen@stromboli.it
> >
> > wrote:
> >
> > > And removing ~/,m2/repository/org/apache/isis before mvn clean install
> is
> > > also worth trying.
> > >
> > > On 24 October 2015 at 12:13, Jeroen van der Wal <je...@stromboli.it>
> > > wrote:
> > >
> > > > You could try a mvn clean install and reimport the project into
> > Intellij.
> > > >
> > > > On 24 October 2015 at 03:01, Stephen Cameron <
> > steve.cameron.62@gmail.com
> > > >
> > > > wrote:
> > > >
> > > >> What do I have to change to go from 1.9.0 to 1.10.0-SNAPSHOT?
> > > >>
> > > >>  I just changed version number in pom.xml but then I get the dreaded
> > > guice
> > > >> cannot instantiate class ... error, last time I fixed this by
> updating
> > > >> simpleapp with my classes.  Now it looks like the same thing is
> > required
> > > >> again to get a working version :(
> > > >>
> > > >>
> > > >>
> > > >> On Thu, Oct 22, 2015 at 12:44 AM, Cesar Lugo <
> > cesar.lugo@sisorg.com.mx>
> > > >> wrote:
> > > >>
> > > >> > Great!
> > > >> >
> > > >> > -----Original Message-----
> > > >> > From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
> > > >> > Sent: Wednesday, October 21, 2015 2:57 AM
> > > >> > To: users
> > > >> > Subject: Re: Automatic created-by and modified-by property updates
> > > >> >
> > > >> > Just to close off this thread... in 1.10.0-SNAPSHOT there is
> > built-in
> > > >> > support for this feature... just implement Timetstampable [1]
> > > >> >
> > > >> > Cheers
> > > >> > Dan
> > > >> >
> > > >> > [1] http://isis.apache.org/guides/rg.html#_rg_classes_roles
> > > >> >
> > > >> > On 28 September 2015 at 04:01, Stephen Cameron <
> > > >> steve.cameron.62@gmail.com
> > > >> > >
> > > >> > wrote:
> > > >> >
> > > >> > > Hi Dan,
> > > >> > >
> > > >> > > I tried this and its not correct, I get the open and close
> methods
> > > >> > > being called over and over whenever I open and close an object
> in
> > > the
> > > >> > > UI. but the jdo listener method preStore (InstanceLifecycleEvent
> > > >> > > event) never gets called.
> > > >> > >
> > > >> > > I pictured open()  and close() being called just once as the
> > DOMAIN
> > > >> > > service singleton is created by Isis and then it listens on the
> > JDO
> > > >> > > events as each entity goes through its lifecycle.
> > > >> > >
> > > >> > >  I will put this aside as its not the main priority. I'll read
> up
> > > and
> > > >> > > understand the jdo events to find an answer, this must be close
> to
> > > >> > correct.
> > > >> > >
> > > >> > >
> > > >> > > On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood
> > > >> > > <dan@haywood-associates.co.uk
> > > >> > > >
> > > >> > > wrote:
> > > >> > >
> > > >> > > > Hi Steve,
> > > >> > > >
> > > >> > > > Although there isn't any direct support for this, it's should
> be
> > > >> > > relatively
> > > >> > > > easy to do by using the underlying JDO API.
> > > >> > > >
> > > >> > > > As a quick code sketch:
> > > >> > > >
> > > >> > > > public interface CreateTrackingEntity {
> > > >> > > >     void setCreatedBy(String createdBy);
> > > >> > > >     void setCreatedOn(DateTime createdOn); }
> > > >> > > >
> > > >> > > > public interface ModifyTrackingEntity {
> > > >> > > >     void setModifiedBy(String username);
> > > >> > > >     void setModifiedOn(DateTime modifiedOn); }
> > > >> > > >
> > > >> > > >
> > > >> > > > Your entity should implement one or both of the above.
> > > >> > > >
> > > >> > > > Then, define a service such as:
> > > >> > > >
> > > >> > > > @RequestScoped
> > > >> > > > @DomainService(nature=NatureOfService.DOMAIN)
> > > >> > > > public class UpdateableEntityServices implements
> > > >> > > > javax.jdo.listener.StoreLifecycleListener {
> > > >> > > >
> > > >> > > >     @PostConstruct
> > > >> > > >     public void open() {
> > > >> > > >
> > > >> > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
> > > >> > > >     }
> > > >> > > >
> > > >> > > >     @PreDestroy
> > > >> > > >     public void close() {
> > > >> > > >
> > > >> > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > >
> >
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
> > > >> > > >     }
> > > >> > > >
> > > >> > > >     @Programmatic
> > > >> > > >     public void preStore (InstanceLifecycleEvent event) {
> > > >> > > >
> > > >> > > >         final Object pi = event.getPersistentInstance();
> > > >> > > >
> > > >> > > >         if(pi instanceof
> > org.datanucleus.enhancement.Persistable)
> > > {
> > > >> > > >             boolean isPersistent =
> > > >> > > >
> ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
> > > >> > > >
> > > >> > > >             if(!isPersistent) {
> > > >> > > >                 if(pi instanceof CreateTrackingEntity) {
> > > >> > > >
> > > >> > > >
> > ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
> > > >> > > >
> > > >> > > >
> > > >>
> ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
> > > >> > > >                 }
> > > >> > > >             } else {
> > > >> > > >                 if(pi instanceof ModifyTrackingEntity) {
> > > >> > > >
> > > >> > > >
> > > ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
> > > >> > > >
> > > >> > > >
> > > >>
> ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
> > > >> > > >                 }
> > > >> > > >             }
> > > >> > > >         }
> > > >> > > >     }
> > > >> > > >
> > > >> > > >     @Programmatic
> > > >> > > >     public void postStore (InstanceLifecycleEvent event) {
> > > >> > > >         // no-op
> > > >> > > >     }
> > > >> > > >
> > > >> > > >     @Inject
> > > >> > > >     private DomainObjectContainer container;
> > > >> > > >
> > > >> > > >     @Inject
> > > >> > > >     private ClockService clockService;
> > > >> > > >
> > > >> > > >     @Inject
> > > >> > > >     private IsisJdoSupport isisJdoSupport;
> > > >> > > > }
> > > >> > > >
> > > >> > > >
> > > >> > > >
> > > >> > > > ~~~~~~~~~~~~
> > > >> > > > There is actually a ticket in JIRA for this [1], so I'll
> > formalize
> > > >> this
> > > >> > > as
> > > >> > > > a service in Isis 1.10.0.
> > > >> > > >
> > > >> > > > HTH
> > > >> > > > Dan
> > > >> > > >
> > > >> > > > [1] https://issues.apache.org/jira/browse/ISIS-867
> > > >> > > >
> > > >> > > >
> > > >> > > > On 16 September 2015 at 05:18, Stephen Cameron <
> > > >> > > steve.cameron.62@gmail.com
> > > >> > > > >
> > > >> > > > wrote:
> > > >> > > >
> > > >> > > > > Hi,
> > > >> > > > >
> > > >> > > > > Could someone please assist me in adding this capability, to
> > > >> automate
> > > >> > > the
> > > >> > > > > creation and update of values in these standard fields
> > > >> > > > >
> > > >> > > > > created_by
> > > >> > > > > created_on
> > > >> > > > > modified_by
> > > >> > > > > modified_on
> > > >> > > > >
> > > >> > > > > That is I need to set the first two on creating a new
> object,
> > > and
> > > >> the
> > > >> > > > last
> > > >> > > > > two on modifying an object.
> > > >> > > > >
> > > >> > > > > Thanks
> > > >> > > > > Steve Cameron
> > > >> > > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >> >
> > > >> > ---
> > > >> > This email has been checked for viruses by Avast antivirus
> software.
> > > >> > https://www.avast.com/antivirus
> > > >> >
> > > >> >
> > > >>
> > > >
> > > >
> > >
> >
>

Re: Automatic created-by and modified-by property updates

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
With Eclipse (as I'm sure you know) the m2e plugin generates the .project
and .classpath files from the maven pom.xml files.  Doing an update project
from the context menu of the package explorer view is generally pretty
reliable.  Thereafter Eclipse just uses its .classpath and .project.

Another thing to do is to look at the dependency tree tab of the pom.xml,
check it looks correct.  It's also possible to view the dependencies as per
the .classpath file, by viewing the build path, eg [1]

When you run the app up, the Debug view (IIRC) shows the actual Java
command that Eclipse constructs, along with all the JARs constructed from
the classpath.  That might also provide some clues.

HTH
Dan


[1] http://www.tutorialspoint.com/eclipse/eclipse_java_build_path.htm

On 24 October 2015 at 11:27, Stephen Cameron <st...@gmail.com>
wrote:

> Hi
>
> I'll have another go tomorrow, I am using Eclipse and can get the simpleapp
> on Isis 1.10.0 imported and webapp starting fine, its just when I try to go
> from there by adding my dom classes and changing the dom module 'marker'
> class something breaks, also going from a fresh install of my app and
> updating the poms from the simpleapp too.
>
> I assume if Guice cannot find a class file it gives that error, so its
> seems my classes are not be on the classpath, but as to why is where my
> knowledge is not very good. I was just hoping someone else might have had
> the same thing happen.
>
> On Sat, Oct 24, 2015 at 9:16 PM, Jeroen van der Wal <je...@stromboli.it>
> wrote:
>
> > And removing ~/,m2/repository/org/apache/isis before mvn clean install is
> > also worth trying.
> >
> > On 24 October 2015 at 12:13, Jeroen van der Wal <je...@stromboli.it>
> > wrote:
> >
> > > You could try a mvn clean install and reimport the project into
> Intellij.
> > >
> > > On 24 October 2015 at 03:01, Stephen Cameron <
> steve.cameron.62@gmail.com
> > >
> > > wrote:
> > >
> > >> What do I have to change to go from 1.9.0 to 1.10.0-SNAPSHOT?
> > >>
> > >>  I just changed version number in pom.xml but then I get the dreaded
> > guice
> > >> cannot instantiate class ... error, last time I fixed this by updating
> > >> simpleapp with my classes.  Now it looks like the same thing is
> required
> > >> again to get a working version :(
> > >>
> > >>
> > >>
> > >> On Thu, Oct 22, 2015 at 12:44 AM, Cesar Lugo <
> cesar.lugo@sisorg.com.mx>
> > >> wrote:
> > >>
> > >> > Great!
> > >> >
> > >> > -----Original Message-----
> > >> > From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
> > >> > Sent: Wednesday, October 21, 2015 2:57 AM
> > >> > To: users
> > >> > Subject: Re: Automatic created-by and modified-by property updates
> > >> >
> > >> > Just to close off this thread... in 1.10.0-SNAPSHOT there is
> built-in
> > >> > support for this feature... just implement Timetstampable [1]
> > >> >
> > >> > Cheers
> > >> > Dan
> > >> >
> > >> > [1] http://isis.apache.org/guides/rg.html#_rg_classes_roles
> > >> >
> > >> > On 28 September 2015 at 04:01, Stephen Cameron <
> > >> steve.cameron.62@gmail.com
> > >> > >
> > >> > wrote:
> > >> >
> > >> > > Hi Dan,
> > >> > >
> > >> > > I tried this and its not correct, I get the open and close methods
> > >> > > being called over and over whenever I open and close an object in
> > the
> > >> > > UI. but the jdo listener method preStore (InstanceLifecycleEvent
> > >> > > event) never gets called.
> > >> > >
> > >> > > I pictured open()  and close() being called just once as the
> DOMAIN
> > >> > > service singleton is created by Isis and then it listens on the
> JDO
> > >> > > events as each entity goes through its lifecycle.
> > >> > >
> > >> > >  I will put this aside as its not the main priority. I'll read up
> > and
> > >> > > understand the jdo events to find an answer, this must be close to
> > >> > correct.
> > >> > >
> > >> > >
> > >> > > On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood
> > >> > > <dan@haywood-associates.co.uk
> > >> > > >
> > >> > > wrote:
> > >> > >
> > >> > > > Hi Steve,
> > >> > > >
> > >> > > > Although there isn't any direct support for this, it's should be
> > >> > > relatively
> > >> > > > easy to do by using the underlying JDO API.
> > >> > > >
> > >> > > > As a quick code sketch:
> > >> > > >
> > >> > > > public interface CreateTrackingEntity {
> > >> > > >     void setCreatedBy(String createdBy);
> > >> > > >     void setCreatedOn(DateTime createdOn); }
> > >> > > >
> > >> > > > public interface ModifyTrackingEntity {
> > >> > > >     void setModifiedBy(String username);
> > >> > > >     void setModifiedOn(DateTime modifiedOn); }
> > >> > > >
> > >> > > >
> > >> > > > Your entity should implement one or both of the above.
> > >> > > >
> > >> > > > Then, define a service such as:
> > >> > > >
> > >> > > > @RequestScoped
> > >> > > > @DomainService(nature=NatureOfService.DOMAIN)
> > >> > > > public class UpdateableEntityServices implements
> > >> > > > javax.jdo.listener.StoreLifecycleListener {
> > >> > > >
> > >> > > >     @PostConstruct
> > >> > > >     public void open() {
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > >
> > >> >
> > >>
> >
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
> > >> > > >     }
> > >> > > >
> > >> > > >     @PreDestroy
> > >> > > >     public void close() {
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > >
> > >> >
> > >>
> >
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
> > >> > > >     }
> > >> > > >
> > >> > > >     @Programmatic
> > >> > > >     public void preStore (InstanceLifecycleEvent event) {
> > >> > > >
> > >> > > >         final Object pi = event.getPersistentInstance();
> > >> > > >
> > >> > > >         if(pi instanceof
> org.datanucleus.enhancement.Persistable)
> > {
> > >> > > >             boolean isPersistent =
> > >> > > > ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
> > >> > > >
> > >> > > >             if(!isPersistent) {
> > >> > > >                 if(pi instanceof CreateTrackingEntity) {
> > >> > > >
> > >> > > >
> ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
> > >> > > >
> > >> > > >
> > >> ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
> > >> > > >                 }
> > >> > > >             } else {
> > >> > > >                 if(pi instanceof ModifyTrackingEntity) {
> > >> > > >
> > >> > > >
> > ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
> > >> > > >
> > >> > > >
> > >> ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
> > >> > > >                 }
> > >> > > >             }
> > >> > > >         }
> > >> > > >     }
> > >> > > >
> > >> > > >     @Programmatic
> > >> > > >     public void postStore (InstanceLifecycleEvent event) {
> > >> > > >         // no-op
> > >> > > >     }
> > >> > > >
> > >> > > >     @Inject
> > >> > > >     private DomainObjectContainer container;
> > >> > > >
> > >> > > >     @Inject
> > >> > > >     private ClockService clockService;
> > >> > > >
> > >> > > >     @Inject
> > >> > > >     private IsisJdoSupport isisJdoSupport;
> > >> > > > }
> > >> > > >
> > >> > > >
> > >> > > >
> > >> > > > ~~~~~~~~~~~~
> > >> > > > There is actually a ticket in JIRA for this [1], so I'll
> formalize
> > >> this
> > >> > > as
> > >> > > > a service in Isis 1.10.0.
> > >> > > >
> > >> > > > HTH
> > >> > > > Dan
> > >> > > >
> > >> > > > [1] https://issues.apache.org/jira/browse/ISIS-867
> > >> > > >
> > >> > > >
> > >> > > > On 16 September 2015 at 05:18, Stephen Cameron <
> > >> > > steve.cameron.62@gmail.com
> > >> > > > >
> > >> > > > wrote:
> > >> > > >
> > >> > > > > Hi,
> > >> > > > >
> > >> > > > > Could someone please assist me in adding this capability, to
> > >> automate
> > >> > > the
> > >> > > > > creation and update of values in these standard fields
> > >> > > > >
> > >> > > > > created_by
> > >> > > > > created_on
> > >> > > > > modified_by
> > >> > > > > modified_on
> > >> > > > >
> > >> > > > > That is I need to set the first two on creating a new object,
> > and
> > >> the
> > >> > > > last
> > >> > > > > two on modifying an object.
> > >> > > > >
> > >> > > > > Thanks
> > >> > > > > Steve Cameron
> > >> > > > >
> > >> > > >
> > >> > >
> > >> >
> > >> >
> > >> > ---
> > >> > This email has been checked for viruses by Avast antivirus software.
> > >> > https://www.avast.com/antivirus
> > >> >
> > >> >
> > >>
> > >
> > >
> >
>

Re: Automatic created-by and modified-by property updates

Posted by Stephen Cameron <st...@gmail.com>.
Hi

I'll have another go tomorrow, I am using Eclipse and can get the simpleapp
on Isis 1.10.0 imported and webapp starting fine, its just when I try to go
from there by adding my dom classes and changing the dom module 'marker'
class something breaks, also going from a fresh install of my app and
updating the poms from the simpleapp too.

I assume if Guice cannot find a class file it gives that error, so its
seems my classes are not be on the classpath, but as to why is where my
knowledge is not very good. I was just hoping someone else might have had
the same thing happen.

On Sat, Oct 24, 2015 at 9:16 PM, Jeroen van der Wal <je...@stromboli.it>
wrote:

> And removing ~/,m2/repository/org/apache/isis before mvn clean install is
> also worth trying.
>
> On 24 October 2015 at 12:13, Jeroen van der Wal <je...@stromboli.it>
> wrote:
>
> > You could try a mvn clean install and reimport the project into Intellij.
> >
> > On 24 October 2015 at 03:01, Stephen Cameron <steve.cameron.62@gmail.com
> >
> > wrote:
> >
> >> What do I have to change to go from 1.9.0 to 1.10.0-SNAPSHOT?
> >>
> >>  I just changed version number in pom.xml but then I get the dreaded
> guice
> >> cannot instantiate class ... error, last time I fixed this by updating
> >> simpleapp with my classes.  Now it looks like the same thing is required
> >> again to get a working version :(
> >>
> >>
> >>
> >> On Thu, Oct 22, 2015 at 12:44 AM, Cesar Lugo <ce...@sisorg.com.mx>
> >> wrote:
> >>
> >> > Great!
> >> >
> >> > -----Original Message-----
> >> > From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
> >> > Sent: Wednesday, October 21, 2015 2:57 AM
> >> > To: users
> >> > Subject: Re: Automatic created-by and modified-by property updates
> >> >
> >> > Just to close off this thread... in 1.10.0-SNAPSHOT there is built-in
> >> > support for this feature... just implement Timetstampable [1]
> >> >
> >> > Cheers
> >> > Dan
> >> >
> >> > [1] http://isis.apache.org/guides/rg.html#_rg_classes_roles
> >> >
> >> > On 28 September 2015 at 04:01, Stephen Cameron <
> >> steve.cameron.62@gmail.com
> >> > >
> >> > wrote:
> >> >
> >> > > Hi Dan,
> >> > >
> >> > > I tried this and its not correct, I get the open and close methods
> >> > > being called over and over whenever I open and close an object in
> the
> >> > > UI. but the jdo listener method preStore (InstanceLifecycleEvent
> >> > > event) never gets called.
> >> > >
> >> > > I pictured open()  and close() being called just once as the DOMAIN
> >> > > service singleton is created by Isis and then it listens on the JDO
> >> > > events as each entity goes through its lifecycle.
> >> > >
> >> > >  I will put this aside as its not the main priority. I'll read up
> and
> >> > > understand the jdo events to find an answer, this must be close to
> >> > correct.
> >> > >
> >> > >
> >> > > On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood
> >> > > <dan@haywood-associates.co.uk
> >> > > >
> >> > > wrote:
> >> > >
> >> > > > Hi Steve,
> >> > > >
> >> > > > Although there isn't any direct support for this, it's should be
> >> > > relatively
> >> > > > easy to do by using the underlying JDO API.
> >> > > >
> >> > > > As a quick code sketch:
> >> > > >
> >> > > > public interface CreateTrackingEntity {
> >> > > >     void setCreatedBy(String createdBy);
> >> > > >     void setCreatedOn(DateTime createdOn); }
> >> > > >
> >> > > > public interface ModifyTrackingEntity {
> >> > > >     void setModifiedBy(String username);
> >> > > >     void setModifiedOn(DateTime modifiedOn); }
> >> > > >
> >> > > >
> >> > > > Your entity should implement one or both of the above.
> >> > > >
> >> > > > Then, define a service such as:
> >> > > >
> >> > > > @RequestScoped
> >> > > > @DomainService(nature=NatureOfService.DOMAIN)
> >> > > > public class UpdateableEntityServices implements
> >> > > > javax.jdo.listener.StoreLifecycleListener {
> >> > > >
> >> > > >     @PostConstruct
> >> > > >     public void open() {
> >> > > >
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
> >> > > >     }
> >> > > >
> >> > > >     @PreDestroy
> >> > > >     public void close() {
> >> > > >
> >> > > >
> >> > > >
> >> > >
> >> >
> >>
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
> >> > > >     }
> >> > > >
> >> > > >     @Programmatic
> >> > > >     public void preStore (InstanceLifecycleEvent event) {
> >> > > >
> >> > > >         final Object pi = event.getPersistentInstance();
> >> > > >
> >> > > >         if(pi instanceof org.datanucleus.enhancement.Persistable)
> {
> >> > > >             boolean isPersistent =
> >> > > > ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
> >> > > >
> >> > > >             if(!isPersistent) {
> >> > > >                 if(pi instanceof CreateTrackingEntity) {
> >> > > >
> >> > > >  ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
> >> > > >
> >> > > >
> >> ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
> >> > > >                 }
> >> > > >             } else {
> >> > > >                 if(pi instanceof ModifyTrackingEntity) {
> >> > > >
> >> > > >
> ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
> >> > > >
> >> > > >
> >> ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
> >> > > >                 }
> >> > > >             }
> >> > > >         }
> >> > > >     }
> >> > > >
> >> > > >     @Programmatic
> >> > > >     public void postStore (InstanceLifecycleEvent event) {
> >> > > >         // no-op
> >> > > >     }
> >> > > >
> >> > > >     @Inject
> >> > > >     private DomainObjectContainer container;
> >> > > >
> >> > > >     @Inject
> >> > > >     private ClockService clockService;
> >> > > >
> >> > > >     @Inject
> >> > > >     private IsisJdoSupport isisJdoSupport;
> >> > > > }
> >> > > >
> >> > > >
> >> > > >
> >> > > > ~~~~~~~~~~~~
> >> > > > There is actually a ticket in JIRA for this [1], so I'll formalize
> >> this
> >> > > as
> >> > > > a service in Isis 1.10.0.
> >> > > >
> >> > > > HTH
> >> > > > Dan
> >> > > >
> >> > > > [1] https://issues.apache.org/jira/browse/ISIS-867
> >> > > >
> >> > > >
> >> > > > On 16 September 2015 at 05:18, Stephen Cameron <
> >> > > steve.cameron.62@gmail.com
> >> > > > >
> >> > > > wrote:
> >> > > >
> >> > > > > Hi,
> >> > > > >
> >> > > > > Could someone please assist me in adding this capability, to
> >> automate
> >> > > the
> >> > > > > creation and update of values in these standard fields
> >> > > > >
> >> > > > > created_by
> >> > > > > created_on
> >> > > > > modified_by
> >> > > > > modified_on
> >> > > > >
> >> > > > > That is I need to set the first two on creating a new object,
> and
> >> the
> >> > > > last
> >> > > > > two on modifying an object.
> >> > > > >
> >> > > > > Thanks
> >> > > > > Steve Cameron
> >> > > > >
> >> > > >
> >> > >
> >> >
> >> >
> >> > ---
> >> > This email has been checked for viruses by Avast antivirus software.
> >> > https://www.avast.com/antivirus
> >> >
> >> >
> >>
> >
> >
>

Re: Automatic created-by and modified-by property updates

Posted by Jeroen van der Wal <je...@stromboli.it>.
And removing ~/,m2/repository/org/apache/isis before mvn clean install is
also worth trying.

On 24 October 2015 at 12:13, Jeroen van der Wal <je...@stromboli.it> wrote:

> You could try a mvn clean install and reimport the project into Intellij.
>
> On 24 October 2015 at 03:01, Stephen Cameron <st...@gmail.com>
> wrote:
>
>> What do I have to change to go from 1.9.0 to 1.10.0-SNAPSHOT?
>>
>>  I just changed version number in pom.xml but then I get the dreaded guice
>> cannot instantiate class ... error, last time I fixed this by updating
>> simpleapp with my classes.  Now it looks like the same thing is required
>> again to get a working version :(
>>
>>
>>
>> On Thu, Oct 22, 2015 at 12:44 AM, Cesar Lugo <ce...@sisorg.com.mx>
>> wrote:
>>
>> > Great!
>> >
>> > -----Original Message-----
>> > From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
>> > Sent: Wednesday, October 21, 2015 2:57 AM
>> > To: users
>> > Subject: Re: Automatic created-by and modified-by property updates
>> >
>> > Just to close off this thread... in 1.10.0-SNAPSHOT there is built-in
>> > support for this feature... just implement Timetstampable [1]
>> >
>> > Cheers
>> > Dan
>> >
>> > [1] http://isis.apache.org/guides/rg.html#_rg_classes_roles
>> >
>> > On 28 September 2015 at 04:01, Stephen Cameron <
>> steve.cameron.62@gmail.com
>> > >
>> > wrote:
>> >
>> > > Hi Dan,
>> > >
>> > > I tried this and its not correct, I get the open and close methods
>> > > being called over and over whenever I open and close an object in the
>> > > UI. but the jdo listener method preStore (InstanceLifecycleEvent
>> > > event) never gets called.
>> > >
>> > > I pictured open()  and close() being called just once as the DOMAIN
>> > > service singleton is created by Isis and then it listens on the JDO
>> > > events as each entity goes through its lifecycle.
>> > >
>> > >  I will put this aside as its not the main priority. I'll read up and
>> > > understand the jdo events to find an answer, this must be close to
>> > correct.
>> > >
>> > >
>> > > On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood
>> > > <dan@haywood-associates.co.uk
>> > > >
>> > > wrote:
>> > >
>> > > > Hi Steve,
>> > > >
>> > > > Although there isn't any direct support for this, it's should be
>> > > relatively
>> > > > easy to do by using the underlying JDO API.
>> > > >
>> > > > As a quick code sketch:
>> > > >
>> > > > public interface CreateTrackingEntity {
>> > > >     void setCreatedBy(String createdBy);
>> > > >     void setCreatedOn(DateTime createdOn); }
>> > > >
>> > > > public interface ModifyTrackingEntity {
>> > > >     void setModifiedBy(String username);
>> > > >     void setModifiedOn(DateTime modifiedOn); }
>> > > >
>> > > >
>> > > > Your entity should implement one or both of the above.
>> > > >
>> > > > Then, define a service such as:
>> > > >
>> > > > @RequestScoped
>> > > > @DomainService(nature=NatureOfService.DOMAIN)
>> > > > public class UpdateableEntityServices implements
>> > > > javax.jdo.listener.StoreLifecycleListener {
>> > > >
>> > > >     @PostConstruct
>> > > >     public void open() {
>> > > >
>> > > >
>> > > >
>> > >
>> >
>> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
>> > > >     }
>> > > >
>> > > >     @PreDestroy
>> > > >     public void close() {
>> > > >
>> > > >
>> > > >
>> > >
>> >
>> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
>> > > >     }
>> > > >
>> > > >     @Programmatic
>> > > >     public void preStore (InstanceLifecycleEvent event) {
>> > > >
>> > > >         final Object pi = event.getPersistentInstance();
>> > > >
>> > > >         if(pi instanceof org.datanucleus.enhancement.Persistable) {
>> > > >             boolean isPersistent =
>> > > > ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
>> > > >
>> > > >             if(!isPersistent) {
>> > > >                 if(pi instanceof CreateTrackingEntity) {
>> > > >
>> > > >  ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
>> > > >
>> > > >
>> ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
>> > > >                 }
>> > > >             } else {
>> > > >                 if(pi instanceof ModifyTrackingEntity) {
>> > > >
>> > > >  ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
>> > > >
>> > > >
>> ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
>> > > >                 }
>> > > >             }
>> > > >         }
>> > > >     }
>> > > >
>> > > >     @Programmatic
>> > > >     public void postStore (InstanceLifecycleEvent event) {
>> > > >         // no-op
>> > > >     }
>> > > >
>> > > >     @Inject
>> > > >     private DomainObjectContainer container;
>> > > >
>> > > >     @Inject
>> > > >     private ClockService clockService;
>> > > >
>> > > >     @Inject
>> > > >     private IsisJdoSupport isisJdoSupport;
>> > > > }
>> > > >
>> > > >
>> > > >
>> > > > ~~~~~~~~~~~~
>> > > > There is actually a ticket in JIRA for this [1], so I'll formalize
>> this
>> > > as
>> > > > a service in Isis 1.10.0.
>> > > >
>> > > > HTH
>> > > > Dan
>> > > >
>> > > > [1] https://issues.apache.org/jira/browse/ISIS-867
>> > > >
>> > > >
>> > > > On 16 September 2015 at 05:18, Stephen Cameron <
>> > > steve.cameron.62@gmail.com
>> > > > >
>> > > > wrote:
>> > > >
>> > > > > Hi,
>> > > > >
>> > > > > Could someone please assist me in adding this capability, to
>> automate
>> > > the
>> > > > > creation and update of values in these standard fields
>> > > > >
>> > > > > created_by
>> > > > > created_on
>> > > > > modified_by
>> > > > > modified_on
>> > > > >
>> > > > > That is I need to set the first two on creating a new object, and
>> the
>> > > > last
>> > > > > two on modifying an object.
>> > > > >
>> > > > > Thanks
>> > > > > Steve Cameron
>> > > > >
>> > > >
>> > >
>> >
>> >
>> > ---
>> > This email has been checked for viruses by Avast antivirus software.
>> > https://www.avast.com/antivirus
>> >
>> >
>>
>
>

Re: Automatic created-by and modified-by property updates

Posted by Jeroen van der Wal <je...@stromboli.it>.
You could try a mvn clean install and reimport the project into Intellij.

On 24 October 2015 at 03:01, Stephen Cameron <st...@gmail.com>
wrote:

> What do I have to change to go from 1.9.0 to 1.10.0-SNAPSHOT?
>
>  I just changed version number in pom.xml but then I get the dreaded guice
> cannot instantiate class ... error, last time I fixed this by updating
> simpleapp with my classes.  Now it looks like the same thing is required
> again to get a working version :(
>
>
>
> On Thu, Oct 22, 2015 at 12:44 AM, Cesar Lugo <ce...@sisorg.com.mx>
> wrote:
>
> > Great!
> >
> > -----Original Message-----
> > From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
> > Sent: Wednesday, October 21, 2015 2:57 AM
> > To: users
> > Subject: Re: Automatic created-by and modified-by property updates
> >
> > Just to close off this thread... in 1.10.0-SNAPSHOT there is built-in
> > support for this feature... just implement Timetstampable [1]
> >
> > Cheers
> > Dan
> >
> > [1] http://isis.apache.org/guides/rg.html#_rg_classes_roles
> >
> > On 28 September 2015 at 04:01, Stephen Cameron <
> steve.cameron.62@gmail.com
> > >
> > wrote:
> >
> > > Hi Dan,
> > >
> > > I tried this and its not correct, I get the open and close methods
> > > being called over and over whenever I open and close an object in the
> > > UI. but the jdo listener method preStore (InstanceLifecycleEvent
> > > event) never gets called.
> > >
> > > I pictured open()  and close() being called just once as the DOMAIN
> > > service singleton is created by Isis and then it listens on the JDO
> > > events as each entity goes through its lifecycle.
> > >
> > >  I will put this aside as its not the main priority. I'll read up and
> > > understand the jdo events to find an answer, this must be close to
> > correct.
> > >
> > >
> > > On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood
> > > <dan@haywood-associates.co.uk
> > > >
> > > wrote:
> > >
> > > > Hi Steve,
> > > >
> > > > Although there isn't any direct support for this, it's should be
> > > relatively
> > > > easy to do by using the underlying JDO API.
> > > >
> > > > As a quick code sketch:
> > > >
> > > > public interface CreateTrackingEntity {
> > > >     void setCreatedBy(String createdBy);
> > > >     void setCreatedOn(DateTime createdOn); }
> > > >
> > > > public interface ModifyTrackingEntity {
> > > >     void setModifiedBy(String username);
> > > >     void setModifiedOn(DateTime modifiedOn); }
> > > >
> > > >
> > > > Your entity should implement one or both of the above.
> > > >
> > > > Then, define a service such as:
> > > >
> > > > @RequestScoped
> > > > @DomainService(nature=NatureOfService.DOMAIN)
> > > > public class UpdateableEntityServices implements
> > > > javax.jdo.listener.StoreLifecycleListener {
> > > >
> > > >     @PostConstruct
> > > >     public void open() {
> > > >
> > > >
> > > >
> > >
> >
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
> > > >     }
> > > >
> > > >     @PreDestroy
> > > >     public void close() {
> > > >
> > > >
> > > >
> > >
> >
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
> > > >     }
> > > >
> > > >     @Programmatic
> > > >     public void preStore (InstanceLifecycleEvent event) {
> > > >
> > > >         final Object pi = event.getPersistentInstance();
> > > >
> > > >         if(pi instanceof org.datanucleus.enhancement.Persistable) {
> > > >             boolean isPersistent =
> > > > ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
> > > >
> > > >             if(!isPersistent) {
> > > >                 if(pi instanceof CreateTrackingEntity) {
> > > >
> > > >  ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
> > > >
> > > >
> ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
> > > >                 }
> > > >             } else {
> > > >                 if(pi instanceof ModifyTrackingEntity) {
> > > >
> > > >  ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
> > > >
> > > >
> ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
> > > >                 }
> > > >             }
> > > >         }
> > > >     }
> > > >
> > > >     @Programmatic
> > > >     public void postStore (InstanceLifecycleEvent event) {
> > > >         // no-op
> > > >     }
> > > >
> > > >     @Inject
> > > >     private DomainObjectContainer container;
> > > >
> > > >     @Inject
> > > >     private ClockService clockService;
> > > >
> > > >     @Inject
> > > >     private IsisJdoSupport isisJdoSupport;
> > > > }
> > > >
> > > >
> > > >
> > > > ~~~~~~~~~~~~
> > > > There is actually a ticket in JIRA for this [1], so I'll formalize
> this
> > > as
> > > > a service in Isis 1.10.0.
> > > >
> > > > HTH
> > > > Dan
> > > >
> > > > [1] https://issues.apache.org/jira/browse/ISIS-867
> > > >
> > > >
> > > > On 16 September 2015 at 05:18, Stephen Cameron <
> > > steve.cameron.62@gmail.com
> > > > >
> > > > wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > Could someone please assist me in adding this capability, to
> automate
> > > the
> > > > > creation and update of values in these standard fields
> > > > >
> > > > > created_by
> > > > > created_on
> > > > > modified_by
> > > > > modified_on
> > > > >
> > > > > That is I need to set the first two on creating a new object, and
> the
> > > > last
> > > > > two on modifying an object.
> > > > >
> > > > > Thanks
> > > > > Steve Cameron
> > > > >
> > > >
> > >
> >
> >
> > ---
> > This email has been checked for viruses by Avast antivirus software.
> > https://www.avast.com/antivirus
> >
> >
>

Re: Automatic created-by and modified-by property updates

Posted by Stephen Cameron <st...@gmail.com>.
What do I have to change to go from 1.9.0 to 1.10.0-SNAPSHOT?

 I just changed version number in pom.xml but then I get the dreaded guice
cannot instantiate class ... error, last time I fixed this by updating
simpleapp with my classes.  Now it looks like the same thing is required
again to get a working version :(



On Thu, Oct 22, 2015 at 12:44 AM, Cesar Lugo <ce...@sisorg.com.mx>
wrote:

> Great!
>
> -----Original Message-----
> From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
> Sent: Wednesday, October 21, 2015 2:57 AM
> To: users
> Subject: Re: Automatic created-by and modified-by property updates
>
> Just to close off this thread... in 1.10.0-SNAPSHOT there is built-in
> support for this feature... just implement Timetstampable [1]
>
> Cheers
> Dan
>
> [1] http://isis.apache.org/guides/rg.html#_rg_classes_roles
>
> On 28 September 2015 at 04:01, Stephen Cameron <steve.cameron.62@gmail.com
> >
> wrote:
>
> > Hi Dan,
> >
> > I tried this and its not correct, I get the open and close methods
> > being called over and over whenever I open and close an object in the
> > UI. but the jdo listener method preStore (InstanceLifecycleEvent
> > event) never gets called.
> >
> > I pictured open()  and close() being called just once as the DOMAIN
> > service singleton is created by Isis and then it listens on the JDO
> > events as each entity goes through its lifecycle.
> >
> >  I will put this aside as its not the main priority. I'll read up and
> > understand the jdo events to find an answer, this must be close to
> correct.
> >
> >
> > On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood
> > <dan@haywood-associates.co.uk
> > >
> > wrote:
> >
> > > Hi Steve,
> > >
> > > Although there isn't any direct support for this, it's should be
> > relatively
> > > easy to do by using the underlying JDO API.
> > >
> > > As a quick code sketch:
> > >
> > > public interface CreateTrackingEntity {
> > >     void setCreatedBy(String createdBy);
> > >     void setCreatedOn(DateTime createdOn); }
> > >
> > > public interface ModifyTrackingEntity {
> > >     void setModifiedBy(String username);
> > >     void setModifiedOn(DateTime modifiedOn); }
> > >
> > >
> > > Your entity should implement one or both of the above.
> > >
> > > Then, define a service such as:
> > >
> > > @RequestScoped
> > > @DomainService(nature=NatureOfService.DOMAIN)
> > > public class UpdateableEntityServices implements
> > > javax.jdo.listener.StoreLifecycleListener {
> > >
> > >     @PostConstruct
> > >     public void open() {
> > >
> > >
> > >
> >
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
> > >     }
> > >
> > >     @PreDestroy
> > >     public void close() {
> > >
> > >
> > >
> >
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
> > >     }
> > >
> > >     @Programmatic
> > >     public void preStore (InstanceLifecycleEvent event) {
> > >
> > >         final Object pi = event.getPersistentInstance();
> > >
> > >         if(pi instanceof org.datanucleus.enhancement.Persistable) {
> > >             boolean isPersistent =
> > > ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
> > >
> > >             if(!isPersistent) {
> > >                 if(pi instanceof CreateTrackingEntity) {
> > >
> > >  ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
> > >
> > >  ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
> > >                 }
> > >             } else {
> > >                 if(pi instanceof ModifyTrackingEntity) {
> > >
> > >  ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
> > >
> > >  ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
> > >                 }
> > >             }
> > >         }
> > >     }
> > >
> > >     @Programmatic
> > >     public void postStore (InstanceLifecycleEvent event) {
> > >         // no-op
> > >     }
> > >
> > >     @Inject
> > >     private DomainObjectContainer container;
> > >
> > >     @Inject
> > >     private ClockService clockService;
> > >
> > >     @Inject
> > >     private IsisJdoSupport isisJdoSupport;
> > > }
> > >
> > >
> > >
> > > ~~~~~~~~~~~~
> > > There is actually a ticket in JIRA for this [1], so I'll formalize this
> > as
> > > a service in Isis 1.10.0.
> > >
> > > HTH
> > > Dan
> > >
> > > [1] https://issues.apache.org/jira/browse/ISIS-867
> > >
> > >
> > > On 16 September 2015 at 05:18, Stephen Cameron <
> > steve.cameron.62@gmail.com
> > > >
> > > wrote:
> > >
> > > > Hi,
> > > >
> > > > Could someone please assist me in adding this capability, to automate
> > the
> > > > creation and update of values in these standard fields
> > > >
> > > > created_by
> > > > created_on
> > > > modified_by
> > > > modified_on
> > > >
> > > > That is I need to set the first two on creating a new object, and the
> > > last
> > > > two on modifying an object.
> > > >
> > > > Thanks
> > > > Steve Cameron
> > > >
> > >
> >
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>
>

Re: Automatic created-by and modified-by property updates

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Just to close off this thread... in 1.10.0-SNAPSHOT there is built-in
support for this feature... just implement Timetstampable [1]

Cheers
Dan

[1] http://isis.apache.org/guides/rg.html#_rg_classes_roles

On 28 September 2015 at 04:01, Stephen Cameron <st...@gmail.com>
wrote:

> Hi Dan,
>
> I tried this and its not correct, I get the open and close methods being
> called over and over whenever I open and close an object in the UI. but the
> jdo listener method preStore (InstanceLifecycleEvent event) never gets
> called.
>
> I pictured open()  and close() being called just once as the DOMAIN service
> singleton is created by Isis and then it listens on the JDO events as each
> entity goes through its lifecycle.
>
>  I will put this aside as its not the main priority. I'll read up and
> understand the jdo events to find an answer, this must be close to correct.
>
>
> On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood <dan@haywood-associates.co.uk
> >
> wrote:
>
> > Hi Steve,
> >
> > Although there isn't any direct support for this, it's should be
> relatively
> > easy to do by using the underlying JDO API.
> >
> > As a quick code sketch:
> >
> > public interface CreateTrackingEntity {
> >     void setCreatedBy(String createdBy);
> >     void setCreatedOn(DateTime createdOn);
> > }
> >
> > public interface ModifyTrackingEntity {
> >     void setModifiedBy(String username);
> >     void setModifiedOn(DateTime modifiedOn);
> > }
> >
> >
> > Your entity should implement one or both of the above.
> >
> > Then, define a service such as:
> >
> > @RequestScoped
> > @DomainService(nature=NatureOfService.DOMAIN)
> > public class UpdateableEntityServices implements
> > javax.jdo.listener.StoreLifecycleListener {
> >
> >     @PostConstruct
> >     public void open() {
> >
> >
> >
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
> >     }
> >
> >     @PreDestroy
> >     public void close() {
> >
> >
> >
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
> >     }
> >
> >     @Programmatic
> >     public void preStore (InstanceLifecycleEvent event) {
> >
> >         final Object pi = event.getPersistentInstance();
> >
> >         if(pi instanceof org.datanucleus.enhancement.Persistable) {
> >             boolean isPersistent =
> > ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
> >
> >             if(!isPersistent) {
> >                 if(pi instanceof CreateTrackingEntity) {
> >
> >  ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
> >
> >  ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
> >                 }
> >             } else {
> >                 if(pi instanceof ModifyTrackingEntity) {
> >
> >  ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
> >
> >  ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
> >                 }
> >             }
> >         }
> >     }
> >
> >     @Programmatic
> >     public void postStore (InstanceLifecycleEvent event) {
> >         // no-op
> >     }
> >
> >     @Inject
> >     private DomainObjectContainer container;
> >
> >     @Inject
> >     private ClockService clockService;
> >
> >     @Inject
> >     private IsisJdoSupport isisJdoSupport;
> > }
> >
> >
> >
> > ~~~~~~~~~~~~
> > There is actually a ticket in JIRA for this [1], so I'll formalize this
> as
> > a service in Isis 1.10.0.
> >
> > HTH
> > Dan
> >
> > [1] https://issues.apache.org/jira/browse/ISIS-867
> >
> >
> > On 16 September 2015 at 05:18, Stephen Cameron <
> steve.cameron.62@gmail.com
> > >
> > wrote:
> >
> > > Hi,
> > >
> > > Could someone please assist me in adding this capability, to automate
> the
> > > creation and update of values in these standard fields
> > >
> > > created_by
> > > created_on
> > > modified_by
> > > modified_on
> > >
> > > That is I need to set the first two on creating a new object, and the
> > last
> > > two on modifying an object.
> > >
> > > Thanks
> > > Steve Cameron
> > >
> >
>

Re: Automatic created-by and modified-by property updates

Posted by Stephen Cameron <st...@gmail.com>.
Hi Dan,

I tried this and its not correct, I get the open and close methods being
called over and over whenever I open and close an object in the UI. but the
jdo listener method preStore (InstanceLifecycleEvent event) never gets
called.

I pictured open()  and close() being called just once as the DOMAIN service
singleton is created by Isis and then it listens on the JDO events as each
entity goes through its lifecycle.

 I will put this aside as its not the main priority. I'll read up and
understand the jdo events to find an answer, this must be close to correct.


On Wed, Sep 16, 2015 at 4:02 PM, Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> Hi Steve,
>
> Although there isn't any direct support for this, it's should be relatively
> easy to do by using the underlying JDO API.
>
> As a quick code sketch:
>
> public interface CreateTrackingEntity {
>     void setCreatedBy(String createdBy);
>     void setCreatedOn(DateTime createdOn);
> }
>
> public interface ModifyTrackingEntity {
>     void setModifiedBy(String username);
>     void setModifiedOn(DateTime modifiedOn);
> }
>
>
> Your entity should implement one or both of the above.
>
> Then, define a service such as:
>
> @RequestScoped
> @DomainService(nature=NatureOfService.DOMAIN)
> public class UpdateableEntityServices implements
> javax.jdo.listener.StoreLifecycleListener {
>
>     @PostConstruct
>     public void open() {
>
>
> isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
>     }
>
>     @PreDestroy
>     public void close() {
>
>
> isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
>     }
>
>     @Programmatic
>     public void preStore (InstanceLifecycleEvent event) {
>
>         final Object pi = event.getPersistentInstance();
>
>         if(pi instanceof org.datanucleus.enhancement.Persistable) {
>             boolean isPersistent =
> ((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();
>
>             if(!isPersistent) {
>                 if(pi instanceof CreateTrackingEntity) {
>
>  ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());
>
>  ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
>                 }
>             } else {
>                 if(pi instanceof ModifyTrackingEntity) {
>
>  ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());
>
>  ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
>                 }
>             }
>         }
>     }
>
>     @Programmatic
>     public void postStore (InstanceLifecycleEvent event) {
>         // no-op
>     }
>
>     @Inject
>     private DomainObjectContainer container;
>
>     @Inject
>     private ClockService clockService;
>
>     @Inject
>     private IsisJdoSupport isisJdoSupport;
> }
>
>
>
> ~~~~~~~~~~~~
> There is actually a ticket in JIRA for this [1], so I'll formalize this as
> a service in Isis 1.10.0.
>
> HTH
> Dan
>
> [1] https://issues.apache.org/jira/browse/ISIS-867
>
>
> On 16 September 2015 at 05:18, Stephen Cameron <steve.cameron.62@gmail.com
> >
> wrote:
>
> > Hi,
> >
> > Could someone please assist me in adding this capability, to automate the
> > creation and update of values in these standard fields
> >
> > created_by
> > created_on
> > modified_by
> > modified_on
> >
> > That is I need to set the first two on creating a new object, and the
> last
> > two on modifying an object.
> >
> > Thanks
> > Steve Cameron
> >
>

Re: Automatic created-by and modified-by property updates

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
Hi Steve,

Although there isn't any direct support for this, it's should be relatively
easy to do by using the underlying JDO API.

As a quick code sketch:

public interface CreateTrackingEntity {
    void setCreatedBy(String createdBy);
    void setCreatedOn(DateTime createdOn);
}

public interface ModifyTrackingEntity {
    void setModifiedBy(String username);
    void setModifiedOn(DateTime modifiedOn);
}


Your entity should implement one or both of the above.

Then, define a service such as:

@RequestScoped
@DomainService(nature=NatureOfService.DOMAIN)
public class UpdateableEntityServices implements
javax.jdo.listener.StoreLifecycleListener {

    @PostConstruct
    public void open() {

isisJdoSupport.getJdoPersistenceManager().addInstanceLifecycleListener(this);
    }

    @PreDestroy
    public void close() {

isisJdoSupport.getJdoPersistenceManager().removeInstanceLifecycleListener(this);
    }

    @Programmatic
    public void preStore (InstanceLifecycleEvent event) {

        final Object pi = event.getPersistentInstance();

        if(pi instanceof org.datanucleus.enhancement.Persistable) {
            boolean isPersistent =
((org.datanucleus.enhancement.Persistable)pi).dnIsPersistent();

            if(!isPersistent) {
                if(pi instanceof CreateTrackingEntity) {

 ((CreateTrackingEntity)pi).setCreatedBy(container.getUserName());

 ((CreateTrackingEntity)pi).setCreatedOn(clockService.nowAsDateTime());
                }
            } else {
                if(pi instanceof ModifyTrackingEntity) {

 ((ModifyTrackingEntity)pi).setModifiedBy(container.getUserName());

 ((ModifyTrackingEntity)pi).setModifedOn(clockService.nowAsDateTime());
                }
            }
        }
    }

    @Programmatic
    public void postStore (InstanceLifecycleEvent event) {
        // no-op
    }

    @Inject
    private DomainObjectContainer container;

    @Inject
    private ClockService clockService;

    @Inject
    private IsisJdoSupport isisJdoSupport;
}



~~~~~~~~~~~~
There is actually a ticket in JIRA for this [1], so I'll formalize this as
a service in Isis 1.10.0.

HTH
Dan

[1] https://issues.apache.org/jira/browse/ISIS-867


On 16 September 2015 at 05:18, Stephen Cameron <st...@gmail.com>
wrote:

> Hi,
>
> Could someone please assist me in adding this capability, to automate the
> creation and update of values in these standard fields
>
> created_by
> created_on
> modified_by
> modified_on
>
> That is I need to set the first two on creating a new object, and the last
> two on modifying an object.
>
> Thanks
> Steve Cameron
>