Help - why does this code start a new session???
Help - why does this code start a new session???
- Subject: Help - why does this code start a new session???
- From: James Cicenia <email@hidden>
- Date: Sat, 1 May 2004 08:44:12 -0500
Here is the code...
Where and why does it create a new session every time it is run????
// Generated by the WOLips Core at Sun Feb 29 12:06:45 CST 2004
package dashboard;
import Application;
import Session;
import org.jfree.chart.*;
import org.jfree.chart.labels.*;
import org.jfree.chart.plot.*;
import org.jfree.data.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.foundation.*;
import eo.*;
import er.extensions.*;
public class DashboardQ1 extends WOComponent {
protected Number chartHeight = new Integer(450);
protected Number chartWidth = new Integer(270);
protected NSData jpgChart;
protected JFreeChart chart;
protected NSArray aCustomers = null;
public PortfolioCustomer portfolioCustomerItem;
public PortfolioCustomer selectedCustomer;
//data object and NSArray to hold data
protected DefaultPieDataset dataSetQ1;
protected String chartName = "";
protected static String key = "projectState.lifeCycleState";
private static EOQualifier qualifier2 =
EOQualifier.qualifierWithQualifierFormat(
"projectState.lifeCycleState = 'Request'",
null);
private static EOQualifier qualifier3 =
EOQualifier.qualifierWithQualifierFormat(
"projectState.lifeCycleState = 'Pipeline'",
null);
private static EOQualifier qualifier4 =
EOQualifier.qualifierWithQualifierFormat(
"projectState.lifeCycleState = 'Project'",
null);
private static EOQualifier qualifier5 =
EOQualifier.qualifierWithQualifierFormat(
"projectState.lifeCycleState = 'Measure'",
null);
public DashboardQ1(WOContext context) {
super(context);
}
public DefaultPieDataset dataSetQ1(){
Portfolio portfolio = ((Session) session()).portfolio();
if (portfolio != null) {
if (portfolio.projects() != null) {
if(selectedCustomer != null){
EOQualifier qualifier1;
NSMutableArray args = new NSMutableArray();
args.addObject("customer");
args.addObject(selectedCustomer);
qualifier1 = EOQualifier.qualifierWithQualifierFormat("%@ = %@",
args);
EOOrQualifier orQualifier1 =
new EOOrQualifier(new NSArray(new Object[] {qualifier2,
qualifier3, qualifier4, qualifier5 }));
EOAndQualifier andQualifier1 =
new EOAndQualifier(new NSArray(new Object[] { qualifier1,
orQualifier1}));
NSArray results = EOQualifier.filteredArrayWithQualifier(
portfolio.projects(),andQualifier1);
if (results.count() == 0) {
return null;
}
dataSetQ1 = new DefaultPieDataset();
NSDictionary result=new NSDictionary();
result = ERXArrayUtilities.arrayGroupedByKeyPath(results,key);
java.util.Enumeration enumerator = result.keyEnumerator();
dataSetQ1.setValue(Application.LIFECYCLE_REQUEST,0);
dataSetQ1.setValue(Application.LIFECYCLE_PIPELINE,0);
dataSetQ1.setValue(Application.LIFECYCLE_PROJECT,0);
dataSetQ1.setValue(Application.LIFECYCLE_MEASURE,0);
while (enumerator.hasMoreElements()) {
String myKey = (String)enumerator.nextElement();
dataSetQ1.setValue(myKey,((NSArray)result.objectForKey(myKey)).count());
}
}else{
EOOrQualifier orQualifier1 =
new EOOrQualifier(new NSArray(new Object[] {qualifier2,
qualifier3, qualifier4, qualifier5 }));
NSArray results = EOQualifier.filteredArrayWithQualifier(
portfolio.projects(),orQualifier1);
dataSetQ1 = new DefaultPieDataset();
NSDictionary result=new NSDictionary();
result = ERXArrayUtilities.arrayGroupedByKeyPath(results,key);
java.util.Enumeration enumerator = result.keyEnumerator();
dataSetQ1.setValue(Application.LIFECYCLE_REQUEST,0);
dataSetQ1.setValue(Application.LIFECYCLE_PIPELINE,0);
dataSetQ1.setValue(Application.LIFECYCLE_PROJECT,0);
dataSetQ1.setValue(Application.LIFECYCLE_MEASURE,0);
while (enumerator.hasMoreElements()) {
String myKey = (String)enumerator.nextElement();
dataSetQ1.setValue(myKey,((NSArray)result.objectForKey(myKey)).count());
}
}
}
}
return dataSetQ1;
}
public NSArray aCustomers() {
if (aCustomers == null) {
aCustomers = new NSArray();
}
Portfolio portfolio = ((Session) session()).portfolio();
if (portfolio != null) {
if (portfolio.customers() != null) {
aCustomers = portfolio.customers();
}
}
return aCustomers;
}
public NSData jpgChart() {
try {
// create the chart...
JFreeChart chart = null ;
chart = ChartFactory.createPieChart(chartName, dataSetQ1(), true,
false, false);
chart.setBackgroundPaint(Application.CHART_COLOR);
chart.setBorderPaint(Application.CHART_COLOR);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setBackgroundPaint(Application.CHART_COLOR);
plot.setSectionLabelType(PiePlot.VALUE_AND_PERCENT_LABELS);
plot.setNoDataMessage("No data available");
plot.setItemLabelGenerator(new StandardPieItemLabelGenerator());
//create byteOutputStream
java.io.ByteArrayOutputStream baos = new
java.io.ByteArrayOutputStream();
if (chartHeight == null) chartHeight = new Integer(400);
if (chartWidth == null) chartWidth = new Integer(400);
//create a Jpeg chart
org.jfree.chart.ChartUtilities.writeChartAsJPEG(baos, chart,
chartHeight.intValue(), chartWidth.intValue() );
//send the chart to NSData jpgChart
jpgChart = new NSData(baos.toByteArray());
} //try
catch (Exception e) {
NSLog.out.appendln("***** EXCEPTION "+e.toString() );
}
return jpgChart;
}
}
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.