Introduce MDashboardContent class
Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=3018377
This commit is contained in:
parent
9e9699674c
commit
77ceb1dbad
|
@ -0,0 +1,76 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.compiere.util.Env;
|
||||
|
||||
/**
|
||||
* @author teo_sarca
|
||||
*
|
||||
*/
|
||||
public class MDashboardContent extends X_PA_DashboardContent
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5425307033413466516L;
|
||||
|
||||
public static int getForSessionColumnCount()
|
||||
{
|
||||
int noOfCols = getForSessionQuery().aggregate("DISTINCT "+COLUMNNAME_ColumnNo, Query.AGGREGATE_COUNT, Integer.class);
|
||||
return noOfCols;
|
||||
}
|
||||
|
||||
public static MDashboardContent[] getForSession()
|
||||
{
|
||||
List<MDashboardContent> list = getForSessionQuery().list();
|
||||
return list.toArray(new MDashboardContent[list.size()]);
|
||||
}
|
||||
|
||||
public static Query getForSessionQuery()
|
||||
{
|
||||
Properties ctx = Env.getCtx();
|
||||
return new Query(ctx, Table_Name, null, null)
|
||||
.setOnlyActiveRecords(true)
|
||||
.setApplyAccessFilter(true, false)
|
||||
.setOrderBy(COLUMNNAME_ColumnNo+","+COLUMNNAME_AD_Client_ID+","+COLUMNNAME_Line);
|
||||
}
|
||||
|
||||
public MDashboardContent (Properties ctx, int PA_DashboardContent_ID, String trxName)
|
||||
{
|
||||
super (ctx, PA_DashboardContent_ID, trxName);
|
||||
}
|
||||
public MDashboardContent (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
}
|
||||
|
||||
public int getAD_Menu_ID()
|
||||
{
|
||||
if (m_AD_Menu_ID != null)
|
||||
return m_AD_Menu_ID;
|
||||
if (getAD_Window_ID() <= 0)
|
||||
{
|
||||
m_AD_Menu_ID = -1;
|
||||
return m_AD_Menu_ID;
|
||||
}
|
||||
m_AD_Menu_ID = new Query(getCtx(), MMenu.Table_Name, MMenu.COLUMNNAME_AD_Window_ID+"=?", null)
|
||||
.setParameters(getAD_Window_ID())
|
||||
.setOnlyActiveRecords(true)
|
||||
.setOrderBy(MMenu.COLUMNNAME_AD_Menu_ID+" DESC")
|
||||
.firstId();
|
||||
return m_AD_Menu_ID;
|
||||
}
|
||||
private Integer m_AD_Menu_ID = null;
|
||||
|
||||
public I_AD_Menu getAD_Menu()
|
||||
{
|
||||
return (I_AD_Menu)MTable.get(getCtx(), I_AD_Menu.Table_Name)
|
||||
.getPO(getAD_Menu_ID(), get_TrxName());
|
||||
}
|
||||
}
|
|
@ -17,9 +17,6 @@ import java.io.IOException;
|
|||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
@ -35,6 +32,7 @@ import javax.swing.text.Document;
|
|||
import org.compiere.apps.AEnv;
|
||||
import org.compiere.apps.AWindow;
|
||||
import org.compiere.model.MAchievement;
|
||||
import org.compiere.model.MDashboardContent;
|
||||
import org.compiere.model.MGoal;
|
||||
import org.compiere.model.MMeasureCalc;
|
||||
import org.compiere.model.MProjectType;
|
||||
|
@ -43,10 +41,10 @@ import org.compiere.model.MRequestType;
|
|||
import org.compiere.model.MRole;
|
||||
import org.compiere.swing.CMenuItem;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Ini;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
|
||||
/**
|
||||
* @author fcsku
|
||||
|
@ -143,49 +141,39 @@ public class HtmlDashboard extends JPanel implements MouseListener,
|
|||
queryZoom = null;
|
||||
queryZoom = new ArrayList<MQuery>();
|
||||
String appendToHome = null;
|
||||
String sql = " SELECT x.AD_CLIENT_ID, x.NAME, x.DESCRIPTION, x.AD_WINDOW_ID, x.PA_GOAL_ID, x.LINE, x.HTML, m.AD_MENU_ID"
|
||||
+ " FROM PA_DASHBOARDCONTENT x"
|
||||
+ " LEFT OUTER JOIN AD_MENU m ON x.ad_window_id=m.ad_window_id"
|
||||
+ " WHERE (x.AD_Client_ID=0 OR x.AD_Client_ID=?) AND x.IsActive='Y'"
|
||||
+ " AND x.ZulFilePath IS NULL" // Elaine 2008/11/19 - available in WebUI only at the moment
|
||||
+ " ORDER BY LINE";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, Env.getAD_Client_ID(Env.getCtx()));
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
appendToHome = rs.getString("HTML");
|
||||
for (final MDashboardContent dp : MDashboardContent.getForSession())
|
||||
{
|
||||
if (!Util.isEmpty(dp.getZulFilePath(), true))
|
||||
continue;
|
||||
//
|
||||
appendToHome = dp.getHTML();
|
||||
if (appendToHome != null) {
|
||||
if (rs.getString("DESCRIPTION") != null)
|
||||
result += "<H2>" + rs.getString("DESCRIPTION") + "</H2>\n";
|
||||
if (dp.getDescription() != null)
|
||||
result += "<H2>" + dp.getDescription() + "</H2>\n";
|
||||
result += stripHtml(appendToHome, false) + "<br>\n";
|
||||
}
|
||||
|
||||
if (rs.getInt("AD_MENU_ID") > 0) {
|
||||
if (dp.getAD_Menu_ID() > 0) {
|
||||
result += "<a class=\"hrefNode\" href=\"http:///window/node#"
|
||||
+ String.valueOf( rs.getInt("AD_WINDOW_ID")// "AD_MENU_ID") fcsku 3.7.07
|
||||
+ String.valueOf( dp.getAD_Window_ID() // "AD_MENU_ID") fcsku 3.7.07
|
||||
+ "\">"
|
||||
+ rs.getString("DESCRIPTION")
|
||||
+ dp.getDescription()
|
||||
+ "</a><br>\n");
|
||||
}
|
||||
result += "<br>\n";
|
||||
//result += "table id: " + rs.getInt("AD_TABLE_ID");
|
||||
if (rs.getInt("PA_GOAL_ID") > 0)
|
||||
result += goalsDetail(rs.getInt("PA_GOAL_ID"));
|
||||
//result += goalsDetail(rs.getInt("AD_TABLE_ID"));
|
||||
if (dp.getPA_Goal_ID() > 0)
|
||||
result += goalsDetail(dp.getPA_Goal_ID());
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
log.log(Level.SEVERE, sql, e);
|
||||
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
result += "<br><br><br>\n"
|
||||
+ "</div>\n</body>\n</html>\n";
|
||||
|
|
|
@ -22,8 +22,6 @@ import java.io.IOException;
|
|||
import java.io.InputStreamReader;
|
||||
import java.io.Serializable;
|
||||
import java.net.URL;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.apps.graph.WGraph;
|
||||
|
@ -40,12 +38,11 @@ import org.adempiere.webui.session.SessionManager;
|
|||
import org.adempiere.webui.util.IServerPushCallback;
|
||||
import org.adempiere.webui.util.ServerPushTemplate;
|
||||
import org.adempiere.webui.util.UserPreference;
|
||||
import org.compiere.model.I_AD_Menu;
|
||||
import org.compiere.model.MDashboardContent;
|
||||
import org.compiere.model.MGoal;
|
||||
import org.compiere.model.MMenu;
|
||||
import org.compiere.model.X_AD_Menu;
|
||||
import org.compiere.model.X_PA_DashboardContent;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.zkoss.zk.au.out.AuScript;
|
||||
|
@ -176,31 +173,16 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
Portalchildren portalchildren = null;
|
||||
int currentColumnNo = 0;
|
||||
|
||||
String sql = "SELECT COUNT(DISTINCT COLUMNNO) "
|
||||
+ "FROM PA_DASHBOARDCONTENT "
|
||||
+ "WHERE (AD_CLIENT_ID=0 OR AD_CLIENT_ID=?) AND ISACTIVE='Y'";
|
||||
int noOfCols = 0;
|
||||
int width = 0;
|
||||
|
||||
int noOfCols = DB.getSQLValue(null, sql,
|
||||
Env.getAD_Client_ID(Env.getCtx()));
|
||||
|
||||
int width = noOfCols <= 0 ? 100 : 100/noOfCols;
|
||||
|
||||
sql = "SELECT x.*, m.AD_MENU_ID "
|
||||
+ "FROM PA_DASHBOARDCONTENT x "
|
||||
+ "LEFT OUTER JOIN AD_MENU m ON x.AD_WINDOW_ID=m.AD_WINDOW_ID "
|
||||
+ "WHERE (x.AD_CLIENT_ID=0 OR x.AD_CLIENT_ID=?) AND x.ISACTIVE='Y' "
|
||||
+ "ORDER BY x.COLUMNNO, x.AD_CLIENT_ID, x.LINE ";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, null);
|
||||
pstmt.setInt(1, Env.getAD_Client_ID(Env.getCtx()));
|
||||
rs = pstmt.executeQuery();
|
||||
|
||||
while (rs.next())
|
||||
noOfCols = MDashboardContent.getForSessionColumnCount();
|
||||
width = noOfCols <= 0 ? 100 : 100 / noOfCols;
|
||||
for (final MDashboardContent dp : MDashboardContent.getForSession())
|
||||
{
|
||||
int columnNo = rs.getInt(X_PA_DashboardContent.COLUMNNAME_ColumnNo);
|
||||
int columnNo = dp.getColumnNo();
|
||||
if(portalchildren == null || currentColumnNo != columnNo)
|
||||
{
|
||||
portalchildren = new Portalchildren();
|
||||
|
@ -213,14 +195,13 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
|
||||
Panel panel = new Panel();
|
||||
panel.setStyle("margin-bottom:10px");
|
||||
panel.setTitle(rs.getString(X_PA_DashboardContent.COLUMNNAME_Name));
|
||||
panel.setTitle(dp.getName());
|
||||
|
||||
String description = rs.getString(X_PA_DashboardContent.COLUMNNAME_Description);
|
||||
String description = dp.getDescription();
|
||||
if(description != null)
|
||||
panel.setTooltiptext(description);
|
||||
|
||||
String collapsible = rs.getString(X_PA_DashboardContent.COLUMNNAME_IsCollapsible);
|
||||
panel.setCollapsible(collapsible.equals("Y"));
|
||||
panel.setCollapsible(dp.isCollapsible());
|
||||
|
||||
panel.setBorder("normal");
|
||||
portalchildren.appendChild(panel);
|
||||
|
@ -230,13 +211,12 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
boolean panelEmpty = true;
|
||||
|
||||
// HTML content
|
||||
String htmlContent = rs.getString(X_PA_DashboardContent.COLUMNNAME_HTML);
|
||||
String htmlContent = dp.getHTML();
|
||||
if(htmlContent != null)
|
||||
{
|
||||
StringBuffer result = new StringBuffer("<html><head>");
|
||||
|
||||
URL url = getClass().getClassLoader().
|
||||
getResource("org/compiere/images/PAPanel.css");
|
||||
URL url = getClass().getClassLoader().getResource("org/compiere/images/PAPanel.css");
|
||||
InputStreamReader ins;
|
||||
try {
|
||||
ins = new InputStreamReader(url.openStream());
|
||||
|
@ -262,12 +242,12 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
}
|
||||
|
||||
// Window
|
||||
int AD_Window_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_AD_Window_ID);
|
||||
int AD_Window_ID = dp.getAD_Window_ID();
|
||||
if(AD_Window_ID > 0)
|
||||
{
|
||||
int AD_Menu_ID = rs.getInt(X_AD_Menu.COLUMNNAME_AD_Menu_ID);
|
||||
int AD_Menu_ID = dp.getAD_Menu_ID();
|
||||
ToolBarButton btn = new ToolBarButton(String.valueOf(AD_Menu_ID));
|
||||
MMenu menu = new MMenu(Env.getCtx(), AD_Menu_ID, null);
|
||||
I_AD_Menu menu = dp.getAD_Menu();
|
||||
btn.setLabel(menu.getName());
|
||||
btn.addEventListener(Events.ON_CLICK, this);
|
||||
content.appendChild(btn);
|
||||
|
@ -275,7 +255,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
}
|
||||
|
||||
// Goal
|
||||
int PA_Goal_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_PA_Goal_ID);
|
||||
int PA_Goal_ID = dp.getPA_Goal_ID();
|
||||
if(PA_Goal_ID > 0)
|
||||
{
|
||||
//link to open performance detail
|
||||
|
@ -293,7 +273,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
});
|
||||
content.appendChild(link);
|
||||
|
||||
String goalDisplay = rs.getString(X_PA_DashboardContent.COLUMNNAME_GoalDisplay);
|
||||
String goalDisplay = dp.getGoalDisplay();
|
||||
MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null);
|
||||
WGraph graph = new WGraph(goal, 55, false, true,
|
||||
!(X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)),
|
||||
|
@ -303,7 +283,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
}
|
||||
|
||||
// ZUL file url
|
||||
String url = rs.getString(X_PA_DashboardContent.COLUMNNAME_ZulFilePath);
|
||||
String url = dp.getZulFilePath();
|
||||
if(url != null)
|
||||
{
|
||||
try {
|
||||
|
@ -333,10 +313,13 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
|||
if (panelEmpty)
|
||||
panel.detach();
|
||||
}
|
||||
} catch(Exception e) {
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.log(Level.WARNING, "Failed to create dashboard content", e);
|
||||
} finally {
|
||||
DB.close(rs, pstmt);
|
||||
}
|
||||
finally
|
||||
{
|
||||
}
|
||||
//
|
||||
|
||||
|
|
Loading…
Reference in New Issue