|
| 1 | +;;***************************************************************************** |
| 2 | +;; |
| 3 | +;; Title: OneToMany.dbl |
| 4 | +;; |
| 5 | +;; Type: Class |
| 6 | +;; |
| 7 | +;; Description: A custom relation loop expression token for use with Harmony Core |
| 8 | +;; |
| 9 | +;; Date: 21st August 2019 |
| 10 | +;; |
| 11 | +;; Author: Steve Ives, Synergex Professional Services Group |
| 12 | +;; http://www.synergex.com |
| 13 | +;; |
| 14 | +;;***************************************************************************** |
| 15 | +;; |
| 16 | +;; Copyright (c) 2019, 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 IsFieldReserved implements IExpressionToken |
| 51 | + |
| 52 | + public property TokenName, String |
| 53 | + method get |
| 54 | + proc |
| 55 | + mreturn "IS_FIELD_RESERVED" |
| 56 | + endmethod |
| 57 | + endproperty |
| 58 | + |
| 59 | + public property Description, String |
| 60 | + method get |
| 61 | + proc |
| 62 | + mreturn "Determines if a field name is a reserved word" |
| 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 | + proc |
| 78 | + lambda doEvaluate(str, field, index) |
| 79 | + begin |
| 80 | + mreturn string.Compare(field.Name, "globalrfa", true) == 0 || |
| 81 | + & string.Compare(field.Name, "synergyrecord", true) == 0 || |
| 82 | + & string.Compare(field.Name, "metadata", true) == 0 || |
| 83 | + & string.Compare(field.Name, "iriginalsynergyrecord", true) == 0 |
| 84 | + end |
| 85 | + |
| 86 | + mreturn ExpressionEvaluator.EvaluateFieldLoopExpression(tkn, template, loops, doEvaluate) |
| 87 | + |
| 88 | + endmethod |
| 89 | + |
| 90 | + endclass |
| 91 | + |
| 92 | +endnamespace |
0 commit comments