Page 1 of 1

bug ,search by date range

PostPosted:Mon Oct 04, 2010 8:39 am
by wangmj
1、login the openKM system, cilck the search panel
2、select the start date 2010-08-01,and the end date 2010-10-02,then click the search button
3、openkm the log file "server.log",

2010-10-04 16:31:09,187 DEBUG [com.openkm.module.direct.DirectSearchModule] prepareStatement: /jcr:root/okm:root//*[@jcr:primaryType eq 'okm:void' or (@jcr:primaryType eq 'okm:document' and (@okm:content/jcr:lastModified >= xs:dateTime('2010-10-01T00:00:00.000+08:00') and @okm:content/jcr:lastModified <= xs:dateTime('2010-10-02T00:00:00.000+08:00')))] order by @jcr:score descending

you will find the date changed!

=============solution=====================
1.open the source file com.openkm.frontend.client.widget.searchin.SearchIn.java
2.goto line 130
Code: Select all
	private Date modifyDateFrom;
	private Date modifyDateTo;
change to
Code: Select all
	private Date modifyDateFrom;
	private Date modifyDateTo;
	private long modifyDateFromLong; 
	private long modifyDateToLong;	
Code: Select all
		calendar.addChangeHandler(new ChangeHandler(){
			@Override
			public void onChange(ChangeEvent event) {
				calendarPopup.hide();
				DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern"));
				
				switch (calendarFired) {
					case CALENDAR_FIRED_START:
						startDate.setText(dtf.format(calendar.getDate()));
						modifyDateFrom = calendar.getDate();
						break;
					
					case CALENDAR_FIRED_END:
						endDate.setText(dtf.format(calendar.getDate()));
						modifyDateTo = calendar.getDate();
						break;
				}
				calendarFired = CALENDAR_FIRED_NONE;
				evaluateSearchButtonVisible();	
			}
		});
change to
Code: Select all
		calendar.addChangeHandler(new ChangeHandler(){
			@Override
			public void onChange(ChangeEvent event) {
				calendarPopup.hide();
				DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.day.pattern"));
				
				switch (calendarFired) {
					case CALENDAR_FIRED_START:
						startDate.setText(dtf.format(calendar.getDate()));
						modifyDateFrom = calendar.getDate();
						modifyDateFromLong = calendar.getDate().getTime();
						Log.debug("modifyDateFrom="+modifyDateFrom+"||modifyDateFromLong="+modifyDateFromLong);	
						break;
					
					case CALENDAR_FIRED_END:
						endDate.setText(dtf.format(calendar.getDate()));
						modifyDateTo = calendar.getDate();
						modifyDateToLong = calendar.getDate().getTime();
						Log.debug("modifyDateTo="+modifyDateTo+"||modifyDateToLong="+modifyDateToLong);	
						break;
				}
				calendarFired = CALENDAR_FIRED_NONE;
				evaluateSearchButtonVisible();	
			}
		});
Code: Select all
		if (modifyDateFrom!=null && modifyDateTo!=null) {
			gwtParams.setLastModifiedFrom(modifyDateFrom);
			gwtParams.setLastModifiedTo(modifyDateTo);
		} else {
			gwtParams.setLastModifiedFrom(null);
			gwtParams.setLastModifiedTo(null);
		}
change to
Code: Select all
		if (modifyDateFrom!=null && modifyDateTo!=null) {
//			gwtParams.setLastModifiedFrom(modifyDateFrom);  //fixed by wangmj 
//			gwtParams.setLastModifiedTo(modifyDateTo);
			gwtParams.setLastModifiedFrom(new Date(modifyDateFromLong));
			gwtParams.setLastModifiedTo(new Date(modifyDateToLong));
		} else {
			gwtParams.setLastModifiedFrom(null);
			gwtParams.setLastModifiedTo(null);
		}

Re: bug ,search by date range

PostPosted:Mon Oct 04, 2010 8:40 pm
by jllort
Good job, send to me the eclipse patch and I'll apply to svn ( selecting document / then menu and here there's some option in team to create the patch file)

You're developing in version 4.x or 5.x ?

Next time post in developer forum, seems better place than usage.

Thanks for your support wangmj

Re: bug ,search by date range

PostPosted:Tue Oct 05, 2010 3:19 am
by wangmj
ok ,both versin 4.x and 5.x.

Re: bug ,search by date range

PostPosted:Tue Oct 05, 2010 8:13 am
by pavila
Please, attach the patch here to be included in OpenKM 5.0 final.

Re: bug ,search by date range

PostPosted:Tue Oct 05, 2010 3:24 pm
by wangmj
openkm 5.x

Re: bug ,search by date range

PostPosted:Tue Oct 05, 2010 4:44 pm
by jllort
ok, thanks

Re: bug ,search by date range

PostPosted:Wed Oct 06, 2010 4:17 pm
by jllort
I've added solution in svn. The problem is the Date object that's something special.
Code: Select all
switch (calendarFired) {
					case CALENDAR_FIRED_START:
						startDate.setText(dtf.format(calendar.getDate()));
						modifyDateFrom = (Date)calendar.getDate().clone();
						break;
					
					case CALENDAR_FIRED_END:
						endDate.setText(dtf.format(calendar.getDate()));
						modifyDateTo = (Date)calendar.getDate().clone();
						break;
				}

Re: bug ,search by date range

PostPosted:Thu Oct 07, 2010 12:52 am
by wangmj
good solution!

Re: bug ,search by date range

PostPosted:Thu Oct 07, 2010 5:45 am
by jllort
Thanks for reporting the problem wangmj, really it's the typical tedious error that's not easy to find.