equal instruction inside SWRL rule not working - reasoning

I am using Protege 4.3 to make some SWRL rules.
I have one class called "Person" with one property called "name".
I created individuals from the class with different names, and some names are the same.
I want to write a rule that creates instances of Property called "sameName" to bind people who have the same name. So I wrote the following rule :
Person(?p1), Person(?p2), name(?p1, ?n1), name(?p2, ?n2), equal(?n1, ?n2) -> sameName(?p1, ?p2)
The rule gave the right result but includes every person with himself, means compares also every person with himself, so I added notEqual(?p1,?p2) to force the reasoner to not compare a person with himself like this:
Person(?p1), Person(?p2), name(?p1, ?n1), name(?p2, ?n2), equal(?n1, ?n2), notEqual(?p1, ?p2) -> sameName(?p1, ?p2)
The result was empty. Did I miss something?

I guess you should set all the individuals be different.
If you did not do that, the reasoner could not judge whether two individuals are same or not, so the SWRL rules you wrote did not work at all.

Related

Cypress, page content and variables

Right or wrong: In Cypress, its impossible to read a value on page X, then keep this value and compare it to a value on page Y.
I can read a value from the page and log it:
cy.get('[data-e2e-selector=whatever]').then(elm => cy.log('Value from page X : ' + elm))
or, for instance, the number of elements with similar or partially matchin selectors:
cy.get('[data-e2e-selector=^whatever]').then(elm => cy.log('Number of elements like this on page X: ' + elm.length))
Hoever, I cannot create a variable of this, because of the asynchronous way Cypress runs. Right? Any value created to just be blank.
Nor can I pass the value read to a method, which in turn compares it to the value on the next page:
compareToValueOnNextPage(cy.get('[data-e2e-selector=^whatever]').then(elm => elm.length));
compareToValueOnNextPage(value: number) { // NB: Not sure if it's a number or string yet...
cy.get('[data-e2e-selector=^whateverNextPage]').then(elm => elm.length).should('have.length', 4)
}
Basically, if I want to compare values, the either have to be on the same page, or they need to be hard-coded. This is a huge limitation when actually end-to-end testing some applications. Very often, a value is created on page X, based on input which should in many cases ba random, thus creating a dynamic value in the test. Then, on page Y, that same value is fetch (from the backend) or shown in some other way, in a Summary etc. And, naturally, I want to compare the value shown on page X to the one shown on page Y/Summary. But this is not possible, due to the very unit-testing thinking that seems to be the foundation for Cypress.
Or am I missing something here? Are there ways around this that aren't ugly/smelly? I think it's possible to store the value on page X in a file, then read that file on page Y. However, Cypress seems to only have one option when reading the file, and that's reading the whole file and looking for a match. So that file would be a mess. Or I'd need several files.
I realize this is kind of trying to impose non-functional ways on a quite functional and asynchroeous technology. However, if it's not possible to "keep" a value and use it later, it's very limiting when it comes to end-to-end testing (even though it's not when the testing is unit-based on frontend components).
UPDATE:
As per Kerrry's suggestion in the answer below:
cy.get('[data-e2e-selector=dellan-accordion]')
.then(elm => cy.wrap(elm.length).as("myVariableName"));
-GO TO NEXT PAGE-
cy.get('[data-e2e-selector=betalingsplan-dellan]')
.then(elm => elm.length)
.should('have.length', myVariableName)
This yeilds "expected 4 to have property 'length'.
This means, obviously, that I cannot get the length of the length.
So I replace 'have.length' with 'eq':
cy.get('[data-e2e-selector=betalingsplan-dellan]')
.then(elm => elm.length)
.should('have.length', myVariableName)
And I get the following error:
expected 4 to equal 0
So, it seems that the first variable - myVariable - is gone after the first cy.get().
If I do everything inside one get (have another get inside that, where I go to the next page AND get the count of the elements), then it works. But the way Kerry shows it, it would be much more flexible. But, alas, the above error.
As jonrsharpe mentioned in the comments, please read the Cypress document on variables and aliases thoroughly. This is a core concept of Cypress, and it will give you a solid understanding of how to implement variables and carry the values between test steps.
The reader's digest example of what you how you can achieve is this:
cy.get('[data-e2e-selector=^whatever]')
.then(elm => cy.wrap(elm.length).as("myVariableName"));
What this is doing is cy.wrap will yield the value from elm.length in a Cypress command chain, which then allows you to assign it to an alias "myVariableName".
In your following test step where you want to compare the value on a separate page, you would then access the alias' value in one of two ways:
Using this.
cy.get('[data-e2e-selector=^whateverNextPage]')
.then(elm => elm.length)
.should('have.length', this.myVariableName)
OR
via cy.get()
cy.get("#myVariableName").then(function(variableValue){
cy.get('[data-e2e-selector=^whateverNextPage]')
.then(elm => elm.length)
.should('have.length', variableValue)
})

capturing a child value in Firebase rules

Using Firebase, it's possible to create rule expressions tp protect data but I've found it can quickly become complex.
One case I'm looking at has a rule using the children of the current node, e.g.:
data.child('value').val() === true
It's also possible to create a rule based on the contents of another node:
root.hasChild($node_variable)
What I'd like to do is to combine these two, e.g.:
root.child(data.child('value')).hasChild($node_variable)
but this hybrid approach throws an error when I publish the combined rule. Is there a way around this?
As suggested by David in the comments, the solution was
root.child(data.child('value').val()).hasChild($node_variabl‌​e)

Filter at event viewer by data

I want to get event entries by their description (data).
I know how to get the event entry with a certain description, however I want to get an entry whith a description which contains a string (not equals to it).
That, I don't know how to do.
Please help :)
According to my answer here: https://stackoverflow.com/a/34119006/5089204 you should be able to retrieve EventRecords.
Dealing with these events is a quite complex issue... Each event has its own internal structure. The common properties are bundled in EventRecord, but the specific data must be taken from the internal details. Use the ToXml() method of an EventRecord...
In order to get the right events you must define an EventLogQuery. You must know the Provider's name and specify the filter.
Try the following: Open eventvwr and there the Windows-System queue. Right click one event, open the "Details" and choose the "XML-View". Look over different events and you will find, that they are quite differing.
But: You'll find everything you need there: First the "Provider Name" and the "EventId", these two are most important for the `EventLogQuery'.
Now go to the "define a user filter on the current protocoll"-action and type in some values. Then switch to the filter's XML and you'll learn how to define the correct query.
I'm sorry, there is no "easy and general" approach :-)

Less override variable just for one country (language)

The context of my problem :
I have a website multi-language ( 20 ), I use less css.
All stylesheets are common, except one for every country called to the end.
I have a file com.base.less which has a variable of font.
Every stylesheet calls this file to use the variables which it contains.
My question, for a country I must change the font, thus to re-declare the variable only for this country.
How can I proceed?
Because if I re-celare my variable in my file of country, that this being called to the end it isn't written again.
I use lessPhp, and I see ModifyVars but I don't know if it's good method ?
(when I test he doesn't work)
Thank you
Yes, as the docs tell you "You can use the ModifyVars() method to customize your CSS if you have variables stored in PHP associative arrays".
Less uses the last declaration wins rule for variables, so the last re-declare value of variable at the end of your code will be used everywhere in your code.
I use lessPhp, and I see ModifyVars but I don't know if it's good
method ? (when I test he doesn't work)
Make sure that you call ModifyVars() before getCss() and call both on the same instance of Less_Parser.

lotus public variable in formula

once again I have to ask you for a help.
I have a problem with creating public variable and using it in formula.
The details of this issue is:
1, right after starting a Lotus Notes Application i have to create public variable EmpNum which will be contain an employee number (the number will be imported from IBM Blue Pages)
2, this EmpNum variable will be used to filter the data in a view, so I have to use it in formula in View Selection.
I'll be very grateful if you help with this issue.
Maybe there is possible any simplest solution of this problem?
Thanks in advance,
Tomasz (td2003)
EDIT:
Torsten, Panu, thank you.
I've decided to try write an EmpNum variable in notes.ini using #SetEnvironment and read it by #GetEnvironment, and it works.
BUT (!) there is a very strange thing:
1) when I entered formula "SELECT((form="ITForm") & (Status="Completed") & (TX_EmployeeNumber=#Environment("EmpNum")))" the view shows me all document where "TX_EmployeeNumber" is EMPTY;
2) otherwise when I entered formula "SELECT((form="ITForm") & (Status="Completed") & (TX_EmployeeNumber!=#Environment("EmpNum")))" (not equal) the view shows me all document where "TX_EmployeeNumber" is NOT EMPTY and no matter if TX_EmployeeNumber have exactly the same value as EmpNum.
For example: if EmpNum="P11" the view with 2nd formula shows the documents where TX_EmployeeNumber fields contains "P11", "P22", "A32" and so on.
I'm sure that #Environment("EmpNum") retrieves correct data from notes.ini.
I'm totally confused and completely don't know what's going on.
Do you have any idea about this?
First of all: There are NO public variables in Lotus Notes as you request it. Neither in LotusScript nor in Formula. Every variable just lives in its context, never in the complete client.
There are two places to put such a variable:
in the notes.ini, where you can set / read it using Formula (#Environment, #SetEnvironment, #getEnvironent) or LotusScript (NotesSession.GetEnvironmentString, NotesSession.SetEnvironmentVar).
In a Profile document in a database, where you can get it using #GetProfileField (Formula) or NotesDatabase.GetprofileDocument() (LotusScript)
Both of these approches will NOT help you for your number 2.
There is only ONE View- Selection- Formula for ALL Users. Putting something "userspecific" in there will let it render correctly for ONE value (the one, that the server uses when building the view- index), but not for all the others.
To solve your problem you can use:
a) An embedded View
A view that is categorized by empNum
A Form that has this view embedded and a Formula for "Show single category" for this embedded view set
b) A SPOFU view
SPOFU is "Shared, private on first use" and means, that every user has his own copy of the view. These views have some caveats and are hard to maintain. You should NOT use them, if you are not totally aware of the implications (getting the ACL right is one very important thing for these views)...
EDIT (due to change in question): SPOFU will neither work with Environment nor with Profile- documents, as the methods to read them are not supported in Views... So b) is not really an option... Sorry...
It is possible to use the #SetViewInfo formula in the QueryOpen and/or PostOpen of a view to get the view to only present data from one category. Be careful with this because you will need to touch EVERY view so that the value is cleared if the user navigates to a view which is not categorized by the employee num...
FWIW: I only have done this using #UserName not with another piece of data. I suggest you do that by having the import process add the fully qualified Notes name of the user to the documents as they are imported.
You can modify view selection formula with NotesView class. In this case you would have to use private views.
A better solution would be to use an XPage to show the view and use category filter. Or if you want to use traditional style then embed the view to a form or page and use "Show Single Category" feature.

Resources