/** * Simulates the effect of database storing a particular date. * * <p>On MySQL this means dropping all milliseconds! * * <p>On MSSQL produces a discrete values 0,3,7 on the less important position */ private Date adjustToDB(final Date date) { if (Config.isMySQLUsed()) { return new Date((date.getTime() / 1000) * 1000); } // PLA-11109 else if (Config.isSQLServerUsed()) { final long millis = date.getTime(); long roundedmillis = 0; switch ((int) (millis % 10)) { case 0: case 1: roundedmillis = (millis / 10 * 10); break; case 2: case 3: case 4: roundedmillis = (millis / 10 * 10) + 3; break; case 5: case 6: case 7: case 8: roundedmillis = (millis / 10 * 10) + 7; break; case 9: roundedmillis = (millis / 10 * 10) + 10; break; } return new java.util.Date(roundedmillis); } else { return date; } }
/** * This method will be called by system creator during initialization and system update. Be sure * that this method can be called repeatedly. * * @param context the context provides the selected parameters and values */ @SystemSetup(type = Type.ESSENTIAL, process = Process.ALL) public void createEssentialData(final SystemSetupContext context) { final boolean importCustomReports = getBooleanSystemSetupParameter(context, IMPORT_CUSTOM_REPORTS); if (importCustomReports) { if (MediaManager.getInstance() .getMediaFolderByQualifier(V2kartCockpitsConstants.JASPER_REPORTS_MEDIA_FOLDER) .size() < 1) { MediaManager.getInstance() .createMediaFolder( V2kartCockpitsConstants.JASPER_REPORTS_MEDIA_FOLDER, V2kartCockpitsConstants.JASPER_REPORTS_MEDIA_FOLDER); } try { String prefix = null; if (Config.isMySQLUsed()) { prefix = "mysql"; } else if (Config.isHSQLDBUsed()) { prefix = "hsqldb"; } else if (Config.isOracleUsed()) { prefix = "oracle"; } else if (Config.isSQLServerUsed()) { prefix = "sqlserver"; } if (prefix != null) { importImpexFile( context, "/v2kartcockpits/reportcockpit/import/" + prefix + "_jasperreports.impex"); } } catch (final Exception e) { LOG.error("Error during Jasper Report files import " + e); } } }