use of org.adempiere.apps.graph.GraphColumn in project adempiere by adempiere.
the class WGraph method chartMouseClicked.
/**************************************************************************
* Paint Component
*
* @param g
* graphics
*/
public void chartMouseClicked(int index) {
GraphColumn bgc = list.get(index);
if (null == bgc)
return;
MQuery query = bgc.getMQuery(builder.getMGoal());
if (query != null)
AEnv.zoom(query);
else
log.warning("Nothing to zoom to - " + bgc);
}
use of org.adempiere.apps.graph.GraphColumn in project adempiere by adempiere.
the class WGraph method renderTable.
private void renderTable(Component parent) {
Div div = new Div();
appendChild(div);
div.setSclass("pa-content");
parent.appendChild(div);
Table table = new Table();
table.setSclass("pa-dataGrid");
div.appendChild(table);
Tr tr = new Tr();
table.appendChild(tr);
Td td = new Td();
td.setSclass("pa-label");
tr.appendChild(td);
Text text = new Text("Target");
td.appendChild(text);
td = new Td();
td.setDynamicProperty("colspan", "2");
td.setSclass("pa-tdcontent");
tr.appendChild(td);
text = new Text(builder.getMGoal().getMeasureTarget().setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
td.appendChild(text);
tr = new Tr();
table.appendChild(tr);
td = new Td();
td.setSclass("pa-label");
tr.appendChild(td);
text = new Text("Actual");
td.appendChild(text);
td = new Td();
td.setDynamicProperty("colspan", "2");
td.setSclass("pa-tdcontent");
tr.appendChild(td);
text = new Text(builder.getMGoal().getMeasureActual().setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
td.appendChild(text);
GraphColumn[] bList = getGraphColumnList();
tr = new Tr();
table.appendChild(tr);
td = new Td();
tr.appendChild(td);
td.setDynamicProperty("rowspan", bList.length);
td.setSclass("pa-label");
td.setDynamicProperty("valign", "top");
text = new Text(builder.getMGoal().getXAxisText());
td.appendChild(text);
for (int k = 0; k < bList.length; k++) {
GraphColumn bgc = bList[k];
if (k > 0) {
tr = new Tr();
table.appendChild(tr);
}
td = new Td();
td.setSclass("pa-tdlabel");
tr.appendChild(td);
text = new Text(bgc.getLabel());
td.appendChild(text);
td = new Td();
td.setSclass("pa-tdvalue");
tr.appendChild(td);
BigDecimal value = new BigDecimal(bgc.getValue());
if (bgc.getMQuery(builder.getMGoal()) != null) {
A a = new A();
a.setSclass("pa-hrefNode");
td.appendChild(a);
a.setId(ZOOM_KEY + k);
a.addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(Event event) throws Exception {
Component comp = event.getTarget();
String id = comp.getId();
if (id.startsWith(ZOOM_KEY)) {
String ss = id.substring(ZOOM_KEY.length());
int index = Integer.parseInt(String.valueOf(ss));
GraphColumn[] colList = getGraphColumnList();
if ((index >= 0) && (index < colList.length))
AEnv.zoom(colList[index].getMQuery(builder.getMGoal()));
}
}
});
a.setDynamicProperty("href", "javascript:;");
text = new Text(value.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
a.appendChild(text);
} else {
text = new Text(value.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
}
}
tr = new Tr();
table.appendChild(tr);
td = new Td();
td.setDynamicProperty("colspan", "3");
tr.appendChild(td);
text = new Text(builder.getMGoal().getDescription());
td.appendChild(text);
Br br = new Br();
td.appendChild(br);
text = new Text(stripHtml(builder.getMGoal().getColorSchema().getDescription(), true));
td.appendChild(text);
}
use of org.adempiere.apps.graph.GraphColumn in project adempiere by adempiere.
the class MMeasure method getGraphColumnList.
// MMeasure
public ArrayList<GraphColumn> getGraphColumnList(MGoal goal) {
ArrayList<GraphColumn> list = new ArrayList<GraphColumn>();
if (MMeasure.MEASURETYPE_Calculated.equals(getMeasureType())) {
MMeasureCalc mc = MMeasureCalc.get(getCtx(), getPA_MeasureCalc_ID());
String sql = mc.getSqlBarChart(goal.getRestrictions(false), goal.getMeasureDisplay(), goal.getDateFrom(), // logged in role
MRole.getDefault());
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
ArrayList<Timestamp> dataList = new ArrayList<Timestamp>();
while (rs.next()) {
BigDecimal data = rs.getBigDecimal(1);
Timestamp date = rs.getTimestamp(2);
GraphColumn bgc = new GraphColumn(mc, data);
//TODO copy order-loop to other measures
bgc.setLabel(date, goal.getMeasureDisplay());
int pos = 0;
for (int i = 0; i < dataList.size(); i++) if (dataList.get(i).before(date))
pos++;
// list of dates
dataList.add(date);
list.add(pos, bgc);
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} else if (MMeasure.MEASURETYPE_Achievements.equals(getMeasureType())) {
if (MMeasure.MEASUREDATATYPE_StatusQtyAmount.equals(getMeasureDataType())) {
MAchievement[] achievements = MAchievement.get(this);
for (int i = 0; i < achievements.length; i++) {
MAchievement achievement = achievements[i];
GraphColumn bgc = new GraphColumn(achievement);
list.add(bgc);
}
} else // MMeasure.MEASUREDATATYPE_QtyAmountInTime
{
String MeasureDisplay = goal.getMeasureDisplay();
String trunc = "D";
if (MGoal.MEASUREDISPLAY_Year.equals(MeasureDisplay))
trunc = "Y";
else if (MGoal.MEASUREDISPLAY_Quarter.equals(MeasureDisplay))
trunc = "Q";
else if (MGoal.MEASUREDISPLAY_Month.equals(MeasureDisplay))
trunc = "MM";
else if (MGoal.MEASUREDISPLAY_Week.equals(MeasureDisplay))
trunc = "W";
// else if (MGoal.MEASUREDISPLAY_Day.equals(MeasureDisplay))
// trunc = "D";
trunc = "TRUNC(DateDoc,'" + trunc + "')";
StringBuffer sql = new StringBuffer("SELECT SUM(ManualActual), ").append(trunc).append(" FROM PA_Achievement WHERE PA_Measure_ID=? AND IsAchieved='Y' ").append("GROUP BY ").append(trunc).append(" ORDER BY ").append(trunc);
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, getPA_Measure_ID());
rs = pstmt.executeQuery();
while (rs.next()) {
BigDecimal data = rs.getBigDecimal(1);
Timestamp date = rs.getTimestamp(2);
GraphColumn bgc = new GraphColumn(goal, data);
bgc.setLabel(date, goal.getMeasureDisplay());
list.add(bgc);
}
} catch (Exception e) {
log.log(Level.SEVERE, sql.toString(), e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
// Achievement in time
} else // Request
if (MMeasure.MEASURETYPE_Request.equals(getMeasureType())) {
MRequestType rt = MRequestType.get(Env.getCtx(), getR_RequestType_ID());
String sql = rt.getSqlBarChart(goal.getRestrictions(false), goal.getMeasureDisplay(), getMeasureDataType(), goal.getDateFrom(), // logged in role
MRole.getDefault());
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next()) {
BigDecimal data = rs.getBigDecimal(1);
int R_Status_ID = rs.getInt(3);
GraphColumn bgc = new GraphColumn(rt, data, R_Status_ID);
if (R_Status_ID == 0) {
Timestamp date = rs.getTimestamp(2);
bgc.setLabel(date, goal.getMeasureDisplay());
} else {
MStatus status = MStatus.get(Env.getCtx(), R_Status_ID);
bgc.setLabel(status.getName());
}
list.add(bgc);
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
} else // Project
if (MMeasure.MEASURETYPE_Project.equals(getMeasureType())) {
MProjectType pt = MProjectType.get(Env.getCtx(), getC_ProjectType_ID());
String sql = pt.getSqlBarChart(goal.getRestrictions(false), goal.getMeasureDisplay(), getMeasureDataType(), goal.getDateFrom(), // logged in role
MRole.getDefault());
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
rs = pstmt.executeQuery();
while (rs.next()) {
BigDecimal data = rs.getBigDecimal(1);
Timestamp date = rs.getTimestamp(2);
int id = rs.getInt(3);
GraphColumn bgc = new GraphColumn(pt, data, id);
bgc.setLabel(date, goal.getMeasureDisplay());
list.add(bgc);
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
}
return list;
}
Aggregations