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 2016/10/04 00:58:59 UTC

dates not showing in view model

Hi,

I've noticed that Dates and Joda DateTimes are not being shown in Wicket
Viewer from a View Model class based on a database view.

I am using 1.13.0 and a MySQL database.

Its not critical at the moment, I'll look into it further soon.

Steve

Re: dates not showing in view model

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

On Sat, Oct 22, 2016 at 10:19 PM, Dan Haywood <da...@haywood-associates.co.uk>
wrote:

> I've raised https://issues.apache.org/jira/browse/ISIS-1524 for this...
> thanks for the example demonstrating the issue, Jeroen.
>
> On 18 October 2016 at 22:31, Stephen Cameron <st...@gmail.com>
> wrote:
>
> > Thanks Jeroen, I'll raise a ticket and maybe try to fix it too.
> >
> >
> > On Wed, Oct 19, 2016 at 8:14 AM, Jeroen van der Wal <jeroen@stromboli.it
> >
> > wrote:
> >
> > > Hi Stephen,
> > >
> > > I've created a separate branch in my personal fork of the kitchensink
> app
> > > [1] and pasted some of your code there in order to reproduce the issue.
> > > Could you please follow a similar pattern next time to allow faster
> > > debugging?
> > >
> > > I have not debugged further but it might be an issue with storing Date
> > > types in the viewmodel memento, could you raise a ticket in Jira?
> > >
> > > Cheers,
> > >
> > > Jeroen
> > >
> > > [1] https://github.com/jcvanderwal/isis-app-
> kitchensink/tree/bug-stephen
> > >
> > > On 12 October 2016 at 11:49, Stephen Cameron <
> steve.cameron.62@gmail.com
> > >
> > > wrote:
> > >
> > > > Hi,
> > > >
> > > > I've done a bit more investigation on this but no solution, maybe
> > someone
> > > > can tell me what is happening?
> > > >
> > > > I've defined a View Model, objects properties will normally get
> seeded
> > > from
> > > > a database view but the behaviour is the same if I initialise the
> > > property
> > > > values directly.
> > > >
> > > > I have the action below to demonstrate the effect:
> > > >
> > > >         public List<ActivityAttendanceSummary> listAttendanceData()
> {
> > > >         ArrayList<ActivityAttendanceSummary> list = new
> ArrayList<>();
> > > >         Calendar calendar1 = new GregorianCalendar(2015,0,29);
> > > >         ActivityAttendanceSummary temp1 = new
> > > ActivityAttendanceSummary();
> > > >         temp1.setActivityId(1000L);
> > > >         temp1.setActivityName("Activity 1");
> > > >         temp1.setAttendedCount(10);
> > > >         temp1.setCancelled(false);
> > > >         temp1.setRegionName("SOUTH");
> > > >         temp1.setMaxEndDateTime(calendar1.getTime());
> > > >         temp1.setMinEndDateTime(calendar1.getTime());
> > > >         temp1.setMaxStartDateTime(calendar1.getTime());
> > > >         temp1.setMinStartDateTime(calendar1.getTime());
> > > >         list.add(temp1);
> > > >
> > > >         Calendar calendar2 = new GregorianCalendar(2015,0,30);
> > > >         ActivityAttendanceSummary temp2 = new
> > > ActivityAttendanceSummary();
> > > >         temp2.setActivityId(1001L);
> > > >         temp2.setActivityName("Activity 2");
> > > >         temp2.setAttendedCount(20);
> > > >         temp2.setCancelled(true);
> > > >         temp2.setRegionName("NORTH");
> > > >         temp2.setMaxEndDateTime(calendar2.getTime());
> > > >         temp2.setMinEndDateTime(calendar2.getTime());
> > > >         temp2.setMaxStartDateTime(calendar2.getTime());
> > > >         temp2.setMinStartDateTime(calendar2.getTime());
> > > >         //list.add(temp2);
> > > >         return list;
> > > >     }
> > > >
> > > > The effect seen is that if there is only one object in the list then
> > all
> > > > the dates are displayed fine, whereas if there is two (I do add
> temp2)
> > no
> > > > dates for either temp1 or temp2 get displayed in the table but the
> > other
> > > > values I set do get displayed.
> > > >
> > > > The class ActivityAttendanceSummary is very simple:
> > > >
> > > > package au.com.scds.chats.dom.report.view;
> > > >
> > > > import java.util.Date;
> > > >
> > > > import javax.jdo.annotations.Extension;
> > > > import javax.jdo.annotations.IdentityType;
> > > > import javax.jdo.annotations.Inheritance;
> > > > import javax.jdo.annotations.InheritanceStrategy;
> > > > import javax.jdo.annotations.PersistenceCapable;
> > > > import javax.jdo.annotations.Queries;
> > > > import javax.jdo.annotations.Query;
> > > >
> > > > import org.apache.isis.applib.annotation.DomainObject;
> > > > import org.apache.isis.applib.annotation.Editing;
> > > > import org.apache.isis.applib.annotation.ViewModel;
> > > > import org.joda.time.DateTime;
> > > >
> > > > @ViewModel
> > > > @DomainObject(editing = Editing.DISABLED)
> > > > @PersistenceCapable(identityType = IdentityType.NONDURABLE, table =
> > > > "ActivityAttendanceSummary", extensions = {
> > > >         @Extension(vendorName = "datanucleus", key =
> "view-definition",
> > > > value = "CREATE VIEW ActivityAttendanceSummary "
> > > >                 + "( " + "  {this.activityId}, " + "
> > > {this.activityName},
> > > > " + "  {this.regionName}, "
> > > >                 + "  {this.startDateTime}, " + "  {this.cancelled}, "
> > + "
> > > > {this.attendedCount}, "
> > > >                 + "  {this.notAttendedCount}, " + "
> > > > {this.hasStartAndEndDateTimesCount}, "
> > > >                 + "  {this.minStartDateTime}, " + "
> > > > {this.maxStartDateTime}, " + "  {this.minEndDateTime}, "
> > > >                 + "  {this.maxEndDateTime} " + ") AS " + "SELECT " +
> "
> > > > activity.activity_id as activityId, "
> > > >                 + "  activity.name AS activityName, " + "
> > > > activity.region_name AS regionName, "
> > > >                 + "  activity.startdatetime AS startDateTime, " + "
> > > > activity.cancelled, "
> > > >                 + "  sum(case when attend.attended = TRUE then 1
> else 0
> > > > end) as attendedCount, "
> > > >                 + "  sum(case when attend.attended = FALSE then 1
> else
> > 0
> > > > end) as notAttendedCount, "
> > > >                 + "  sum(case when attend.attended = TRUE AND not
> > > > isnull(attend.startdatetime) AND not isnull(attend.enddatetime) then
> 1
> > > else
> > > > 0 end) as hasStartAndEndDateTimesCount, "
> > > >                 + "  min(attend.startdatetime) as minStartDateTime, "
> > > >                 + "  max(attend.startdatetime) as maxStartDateTime, "
> > + "
> > > > min(attend.enddatetime) as minEndDateTime, "
> > > >                 + "  max(attend.enddatetime) as maxEndDateTime " +
> > "FROM
> > > "
> > > > + "  activity " + "LEFT OUTER JOIN"
> > > >                 + "  attend " + "ON " + "
> attend.activity_activity_id
> > =
> > > > activity.activity_id " + "GROUP BY"
> > > >                 + "  activity.activity_id") })
> > > > @Queries({
> > > >         @Query(name = "allActivityAttendanceSummary", language =
> > > "JDOQL",
> > > > value = "SELECT FROM
> > > > au.com.scds.chats.dom.report.view.ActivityAttendanceSummary"),
> > > >         @Query(name = "allActivityAttendanceSummaryFo
> > rPeriodAndRegion",
> > > > language = "JDOQL", value = "SELECT FROM
> > > > au.com.scds.chats.dom.report.view.ActivityAttendanceSummary pa "
> > > >                 + "WHERE pa.startDateTime >= :startDateTime &&
> > > > pa.startDateTime <= :endDateTime && pa.regionName == :region"), })
> > > > @Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
> > > > public class ActivityAttendanceSummary implements
> > > > Comparable<ActivityAttendanceSummary> {
> > > >
> > > >     private Long activityId;
> > > >     private String activityName;
> > > >     private String regionName;
> > > >     private Date startDateTime;
> > > >     private Boolean cancelled;
> > > >     private Integer attendedCount;
> > > >     private Integer notAttendedCount;
> > > >     private Integer hasStartAndEndDateTimesCount;
> > > >     private Date minStartDateTime;
> > > >     private Date maxStartDateTime;
> > > >     private Date minEndDateTime;
> > > >     private Date maxEndDateTime;
> > > >
> > > >     public Long getActivityId() {
> > > >         return activityId;
> > > >     }
> > > >
> > > >     public void setActivityId(Long activityId) {
> > > >         this.activityId = activityId;
> > > >     }
> > > >
> > > >     public String getActivityName() {
> > > >         return activityName;
> > > >     }
> > > >
> > > >     public void setActivityName(String activityName) {
> > > >         this.activityName = activityName;
> > > >     }
> > > >
> > > >     public String getRegionName() {
> > > >         return regionName;
> > > >     }
> > > >
> > > >     public void setRegionName(String regionName) {
> > > >         this.regionName = regionName;
> > > >     }
> > > >
> > > >     public Date getStartDateTime() {
> > > >         return startDateTime;
> > > >     }
> > > >
> > > >     public void setStartDateTime(Date startDateTime) {
> > > >         this.startDateTime = startDateTime;
> > > >     }
> > > >
> > > >     public Boolean getCancelled() {
> > > >         return cancelled;
> > > >     }
> > > >
> > > >     public void setCancelled(Boolean cancelled) {
> > > >         this.cancelled = cancelled;
> > > >     }
> > > >
> > > >     public Integer getAttendedCount() {
> > > >         return attendedCount;
> > > >     }
> > > >
> > > >     public void setAttendedCount(Integer attendedCount) {
> > > >         this.attendedCount = attendedCount;
> > > >     }
> > > >
> > > >     public Integer getNotAttendedCount() {
> > > >         return notAttendedCount;
> > > >     }
> > > >
> > > >     public void setNotAttendedCount(Integer notAttendedCount) {
> > > >         this.notAttendedCount = notAttendedCount;
> > > >     }
> > > >
> > > >     public Integer getHasStartAndEndDateTimesCount() {
> > > >         return hasStartAndEndDateTimesCount;
> > > >     }
> > > >
> > > >     public void setHasStartAndEndDateTimesCount(Integer
> > > > hasStartAndEndDateTimesCount) {
> > > >         this.hasStartAndEndDateTimesCount =
> > > hasStartAndEndDateTimesCount;
> > > >     }
> > > >
> > > >     public Date getMinStartDateTime() {
> > > >         return minStartDateTime;
> > > >     }
> > > >
> > > >     public void setMinStartDateTime(Date minStartDateTime) {
> > > >         this.minStartDateTime = minStartDateTime;
> > > >     }
> > > >
> > > >     public Date getMaxStartDateTime() {
> > > >         return maxStartDateTime;
> > > >     }
> > > >
> > > >     public void setMaxStartDateTime(Date maxStartDateTime) {
> > > >         this.maxStartDateTime = maxStartDateTime;
> > > >     }
> > > >
> > > >     public Date getMinEndDateTime() {
> > > >         return minEndDateTime;
> > > >     }
> > > >
> > > >     public void setMinEndDateTime(Date minEndDateTime) {
> > > >         this.minEndDateTime = minEndDateTime;
> > > >     }
> > > >
> > > >     public Date getMaxEndDateTime() {
> > > >         return maxEndDateTime;
> > > >     }
> > > >
> > > >     public void setMaxEndDateTime(Date maxEndDateTime) {
> > > >         this.maxEndDateTime = maxEndDateTime;
> > > >     }
> > > >
> > > >     public String getMinStartDateTimeName() {
> > > >         if (getMinStartDateTime() == null)
> > > >             return null;
> > > >         else
> > > >             return getMinStartDateTime().toString();
> > > >     }
> > > >
> > > >     public String getMaxStartDateTimeName() {
> > > >         if (getMaxStartDateTime() == null)
> > > >             return null;
> > > >         else
> > > >             return getMaxStartDateTime().toString();
> > > >     }
> > > >
> > > >     public String getMinEndDateTimeName() {
> > > >         if (getMinEndDateTime() == null)
> > > >             return null;
> > > >         else
> > > >             return getMinEndDateTime().toString();
> > > >     }
> > > >
> > > >     public String getMaxEndDateTimeName() {
> > > >         if (getMaxEndDateTime() == null)
> > > >             return null;
> > > >         else
> > > >             return getMaxEndDateTime().toString();
> > > >     }
> > > >
> > > >     @Override
> > > >     public int compareTo(ActivityAttendanceSummary o) {
> > > >         // compare on name
> > > >         if (getActivityName() != null && o.getActivityName() !=
> null) {
> > > >             if (!getActivityName().equals(o.getActivityName()))
> > > >                 return getActivityName().compareTo(o.
> > getActivityName());
> > > >         }
> > > >         // compare on start date
> > > >         if (getStartDateTime() != null && o.getStartDateTime() !=
> > null) {
> > > >             if (getStartDateTime().equals(o.getStartDateTime()))
> > > >                 return 0;
> > > >             else if (getStartDateTime().before(o.
> getStartDateTime()))
> > > >                 return -1;
> > > >             else
> > > >                 return 1;
> > > >         }
> > > >         // compare on activity Id
> > > >         if (getActivityId() != null && o.getActivityId() != null) {
> > > >             if (getActivityId().equals(o.getActivityId()))
> > > >                 return 0;
> > > >             else if (getActivityId() < o.getActivityId())
> > > >                 return -1;
> > > >             else
> > > >                 return 1;
> > > >         } else
> > > >             return 0;
> > > >     }
> > > >
> > > > }
> > > >
> > > >
> > > >
> > > >
> > > > On Tue, Oct 4, 2016 at 11:58 AM, Stephen Cameron <
> > > > steve.cameron.62@gmail.com
> > > > > wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I've noticed that Dates and Joda DateTimes are not being shown in
> > > Wicket
> > > > > Viewer from a View Model class based on a database view.
> > > > >
> > > > > I am using 1.13.0 and a MySQL database.
> > > > >
> > > > > Its not critical at the moment, I'll look into it further soon.
> > > > >
> > > > > Steve
> > > > >
> > > >
> > >
> >
>

Re: dates not showing in view model

Posted by Dan Haywood <da...@haywood-associates.co.uk>.
I've raised https://issues.apache.org/jira/browse/ISIS-1524 for this...
thanks for the example demonstrating the issue, Jeroen.

On 18 October 2016 at 22:31, Stephen Cameron <st...@gmail.com>
wrote:

> Thanks Jeroen, I'll raise a ticket and maybe try to fix it too.
>
>
> On Wed, Oct 19, 2016 at 8:14 AM, Jeroen van der Wal <je...@stromboli.it>
> wrote:
>
> > Hi Stephen,
> >
> > I've created a separate branch in my personal fork of the kitchensink app
> > [1] and pasted some of your code there in order to reproduce the issue.
> > Could you please follow a similar pattern next time to allow faster
> > debugging?
> >
> > I have not debugged further but it might be an issue with storing Date
> > types in the viewmodel memento, could you raise a ticket in Jira?
> >
> > Cheers,
> >
> > Jeroen
> >
> > [1] https://github.com/jcvanderwal/isis-app-kitchensink/tree/bug-stephen
> >
> > On 12 October 2016 at 11:49, Stephen Cameron <steve.cameron.62@gmail.com
> >
> > wrote:
> >
> > > Hi,
> > >
> > > I've done a bit more investigation on this but no solution, maybe
> someone
> > > can tell me what is happening?
> > >
> > > I've defined a View Model, objects properties will normally get seeded
> > from
> > > a database view but the behaviour is the same if I initialise the
> > property
> > > values directly.
> > >
> > > I have the action below to demonstrate the effect:
> > >
> > >         public List<ActivityAttendanceSummary> listAttendanceData() {
> > >         ArrayList<ActivityAttendanceSummary> list = new ArrayList<>();
> > >         Calendar calendar1 = new GregorianCalendar(2015,0,29);
> > >         ActivityAttendanceSummary temp1 = new
> > ActivityAttendanceSummary();
> > >         temp1.setActivityId(1000L);
> > >         temp1.setActivityName("Activity 1");
> > >         temp1.setAttendedCount(10);
> > >         temp1.setCancelled(false);
> > >         temp1.setRegionName("SOUTH");
> > >         temp1.setMaxEndDateTime(calendar1.getTime());
> > >         temp1.setMinEndDateTime(calendar1.getTime());
> > >         temp1.setMaxStartDateTime(calendar1.getTime());
> > >         temp1.setMinStartDateTime(calendar1.getTime());
> > >         list.add(temp1);
> > >
> > >         Calendar calendar2 = new GregorianCalendar(2015,0,30);
> > >         ActivityAttendanceSummary temp2 = new
> > ActivityAttendanceSummary();
> > >         temp2.setActivityId(1001L);
> > >         temp2.setActivityName("Activity 2");
> > >         temp2.setAttendedCount(20);
> > >         temp2.setCancelled(true);
> > >         temp2.setRegionName("NORTH");
> > >         temp2.setMaxEndDateTime(calendar2.getTime());
> > >         temp2.setMinEndDateTime(calendar2.getTime());
> > >         temp2.setMaxStartDateTime(calendar2.getTime());
> > >         temp2.setMinStartDateTime(calendar2.getTime());
> > >         //list.add(temp2);
> > >         return list;
> > >     }
> > >
> > > The effect seen is that if there is only one object in the list then
> all
> > > the dates are displayed fine, whereas if there is two (I do add temp2)
> no
> > > dates for either temp1 or temp2 get displayed in the table but the
> other
> > > values I set do get displayed.
> > >
> > > The class ActivityAttendanceSummary is very simple:
> > >
> > > package au.com.scds.chats.dom.report.view;
> > >
> > > import java.util.Date;
> > >
> > > import javax.jdo.annotations.Extension;
> > > import javax.jdo.annotations.IdentityType;
> > > import javax.jdo.annotations.Inheritance;
> > > import javax.jdo.annotations.InheritanceStrategy;
> > > import javax.jdo.annotations.PersistenceCapable;
> > > import javax.jdo.annotations.Queries;
> > > import javax.jdo.annotations.Query;
> > >
> > > import org.apache.isis.applib.annotation.DomainObject;
> > > import org.apache.isis.applib.annotation.Editing;
> > > import org.apache.isis.applib.annotation.ViewModel;
> > > import org.joda.time.DateTime;
> > >
> > > @ViewModel
> > > @DomainObject(editing = Editing.DISABLED)
> > > @PersistenceCapable(identityType = IdentityType.NONDURABLE, table =
> > > "ActivityAttendanceSummary", extensions = {
> > >         @Extension(vendorName = "datanucleus", key = "view-definition",
> > > value = "CREATE VIEW ActivityAttendanceSummary "
> > >                 + "( " + "  {this.activityId}, " + "
> > {this.activityName},
> > > " + "  {this.regionName}, "
> > >                 + "  {this.startDateTime}, " + "  {this.cancelled}, "
> + "
> > > {this.attendedCount}, "
> > >                 + "  {this.notAttendedCount}, " + "
> > > {this.hasStartAndEndDateTimesCount}, "
> > >                 + "  {this.minStartDateTime}, " + "
> > > {this.maxStartDateTime}, " + "  {this.minEndDateTime}, "
> > >                 + "  {this.maxEndDateTime} " + ") AS " + "SELECT " + "
> > > activity.activity_id as activityId, "
> > >                 + "  activity.name AS activityName, " + "
> > > activity.region_name AS regionName, "
> > >                 + "  activity.startdatetime AS startDateTime, " + "
> > > activity.cancelled, "
> > >                 + "  sum(case when attend.attended = TRUE then 1 else 0
> > > end) as attendedCount, "
> > >                 + "  sum(case when attend.attended = FALSE then 1 else
> 0
> > > end) as notAttendedCount, "
> > >                 + "  sum(case when attend.attended = TRUE AND not
> > > isnull(attend.startdatetime) AND not isnull(attend.enddatetime) then 1
> > else
> > > 0 end) as hasStartAndEndDateTimesCount, "
> > >                 + "  min(attend.startdatetime) as minStartDateTime, "
> > >                 + "  max(attend.startdatetime) as maxStartDateTime, "
> + "
> > > min(attend.enddatetime) as minEndDateTime, "
> > >                 + "  max(attend.enddatetime) as maxEndDateTime " +
> "FROM
> > "
> > > + "  activity " + "LEFT OUTER JOIN"
> > >                 + "  attend " + "ON " + "  attend.activity_activity_id
> =
> > > activity.activity_id " + "GROUP BY"
> > >                 + "  activity.activity_id") })
> > > @Queries({
> > >         @Query(name = "allActivityAttendanceSummary", language =
> > "JDOQL",
> > > value = "SELECT FROM
> > > au.com.scds.chats.dom.report.view.ActivityAttendanceSummary"),
> > >         @Query(name = "allActivityAttendanceSummaryFo
> rPeriodAndRegion",
> > > language = "JDOQL", value = "SELECT FROM
> > > au.com.scds.chats.dom.report.view.ActivityAttendanceSummary pa "
> > >                 + "WHERE pa.startDateTime >= :startDateTime &&
> > > pa.startDateTime <= :endDateTime && pa.regionName == :region"), })
> > > @Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
> > > public class ActivityAttendanceSummary implements
> > > Comparable<ActivityAttendanceSummary> {
> > >
> > >     private Long activityId;
> > >     private String activityName;
> > >     private String regionName;
> > >     private Date startDateTime;
> > >     private Boolean cancelled;
> > >     private Integer attendedCount;
> > >     private Integer notAttendedCount;
> > >     private Integer hasStartAndEndDateTimesCount;
> > >     private Date minStartDateTime;
> > >     private Date maxStartDateTime;
> > >     private Date minEndDateTime;
> > >     private Date maxEndDateTime;
> > >
> > >     public Long getActivityId() {
> > >         return activityId;
> > >     }
> > >
> > >     public void setActivityId(Long activityId) {
> > >         this.activityId = activityId;
> > >     }
> > >
> > >     public String getActivityName() {
> > >         return activityName;
> > >     }
> > >
> > >     public void setActivityName(String activityName) {
> > >         this.activityName = activityName;
> > >     }
> > >
> > >     public String getRegionName() {
> > >         return regionName;
> > >     }
> > >
> > >     public void setRegionName(String regionName) {
> > >         this.regionName = regionName;
> > >     }
> > >
> > >     public Date getStartDateTime() {
> > >         return startDateTime;
> > >     }
> > >
> > >     public void setStartDateTime(Date startDateTime) {
> > >         this.startDateTime = startDateTime;
> > >     }
> > >
> > >     public Boolean getCancelled() {
> > >         return cancelled;
> > >     }
> > >
> > >     public void setCancelled(Boolean cancelled) {
> > >         this.cancelled = cancelled;
> > >     }
> > >
> > >     public Integer getAttendedCount() {
> > >         return attendedCount;
> > >     }
> > >
> > >     public void setAttendedCount(Integer attendedCount) {
> > >         this.attendedCount = attendedCount;
> > >     }
> > >
> > >     public Integer getNotAttendedCount() {
> > >         return notAttendedCount;
> > >     }
> > >
> > >     public void setNotAttendedCount(Integer notAttendedCount) {
> > >         this.notAttendedCount = notAttendedCount;
> > >     }
> > >
> > >     public Integer getHasStartAndEndDateTimesCount() {
> > >         return hasStartAndEndDateTimesCount;
> > >     }
> > >
> > >     public void setHasStartAndEndDateTimesCount(Integer
> > > hasStartAndEndDateTimesCount) {
> > >         this.hasStartAndEndDateTimesCount =
> > hasStartAndEndDateTimesCount;
> > >     }
> > >
> > >     public Date getMinStartDateTime() {
> > >         return minStartDateTime;
> > >     }
> > >
> > >     public void setMinStartDateTime(Date minStartDateTime) {
> > >         this.minStartDateTime = minStartDateTime;
> > >     }
> > >
> > >     public Date getMaxStartDateTime() {
> > >         return maxStartDateTime;
> > >     }
> > >
> > >     public void setMaxStartDateTime(Date maxStartDateTime) {
> > >         this.maxStartDateTime = maxStartDateTime;
> > >     }
> > >
> > >     public Date getMinEndDateTime() {
> > >         return minEndDateTime;
> > >     }
> > >
> > >     public void setMinEndDateTime(Date minEndDateTime) {
> > >         this.minEndDateTime = minEndDateTime;
> > >     }
> > >
> > >     public Date getMaxEndDateTime() {
> > >         return maxEndDateTime;
> > >     }
> > >
> > >     public void setMaxEndDateTime(Date maxEndDateTime) {
> > >         this.maxEndDateTime = maxEndDateTime;
> > >     }
> > >
> > >     public String getMinStartDateTimeName() {
> > >         if (getMinStartDateTime() == null)
> > >             return null;
> > >         else
> > >             return getMinStartDateTime().toString();
> > >     }
> > >
> > >     public String getMaxStartDateTimeName() {
> > >         if (getMaxStartDateTime() == null)
> > >             return null;
> > >         else
> > >             return getMaxStartDateTime().toString();
> > >     }
> > >
> > >     public String getMinEndDateTimeName() {
> > >         if (getMinEndDateTime() == null)
> > >             return null;
> > >         else
> > >             return getMinEndDateTime().toString();
> > >     }
> > >
> > >     public String getMaxEndDateTimeName() {
> > >         if (getMaxEndDateTime() == null)
> > >             return null;
> > >         else
> > >             return getMaxEndDateTime().toString();
> > >     }
> > >
> > >     @Override
> > >     public int compareTo(ActivityAttendanceSummary o) {
> > >         // compare on name
> > >         if (getActivityName() != null && o.getActivityName() != null) {
> > >             if (!getActivityName().equals(o.getActivityName()))
> > >                 return getActivityName().compareTo(o.
> getActivityName());
> > >         }
> > >         // compare on start date
> > >         if (getStartDateTime() != null && o.getStartDateTime() !=
> null) {
> > >             if (getStartDateTime().equals(o.getStartDateTime()))
> > >                 return 0;
> > >             else if (getStartDateTime().before(o.getStartDateTime()))
> > >                 return -1;
> > >             else
> > >                 return 1;
> > >         }
> > >         // compare on activity Id
> > >         if (getActivityId() != null && o.getActivityId() != null) {
> > >             if (getActivityId().equals(o.getActivityId()))
> > >                 return 0;
> > >             else if (getActivityId() < o.getActivityId())
> > >                 return -1;
> > >             else
> > >                 return 1;
> > >         } else
> > >             return 0;
> > >     }
> > >
> > > }
> > >
> > >
> > >
> > >
> > > On Tue, Oct 4, 2016 at 11:58 AM, Stephen Cameron <
> > > steve.cameron.62@gmail.com
> > > > wrote:
> > >
> > > > Hi,
> > > >
> > > > I've noticed that Dates and Joda DateTimes are not being shown in
> > Wicket
> > > > Viewer from a View Model class based on a database view.
> > > >
> > > > I am using 1.13.0 and a MySQL database.
> > > >
> > > > Its not critical at the moment, I'll look into it further soon.
> > > >
> > > > Steve
> > > >
> > >
> >
>

Re: dates not showing in view model

Posted by Stephen Cameron <st...@gmail.com>.
Thanks Jeroen, I'll raise a ticket and maybe try to fix it too.


On Wed, Oct 19, 2016 at 8:14 AM, Jeroen van der Wal <je...@stromboli.it>
wrote:

> Hi Stephen,
>
> I've created a separate branch in my personal fork of the kitchensink app
> [1] and pasted some of your code there in order to reproduce the issue.
> Could you please follow a similar pattern next time to allow faster
> debugging?
>
> I have not debugged further but it might be an issue with storing Date
> types in the viewmodel memento, could you raise a ticket in Jira?
>
> Cheers,
>
> Jeroen
>
> [1] https://github.com/jcvanderwal/isis-app-kitchensink/tree/bug-stephen
>
> On 12 October 2016 at 11:49, Stephen Cameron <st...@gmail.com>
> wrote:
>
> > Hi,
> >
> > I've done a bit more investigation on this but no solution, maybe someone
> > can tell me what is happening?
> >
> > I've defined a View Model, objects properties will normally get seeded
> from
> > a database view but the behaviour is the same if I initialise the
> property
> > values directly.
> >
> > I have the action below to demonstrate the effect:
> >
> >         public List<ActivityAttendanceSummary> listAttendanceData() {
> >         ArrayList<ActivityAttendanceSummary> list = new ArrayList<>();
> >         Calendar calendar1 = new GregorianCalendar(2015,0,29);
> >         ActivityAttendanceSummary temp1 = new
> ActivityAttendanceSummary();
> >         temp1.setActivityId(1000L);
> >         temp1.setActivityName("Activity 1");
> >         temp1.setAttendedCount(10);
> >         temp1.setCancelled(false);
> >         temp1.setRegionName("SOUTH");
> >         temp1.setMaxEndDateTime(calendar1.getTime());
> >         temp1.setMinEndDateTime(calendar1.getTime());
> >         temp1.setMaxStartDateTime(calendar1.getTime());
> >         temp1.setMinStartDateTime(calendar1.getTime());
> >         list.add(temp1);
> >
> >         Calendar calendar2 = new GregorianCalendar(2015,0,30);
> >         ActivityAttendanceSummary temp2 = new
> ActivityAttendanceSummary();
> >         temp2.setActivityId(1001L);
> >         temp2.setActivityName("Activity 2");
> >         temp2.setAttendedCount(20);
> >         temp2.setCancelled(true);
> >         temp2.setRegionName("NORTH");
> >         temp2.setMaxEndDateTime(calendar2.getTime());
> >         temp2.setMinEndDateTime(calendar2.getTime());
> >         temp2.setMaxStartDateTime(calendar2.getTime());
> >         temp2.setMinStartDateTime(calendar2.getTime());
> >         //list.add(temp2);
> >         return list;
> >     }
> >
> > The effect seen is that if there is only one object in the list then all
> > the dates are displayed fine, whereas if there is two (I do add temp2) no
> > dates for either temp1 or temp2 get displayed in the table but the other
> > values I set do get displayed.
> >
> > The class ActivityAttendanceSummary is very simple:
> >
> > package au.com.scds.chats.dom.report.view;
> >
> > import java.util.Date;
> >
> > import javax.jdo.annotations.Extension;
> > import javax.jdo.annotations.IdentityType;
> > import javax.jdo.annotations.Inheritance;
> > import javax.jdo.annotations.InheritanceStrategy;
> > import javax.jdo.annotations.PersistenceCapable;
> > import javax.jdo.annotations.Queries;
> > import javax.jdo.annotations.Query;
> >
> > import org.apache.isis.applib.annotation.DomainObject;
> > import org.apache.isis.applib.annotation.Editing;
> > import org.apache.isis.applib.annotation.ViewModel;
> > import org.joda.time.DateTime;
> >
> > @ViewModel
> > @DomainObject(editing = Editing.DISABLED)
> > @PersistenceCapable(identityType = IdentityType.NONDURABLE, table =
> > "ActivityAttendanceSummary", extensions = {
> >         @Extension(vendorName = "datanucleus", key = "view-definition",
> > value = "CREATE VIEW ActivityAttendanceSummary "
> >                 + "( " + "  {this.activityId}, " + "
> {this.activityName},
> > " + "  {this.regionName}, "
> >                 + "  {this.startDateTime}, " + "  {this.cancelled}, " + "
> > {this.attendedCount}, "
> >                 + "  {this.notAttendedCount}, " + "
> > {this.hasStartAndEndDateTimesCount}, "
> >                 + "  {this.minStartDateTime}, " + "
> > {this.maxStartDateTime}, " + "  {this.minEndDateTime}, "
> >                 + "  {this.maxEndDateTime} " + ") AS " + "SELECT " + "
> > activity.activity_id as activityId, "
> >                 + "  activity.name AS activityName, " + "
> > activity.region_name AS regionName, "
> >                 + "  activity.startdatetime AS startDateTime, " + "
> > activity.cancelled, "
> >                 + "  sum(case when attend.attended = TRUE then 1 else 0
> > end) as attendedCount, "
> >                 + "  sum(case when attend.attended = FALSE then 1 else 0
> > end) as notAttendedCount, "
> >                 + "  sum(case when attend.attended = TRUE AND not
> > isnull(attend.startdatetime) AND not isnull(attend.enddatetime) then 1
> else
> > 0 end) as hasStartAndEndDateTimesCount, "
> >                 + "  min(attend.startdatetime) as minStartDateTime, "
> >                 + "  max(attend.startdatetime) as maxStartDateTime, " + "
> > min(attend.enddatetime) as minEndDateTime, "
> >                 + "  max(attend.enddatetime) as maxEndDateTime " + "FROM
> "
> > + "  activity " + "LEFT OUTER JOIN"
> >                 + "  attend " + "ON " + "  attend.activity_activity_id =
> > activity.activity_id " + "GROUP BY"
> >                 + "  activity.activity_id") })
> > @Queries({
> >         @Query(name = "allActivityAttendanceSummary", language =
> "JDOQL",
> > value = "SELECT FROM
> > au.com.scds.chats.dom.report.view.ActivityAttendanceSummary"),
> >         @Query(name = "allActivityAttendanceSummaryForPeriodAndRegion",
> > language = "JDOQL", value = "SELECT FROM
> > au.com.scds.chats.dom.report.view.ActivityAttendanceSummary pa "
> >                 + "WHERE pa.startDateTime >= :startDateTime &&
> > pa.startDateTime <= :endDateTime && pa.regionName == :region"), })
> > @Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
> > public class ActivityAttendanceSummary implements
> > Comparable<ActivityAttendanceSummary> {
> >
> >     private Long activityId;
> >     private String activityName;
> >     private String regionName;
> >     private Date startDateTime;
> >     private Boolean cancelled;
> >     private Integer attendedCount;
> >     private Integer notAttendedCount;
> >     private Integer hasStartAndEndDateTimesCount;
> >     private Date minStartDateTime;
> >     private Date maxStartDateTime;
> >     private Date minEndDateTime;
> >     private Date maxEndDateTime;
> >
> >     public Long getActivityId() {
> >         return activityId;
> >     }
> >
> >     public void setActivityId(Long activityId) {
> >         this.activityId = activityId;
> >     }
> >
> >     public String getActivityName() {
> >         return activityName;
> >     }
> >
> >     public void setActivityName(String activityName) {
> >         this.activityName = activityName;
> >     }
> >
> >     public String getRegionName() {
> >         return regionName;
> >     }
> >
> >     public void setRegionName(String regionName) {
> >         this.regionName = regionName;
> >     }
> >
> >     public Date getStartDateTime() {
> >         return startDateTime;
> >     }
> >
> >     public void setStartDateTime(Date startDateTime) {
> >         this.startDateTime = startDateTime;
> >     }
> >
> >     public Boolean getCancelled() {
> >         return cancelled;
> >     }
> >
> >     public void setCancelled(Boolean cancelled) {
> >         this.cancelled = cancelled;
> >     }
> >
> >     public Integer getAttendedCount() {
> >         return attendedCount;
> >     }
> >
> >     public void setAttendedCount(Integer attendedCount) {
> >         this.attendedCount = attendedCount;
> >     }
> >
> >     public Integer getNotAttendedCount() {
> >         return notAttendedCount;
> >     }
> >
> >     public void setNotAttendedCount(Integer notAttendedCount) {
> >         this.notAttendedCount = notAttendedCount;
> >     }
> >
> >     public Integer getHasStartAndEndDateTimesCount() {
> >         return hasStartAndEndDateTimesCount;
> >     }
> >
> >     public void setHasStartAndEndDateTimesCount(Integer
> > hasStartAndEndDateTimesCount) {
> >         this.hasStartAndEndDateTimesCount =
> hasStartAndEndDateTimesCount;
> >     }
> >
> >     public Date getMinStartDateTime() {
> >         return minStartDateTime;
> >     }
> >
> >     public void setMinStartDateTime(Date minStartDateTime) {
> >         this.minStartDateTime = minStartDateTime;
> >     }
> >
> >     public Date getMaxStartDateTime() {
> >         return maxStartDateTime;
> >     }
> >
> >     public void setMaxStartDateTime(Date maxStartDateTime) {
> >         this.maxStartDateTime = maxStartDateTime;
> >     }
> >
> >     public Date getMinEndDateTime() {
> >         return minEndDateTime;
> >     }
> >
> >     public void setMinEndDateTime(Date minEndDateTime) {
> >         this.minEndDateTime = minEndDateTime;
> >     }
> >
> >     public Date getMaxEndDateTime() {
> >         return maxEndDateTime;
> >     }
> >
> >     public void setMaxEndDateTime(Date maxEndDateTime) {
> >         this.maxEndDateTime = maxEndDateTime;
> >     }
> >
> >     public String getMinStartDateTimeName() {
> >         if (getMinStartDateTime() == null)
> >             return null;
> >         else
> >             return getMinStartDateTime().toString();
> >     }
> >
> >     public String getMaxStartDateTimeName() {
> >         if (getMaxStartDateTime() == null)
> >             return null;
> >         else
> >             return getMaxStartDateTime().toString();
> >     }
> >
> >     public String getMinEndDateTimeName() {
> >         if (getMinEndDateTime() == null)
> >             return null;
> >         else
> >             return getMinEndDateTime().toString();
> >     }
> >
> >     public String getMaxEndDateTimeName() {
> >         if (getMaxEndDateTime() == null)
> >             return null;
> >         else
> >             return getMaxEndDateTime().toString();
> >     }
> >
> >     @Override
> >     public int compareTo(ActivityAttendanceSummary o) {
> >         // compare on name
> >         if (getActivityName() != null && o.getActivityName() != null) {
> >             if (!getActivityName().equals(o.getActivityName()))
> >                 return getActivityName().compareTo(o.getActivityName());
> >         }
> >         // compare on start date
> >         if (getStartDateTime() != null && o.getStartDateTime() != null) {
> >             if (getStartDateTime().equals(o.getStartDateTime()))
> >                 return 0;
> >             else if (getStartDateTime().before(o.getStartDateTime()))
> >                 return -1;
> >             else
> >                 return 1;
> >         }
> >         // compare on activity Id
> >         if (getActivityId() != null && o.getActivityId() != null) {
> >             if (getActivityId().equals(o.getActivityId()))
> >                 return 0;
> >             else if (getActivityId() < o.getActivityId())
> >                 return -1;
> >             else
> >                 return 1;
> >         } else
> >             return 0;
> >     }
> >
> > }
> >
> >
> >
> >
> > On Tue, Oct 4, 2016 at 11:58 AM, Stephen Cameron <
> > steve.cameron.62@gmail.com
> > > wrote:
> >
> > > Hi,
> > >
> > > I've noticed that Dates and Joda DateTimes are not being shown in
> Wicket
> > > Viewer from a View Model class based on a database view.
> > >
> > > I am using 1.13.0 and a MySQL database.
> > >
> > > Its not critical at the moment, I'll look into it further soon.
> > >
> > > Steve
> > >
> >
>

Re: dates not showing in view model

Posted by Jeroen van der Wal <je...@stromboli.it>.
Hi Stephen,

I've created a separate branch in my personal fork of the kitchensink app
[1] and pasted some of your code there in order to reproduce the issue.
Could you please follow a similar pattern next time to allow faster
debugging?

I have not debugged further but it might be an issue with storing Date
types in the viewmodel memento, could you raise a ticket in Jira?

Cheers,

Jeroen

[1] https://github.com/jcvanderwal/isis-app-kitchensink/tree/bug-stephen

On 12 October 2016 at 11:49, Stephen Cameron <st...@gmail.com>
wrote:

> Hi,
>
> I've done a bit more investigation on this but no solution, maybe someone
> can tell me what is happening?
>
> I've defined a View Model, objects properties will normally get seeded from
> a database view but the behaviour is the same if I initialise the property
> values directly.
>
> I have the action below to demonstrate the effect:
>
>         public List<ActivityAttendanceSummary> listAttendanceData() {
>         ArrayList<ActivityAttendanceSummary> list = new ArrayList<>();
>         Calendar calendar1 = new GregorianCalendar(2015,0,29);
>         ActivityAttendanceSummary temp1 = new ActivityAttendanceSummary();
>         temp1.setActivityId(1000L);
>         temp1.setActivityName("Activity 1");
>         temp1.setAttendedCount(10);
>         temp1.setCancelled(false);
>         temp1.setRegionName("SOUTH");
>         temp1.setMaxEndDateTime(calendar1.getTime());
>         temp1.setMinEndDateTime(calendar1.getTime());
>         temp1.setMaxStartDateTime(calendar1.getTime());
>         temp1.setMinStartDateTime(calendar1.getTime());
>         list.add(temp1);
>
>         Calendar calendar2 = new GregorianCalendar(2015,0,30);
>         ActivityAttendanceSummary temp2 = new ActivityAttendanceSummary();
>         temp2.setActivityId(1001L);
>         temp2.setActivityName("Activity 2");
>         temp2.setAttendedCount(20);
>         temp2.setCancelled(true);
>         temp2.setRegionName("NORTH");
>         temp2.setMaxEndDateTime(calendar2.getTime());
>         temp2.setMinEndDateTime(calendar2.getTime());
>         temp2.setMaxStartDateTime(calendar2.getTime());
>         temp2.setMinStartDateTime(calendar2.getTime());
>         //list.add(temp2);
>         return list;
>     }
>
> The effect seen is that if there is only one object in the list then all
> the dates are displayed fine, whereas if there is two (I do add temp2) no
> dates for either temp1 or temp2 get displayed in the table but the other
> values I set do get displayed.
>
> The class ActivityAttendanceSummary is very simple:
>
> package au.com.scds.chats.dom.report.view;
>
> import java.util.Date;
>
> import javax.jdo.annotations.Extension;
> import javax.jdo.annotations.IdentityType;
> import javax.jdo.annotations.Inheritance;
> import javax.jdo.annotations.InheritanceStrategy;
> import javax.jdo.annotations.PersistenceCapable;
> import javax.jdo.annotations.Queries;
> import javax.jdo.annotations.Query;
>
> import org.apache.isis.applib.annotation.DomainObject;
> import org.apache.isis.applib.annotation.Editing;
> import org.apache.isis.applib.annotation.ViewModel;
> import org.joda.time.DateTime;
>
> @ViewModel
> @DomainObject(editing = Editing.DISABLED)
> @PersistenceCapable(identityType = IdentityType.NONDURABLE, table =
> "ActivityAttendanceSummary", extensions = {
>         @Extension(vendorName = "datanucleus", key = "view-definition",
> value = "CREATE VIEW ActivityAttendanceSummary "
>                 + "( " + "  {this.activityId}, " + "  {this.activityName},
> " + "  {this.regionName}, "
>                 + "  {this.startDateTime}, " + "  {this.cancelled}, " + "
> {this.attendedCount}, "
>                 + "  {this.notAttendedCount}, " + "
> {this.hasStartAndEndDateTimesCount}, "
>                 + "  {this.minStartDateTime}, " + "
> {this.maxStartDateTime}, " + "  {this.minEndDateTime}, "
>                 + "  {this.maxEndDateTime} " + ") AS " + "SELECT " + "
> activity.activity_id as activityId, "
>                 + "  activity.name AS activityName, " + "
> activity.region_name AS regionName, "
>                 + "  activity.startdatetime AS startDateTime, " + "
> activity.cancelled, "
>                 + "  sum(case when attend.attended = TRUE then 1 else 0
> end) as attendedCount, "
>                 + "  sum(case when attend.attended = FALSE then 1 else 0
> end) as notAttendedCount, "
>                 + "  sum(case when attend.attended = TRUE AND not
> isnull(attend.startdatetime) AND not isnull(attend.enddatetime) then 1 else
> 0 end) as hasStartAndEndDateTimesCount, "
>                 + "  min(attend.startdatetime) as minStartDateTime, "
>                 + "  max(attend.startdatetime) as maxStartDateTime, " + "
> min(attend.enddatetime) as minEndDateTime, "
>                 + "  max(attend.enddatetime) as maxEndDateTime " + "FROM "
> + "  activity " + "LEFT OUTER JOIN"
>                 + "  attend " + "ON " + "  attend.activity_activity_id =
> activity.activity_id " + "GROUP BY"
>                 + "  activity.activity_id") })
> @Queries({
>         @Query(name = "allActivityAttendanceSummary", language = "JDOQL",
> value = "SELECT FROM
> au.com.scds.chats.dom.report.view.ActivityAttendanceSummary"),
>         @Query(name = "allActivityAttendanceSummaryForPeriodAndRegion",
> language = "JDOQL", value = "SELECT FROM
> au.com.scds.chats.dom.report.view.ActivityAttendanceSummary pa "
>                 + "WHERE pa.startDateTime >= :startDateTime &&
> pa.startDateTime <= :endDateTime && pa.regionName == :region"), })
> @Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
> public class ActivityAttendanceSummary implements
> Comparable<ActivityAttendanceSummary> {
>
>     private Long activityId;
>     private String activityName;
>     private String regionName;
>     private Date startDateTime;
>     private Boolean cancelled;
>     private Integer attendedCount;
>     private Integer notAttendedCount;
>     private Integer hasStartAndEndDateTimesCount;
>     private Date minStartDateTime;
>     private Date maxStartDateTime;
>     private Date minEndDateTime;
>     private Date maxEndDateTime;
>
>     public Long getActivityId() {
>         return activityId;
>     }
>
>     public void setActivityId(Long activityId) {
>         this.activityId = activityId;
>     }
>
>     public String getActivityName() {
>         return activityName;
>     }
>
>     public void setActivityName(String activityName) {
>         this.activityName = activityName;
>     }
>
>     public String getRegionName() {
>         return regionName;
>     }
>
>     public void setRegionName(String regionName) {
>         this.regionName = regionName;
>     }
>
>     public Date getStartDateTime() {
>         return startDateTime;
>     }
>
>     public void setStartDateTime(Date startDateTime) {
>         this.startDateTime = startDateTime;
>     }
>
>     public Boolean getCancelled() {
>         return cancelled;
>     }
>
>     public void setCancelled(Boolean cancelled) {
>         this.cancelled = cancelled;
>     }
>
>     public Integer getAttendedCount() {
>         return attendedCount;
>     }
>
>     public void setAttendedCount(Integer attendedCount) {
>         this.attendedCount = attendedCount;
>     }
>
>     public Integer getNotAttendedCount() {
>         return notAttendedCount;
>     }
>
>     public void setNotAttendedCount(Integer notAttendedCount) {
>         this.notAttendedCount = notAttendedCount;
>     }
>
>     public Integer getHasStartAndEndDateTimesCount() {
>         return hasStartAndEndDateTimesCount;
>     }
>
>     public void setHasStartAndEndDateTimesCount(Integer
> hasStartAndEndDateTimesCount) {
>         this.hasStartAndEndDateTimesCount = hasStartAndEndDateTimesCount;
>     }
>
>     public Date getMinStartDateTime() {
>         return minStartDateTime;
>     }
>
>     public void setMinStartDateTime(Date minStartDateTime) {
>         this.minStartDateTime = minStartDateTime;
>     }
>
>     public Date getMaxStartDateTime() {
>         return maxStartDateTime;
>     }
>
>     public void setMaxStartDateTime(Date maxStartDateTime) {
>         this.maxStartDateTime = maxStartDateTime;
>     }
>
>     public Date getMinEndDateTime() {
>         return minEndDateTime;
>     }
>
>     public void setMinEndDateTime(Date minEndDateTime) {
>         this.minEndDateTime = minEndDateTime;
>     }
>
>     public Date getMaxEndDateTime() {
>         return maxEndDateTime;
>     }
>
>     public void setMaxEndDateTime(Date maxEndDateTime) {
>         this.maxEndDateTime = maxEndDateTime;
>     }
>
>     public String getMinStartDateTimeName() {
>         if (getMinStartDateTime() == null)
>             return null;
>         else
>             return getMinStartDateTime().toString();
>     }
>
>     public String getMaxStartDateTimeName() {
>         if (getMaxStartDateTime() == null)
>             return null;
>         else
>             return getMaxStartDateTime().toString();
>     }
>
>     public String getMinEndDateTimeName() {
>         if (getMinEndDateTime() == null)
>             return null;
>         else
>             return getMinEndDateTime().toString();
>     }
>
>     public String getMaxEndDateTimeName() {
>         if (getMaxEndDateTime() == null)
>             return null;
>         else
>             return getMaxEndDateTime().toString();
>     }
>
>     @Override
>     public int compareTo(ActivityAttendanceSummary o) {
>         // compare on name
>         if (getActivityName() != null && o.getActivityName() != null) {
>             if (!getActivityName().equals(o.getActivityName()))
>                 return getActivityName().compareTo(o.getActivityName());
>         }
>         // compare on start date
>         if (getStartDateTime() != null && o.getStartDateTime() != null) {
>             if (getStartDateTime().equals(o.getStartDateTime()))
>                 return 0;
>             else if (getStartDateTime().before(o.getStartDateTime()))
>                 return -1;
>             else
>                 return 1;
>         }
>         // compare on activity Id
>         if (getActivityId() != null && o.getActivityId() != null) {
>             if (getActivityId().equals(o.getActivityId()))
>                 return 0;
>             else if (getActivityId() < o.getActivityId())
>                 return -1;
>             else
>                 return 1;
>         } else
>             return 0;
>     }
>
> }
>
>
>
>
> On Tue, Oct 4, 2016 at 11:58 AM, Stephen Cameron <
> steve.cameron.62@gmail.com
> > wrote:
>
> > Hi,
> >
> > I've noticed that Dates and Joda DateTimes are not being shown in Wicket
> > Viewer from a View Model class based on a database view.
> >
> > I am using 1.13.0 and a MySQL database.
> >
> > Its not critical at the moment, I'll look into it further soon.
> >
> > Steve
> >
>

Re: dates not showing in view model

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

I've done a bit more investigation on this but no solution, maybe someone
can tell me what is happening?

I've defined a View Model, objects properties will normally get seeded from
a database view but the behaviour is the same if I initialise the property
values directly.

I have the action below to demonstrate the effect:

        public List<ActivityAttendanceSummary> listAttendanceData() {
        ArrayList<ActivityAttendanceSummary> list = new ArrayList<>();
        Calendar calendar1 = new GregorianCalendar(2015,0,29);
        ActivityAttendanceSummary temp1 = new ActivityAttendanceSummary();
        temp1.setActivityId(1000L);
        temp1.setActivityName("Activity 1");
        temp1.setAttendedCount(10);
        temp1.setCancelled(false);
        temp1.setRegionName("SOUTH");
        temp1.setMaxEndDateTime(calendar1.getTime());
        temp1.setMinEndDateTime(calendar1.getTime());
        temp1.setMaxStartDateTime(calendar1.getTime());
        temp1.setMinStartDateTime(calendar1.getTime());
        list.add(temp1);

        Calendar calendar2 = new GregorianCalendar(2015,0,30);
        ActivityAttendanceSummary temp2 = new ActivityAttendanceSummary();
        temp2.setActivityId(1001L);
        temp2.setActivityName("Activity 2");
        temp2.setAttendedCount(20);
        temp2.setCancelled(true);
        temp2.setRegionName("NORTH");
        temp2.setMaxEndDateTime(calendar2.getTime());
        temp2.setMinEndDateTime(calendar2.getTime());
        temp2.setMaxStartDateTime(calendar2.getTime());
        temp2.setMinStartDateTime(calendar2.getTime());
        //list.add(temp2);
        return list;
    }

The effect seen is that if there is only one object in the list then all
the dates are displayed fine, whereas if there is two (I do add temp2) no
dates for either temp1 or temp2 get displayed in the table but the other
values I set do get displayed.

The class ActivityAttendanceSummary is very simple:

package au.com.scds.chats.dom.report.view;

import java.util.Date;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.Inheritance;
import javax.jdo.annotations.InheritanceStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Queries;
import javax.jdo.annotations.Query;

import org.apache.isis.applib.annotation.DomainObject;
import org.apache.isis.applib.annotation.Editing;
import org.apache.isis.applib.annotation.ViewModel;
import org.joda.time.DateTime;

@ViewModel
@DomainObject(editing = Editing.DISABLED)
@PersistenceCapable(identityType = IdentityType.NONDURABLE, table =
"ActivityAttendanceSummary", extensions = {
        @Extension(vendorName = "datanucleus", key = "view-definition",
value = "CREATE VIEW ActivityAttendanceSummary "
                + "( " + "  {this.activityId}, " + "  {this.activityName},
" + "  {this.regionName}, "
                + "  {this.startDateTime}, " + "  {this.cancelled}, " + "
{this.attendedCount}, "
                + "  {this.notAttendedCount}, " + "
{this.hasStartAndEndDateTimesCount}, "
                + "  {this.minStartDateTime}, " + "
{this.maxStartDateTime}, " + "  {this.minEndDateTime}, "
                + "  {this.maxEndDateTime} " + ") AS " + "SELECT " + "
activity.activity_id as activityId, "
                + "  activity.name AS activityName, " + "
activity.region_name AS regionName, "
                + "  activity.startdatetime AS startDateTime, " + "
activity.cancelled, "
                + "  sum(case when attend.attended = TRUE then 1 else 0
end) as attendedCount, "
                + "  sum(case when attend.attended = FALSE then 1 else 0
end) as notAttendedCount, "
                + "  sum(case when attend.attended = TRUE AND not
isnull(attend.startdatetime) AND not isnull(attend.enddatetime) then 1 else
0 end) as hasStartAndEndDateTimesCount, "
                + "  min(attend.startdatetime) as minStartDateTime, "
                + "  max(attend.startdatetime) as maxStartDateTime, " + "
min(attend.enddatetime) as minEndDateTime, "
                + "  max(attend.enddatetime) as maxEndDateTime " + "FROM "
+ "  activity " + "LEFT OUTER JOIN"
                + "  attend " + "ON " + "  attend.activity_activity_id =
activity.activity_id " + "GROUP BY"
                + "  activity.activity_id") })
@Queries({
        @Query(name = "allActivityAttendanceSummary", language = "JDOQL",
value = "SELECT FROM
au.com.scds.chats.dom.report.view.ActivityAttendanceSummary"),
        @Query(name = "allActivityAttendanceSummaryForPeriodAndRegion",
language = "JDOQL", value = "SELECT FROM
au.com.scds.chats.dom.report.view.ActivityAttendanceSummary pa "
                + "WHERE pa.startDateTime >= :startDateTime &&
pa.startDateTime <= :endDateTime && pa.regionName == :region"), })
@Inheritance(strategy = InheritanceStrategy.NEW_TABLE)
public class ActivityAttendanceSummary implements
Comparable<ActivityAttendanceSummary> {

    private Long activityId;
    private String activityName;
    private String regionName;
    private Date startDateTime;
    private Boolean cancelled;
    private Integer attendedCount;
    private Integer notAttendedCount;
    private Integer hasStartAndEndDateTimesCount;
    private Date minStartDateTime;
    private Date maxStartDateTime;
    private Date minEndDateTime;
    private Date maxEndDateTime;

    public Long getActivityId() {
        return activityId;
    }

    public void setActivityId(Long activityId) {
        this.activityId = activityId;
    }

    public String getActivityName() {
        return activityName;
    }

    public void setActivityName(String activityName) {
        this.activityName = activityName;
    }

    public String getRegionName() {
        return regionName;
    }

    public void setRegionName(String regionName) {
        this.regionName = regionName;
    }

    public Date getStartDateTime() {
        return startDateTime;
    }

    public void setStartDateTime(Date startDateTime) {
        this.startDateTime = startDateTime;
    }

    public Boolean getCancelled() {
        return cancelled;
    }

    public void setCancelled(Boolean cancelled) {
        this.cancelled = cancelled;
    }

    public Integer getAttendedCount() {
        return attendedCount;
    }

    public void setAttendedCount(Integer attendedCount) {
        this.attendedCount = attendedCount;
    }

    public Integer getNotAttendedCount() {
        return notAttendedCount;
    }

    public void setNotAttendedCount(Integer notAttendedCount) {
        this.notAttendedCount = notAttendedCount;
    }

    public Integer getHasStartAndEndDateTimesCount() {
        return hasStartAndEndDateTimesCount;
    }

    public void setHasStartAndEndDateTimesCount(Integer
hasStartAndEndDateTimesCount) {
        this.hasStartAndEndDateTimesCount = hasStartAndEndDateTimesCount;
    }

    public Date getMinStartDateTime() {
        return minStartDateTime;
    }

    public void setMinStartDateTime(Date minStartDateTime) {
        this.minStartDateTime = minStartDateTime;
    }

    public Date getMaxStartDateTime() {
        return maxStartDateTime;
    }

    public void setMaxStartDateTime(Date maxStartDateTime) {
        this.maxStartDateTime = maxStartDateTime;
    }

    public Date getMinEndDateTime() {
        return minEndDateTime;
    }

    public void setMinEndDateTime(Date minEndDateTime) {
        this.minEndDateTime = minEndDateTime;
    }

    public Date getMaxEndDateTime() {
        return maxEndDateTime;
    }

    public void setMaxEndDateTime(Date maxEndDateTime) {
        this.maxEndDateTime = maxEndDateTime;
    }

    public String getMinStartDateTimeName() {
        if (getMinStartDateTime() == null)
            return null;
        else
            return getMinStartDateTime().toString();
    }

    public String getMaxStartDateTimeName() {
        if (getMaxStartDateTime() == null)
            return null;
        else
            return getMaxStartDateTime().toString();
    }

    public String getMinEndDateTimeName() {
        if (getMinEndDateTime() == null)
            return null;
        else
            return getMinEndDateTime().toString();
    }

    public String getMaxEndDateTimeName() {
        if (getMaxEndDateTime() == null)
            return null;
        else
            return getMaxEndDateTime().toString();
    }

    @Override
    public int compareTo(ActivityAttendanceSummary o) {
        // compare on name
        if (getActivityName() != null && o.getActivityName() != null) {
            if (!getActivityName().equals(o.getActivityName()))
                return getActivityName().compareTo(o.getActivityName());
        }
        // compare on start date
        if (getStartDateTime() != null && o.getStartDateTime() != null) {
            if (getStartDateTime().equals(o.getStartDateTime()))
                return 0;
            else if (getStartDateTime().before(o.getStartDateTime()))
                return -1;
            else
                return 1;
        }
        // compare on activity Id
        if (getActivityId() != null && o.getActivityId() != null) {
            if (getActivityId().equals(o.getActivityId()))
                return 0;
            else if (getActivityId() < o.getActivityId())
                return -1;
            else
                return 1;
        } else
            return 0;
    }

}




On Tue, Oct 4, 2016 at 11:58 AM, Stephen Cameron <steve.cameron.62@gmail.com
> wrote:

> Hi,
>
> I've noticed that Dates and Joda DateTimes are not being shown in Wicket
> Viewer from a View Model class based on a database view.
>
> I am using 1.13.0 and a MySQL database.
>
> Its not critical at the moment, I'll look into it further soon.
>
> Steve
>