1 14 package org.compiere.model; 15 16 import java.util.*; 17 import java.sql.*; 18 import java.text.*; 19 20 import org.compiere.util.*; 21 22 28 public class MClickCount extends X_W_ClickCount 29 { 30 35 public MClickCount (Properties ctx, int W_ClickCount_ID) 36 { 37 super (ctx, W_ClickCount_ID); 38 } 40 private SimpleDateFormat m_dateFormat = DisplayType.getDateFormat(DisplayType.Date); 41 private DecimalFormat m_intFormat = DisplayType.getNumberFormat(DisplayType.Integer); 42 43 44 45 49 public MClick[] getMClicks() 50 { 51 ArrayList list = new ArrayList(); 52 53 MClick[] retValue = new MClick[list.size()]; 55 list.toArray(retValue); 56 return retValue; 57 } 59 64 public ValueNamePair[] getCount (String DateFormat) 65 { 66 ArrayList list = new ArrayList(); 67 String sql = "SELECT TRUNC(Created, '" + DateFormat + "'), Count(*) " 68 + "FROM W_Click " 69 + "WHERE W_ClickCount_ID=? " 70 + "GROUP BY TRUNC(Created, '" + DateFormat + "')"; 71 PreparedStatement pstmt = null; 73 try 74 { 75 pstmt = DB.prepareStatement(sql); 76 pstmt.setInt(1, getW_ClickCount_ID()); 77 ResultSet rs = pstmt.executeQuery(); 78 while (rs.next()) 79 { 80 String value = m_dateFormat.format(rs.getTimestamp(1)); 81 String name = m_intFormat.format(rs.getInt(2)); 82 ValueNamePair pp = new ValueNamePair (value, name); 83 list.add(pp); 84 } 85 rs.close(); 86 pstmt.close(); 87 pstmt = null; 88 } 89 catch (SQLException ex) 90 { 91 log.error("getCount - " + sql, ex); 92 } 93 try 94 { 95 if (pstmt != null) 96 pstmt.close(); 97 } 98 catch (SQLException ex1) 99 { 100 } 101 pstmt = null; 102 ValueNamePair[] retValue = new ValueNamePair[list.size()]; 104 list.toArray(retValue); 105 return retValue; 106 } 108 112 public ValueNamePair[] getCountQuarter () 113 { 114 return getCount("Q"); 115 } 117 121 public ValueNamePair[] getCountMonth () 122 { 123 return getCount("MM"); 124 } 126 130 public ValueNamePair[] getCountWeek () 131 { 132 return getCount("DY"); 133 } 135 139 public ValueNamePair[] getCountDay () 140 { 141 return getCount("J"); 142 } 144 } | Popular Tags |