Skip to content

Commit 9f6d0b5

Browse files
committed
Added HARMONYCORE_CUSTOM_FIELD_PARAM expression and expansion tokens
1 parent 5aabe41 commit 9f6d0b5

File tree

7 files changed

+188
-8
lines changed

7 files changed

+188
-8
lines changed

Documentation/CodeGen.chm

924 Bytes
Binary file not shown.

Documentation/CodeGen.hsmx

-2.17 KB
Binary file not shown.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
;;*****************************************************************************
2+
;;
3+
;; Title: CustomFieldParam.dbl
4+
;;
5+
;; Type: Class
6+
;;
7+
;; Description: A custom field loop expansion token for use with Harmony Core
8+
;;
9+
;; Date: 26th April 2023
10+
;;
11+
;; Author: Steve Ives, Synergex Professional Services Group
12+
;; http://www.synergex.com
13+
;;
14+
;;*****************************************************************************
15+
;;
16+
;; Copyright (c) 2023, Synergex International, Inc.
17+
;; All rights reserved.
18+
;;
19+
;; Redistribution and use in source and binary forms, with or without
20+
;; modification, are permitted provided that the following conditions are met:
21+
;;
22+
;; * Redistributions of source code must retain the above copyright notice,
23+
;; this list of conditions and the following disclaimer.
24+
;;
25+
;; * Redistributions in binary form must reproduce the above copyright notice,
26+
;; this list of conditions and the following disclaimer in the documentation
27+
;; and/or other materials provided with the distribution.
28+
;;
29+
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30+
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31+
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32+
;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
33+
;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34+
;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35+
;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36+
;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37+
;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38+
;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39+
;; POSSIBILITY OF SUCH DAMAGE.
40+
;;
41+
;;*****************************************************************************
42+
43+
import System
44+
import System.Collections.Generic
45+
import CodeGen.Engine
46+
import CodeGen.RepositoryAPI
47+
48+
namespace HarmonyCoreExtensions
49+
50+
public class CustomFieldParam implements IExpansionToken
51+
52+
public property TokenName, String
53+
method get
54+
proc
55+
mreturn "HARMONYCORE_CUSTOM_FIELD_PARAM"
56+
endmethod
57+
endproperty
58+
59+
public property Description, String
60+
method get
61+
proc
62+
mreturn "An example of a custom field loop token."
63+
endmethod
64+
endproperty
65+
66+
public property Validity, TokenValidity
67+
method get
68+
proc
69+
mreturn TokenValidity.FieldLoop
70+
endmethod
71+
endproperty
72+
73+
public property TokenCase, TokenCaseMode
74+
method get
75+
proc
76+
mreturn TokenCaseMode.UppercaseOnly
77+
endmethod
78+
endproperty
79+
80+
public method Expand, String
81+
tkn, @Token
82+
template, @FileNode
83+
loops, @IEnumerable<LoopNode>
84+
endparams
85+
proc
86+
lambda doExpand(str, field)
87+
begin
88+
data propValue = field.GetProperty<string>(template, "HARMONYCORE_CUSTOM_FIELD_PARAM")
89+
mreturn propValue == ^null ? "" : propValue
90+
end
91+
mreturn TokenExpander.ExpandFieldLoopToken(tkn, template, loops, doExpand)
92+
endmethod
93+
94+
endclass
95+
96+
endnamespace

HarmonyCoreExtensions/CustomFieldType.dbl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ namespace HarmonyCoreExtensions
8686
lambda doExpand(str, field)
8787
begin
8888
data propValue = field.GetProperty<string>(template, "HARMONYCORE_CUSTOM_FIELD_TYPE")
89-
if(propValue != ^null) then
90-
mreturn propValue
91-
else
92-
mreturn ""
89+
mreturn propValue == ^null ? "" : propValue
9390
end
9491
mreturn TokenExpander.ExpandFieldLoopToken(tkn, template, loops, doExpand)
9592
endmethod

HarmonyCoreExtensions/CustomFieldValidator.dbl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,7 @@ namespace HarmonyCoreExtensions
128128
lambda doExpand(str, field)
129129
begin
130130
data propValue = field.GetProperty<string>(template, "HARMONYCORE_CUSTOM_FIELD_VALIDATOR")
131-
if(propValue != ^null) then
132-
mreturn propValue
133-
else
134-
mreturn ""
131+
mreturn propValue == ^null ? "" : propValue
135132
end
136133
mreturn TokenExpander.ExpandFieldLoopToken(tkn, template, loops, doExpand)
137134
endmethod

HarmonyCoreExtensions/HarmonyCoreExtensions.synproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
</ItemGroup>
7373
<ItemGroup>
7474
<Compile Include="AlternateKeyEndpoints.dbl" />
75+
<Compile Include="CustomFieldParam.dbl" />
7576
<Compile Include="CustomFieldValidator.dbl" />
7677
<Compile Include="DeleteEndpoint.dbl" />
7778
<Compile Include="FieldDataType.dbl" />
@@ -82,6 +83,7 @@
8283
<Compile Include="GetEndpoint.dbl" />
8384
<Compile Include="GlobalEntity.dbl" />
8485
<Compile Include="HarmonyRoles.dbl" />
86+
<Compile Include="HasCustomFieldParam.dbl" />
8587
<Compile Include="ParameterBridgeDataObject.dbl" />
8688
<Compile Include="ParameterBridgeDefinition.dbl" />
8789
<Compile Include="ParameterBridgeTypeCS.dbl" />
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
;;*****************************************************************************
2+
;;
3+
;; Title: HasCustomFieldParam.dbl
4+
;;
5+
;; Type: Class
6+
;;
7+
;; Description: A custom field loop expression token for use with Harmony Core
8+
;;
9+
;; Date: 26th April 2023
10+
;;
11+
;; Author: Steve Ives, Synergex Professional Services Group
12+
;; http://www.synergex.com
13+
;;
14+
;;*****************************************************************************
15+
;;
16+
;; Copyright (c) 2023, Synergex International, Inc.
17+
;; All rights reserved.
18+
;;
19+
;; Redistribution and use in source and binary forms, with or without
20+
;; modification, are permitted provided that the following conditions are met:
21+
;;
22+
;; * Redistributions of source code must retain the above copyright notice,
23+
;; this list of conditions and the following disclaimer.
24+
;;
25+
;; * Redistributions in binary form must reproduce the above copyright notice,
26+
;; this list of conditions and the following disclaimer in the documentation
27+
;; and/or other materials provided with the distribution.
28+
;;
29+
;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30+
;; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31+
;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32+
;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
33+
;; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34+
;; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35+
;; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36+
;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37+
;; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38+
;; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39+
;; POSSIBILITY OF SUCH DAMAGE.
40+
;;
41+
;;*****************************************************************************
42+
43+
import System
44+
import System.Collections.Generic
45+
import CodeGen.Engine
46+
import CodeGen.RepositoryAPI
47+
48+
namespace HarmonyCoreExtensions
49+
50+
public class HasCustomFieldParam implements IExpressionToken
51+
52+
public property TokenName, String
53+
method get
54+
proc
55+
mreturn "HARMONYCORE_CUSTOM_FIELD_PARAM"
56+
endmethod
57+
endproperty
58+
59+
public property Description, String
60+
method get
61+
proc
62+
mreturn "Does the field have a custom field parameter?"
63+
endmethod
64+
endproperty
65+
66+
public property Validity, TokenValidity
67+
method get
68+
proc
69+
mreturn TokenValidity.FieldLoop
70+
endmethod
71+
endproperty
72+
73+
public method Evaluate, Boolean
74+
tkn, @Token
75+
template, @FileNode
76+
loops, @IEnumerable<LoopNode>
77+
endparams
78+
proc
79+
lambda doEvaluate(str, field, index)
80+
begin
81+
mreturn field.HasProperty(template, "HARMONYCORE_CUSTOM_FIELD_PARAM")
82+
end
83+
mreturn ExpressionEvaluator.EvaluateFieldLoopExpression(tkn, template, loops, doEvaluate)
84+
endmethod
85+
86+
endclass
87+
88+
endnamespace

0 commit comments

Comments
 (0)