1 11 12 package org.eclipse.birt.chart.examples.api.data; 13 14 18 import java.io.IOException ; 19 20 import org.eclipse.birt.chart.model.Chart; 21 import org.eclipse.birt.report.model.api.DesignEngine; 22 import org.eclipse.birt.report.model.api.DesignFileException; 23 import org.eclipse.birt.report.model.api.ExtendedItemHandle; 24 import org.eclipse.birt.report.model.api.OdaDataSetHandle; 25 import org.eclipse.birt.report.model.api.ReportDesignHandle; 26 import org.eclipse.birt.report.model.api.SessionHandle; 27 import org.eclipse.birt.report.model.api.activity.SemanticException; 28 import org.eclipse.birt.report.model.api.extension.ExtendedElementException; 29 30 import com.ibm.icu.util.ULocale; 31 32 public class MinSliceOld 33 { 34 35 40 public static void main( String [] args ) 41 { 42 new MinSliceOld( ).pieMinSlice( ); 43 44 } 45 46 52 void pieMinSlice( ) 53 { 54 SessionHandle sessionHandle = new DesignEngine( null ).newSessionHandle( (ULocale) null ); 55 ReportDesignHandle designHandle = null; 56 57 String path = "src/org/eclipse/birt/chart/examples/api/data/"; 59 try 60 { 61 designHandle = sessionHandle.openDesign( path 62 + "NonMinSlice.rptdesign" ); } 64 catch ( DesignFileException e ) 65 { 66 e.printStackTrace( ); 68 } 69 70 OdaDataSetHandle dataSet = (OdaDataSetHandle) designHandle 71 .getDataSets( ).get( 0 ); 72 String query = dataSet 73 .getQueryText( ) 74 .concat( 75 "\nhaving SUM(CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED) > 7000\n" + "union\n" + "select (MIN(CLASSICMODELS.ORDERDETAILS.ORDERLINENUMBER)-MIN(CLASSICMODELS.ORDERDETAILS.ORDERLINENUMBER)) as ORDERLINENUMBER,\n" + "SUM(CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED) as TotalQuantities\n" + "from CLASSICMODELS.ORDERDETAILS\n" + "where CLASSICMODELS.ORDERDETAILS.ORDERLINENUMBER in\n" + "(select CLASSICMODELS.ORDERDETAILS.ORDERLINENUMBER\n" + "from CLASSICMODELS.ORDERDETAILS\n" + "group by CLASSICMODELS.ORDERDETAILS.ORDERLINENUMBER\n" + "having SUM(CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED)<=7000)" ); 86 try 87 { 88 dataSet.setQueryText( query ); 89 } 90 catch ( SemanticException e ) 91 { 92 e.printStackTrace( ); 93 } 94 95 ExtendedItemHandle eih = (ExtendedItemHandle) designHandle.getBody( ) 96 .getContents( ).get( 0 ); 97 98 Chart cm = null; 99 try 100 { 101 cm = (Chart) eih.getReportItem( ).getProperty( "chart.instance" ); } 103 catch ( ExtendedElementException e ) 104 { 105 e.printStackTrace( ); 107 } 108 109 cm.getTitle( ).getLabel( ).getCaption( ).setValue( "MinSlice" ); 111 try 112 { 113 designHandle.saveAs( path + "MinSlice.rptdesign" ); } 115 catch ( IOException e ) 116 { 117 e.printStackTrace( ); 118 } 119 } 120 } 121 | Popular Tags |