addCondition with addQuickSearch - atk4

I have a condition that I'm always adding on some of the models on the init. It's a authorization condition.
When I add a grid with a model that has this condition, and I add a quick search I get unexpected behavior.
Both conditions are there, the one that I've added and the one generated by the quick search, but they are connected with "OR" so nothing works because of it.
I think the conditions should be linked together like this:
select * from my_model
where
(condition_added_with_addCondition1) AND (condition_added_with_addCondition2)
AND (condition_from_quicksearch1 or condition_from_quicksearch2)
In my example I have used addCondition twice and added two seach boxes using addQuickSearch.

Related

Simplest way to get a value from a select row in a table and send it to a bounded task flow

I'm trying to select a row in a displayed table and use a value in the row as input to a bounded task flow. This seems like a very common thing to do so you can reuse task flows, but everything I have found on the web requires tons of code. The missing piece seems to be getting the data from a select row to the input of the task flow. Are there any good examples of this on the web? I must be searching for the wrong thing.
While A_BOSS is correct, you can use setPropertyListener to set the value, unfortunately, the example is flawed. The example is using a memory scoped parameter: pageFlowScope.testVal. is is very bad practice to do this in ADF and should never be done in production, There are myriad issues do ing this. For example: JDeveloper cannot give feedback if you spell the param wrong and it is prone to NPE. While it is not exactly an anti-pattern, it's close enough not to do it. Proper way to do it is to create and register a managed bean and pass that bean's attribute: pageFLowScope.bean.testal
1- First get the value from selected row with this simple way :
a- add column in your table and add command button / link with PropertyActionListener to set the selected value in pageFlowScope as follows :
<af:column id="c8" headerText="Select">
<af:commandLink text="Select" id="cl1">
<f:setPropertyActionListener target="#{pageFlowScope.testVal}"
value="#{row.FirstName}"/>
</af:commandLink>
</af:column>
b- In Taskflow properties > in parameters section > add your param with the selection value from pageFlowScope variable ... in our case will be #{pageFlowScope.testVal}

How developers can assign Unique Id for HTML Controls in Grid which can used by Automation Test tool like Code UI?

I am using Angular JS - ng-table. Which generates grid structure with Sorting, filtering, pagination features.
We are using Coded UI automation tools which expects all HTML controls should be Unique.
For Example :
Lets have Grid Table consist of Employee records.
Automation Tester wrote a test cases expecting the first 1-10 records are having unique Id (Emp1-to-Emp10) which is NOT going to be changed.
But when Tester sorting the Grid then whole structure of Grid is being changed.
First 10 records will have - Emp11,Emp1,Emp4,Emp5,Emp37,Emp42,Emp67,Emp89,Emp12,Emp10.
when the Tester re test the test case it FAILs .
So, how to maintain the consistency for dynamic records unique ids with the combination of Angular JS + Coded UI?.
Thanks
Gokul
I would say that what is happening is expected sorting behaviour..
Some ways that you could solve your problem. From the tester's point of view:
Tests should restore the page to the initial state before ending. For example if the test sorts a table, it should 'un-sort' the table before it finishes. This leaves the data in an expected state so that the test can be repeated
Don't select things by id. All the test frameworks I know of allow you to select things by css selectors, which can do much more powerful selections than by id. E.g. you could look up a row by the employee Id and it would find it regardless of what order the table is in.
From the developer's point of view:
I presume the rows are items in an array. You can assign a unique id as a property to each item in the array and use it in the template markup. The unique id would not be affected by any sorting.
Unless you are using a very unusual framework or constrained by strange rules, I would suggest that the automated tests are amended rather than the code.

Using Access Next Record to Cycle through records that have a certain field as null

So I'm running into trouble, I'm trying to use Next and Previous record buttons (using prebuilt macros) to cycle through the ID of different resources. However, I'd like it to go through ONLY the Records where "TimeReturned" in Table "Loans" is empty (null).
I've tried using validation rules on the specific Textbox; here's what I tried (with no success): [Loans]![TimeReturned] Is Null
Should I even by trying to use the Validation Rules to achieve this?
Thanks!
EDIT:
I think I should be changing the Macro I'm using to cycle through the entries rather than just the text field for the ID. >.<

How to create a Drupal rule to check (on cron) a date field and if passed set field "status" to "ended"?

I'm trying to create a custom rule (using the Rules module) so that every time the cron runs, this rule checks a date field in a custom content type I created. If that date has passed then I want to set a list widget from active to ended.
This is how far I get when trying to create this rule:
Set React on event to Cron maintenance tasks are performed
Add Condition > Set Select the condition to add to Data comparison > Continue
Here is the issue: Data selectors only has site and no access to field data.
Any ideas where I'm going wrong here?
The problem with Rules condition "Cron maintenance tasks are performed" is that at that point, there is no access to the node object so any checks/manipulations on the node are not possible. As a solution, instead of Event = Cron maintenance tasks are performed, use Event = Node: Content is viewed. You can leave it open for any content type so that when someone visits the website and opens at least one page, some action will be triggered.
You need to create a rules component first:
Go to Rules > Components (admin/config/workflow/rules/components)
Then create a new component and select 'Rule' from select list
Set a name for this component and in the table below select:
Data type: Text Token
Label: A name that you want
Machine name: Use the same name of the label but set here only lower case and underscore
Usage: Parameter
In the component add the condition 'Data comparison' and select node:type
Add other conditions that you want
Set the actions that you want and save
Now go to Rules (admin/config/workflow/rules) and create the rule with action on cron maintenance (as you have already done)
Jump the conditions section and in the actions:
New action: Add a variable
Value: Text
Then write the value of this variable just like the machine name of content type that you want to cycle on (if you want you can change the name and machine name of this variable in the section below)
Now add another action 'Fetch entity by property'
Entity type value: Node
Property value: Type
Data selector: the variable created at the point 8
Now add a loop in parameter list use the variable provided by 'Fetch entity by property'
Add an action in the loop (click on the link to the right of loop row) and select the component created in the point 2 and pass the variable provided by loop
I state: I do not know if it works but at least it should direct you towards the right path
Sorry for my english, I hope you understand everything :)
Yes you should be able to get this to work using the Rules module to implement what you're looking for, but I recommend you to also combine that with the Views Rules module. Some details about this module (from its project page):
Provides Views directly as Rules actions and loops to seamlessly use view result data.
The previous quote may seem a bit cryptic (it may make you think like "so what, how can this help me?"). Therefor some more details about how to move forward using these modules:
Create a view (using Views) so that you have 1 Views result (row) with all the nodes you want to be processed (related to your custom content type and if possible filter somehow using your date field). Whereas that view has fields (columns) for whatever is needed in subsequent steps, e.g the node ID, the date field, and possibly other fields as well. You'll need these View fields later on as values to be processed by your rule, "to set a list widget from active to ended*" (as in your question). Important: use a Views display type of "Rules".
Remove that "add condition" (in the custom rule you started) and, instead, use the Views Rules module to iterate over each of these Views results in a Rules action, using the Rules technique known as a "Rules Loop".
For each iteration step in your Rules loop, perform a Rules Action to "do your thing" (= to set a list widget from active to ended). At that point you'll have all data from each column of your Views results available as so called Rules Parameters. So at that point it's a piece of cake to adapt the value of that list widget for the node you're processing in that loop.
Optionally, you may also want to add whatever extra Rules Condition(s), also up to your own imagination. Typically the things you cannot, or have not yet, expressed as a Views filter. However, if you have a choice between using a Views filter and an extra Rules Condition, I recommend to go for the Views filter, because that will reduce the number of your iterations in your Rules loop (performance!).
Easy, no?

Get only one matching row from Solr array

How do I get only a row which matches my query: ?q=taxonomy_ids:1/636/*
Got that result:
Want only: <str>1/636/587</str>
There is no easy way. However, there is a trick, where you use a match highlighter and use those results instead of the results returned from the search itself. You may want to configure PRE/POST highlight tags to empty strings. There was an article on the web about somewhere, but I can't find it again.
The disadvantage is that you get your results twice. Once as docs and once as highlight.
The other option is a custom component that hooks into Lucene's explain structure.

Resources