From wiki.ginstr.com
Revision as of 10:20, 3 October 2019 by Dinko (talk | contribs) (Copy data)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

gn:act_copyDataNew

Description
Action used to copy content from source to target. Content that is copied ALWAYS REPLACES the content in target. Source and target have to be of same datatype unless there is a supported conversion.
For supported conversions see table below.
Action returns
boolean, true if content was successfully copied otherwise false
Supported source to target data conversions
Source Target
pointer text
text pointer
email pointer
email text
number pointer
text number
date long
dateTime long
enum text

Action signatures

Copy data

[gn:act_copyDataNew]|[source(indexSource)(columnSource),target(indexTarget)(columnTarget)]
Parameter Description
source source from where the value will be copied
target target where the value will be stored
indexSource
indexTarget
optional

source or target which will be used as index for source and target, needs to be an integer

columnSource
columnTarget
optional

source or target which will be used as column name within a row or complex datatype.

Examples of row operation signatures from rows to rows datatype with index
[gn:act_copyDataNew]|[@variable/rows,@variable/targetRows]
[gn:act_copyDataNew]|[@variable/rows(indexSource)(),@variable/targetRows]
[gn:act_copyDataNew]|[@variable/rows(indexSource)(),@variable/targetRows(indexTarget)()]
Examples of row operation signatures from rows to rows datatype with column
[gn:act_copyDataNew]|[@variable/rows()(columnSource),@variable/targetRows()(columnTarget)] source and target have single row
Examples of row operation signatures from rows to rows datatype with index and column
[gn:act_copyDataNew]|[@variable/rows(indexSource)(columnSource),@variable/targetRows(indexTarget)(columnTarget)]
[gn:act_copyDataNew]|[@variable/rows()(columnSource),@variable/targetRows(indexTarget)(columnTarget)] source has single row
[gn:act_copyDataNew]|[@variable/rows(indexSource)(columnSource),@variable/targetRows()(columnTarget)] target has single row
Examples of datatype internal operation signatures with index and column
[gn:act_copyDataNew]|[@variable/emails,@variable/emailsNew]
[gn:act_copyDataNew]|[@variable/emails(indexSource)(columnSource),@variable/text]
[gn:act_copyDataNew]|[@variable/emails()(columnSource),@variable/text] source has single row
[gn:act_copyDataNew]|[@variable/emails(indexSource)(),@variable/emailsNew]
[gn:act_copyDataNew]|[@variable/enum()(key),@variable/enumText]
[gn:act_copyDataNew]|[@variable/enum()(value),@variable/enumText] (M104)
Example of datatype pointer to datatype text (extraction of email)
[gn:act_copyDataNew]|[@variable/employee_userIdPointer()(value),@variable/employee_testEmail]
[gn:act_copyDataNew]|[@variable/employee_testEmail()(email),@variable/employee_testEmailText]

Example 1

initial value
@variable/allReportRows - 3 rows with 10 columns each
@variable/allReportRowsCopy - empty
variables.xml
<variable id="allReportRows" type="rows"/>
<variable id="allReportRowsCopy" type="rows"/>
screen.xml
          <com.ginstr.widgets.GnEditText
               android:id="@+id/screen_integerNumberLabel_input"
               android:layout_height="wrap_content"
               android:layout_width="match_parent"
               gn:dataType="number"
               gn:inputType="NUMBER"
               gn:s_decimalFormat="#"
               gn:s_sourceType="input"
               gn:style="@style/numberInteger_input"/>

<FrameLayout
    android:id="@+id/exampleFrame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    gn:act_set="[gn:act_copyDataNew]|[@variable/allReportRows(@+id/screen_integerNumberLabel_input)(),@variable/allReportRowsCopy]" />
after action execution

if numerical value i.e. 0 was defined at widget @+id/screen_integerNumberLabel_input

@variable/allReportRowsCopy - 0'th row from @variable/allReportRows

Example 2

initial value
@variable/allReportRows - 3 rows with 10 columns each
@variable/allReportRowsCopy - empty
variables.xml
<variable id="allReportRows" type="rows"/>
<variable id="allReportRowsCopy" type="rows"/>
screen.xml
          <com.ginstr.widgets.GnEditText
               android:id="@+id/screen_integerNumberLabel_input"
               android:layout_height="wrap_content"
               android:layout_width="match_parent"
               gn:dataType="number"
               gn:inputType="NUMBER"
               gn:s_decimalFormat="#"
               gn:s_sourceType="input"
               gn:style="@style/numberInteger_input"/>

<FrameLayout
    android:id="@+id/exampleFrame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    gn:act_set="[gn:act_copyDataNew]|[@variable/allReportRows(@+id/screen_integerNumberLabel_input)(),@variable/allReportRowsCopy]" />
after action execution

if numerical value i.e. 0 was defined at widget @+id/screen_integerNumberLabel_input

@variable/allReportRowsCopy - 0'th row from @variable/allReportRows

if widget@+id/screen_integerNumberLabel_input is empty

@variable/allReportRowsCopy - all rows from @variable/allReportRows

Example 3

initial value
@+id/screen_mediaPhotoLabel_button - widget contains 3 images loaded from database
@+id/screen_textLabel_fileInfo - empty input field
screen.xml
          <com.ginstr.widgets.GnMediaAction
                    android:id="@+id/screen_mediaPhotoLabel_button"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content"
                    gn:act_setAfterMediaTaken="[gn:act_copyDataNew]|[@+id/screen_mediaPhotoLabel_button,@+id/screen_mediaPhotoLabel_gallery]"
                    gn:dataType="pictures"
                    gn:maxMediaTaken="5"
                    gn:s_actionType="photo"
                    gn:singleValueMode="false"
                    gn:style="@style/mediaPhoto_button"/>

<com.ginstr.widgets.GnEditText
               android:id="@+id/screen_textLabel_fileInfo"
               android:layout_height="wrap_content"
               android:layout_width="match_parent"
               gn:dataType="text"
               gn:s_hint="@string/fileInfo"
               gn:s_sourceType="input"
               gn:style="@style/textEditable_input"/>		

<FrameLayout
    android:id="@+id/exampleFrame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:visibility="gone"
    gn:act_set="[gn:act_copyDataNew]|[@+id/screen_mediaPhotoLabel_button(0)(filename),@+id/screen_textLabel_fileInfo]" />
after action execution
@+id/screen_textLabel_fileInfo - input field will show name of the first file that is stored in @+id/screen_mediaPhotoLabel_button widget

Example 4

initial value
@variable/takeover_fuelLevel - source variable contains enum DT value
screen.xml
[gn:act_copyDataNew]|[@variable/takeover_fuelLevel()(key),@variable/takeover_fuelLevelTextKey];
after action execution
@variable/takeover_fuelLevelTextKey - target variable which will store text value from @variable/takeover_fuelLevel based on key