`
mf1389004071
  • 浏览: 72189 次
  • 性别: Icon_minigender_1
  • 来自: 上海
博客专栏
1ab096d2-14d4-3a83-b102-8097ee3bdc66
OFBiz进阶-OFC
浏览量:50745
社区版块
存档分类
最新评论

OFBiz进阶--OFBiz标签之[*Services.xml]-mililang介绍与分析(五)[对象<*field|map|list*>...]

阅读更多

OFBiz进阶--OFBiz标签之
                 [*Services.xml]-mililang介绍与分析(五)




     Mililang标签:   
          <*object|class*> , 调用Java类及方法标签(Java Call Operations)           <*field|map|list*>, 变量处理(Method Environment Operations)           <calculate|calendar>, 服务特定操作(Service Specific Operations)

     标签规则: [simple-methods.xsd] 新版本还有 [simple-methods-v2.xsd]

      <create-object class-name="org.ofbiz.order.shoppingcart.ShoppingCart" field="shoppingCart">
          <field field="delegator" type="org.ofbiz.entity.Delegator"/>
          <field field="productStoreId" type="String"/>
          <field field="locale" type="java.util.Locale"/>
          <field field="currencyUom" type="String"/>
      </create-object>
      <!-- create-object按照指定的类名创建对象, 即调用类构造方法; class-name类全路径; field创建好的对象赋值给此变量; -->
        <!-- 内部子标签必须按照构建对象的入参顺序配置, 若有静态值, 可以使用 <string> 标签 -->
    
    <call-object-method obj-field="shoppingCart" method-name="addContactMech" ret-field="">
        <string value="PHONE_SHIPPING"/>
        <field field="shipToPhoneContactMechId"/>
    </call-object-method>
    <!-- 调用当前Object变量拥有的方法: method-name变量对象的方法名; obj-field变量对象名; ret-field变量对象方法执行返回的结果,没有则忽略; -->
    
    <call-class-method class-name="org.ofbiz.base.util.UtilValidate" method-name="isDateAfterToday" ret-field="booleanIsDateAfterToday">
      <!-- 调用java方法: class-name类全路径(包名+类名); method-name方法名称; ret-field-name返回的结果变量名称(如果不指定,则忽略返回); -->
      
      <field field="createdDate" type="String" />
        <!-- 传入参数-对象名: field-name变量名称; type变量类型; -->
        
      <string value=""></string>
        <!-- 传入参数-静态: value值 -->
    </call-class-method>
    <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getDescendantGlAccountClassIds" ret-field="assetAccountClassIds">
        <field field="assetGlAccountClass" type="GenericValue"/>
    </call-class-method>








    <map-to-map map="" to-map=""/><!-- 复制一个 map 到另外一个 map中 -->
    <map-to-map to-map="emailParams.bodyParameters" map="bodyParameters"/>
    
    <field-to-list list="" field=""/><!-- 将变量放入list集合: list变量集合; field要放入list集合的变量 -->
    <field-to-list field="payment" list="payments"/>
    
    <list-to-list to-list="" list=""/><!-- 复制一个list 到另外一个list中 -->
    <list-to-list list="secondaryInventoryItemList" to-list="inventoryItemList"/>
    
    <order-map-list list="">
      <order-by field-name=""/>
      <order-by field-name=""/>
    </order-map-list>
      <!-- 对一个List<Map>列表按指定的Map.Key排序: order-by.field-name用于排序的字段名 -->
    <order-map-list list="productsList">
        <order-by field-name="sequenceNum"/>
    </order-map-list>
    
    <set field="" from-field="" default-value="" value="" set-if-empty="true" set-if-null="false" type="PlainString"/>
      <!-- 设置变量: field变量; from-field来源变量名; default-value默认值; value手动设值; set-if-empty空也设值; 
        set-if-null若数据来源变量空则不设值; type变量类型(可以是自定义的对象); -->
    <set field="costsByType.${wecc.costComponentTypeId}" from-field="totalCostComponentCost"/>
    <!-- 动态 Map.key 设定 -->
    
    <!-- 构建排序 List 的示例 -->
    <set field="orderByList[]" value="+supplierPrefOrderId"/>
    <set field="orderByList[]" value="+lastPrice"/>
    
    <string-append string="" field="" prefix="" arg-list="" suffix=""/>
      <!-- 字符串拼接: string将要被拼接的字符串; field字符串变量; prefix拼接前缀; arg-list自变量集合; suffix拼接后缀; -->
        <!-- 类同: newString = “${newString}”+”${prefix}”+”${string}”+”${suffix}”  -->
      <string-append field="sendEmailMap.sendFrom" string="${curUserPartyAndContactMech.infoString}" prefix=","/>
    
    <string-to-list string="" list="" arg-list="" message-field=""/>
      <!-- 将字符串转为list集合: string将要被拼接的字符串; list集合; arg-list自变量集合; message-field消息变量; -->
      <string-to-list list="targetOperationList" string="CONTENT_UPDATE"/>
    
    <to-string field="" format="" numeric-padding=""/>
      <!-- 将变量格式化为字符串: field变量名; format格式化规则; numeric-padding数据填充; -->
      <to-string field="nowTimestamp"/>
      <to-string field="context.contactMechId"/>
    
    <clear-field field=""/> <!-- 将指定的变量的值清空, 一般设为 null -->
    <clear-field field="updatePaymentMap.finAccountTransId"/>
    <clear-field field="updatePaymentCtx"/>
    
    <first-from-list entry="" list=""/><!-- 从list集合中获取第一个对象: entry获取的第一个对象放入此变量; list源list集合 -->
    <first-from-list entry="oldFinAccountStatus" list="oldFinAccountStatusList"/>
    
    <iterate entry="" list=""></iterate>
      <!-- 执行迭代操作: entry迭代器内部的临时变量对象; list被迭代的集合; -->
    <iterate list="uomConversions" entry="uomConversion">
        <set from-field="nowTimestamp" field="uomConversion.thruDate"/>
    </iterate>
    
    <iterate-map key="" value="" map=""></iterate-map>
      <!-- 迭代map对象: key对象中被迭代的对象的key; value迭代时空值将被此值替换; 被迭代的map对象; -->
    <iterate-map map="pResults" key="key" value="val">
        <field-to-result field="val" result-name="${key}"/>
    </iterate-map>
    
    <loop count="" field=""><!-- 内部实现简单循环 --></loop>
      <!-- 在方法中使用简单循环: count循环的次数; field循环计数器的值存在此变量中; -->
      <loop count="${rowCount}" field="currentRow">
        <set field="suffix" value="${groovy:org.ofbiz.base.util.UtilHttp.MULTI_ROW_DELIMITER + currentRow}"/>
        <set field="isSelected" value="${groovy:parameterMap.containsKey(&quot;_rowSubmit&quot; + suffix) &amp;&amp; &quot;Y&quot;.equalsIgnoreCase(parameterMap.get(&quot;_rowSubmit&quot; + suffix))}" type="Boolean"/>
      </loop>
    




    <calculate field="" decimal-format="" decimal-scale="2" type="BigDecimal" rounding-mode="HalfEven">
      <!-- calculate数字类型数据的计算; field变量名; decimal-format小数格式化表达式; decimal-scale小数点位数(数值精度); 
        type变量类型(String/Double/Float/Long/Integer/BigDecimal); 
        
        rounding-mode变量舍入规则(Ceiling上升限度/Floor就近原则/Up向上/Down向下/HalfUp半数向上/HalfDown半数向下/HalfEven半数偶数/Unnecessary摈除多余);
        
          Ceiling -四舍五入模式圆往积极的无限。如果BigDecimal是积极的,表现为ROUND_UP;如果消极,对ROUND_DOWN行为。注意,这永远不会减小舍入模式计算值。
            Rounding mode to round towards positive infinity. If the BigDecimal is positive, behaves as for ROUND_UP; if negative, behaves as for ROUND_DOWN. Note that this rounding mode never decreases the calculated value.
          Floor -四舍五入模式轮对负无穷大。如果BigDecimal是积极的,表现为ROUND_DOWN;如果负面,表现为ROUND_UP一样。注意,这个四舍五入模式不增加计算值。
            Rounding mode to round towards negative infinity. If the BigDecimal is positive, behave as for ROUND_DOWN; if negative, behave as for ROUND_UP. Note that this rounding mode never increases the calculated value.
          Up -四舍五入模式圆远离零。总是递增数字零之前丢弃的分数。注意,这个四舍五入模式永远不会减小计算值的大小。
            Rounding mode to round away from zero. Always increments the digit prior to a nonzero discarded fraction. Note that this rounding mode never decreases the magnitude of the calculated value.
          Down -四舍五入模式圆趋于零。从不递增数字之前丢弃的一部分(即,将)。注意,这个四舍五入模式不增加计算值的大小。
            Rounding mode to round towards zero. Never increments the digit prior to a discarded fraction (i.e., truncates). Note that this rounding mode never increases the magnitude of the calculated value.
          HalfUp -四舍五入模式轮转向“最近邻”,除非这两个邻国都等距,在这种情况下围捕。为ROUND_UP行为,如果分数≥0.5丢弃的;否则,为ROUND_DOWN行为。注意,这是四舍五入模式,我们大多数人都教小学。
            Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up. Behaves as for ROUND_UP if the discarded fraction is ≥ 0.5; otherwise, behaves as for ROUND_DOWN. Note that this is the rounding mode that most of us were taught in grade school.
          HalfDown -四舍五入模式轮转向“最近邻”,除非这两个邻国都等距,在这种情况下一轮下来。至于ROUND_UP行为如果丢弃的分数> 0.5;否则,为ROUND_DOWN行为。
            Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down. Behaves as for ROUND_UP if the discarded fraction is > 0.5; otherwise, behaves as for ROUND_DOWN.
          HalfEven -四舍五入模式轮对“最近邻”,除非这两个邻国都等距,在这种情况下,圆向甚至邻居。为ROUND_HALF_UP行为,如果数字到左边的废弃分数是奇怪;行为对于ROUND_HALF_DOWN如果它甚至。注意,这是四舍五入模式,减少累积误差的反复应用一系列的计算。
            Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor. Behaves as for ROUND_HALF_UP if the digit to the left of the discarded fraction is odd; behaves as for ROUND_HALF_DOWN if it's even. Note that this is the rounding mode that minimizes cumulative error when applied repeatedly over a sequence of calculations.
          Unnecessary -四舍五入模式的断言请求的操作有一个准确的结果,因此不舍入是必要的。如果这个四舍五入模式被指定一个操作,产生一个不精确的结果,一个ArithmeticException被抛出。
            Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary. If this rounding mode is specified on an operation that yields an inexact result, an ArithmeticException is thrown.
           -->
    
      <calcop operator="get" field=""></calcop>
        <!-- calcop数据连接标签: operator操作方式(get加/add加/subtract减/multiply乘/divide除/negative取反,负数) field变量 -->
      
      <number value="0"></number><!-- 指定变量的值, 必须是数字, 否则报错 -->
    </calculate>
    <iterate entry="costComponent" list="costComponents">
        <calculate field="productCost" decimal-scale="6">
            <calcop field="costComponent.cost" operator="add">
                <calcop field="productCost" operator="get"/>
            </calcop>
        </calculate>
        <!--set field="productCost" value="${costComponent.cost + productCost}" type="BigDecimal"/-->
    </iterate>
    <calculate field="newEntity.replenishLevel" decimal-scale="${roundingDecimals}" rounding-mode="${roundingMode}">
        <calcop operator="get" field="newEntity.replenishLevel"/>
    </calculate>
    
    <log level="info" message="Called the Event: deleteNoteMainFromSimple" />
      <!-- 打印日志: level打印级别; message消息内容; -->
        <!-- 日志的打印级别有: verbose、info、important、warning、error -->
    
    <property-to-field resource="" property="" field="" arg-list-name="" default="" no-locale="false"/>
      <!-- 从一个资源属性文件中获取指定属性到变量中: resource资源文件名(NoteUiLabel); property国际化标签的key; field资源放入此变量; 
        arg-list-name自变量的list集合名; default默认值; no-locale不使用语言环境; -->
    <property-to-field resource="general" property="currency.uom.id.default" field="defaultCurrency"/>
    <property-to-field property="AccountingNotWithdrawalFinAccountTrans" resource="AccountingUiLabels" field="errorMessage"/>
    <property-to-field resource="AccountingUiLabels" property="AccountingExpEndOfLifeIsEmpty" field="successMessageList[]"/>
    <property-to-field resource="AccountingConfig" property="create.invoice.per.shipment" field="invoicePerShipment"/>
    
    <set-calendar field="" from-field="" default-value="" value="" locale="" period-align-end="year" period-align-start="year"
      set-if-empty="true" set-if-null="false" time-zone="" years="" months="" days="" hours="" minutes="" seconds="" millis="" />
      <!-- 创建一个日历对象: field变量; from-field来源变量; default-value默认值; value手动值; locale环境变量; period-align-end日历结束; 
        period-align-start日历开始(year/month/week/day); set-if-empty是否空设值; set-if-null是否空设值; 
        .设置具体默认值: time-zone时区; years年; months月; days天; hours时; minutes分; seconds秒; millis毫秒; -->
        <set-calendar field="startDate" from-field="nowTimestamp" days="1"/>
        <set-calendar field="productAverageCostMap.fromDate" from-field="nowTimestamp" seconds="+1"/>
        <set-calendar field="compareDate" from-field="nowTimestamp" years="-${intervalQuantity}"/>
    
    <set-current-user-login value-field=""/><!-- 设置登录用户的对象 -->
    <set-current-user-login value-field="userLogin"/>
    
    <field-to-result field="" result-name=""/><!-- 将变量放入结果结果中: field变量名; result-name结果结果的key名; -->
      <!-- 如: <field-to-result result-name="transactionId" field="newEntity.transactionId"/> -->
      <field-to-result field="newEntity.agreementItemSeqId" result-name="agreementItemSeqId"/>
    

 



==================================关于本文===================================
 
        作者: mf1389004071
        ......上海_香飘飘
        博客: http://ofbizer.iteye.com/
        邮箱: mf1389004071@163.com
        有此标记, 均为原创, 禁止盗用, 转载请注明来源
        技术无上限, 能力有上限, 欢迎参与交流讨论和提出建议
        本文永久地址: http://ofbizer.iteye.com/blog/2047082

 
 
   

0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics