From wiki.ginstr.com
Jump to: navigation, search
added in Milestone 102

gn:act_filterRows

Description
Action used to create a filtered list of rows based on some condition from existing collection of rows
Action returns
void

Action signatures

Single column condition

[gn:act_filterRows]|[source,target;column;comparedTarget,comparator,,operation]

Multiple columns condition

[gn:act_filterRows]|[source,target;columns{n};comparedTarget,comparator,logicalOperator,operation]
Parameter Description
source source source which contains rows
target target target to which filtered rows will be added
columns{n} id of column or columns in source that will be compared to comparedTarget by comparator
comparedTarget id of target that will be compared to column value
comparator comparator that will be used to compare column value and comparedTarget value.

Compared column and comparedTarget must be of same datatype!

logicalOperator if there is more than one column in columns{n} defined, describes how columns{n} are connected.

Operators:

  • AND - all columns{n} need to satisfy condition for source row/rowColumn to be included/excluded at result set that will be stored to target
  • OR - at least one columns{n} need to satisfy condition for source row/rowColumn to be included/excluded at result set that will be stored to target
operation hardcoded value that defines what will happen to matched row.
  • Valid operation:
    • include will add row/rowColumn into target if comparison is true
    • exclude will not add row/rowColumn into target if comparison is true but it will add all other rows where comparison is false

Comparator types

comparator Description
empty (empty) Compares if value of column is empty
notempty (notempty) Compares if value of column is not empty
= (equals) Compares is content of column and comparedTarget is equal
! (not equal) Compares is content of column and comparedTarget is not equal
c= (case ignore equal) Compares is content of column and comparedTarget is equal and ignores case
c! (case ignore not equal) Compares is content of column and comparedTarget is not equal and ignores case
> (>, greater than) Compares if value of column is greater than comparedTarget value
>= (>=, greater than or equal) Compares if value of column is greater than or equal to comparedTarget value
&lt; (<, less than) Compares if value of column is smaller than comparedTarget value
&lt;= (<=, less than or equal) Compares if value of column is less than or equal to comparedTarget value
true (true) Compares if content of column is "true"
false (false) Compares if content of column is "false"
contains Compares if content of column contains comparedTarget value
startsWith Compares if content of column starts with comparedTarget value
endsWith Compares if content of column ends with comparedTarget value
caseIgnoreContains Compares if content of column contains comparedTarget value and ignores case
caseIgnoreStartsWith Compares if content of column starts with comparedTarget value and ignores case
caseIgnoreEndsWith Compares if content of column ends with comparedTarget value and ignores case

Example (single column)

variables.xml
<variable id="allClientsRows" type="rows" defaultValue="" />
<variable id="allNewClientsRows" type="rows" defaultValue="" />
<variable id="newClientNFCPattern" type="text" defaultValue="wert1234">wert1234</variable>
screen.xml
<FrameLayout
    android:id="@+id/exampleFrame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    gn:act_set="[gn:act_resetVariables]|[@variable/allNewClientsRows,@variable/allClientsRows],

                [gn:act_if]|[
                    [gn:act_rawQueryToWidgets]|[clients,allClients;client_client;@variable/allClientsRows]--
						[gn:act_filterRows]|[@variable/allClientsRows,@variable/allNewClientsRows;client_NFCid;@variable/newClientNFCPattern,contains,,include];
                    ::
                ]" />
after action execution

all rows in variable allClientsRows that have column client_NFCid containing value of variable newClientNFCPattern will be added to allNewClientsRows variable.

Example2 (multiple columns)

variables.xml
<variable id="allClientsRows" type="rows" defaultValue="" />
<variable id="allNewClientsRows" type="rows" defaultValue="" />
<variable id="newClientNFCPattern" type="text" defaultValue="wert1234">wert1234</variable>
screen.xml
<FrameLayout
    android:id="@+id/exampleFrame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    gn:act_set="[gn:act_resetVariables]|[@variable/allNewClientsRows,@variable/allClientsRows],

                [gn:act_if]|[
                    [gn:act_rawQueryToWidgets]|[clients,allClients;client_client;@variable/allClientsRows]--
						[gn:act_filterRows]|[@variable/allClientsRows,@variable/allNewClientsRows;client_NFCid,client_client;@variable/newClientNFCPattern,contains,OR,include];
                    ::
                ]" />
after action execution

all rows in variable allClientsRows that have column client_NFCid OR column client_client containing value of variable newClientNFCPattern will be added to allNewClientsRows variable.