@cyklang/cli 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/AssetCommand.d.ts +4 -0
- package/build/AssetCommand.js +293 -0
- package/build/Cmd.d.ts +2 -1
- package/build/Cmd.js +3 -3
- package/build/DBClient.d.ts +1 -0
- package/build/DBClient.js +51 -17
- package/build/ModuleCommand.js +6 -6
- package/build/TableCommand.js +235 -45
- package/build/index.js +3 -0
- package/package.json +5 -2
- package/pgdata/entry.csv +22 -0
- package/pgdata/setting.csv +4 -0
- package/src/AssetCommand.ts +307 -0
- package/src/Cmd.ts +4 -3
- package/src/DBClient.ts +70 -31
- package/src/ModuleCommand.ts +7 -5
- package/src/TableCommand.ts +269 -56
- package/src/index.ts +3 -0
- package/test/cyklang.xsd +439 -0
- package/test/t0.output +4 -0
- package/test/t0.xml +26 -0
- package/test/t01.output +32 -0
- package/test/t01.xml +185 -0
- package/test/t02.output +10 -0
- package/test/t02.xml +88 -0
- package/test/t03.output +9 -0
- package/test/t03.xml +74 -0
- package/test/t04.output +29 -0
- package/test/t04.xml +116 -0
- package/test/t05.output +18 -0
- package/test/t05.xml +41 -0
- package/test/t06.output +4 -0
- package/test/t06.xml +16 -0
- package/test/t07.output +5 -0
- package/test/t07.xml +82 -0
- package/test/t08.output +8 -0
- package/test/t08.xml +57 -0
- package/test/t09.output +10 -0
- package/test/t09.xml +29 -0
- package/test/t10.xml +125 -0
- package/test/t11.output +3 -0
- package/test/t11.xml +25 -0
- package/test/t12.output +7 -0
- package/test/t12.xml +42 -0
- package/test/t13.xml +23 -0
- package/test/t14.output +50 -0
- package/test/t14.xml +82 -0
- package/test/t14.xsd +102 -0
- package/test/t15.xml +47 -0
- package/test/t16.output +49 -0
- package/test/t16.xml +86 -0
- package/test/t17.output +5 -0
- package/test/t17.xml +21 -0
- package/test/t18.output +22 -0
- package/test/t18.xml +59 -0
- package/test/t19.xml +234 -0
- package/test/t20.xml +15 -0
- package/test/t21.output +21 -0
- package/test/t21.xml +71 -0
- package/test/t22.xml +23 -0
- package/test/t23.xml +44 -0
- package/test/t24.xml +10 -0
- package/test/test.json +113 -0
package/test/t15.xml
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<?xml-model href="cyklang.xsd" ?>
|
|
2
|
+
<module>
|
|
3
|
+
<print>"test de if()"</print>
|
|
4
|
+
<print>if(2+2 == 4, "2+2==4", "2+2!==4")</print>
|
|
5
|
+
|
|
6
|
+
<db.query name="actors_by_film">
|
|
7
|
+
<number name="film_id"/>
|
|
8
|
+
<string name="__fields__">"
|
|
9
|
+
film_id: number;
|
|
10
|
+
actor_id: number: key;
|
|
11
|
+
title: string;
|
|
12
|
+
image_uri: string;
|
|
13
|
+
first_name: string;
|
|
14
|
+
last_name: string
|
|
15
|
+
"
|
|
16
|
+
</string>
|
|
17
|
+
<string name="__sql__" literal="">
|
|
18
|
+
select film.film_id, title, actor.actor_id actor_id,
|
|
19
|
+
actor.image_uri,
|
|
20
|
+
first_name, last_name
|
|
21
|
+
from film_actor join film on film.film_id = film_actor.film_id
|
|
22
|
+
join actor on actor.actor_id = film_actor.actor_id
|
|
23
|
+
where film_actor.film_id = {{ film_id }}
|
|
24
|
+
</string>
|
|
25
|
+
</db.query>
|
|
26
|
+
|
|
27
|
+
<object name="actors_by_film"/>
|
|
28
|
+
|
|
29
|
+
<!-- <db.execute query="actors_by_film" result="actors_by_film">
|
|
30
|
+
<number name="film_id">103</number>
|
|
31
|
+
</db.execute> -->
|
|
32
|
+
|
|
33
|
+
<db.runquery name="actors_by_film" result="actors_by_film">
|
|
34
|
+
<number name="film_id">103</number>
|
|
35
|
+
</db.runquery>
|
|
36
|
+
|
|
37
|
+
<print>string(actors_by_film)</print>
|
|
38
|
+
<print>actors_by_film.resultset.length()</print>
|
|
39
|
+
<!-- <object name="films_actors"/>
|
|
40
|
+
<db.execute query="films_actors" result="films_actors">
|
|
41
|
+
<number name="length_from">60</number>
|
|
42
|
+
<number name="length_to">60</number>
|
|
43
|
+
</db.execute>
|
|
44
|
+
<print>"============= films_actors =========="</print>
|
|
45
|
+
<print>string(films_actors)</print> -->
|
|
46
|
+
|
|
47
|
+
</module>
|
package/test/t16.output
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<object name="year">
|
|
2
|
+
<object name="2021">
|
|
3
|
+
<number name="year_num">2021</number>
|
|
4
|
+
<string name="year_begin_date" literal="">2021-01-01</string>
|
|
5
|
+
<string name="year_end_date" literal="">2021-12-31</string>
|
|
6
|
+
</object>
|
|
7
|
+
</object>
|
|
8
|
+
<object name="resultset">
|
|
9
|
+
<object>
|
|
10
|
+
<object name="year">
|
|
11
|
+
<number name="year_num">2021</number>
|
|
12
|
+
<string name="year_begin_date" literal="">2021-01-01</string>
|
|
13
|
+
<string name="year_end_date" literal="">2021-12-31</string>
|
|
14
|
+
</object>
|
|
15
|
+
</object>
|
|
16
|
+
</object>
|
|
17
|
+
<object name="meta">
|
|
18
|
+
<string name="year" literal=""><db.table name="year" id="14">
|
|
19
|
+
<number name="year_num" type="int" primary="">
|
|
20
|
+
</number>
|
|
21
|
+
<string name="year_begin_date" type="date">
|
|
22
|
+
</string>
|
|
23
|
+
<string name="year_end_date" type="date">
|
|
24
|
+
</string>
|
|
25
|
+
</db.table></string>
|
|
26
|
+
<string name="resultset" literal="">year</string>
|
|
27
|
+
</object>
|
|
28
|
+
dbresult.year_begin_date : 2021-01-01
|
|
29
|
+
year_begin_date : 2021-01-01
|
|
30
|
+
year_end_date : 2021-12-31
|
|
31
|
+
year_begin : 2021-01-01 09:00:00 GMT+0400
|
|
32
|
+
year_end : 2021-12-31 09:00:00 GMT+0400
|
|
33
|
+
year_end greater than year_begin
|
|
34
|
+
OK Février
|
|
35
|
+
test IF before
|
|
36
|
+
monthlabel Mars
|
|
37
|
+
test IF after
|
|
38
|
+
month 1 Janvier 2021 2021-01-01 -> 2021-01-31
|
|
39
|
+
month 2 Février 2021 2021-02-01 -> 2021-02-28
|
|
40
|
+
month 3 Mars 2021 2021-03-01 -> 2021-03-31
|
|
41
|
+
month 4 Avril 2021 2021-04-01 -> 2021-04-30
|
|
42
|
+
month 5 Mai 2021 2021-05-01 -> 2021-05-31
|
|
43
|
+
month 6 Juin 2021 2021-06-01 -> 2021-06-30
|
|
44
|
+
month 7 Juillet 2021 2021-07-01 -> 2021-07-31
|
|
45
|
+
month 8 Août 2021 2021-08-01 -> 2021-08-31
|
|
46
|
+
month 9 Septembre 2021 2021-09-01 -> 2021-09-30
|
|
47
|
+
month 10 Octobre 2021 2021-10-01 -> 2021-10-31
|
|
48
|
+
month 11 Novembre 2021 2021-11-01 -> 2021-11-30
|
|
49
|
+
month 12 Décembre 2021 2021-12-01 -> 2021-12-31
|
package/test/t16.xml
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<?xml-model href="cyklang.xsd" ?>
|
|
2
|
+
<module>
|
|
3
|
+
<object name="dbresult"/>
|
|
4
|
+
<!-- <db.execute select_from_table="year" result="dbresult">
|
|
5
|
+
<string name="where">"year_num = 2021"</string>
|
|
6
|
+
</db.execute> -->
|
|
7
|
+
<db.select table="year" result="dbresult">
|
|
8
|
+
<string name="where">"year_num = 2021"</string>
|
|
9
|
+
</db.select>
|
|
10
|
+
<print>string(dbresult)</print>
|
|
11
|
+
<print>"dbresult.year_begin_date : "+dbresult.year.at(0).year_begin_date</print>
|
|
12
|
+
<string name="year_begin_date">dbresult.year.at(0).year_begin_date</string>
|
|
13
|
+
<string name="year_end_date">dbresult.year.at(0).year_end_date</string>
|
|
14
|
+
<print>"year_begin_date : "+year_begin_date</print>
|
|
15
|
+
<print>"year_end_date : "+year_end_date</print>
|
|
16
|
+
<datetime name="year_begin">datetime("2021-01-01 04:00:00 GMT-0100")</datetime>
|
|
17
|
+
<print>"year_begin : "+year_begin</print>
|
|
18
|
+
<datetime name="year_end">datetime("2021-12-31 04:00:00 GMT-0100")</datetime>
|
|
19
|
+
<print>"year_end : "+year_end</print>
|
|
20
|
+
<if>
|
|
21
|
+
<condition><![CDATA[ year_end > year_begin]]></condition>
|
|
22
|
+
<then>
|
|
23
|
+
<print>"year_end greater than year_begin"</print>
|
|
24
|
+
</then>
|
|
25
|
+
<else>
|
|
26
|
+
<print>"TEST KO"</print>
|
|
27
|
+
</else>
|
|
28
|
+
</if>
|
|
29
|
+
|
|
30
|
+
<object name="monthlabel">
|
|
31
|
+
<string name="_01">"Janvier"</string>
|
|
32
|
+
<string name="_02">"Février"</string>
|
|
33
|
+
<string name="_03">"Mars"</string>
|
|
34
|
+
<string name="_04">"Avril"</string>
|
|
35
|
+
<string name="_05">"Mai"</string>
|
|
36
|
+
<string name="_06">"Juin"</string>
|
|
37
|
+
<string name="_07">"Juillet"</string>
|
|
38
|
+
<string name="_08">"Août"</string>
|
|
39
|
+
<string name="_09">"Septembre"</string>
|
|
40
|
+
<string name="_10">"Octobre"</string>
|
|
41
|
+
<string name="_11">"Novembre"</string>
|
|
42
|
+
<string name="_12">"Décembre"</string>
|
|
43
|
+
</object>
|
|
44
|
+
<if>
|
|
45
|
+
<condition>monthlabel.has("_02")</condition>
|
|
46
|
+
<then>
|
|
47
|
+
<print>"OK "+monthlabel.get("_02")</print>
|
|
48
|
+
</then>
|
|
49
|
+
<else>
|
|
50
|
+
<print>"KO"</print>
|
|
51
|
+
</else>
|
|
52
|
+
</if>
|
|
53
|
+
<print>"test IF before"</print>
|
|
54
|
+
<print>"monthlabel " + monthlabel.get("_03")</print>
|
|
55
|
+
<print>"test IF after"</print>
|
|
56
|
+
|
|
57
|
+
<object name="months"></object>
|
|
58
|
+
|
|
59
|
+
<number name="count">0</number>
|
|
60
|
+
<string name="month_begin">year_begin_date</string>
|
|
61
|
+
<while>
|
|
62
|
+
<condition><![CDATA[ month_begin < year_end_date]]></condition>
|
|
63
|
+
<then>
|
|
64
|
+
<set name="count">count + 1</set>
|
|
65
|
+
|
|
66
|
+
<string name="month_end">dateadd("day", -1, dateadd("month", 1, month_begin))</string>
|
|
67
|
+
|
|
68
|
+
<string name="month_label">monthlabel.at(datepart("month",month_begin)-1)+" "+datepart("year",month_begin)</string>
|
|
69
|
+
<print>"month "+count+ " "+month_label+" "+month_begin + " -> "+month_end</print>
|
|
70
|
+
|
|
71
|
+
<call object="months" method="push">
|
|
72
|
+
<object>
|
|
73
|
+
<string name="month_label">month_label</string>
|
|
74
|
+
<string name="begin">month_begin</string>
|
|
75
|
+
<string name="end">month_end</string>
|
|
76
|
+
</object>
|
|
77
|
+
</call>
|
|
78
|
+
|
|
79
|
+
<set name="month_begin">dateadd("month", 1, month_begin)</set>
|
|
80
|
+
</then>
|
|
81
|
+
</while>
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
<!-- <print>string(months)</print> -->
|
|
85
|
+
|
|
86
|
+
</module>
|
package/test/t17.output
ADDED
package/test/t17.xml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<?xml-model href="cyklang.xsd" ?>
|
|
2
|
+
<module>
|
|
3
|
+
<string name="d1">"2022-07-14"</string>
|
|
4
|
+
<print>"day : "+datepart("day", d1)+", month : "+datepart("month", d1)+", year : "+datepart("year", d1)</print>
|
|
5
|
+
<string name="d2">dateadd("day", -18, d1)</string>
|
|
6
|
+
<print>"d2 : "+d2</print>
|
|
7
|
+
<object name="entry">
|
|
8
|
+
<number name="entry_debit"></number>
|
|
9
|
+
<number name="entry_credit">100</number>
|
|
10
|
+
</object>
|
|
11
|
+
<print>
|
|
12
|
+
if(entry.entry_debit == null || entry.entry_debit == undefined, "DEBIT NULL OR UNDEFINED", entry.entry_debit)
|
|
13
|
+
</print>
|
|
14
|
+
<print>
|
|
15
|
+
if(entry.entry_credit == null || entry.entry_credit == undefined, "CREDIT NULL OR UNDEFINED", entry.entry_credit)
|
|
16
|
+
</print>
|
|
17
|
+
<print>
|
|
18
|
+
if(entry.entry_debit == null || entry.entry_debit == undefined, 0, entry.entry_debit)
|
|
19
|
+
- if(entry.entry_credit == null || entry.entry_credit == undefined, 0, entry.entry_credit)
|
|
20
|
+
</print>
|
|
21
|
+
</module>
|
package/test/t18.output
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
a = value_a
|
|
2
|
+
b = <string name='c'>'value_c'</string>
|
|
3
|
+
c = value_c
|
|
4
|
+
d = value_d
|
|
5
|
+
variable_name = value_variable_name
|
|
6
|
+
g.member1 = member1 VALUE, g.member2 = 100
|
|
7
|
+
ht = 15
|
|
8
|
+
taux = 8.5
|
|
9
|
+
tva = 1.28
|
|
10
|
+
ttc = 16.28
|
|
11
|
+
xpr = 'john ' + ' doe', i = john doe
|
|
12
|
+
xpr_ht_tva : ht + tva
|
|
13
|
+
result_ttc = 16.28
|
|
14
|
+
array before = <object>
|
|
15
|
+
<string literal="">obj1_element</string>
|
|
16
|
+
</object>
|
|
17
|
+
<object>
|
|
18
|
+
<string literal="">obj2_element</string>
|
|
19
|
+
</object>
|
|
20
|
+
array after =
|
|
21
|
+
substring('12345',0,2) = 12
|
|
22
|
+
substring('12345',2) = 345
|
package/test/t18.xml
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<?xml-model href="cyklang.xsd" ?>
|
|
2
|
+
<module>
|
|
3
|
+
<stringexec><![CDATA[ "<string name='a'>'value_a'</string>" ]]> </stringexec>
|
|
4
|
+
<print>"a = " + a </print>
|
|
5
|
+
<string name="b" literal=""><![CDATA[ <string name='c'>'value_c'</string> ]]></string>
|
|
6
|
+
<print>"b = " + b </print>
|
|
7
|
+
<stringexec>b</stringexec>
|
|
8
|
+
<print>"c = " + c </print>
|
|
9
|
+
<stringexec literal=""> <![CDATA[ <string name="d"> "value_d" </string> ]]></stringexec>
|
|
10
|
+
<print>"d = " + d</print>
|
|
11
|
+
<string name="e">"variable_name"</string>
|
|
12
|
+
<stringexec literal=""> <![CDATA[ <string name="{{ e }}"> "value_variable_name" </string> ]]> </stringexec>
|
|
13
|
+
<print>"variable_name = " + variable_name </print>
|
|
14
|
+
|
|
15
|
+
<string name="f" literal="">
|
|
16
|
+
<![CDATA[
|
|
17
|
+
<string name='member1'>"member1 VALUE"</string>
|
|
18
|
+
<number name='member2'>100</number>
|
|
19
|
+
]]>
|
|
20
|
+
</string>
|
|
21
|
+
<object name="g">object(f)</object>
|
|
22
|
+
<print>"g.member1 = "+g.member1 + ", g.member2 = "+g.member2</print>
|
|
23
|
+
|
|
24
|
+
<number name="taux">8.5</number>
|
|
25
|
+
<number name="ht">15</number>
|
|
26
|
+
<number name="tva"> round( ht * taux ) / 100 </number>
|
|
27
|
+
<number name="ttc">ht + tva</number>
|
|
28
|
+
<print>"ht = "+ht</print>
|
|
29
|
+
<print>"taux = "+taux</print>
|
|
30
|
+
<print>"tva = "+ tva</print>
|
|
31
|
+
<print><![CDATA[ "ttc = "]]> <![CDATA[ + ttc ]]> </print>
|
|
32
|
+
<string name="xpr">"'john ' + ' doe'"</string>
|
|
33
|
+
<string name="i">eval(xpr)</string>
|
|
34
|
+
<print>"xpr = " + xpr + ", i = "+i</print>
|
|
35
|
+
<string name="xpr_ht_tva">"ht + tva"</string>
|
|
36
|
+
<number name="result_ttc">eval(xpr_ht_tva)</number>
|
|
37
|
+
<print>"xpr_ht_tva : " + xpr_ht_tva</print>
|
|
38
|
+
<print>"result_ttc = "+result_ttc</print>
|
|
39
|
+
|
|
40
|
+
<object name="obj1">
|
|
41
|
+
<string>"obj1_element"</string>
|
|
42
|
+
</object>
|
|
43
|
+
<object name="obj2">
|
|
44
|
+
<string>"obj2_element"</string>
|
|
45
|
+
</object>
|
|
46
|
+
<object name="array">
|
|
47
|
+
<object>obj1</object>
|
|
48
|
+
<object>obj2</object>
|
|
49
|
+
</object>
|
|
50
|
+
<print>"array before = "+string(array)</print>
|
|
51
|
+
<call object="array" method="remove">
|
|
52
|
+
<object>obj1</object>
|
|
53
|
+
<object>obj2</object>
|
|
54
|
+
</call>
|
|
55
|
+
<print>"array after = "+string(array)</print>
|
|
56
|
+
|
|
57
|
+
<print>"substring('12345',0,2) = " + substring('12345', 0, 2)</print>
|
|
58
|
+
<print>"substring('12345',2) = " + substring('12345', 2)</print>
|
|
59
|
+
</module>
|
package/test/t19.xml
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
<?xml-model href="cyklang.xsd" ?>
|
|
2
|
+
<module>
|
|
3
|
+
<!--
|
|
4
|
+
function build_entries
|
|
5
|
+
-->
|
|
6
|
+
|
|
7
|
+
<function name="build_entries" returns="result: object">
|
|
8
|
+
<object name="param"/>
|
|
9
|
+
<object name="model_entries"/>
|
|
10
|
+
<block>
|
|
11
|
+
<set name="result"></set>
|
|
12
|
+
<call object="model_entries" method="foreach">
|
|
13
|
+
<function>
|
|
14
|
+
<object name="model_entry"/>
|
|
15
|
+
<block>
|
|
16
|
+
<object name="entry">newDBRow("entry")</object>
|
|
17
|
+
<set name="entry.entry_ord">model_entry.ent_ord</set>
|
|
18
|
+
<set name="entry.entry_acct">eval(model_entry.ent_acct)</set>
|
|
19
|
+
<set name="entry.entry_aux">eval(model_entry.ent_aux)</set>
|
|
20
|
+
<set name="entry.entry_debit">eval(model_entry.ent_debit)</set>
|
|
21
|
+
<set name="entry.entry_credit">eval(model_entry.ent_credit)</set>
|
|
22
|
+
<call object="result" method="push">
|
|
23
|
+
<object>entry</object>
|
|
24
|
+
</call>
|
|
25
|
+
</block>
|
|
26
|
+
</function>
|
|
27
|
+
</call>
|
|
28
|
+
</block>
|
|
29
|
+
</function>
|
|
30
|
+
|
|
31
|
+
<!--
|
|
32
|
+
function update_document_entries
|
|
33
|
+
-->
|
|
34
|
+
|
|
35
|
+
<function name="update_document_entries">
|
|
36
|
+
<number name="doc_id"/>
|
|
37
|
+
<block>
|
|
38
|
+
|
|
39
|
+
<object name="result_document"/>
|
|
40
|
+
<!-- <db.execute select_from_table="document" result="result_document">
|
|
41
|
+
<string name="where">"doc_id="+doc_id</string>
|
|
42
|
+
</db.execute> -->
|
|
43
|
+
|
|
44
|
+
<db.select table="document" result="result_document">
|
|
45
|
+
<string name="where">"doc_id="+doc_id</string>
|
|
46
|
+
</db.select>
|
|
47
|
+
|
|
48
|
+
<if>
|
|
49
|
+
<condition>result_document.document.length() == 0</condition>
|
|
50
|
+
<then>
|
|
51
|
+
<print>"doc_id "+doc_id+" not found"</print>
|
|
52
|
+
<break/>
|
|
53
|
+
</then>
|
|
54
|
+
<condition>result_document.document.at(0).doc_model == undefined</condition>
|
|
55
|
+
<then>
|
|
56
|
+
<print>"doc_id "+doc_id+" doc_model is null"</print>
|
|
57
|
+
<break/>
|
|
58
|
+
</then>
|
|
59
|
+
</if>
|
|
60
|
+
|
|
61
|
+
<object name="document">result_document.document.at(0)</object>
|
|
62
|
+
|
|
63
|
+
<object name="result_model"/>
|
|
64
|
+
|
|
65
|
+
<db.select table="model" result="result_model">
|
|
66
|
+
<string name="where">"model_id="+document.doc_model</string>
|
|
67
|
+
</db.select>
|
|
68
|
+
|
|
69
|
+
<!-- <db.execute select_from_table="model" result="result_model">
|
|
70
|
+
<string name="where">"model_id="+document.doc_model</string>
|
|
71
|
+
</db.execute> -->
|
|
72
|
+
|
|
73
|
+
<if>
|
|
74
|
+
<condition>result_model.model.length() == 0</condition>
|
|
75
|
+
<then>
|
|
76
|
+
<print>"doc_id "+doc_id+", doc_model "+document.doc_model +" not found"</print>
|
|
77
|
+
<break/>
|
|
78
|
+
</then>
|
|
79
|
+
</if>
|
|
80
|
+
|
|
81
|
+
<object name="model">result_model.model.at(0)</object>
|
|
82
|
+
|
|
83
|
+
<object name="new_entries"/>
|
|
84
|
+
<call function="build_entries" returns="new_entries">
|
|
85
|
+
<object name="param">object(document.doc_params)</object>
|
|
86
|
+
<object name="model_entries">object(model.model_entries)</object>
|
|
87
|
+
</call>
|
|
88
|
+
|
|
89
|
+
<call object="new_entries" method="foreach">
|
|
90
|
+
<function>
|
|
91
|
+
<object name="entry"/>
|
|
92
|
+
<block>
|
|
93
|
+
<set name="entry.entry_year">document.doc_year</set>
|
|
94
|
+
<set name="entry.entry_date">document.doc_date</set>
|
|
95
|
+
<set name="entry.entry_jnl">document.doc_jnl</set>
|
|
96
|
+
<set name="entry.entry_doc">document.doc_id</set>
|
|
97
|
+
</block>
|
|
98
|
+
</function>
|
|
99
|
+
</call>
|
|
100
|
+
<print>"***** NEW ENTRIES ******"</print>
|
|
101
|
+
<print>string(new_entries)</print>
|
|
102
|
+
|
|
103
|
+
<object name="result_old_entries"/>
|
|
104
|
+
|
|
105
|
+
<db.select table="entry" result="result_old_entries">
|
|
106
|
+
<string name="where">"entry_doc="+doc_id</string>
|
|
107
|
+
<string name="order_by">"entry_ord,entry_id"</string>
|
|
108
|
+
</db.select>
|
|
109
|
+
|
|
110
|
+
<!-- <db.execute select_from_table="entry" result="result_old_entries">
|
|
111
|
+
<string name="where">"entry_doc="+doc_id</string>
|
|
112
|
+
<string name="order_by">"entry_ord,entry_id"</string>
|
|
113
|
+
</db.execute> -->
|
|
114
|
+
<object name="old_entries">result_old_entries.entry</object>
|
|
115
|
+
<print>"***** OLD ENTRIES ******"</print>
|
|
116
|
+
<print>string(old_entries)</print>
|
|
117
|
+
|
|
118
|
+
<!-- synchronize between old_entries and new_entries -->
|
|
119
|
+
|
|
120
|
+
<number name="i_old">0</number>
|
|
121
|
+
<number name="i_new">0</number>
|
|
122
|
+
|
|
123
|
+
<object name="old_entry"/>
|
|
124
|
+
<object name="new_entry"/>
|
|
125
|
+
|
|
126
|
+
<function name="next_old">
|
|
127
|
+
<block>
|
|
128
|
+
<if>
|
|
129
|
+
<condition><![CDATA[ i_old < old_entries.length() ]]></condition>
|
|
130
|
+
<then>
|
|
131
|
+
<set name="old_entry">old_entries.at(i_old)</set>
|
|
132
|
+
<set name="i_old">i_old + 1</set>
|
|
133
|
+
</then>
|
|
134
|
+
<else>
|
|
135
|
+
<set name="old_entry">undefined</set>
|
|
136
|
+
</else>
|
|
137
|
+
</if>
|
|
138
|
+
</block>
|
|
139
|
+
</function>
|
|
140
|
+
|
|
141
|
+
<function name="next_new">
|
|
142
|
+
<block>
|
|
143
|
+
<if>
|
|
144
|
+
<condition><![CDATA[ i_new < new_entries.length() ]]></condition>
|
|
145
|
+
<then>
|
|
146
|
+
<set name="new_entry">new_entries.at(i_new)</set>
|
|
147
|
+
<set name="i_new">i_new + 1</set>
|
|
148
|
+
</then>
|
|
149
|
+
<else>
|
|
150
|
+
<set name="new_entry">undefined</set>
|
|
151
|
+
</else>
|
|
152
|
+
</if>
|
|
153
|
+
</block>
|
|
154
|
+
</function>
|
|
155
|
+
|
|
156
|
+
<call function="next_old"/>
|
|
157
|
+
<call function="next_new"/>
|
|
158
|
+
|
|
159
|
+
<loop>
|
|
160
|
+
<break>old_entry == undefined</break>
|
|
161
|
+
<loop>
|
|
162
|
+
<break>new_entry == undefined</break>
|
|
163
|
+
<break> <![CDATA[ new_entry.entry_ord >= old_entry.entry_ord ]]> </break>
|
|
164
|
+
|
|
165
|
+
<db.insert table="entry">
|
|
166
|
+
<object>new_entry</object>
|
|
167
|
+
</db.insert>
|
|
168
|
+
|
|
169
|
+
<!-- <db.execute insert_into_table="entry">
|
|
170
|
+
<object>new_entry</object>
|
|
171
|
+
</db.execute> -->
|
|
172
|
+
<print>"old_entry : "+old_entry.entry_ord+", insert new_entry : "+new_entry.entry_ord</print>
|
|
173
|
+
<call function="next_new"/>
|
|
174
|
+
</loop>
|
|
175
|
+
|
|
176
|
+
<if>
|
|
177
|
+
<condition>new_entry == undefined</condition>
|
|
178
|
+
<then>
|
|
179
|
+
<db.delete table="entry">
|
|
180
|
+
<object>old_entry</object>
|
|
181
|
+
</db.delete>
|
|
182
|
+
<!-- <db.execute delete_from_table="entry">
|
|
183
|
+
<object>old_entry</object>
|
|
184
|
+
</db.execute> -->
|
|
185
|
+
<print>"delete old_entry : "+old_entry.entry_ord +", new_entry undefined"</print>
|
|
186
|
+
</then>
|
|
187
|
+
<condition><![CDATA[ old_entry.entry_ord < new_entry.entry_ord ]]> </condition>
|
|
188
|
+
<then>
|
|
189
|
+
<db.delete table="entry">
|
|
190
|
+
<object>old_entry</object>
|
|
191
|
+
</db.delete>
|
|
192
|
+
<!-- <db.execute delete_from_table="entry">
|
|
193
|
+
<object>old_entry</object>
|
|
194
|
+
</db.execute> -->
|
|
195
|
+
<print>"delete old_entry : "+old_entry.entry_ord+", new_entry = "+new_entry.entry_ord</print>
|
|
196
|
+
</then>
|
|
197
|
+
<condition>old_entry.entry_ord == new_entry.entry_ord</condition>
|
|
198
|
+
<then>
|
|
199
|
+
<set name="new_entry.entry_id">old_entry.entry_id</set>
|
|
200
|
+
<db.update table="entry">
|
|
201
|
+
<object>new_entry</object>
|
|
202
|
+
</db.update>
|
|
203
|
+
<!-- <db.execute update_table="entry">
|
|
204
|
+
<object>new_entry</object>
|
|
205
|
+
</db.execute> -->
|
|
206
|
+
<print>"update new_entry id="+new_entry.entry_id+", ord="+new_entry.entry_ord</print>
|
|
207
|
+
<call function="next_new"/>
|
|
208
|
+
</then>
|
|
209
|
+
</if>
|
|
210
|
+
|
|
211
|
+
<call function="next_old"/>
|
|
212
|
+
</loop>
|
|
213
|
+
|
|
214
|
+
<loop>
|
|
215
|
+
<break>new_entry == undefined</break>
|
|
216
|
+
<db.insert table="entry">
|
|
217
|
+
<object>new_entry</object>
|
|
218
|
+
</db.insert>
|
|
219
|
+
<!-- <db.execute insert_into_table="entry">
|
|
220
|
+
<object>new_entry</object>
|
|
221
|
+
</db.execute> -->
|
|
222
|
+
|
|
223
|
+
<print>"after old_entries, insert new_entry : "+new_entry.entry_ord</print>
|
|
224
|
+
<call function="next_new"/>
|
|
225
|
+
</loop>
|
|
226
|
+
|
|
227
|
+
</block>
|
|
228
|
+
</function>
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
<call function="update_document_entries">
|
|
232
|
+
<number name="doc_id">4</number>
|
|
233
|
+
</call>
|
|
234
|
+
</module>
|
package/test/t20.xml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml-model href="cyklang.xsd" ?>
|
|
2
|
+
<module name="t20" dbname="t20">
|
|
3
|
+
<object name="settings"/>
|
|
4
|
+
<function name="__init__">
|
|
5
|
+
<object name="settings"/>
|
|
6
|
+
<block>
|
|
7
|
+
<set name="this.settings">settings</set>
|
|
8
|
+
</block>
|
|
9
|
+
</function>
|
|
10
|
+
<function name="print_settings">
|
|
11
|
+
<block>
|
|
12
|
+
<print>"print_settings : " + string(settings)</print>
|
|
13
|
+
</block>
|
|
14
|
+
</function>
|
|
15
|
+
</module>
|
package/test/t21.output
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
print_settings : <string name="name" literal="">Dupont</string>
|
|
2
|
+
<string name="surname" literal="">Jean</string>
|
|
3
|
+
owner not set
|
|
4
|
+
owner yves not in the collection
|
|
5
|
+
john's car's brand is BMW
|
|
6
|
+
bool : false
|
|
7
|
+
chaine : 150
|
|
8
|
+
<datetime name="dtbirthday">datetime("Mon Nov 04 1963 04:00:00 GMT+0400 (heure de La Réunion)")</datetime>
|
|
9
|
+
<datetime name="dtundef1">
|
|
10
|
+
</datetime>
|
|
11
|
+
<datetime name="dtundef2">
|
|
12
|
+
</datetime>
|
|
13
|
+
<datetime name="dtnull1">
|
|
14
|
+
</datetime>
|
|
15
|
+
<datetime name="dtbirthday">datetime("Mon Nov 04 1963 04:00:00 GMT+0400 (heure de La Réunion)")</datetime>
|
|
16
|
+
<datetime name="dtundef1">
|
|
17
|
+
</datetime>
|
|
18
|
+
<datetime name="dtundef2">
|
|
19
|
+
</datetime>
|
|
20
|
+
<datetime name="dtnull1">
|
|
21
|
+
</datetime>
|
package/test/t21.xml
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<?xml-model href="cyklang.xsd" ?>
|
|
2
|
+
<module>
|
|
3
|
+
<object name="params">
|
|
4
|
+
<string name="name">"Dupont"</string>
|
|
5
|
+
<string name="surname">"Jean"</string>
|
|
6
|
+
</object>
|
|
7
|
+
<module_object name="m_t20" dbname="t20">
|
|
8
|
+
<object name="settings">params</object>
|
|
9
|
+
</module_object>
|
|
10
|
+
<!-- <call object="m_t20" method="__init__">
|
|
11
|
+
<object name="settings">params</object>
|
|
12
|
+
</call> -->
|
|
13
|
+
<call object="m_t20" method="print_settings"/>
|
|
14
|
+
|
|
15
|
+
<object name="obj">m_t20</object>
|
|
16
|
+
<string name="owner"/>
|
|
17
|
+
<object name="cars">
|
|
18
|
+
<object name="john">
|
|
19
|
+
<string name="brand">"BMW"</string>
|
|
20
|
+
</object>
|
|
21
|
+
<object name="pierre">
|
|
22
|
+
<string name="brand">"TOYOTA"</string>
|
|
23
|
+
</object>
|
|
24
|
+
</object>
|
|
25
|
+
<if>
|
|
26
|
+
<condition><![CDATA[ owner !== undefined && cars.get(owner) !== undefined && cars.get(owner).has('brand') == true ]]> </condition>
|
|
27
|
+
<then>
|
|
28
|
+
<print>owner + "'s car's brand is " + cars.get(owner).brand</print>
|
|
29
|
+
</then>
|
|
30
|
+
<else>
|
|
31
|
+
<print>"owner not set"</print>
|
|
32
|
+
</else>
|
|
33
|
+
</if>
|
|
34
|
+
<set name="owner">"yves"</set>
|
|
35
|
+
<if>
|
|
36
|
+
<condition><![CDATA[ owner !== undefined && cars.get(owner) !== undefined && cars.get(owner).has('brand') == true ]]> </condition>
|
|
37
|
+
<then>
|
|
38
|
+
<print>owner + "'s car's brand is " + cars.get(owner).brand</print>
|
|
39
|
+
</then>
|
|
40
|
+
<else>
|
|
41
|
+
<print>"owner " + owner + " not in the collection "</print>
|
|
42
|
+
</else>
|
|
43
|
+
</if>
|
|
44
|
+
<set name="owner">"john"</set>
|
|
45
|
+
<if>
|
|
46
|
+
<condition><![CDATA[ owner !== undefined && cars.get(owner) !== undefined && cars.get(owner).has('brand') == true ]]> </condition>
|
|
47
|
+
<then>
|
|
48
|
+
<print>owner + "'s car's brand is " + cars.get(owner).brand</print>
|
|
49
|
+
</then>
|
|
50
|
+
<else>
|
|
51
|
+
<print>"TEST KO"</print>
|
|
52
|
+
</else>
|
|
53
|
+
</if>
|
|
54
|
+
|
|
55
|
+
<boolean name="bool">true</boolean>
|
|
56
|
+
<set name="bool">boolean("")</set>
|
|
57
|
+
<print>"bool : " + bool</print>
|
|
58
|
+
|
|
59
|
+
<string name="chaine">150</string>
|
|
60
|
+
<print>"chaine : " + chaine</print>
|
|
61
|
+
|
|
62
|
+
<object name="document">
|
|
63
|
+
<datetime name="dtbirthday">datetime("1963-11-04")</datetime>
|
|
64
|
+
<datetime name="dtundef1"/>
|
|
65
|
+
<datetime name="dtundef2">undefined</datetime>
|
|
66
|
+
<datetime name="dtnull1">null</datetime>
|
|
67
|
+
</object>
|
|
68
|
+
<print>string(document)</print>
|
|
69
|
+
<print>string(object(string(document)))</print>
|
|
70
|
+
|
|
71
|
+
</module>
|
package/test/t22.xml
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<?xml-model href="cyklang.xsd" ?>
|
|
2
|
+
<module dbname="t22">
|
|
3
|
+
<function name="get_tables" returns="result: object">
|
|
4
|
+
<block>
|
|
5
|
+
|
|
6
|
+
<object name="result_setting"/>
|
|
7
|
+
<db.select table="setting" result="result_setting"/>
|
|
8
|
+
<!-- <db.execute select_from_table="setting" result="result_setting"/> -->
|
|
9
|
+
|
|
10
|
+
<object name="result_">
|
|
11
|
+
<string name="name">"CYK"</string>
|
|
12
|
+
<string name="surname">"Philippe"</string>
|
|
13
|
+
<object name="setting">result_setting.setting</object>
|
|
14
|
+
<object name="meta">
|
|
15
|
+
<string name="setting">result_setting.meta.setting</string>
|
|
16
|
+
</object>
|
|
17
|
+
</object>
|
|
18
|
+
<set name="result">result_</set>
|
|
19
|
+
|
|
20
|
+
<print>"Server side : " + string(result)</print>
|
|
21
|
+
</block>
|
|
22
|
+
</function>
|
|
23
|
+
</module>
|