• CodeGen字段循环Field Loop


    CodeGen字段循环Field Loop

    字段循环是一个模板文件构造,它允许迭代CodeGen拥有的有关字段的集合。这些字段定义可以来自以下两个位置之一:             

    •如果基于从存储库结构中获取的信息生成代码,则字段集合将基于存储库结构中定义的字段。             

    •如果根据UI Toolkit输入窗口(在窗口脚本文件中定义)的定义生成代码,则字段集合由该输入窗口中定义的字段确定。当然,这些字段可能反过来引用存储库结构。             

    •如果基于从Synergy方法目录中获取的信息生成代码,并且当前正在处理一个结构参数,则字段集合将基于与当前参数关联的存储库结构中定义的字段。             

    字段循环由一对匹配的<Field_LOOP>和</Field_LOOP>标记分隔,它们围绕要为每个字段插入的模板代码。在每个字段的开始标记和结束标记之间重复处理。             

    •场循环扩展令牌             

    •字段循环表达式标记             

    字段循环可以在结构循环和参数循环中定义,但不能在任何其他循环构造中声明。             

    CodeGen将数组字段作为多个单独的字段进行处理。通常CodeGen不处理覆盖字段或标记为“由语言排除”的字段。             

    有两种类型的场循环,称为多线场循环和串联场循环。

    Multi-Line Field Loops

    在模板的一行或多行中出现一行或多行结束标记时,在模板中出现一行或多行结束标记,如:

    [code]

    <FIELD_LOOP>
    code
    </FIELD_LOOP>

    [code]

    多行字段循环为处理的每个字段生成一行或多行输出代码。

    In-Line Field Loops

    当开始和结束字段循环标记出现在模板文件中的同一行上,并且分隔了模板代码行的一部分时,就会出现行内字段循环,如下所示:

    [code] <FIELD_LOOP> code </FIELD_LOOP> [code]

    行内字段循环将代码生成到当前输出行。

    Field Loop Example 1 (Multi-Line)

    以下模板文件代码:

    sql = "CREATE TABLE <STRUCTURE_NAME> ("
    <FIELD_LOOP>
    & + "<FIELD_SQLNAME> <FIELD_SQLTYPE><IF REQUIRED> NOT NULL</IF><,>"
    </FIELD_LOOP>
    & + ")"

    可以产生这样的输出:

    sql = "CREATE TABLE PROJECT ("
    & + "SYNERGYGRFA VARCHAR(22),"
    & + "PROJECT_ID DECIMAL(8) NOT NULL,"
    & + "CUSTOMER_ID VARCHAR(10) NOT NULL,"
    & + "CONTRACT_ID VARCHAR(10) NOT NULL,"
    & + "CONTRACT_PROJECT_ID DECIMAL(3) NOT NULL,"
    & + "DESCRIPTION VARCHAR(60) NOT NULL,"
    & + "START_DATE DATETIME NOT NULL,"
    & + "END_DATE DATETIME,"
    & + "CURRENT_STATUS DECIMAL(2) NOT NULL,"
    & + "STATUS_DATE DATETIME NOT NULL,"
    & + "LEAD_CONSULTANT VARCHAR(15) NOT NULL,"
    & + "COORDINATOR VARCHAR(15) NOT NULL,"
    & + "APPROVED_BY_FIRST DECIMAL(3) NOT NULL,"
    & + "APPROVED_BY_LAST DECIMAL(3) NOT NULL,"
    & + "APPROVED_DATE DATETIME NOT NULL,"
    & + "APPROVAL_LOCATION DECIMAL(2) NOT NULL,"
    & + "WORK_LOCATION_ID DECIMAL(2),"
    & + "CREATED_BY VARCHAR(15) NOT NULL,"
    & + "CREATED_DATE DATETIME NOT NULL,"
    & + "MODIFIED_BY VARCHAR(15),"
    & + "MODIFIED_DATE DATETIME,"
    & + "TEXT VARCHAR(700),"
    & + "REPLICATION_KEY VARCHAR(20)"
    & + ")"

    Field Loop Example 2 (Multi-Line and In-Line)

    以下模板文件代码:

    sql = "INSERT INTO <STRUCTURE_NAME> ("
    <FIELD_LOOP>
    & + "<FIELD_SQLNAME><,>"
    </FIELD_LOOP>
    & + ") VALUES(<FIELD_LOOP>:<FIELD#LOGICAL><,></FIELD_LOOP>)"

    可以产生这样的输出:

    sql = "INSERT INTO PROJECT ("
    & + "SYNERGYGRFA,"
    & + "PROJECT_ID,"
    & + "CUSTOMER_ID,"
    & + "CONTRACT_ID,"
    & + "CONTRACT_PROJECT_ID,"
    & + "DESCRIPTION,"
    & + "START_DATE,"
    & + "END_DATE,"
    & + "CURRENT_STATUS,"
    & + "STATUS_DATE,"
    & + "LEAD_CONSULTANT,"
    & + "COORDINATOR,"
    & + "APPROVED_BY_FIRST,"
    & + "APPROVED_BY_LAST,"
    & + "APPROVED_DATE,"
    & + "APPROVAL_LOCATION,"
    & + "WORK_LOCATION_ID,"
    & + "CREATED_BY,"
    & + "CREATED_DATE,"
    & + "MODIFIED_BY,"
    & + "MODIFIED_DATE,"
    & + "TEXT,"
    & + "REPLICATION_KEY"
    & + ") VALUES(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11,:12,:13,:14,:15,:16,:17,:18,:19,:20,:21,:22,:23)"

    Field Loop Example 3

    以下模板文件代码:

    #region Private fields (storage for properties)

    <FIELD_LOOP>
    private <FIELD_CSTYPE> p_<Field_Sqlname>;
    </FIELD_LOOP>

    #endregion

    可以产生这样的输出:

    #region Private fields (storage for properties)

    private string p_Synergygrfa;
    private int p_Project_Id;
    private string p_Customer_Id;
    private string p_Contract_Id;
    private int p_Contract_Project_Id;
    private string p_Description;
    private DateTime p_Start_Date;
    private DateTime p_End_Date;
    private int p_Current_Status;
    private DateTime p_Status_Date;
    private string p_Lead_Consultant;
    private string p_Coordinator;
    private int p_Approved_By_First;
    private int p_Approved_By_Last;
    private DateTime p_Approved_Date;
    private int p_Approval_Location;
    private int p_Work_Location_Id;
    private string p_Created_By;
    private DateTime p_Created_Date;
    private string p_Modified_By;
    private DateTime p_Modified_Date;
    private string p_Text;
    private string p_Replication_Key;

    #endregion

    人工智能芯片与自动驾驶
  • 相关阅读:
    [oldboy-django][2深入django]老师管理--查看,添加,编辑
    全虚拟化和半虚拟化的区别 cpu的ring0~ring3又是什么概念?
    Ansible Jinja if 生成不同的MySQL文件
    Linux内核优化(未注释)
    CentOS7入门到精通实战课程课后习题
    基于sersync海量文件实时同步
    CentOS6系统优化
    lnmp架构实现动态php
    云计算与虚拟化KVM深度实践
    Linux6系统安装
  • 原文地址:https://www.cnblogs.com/wujianming-110117/p/14136631.html
Copyright © 2020-2023  润新知