blob: 935be9b275e5b7ad31663d12d061454c86017804 [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.xsd">
<simple-method method-name="movePortletToPortalPage" short-description="Moves a PortalPortlet from the actual portalPage to a different one">
<call-simple-method method-name="checkOwnerShip"/>
<entity-one entity-name="PortalPagePortlet" value-field="oldEntity"/>
<set field="parameters.portalPageId" from-field="parameters.newPortalPageId"/>
<call-simple-method method-name="copyIfRequiredSystemPage" xml-resource="component://common/script/org/ofbiz/common/PortalPageMethods.xml"/>
<set field="parameters.newPortalPageId" from-field="portalPageId"/>
<make-value value-field="newEntity" entity-name="PortalPagePortlet"/>
<set field="newEntity.portalPortletId" from-field="parameters.portalPortletId"/>
<set field="newEntity.portalPageId" from-field="parameters.newPortalPageId"/>
<set field="newEntity.columnNum" value="1"/>
<make-next-seq-id value-field="newEntity" seq-field-name="portletSeqId"/>
<create-value value-field="newEntity"/>
<remove-value value-field="oldEntity"/>
</simple-method>
<simple-method method-name="addPortalPageColumn" short-description="Add a new Column to a PortalPage">
<call-simple-method method-name="checkOwnerShip"/>
<make-value entity-name="PortalPageColumn" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<if-empty field="parameters.columnSeqId">
<make-next-seq-id value-field="newEntity" seq-field-name="columnSeqId"/>
</if-empty>
<field-to-result field="newEntity.columnSeqId" result-name="columnSeqId"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="deletePortalPageColumn" short-description="Delete a Column from a PortalPage">
<call-simple-method method-name="checkOwnerShip"/>
<entity-one entity-name="PortalPageColumn" value-field="column" auto-field-map="true" use-cache="true"/>
<if-not-empty field="column">
<entity-and entity-name="PortalPagePortlet" list="portalPortletList">
<field-map field-name="portalPageId" from-field="column.portalPageId"/>
<field-map field-name="columnSeqId" from-field="column.columnSeqId"/>
</entity-and>
<iterate list="portalPortletList" entry="portalPortlet">
<set-service-fields service-name="deletePortalPagePortlet" to-map="deletePortalPagePortletInMap" map="portalPortlet"/>
<call-service service-name="deletePortalPagePortlet" in-map-name="deletePortalPagePortletInMap"/>
</iterate>
<remove-value value-field="column"/>
</if-not-empty>
<check-errors/>
</simple-method>
<simple-method method-name="createPortalPagePortlet" short-description="Add a registered PortalPortlet to a PortalPage">
<call-simple-method method-name="checkOwnerShip"/>
<make-value entity-name="PortalPagePortlet" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<make-next-seq-id value-field="newEntity" seq-field-name="portletSeqId"/>
<field-to-result field="newEntity.portletSeqId" result-name="portletSeqId"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
<create-value value-field="newEntity"/>
</simple-method>
<simple-method method-name="deletePortalPagePortlet" short-description="Delete a PortalPortlet from a PortalPageColumn">
<call-simple-method method-name="checkOwnerShip"/>
<entity-one entity-name="PortalPagePortlet" value-field="portlet" auto-field-map="true" use-cache="true"/>
<if-not-empty field="portlet">
<make-value value-field="newEntity" entity-name="PortletAttribute"/>
<set field="newEntity.portalPageId" from-field="portlet.portalPageId"/>
<set field="newEntity.portalPortletId" from-field="portlet.portalPortletId"/>
<set field="newEntity.portletSeqId" from-field="portlet.portletSeqId"/>
<remove-by-and entity-name="PortletAttribute" map="newEntity"/>
<remove-value value-field="portlet"/>
</if-not-empty>
</simple-method>
<simple-method method-name="getPortletAttributes" short-description="Get all attributes of a Portlet either by providing userLogin or portalPageid with portalPortletId" login-required="true">
<if-empty field="parameters.ownerUserLoginId">
<if-empty field="parameters.portalPageId">
<log level="error" message="Service getPortletAttributes did not receive either ownerUserLoginId OR portalPageId"></log>
<string-to-list string="Service getPortletAttributes did not receive either ownerUserLoginId OR portalPageId" list="error_list"/>
</if-empty>
</if-empty>
<check-errors/>
<!-- if userLogin provided get the portalPageId with the required portlet -->
<if-not-empty field="parameters.ownerUserLoginId">
<entity-and entity-name="PortalPageAndPortlet" list="ppList">
<field-map field-name="ownerUserLoginId" from-field="parameters.ownerUserLoginId"/>
<field-map field-name="portalPortletId" from-field="parameters.portalPortletId"/>
</entity-and>
<first-from-list entry="portalPage" list="ppList"/>
<set field="parameters.portalPageId" from-field="portalPage.portalPageId"/>
</if-not-empty>
<entity-condition entity-name="PortletAttribute" list="attributeList">
<condition-list combine="and">
<condition-expr field-name="portalPageId" operator="equals" from-field="parameters.portalPageId"/>
<condition-expr field-name="portalPortletId" operator="equals" from-field="parameters.portalPortletId"/>
<condition-expr field-name="portletSeqId" operator="equals" from-field="parameters.portletSeqId" ignore-if-empty="true"/>
</condition-list>
</entity-condition>
<if-not-empty field="attributeList">
<iterate list="attributeList" entry="attributeRecord">
<set field="attributeMap.${attributeRecord.attrName}" from-field="attributeRecord.attrValue"/>
</iterate>
<field-to-result field="attributeMap" result-name="attributeMap"/>
</if-not-empty>
</simple-method>
<simple-method method-name="createPortalPage" short-description="Create a new Portal Page">
<if-not-empty field="parameters.portalPageName">
<make-value entity-name="PortalPage" value-field="newPortalPage"/>
<set-pk-fields map="parameters" value-field="newPortalPage"/>
<if-empty field="newPortalPage.portalPageId">
<sequenced-id sequence-name="PortalPage" field="newPortalPage.portalPageId"/>
</if-empty>
<set-nonpk-fields map="parameters" value-field="newPortalPage"/>
<set field="newPortalPage.ownerUserLoginId" from-field="parameters.userLogin.userLoginId"/>
<if-empty field="parameters.sequenceNum">
<make-next-seq-id value-field="newPortalPage" seq-field-name="sequenceNum"/>
</if-empty>
<create-value value-field="newPortalPage"/>
<set field="newPortalPageColumn.portalPageId" from-field="newPortalPage.portalPageId"/>
<call-service service-name="addPortalPageColumn" in-map-name="newPortalPageColumn"/>
<field-to-result field="newPortalPage.portalPageId" result-name="portalPageId"/>
</if-not-empty>
</simple-method>
<simple-method method-name="deletePortalPage" short-description="Delete a Portal Page">
<entity-one entity-name="PortalPage" value-field="getPortalPage"/>
<if-not-empty field="getPortalPage.originalPortalPageId">
<entity-one entity-name="PortalPage" value-field="getOldSequenceNum">
<field-map field-name="portalPageId" from-field="getPortalPage.originalPortalPageId"/>
</entity-one>
<entity-condition entity-name="PortalPage" list="checkSequenceNums">
<condition-list combine="and">
<condition-expr field-name="sequenceNum" operator="equals" from-field="getOldSequenceNum.sequenceNum"/>
<condition-expr field-name="ownerUserLoginId" operator="equals" from-field="userLogin.userLoginId"/>
<condition-expr field-name="parentPortalPageId" operator="equals" from-field="parameters.parentPortalPageId"/>
</condition-list>
</entity-condition>
<first-from-list entry="checkSequenceNum" list="checkSequenceNums"/>
<if-not-empty field="checkSequenceNum.portalPageId">
<set field="first.portalPageId" from-field="checkSequenceNum.portalPageId"/>
<set field="first.sequenceNum" from-field="getPortalPage.sequenceNum" type="Long"/>
<call-service service-name="updatePortalPage" in-map-name="first"/>
</if-not-empty>
</if-not-empty>
<call-simple-method method-name="checkOwnerShip"/>
<remove-related value-field="portalPage" relation-name="PortalPageColumn"/>
<remove-related value-field="portalPage" relation-name="PortalPagePortlet"/>
<remove-value value-field="portalPage"/>
</simple-method>
<simple-method method-name="checkOwnerShip" short-description="Check the ownership of a Portal Page">
<if-not-empty field="parameters.portalPageId">
<entity-one entity-name="PortalPage" value-field="portalPage"/>
<if-empty field="portalPage">
<add-error>
<fail-property resource="CommonUiLabels" property="PortalPageNotFound"/>
</add-error>
</if-empty>
<check-errors/>
<if-compare field="portalPage.ownerUserLoginId" operator="not-equals" value="${parameters.userLogin.userLoginId}">
<add-error>
<fail-property resource="CommonUiLabels" property="PortalPageNotOwned"/>
</add-error>
</if-compare>
<check-errors/>
</if-not-empty>
</simple-method>
<simple-method method-name="updatePortalPagePortletSeq" short-description="Update the portal page sequence numbers">
<call-simple-method method-name="checkOwnerShip"/>
<entity-one entity-name="PortalPagePortlet" value-field="portalPagePortlet"/>
<if-compare field="parameters.mode" value="UP" operator="equals">
<set field="portalPagePortlet.sequenceNum" value="${portalPagePortlet.sequenceNum - 1}" type="Long"/>
</if-compare>
<if-compare field="parameters.mode" value="DOWN" operator="equals">
<set field="portalPagePortlet.sequenceNum" value="${portalPagePortlet.sequenceNum + 1}" type="Long"/>
</if-compare>
<if-compare field="parameters.mode" value="TOP" operator="equals">
<set field="portalPagePortlet.sequenceNum" value="0" type="Long"/>
</if-compare>
<if-compare field="parameters.mode" value="BOTTOM" operator="equals">
<entity-and entity-name="PortalPagePortlet" list="ppList">
<field-map field-name="portalPageId" from-field="parameters.portalPageId"/>
<order-by field-name="-sequenceNum"/>
</entity-and>
<first-from-list entry="ppEntry" list="ppList"/>
<set field="portalPagePortlet.sequenceNum" value="${ppEntry.sequenceNum + 1}" type="Long"/>
</if-compare>
<!-- update folowing entries in the same column if any -->
<if-compare field="parameters.mode" value="BOTTOM" operator="not-equals">
<if-compare field="parameters.mode" value="DOWN" operator="equals">
<entity-condition entity-name="PortalPagePortlet" list="ppList">
<condition-list combine="and">
<condition-expr field-name="portalPageId" operator="equals" from-field="parameters.portalPageId"/>
<condition-expr field-name="columnSeqId" operator="equals" from-field="portalPagePortlet.columnSeqId"/>
<condition-expr field-name="sequenceNum" operator="greater-equals" from-field="portalPagePortlet.sequenceNum"/>
</condition-list>
<order-by field-name="+sequenceNum"/>
</entity-condition>
<if-not-empty field="ppList">
<first-from-list entry="ppEntry" list="ppList"/>
<set field="ppEntry.sequenceNum" value="${portalPagePortlet.sequenceNum - 1}" type="Long"/>
<store-value value-field="ppEntry"/>
</if-not-empty>
<else><!-- this for up and top -->
<entity-condition entity-name="PortalPagePortlet" list="ppList">
<condition-list combine="and">
<condition-expr field-name="portalPageId" operator="equals" from-field="parameters.portalPageId"/>
<condition-expr field-name="columnSeqId" operator="equals" from-field="portalPagePortlet.columnSeqId"/>
<condition-expr field-name="sequenceNum" operator="less-equals" from-field="portalPagePortlet.sequenceNum"/>
</condition-list>
<order-by field-name="-sequenceNum"/>
</entity-condition>
<if-not-empty field="ppList">
<first-from-list entry="ppEntry" list="ppList"/>
<set field="ppEntry.sequenceNum" value="${portalPagePortlet.sequenceNum + 1}" type="Long"/>
<store-value value-field="ppEntry"/>
</if-not-empty>
</else>
</if-compare>
</if-compare>
<store-value value-field="portalPagePortlet"/>
</simple-method>
<simple-method method-name="updatePortalPageSeq" short-description="Update the portal page sequence numbers">
<call-simple-method method-name="checkOwnerShip"/>
<entity-one entity-name="PortalPage" value-field="getSequenceNum"/>
<if-compare field="parameters.mode" value="UP" operator="equals">
<entity-condition entity-name="PortalPage" list="getDatas">
<condition-list combine="and">
<condition-expr field-name="sequenceNum" operator="less" from-field="getSequenceNum.sequenceNum"/>
<condition-expr field-name="ownerUserLoginId" operator="equals" from-field="userLogin.userLoginId"/>
<condition-list combine="or">
<condition-expr field-name="parentPortalPageId" operator="equals" from-field="parameters.parentPortalPageId"/>
<condition-expr field-name="originalPortalPageId" operator="equals" from-field="parameters.parentPortalPageId"/>
</condition-list>
</condition-list>
<order-by field-name="-sequenceNum"/>
</entity-condition>
</if-compare>
<if-compare field="parameters.mode" value="DWN" operator="equals">
<entity-condition entity-name="PortalPage" list="getDatas">
<condition-list combine="and">
<condition-expr field-name="sequenceNum" operator="greater" from-field="getSequenceNum.sequenceNum"/>
<condition-expr field-name="ownerUserLoginId" operator="equals" from-field="userLogin.userLoginId"/>
<condition-list combine="or">
<condition-expr field-name="parentPortalPageId" operator="equals" from-field="parameters.parentPortalPageId"/>
<condition-expr field-name="originalPortalPageId" operator="equals" from-field="parameters.parentPortalPageId"/>
</condition-list>
</condition-list>
<order-by field-name="sequenceNum"/>
</entity-condition>
</if-compare>
<if-compare field="parameters.mode" value="TOP" operator="equals">
<entity-condition entity-name="PortalPage" list="getDatas">
<condition-list combine="and">
<condition-expr field-name="sequenceNum" operator="less" from-field="getSequenceNum.sequenceNum"/>
<condition-expr field-name="ownerUserLoginId" operator="equals" from-field="userLogin.userLoginId"/>
<condition-list combine="or">
<condition-expr field-name="parentPortalPageId" operator="equals" from-field="parameters.parentPortalPageId"/>
<condition-expr field-name="originalPortalPageId" operator="equals" from-field="parameters.parentPortalPageId"/>
</condition-list>
</condition-list>
<order-by field-name="sequenceNum"/>
</entity-condition>
</if-compare>
<if-compare field="parameters.mode" value="BOT" operator="equals">
<entity-condition entity-name="PortalPage" list="getDatas">
<condition-list combine="and">
<condition-expr field-name="sequenceNum" operator="greater" from-field="getSequenceNum.sequenceNum"/>
<condition-expr field-name="ownerUserLoginId" operator="equals" from-field="userLogin.userLoginId"/>
<condition-list combine="or">
<condition-expr field-name="parentPortalPageId" operator="equals" from-field="parameters.parentPortalPageId"/>
<condition-expr field-name="originalPortalPageId" operator="equals" from-field="parameters.parentPortalPageId"/>
</condition-list>
</condition-list>
<order-by field-name="-sequenceNum"/>
</entity-condition>
</if-compare>
<first-from-list entry="getData" list="getDatas"/>
<set field="portalPage.sequenceNum" from-field="getData.sequenceNum" type="Long"/>
<store-value value-field="portalPage"/>
<set field="first.portalPageId" from-field="getData.portalPageId"/>
<set field="first.sequenceNum" from-field="getSequenceNum.sequenceNum" type="Long"/>
<call-service service-name="updatePortalPage" in-map-name="first"/>
</simple-method>
</simple-methods>