MResourceUnAvailable.isUnAvailable - use interface parameters as much as possible; also this will be needed for further libero development

This commit is contained in:
teo_sarca 2009-07-07 09:46:43 +00:00
parent b619468f26
commit 05099dacae
1 changed files with 5 additions and 4 deletions

View File

@ -20,6 +20,7 @@ import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.Properties; import java.util.Properties;
import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.TimeUtil; import org.compiere.util.TimeUtil;
@ -46,16 +47,16 @@ public class MResourceUnAvailable extends X_S_ResourceUnAvailable
* @param dateTime date (date is truncated to day) * @param dateTime date (date is truncated to day)
* @return true if resource is unavailable * @return true if resource is unavailable
*/ */
public static boolean isUnAvailable(MResource r, Timestamp dateTime) public static boolean isUnAvailable(I_S_Resource r, Timestamp dateTime)
{ {
Timestamp date = TimeUtil.trunc(dateTime, TimeUtil.TRUNC_DAY); Timestamp date = TimeUtil.trunc(dateTime, TimeUtil.TRUNC_DAY);
final String whereClause = COLUMNNAME_S_Resource_ID+"=? AND AD_Client_ID=?" final String whereClause = COLUMNNAME_S_Resource_ID+"=? AND AD_Client_ID=?"
+" AND TRUNC("+COLUMNNAME_DateFrom+") <= ?" +" AND TRUNC("+COLUMNNAME_DateFrom+") <= ?"
+" AND TRUNC("+COLUMNNAME_DateTo+") >= ?"; +" AND TRUNC("+COLUMNNAME_DateTo+") >= ?";
return new Query(r.getCtx(), MResourceUnAvailable.Table_Name, whereClause, null) Properties ctx = r instanceof PO ? ((PO)r).getCtx() : Env.getCtx();
.setParameters(new Object[]{r.get_ID(), r.getAD_Client_ID(), date, date}) return new Query(ctx, MResourceUnAvailable.Table_Name, whereClause, null)
.setParameters(new Object[]{r.getS_Resource_ID(), r.getAD_Client_ID(), date, date})
.match(); .match();
} }
/** /**