blob: c4290b3ae5a199a6d09bc7b3eaaefa1fbaecaffb [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods-v2.xsd">
<simple-method method-name="applyFeatureToProductFromTypeAndCode" short-description="Apply Feature to Product using Feature Type and ID Code">
<set field="callingMethodName" value="applyFeatureToProductFromTypeAndCode"/>
<set field="checkAction" value="CREATE"/>
<call-simple-method method-name="checkProductRelatedPermission" xml-resource="component://product/script/org/ofbiz/product/product/ProductServices.xml"/>
<check-errors/>
<!-- find the ProductFeatures by type and id code -->
<entity-and entity-name="ProductFeature" list="productFeatures">
<field-map field-name="productFeatureTypeId" from-field="parameters.productFeatureTypeId"/>
<field-map field-name="idCode" from-field="parameters.idCode"/>
</entity-and>
<iterate entry="productFeature" list="productFeatures">
<set-service-fields service-name="applyFeatureToProduct" map="parameters" to-map="applyFeatureContext"/>
<set field="applyFeatureContext.productFeatureId" from-field="productFeature.productFeatureId"/>
<if-empty field="applyFeatureContext.sequenceNum">
<set field="applyFeatureContext.sequenceNum" from-field="productFeature.defaultSequenceNum"/>
</if-empty>
<call-service service-name="applyFeatureToProduct" in-map-name="applyFeatureContext"/>
</iterate>
</simple-method>
<!-- Methods for ProductFeatureType -->
<simple-method method-name="createProductFeatureType" short-description="Create a Product Feature Type">
<check-permission permission="CATALOG" action="_CREATE">
<fail-property resource="ProductUiLabels" property="ProductCatalogCreatePermissionError"/>
</check-permission>
<check-errors/>
<if>
<condition>
<if-empty field="parameters.productFeatureTypeId" />
</condition>
<then>
<sequenced-id sequence-name="ProductFeatureType" field="parameters.productFeatureTypeId"/>
</then>
</if>
<check-errors/>
<if>
<condition>
<not>
<if-regexp field="parameters.productFeatureTypeId" expr="^[a-zA-Z_0-9]+$"></if-regexp>
</not>
</condition>
<then>
<add-error>
<fail-property resource="ProductErrorUiLabels" property="ProductFeatureTypeIdMustContainsLettersAndDigits"/>
</add-error>
</then>
</if>
<check-errors/>
<make-value value-field="newEntity" entity-name="ProductFeatureType"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
<field-to-result field="newEntity.productFeatureTypeId" result-name="productFeatureTypeId"/>
</simple-method>
<!-- create a new ProductFeatureApplAttr -->
<simple-method method-name="createProductFeatureApplAttr" short-description="Create a ProductFeatureApplAttr">
<check-permission permission="CATALOG" action="_CREATE">
<fail-property resource="ProductUiLabels" property="ProductCatalogCreatePermissionError"/>
</check-permission>
<check-errors/>
<make-value value-field="newEntity" entity-name="ProductFeatureApplAttr"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<if-empty field="newEntity.fromDate">
<entity-condition entity-name="ProductFeatureAppl" list="productFeatureAppls" filter-by-date="true">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="newEntity.productId"/>
<condition-expr field-name="productFeatureId" from-field="newEntity.productFeatureId"/>
</condition-list>
<order-by field-name="-fromDate"/>
</entity-condition>
<first-from-list list="productFeatureAppls" entry="productFeatureAppl"/>
<set field="newEntity.fromDate" from-field="productFeatureAppl.fromDate"/>
</if-empty>
<create-value value-field="newEntity"/>
<check-errors/>
</simple-method>
</simple-methods>