List of usage examples for java.sql Timestamp getTime
public long getTime()
From source file:com.collabnet.ccf.core.EntityService2.java
/** * This method looks up whether the artifact has been quarantined in the * hospital and has not been reprocessed yet. If so, it will find out * whether to skip the artifact or not./*from www. j a v a 2 s . com*/ * * @param sourceArtifactId * - The source artifact id that should be looked up for a target * artifact id * @param sourceSystemId * - The system id of the source repository * @param sourceRepositoryId * - The repository id of the source artifact * @param targetSystemId * - The system id of the target repository * @param targetRepositoryId * - The repository id of the target artifact * @param artifactType * - The artifact type * @param sourceArtifactVersionInt * version of the current artifact * @param sourceArtifactLastModifiedDate * last modified date of the current artifact * * @return true if artifact should be skipped, false if not */ private boolean skipQuarantinedArtifact(Element element, String sourceArtifactId, String sourceSystemId, String sourceRepositoryId, String targetSystemId, String targetRepositoryId, String artifactType, Date sourceArtifactLastModifiedDate, long sourceArtifactVersionLong, boolean onlyCheckIfQuarantinedArtifactExists, String repositoryMappingDirectionId) { // only if a connection to the hospital table is possible we can skip // artifacts if (getHospitalDatabaseReader() == null) { return false; } IOrderedMap inputParameters = new OrderedHashMap(); inputParameters.add(repositoryMappingDirectionId); inputParameters.add(sourceArtifactId); inputParameters.add(artifactType); // hospitalDatabaseReader.disconnect(); hospitalDatabaseReader.connect(); // TODO Find out whether 10000 is enough in hard cases Object[] resultSet = hospitalDatabaseReader.next(inputParameters, 10000); // hospitalDatabaseReader.disconnect(); if (resultSet == null || resultSet.length == 0) { // artifact is not in the hospital return false; } else if (onlyCheckIfQuarantinedArtifactExists) { return true; } else if (isSkipNewerVersionsOfQuarantinedArtifacts()) { // we do not have to compare version numbers since we skip every // version of the artifact log.warn("At least one entry for combination " + sourceArtifactId + "-" + sourceRepositoryId + "-" + sourceSystemId + targetRepositoryId + "-" + targetSystemId + " is still in the hospital and not yet reprocessed, skipping it ..."); return true; } for (Object resultObject : resultSet) { if (resultObject instanceof OrderedHashMap) { OrderedHashMap result = (OrderedHashMap) resultObject; if (result.size() == 3) { Date sourceArtifactLastModifiedDateFromTable; String hospitalId = result.get(0).toString(); Timestamp timeStamp = (Timestamp) result.get(1); if (timeStamp == null) { // use earliest date possible sourceArtifactLastModifiedDateFromTable = new Date(0); } else { sourceArtifactLastModifiedDateFromTable = new Date(timeStamp.getTime()); } String sourceArtifactVersionFromTable = result.get(2).toString(); if (sourceArtifactVersionFromTable.equalsIgnoreCase(GenericArtifact.VALUE_UNKNOWN)) { sourceArtifactVersionFromTable = GenericArtifactHelper.ARTIFACT_VERSION_FORCE_RESYNC; } long sourceArtifactVersionLongFromTable = Long.parseLong(sourceArtifactVersionFromTable); if (sourceArtifactLastModifiedDateFromTable.after(sourceArtifactLastModifiedDate) || sourceArtifactVersionLongFromTable >= sourceArtifactVersionLong) { if (sourceArtifactVersionLong == -1 && sourceArtifactVersionLongFromTable == -1) { log.warn( "It seems as if artifact synchronization is done exclusively with a system that does not support version control, so artifact from combination " + sourceArtifactId + "-" + sourceRepositoryId + "-" + sourceSystemId + targetRepositoryId + "-" + targetSystemId + " will not be skipped despite it is in the hospital. Hospital ID: " + hospitalId); } else { if (rmdDryModeHandler.isDryRunMode(repositoryMappingDirectionId)) { log.info("Dont Repeat the artifact from combination" + sourceArtifactId + "-" + sourceRepositoryId + "-" + sourceSystemId + targetRepositoryId + "-" + targetSystemId + " as repository mapping direction id " + repositoryMappingDirectionId + " is in dry-run mode. To reprocess the artifact,stop the dry-run mode for the repository mapping direction and delete the corresponding entry from Hospital"); } else { log.warn("Non re-processed artifact from combination " + sourceArtifactId + "-" + sourceRepositoryId + "-" + sourceSystemId + targetRepositoryId + "-" + targetSystemId + " is still in the hospital in a newer or equal version, so skipping it. Hospital ID: " + hospitalId); } return true; } } } else { String cause = "Seems as if the SQL statement for hospitalDatabase reader does not return 3 values."; XPathUtils.addAttribute(element, GenericArtifactHelper.ERROR_CODE, GenericArtifact.ERROR_INTERNAL_DATABASE_TABLE_CORRUPT); log.error(cause); throw new CCFRuntimeException(cause); } } else { String cause = "SQL query on hospital table did not return data in correct format!"; XPathUtils.addAttribute(element, GenericArtifactHelper.ERROR_CODE, GenericArtifact.ERROR_INTERNAL_DATABASE_TABLE_CORRUPT); log.error(cause); throw new CCFRuntimeException(cause); } } log.info("Only older non-reprocessed versions of artifact combination " + sourceArtifactId + "-" + sourceRepositoryId + "-" + sourceSystemId + "-" + targetRepositoryId + "-" + targetSystemId + " are in the hospital, so pass artifact ..."); return false; }
From source file:edu.internet2.middleware.grouper.internal.dao.hib3.Hib3PermissionEntryDAO.java
/** * @see PermissionEntryDAO#findPermissionsByAttributeDefDisabledRange(String, Timestamp, Timestamp) * find permissions by attribute definition which are about to expire */// w w w . j ava 2s . c o m public Set<PermissionEntry> findPermissionsByAttributeDefDisabledRange(String attributeDefId, Timestamp disabledDateFrom, Timestamp disabledDateTo) { if (disabledDateFrom == null && disabledDateTo == null) { throw new RuntimeException("Need to pass in disabledFrom or disabledTo"); } //if they got it backwards, then fix it for them if (disabledDateFrom != null && disabledDateTo != null && disabledDateFrom.getTime() > disabledDateTo.getTime()) { Timestamp temp = disabledDateFrom; disabledDateFrom = disabledDateTo; disabledDateTo = temp; } ByHqlStatic byHqlStatic = HibernateSession.byHqlStatic(); StringBuilder sql = new StringBuilder("select " + PERMISSION_ENTRY_COLUMNS + " from " + PERMISSION_ENTRY_TABLES + ", AttributeDefName theAttributeDefName where " + PERMISSION_ENTRY_WHERE_CLAUSE + " and gadn.id = theAttributeDefName.id " + " and theAttributeDefName.attributeDefId = :theAttributeDefId " + " and gm.uuid is not null " + " and gaa.enabledDb = 'T' "); if (disabledDateFrom != null) { sql.append(" and gaa.disabledTimeDb >= :disabledDateFrom "); byHqlStatic.setLong("disabledDateFrom", disabledDateFrom.getTime()); } if (disabledDateTo != null) { sql.append(" and gaa.disabledTimeDb <= :disabledDateTo "); byHqlStatic.setLong("disabledDateTo", disabledDateTo.getTime()); } sql.append(" and not exists ( select gaaInner.id from " + PERMISSION_ENTRY_TABLES.replaceAll("(\\w+) (\\w+)", "$1 $2Inner") + " where " + PERMISSION_ENTRY_WHERE_CLAUSE.replace(".", "Inner.") + " and gadnInner.id = gadn.id " + " and gaaaInner.id = gaaa.id " + //note, who cares which role it is, if the user has the permission... (not exactly right if not flattening permissions, but thats ok) //" and validPermissionEntry.roleId = thePermissionEntry.roleId " + " and gmInner.uuid = gm.uuid " + " and gaaInner.enabledDb = 'T' and ( gaaInner.disabledTimeDb is null "); if (disabledDateTo != null) { sql.append(" or gaaInner.disabledTimeDb > :disabledDateTo "); } else if (disabledDateFrom != null) { sql.append(" or gaaInner.disabledTimeDb < :disabledDateFrom "); } sql.append(") )"); Set<PermissionEntryImpl> permissionEntries = byHqlStatic.createQuery(sql.toString()).setCacheable(false) .setCacheRegion(KLASS + ".FindPermissionsByAttributeDefDisabledRange") .setString("theAttributeDefId", attributeDefId).assignConvertHqlColumnsToObject(true) .listSet(PermissionEntryImpl.class); return new LinkedHashSet<PermissionEntry>(permissionEntries); }
From source file:fr.paris.lutece.plugins.stock.modules.billetterie.web.StatisticJspBean.java
/** * Gets the form result page.// ww w.j av a2s .c om * * @param request the http request * @return the form test page */ public String getManageProducts(HttpServletRequest request) { Locale locale = getLocale(); HtmlTemplate template; int nNumberResponse = 0; Map<String, Object> model = new HashMap<String, Object>(); String strFistResponseDateFilter = request.getParameter(PARAMETER_FIRST_RESPONSE_DATE_FILTER); String strLastResponseDateFilter = request.getParameter(PARAMETER_LAST_RESPONSE_DATE_FILTER); String strTimesUnit = request.getParameter(PARAMETER_TIMES_UNIT); if ((strFistResponseDateFilter != null) && (strLastResponseDateFilter != null) && !strFistResponseDateFilter.equals(StringUtils.EMPTY) && !strLastResponseDateFilter.equals(StringUtils.EMPTY)) { if (DateUtil.formatDate(strFistResponseDateFilter, locale) .after(DateUtil.formatDate(strLastResponseDateFilter, locale))) { BusinessException fe = new BusinessException(null, MESSAGE_ERROR_INVALID_DATE); model.put(BilletterieConstants.ERROR, getHtmlError(fe)); } } Timestamp tFistResponseDateFilter = null; Timestamp tLastResponseDateFilter = null; if (strFistResponseDateFilter != null) { tFistResponseDateFilter = DateUtils .getDateFirstMinute(DateUtil.formatDate(strFistResponseDateFilter, locale)); } if (strLastResponseDateFilter != null) { tLastResponseDateFilter = DateUtils .getDateLastMinute(DateUtil.formatDate(strLastResponseDateFilter, locale)); } nNumberResponse = _serviceStatistic.getCountProductsByDates(strFistResponseDateFilter, strLastResponseDateFilter); if (strTimesUnit == null) { strTimesUnit = CONSTANT_GROUP_BY_DAY; } model.put(MARK_LOCALE, AdminUserService.getLocale(request).getLanguage()); model.put(MARK_NUMBER_RESPONSE, nNumberResponse); model.put(MARK_FIRST_RESPONSE_DATE_FILTER, (tFistResponseDateFilter == null) ? null : new Date(tFistResponseDateFilter.getTime())); model.put(MARK_LAST_RESPONSE_DATE_FILTER, (tLastResponseDateFilter == null) ? null : new Date(tLastResponseDateFilter.getTime())); model.put(MARK_TIMES_UNIT, strTimesUnit); // model.put( MARK_EXPORT_FORMAT_REF_LIST, ExportFormatHome.getListExport( plugin ) ); model.put("beanName", "product"); setPageTitleProperty(PAGE_TITLE_MANAGE_PRODUCTS); template = AppTemplateService.getTemplate(TEMPLATE_MANAGE_PRODUCTS_STATISTICS, locale, model); return getAdminPage(template.getHtml()); }
From source file:fr.paris.lutece.plugins.stock.modules.billetterie.web.StatisticJspBean.java
/** * Gets the form result page./*www . j av a 2s .co m*/ * * @param request the http request * @return the form test page */ public String getManagePurchases(HttpServletRequest request) { Locale locale = getLocale(); HtmlTemplate template; int nNumberResponse = 0; Map<String, Object> model = new HashMap<String, Object>(); String strFistResponseDateFilter = request.getParameter(PARAMETER_FIRST_RESPONSE_DATE_FILTER); String strLastResponseDateFilter = request.getParameter(PARAMETER_LAST_RESPONSE_DATE_FILTER); String strTimesUnit = request.getParameter(PARAMETER_TIMES_UNIT); if ((strFistResponseDateFilter != null) && (strLastResponseDateFilter != null) && !strFistResponseDateFilter.equals(StringUtils.EMPTY) && !strLastResponseDateFilter.equals(StringUtils.EMPTY)) { if (DateUtil.formatDate(strFistResponseDateFilter, locale) .after(DateUtil.formatDate(strLastResponseDateFilter, locale))) { BusinessException fe = new BusinessException(null, MESSAGE_ERROR_INVALID_DATE); model.put(BilletterieConstants.ERROR, getHtmlError(fe)); } } Timestamp tFistResponseDateFilter = null; Timestamp tLastResponseDateFilter = null; if (strFistResponseDateFilter != null) { tFistResponseDateFilter = DateUtils .getDateFirstMinute(DateUtil.formatDate(strFistResponseDateFilter, locale)); } if (strLastResponseDateFilter != null) { tLastResponseDateFilter = DateUtils .getDateLastMinute(DateUtil.formatDate(strLastResponseDateFilter, locale)); } nNumberResponse = _serviceStatistic.getCountPurchasesByDates(strFistResponseDateFilter, strLastResponseDateFilter); if (strTimesUnit == null) { strTimesUnit = CONSTANT_GROUP_BY_DAY; } model.put(MARK_LOCALE, AdminUserService.getLocale(request).getLanguage()); model.put(MARK_NUMBER_RESPONSE, nNumberResponse); model.put(MARK_FIRST_RESPONSE_DATE_FILTER, (tFistResponseDateFilter == null) ? null : new Date(tFistResponseDateFilter.getTime())); model.put(MARK_LAST_RESPONSE_DATE_FILTER, (tLastResponseDateFilter == null) ? null : new Date(tLastResponseDateFilter.getTime())); model.put(MARK_TIMES_UNIT, strTimesUnit); //model.put( MARK_EXPORT_FORMAT_REF_LIST, ExportFormatHome.getListExport( plugin ) ); setPageTitleProperty(PAGE_TITLE_MANAGE_PURCHASE); template = AppTemplateService.getTemplate(TEMPLATE_MANAGE_PURCHASE_STATISTICS, locale, model); return getAdminPage(template.getHtml()); }
From source file:com.flexive.core.search.PropertyEntry.java
/** * Return the result value of this property entry in a given result set. * * @param rs the SQL result set//from w w w . j av a2 s .c o m * @param languageId id of the requested language * @param xpathAvailable if the XPath was selected as an additional column for content table entries * @param typeId the result row type ID (if available, otherwise -1) * @return the value of this property (column) in the result set * @throws FxSqlSearchException if the database cannot read the value */ public Object getResultValue(ResultSet rs, long languageId, boolean xpathAvailable, long typeId) throws FxSqlSearchException { final FxValue result; final int pos = positionInResultSet; // Handle by type try { switch (overrideDataType == null ? property.getDataType() : overrideDataType) { case DateTime: switch (rs.getMetaData().getColumnType(pos)) { case java.sql.Types.BIGINT: case java.sql.Types.DECIMAL: case java.sql.Types.NUMERIC: case java.sql.Types.INTEGER: result = new FxDateTime(multilanguage, FxLanguage.SYSTEM_ID, new Date(rs.getLong(pos))); break; default: Timestamp dttstp = rs.getTimestamp(pos); Date _dtdate = dttstp != null ? new Date(dttstp.getTime()) : null; result = new FxDateTime(multilanguage, FxLanguage.SYSTEM_ID, _dtdate); if (dttstp == null) result.setEmpty(FxLanguage.SYSTEM_ID); } break; case Date: Timestamp tstp = rs.getTimestamp(pos); result = new FxDate(multilanguage, FxLanguage.SYSTEM_ID, tstp != null ? new Date(tstp.getTime()) : null); if (tstp == null) { result.setEmpty(); } break; case DateRange: final Pair<Date, Date> pair = decodeDateRange(rs, pos, 1); if (pair.getFirst() == null || pair.getSecond() == null) { result = new FxDateRange(multilanguage, FxLanguage.SYSTEM_ID, FxDateRange.EMPTY); result.setEmpty(FxLanguage.SYSTEM_ID); } else { result = new FxDateRange(multilanguage, FxLanguage.SYSTEM_ID, new DateRange(pair.getFirst(), pair.getSecond())); } break; case DateTimeRange: final Pair<Date, Date> pair2 = decodeDateRange(rs, pos, 1); if (pair2.getFirst() == null || pair2.getSecond() == null) { result = new FxDateTimeRange(multilanguage, FxLanguage.SYSTEM_ID, FxDateRange.EMPTY); result.setEmpty(FxLanguage.SYSTEM_ID); } else { result = new FxDateTimeRange(new DateRange(pair2.getFirst(), pair2.getSecond())); } break; case HTML: result = new FxHTML(multilanguage, FxLanguage.SYSTEM_ID, rs.getString(pos)); break; case String1024: case Text: result = new FxString(multilanguage, FxLanguage.SYSTEM_ID, rs.getString(pos)); break; case LargeNumber: result = new FxLargeNumber(multilanguage, FxLanguage.SYSTEM_ID, rs.getLong(pos)); break; case Number: result = new FxNumber(multilanguage, FxLanguage.SYSTEM_ID, rs.getInt(pos)); break; case Float: result = new FxFloat(multilanguage, FxLanguage.SYSTEM_ID, rs.getFloat(pos)); break; case Boolean: result = new FxBoolean(multilanguage, FxLanguage.SYSTEM_ID, rs.getBoolean(pos)); break; case Double: result = new FxDouble(multilanguage, FxLanguage.SYSTEM_ID, rs.getDouble(pos)); break; case Reference: result = new FxReference(new ReferencedContent(new FxPK(rs.getLong(pos), FxPK.MAX))); // TODO!! break; case SelectOne: FxSelectListItem oneItem = getEnvironment().getSelectListItem(rs.getLong(pos)); result = new FxSelectOne(multilanguage, FxLanguage.SYSTEM_ID, oneItem); break; case SelectMany: FxSelectListItem manyItem = getEnvironment().getSelectListItem(rs.getLong(pos)); SelectMany valueMany = new SelectMany(manyItem.getList()); valueMany.selectFromList(rs.getString(pos + 1)); result = new FxSelectMany(multilanguage, FxLanguage.SYSTEM_ID, valueMany); break; case Binary: result = new FxBinary(multilanguage, FxLanguage.SYSTEM_ID, DataSelector.decodeBinary(rs, pos)); break; default: throw new FxSqlSearchException(LOG, "ex.sqlSearch.reader.UnknownColumnType", String.valueOf(getProperty().getDataType())); } if (rs.wasNull()) { result.setEmpty(languageId); } int currentPosition = positionInResultSet + getReadColumns().length; // process XPath if (isProcessXPath()) { if (xpathAvailable && getTableType() == PropertyResolver.Table.T_CONTENT_DATA) { // Get the XPATH if we are reading from the content data table result.setXPath(rebuildXPath(rs.getString(currentPosition++))); } else if (xpathAvailable && getTableType() == PropertyResolver.Table.T_CONTENT && property != null) { // set XPath for system-internal properties result.setXPath("ROOT/" + property.getName()); } else if (getTableType() == PropertyResolver.Table.T_CONTENT_DATA_FLAT) { // fill in XPath from assignment, create XPath with full type information if (typeId != -1) { result.setXPath(getEnvironment().getType(typeId).getName() + "/" + assignment.getAlias()); } } } else { result.setXPath(null); } // process data if (isProcessData() && getTableType() != null) { final Integer valueData; switch (getTableType()) { case T_CONTENT_DATA: final int data = rs.getInt(currentPosition++); valueData = rs.wasNull() ? null : data; break; case T_CONTENT_DATA_FLAT: // comma-separated string with the data entries of all columns final String csvData = rs.getString(currentPosition++); valueData = FxArrayUtils.getHexIntElementAt(csvData, ',', flatColumnIndex); break; default: // no value data in other tables valueData = null; } result.setValueData(languageId, valueData); } return result; } catch (SQLException e) { throw new FxSqlSearchException(e); } }
From source file:org.siphon.jssql.SqlExecutor.java
private Object jdbcReturnTypeToJsObject(Object obj) throws SQLException, SqlExecutorException, ScriptException { if (obj == null) { return null; } else if (obj instanceof String) { return obj; } else if (obj instanceof BigDecimal) { return ((BigDecimal) obj).doubleValue(); } else if (obj instanceof Integer) { return ((Integer) obj).doubleValue(); } else if (obj instanceof Float) { return ((Float) obj).doubleValue(); } else if (obj instanceof Double) { return ((Double) obj).doubleValue(); } else if (obj instanceof Byte) { return ((Byte) obj).doubleValue(); } else if (obj instanceof Long) { return ((Long) obj).doubleValue(); } else if (obj instanceof Timestamp) { Timestamp tstmp = ((java.sql.Timestamp) obj); return jsTypeUtil.toNativeDate(tstmp.getTime()); } else if (obj instanceof java.sql.Date) { return jsTypeUtil.toNativeDate(((java.sql.Date) obj).getTime()); } else if (obj instanceof Time) { return jsTypeUtil.toNativeDate(((java.sql.Time) obj).getTime()); } else if (obj instanceof RowId) { return jsTypeUtil.bytesToNativeArray(((RowId) obj).getBytes()); } else if (obj instanceof Boolean) { return ((Boolean) obj).booleanValue(); } else if (obj instanceof byte[]) { // return bytesToNativeArray((byte[]) obj); return (byte[]) obj; } else if (obj instanceof Clob) { Reader strm = ((Clob) obj).getCharacterStream(); StringBuffer sb = new StringBuffer(); char[] buff = new char[1024]; int count = 0; try {//from w w w.j a v a 2 s .c o m while ((count = strm.read(buff)) > 0) { sb.append(buff, 0, count); } } catch (IOException e) { throw new SqlExecutorException("", e); } finally { try { strm.close(); } catch (IOException e) { } } return sb.toString(); } else if (obj instanceof Blob) { InputStream in = ((Blob) obj).getBinaryStream(); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { byte[] buff1 = new byte[1024]; for (int i = 0; (i = in.read(buff1)) > 0;) { out.write(buff1, 0, i); } out.flush(); in.close(); byte[] bytes = out.toByteArray(); out.close(); // return bytesToNativeArray(bytes); return bytes; } catch (IOException e) { throw new SqlExecutorException("got an error when read blob", e); } } else if (obj instanceof Array) { ScriptObjectMirror result = jsTypeUtil.newArray(); NativeArray narr = result.to(NativeArray.class); Object arr = ((Array) obj).getArray(); for (int i = 0; i < java.lang.reflect.Array.getLength(arr); i++) { Object v = jdbcReturnTypeToJsObject(java.lang.reflect.Array.get(arr, i)); // NativeArray.push(narr, v); result.callMember("push", v); } return result; } else if (obj instanceof UUID) { return obj.toString(); } else if (obj instanceof PGobject) { PGobject pgObj = (PGobject) obj; if ("jsonb".equals(pgObj.getType()) || "json".equals(pgObj.getType())) { try { return JSON.parse((String) pgObj.getValue()); } catch (Exception e) { throw new SqlExecutorException("cannot parse json " + obj + " " + obj.getClass()); } } else { throw new SqlExecutorException("unknown object type " + obj + " " + obj.getClass()); } } else { throw new SqlExecutorException("unknown object type " + obj + " " + obj.getClass()); } }
From source file:org.eevolution.form.VCRP.java
public CategoryDataset createDataset(Timestamp start, MResource r) { //System.out.println("Create new data set"); GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTimeInMillis(start.getTime()); gc1.clear(Calendar.MILLISECOND); gc1.clear(Calendar.SECOND);// w w w . j a va 2 s. c o m gc1.clear(Calendar.MINUTE); gc1.clear(Calendar.HOUR_OF_DAY); Timestamp date = start; String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); System.out.println("\n Namecapacity :" + namecapacity); String nameload = Msg.translate(Env.getCtx(), "Load"); System.out.println("\n Nameload :" + nameload); String namesummary = Msg.translate(Env.getCtx(), "Summary"); System.out.println("\n Namesummary :" + namesummary); MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); System.out.println("\n Resourcetype " + t); int days = 1; long hours = 0; if (t.isTimeSlot()) { hours = MMPCMRP.getHoursAvailable(t.getTimeSlotStart(), t.getTimeSlotEnd()); } else { //fjviejo e-evolution MachineQty if (r.getDailyCapacity().multiply(r.getMachineQty()).compareTo(Env.ZERO) != 0) hours = r.getDailyCapacity().multiply(r.getMachineQty()).longValue(); else //fjviejo e-evolution end hours = 24; } DefaultCategoryDataset dataset = new DefaultCategoryDataset(); // Long Hours = new Long(hours); int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ", r.getS_Resource_ID()); MUOM uom = new MUOM(Env.getCtx(), C_UOM_ID, null); System.out.println("\n uom1 " + uom + "\n"); //System.out.println("um.isHour()"+ uom.isHour() ); if (!uom.isHour()) { System.out.println("\n uom2 " + uom + "\n"); return dataset; } System.out.println("\n Dataset " + dataset + "\n"); int summary = 0; //int cont = 1; DateFormat formatter = DateFormat.getDateInstance(); /* * Vit4B Modificado para que tome 28 dias y * * */ while (days < 29) { /* * VIT4B MODIFICACION PARA ACUMULADO DE DIAS * * * //System.out.println("Day Number" + days); String strday = formatter.format(date); //String day = new String(new Integer (date.getDate()).toString()); String day = new String(formatter.format(date)); //day = day.substring(0,5); int index = day.indexOf("/"); String str = day.substring(0,index); System.out.println("str: " + str + " index de / " + index); String str2 = day.substring(index+1,day.length()); System.out.println("str2 resto: " + str2); index = str2.indexOf("/"); System.out.println(index); String str3 = str2.substring(0,index); System.out.println("str3: " + str3 + " index de / " + index); String str4 = str2.substring(index+1,str2.length()); System.out.println(str4); System.out.println("dia: " + str); System.out.println("mes: " + str3); System.out.println("ao: " + str4); //day = str + str3; day = new String(str + str3); //day = day.substring(0,day.lastIndexOf("/")); //day =day.substring(0,3); //cont++; System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID()); System.out.println("Date: " + date + " day: " + day); int seconds = getLoad(r.getS_Resource_ID(),date ,date); Long Hours = new Long(hours); System.out.println("Summary "+ summary); System.out.println("Capacity "+ hours); System.out.println("Load "+ seconds); /* * * VIT4B MODIFICACION PARA ACUMULADO DE DIAS * * */ /* * ORIGINAL COMPIERE */ String day = new String(new Integer(date.getDate()).toString()); System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID()); System.out.println("Date:" + date); /* * VIT4B - Modificacin para calcular como se calcula el reporte CCRP * en funcion de la carga parcial * * */ int seconds = getLoad(r.getS_Resource_ID(), date, date); //BigDecimal value = calculateLoad(date, r, null); //int seconds = value.intValue(); Long Hours = new Long(hours); System.out.println("Summary " + summary); System.out.println("Load " + seconds); /* * FIN ORIGINAL COMPIERE * */ switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: days++; if (t.isOnSunday()) { //System.out.println("si Sunday"); //Msg.translate(Env.getCtx(), "OnSunday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); //+ (Hours.intValue() - ((seconds / 3600))); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //System.out.println("no Sunday"); //String day = Msg.translate(Env.getCtx(), "OnSunday") ; dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.MONDAY: days++; if (t.isOnMonday()) { //System.out.println("si Monday"); //String day = Msg.translate(Env.getCtx(), "OnMonday") ; dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //System.out.println("no Monday"); //String day = Msg.translate(Env.getCtx(), "OnMonday") ; dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.TUESDAY: days++; if (t.isOnTuesday()) { //System.out.println("si TuesDay"); //String day = Msg.translate(Env.getCtx(), "OnTuesday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //System.out.println("no TuesDay"); //String day = Msg.translate(Env.getCtx(), "OnTuesday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.WEDNESDAY: days++; if (t.isOnWednesday()) { //String day = Msg.translate(Env.getCtx(), "OnWednesday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnWednesday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.THURSDAY: days++; if (t.isOnThursday()) { //String day = Msg.translate(Env.getCtx(), "OnThursday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnThursday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.FRIDAY: days++; if (t.isOnFriday()) { //String day = Msg.translate(Env.getCtx(), "OnFriday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnFriday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } case Calendar.SATURDAY: days++; if (t.isOnSaturday()) { //String day = Msg.translate(Env.getCtx(), "OnSaturday"); dataset.addValue(hours, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } else { //String day = Msg.translate(Env.getCtx(), "OnSaturday"); dataset.addValue(0, namecapacity, day); dataset.addValue(seconds / 3600, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (seconds / 3600); gc1.add(Calendar.DATE, 1); date = org.compiere.util.TimeUtil.addDays(date, 1); break; } } } return dataset; }
From source file:org.openmicroscopy.shoola.env.data.OmeroDataServiceImpl.java
/** * Implemented as specified by {@link OmeroDataService}. * @see OmeroDataService#getImagesPeriod(SecurityContext, Timestamp, Timestamp, long, boolean) *///from w w w . j av a2s . c om public Collection getImagesPeriod(SecurityContext ctx, Timestamp startTime, Timestamp endTime, long userID, boolean asDataObject) throws DSOutOfServiceException, DSAccessException { if (startTime == null && endTime == null) throw new NullPointerException("Time not specified."); ParametersI po = new ParametersI(); po.leaves(); if (userID >= 0) po.exp(omero.rtypes.rlong(userID)); if (startTime != null) po.startTime(omero.rtypes.rtime(startTime.getTime())); if (endTime != null) po.endTime(omero.rtypes.rtime(endTime.getTime())); return gateway.getImages(ctx, po, asDataObject); }
From source file:com.enonic.vertical.engine.handlers.SectionHandler.java
public long getSectionContentTimestamp(int sectionKey) { long timestamp = 0; Connection con = null;/* w ww .j a v a2 s . c o m*/ PreparedStatement preparedStmt = null; ResultSet resultSet = null; try { con = getConnection(); StringBuffer sql = XDG.generateSelectSQL(db.tSectionContent2, db.tSectionContent2.sco_dteTimestamp, false, db.tSectionContent2.sco_mei_lKey); sql.append(" ORDER BY sco_dteTimestamp DESC"); preparedStmt = con.prepareStatement(sql.toString()); preparedStmt.setInt(1, sectionKey); resultSet = preparedStmt.executeQuery(); if (resultSet.next()) { Timestamp time = resultSet.getTimestamp("sco_dteTimestamp"); timestamp = time.getTime(); } } catch (SQLException sqle) { String message = "Failed to get section content timestamp: %t"; VerticalEngineLogger.error(this.getClass(), 1, message, sqle); } finally { close(resultSet); close(preparedStmt); close(con); } return timestamp; }
From source file:org.projectforge.plugins.teamcal.event.TeamEventEditPage.java
/** * @param parameters//from w ww .ja va2 s .com */ public TeamEventEditPage(final PageParameters parameters, final TeamEvent event, final Timestamp newStartDate, final Timestamp newEndDate, final RecurrencyChangeType recurrencyChangeType) { super(parameters, "plugins.teamcal.event"); Validate.notNull(event); Validate.notNull(recurrencyChangeType); // event contains the new start and/or stop date if modified. if (log.isDebugEnabled() == true) { log.debug("TeamEvent is: newStartDate=" + newStartDate + ", newEndDate=" + newEndDate + ", event=[" + event + "], recurrencyChangeType=[" + recurrencyChangeType + "]"); } this.eventOfCaller = event; this.recurrencyChangeType = recurrencyChangeType; Integer id; if (event instanceof TeamEventDO) { id = ((TeamEventDO) event).getId(); } else { id = ((TeamRecurrenceEvent) event).getMaster().getId(); } final TeamEventDO teamEventDO = teamEventDao.getById(id); if (recurrencyChangeType == RecurrencyChangeType.ALL) { // The user wants to edit all events, so check if the user changes start and/or end date. If so, move the date of the original event. if (newStartDate != null) { final long startDateMove = newStartDate.getTime() - event.getStartDate().getTime(); teamEventDO.setStartDate(new Timestamp(teamEventDO.getStartDate().getTime() + startDateMove)); } if (newEndDate != null) { final long endDateMove = newEndDate.getTime() - event.getEndDate().getTime(); teamEventDO.setEndDate(new Timestamp(teamEventDO.getEndDate().getTime() + endDateMove)); } } else { if (newStartDate != null) { teamEventDO.setStartDate(newStartDate); } else { teamEventDO.setStartDate(new Timestamp(event.getStartDate().getTime())); } if (newEndDate != null) { teamEventDO.setEndDate(newEndDate); } else { teamEventDO.setEndDate(new Timestamp(event.getEndDate().getTime())); } } if (recurrencyChangeType == RecurrencyChangeType.ONLY_CURRENT) { // The user wants to change only the current event, so remove all recurrency fields. teamEventDO.clearAllRecurrenceFields(); } super.init(teamEventDO); }