• bug ,search by date range

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #6665  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);
		}
 #6677  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
 #6692  by pavila
 
Please, attach the patch here to be included in OpenKM 5.0 final.
 #6728  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;
				}
 #6736  by jllort
 
Thanks for reporting the problem wangmj, really it's the typical tedious error that's not easy to find.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.