Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Conditionally showing draft figure?
Conditionally showing draft figure? [message #638153] Wed, 10 November 2010 08:34 Go to next message
Missing name Missing name is currently offline Missing name Missing name
Messages: 55
Registered: July 2010
Member
Hello,

Is it possible to conditionally show the draft figure in the master page of the report?

My xml datasource is:

<?xml version="1.0" encoding="UTF-8"?>
<parameters>
	<data>This is an important report.</data>
	<draftPicture>true</draftPicture>
</parameters>


If the value of the draftPicture element is true the draft picture in the master page is shown otherwise it is not shown.

My report is:

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.22" id="1">
    <property name="createdBy">Eclipse BIRT Designer Version 2.6.1.v20100902 Build &lt;2.6.1.v20100915-1750></property>
    <property name="units">in</property>
    <property name="iconFile">/templates/blank_report.gif</property>
    <property name="bidiLayoutOrientation">ltr</property>
    <property name="imageDPI">96</property>
    <data-sources>
        <oda-data-source extensionID="org.eclipse.datatools.enablement.oda.xml" name="Data Source" id="7">
            <property name="FILELIST">C:\birtWorkspace\BirtEsittely\reports\parameters.xml</property>
        </oda-data-source>
    </data-sources>
    <data-sets>
        <oda-data-set extensionID="org.eclipse.datatools.enablement.oda.xml.dataSet" name="Data Set" id="8">
            <list-property name="columnHints">
                <structure>
                    <property name="columnName">data</property>
                    <text-property name="heading">data</text-property>
                </structure>
            </list-property>
            <structure name="cachedMetaData">
                <list-property name="resultSet">
                    <structure>
                        <property name="position">1</property>
                        <property name="name">data</property>
                        <property name="dataType">string</property>
                    </structure>
                </list-property>
            </structure>
            <property name="dataSource">Data Source</property>
            <list-property name="resultSet">
                <structure>
                    <property name="position">1</property>
                    <property name="name">data</property>
                    <property name="nativeName">data</property>
                    <property name="dataType">string</property>
                    <property name="nativeDataType">12</property>
                </structure>
            </list-property>
            <xml-property name="queryText"><![CDATA[table0#-TNAME-#table0#:#[/parameters]#:#{data;STRING;/data}]]></xml-property>
            <xml-property name="designerValues"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<model:DesignValues xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design" xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
  <Version>1.0</Version>
  <design:ResultSets derivedMetaData="true">
    <design:resultSetDefinitions>
      <design:resultSetColumns>
        <design:resultColumnDefinitions>
          <design:attributes>
            <design:name>data</design:name>
            <design:position>1</design:position>
            <design:nativeDataTypeCode>12</design:nativeDataTypeCode>
            <design:precision>-1</design:precision>
            <design:scale>-1</design:scale>
            <design:nullability>Unknown</design:nullability>
          </design:attributes>
          <design:usageHints>
            <design:label>data</design:label>
            <design:formattingHints/>
          </design:usageHints>
        </design:resultColumnDefinitions>
      </design:resultSetColumns>
      <design:criteria/>
    </design:resultSetDefinitions>
  </design:ResultSets>
</model:DesignValues>
]]></xml-property>
            <list-property name="privateDriverProperties">
                <ex-property>
                    <name>MAX_ROW</name>
                    <value>-1</value>
                </ex-property>
                <ex-property>
                    <name>XML_FILE</name>
                </ex-property>
            </list-property>
        </oda-data-set>
    </data-sets>
    <styles>
        <style name="report" id="4">
            <property name="fontFamily">sans-serif</property>
            <property name="fontSize">10pt</property>
        </style>
        <style name="crosstab" id="5">
            <property name="borderBottomColor">#CCCCCC</property>
            <property name="borderBottomStyle">solid</property>
            <property name="borderBottomWidth">1pt</property>
            <property name="borderLeftColor">#CCCCCC</property>
            <property name="borderLeftStyle">solid</property>
            <property name="borderLeftWidth">1pt</property>
            <property name="borderRightColor">#CCCCCC</property>
            <property name="borderRightStyle">solid</property>
            <property name="borderRightWidth">1pt</property>
            <property name="borderTopColor">#CCCCCC</property>
            <property name="borderTopStyle">solid</property>
            <property name="borderTopWidth">1pt</property>
        </style>
        <style name="crosstab-cell" id="6">
            <property name="borderBottomColor">#CCCCCC</property>
            <property name="borderBottomStyle">solid</property>
            <property name="borderBottomWidth">1pt</property>
            <property name="borderLeftColor">#CCCCCC</property>
            <property name="borderLeftStyle">solid</property>
            <property name="borderLeftWidth">1pt</property>
            <property name="borderRightColor">#CCCCCC</property>
            <property name="borderRightStyle">solid</property>
            <property name="borderRightWidth">1pt</property>
            <property name="borderTopColor">#CCCCCC</property>
            <property name="borderTopStyle">solid</property>
            <property name="borderTopWidth">1pt</property>
        </style>
    </styles>
    <page-setup>
        <simple-master-page name="Simple MasterPage" id="2">
            <property name="backgroundImage">reports/draft.jpg</property>
            <page-footer>
                <text id="3">
                    <property name="contentType">html</property>
                    <text-property name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
                </text>
            </page-footer>
        </simple-master-page>
    </page-setup>
    <body>
        <data id="9">
            <property name="whiteSpace">nowrap</property>
            <property name="dataSet">Data Set</property>
            <list-property name="boundDataColumns">
                <structure>
                    <property name="name">data</property>
                    <text-property name="displayName">data</text-property>
                    <expression name="expression" type="javascript">dataSetRow["data"]</expression>
                    <property name="dataType">string</property>
                </structure>
            </list-property>
            <property name="resultSetColumn">data</property>
        </data>
    </body>
</report>



It is possible for me to manipulate the rptdesign file with Java and remove

<property name="backgroundImage">reports/draft.jpg</property>


if the value of the draftFigure is false.

Is there more elegant ways to do this?


Thanks,

Mika
Re: Conditionally showing draft figure? [message #638303 is a reply to message #638153] Wed, 10 November 2010 18:24 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

You could add a beforeFactory script that changes the property like:

importPackage( Packages.javax.xml.parsers);
importPackage( Packages.org.xml.sax);
importPackage( Packages.org.w3c.dom);
importPackage( Packages.java.io);

function getTagValue(file, tagName) {

factory = DocumentBuilderFactory.newInstance();
builder = factory.newDocumentBuilder();
document = builder.parse( new InputSource( new FileInputStream( file ))
);
nlist = document.getElementsByTagName(tagName);
return nlist.item(0).getFirstChild().getNodeValue();
}

dp = getTagValue("C:/work/styles/parm.xml", "draftPicture");
if( dp == "false" ){
reportContext.getDesignHandle().findMasterPage("Simple
MasterPage").setProperty("backgroundImage", "" );
}

Jason

On 11/10/2010 3:34 AM, Mika wrote:
> <?xml version="1.0" encoding="UTF-8"?>
> <parameters>
> <data>This is an important report.</data>
> <draftPicture>true</draftPicture>
> </parameters>
Previous Topic:Scaling Multiple Bar Charts
Next Topic:How to calculate sum of all childs in a group plus the parent data set
Goto Forum:
  


Current Time: Wed Oct 01 05:59:42 GMT 2014

Powered by FUDForum. Page generated in 0.01715 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software