Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
GeneratingOpenForBusinessReportswiththeBIRTRCPDesigner
byLeonTorresandSiChen
TheBusinessIntelligenceReportingTools(BIRT)isasuiteoftoolsforgeneratingprofessional
lookingreportsfromadatabase.BIRTcanbeintegratedintoawebapplicationserverframeworkto
renderreportsinHTMLorPDFonthefly.Alternatively,BIRTcanrunstandaloneusingtheRich
ClientPlatform(RCP)Designerapplication,whichisinstalledonaclientmachineandconnectstoan
OFBizdatabaseremotely.
Overview
ThistutorialdescribesindetailhowtosetuptheBIRTRCPDesignerapplicationonaWindows
machineasaclienttoanOFBizdatabaserunningonanothermachine.Italsopresentsabrieftutorial
onhowtogeneratereportsusingsamplesalesorderscreatedintheOFBizOrderManagerapplication.
ThedatabaseusedinthistutorialisPostgreSQL8.0.However,itiseasytoreplicatetheinstructions
foranyotherdatabase.
Prerequisites
OFBizrunningonadatabaseofyourchoice.Inthistutorial,wewillcoverPostgreSQL8.0.
StandaloneBIRTRCPDesigner(downloadthelatestontotheWindowsclientmachine).
http://download.eclipse.org/birt/downloads/
Configuration
First,youwillneedtoconfiguretheOFBizdatabasetoallowconnectionsfromtheWindowsclient
machine.
InordertodothisinPostgreSQL,editthepg_hba.conffileandenteralinetoallowaccessfromthe
clientmachine'sIPaddress,or,ifdesired,fromtheIPblockwhichtheclientmachineresidesin.Inthis
examplewewillassumethattheclientmachineandtheserverrunningOFBizandPostgreSQL8.0are
inthesameinternalnetworkblock192.168.1.0/24.
# Enter this line into pg_hba.conf
host
all
all
192.168.1.0/24
md5
DatabaseconnectivitycanbetestedfromwithintheBIRTRCPDesigner.
Next,youwillneedtodownloadtheJDBCdriverforyourdatabaseontotheWindowsclientmachine
2006OpenSourceStrategies,Inc.AllRightsReserved.
OFBIZReportswithBIRT
sothatBIRTcanconnect.Youcanplacethedriveranywhereontheclient.ThePostgreSQL8.0JDBC
driverisdistributedwithOFBizatthefollowinglocation,
ofbiz/framework/entity/lib/jdbc/postgresql-8.0-311.jdbc3.jar
PlanningaReport
BeforewebeginusingBIRT,weshouldplanwhatourreportisgoingtobe.Forthistutorial,wewill
bedeterminingthetotalnumberofproductssoldandtherevenuegeneratedbyproductID.This
involvessummingthequantityofeachorderitem,summingthequantitytimesunitpriceofeachorder
item,andgroupingtheresultsbyorderID.
Ifyou'rerunningademo,createsomesalesordersusingtheordermanagerapplication.Thereisno
needtocompletetheorders.
BIRThasadatamodelnavigationtoolandahandySQLeditor,soitisunnecessarytowritedownthe
SQLhere.Withthereportplaninmind,wecannowbeginwritingthereport.
RunningBIRT
UnziptheBIRTRCPzipfilethatyoudownloadedanywhereontheclientmachine.Clickonthe
BIRT.exefiletostarttheprogram.BIRTshouldlooklikethefollowingillustration.
Illustration1:ThisishowBIRTshouldlookwheneveritstarts.
2006OpenSourceStrategies,Inc.AllRightsReserved.
OFBIZReportswithBIRT
Thefirststepistocreateanewreport.FromtheFilemenu,selectNewReportandgiveitanamesuch
astest.newrpt.Whenyoufinish,theviewwillfillupwithmanyoptions.Oneofthewindowsiscalled
CheatSheets.Goaheadandcloseit,youwon'tbeneedingit.
Illustration3:ViewwithaLabelandText
Illustration2:Whenanewreportiscreated,theviewfillsupwithmanyoptions.ClosetheCheatSheetswindow.
Inthemiddleisaviewwindowwhereyouwillconstructthereportbydragginganddroppingelements
fromthePalette.ThePaletteislocatedintheupperleft.
Let'sbeginbyconstructingatitleforthereport.DragaLabelobjectfromthePaletteontotheview
window.You'llbepromptedtoenterthelabeltext.Typeinthenameofthefirstreport,Sales
ByProductandpressEnter.Tochangethetextagain,rightclickontheLabelandselectEdit.
UnderneaththeviewisaPropertyEditorwhichdisplaysoptionsfortheLabel.Youcanchangethe
font,colors,andgeneralappearance.MaketheLabellookslikeatitlebychangingthebackground
color,increasingthefontsize,centeringthetextandmakingitbold.
2006OpenSourceStrategies,Inc.AllRightsReserved.
OFBIZReportswithBIRT
Illustration4:LabelandTextobjectsintheview
Nowaddatextobjectunderneaththetitletodescribethefirstreport.Todothis,dragaTextfromthe
Paletteandaboxshouldpopuppromptingforinput.Enteradescriptionsuchas,Thisisareportthat
showsthesalesbreakdownbyproduct.Thetextshouldappearastheillustrationabove.
Connectingtothedatabase
DatabasesarerepresentedasDataSourcesinBIRT.FindtheDataExplorertabnexttothePaletteand
clickonit.YoushouldseeaDataSourcesfolder.TocreateaDataSource,rightclickontheData
SourcesfolderandselectNewDataSource.
Illustration5:CreatinganewDataSource
2006OpenSourceStrategies,Inc.AllRightsReserved.
OFBIZReportswithBIRT
You'llbepromptedtoselectaDataSourcetype.SelectJDBCDataSourceandclickonNext.
Thenextdialogrequeststheconnectioninformation.FirstwewillneedtoaddourJDBCdrivertothe
listnamedDriverClass.Todothis,selectManageDrivers.
2006OpenSourceStrategies,Inc.AllRightsReserved.
OFBIZReportswithBIRT
IntheManageJDBCDriversdialog,usetheAddbuttontoaddtheJDBCjarfilewhichyoucopied
overtothismachine.ItwillshowupinthelistofJARFiles.
Oncethedriverislisted,clickOKtoreturntothedialogaskingforconnectioninformation.
Illustration6:Enteryourconnectioninformationfromentityengine.xml
NowyoucanselectyourdriverfromtheDriverClasslist.Theremainingconnectioninformation
shouldbethesameasthatdescribedinyourOFBizentityengine.xmlconfigurationfile.Enterthe
informationandthenclickonTestConnectiontoseeifyoucanconnect.ThenclickOKtoreturnto
themainview.
2006OpenSourceStrategies,Inc.AllRightsReserved.
OFBIZReportswithBIRT
CreatingReportQueries
Assumingtheconnectionwassuccessful,wecanproceedtodefinequeriesthatourreportwilluse.
ThesequeriesarecalledDataSets.TheyarelocatedintheDataExplorerundertheDataSources.
TocreateanewDataSet,rightclickontheDataSetfolderandselectNewDataSetfromthecontext
menu.
ThisdialogasksforbasicinformationabouttheDataSet.Giveitaname,suchasSalesByProduct.
Thereisonlyonedatasource.TheDataSetTypeisSQLSelectQuery.
ThenextdialogallowsyoutoconstructaSQLqueryandnavigatethedatabaseandallofitsobjects,
includingtables,sequences,foreignkeys,etc.
2006OpenSourceStrategies,Inc.AllRightsReserved.
OFBIZReportswithBIRT
Youcanalsonarrowdownthelistofchoiceswiththefilteroptionsatthebottom.Itisagoodideato
showtablesonlybyselectingTablesforType.Thiswillgetridofthenontableobjectsfromthe
databaseitemtree.
Illustration7:Creatingaquery
Goaheadandtypethequeryasshownintheillustrationabove.Alternatively,youcandragthenames
oftheobjectsfromthetreeontothequerytosavesometyping.Thequerycouldbemoresophisticated,
butthisissufficientforthepurposeofthetutorial.NotetheuseofAStorenamethefields.BIRTwill
useQuantityandAmountasthecolumnnamesforthesums.
Whenyou'refinished,theDataSetshouldlooklikethe
illustrationontheright.Noticethattheresultcolumnsarepart
ofthelist.Thisisimportantbecausewecandragthesecolumns
ontoobjectsintheviewtocreateanassociationbetweenaview
objectandtheresultcolumn.
2006OpenSourceStrategies,Inc.AllRightsReserved.
OFBIZReportswithBIRT
PresentingtheDataSetinaTable
Thenextstepistodisplaytheresultsinatable.Gotothepaletteand
dragaTableobjectontotheview.Youwillbepresentedwithadialog
requestingthenumberofcolumnsanddetails.Therearethreeresult
columns,sothedefaultofthreeshouldbefine.
Detailsiswhereourdatawouldbedisplayed.ThinkofDetailsasaunion
ofDataSets.SincethereisonlyoneDataSet,thedefaultofonedetailis
good.
Thetableappearsontheviewshowingthreekindsofrows,aHeaderrowforthecolumntitle,aDetail
rowforourdata,andaFooterrow.
Illustration9:TablewithaDetailRowcellhighlighted.
Illustration8:ATableontheviewwiththethefirstcelloftheDetailrowselected.
Inordertolinkthetablecolumnswiththeresultsetcolumns,allyouneedtodoisdragthedesired
columnfromourDataSetintheDataExplorerontothecellintheDetailrowwhereyouwantthedata
todisplay.
2006OpenSourceStrategies,Inc.AllRightsReserved.
OFBIZReportswithBIRT
Thisisbestexplainedbythefollowingillustration,wheretheproduct_idcolumnisdraggedontothe
firstDetailcell.BIRTfillsintheHeaderforyou.
Illustration10:Linkingtheproduct_idresultcolumntothefirstDetailcolumnbydragging.
Toformatthetable,clickoneachobjecttobeformattedandedittheirpropertiesasyoudidwiththe
LabelandTextobjects.Youcanformatindividualcellsorwholerowsandcolumns.
Finally,ourreportisfinished.PreviewtheresultsbyclickingonthePreviewtab,whichislocated
alongthebottomoftheview.Alternatively,youmayselectapreviewoptionfromtheFilemenu.
Illustration11:Reportpreview
2006OpenSourceStrategies,Inc.AllRightsReserved.
OFBIZReportswithBIRT
SavingtheReport
Tosavethereport,selectSavefromtheFilemenu.Thispreservesalltheworkyou'vedoneuptothis
pointasa.rptdesignfileandallowsyoutoresumethereportcreationatalatertime.The.rptdesignfile
isalsousedtogenerateareporttotheuserdynamicallyaswillbedescribedinthenextsection.
PresentingtheReportDynamically
Onceyou'vesavedyourreportasan.rptdesignfile,you
canusethereportasHTMLorPDFbyusingaweb
browser.InPreviewmode,rightclickonthewindow
andselectCreateShortcutfromthecontextmenuas
shownintheillustrationontheright.BIRTwillplacea
URLshortcutonyourdesktopthatcontainsthe
.rptdesignfile.
Whenyouwanttoviewyourreport,firstopentheBIRT
RCPDesigneronyourdesktop.Then,opentheshortcut
inawebbrowser,andyoushouldseethereportas
HTML.Thereportwillbeupdatedeverytimethelink
isrefreshed.ToservethispageasaPDFinstead,look
fortheURLparameter__format=html.Changeitto
__format=pdf.AslongastheBIRTRCPDesigneris
running,your.rptdesignreportwillberendered.
Alternatively,the.rptdesignfilesthatyoucreatecanbe
Illustration12:CreatingaShortcutURL
incorporatedintoanapplicationsuchasOFBizoran
applicationserversuchasGeronimoandservedupovertheweb.TheuserwouldtypeinaURLthat
containsthe.rptdesignfileandbepresentedwiththeHTMLorPDFresult.Thiswilldeservefurther
investigation.
Conclusions
InthistutorialyoulearnedhowtosetupBIRTRCPDesigneronaclientmachine,howtoconnect
BIRTtoaremoteserverrunningOFBiz,howtogenerateareport,andhowtopresentthereportas
HTMLorPDFdynamically.
Fromthispoint,youmaywishtoexplorehowtointegrateBIRTintoOFBizorserveitfromGeronimo
sothatthereportsmayberunfromawebbrowser.Inallcases,thereportfiles(.rptdesign)mustbe
createdfirst,asyoudidherewiththeBIRTRCPDesigner.
2006OpenSourceStrategies,Inc.AllRightsReserved.
OFBIZReportswithBIRT
BIRTisalsoavailableasanEclipseperspective.Ifthepersonwhowillbegeneratingthereportsalso
usestheEclipseIDE,heorshemaywishtoinstallitasaplugin.Instructionsfordoingthismaybe
foundattheEclipseProjecthomepage.
http://www.eclipse.org/birt/phoenix/
2006OpenSourceStrategies,Inc.AllRightsReserved.