How can I execute a rule from within a script in booggie2? - rule

Is there a way to call a rule (or multiple rules) in a script and execute it?
Please note: The booggie-project does not exist anymore but led to the development of Soley Studio which covers the same functionality.

Yes!
There are two cases:
You know which rule to apply:
thisRule = transformation.GetRuleByName("myRule")
thisRule.Apply(param1, param2, ...)
Make sure that the rule parameters param1, param2, ... are of the right type!
You don't know which rule to apply:
rules = transformation.GetRulesWithParams(0)
rules[0].Apply()
In this case might only use rules that have no parameters since you have to provide the rule parameter of the right type. Here, all rules with no parameters are stored in the list rule and the first one is applied. You can also get the rules' names using rules[0].Name.

Related

Logic Apps: Using the "compose" action with an IF statement

I am using a compose action in a logic app in which I need to use a logical function that if xx condition passes then it can take the output from one compose action say compose1 and if failed then it can use from compose2
I tried to use the "if" logical function but it keeps saying that the expression is wrong.
Ex what I have used ...
if(contains(outputs('Create_duplicateKey'),'SendVehicleOrder'),'outputs('Compose_Priority')','outputs('Compose_Category')')
I have also tried to directly use the outputs of compose1 and compose2 but it is still failing ...
if(contains(outputs('Create_duplicateKey'),'SendVehicleOrder'),'Id: #{items('Loop_through_all_alerts')?['ID']}','orderType: #{items('Loop_through_all_alerts')?['OrderType']}')
Is there anyway I can use these outputs in an expression
After reproducing from my end, like #Skin mentioned removing quotes will make it work.
if(contains(outputs('Create_duplicateKey'),'SendVehicleOrder'),outputs('Compose_Priority'),outputs('Compose_Category'))
Alternatively, you can use condition action to achieve your requirement.

Adding an extra dependency in new Rules to existing Rules

I am writing a Shakefile with the aim of making it extensible with new Rules. Its interface is a function mainFor :: Rules () -> IO (), the idea being that client projects would only need to define main = mainFor myCustomRules to get the whole thing working. mainFor customRules is defined as a bunch of Shake Rules followed by a call to customRules.
This works as long as the custom rules passed to mainFor are for new targets.
However, some of my stock (non-custom) rules are basically of the form "run this big opaque proprietary external script with this input and hope for the best"; and there can be extra files used by the external script depending on its input. For example, imagine I have a rule of the following form:
"_build/output.bin" %> out -> do
need ["_build/script.scr", "_build/src/generated.src"]
runExternalScript
For a particular client project, maybe the generated source code contains references to another file _build/src/extrainput.src. So in the custom rules passed to mainFor, not only do I need extra rules for this file, but the existing rule should also be modified to mark that it needs this input:
main = mainFor $ do
"_build/src/extrainput.src" %> \out -> do
generateExtraSrc
"_buld/output.bin" %> \out -> do
need ["_build/src/extrainput.src"]
but this, unsurprisingly, fails because both the stock rule in mainFor and the second custom rule passed in the customRules argument are for the same target. Note that I do not want to fully override the stock rule, only extend it to add the extra dependency.
There is currently no way to do this using Shake. The possibilities are:
Add it to Shake. Whether that's the right thing depends on how common this requirement is - and my guess is relatively rare - but that needs validating. The fact you want the dependencies run before the rule is more concerning - it's somehow less compositional than just providing multiple actions that together produce a result.
Do it on the outside. My straw man would be to write the "extras" as some kind of FilePath -> Action () function, then define your own %> that also applied that function to the output. It would only work with pre-selected extension points, but if you redefine %> at the top of the file it can hit all your instances.
If you really want to hide it more, use shakeExtra to store the state in some way.

svn2git kde rules errors - converting tags

I am using svn2git all fast export and I am getting the following error:
- I had my rules for tags along these lines:
match /(<folder>/Source/<folder>/[^/]+/)tags/
repository repo
prefix \1
branch refs/tags/\2
end match
How can I correct these rules?
As already told in the comments of your other question, it is probably the invalid backreference you use.
Your rule doesn't make sense.
You have one match group in your regex (thing in parentheses), but you use two back references (backslash + number).
I guess it's erroring out because of that.
Compare your tag rule to my example and you should see the difference.
You miss the ([^/]+)/ in the end of the rule

ANTLR get first production

I'm using ANTLR4 and, in particular, the C grammar available in their repo (grammar). It seems that the grammar hasn't an initial rule, so I was wondering how it's possible to get it. In fact, once initialized the parser, I attach my listener, but I obtain syntax errors since I'm trying to parse two files with different code instructions:
int a;
int foo() { return 0; }
In my example I call the parser with "parser.primaryExpression();" which is the first production of the "g4" file. Is it possible to avoid to call the first production and get it automatically by ANTLR instead?
In addition to #GRosenberg's answer:
Also the rule enum (in the generated parser) contains entries for each rule in the order they appear in the grammar and the first rule has the value 0. However, just because it's the first rule in the grammar doesn't mean that it is the main entry point. Only the grammar author knows what the real entry is and sometimes you might even want to parse only with a subrule, which makes this decision even harder.
ANTLR provides no API to obtain the first rule. However, in the parser as generated, the field
public static final String[] ruleNames = ....;
lists the rulenames in the order of occurrence in the grammar. With reflection, you can access the method.
Beware. Nothing in the Antlr 'spec' defines this ordering. Simply has been true to date.

How to use SWRL rules on Protegé 4.3 using Pellet

I've just started doing work on ontologies with Protegé and I'm trying to understand how to use SWRL rules. I'm afraid I don't get the concept or how to correctly treat them, as I'm not able to produce any output. I'll explain a bit more a simple case I created to test this:
I've created three individuals, called A, B and C. Each one with a test property, that has a boolean range. On the property assertions tab of each one I've initialized their values, so they are test(A,true), test(B,true) and test(C,true). To test how rules work, I created a rule like this: test(A,true), test(B,true) -> test(C,false). The way I understand it is that, if A and B's test property is true, C's one would turn false. To do so, I start the reasoner (Pellet) but nothing happens. I mean, it says the reasoner is active and no "inconsistent ontology" messages appear, but C's test value doesn't change. I'm sure this must be a really simple confusion but I can't seem to find it anywhere nor check if the rule has been activated.
Thank you in advance.
The inference doesnt work like that, you cannot retract test(C, true) if you've asserted it. Your ontology probably includes both test(C, true) and test(C, false) which is completely legal unless you've specified otherwise; in which case then you'd see the inconsistency.

Resources