I am implementing a simple BRE example from Biztalk Certification Guide. My policy is composed as follows:
Seems easy. But then I am trying to test my policy with XML that has LoanAmount = 20. And BRE tells me, that 20<100 = false:
Test Expression: TypedXmlDocument:LoanApp:/LoanApp.LoanAmount < 100
Left Operand Value: 20
Right Operand Value: 100
Test Result: False
When I am testing policy with the same XML that has LoantAmount = 10 everything works fine:
Test Expression: TypedXmlDocument:LoanApp:/LoanApp.LoanAmount < 100
Left Operand Value: 10
Right Operand Value: 100
Test Result: True
Seems to be some awkward magic.
Just recognized that it is compared as string, because LoanAmount schema element is a string type.
Related
first time poster.
I am a student working in netlogo.
I am running the Game if Thrones model and have an error.
The code works, but is appears when the humans defeat the nightlong, before the text comes up, I get an error message.
Code is:
If season = “winter” and count whitewalkers = 0 [
set season “spring”
ask patches with [ snow? ][
set snow? false
if else resources = 0 [
set pcolor brown
][
set pcolor green
]
]
user-message “The Night King has been defeated! Summer is back.”
stop
]
The error message is:
WITH expected a true/false value from (patch 70 253), but got 0 instead. Error while observer running WITH Called bu procedure GO Called by button “go”
Many thanks
I have tried removing the brackets, but I believe they are needed.
I have put more space in between the brackets, but that makes no difference.
NetLogo does not perform type inference and the ? at the end of such primitives is a convention to indicate to the reader of the code that it is a boolean type, but not a language feature. NetLogo’s compiler does not immediately assign a boolean value to a variable that has a ? in its name, but simply assumes that it is an integer and assigns 0.
You probably need to set the snow? variable to a default value before using it elsewhere in your code, probably on top of your model’s setup procedure.
Here is a simple piece of code to illustrate how to initialize boolean variables in NetLogo:
patches-own [snow?]
to show-snow
show "before assigning bool value"
show [snow?] of patches
ask patches [ set snow? false ]
show "after assigning bool value"
show [snow?] of patches
end
enter image description here
I'm playing around with neo4j and cypher and trying to find out why my query is slow.
Here is my original query that is marked as deprecated:
match (h:Hierarchy)-[r:PARENT_OF*1..4]->(s:SoldTo)
where h.id='0100001709'
and all(x in r
where x.to>=date('2022-02-15')
and x.from <= date('2022-02-15')
and x.hvkorg='S000'
and x.hvtweg='D1'
)
and s.loevm=""
and s.aufsd=""
and s.cassd=""
and s.faksd=""
and s.lifsd=""
and s.sperr=""
and s.sperz=""
r>eturn distinct h.id,s.id
This one works fine and returns a result quite quickly: Started streaming 60 records after 1 ms and completed after 17 ms. However neo4j gives the below warning:
This feature is deprecated and will be removed in future versions.
Binding relationships to a list in a variable length pattern is deprecated. (Binding a variable length relationship pattern to a variable ('r') is deprecated and will be unsupported in a future version. The recommended way is to bind the whole path to a variable, then extract the relationships:
MATCH p = (...)-[...]-(...)
WITH *, relationships(p) AS r)
Now, i've tried this:
match p=(h:Hierarchy)-[:PARENT_OF*1..4]->(s:SoldTo)
with *, relationships(p) as r
where h.id='0100001709'
and all(x in r
where x.to>=date('2022-02-15')
and x.from <= date('2022-02-15')
and x.hvkorg='S000'
and x.hvtweg='D1'
)
and s.loevm=""
and s.aufsd=""
and s.cassd=""
and s.faksd=""
and s.lifsd=""
and s.sperr=""
and s.sperz=""
return distinct h.id,s.id
But, this is very slow: Started streaming 60 records in less than 1 ms and completed after 36931 ms.
17ms vs 36931ms
Would any of you have any recommendation to speed things up using relationships()?
There is a typo error on the query. Instead of doing a scan on the first line, put the where clause (found in line #3 to line#2). This will enable a starting node at h and will make your query faster.
Original:
match p=(h:Hierarchy)-[:PARENT_OF*1..4]->(s:SoldTo)
with *, relationships(p) as r
where h.id='0100001709'
Updated:
match p=(h:Hierarchy)-[:PARENT_OF*1..4]->(s:SoldTo)
where h.id='0100001709'
with h, s, relationships(p) as r
...
...
return distinct h.id,s.id
Likely due to my inexperience in Elasticsearch (and the R library Elastic), I cannot figure out how to formulate a search query in such a way that an exact match is combined with a wildcard.
docs_create(index="test",type="x", body=list(txt="this is a test"))
count(index='test', type='x',q="'a test'",default_operator="AND")
... returns one match.
count(index='test', type='x',q="'a te*'",default_operator="AND")
... returns no match (although I hoped to get one match too).
count(index='test', type='x',q="'a te/*'",default_operator="AND")
... produces an error (Error: 400 - all shards failed).
count(index='test', type='x',q="'a te'//*",default_operator="AND")
... returns no match.
Any help is welcome! Thank you.
PS. If this is impossible using the count function, using the Search function is fine too to solve my issue (using the body parameter).
#peterk what does the query without the single quotes return?
Can you try it like this:
count(index='test', type='x', q="a te*", default_operator="AND")
One thing to note, try connect(errors = "complete") to get more verbose errors - basically the same info the elastic server gives
count(index='test', type='x',q="'a te/*'",default_operator="AND")
#> Error: 400 - all shards failed
#> ES stack trace:
#>
#> type: query_shard_exception
#> reason: Failed to parse query ['a te/*']
#> index_uuid: xbZ5ANNBRwqxEsqPqS05Dg
#> index: test
Which suggests that that query is not valid
In general it's easier to use elastic::Search() as its more flexible - and set size parameter to 0 so you just get a count of records matched.
It's still not clear to me what is the exact part. Is it a te or a test or something else?
After a great week of sleep, I figured out how to get this done (using the match_phrase_prefix option:
docs_create(index="test",type="x", body=list(txt="this is a test"))
body <-
'{
"query": {
"match_phrase_prefix" : {
"txt" : {
"query" : "a te",
"max_expansions" : 10
}
}
}
}'
Search(index='test',body=body)
I'm trying to set up a dictionary as a variable (so I can use it as a Resource and access its values from another file) and there is something that is driving me crazy.
Here is the code I have (just for testing purposes):
*** Settings ***
Documentation Suite description
Library Collections
*** Variables ***
&{SOME DICT} key1=value1 key2=value2
*** Test Cases ***
Dict Test # why $ instead of &?
${RANDOM VAR}= Get From Dictionary ${SOME DICT} key1
Log ${RANDOM VAR} WARN
If I run that, I got the expected result ([ WARN ] value1) BUT the IDE (PyCharm) is complaining about that ${SOME DICT} variable is not defined, and the dictionary declaration is not highlighted the same as variable or a list.
If I change that to &{SOME DICT} the IDE won't complain anymore, but the test fails with the following output:
Dict Test | FAIL |
Keyword 'Collections.Get From Dictionary' got positional argument after named arguments.
That is puzzling me to no end: why I have to use a $ instead of a & if it's a dictionary to make it work? Is there something I am doing wrong and it is just running by luck?
Thanks for any advice or guidance you may have!
Have a look into "Get from Dictionary" libdoc,looks like example is showing the same as your working snippet:
Name: Get From Dictionary
Source: Library (Collections)
Arguments: [dictionary, key]
Returns a value from the given ``dictionary`` based on the given ``key``.
If the given ``key`` cannot be found from the ``dictionary``, this
keyword fails.
The given dictionary is never altered by this keyword.
Example:
| ${value} = | Get From Dictionary | ${D3} | b |
=>
| ${value} = 2
Keyword implementation details are as follows:
try:
return dictionary[key]
except KeyError:
raise RuntimeError("Dictionary does not contain key '%s'." % key)
So indeed, Robot sends representation of dict content and not dict name thus value for key can be returned.
This is the same as direct call in python:
a = {u'key1': u'value1', u'key2': u'value2'}
print(a['key1'])
In the end, libdoc for that KW is not straightforward but your PyCharm plugin for Robot does not work properly in this case.
In RED Robot Editor (Eclipse based), proper case does not rise any warnings in editor, wrong-case provides error marker about arguments (better but still not clear what is exactly wrong. Blame minimalistic libdoc info).
ps. I am lead of RED project to be clear.
Simple Example to Use Key Value Variable in robot framework
Set value to dictionary
Get value from dictionary
&{initValues} Create Dictionary key1=value1 key2=value2
Set To Dictionary ${initValues} key1=newvalue1
Set To Dictionary ${initValues} key2=newvalue2
Set To Dictionary ${initValues} key3=newvalue3
${value} Get From Dictionary ${intialValues} key1
I am running the following test inside Robot Framework:
*** Settings ***
Documentation This initializes testrun.robot
Library Process
Library OperatingSystem
Library XML
Library Collections
Output Is A Valid XML File Against JATS format
Start Process xmllint --dtdvalid http://jats.nlm.nih.gov/archiving/1.1d3/JATS-archivearticle1.dtd ./output/nlm/out.xml shell=True
${result}= Wait For Process timeout=45 secs
Log ${result.stdout}
Log ${result.stderr}
Run Keyword Unless '${result.stderr} == ${EMPTY}' Should Contain ${result.stderr} element xref: validity error : IDREFS attribute rid references an unknown
The variable ${result.stderr} is a string that contains the substring 'element xref: validity error : IDREFS attribute rid references an unknown'. As far as I know, I'm not dealing with any whitespace errors or quotation problems, although I could be wrong. (I've been fiddling around with that for a while now.)
Thanks for the help!
Edit: The log that Robot Framework generates tells me that the process has finished (that's how I know what result.stderr contains.)
Consider this statement:
Run Keyword Unless '${result.stderr} == ${EMPTY}' ...
The keyword will never run because you aren't comparing two variables, you are simply checking whether the string literal string '${result.stderr} == ${EMPTY}' is not empty (and it's not, because it has 28 characters).
It is the same as if you did this in python:
if len('${result.stderr} == ${EMPTY}') > 0:
...
You need to put the single quotes around each variable separately so that you are passing a valid expression to the if statement, rather than a string that looks like a valid expression:
Run Keyword Unless '${result.stderr}' == '${EMPTY}' ...