blob: aecdb937063964145e8c20faac9bcf7551b7653a [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"
xmlns="http://ofbiz.apache.org/Simple-Method" xsi:schemaLocation="http://ofbiz.apache.org/Simple-Method http://ofbiz.apache.org/dtds/simple-methods.xsd">
<simple-method method-name="setPortalPortletAttributes" short-description="Sets a PortalPortlet attributes">
<if-not-empty field="parameters">
<iterate-map map="parameters" key="attributeKey" value="attributeValue">
<if>
<condition>
<and>
<if-compare field="attributeKey" operator="not-equals" value="portalPageId"/>
<if-compare field="attributeKey" operator="not-equals" value="portalPortletId"/>
<if-compare field="attributeKey" operator="not-equals" value="portletSeqId"/>
</and>
</condition>
<then>
<log level="always" message="===2==processing: ${attributeKey}"></log>
<clear-field field="attributeEntityMap"/>
<set-service-fields service-name="createPortletAttribute" map="parameters" to-map="attributeEntityMap"/>
<set field="attributeEntityMap.attrName" from-field="attributeKey"/>
<set field="attributeEntityMap.attrValue" from-field="attributeValue"/>
<entity-one entity-name="PortletAttribute" value-field="attributeItem">
<field-map field-name="attrName" from-field="attributeEntityMap.attrName"/>
</entity-one>
<if-not-empty field="attributeItem">
<remove-value value-field="attributeItem"/>
</if-not-empty>
<call-service service-name="createPortletAttribute" in-map-name="attributeEntityMap"/>
<!-- remove all attributes which were not provided -->
<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-null="true"/>
</condition-list>
</entity-condition>
<!-- remove all not supplied attributes -->
<iterate list="attributeList" entry="attribute">
<if-empty field="parameters.${attribute.attrName}">
<remove-value value-field="attribute"/>
</if-empty>
</iterate>
</then>
</if>
</iterate-map>
</if-not-empty>
</simple-method>
<!--Create simple-method of copyOriginalPage-->
<simple-method method-name="copyIfRequiredSystemPage" short-description="Check if the page is a system page, then copy before allowing the user to edit it">
<entity-one entity-name="PortalPage" value-field="portalPage"/>
<if-compare field="portalPage.ownerUserLoginId" value="_NA_" operator="equals">
<!-- check if private page already created -->
<entity-and entity-name="PortalPage" list="getPrivatePages">
<field-map field-name="originalPortalPageId" from-field="parameters.portalPageId"/>
<field-map field-name="ownerUserLoginId" from-field="userLogin.userLoginId"/>
</entity-and>
<if-empty field="getPrivatePages">
<!-- copy the portal page -->
<set-service-fields service-name="createPortalPage" map="portalPage" to-map="createPage"/>
<clear-field field="createPage.portalPageId"/>
<set field="createPage.ownerUserLoginId" from-field="userLogin.userLoginId"/>
<set field="createPage.originalPortalPageId" from-field="parameters.portalPageId"/>
<call-service service-name="createPortalPage" in-map-name="createPage">
<result-to-field result-name="portalPageId"/>
</call-service>
<field-to-request field="portalPageId" request-name="portalPageId"/>
<call-simple-method method-name="duplicatePortalPageDetails"/>
</if-empty>
</if-compare>
</simple-method>
<!--Duplicate content of portalPage, portalPageColumn, portalPagePortlet, portletAttribute,
this method should be call with portalpageId and portalPage in context-->
<simple-method method-name="duplicatePortalPageDetails" short-description="Duplicate content of portalPage, portalPageColumn, portalPagePortlet, portletAttribute">
<log level="info" message="duplicate portalPage detail from portalPageId ${parameters.portalPageId} to new portalPageId=${portalPageId}"/>
<if-not-empty field="portalPageId">
<!-- delete the columns -->
<set field="delMap.portalPageId" from-field="portalPageId" />
<!-- <remove-by-and entity-name="PortalPageColumn" map="delMap"/>-->
<!-- copy columns -->
<entity-and entity-name="PortalPageColumn" use-cache="true" list="portalPageColumns">
<field-map field-name="portalPageId" from-field="parameters.portalPageId" />
</entity-and>
<set field="first" value="true" type="Boolean" />
<iterate list="portalPageColumns" entry="portalPageColumn">
<set-service-fields service-name="addPortalPageColumn" map="portalPageColumn" to-map="addColumnMap" />
<clear-field field="addColumnMap.columnSeqId" />
<set field="addColumnMap.portalPageId" from-field="portalPageId" />
<call-service service-name="addPortalPageColumn" in-map-name="addColumnMap" />
</iterate>
<!-- copy portlets, and portletAttribute -->
<entity-and entity-name="PortalPagePortlet" list="portalPagePortlets">
<field-map field-name="portalPageId" from-field="parameters.portalPageId" />
</entity-and>
<iterate list="portalPagePortlets" entry="portalPagePortlet">
<set-service-fields service-name="createPortalPagePortlet" map="portalPagePortlet" to-map="createPortLet" />
<set field="createPortLet.portalPageId" from-field="portalPageId" />
<call-service service-name="createPortalPagePortlet" in-map-name="createPortLet" />
<!-- copy the attributes -->
<entity-and entity-name="PortletAttribute" list="portletAttributes">
<field-map field-name="portalPageId" from-field="parameters.portalPageId" />
<field-map field-name="portalPortletId" from-field="portalPagePortlet.portalPortletId" />
<field-map field-name="portletSeqId" from-field="portalPagePortlet.portletSeqId" />
</entity-and>
<iterate list="portletAttributes" entry="portletAttribute">
<set field="portletAttribute.portalPageId" from-field="portalPageId" />
<create-value value-field="portletAttribute" />
</iterate>
</iterate>
</if-not-empty>
</simple-method>
<!--Duplicate simple-method of copyOriginalPage-->
<simple-method method-name="duplicatePortalPage" short-description="Only duplicate a portal page, user should put correct owner and securityGroup">
<entity-one entity-name="PortalPage" value-field="portalPage"/>
<!-- copy the portal page -->
<set-service-fields service-name="createPortalPage" map="portalPage" to-map="createPage"/>
<clear-field field="createPage.portalPageId"/>
<if-empty field="createPage.originalPortalPageId">
<set field="createPage.originalPortalPageId" from-field="parameters.portalPageId"/>
</if-empty>
<call-service service-name="createPortalPage" in-map-name="createPage">
<result-to-field result-name="portalPageId"/>
</call-service>
<field-to-request field="portalPageId" request-name="portalPageId"/>
<log level="info" message="new protalPageId=${portalPageId}"/>
<call-simple-method method-name="duplicatePortalPageDetails"/>
</simple-method>
</simple-methods>