In my report there are currently 2 subreports, let's call them A and B.
The A lists Cash positions, and the B lists Stocks.
I run this report from a web based Java environment, the JasperReports's report reads from a sql database.
I want to pass an argument to the JR report that tells it in what order to arrange the subreports, in this case for e.g. (B first, then A or vice versa).
Is there a way to accomplish this?
You should send a parameter of boolean type. while generating report. on the basis of that parameter you should define the path of subreport.
Here is jrxml code for subrepor path.e.g.
For first subreport:
<subreport>
<reportElement uuid="8dba7f58-0466-4504-9d51-7484786450d2" positionType="Float" x="0" y="16" width="315" height="16"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{listOfObject})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{swap} == true ? "/path/to/first/subreport" : /path/to/second/subreport]]></subreportExpression>
</subreport>
And for second subreport:
<subreport>
<reportElement uuid="8dba7f58-0466-4504-9d51-7484786450d2" positionType="Float" x="0" y="16" width="315" height="16"/>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{listOfObject})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{swap} == true ? "/path/to/second/subreport" : /path/to/first/subreport]]></subreportExpression>
</subreport>
And vice-versa in other case.I have not tested. Please have a look.
Enjoy.
You could use a more complex subreportExpression and "Print When Expression".
In first subreport set print when to something like
$P{NUM_OF_SUBS} <= 1 ? true : false
in second
$P{NUM_OF_SUBS} <= 2 ? true : false
etc...
And for subreportExpression in first subreport something like:
$P{SUBS}.split(",")[1] == "A"
? "repo:subA.jrxml"
: $P{SUBS}.split(",")[1] == "B"
? "repo:subB.jrxml"
: $P{SUBS}.split(",")[1] == "C"
? "repo:subC.jrxml"
: "repo:subD.jrxml"
and in second:
$P{SUBS}.split(",")[2] == "A"
? "repo:subA.jrxml"
: $P{SUBS}.split(",")[2] == "B"
? "repo:subB.jrxml"
: $P{SUBS}.split(",")[2] == "C"
? "repo:subC.jrxml"
: "repo:subD.jrxml"
etc...
Related
hello i find many explample with xpath, unfortunatly i can't do what i would like to do :(
I need to control a xml script, a i want to alert if 2 sub elements are correct.
here a part of my xml file
<node componentName="printinput" componentVersion="0.102" offsetLabelX="0" >
<elementParameter field="TEXT" name="UNIQUE_NAME" value="name1" show="false"/>
<elementParameter field="CHECK" name="TCK_HELP" value="true"/>
<elementParameter field="TEXT" name="CO_ON" value="10000" show="false"/>
</node>
i would like to check if TCK_HELP=true AND CO_ON=10000 . With or, no pb, but i don't know hox to do this with 'and'. i understand why it'is not working, but i don't know how to do .. Thank a lot for your help
one of my tries :
/*[local-name() = 'ProcessType']
/*[local-name() = 'node']
[
#componentName='printinput'
]
/*[local-name() = 'elementParameter']
[#name='TCK_HELP' and #value!='true'
and
#name='CO_ON' and #value='10000'
]
What about:
//node[#componentName="printinput"][elementParameter[#name="TCK_HELP"][#value="true"]][elementParameter[#name="CO_ON"][#value="10000"]]
I have created a very basic script in pinescript.
study(title='Renko Strat w/ Alerts', shorttitle='S_EURUSD_5_[MakisMooz]', overlay=true)
rc = close
buy_entry = rc[0] > rc[2]
sell_entry = rc[0] < rc[2]
alertcondition(buy_entry, title='BUY')
alertcondition(sell_entry, title='SELL')
plot(buy_entry/10)
The problem is that I get a lot of duplicate alerts. I want to edit this script so that I only get a 'Buy' alert when the previous alert was a 'Sell' alert and visa versa. It seems like such a simple problem, but I have a hard time finding good sources to learn pinescript. So, any help would be appreciated. :)
One way to solve duplicate alters within the candle is by using "Once Per Bar Close" alert. But for alternative alerts (Buy - Sell) you have to code it with different logic.
I Suggest to use Version 3 (version shown above the study line) than version 1 and 2 and you can accomplish the result by using this logic:
buy_entry = 0.0
sell_entry = 0.0
buy_entry := rc[0] > rc[2] and sell_entry[1] == 0? 2.0 : sell_entry[1] > 0 ? 0.0 : buy_entry[1]
sell_entry := rc[0] < rc[2] and buy_entry[1] == 0 ? 2.0 : buy_entry[1] > 0 ? 0.0 : sell_entry[1]
alertcondition(crossover(buy_entry ,1) , title='BUY' )
alertcondition(crossover(sell_entry ,1), title='SELL')
You'll have to do it this way
if("Your buy condition here")
strategy.entry("Buy Alert",true,1)
if("Your sell condition here")
strategy.entry("Sell Alert",false,1)
This is a very basic form of it but it works.
You were getting duplicate alerts because the conditions were fulfulling more often. But with strategy.entry(), this won't happen
When the sell is triggered, as per paper trading, the quantity sold will be double (one to cut the long position and one to create a short position)
PS :You will have to add code to create alerts and enter this not in study() but strategy()
The simplest solution to this problem is to use the built-in crossover and crossunder functions.
They consider the entire series of in-this-case close values, only returning true the moment they cross rather than every single time a close is lower than the close two candles ago.
//#version=5
indicator(title='Renko Strat w/ Alerts', shorttitle='S_EURUSD_5_[MakisMooz]', overlay=true)
c = close
bool buy_entry = false
bool sell_entry = false
if ta.crossover(c[1], c[3])
buy_entry := true
alert('BUY')
if ta.crossunder(c[1], c[3])
sell_entry := true
alert('SELL')
plotchar(buy_entry, title='BUY', char='B', location=location.belowbar, color=color.green, offset=-1)
plotchar(sell_entry, title='SELL', char='S', location=location.abovebar, color=color.red, offset=-1)
It's important to note why I have changed to the indices to 1 and 3 with an offset of -1 in the plotchar function. This will give the exact same signals as 0 and 2 with no offset.
The difference is that you will only see the character print on the chart when the candle actually closes rather than watch it flicker on and off the chart as the close price of the incomplete candle moves.
Any suggestions for refactoring this ugly case-switch into something more elegant?
This method (in Ruby) returns a (short or full) description for Belgian provinces, given a zipcode.
def province(zipcode, short = false)
case zipcode
when 1000...1300
short ? 'BXL' : 'Brussel'
when 1300...1500
short ? 'WBR' : 'Waals-Brabant'
when 1500...2000, 3000...3500
short ? 'VBR' : 'Vlaams-Brabant'
when 2000...3000
short ? 'ANT' : 'Antwerpen'
when 3500...4000
short ? 'LIM' : 'Limburg'
when 4000...5000
short ? 'LIE' : 'Luik'
when 5000...6000
short ? 'NAM' : 'Namen'
when 6000...6600, 7000...8000
short ? 'HAI' : 'Henegouwen'
when 6600...7000
short ? 'LUX' : 'Luxemburg'
when 8000...9000
short ? 'WVL' : 'West-Vlaanderen'
when 9000..9999
short ? 'OVL' : 'Oost-Vlaanderen'
else
fail ArgumentError, 'Not a valid zipcode'
end
end
Based on suggestions from MiiinimalLogic i made a second version. It this preferable?
class Provincie
ProvincieNaam = Struct.new(:kort, :lang)
PROVINCIES = {
1000...1300 => ProvincieNaam.new('BXL', 'Brussel'),
1300...1500 => ProvincieNaam.new('WBR', 'Waals-Brabant'),
1500...2000 => ProvincieNaam.new('VBR', 'Vlaams-Brabant'),
2000...3000 => ProvincieNaam.new('ANT', 'Antwerpen'),
3000...3500 => ProvincieNaam.new('VBR', 'Vlaams-Brabant'),
3500...4000 => ProvincieNaam.new('LIM', 'Limburg'),
4000...5000 => ProvincieNaam.new('LIE', 'Luik'),
5000...6000 => ProvincieNaam.new('NAM', 'Namen'),
6000...6600 => ProvincieNaam.new('HAI', 'Henegouwen'),
6600...7000 => ProvincieNaam.new('LUX', 'Luxemburg'),
7000...8000 => ProvincieNaam.new('HAI', 'Henegouwen'),
8000...9000 => ProvincieNaam.new('WVL', 'West-Vlaanderen'),
9000..9999 => ProvincieNaam.new('OVL', 'Oost-Vlaanderen')
}.freeze
def self.lang(postcode)
provincie_naam(postcode).lang
end
def self.kort(postcode)
provincie_naam(postcode).kort
end
def self.provincie_naam(postcode)
PROVINCIES.each { |list, prov| return prov if list.cover?(postcode) }
fail ArgumentError, 'Geen geldige postcode'
end
private_class_method :provincie_naam
end
Personally, I'd specify the zip ranges & Province information in a different data structure a la Map of Range objects/Provinces, then use Ruby's Range methods to check if the result falls in the range with the range's method.
You could consider having just one range lookup, either as is done here or with a map structure, with a secondary lookup (probably in a map) from the short description to the long description.
I have an action node named 'CW', after that I placed a Decision Node to check if 'CW' returns error or not.... how should I write the predicate?
I tried:
${ wf:errorCode('CW') eq '' } then go to Y
${ wf:errorCode('CW') != '' } then go to N
Although it return empty string (no error), but it always goes to N. Any advise? Thanks!!
Try
${not empty wf:errorCode('CW')}
to detect failures
This is the only method for checking an empty string that worked for me.
<decision name='decision-action'>
<switch>
<case to='success-action'>${firstNotNull(wf:lastErrorNode(), 'no error') eq 'no error'}</case>
<default to='failed-action' />
</switch>
</decision>
So, to relate this answer directly to the question, this conditional
${firstNotNull(wf:errorCode('CW'), 'no error') eq 'no error}
should map to Y.
Can't you just use the ok and error action transitions to do this?
<action name="CW">
<!--
....
-->
<ok to="Y"/>
<error to="N"/>
<\action>
${ wf:errorCode('CW') == null }
You can also check if CW exits with error like:
${ wf:lastErrorNode()=='CW' }
right after CW completion.
${ wf:errorCode('CW') eq null } then go to Y
${ wf:errorCode('CW') != null } then go to N
Worked for me
${wf:lastErrorNode() eq wf:errorMessage(wf:lastErrorNode())} --> consider this condition as success, these two values are blank when job fails
${wf:lastErrorNode() != wf:errorMessage(wf:lastErrorNode())} --> consider this condition as failure, when jobs fails, these values do not match
it worked for me, hope this helps
I have an if:
-12.times do |control|
-dia += 1
-if control == 1
%a#hoy{:href=>'/dias/algo'}<
-else
%a{:href=>'/dias/algo'}<
=dia
%span=dias[rand(7)]
The problem is I need =dia and span elements inside the anchor tag in both cases (true/false), and when I quit one identation it fails, because haml will end the if (which is also normal).
Is there any way to force end an if? I have tried it in many ways, but couldn't find the right way if it exist.
Thanks.
-12.times do |control|
-dia += 1
%a{:id => control == 1 ? "hoy" : "", :href=>'/dias/algo'}<
=dia
%span=dias[rand(7)]
Didn't test it but it should work ...