<?xml version="1.0" encoding="UTF-8"?>
<!--
This software is in the public domain under CC0 1.0 Universal plus a
Grant of Patent License. To the extent possible under law, the author(s) have dedicated all
copyright and related and neighboring rights to this software to the
public domain worldwide. This software is distributed without any
warranty. You should have received a copy of the CC0 Public Domain Dedication
along with this software (see the LICENSE.md file). If not, see
<http://creativecommons.org/publicdomain/zero/1.0/>.
-->
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/service-definition-1.6.xsd">
<!--从这里可以得知该方法名称为getProductPrice-->
<service verb="get" noun="ProductPrice" authenticate="anonymous-view">
<description>Use the ProductPrice entity to determine the price to charge or pay for a Product.</description>
<in-parameters>
<!--这是一些输入参数所对应的 required若为true则表示为必须的参数 type表示输入的字段的数据类型 default为默认值-->
<parameter name="productId" required="true"/>
<parameter name="quantity" type="BigDecimal" default="1"/> <parameter name="priceUomId" default-value="USD"/>
<parameter name="pricePurposeEnumId" default-value="PppPurchase"/> <parameter name="productStoreId"/>
<parameter name="vendorPartyId"/>
<parameter name="customerPartyId"/> <!-- TODO: to support look for records with this first and then with null: <parameter name="agreementId"/> -->
<!-- TODO: to support look for records with this first and then with null: <parameter name="agreementItemSeqId"/> -->
</in-parameters>
<out-parameters>
<!--这是输出参数 type表示输出参数的数据类型 -->
<parameter name="price" type="BigDecimal"/>
<parameter name="listPrice" type="BigDecimal"/>
<parameter name="priceUomId"/>
</out-parameters>
<actions>
<!-- get PptCurrent price -->
<!-- try most constrained, back off from there -->
<!--根据条件进行查询 其中service-call标签表示的是要调用的方法 in-map表示传入的参数 -->
<if condition="productStoreId &amp;&amp; vendorPartyId &amp;&amp; customerPartyId">
<service-call name="mantle.product.PriceServices.find#ProductPriceRecord" out-map="context"
in-map="[productId:productId, priceUomId:priceUomId, pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId, quantity:quantity,
priceTypeEnumId:'PptCurrent', productStoreId:productStoreId, vendorPartyId:vendorPartyId, customerPartyId:customerPartyId]"/>
</if>
<!-- try just vendor and customer -->
<if condition="!productPrice &amp;&amp; vendorPartyId &amp;&amp; customerPartyId">
<service-call name="mantle.product.PriceServices.find#ProductPriceRecord" out-map="context"
in-map="[productId:productId, priceUomId:priceUomId, pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId, quantity:quantity,
priceTypeEnumId:'PptCurrent', vendorPartyId:vendorPartyId, customerPartyId:customerPartyId]"/>
</if>
<!-- try just customer and store -->
<if condition="!productPrice &amp;&amp; productStoreId &amp;&amp; customerPartyId">
<service-call name="mantle.product.PriceServices.find#ProductPriceRecord" out-map="context"
in-map="[productId:productId, priceUomId:priceUomId, pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId, quantity:quantity,
priceTypeEnumId:'PptCurrent', productStoreId:productStoreId, customerPartyId:customerPartyId]"/>
</if>
<!-- try just store -->
<if condition="!productPrice &amp;&amp; productStoreId">
<service-call name="mantle.product.PriceServices.find#ProductPriceRecord" out-map="context"
in-map="[productId:productId, priceUomId:priceUomId, pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId, quantity:quantity,
priceTypeEnumId:'PptCurrent', productStoreId:productStoreId]"/>
</if>
<!-- try just vendor -->
<if condition="!productPrice &amp;&amp; vendorPartyId">
<service-call name="mantle.product.PriceServices.find#ProductPriceRecord" out-map="context"
in-map="[productId:productId, priceUomId:priceUomId, pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId, quantity:quantity,
priceTypeEnumId:'PptCurrent', vendorPartyId:vendorPartyId]"/>
</if>
<set field="price" from="productPrice?.price"/>
<!-- get PptList price -->
<set field="productPrice" from="null"/>
<!-- try most constrained, back off from there -->
<if condition="productStoreId &amp;&amp; vendorPartyId &amp;&amp; customerPartyId">
<service-call name="mantle.product.PriceServices.find#ProductPriceRecord" out-map="context"
in-map="[productId:productId, priceUomId:priceUomId, pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId, quantity:quantity,
priceTypeEnumId:'PptList', productStoreId:productStoreId, vendorPartyId:vendorPartyId, customerPartyId:customerPartyId]"/>
</if>
<!-- try just vendor and customer -->
<if condition="!productPrice &amp;&amp; vendorPartyId &amp;&amp; customerPartyId">
<service-call name="mantle.product.PriceServices.find#ProductPriceRecord" out-map="context"
in-map="[productId:productId, priceUomId:priceUomId, pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId, quantity:quantity,
priceTypeEnumId:'PptList', vendorPartyId:vendorPartyId, customerPartyId:customerPartyId]"/>
</if>
<!-- try just customer and store -->
<if condition="!productPrice &amp;&amp; productStoreId &amp;&amp; customerPartyId">
<service-call name="mantle.product.PriceServices.find#ProductPriceRecord" out-map="context"
in-map="[productId:productId, priceUomId:priceUomId, pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId, quantity:quantity,
priceTypeEnumId:'PptList', productStoreId:productStoreId, customerPartyId:customerPartyId]"/>
</if>
<!-- try just store -->
<if condition="!productPrice &amp;&amp; productStoreId">
<service-call name="mantle.product.PriceServices.find#ProductPriceRecord" out-map="context"
in-map="[productId:productId, priceUomId:priceUomId, pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId, quantity:quantity,
priceTypeEnumId:'PptList', productStoreId:productStoreId]"/>
</if>
<!-- try just vendor -->
<if condition="!productPrice &amp;&amp; vendorPartyId">
<service-call name="mantle.product.PriceServices.find#ProductPriceRecord" out-map="context"
in-map="[productId:productId, priceUomId:priceUomId, pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId, quantity:quantity,
priceTypeEnumId:'PptList', vendorPartyId:vendorPartyId]"/>
</if>
<!--设置输出参数的显示-->
<set field="listPrice" from="productPrice?.price"/>
<set field="price" from="price ?: listPrice ?: 0"/>
<!-- <log level="warn" message="========== BEFORE rules productId=${productId}, price=${price}, listPrice=${listPrice}"/> -->
<!-- run the ProductPriceKS knowledge session rules -->
<script>ec.getStatelessKieSession("ProductPriceKS").execute([])</script>
<!-- <log level="warn" message="========== AFTER rules productId=${productId}, price=${price}, listPrice=${listPrice}"/> -->
</actions>
</service>
<service verb="find" noun="ProductPriceRecord">
<description>This is an internal service called by get#ProductPrice.</description>
<in-parameters>
<parameter name="productId" required="true"/>
<parameter name="priceUomId" required="true"/>
<parameter name="pricePurposeEnumId" required="true"/>
<parameter name="priceTypeEnumId" required="true"/>
<parameter name="quantity" type="BigDecimal" required="true"/>
<parameter name="productStoreId"/>
<parameter name="vendorPartyId"/>
<parameter name="customerPartyId"/>
</in-parameters>
<out-parameters><parameter name="productPrice" type="EntityValue"/>
</out-parameters>
<actions>
<!-- <log level="warn" message="finding price record with context: ${context}"/> -->
<entity-find entity-name="mantle.product.ProductPrice" list="productPriceList" cache="true">
<econdition-object field="[productId:productId, priceUomId:priceUomId,
pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId]"/>
<econdition field-name="minQuantity" operator="less-equals" from="quantity"/>
<econdition field-name="productStoreId" ignore-if-empty="true"/>
<econdition field-name="vendorPartyId" ignore-if-empty="true"/>
<econdition field-name="customerPartyId" ignore-if-empty="true"/>
<order-by field-name="-fromDate"/>
<!-- get most recent price records first -->
<order-by field-name="-minQuantity"/>
<!-- get highest qualifying (<=quantity) minQuantity records first -->
</entity-find>
<!-- <log level="warn" message="CALC productPriceList: ${productPriceList}"/> -->
<filter-map-list list="productPriceList"><date-filter/></filter-map-list>
<set field="productPrice" from="productPriceList?.first"/>
</actions>
</service>
</services>

这是刚开始时进入的界面,从这里可以看出他所需要的输入参数和输出参数:

 <in-parameters>
<parameter name="productId" required="true"/>
<parameter name="quantity" type="BigDecimal" default="1"/> <parameter name="priceUomId" default-value="USD"/>
<parameter name="pricePurposeEnumId" default-value="PppPurchase"/> <parameter name="productStoreId"/>
<parameter name="vendorPartyId"/>
<parameter name="customerPartyId"/> <!-- TODO: to support look for records with this first and then with null: <parameter name="agreementId"/> -->
<!-- TODO: to support look for records with this first and then with null: <parameter name="agreementItemSeqId"/> -->
</in-parameters>

这是定义输入参数的代码,与页面对应。

 <out-parameters>
<parameter name="price" type="BigDecimal"/>
<parameter name="listPrice" type="BigDecimal"/>
<parameter name="priceUomId"/>
</out-parameters>

这是定义输出参数的代码,与页面对应。

从actions中的代码可以看出他是调用的另一个service的方法:即mantle.product.PriceServices,find#ProductPriceRecord方法。

 <!-- get PptCurrent price -->
<!-- try most constrained, back off from there -->
<if condition="productStoreId &amp;&amp; vendorPartyId &amp;&amp; customerPartyId">
<service-call name="mantle.product.PriceServices.find#ProductPriceRecord" out-map="context"
in-map="[productId:productId, priceUomId:priceUomId, pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId, quantity:quantity,
priceTypeEnumId:'PptCurrent', productStoreId:productStoreId, vendorPartyId:vendorPartyId, customerPartyId:customerPartyId]"/>
</if>

下面就来看这个service方法的定义:

 <service verb="find" noun="ProductPriceRecord">
<description>This is an internal service called by get#ProductPrice.</description>
<in-parameters>
<parameter name="productId" required="true"/>
<parameter name="priceUomId" required="true"/>
<parameter name="pricePurposeEnumId" required="true"/>
<parameter name="priceTypeEnumId" required="true"/>
<parameter name="quantity" type="BigDecimal" required="true"/>
<parameter name="productStoreId"/>
<parameter name="vendorPartyId"/>
<parameter name="customerPartyId"/>
</in-parameters>
<out-parameters><parameter name="productPrice" type="EntityValue"/></out-parameters>
</service>

从这里可以看出该方法的输入参数和输出参数,它执行时所需要的参数是通过上一个方法传入的,具体是:

 <if condition="productStoreId &amp;&amp; vendorPartyId &amp;&amp; customerPartyId">
<service-call name="mantle.product.PriceServices.find#ProductPriceRecord" out-map="context"
in-map="[productId:productId, priceUomId:priceUomId, pricePurposeEnumId:pricePurposeEnumId, priceTypeEnumId:priceTypeEnumId, quantity:quantity,
priceTypeEnumId:'PptCurrent', productStoreId:productStoreId, vendorPartyId:vendorPartyId, customerPartyId:customerPartyId]"/>
</if>

通过service-call标签中的in-map元素来实现的。

Moqui学习之代码分析mantle priceServices.xml的更多相关文章

  1. 20165224 陆艺杰 Exp4 恶意代码分析

    Exp4 恶意代码分析 1实验后回答问题 (1)如果在工作中怀疑一台主机上有恶意代码,但只是猜想,所有想监控下系统一天天的到底在干些什么.请设计下你想监控的操作有哪些,用什么方法来监控. 计划任务每段 ...

  2. 20155207 《网络对抗》exp4 恶意代码分析 学习总结

    20155207 <网络对抗> 恶意代码分析 学习总结 实践目标 1.是监控你自己系统的运行状态,看有没有可疑的程序在运行. 2.是分析一个恶意软件,就分析Exp2或Exp3中生成后门软件 ...

  3. Android代码分析工具lint学习

    1 lint简介 1.1 概述 lint是随Android SDK自带的一个静态代码分析工具.它用来对Android工程的源文件进行检查,找出在正确性.安全.性能.可使用性.可访问性及国际化等方面可能 ...

  4. 开源项目kcws代码分析--基于深度学习的分词技术

    http://blog.csdn.net/pirage/article/details/53424544 分词原理 本小节内容参考待字闺中的两篇博文: 97.5%准确率的深度学习中文分词(字嵌入+Bi ...

  5. ISD9160学习笔记05_ISD9160语音识别代码分析

    前言 语音识别是特别酷的功能,ISD9160的核心卖点就是这个语音识别,使用了Cybron VR 算法. 很好奇这颗10块钱以内的IC是如何实现人家百来块钱的方案.且听如下分析. 本文作者twowin ...

  6. 完整全面的Java资源库(包括构建、操作、代码分析、编译器、数据库、社区等等)

    构建 这里搜集了用来构建应用程序的工具. Apache Maven:Maven使用声明进行构建并进行依赖管理,偏向于使用约定而不是配置进行构建.Maven优于Apache Ant.后者采用了一种过程化 ...

  7. Mybatis学习错误之:重复加载mapper.xml

    学习mybatis的时候,突然遇到测试出错.测试mapper代理失败,现在钻研少了,不喜欢看未知的错误了,立即改正.错误打印说mapper.xml已经注册,仔细查看SQLMapConfig.xml发现 ...

  8. ROS_Kinetic_29 kamtoa simulation学习与示例分析(一)

    致谢源代码网址:https://github.com/Tutorgaming/kamtoa-simulation kamtoa simulation学习与示例分析(一) 源码学习与分析是学习ROS,包 ...

  9. 2018-2019-2 网络对抗技术 20165316 Exp4 恶意代码分析

    2018-2019-2 网络对抗技术 20165316 Exp4 恶意代码分析 一.原理与实践说明 1.实践目标 监控你自己系统的运行状态,看有没有可疑的程序在运行. 分析一个恶意软件,就分析Exp2 ...

随机推荐

  1. mysql sql获取上条插入id,update影响行数

    1.获取上条插入数据 LAST_INSERT_ID(); 2.获取update影响行数. ROW_COUNT(); mysql> UPDATE t -> SET address = 'be ...

  2. 【Ext.Net学习笔记】01:在ASP.NET WebForm中使用Ext.Net

    Ext.NET是基于跨浏览器的ExtJS库和.NET Framework的一套支持ASP.NET AJAX的开源Web控件,包含有丰富的Ajax运用,其前身是Coolite. 下载地址:http:// ...

  3. 合工大 OJ 1332 蛇形阵

    Description 蛇形针回字阵: 如3*3: 回字阵: 7 6 5 8 1 4 9 2 3 Input 多组数据: 每一行一个正整数n(n为奇数,<26),代表n*n矩阵. Output ...

  4. codeforces 487C C. Prefix Product Sequence(构造+数论)

    题目链接: C. Prefix Product Sequence time limit per test 1 second memory limit per test 256 megabytes in ...

  5. 搜索服务Solr集群搭建 使用ZooKeeper作为代理层

    上篇文章搭建了zookeeper集群 那好,今天就可以搭建solr搜服服务的集群了,这个和redis 集群不同,是需要zk管理的,作为一个代理层 安装四个tomcat,修改其端口号不能冲突.8080~ ...

  6. Unity-WIKI 之 DrawArrow

    组件作用 Unity画方向箭头类库,在Scene视图或在Game视图打开Gizmos查看效果 效果预览   wiki地址 http://wiki.unity3d.com/index.php/DrawA ...

  7. Vector3D - AS3

    Vector3D 类使用笛卡尔坐标 x.y 和 z 表示三维空间中的点或位置.与在二维空间中一样,x 属性表示水平轴,y 属性表示垂直轴.在三维空间中,z 属性表示深度.当对象向右移动时,x 属性的值 ...

  8. linux强制用户下线

    Linux系统为多用户多任务系统,因此允许多个用户登录到系统,有时候,我们需要强制某些用户下线. 前提:必须是root权限操作:(1)使用who查看目前有哪些用户登录了服务器,见下图 [root@vm ...

  9. android图片缩小和放大Matrix

    /**Bitmap放大的方法*/ private static Bitmap big(Bitmap bitmap) { Matrix matrix = new Matrix(); matrix.pos ...

  10. cotangent Laplacian

    几何网格处理经常用到 cotangent laplacian矩阵.前几天把这个功能整合到我的Maya 转 Matlab插件了. 这里发一个利用cotangent laplacian计算特征向量并显示的 ...