@Test public void testDefaultDateConversion() { ReportParameters parameters = m_conversionService.convert(m_dao.getParameters(ID)); Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND,0); System.out.println("test date " + cal.getTime().toString()); cal.add(Calendar.DATE, -1); Date configDate = parameters.getDateParms().get(0).getDate(); assertEquals(0, configDate.compareTo(cal.getTime())); }
public ReportParameters convert(Parameters configParameters) { ReportParameters reportParameters = new ReportParameters(); ArrayList<ReportDateParm> dateParms = new ArrayList<ReportDateParm>(); DateParm[] dates = configParameters.getDateParm(); if (dates.length > 0) { for (int i = 0 ; i < dates.length ; i++ ) { ReportDateParm dateParm = new ReportDateParm(); dateParm.setUseAbsoluteDate(dates[i].getUseAbsoluteDate()); dateParm.setDisplayName(dates[i].getDisplayName()); dateParm.setName(dates[i].getName()); dateParm.setCount(new Integer((int) dates[i].getDefaultCount())); dateParm.setInterval(dates[i].getDefaultInterval()); Calendar cal = Calendar.getInstance(); if (dates[i].getDefaultTime() != null) { dateParm.setHours(dates[i].getDefaultTime().getHours()); cal.set(Calendar.HOUR_OF_DAY, dateParm.getHours()); dateParm.setMinutes(dates[i].getDefaultTime().getMinutes()); cal.set(Calendar.MINUTE, dateParm.getMinutes()); } else { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); } cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND,0); int amount = 0 - dates[i].getDefaultCount(); if (dates[i].getDefaultInterval().equals("year")) { cal.add(Calendar.YEAR, amount); } else { if (dates[i].getDefaultInterval().equals("month")) { cal.add(Calendar.MONTH, amount); } else { cal.add(Calendar.DATE, amount); } } dateParm.setDate(cal.getTime()); dateParms.add(dateParm); } } reportParameters.setDateParms(dateParms); ArrayList<ReportStringParm> stringParms = new ArrayList<ReportStringParm>(); StringParm[] strings = configParameters.getStringParm(); if (strings.length > 0) { for (int i = 0 ; i < strings.length ; i++ ) { ReportStringParm stringParm = new ReportStringParm(); stringParm.setDisplayName(strings[i].getDisplayName()); stringParm.setName(strings[i].getName()); stringParm.setInputType(strings[i].getInputType()); stringParm.setValue(strings[i].getDefault()); stringParms.add(stringParm); } } reportParameters.setStringParms(stringParms); ArrayList<ReportIntParm> intParms = new ArrayList<ReportIntParm>(); IntParm[] integers = configParameters.getIntParm(); if (integers.length > 0) { for (int i = 0 ; i < integers.length ; i++ ) { ReportIntParm intParm = new ReportIntParm(); intParm.setDisplayName(integers[i].getDisplayName()); intParm.setName(integers[i].getName()); intParm.setInputType(integers[i].getInputType()); intParm.setValue(integers[i].getDefault()); intParms.add(intParm); } } reportParameters.setIntParms(intParms); return reportParameters; }
DefaultParameterConversionService implements
        ParameterConversionService { public ReportParameters convert(Parameters configParameters) { ReportParameters reportParameters = new ReportParameters(); ArrayList<ReportDateParm> dateParms = new ArrayList<ReportDateParm>(); DateParm[] dates = configParameters.getDateParm(); if (dates.length > 0) { for (int i = 0 ; i < dates.length ; i++ ) { ReportDateParm dateParm = new ReportDateParm(); dateParm.setUseAbsoluteDate(dates[i].getUseAbsoluteDate()); dateParm.setDisplayName(dates[i].getDisplayName()); dateParm.setName(dates[i].getName()); dateParm.setCount(new Integer((int) dates[i].getDefaultCount())); dateParm.setInterval(dates[i].getDefaultInterval()); Calendar cal = Calendar.getInstance(); if (dates[i].getDefaultTime() != null) { dateParm.setHours(dates[i].getDefaultTime().getHours()); cal.set(Calendar.HOUR_OF_DAY, dateParm.getHours()); dateParm.setMinutes(dates[i].getDefaultTime().getMinutes()); cal.set(Calendar.MINUTE, dateParm.getMinutes()); } else { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); } cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND,0); int amount = 0 - dates[i].getDefaultCount(); if (dates[i].getDefaultInterval().equals("year")) { cal.add(Calendar.YEAR, amount); } else { if (dates[i].getDefaultInterval().equals("month")) { cal.add(Calendar.MONTH, amount); } else { cal.add(Calendar.DATE, amount); } } dateParm.setDate(cal.getTime()); dateParms.add(dateParm); } } reportParameters.setDateParms(dateParms); ArrayList<ReportStringParm> stringParms = new ArrayList<ReportStringParm>(); StringParm[] strings = configParameters.getStringParm(); if (strings.length > 0) { for (int i = 0 ; i < strings.length ; i++ ) { ReportStringParm stringParm = new ReportStringParm(); stringParm.setDisplayName(strings[i].getDisplayName()); stringParm.setName(strings[i].getName()); stringParm.setInputType(strings[i].getInputType()); stringParm.setValue(strings[i].getDefault()); stringParms.add(stringParm); } } reportParameters.setStringParms(stringParms); ArrayList<ReportIntParm> intParms = new ArrayList<ReportIntParm>(); IntParm[] integers = configParameters.getIntParm(); if (integers.length > 0) { for (int i = 0 ; i < integers.length ; i++ ) { ReportIntParm intParm = new ReportIntParm(); intParm.setDisplayName(integers[i].getDisplayName()); intParm.setName(integers[i].getName()); intParm.setInputType(integers[i].getInputType()); intParm.setValue(integers[i].getDefault()); intParms.add(intParm); } } reportParameters.setIntParms(intParms); return reportParameters; } }
DefaultParameterConversionService implements
        ParameterConversionService { public ReportParameters convert(Parameters configParameters) { ReportParameters reportParameters = new ReportParameters(); ArrayList<ReportDateParm> dateParms = new ArrayList<ReportDateParm>(); DateParm[] dates = configParameters.getDateParm(); if (dates.length > 0) { for (int i = 0 ; i < dates.length ; i++ ) { ReportDateParm dateParm = new ReportDateParm(); dateParm.setUseAbsoluteDate(dates[i].getUseAbsoluteDate()); dateParm.setDisplayName(dates[i].getDisplayName()); dateParm.setName(dates[i].getName()); dateParm.setCount(new Integer((int) dates[i].getDefaultCount())); dateParm.setInterval(dates[i].getDefaultInterval()); Calendar cal = Calendar.getInstance(); if (dates[i].getDefaultTime() != null) { dateParm.setHours(dates[i].getDefaultTime().getHours()); cal.set(Calendar.HOUR_OF_DAY, dateParm.getHours()); dateParm.setMinutes(dates[i].getDefaultTime().getMinutes()); cal.set(Calendar.MINUTE, dateParm.getMinutes()); } else { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); } cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND,0); int amount = 0 - dates[i].getDefaultCount(); if (dates[i].getDefaultInterval().equals("year")) { cal.add(Calendar.YEAR, amount); } else { if (dates[i].getDefaultInterval().equals("month")) { cal.add(Calendar.MONTH, amount); } else { cal.add(Calendar.DATE, amount); } } dateParm.setDate(cal.getTime()); dateParms.add(dateParm); } } reportParameters.setDateParms(dateParms); ArrayList<ReportStringParm> stringParms = new ArrayList<ReportStringParm>(); StringParm[] strings = configParameters.getStringParm(); if (strings.length > 0) { for (int i = 0 ; i < strings.length ; i++ ) { ReportStringParm stringParm = new ReportStringParm(); stringParm.setDisplayName(strings[i].getDisplayName()); stringParm.setName(strings[i].getName()); stringParm.setInputType(strings[i].getInputType()); stringParm.setValue(strings[i].getDefault()); stringParms.add(stringParm); } } reportParameters.setStringParms(stringParms); ArrayList<ReportIntParm> intParms = new ArrayList<ReportIntParm>(); IntParm[] integers = configParameters.getIntParm(); if (integers.length > 0) { for (int i = 0 ; i < integers.length ; i++ ) { ReportIntParm intParm = new ReportIntParm(); intParm.setDisplayName(integers[i].getDisplayName()); intParm.setName(integers[i].getName()); intParm.setInputType(integers[i].getInputType()); intParm.setValue(integers[i].getDefault()); intParms.add(intParm); } } reportParameters.setIntParms(intParms); return reportParameters; }  }
DefaultParameterConversionService implements
        ParameterConversionService { public ReportParameters convert(Parameters configParameters) { ReportParameters reportParameters = new ReportParameters(); ArrayList<ReportDateParm> dateParms = new ArrayList<ReportDateParm>(); DateParm[] dates = configParameters.getDateParm(); if (dates.length > 0) { for (int i = 0 ; i < dates.length ; i++ ) { ReportDateParm dateParm = new ReportDateParm(); dateParm.setUseAbsoluteDate(dates[i].getUseAbsoluteDate()); dateParm.setDisplayName(dates[i].getDisplayName()); dateParm.setName(dates[i].getName()); dateParm.setCount(new Integer((int) dates[i].getDefaultCount())); dateParm.setInterval(dates[i].getDefaultInterval()); Calendar cal = Calendar.getInstance(); if (dates[i].getDefaultTime() != null) { dateParm.setHours(dates[i].getDefaultTime().getHours()); cal.set(Calendar.HOUR_OF_DAY, dateParm.getHours()); dateParm.setMinutes(dates[i].getDefaultTime().getMinutes()); cal.set(Calendar.MINUTE, dateParm.getMinutes()); } else { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); } cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND,0); int amount = 0 - dates[i].getDefaultCount(); if (dates[i].getDefaultInterval().equals("year")) { cal.add(Calendar.YEAR, amount); } else { if (dates[i].getDefaultInterval().equals("month")) { cal.add(Calendar.MONTH, amount); } else { cal.add(Calendar.DATE, amount); } } dateParm.setDate(cal.getTime()); dateParms.add(dateParm); } } reportParameters.setDateParms(dateParms); ArrayList<ReportStringParm> stringParms = new ArrayList<ReportStringParm>(); StringParm[] strings = configParameters.getStringParm(); if (strings.length > 0) { for (int i = 0 ; i < strings.length ; i++ ) { ReportStringParm stringParm = new ReportStringParm(); stringParm.setDisplayName(strings[i].getDisplayName()); stringParm.setName(strings[i].getName()); stringParm.setInputType(strings[i].getInputType()); stringParm.setValue(strings[i].getDefault()); stringParms.add(stringParm); } } reportParameters.setStringParms(stringParms); ArrayList<ReportIntParm> intParms = new ArrayList<ReportIntParm>(); IntParm[] integers = configParameters.getIntParm(); if (integers.length > 0) { for (int i = 0 ; i < integers.length ; i++ ) { ReportIntParm intParm = new ReportIntParm(); intParm.setDisplayName(integers[i].getDisplayName()); intParm.setName(integers[i].getName()); intParm.setInputType(integers[i].getInputType()); intParm.setValue(integers[i].getDefault()); intParms.add(intParm); } } reportParameters.setIntParms(intParms); return reportParameters; }  ReportParameters convert(Parameters configParameters); }
DefaultParameterConversionService implements
        ParameterConversionService { public ReportParameters convert(Parameters configParameters) { ReportParameters reportParameters = new ReportParameters(); ArrayList<ReportDateParm> dateParms = new ArrayList<ReportDateParm>(); DateParm[] dates = configParameters.getDateParm(); if (dates.length > 0) { for (int i = 0 ; i < dates.length ; i++ ) { ReportDateParm dateParm = new ReportDateParm(); dateParm.setUseAbsoluteDate(dates[i].getUseAbsoluteDate()); dateParm.setDisplayName(dates[i].getDisplayName()); dateParm.setName(dates[i].getName()); dateParm.setCount(new Integer((int) dates[i].getDefaultCount())); dateParm.setInterval(dates[i].getDefaultInterval()); Calendar cal = Calendar.getInstance(); if (dates[i].getDefaultTime() != null) { dateParm.setHours(dates[i].getDefaultTime().getHours()); cal.set(Calendar.HOUR_OF_DAY, dateParm.getHours()); dateParm.setMinutes(dates[i].getDefaultTime().getMinutes()); cal.set(Calendar.MINUTE, dateParm.getMinutes()); } else { cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); } cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND,0); int amount = 0 - dates[i].getDefaultCount(); if (dates[i].getDefaultInterval().equals("year")) { cal.add(Calendar.YEAR, amount); } else { if (dates[i].getDefaultInterval().equals("month")) { cal.add(Calendar.MONTH, amount); } else { cal.add(Calendar.DATE, amount); } } dateParm.setDate(cal.getTime()); dateParms.add(dateParm); } } reportParameters.setDateParms(dateParms); ArrayList<ReportStringParm> stringParms = new ArrayList<ReportStringParm>(); StringParm[] strings = configParameters.getStringParm(); if (strings.length > 0) { for (int i = 0 ; i < strings.length ; i++ ) { ReportStringParm stringParm = new ReportStringParm(); stringParm.setDisplayName(strings[i].getDisplayName()); stringParm.setName(strings[i].getName()); stringParm.setInputType(strings[i].getInputType()); stringParm.setValue(strings[i].getDefault()); stringParms.add(stringParm); } } reportParameters.setStringParms(stringParms); ArrayList<ReportIntParm> intParms = new ArrayList<ReportIntParm>(); IntParm[] integers = configParameters.getIntParm(); if (integers.length > 0) { for (int i = 0 ; i < integers.length ; i++ ) { ReportIntParm intParm = new ReportIntParm(); intParm.setDisplayName(integers[i].getDisplayName()); intParm.setName(integers[i].getName()); intParm.setInputType(integers[i].getInputType()); intParm.setValue(integers[i].getDefault()); intParms.add(intParm); } } reportParameters.setIntParms(intParms); return reportParameters; }  ReportParameters convert(Parameters configParameters);  }