blob: bb8779aa47467ed68ef1b69249af1780164c7882 [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">
<!-- base content CRUD services -->
<simple-method method-name="createContent" short-description="Create a Content Record">
<make-value value-field="content" entity-name="Content"/>
<set-nonpk-fields map="parameters" value-field="content"/>
<set-pk-fields value-field="content" map="parameters"/>
<if-empty field="parameters.contentId">
<sequenced-id sequence-name="Content" field="content.contentId"/>
</if-empty>
<if-empty field="content.statusId">
<!-- get the first status item -->
<entity-and entity-name="StatusItem" list="contentStatus">
<field-map field-name="statusTypeId" value="CONTENT_STATUS"/>
<order-by field-name="sequenceId"/>
</entity-and>
<first-from-list list="contentStatus" entry="statusItem"/>
<set field="content.statusId" from-field="statusItem.statusId"/>
</if-empty>
<now-timestamp field="nowTimestamp"/>
<set field="content.lastModifiedByUserLogin" from-field="userLogin.userLoginId"/>
<set field="content.createdByUserLogin" from-field="userLogin.userLoginId"/>
<set field="content.lastModifiedDate" from-field="nowTimestamp"/>
<set field="content.createdDate" from-field="nowTimestamp"/>
<create-value value-field="content"/>
<field-to-result field="content.contentId" result-name="contentId"/>
</simple-method>
<simple-method method-name="updateContent" short-description="Update a Content Record">
<entity-one entity-name="Content" value-field="content" auto-field-map="true"/>
<set-nonpk-fields map="parameters" value-field="content"/>
<now-timestamp field="nowTimestamp"/>
<set field="content.lastModifiedByUserLogin" from-field="userLogin.userLoginId"/>
<set field="content.lastModifiedDate" from-field="nowTimestamp"/>
<store-value value-field="content"/>
<field-to-result field="content.contentId" result-name="contentId"/>
</simple-method>
<simple-method method-name="removeContent" short-description="Remove a Content Record">
<make-value entity-name="Content" value-field="lookupKeyValue"/>
<set-pk-fields map="parameters" value-field="lookupKeyValue"/>
<find-by-primary-key entity-name="Content" map="lookupKeyValue" value-field="content"/>
<remove-value value-field="content"/>
</simple-method>
<simple-method method-name="removeContentAndRelated" short-description="Remove a Content Record, related resource(s) and assocs.">
<entity-one entity-name="Content" value-field="content"/>
<remove-related value-field="content" relation-name="ContentRole"/>
<remove-related value-field="content" relation-name="ContentKeyword"/>
<remove-related value-field="content" relation-name="FromContentAssoc"/>
<remove-related value-field="content" relation-name="ToContentAssoc"/>
<remove-value value-field="content"/>
<get-related-one value-field="content" relation-name="DataResource" to-value-field="dataResource"/>
<if-not-empty field="dataResource">
<get-related-one value-field="dataResource" relation-name="ImageDataResource" to-value-field="imageDataResource"/>
<if-not-empty field="imageDataResource">
<remove-value value-field="imageDataResource"/>
</if-not-empty>
<get-related-one value-field="dataResource" relation-name="ElectronicText" to-value-field="electronicText"/>
<if-not-empty field="electronicText">
<remove-value value-field="electronicText"/>
</if-not-empty>
<remove-related value-field="dataResource" relation-name="DataResourceRole"/>
<remove-value value-field="dataResource"/>
</if-not-empty>
</simple-method>
<!-- content assoc services -->
<simple-method method-name="createContentAssoc" short-description="Create a ContntAssoc Record">
<make-value value-field="assoc" entity-name="ContentAssoc"/>
<set-nonpk-fields map="parameters" value-field="assoc"/>
<set-pk-fields value-field="assoc" map="parameters"/>
<set field="assoc.contentId" from-field="parameters.contentIdFrom" default-value="${parameters.contentId}"/>
<now-timestamp field="nowTimestamp"/>
<if-empty field="assoc.fromDate">
<set field="assoc.fromDate" from-field="nowTimestamp"/>
</if-empty>
<set field="assoc.lastModifiedByUserLogin" from-field="userLogin.userLoginId"/>
<set field="assoc.createdByUserLogin" from-field="userLogin.userLoginId"/>
<set field="assoc.lastModifiedDate" from-field="nowTimestamp"/>
<set field="assoc.createdDate" from-field="nowTimestamp"/>
<create-value value-field="assoc"/>
<log level="info" message="assoc: ${assoc}"/>
<field-to-result field="assoc.fromDate" result-name="fromDate"/>
</simple-method>
<simple-method method-name="updateContentAssoc" short-description="Update a ContentAssoc Record">
<set field="contentId" from-field="parameters.contentIdFrom" default-value="${parameters.contentId}"/>
<entity-one entity-name="ContentAssoc" value-field="assoc" auto-field-map="true"/>
<set-nonpk-fields map="parameters" value-field="assoc"/>
<now-timestamp field="nowTimestamp"/>
<set field="content.lastModifiedByUserLogin" from-field="userLogin.userLoginId"/>
<set field="content.lastModifiedDate" from-field="nowTimestamp"/>
<store-value value-field="assoc"/>
</simple-method>
<!-- update content; just status -->
<simple-method method-name="setContentStatus" short-description="Set The Content Status">
<entity-one entity-name="Content" value-field="content"/>
<field-to-result field="content.statusId" result-name="oldStatusId"/>
<if-compare-field field="content.statusId" to-field="parameters.statusId" operator="not-equals">
<entity-one entity-name="StatusValidChange" value-field="statusChange" auto-field-map="false">
<field-map field-name="statusId" from-field="content.statusId"/>
<field-map field-name="statusIdTo" from-field="parameters.statusId"/>
</entity-one>
<if-empty field="statusChange">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentCannotChangeStatus"/>
</add-error>
<log level="error" message="Cannot change from ${content.statusId} to ${parameters.statusId}"/>
<check-errors/>
<else>
<set from-field="parameters.statusId" field="content.statusId"/>
<store-value value-field="content"/>
</else>
</if-empty>
</if-compare-field>
</simple-method>
<simple-method method-name="copyContentAndElectronicTextandAssoc" short-description="copy a content, electronic text and assocs and set status in progress">
<set-service-fields service-name="getContent" map="parameters" to-map="getC"/>
<call-service service-name="getContent" in-map-name="getC">
<result-to-field result-name="view" field="content"/>
</call-service>
<clone-value value-field="content" new-value-field="content"/>
<if-not-empty field="content.dataResourceId">
<set-service-fields service-name="getElectronicText" map="content" to-map="getEt"/>
<call-service service-name="getElectronicText" in-map-name="getEt">
<result-to-field result-name="textData" field="et.textData"/>
</call-service>
<set field="dataResource.dataResourceTypeId" value="ELECTRONIC_TEXT"/>
<call-service service-name="createDataResource" in-map-name="dataResource">
<result-to-field result-name="dataResourceId" field="et.dataResourceId"/>
</call-service>
<call-service service-name="createElectronicText" in-map-name="et"/>
<set field="content.dataResourceId" from-field="et.dataResourceId"/>
</if-not-empty>
<clear-field field="content.contentId"/><!-- force new value -->
<clear-field field="content.statusId"/><!-- force new value -->
<set-service-fields service-name="createContent" map="content" to-map="createContent"/>
<call-service service-name="createContent" in-map-name="createContent">
<result-to-field result-name="contentId" field="newContentId"/>
</call-service>
<entity-and entity-name="ContentAssoc" list="assocs">
<field-map field-name="contentId" from-field="parameters.contentId"/>
</entity-and>
<iterate list="assocs" entry="assoc">
<set field="assoc.contentId" from-field="newContentId"/>
<set-service-fields service-name="createContentAssoc" map="assoc" to-map="assocS"/>
<call-service service-name="createContentAssoc" in-map-name="assocS"/>
</iterate>
<entity-and entity-name="ContentAssoc" list="assocsTo">
<field-map field-name="contentIdTo" from-field="parameters.contentId"/>
</entity-and>
<iterate list="assocsTo" entry="assocTo">
<set field="assocTo.contentIdTo" from-field="newContentId"/>
<set-service-fields service-name="createContentAssoc" map="assocTo" to-map="assocTos"/>
<call-service service-name="createContentAssoc" in-map-name="assocTos"/>
</iterate>
<field-to-result field="newContentId" result-name="contentId"/>
</simple-method>
<!-- Methods for ContentAssoc -->
<simple-method login-required="true" method-name="assocContent" short-description="Associate Content" >
<log level="info" message="assocContent, parameters:${parameters}"/>
<log level="info" message="assocContent, context:${context}"/>
<call-service in-map-name="parameters" service-name="checkAssocPermission">
<result-to-field result-name="permissionStatus" field="permissionStatus"/>
<result-to-field result-name="rolesOut" field="rolesOut"/>
</call-service>
<log level="info" message="permissionStatus:${permissionStatus}"/>
<set from-field="parameters.contentIdTo" field="pk.contentId"/>
<set from-field="currentContent" field="context.currentContent"/>
<set from-field="parameters.contentIdFrom" field="pk.contentId"/>
<set from-field="parameters.userLogin" field="context.userLogin"/>
<find-by-primary-key value-field="currentContent" entity-name="Content" map="pk"/>
<find-by-primary-key value-field="fromContent" entity-name="Content" map="pk"/>
<if-compare field="permissionStatus" operator="equals" type="String" value="granted">
<make-value entity-name="ContentAssoc" value-field="newContentAssoc"/>
<set from-field="parameters.contentIdTo" field="newContentAssoc.contentIdTo"/>
<set from-field="parameters.contentIdFrom" field="newContentAssoc.contentId"/>
<set from-field="parameters.contentAssocTypeId" field="newContentAssoc.contentAssocTypeId"/>
<set from-field="newUserLogin.userLoginId" field="newContentAssoc.createdByUserLogin"/>
<set from-field="newUserLogin.userLoginId" field="newContentAssoc.lastModifiedByUserLogin"/>
<now-timestamp field="newContentAssoc.createdDate"/>
<now-timestamp field="newContentAssoc.lastModifiedDate"/>
<if-empty field="parameters.fromDate">
<now-timestamp field="parameters.fromDate"/>
</if-empty>
<set from-field="parameters.fromDate" field="newContentAssoc.fromDate"/>
<if-not-empty field="parameters.thruDate">
<set from-field="parameters.thruDate" field="newContentAssoc.thruDate"/>
</if-not-empty>
<create-value value-field="newContentAssoc"/>
</if-compare>
<check-errors/>
</simple-method>
<!-- Methods for ContentRole -->
<simple-method method-name="deactivateAllContentRoles" short-description="Update Content Role">
<make-value entity-name="ContentRole" value-field="lookupKeyValue"/>
<set from-field="parameters.contentId" field="lookupKeyValue.contentId"/>
<set from-field="parameters.partyId" field="lookupKeyValue.partyId"/>
<set from-field="parameters.roleTypeId" field="lookupKeyValue.roleTypeId"/>
<find-by-and entity-name="ContentRole" map="lookupKeyValue" list="roleList"/>
<iterate list="roleList" entry="contentRoleMap">
<make-value entity-name="ContentRole" value-field="role" map="contentRoleMap"/>
<now-timestamp field="role.thruDate"/>
<store-value value-field="role"/>
</iterate>
</simple-method>
<simple-method method-name="updateSingleContentPurpose" short-description="Updates the purpose making sure there is only one">
<set field="toRemove.contentId" from-field="parameters.contentId"/>
<remove-by-and entity-name="ContentPurpose" map="toRemove"/>
<call-service service-name="createContentPurpose" in-map-name="parameters"/>
</simple-method>
<!-- combined text + uploaded file service -->
<simple-method method-name="createTextAndUploadedContent" short-description="Creates Text and Optionally Uploaded (sub) Content records">
<set-service-fields service-name="createTextContent" map="parameters" to-map="textContext"/>
<call-service service-name="createTextContent" in-map-name="textContext">
<result-to-field result-name="contentId" field="parameters.parentContentId"/>
</call-service>
<log level="info" message="${parameters}"/>
<if-not-empty field="parameters.uploadedFile">
<log level="info" message="Uploaded file found; processing sub-content"/>
<set-service-fields service-name="createContentFromUploadedFile" map="parameters" to-map="uploadContext"/>
<set field="uploadContext.ownerContentId" from-field="parameters.parentContentId"/>
<set field="uploadContext.contentIdFrom" from-field="parameters.parentContentId"/>
<set field="uploadContext.contentAssocTypeId" value="SUB_CONTENT"/>
<set field="uploadContext.contentPurposeTypeId" value="SECTION"/>
<call-service service-name="createContentFromUploadedFile" in-map-name="uploadContext"/>
</if-not-empty>
<field-to-result field="parameters.parentContentId" result-name="contentId"/>
</simple-method>
<!-- Util -->
<simple-method method-name="findAssocContent" short-description="Find associated content">
<set from-field="parameters.contentId" field="queryMap.contentId"/>
<set field="mapKeys" from-field="parameters.mapKeys"/>
<field-to-list field="mapKey" list="mapKeys"/>
<iterate list="mapKeys" entry="mapKey">
<set from-field="mapKey" field="queryMap.mapKey"/>
<find-by-and list="resultMap" entity-name="ContentAssoc" map="queryMap"/>
<filter-list-by-date list="resultMap" to-list="validContent"/>
<iterate list="validContent" entry="contentAssoc">
<field-to-list field="contentAssoc" list="result"/>
</iterate>
</iterate>
<if>
<condition>
<if-empty field="parameters.mapKey"/>
</condition>
<then>
<field-to-result field="result" result-name="contentAssocs"/>
</then>
<else>
<field-to-result field="result" result-name="contentAssoc"/>
</else>
</if>
</simple-method>
<!-- Generic content services -->
<simple-method method-name="createEmailContent" short-description="Create Email as Content">
<!-- Create subject -->
<set-service-fields service-name="createContent" map="parameters" to-map="createSubjectContent"/>
<set from-field="parameters.subject" field="createSubjectEtext.textData"/>
<call-service service-name="createElectronicText" in-map-name="createSubjectEtext">
<result-to-field result-name="dataResourceId" field="createSubjectContent.dataResourceId"/>
</call-service>
<call-service service-name="createContent" in-map-name="createSubjectContent">
<result-to-field result-name="contentId" field="createBodyAssoc.contentId"/>
</call-service>
<!-- Create plain body -->
<set from-field="parameters.plainBody" field="createPlainBodyEtext.textData"/>
<call-service service-name="createElectronicText" in-map-name="createPlainBodyEtext">
<result-to-field result-name="dataResourceId" field="createPlainBodyContent.dataResourceId"/>
</call-service>
<call-service service-name="createContent" in-map-name="createPlainBodyContent">
<result-to-field result-name="contentId" field="createBodyAssoc.contentIdTo"/>
</call-service>
<!-- Create content assoc between subject and plain body -->
<set value="TREE_CHILD" field="createBodyAssoc.contentAssocTypeId"/>
<set value="plainBody" field="createBodyAssoc.mapKey"/>
<call-service service-name="createContentAssoc" in-map-name="createBodyAssoc"/>
<!-- Create HTML body -->
<set from-field="parameters.htmlBody" field="createHtmlBodyEtext.textData"/>
<call-service service-name="createElectronicText" in-map-name="createHtmlBodyEtext">
<result-to-field result-name="dataResourceId" field="createHtmlBodyContent.dataResourceId"/>
</call-service>
<call-service service-name="createContent" in-map-name="createHtmlBodyContent">
<result-to-field result-name="contentId" field="createBodyAssoc.contentIdTo"/>
</call-service>
<!-- Create content assoc between subject and html body -->
<set value="htmlBody" field="createBodyAssoc.mapKey"/>
<call-service service-name="createContentAssoc" in-map-name="createBodyAssoc"/>
<field-to-result field="createBodyAssoc.contentId" result-name="contentId"/>
</simple-method>
<simple-method method-name="updateEmailContent" short-description="Update Email Content">
<if-not-empty field="parameters.subjectDataResourceId">
<set from-field="parameters.subjectDataResourceId" field="updateSubjectEt.dataResourceId"/>
<set from-field="parameters.subject" field="updateSubjectEt.textData"/>
<call-service service-name="updateElectronicText" in-map-name="updateSubjectEt"/>
</if-not-empty>
<if-not-empty field="parameters.plainBodyDataResourceId">
<set from-field="parameters.plainBodyDataResourceId" field="updatePlainBodyEt.dataResourceId"/>
<set from-field="parameters.plainBody" field="updatePlainBodyEt.textData"/>
<call-service service-name="updateElectronicText" in-map-name="updatePlainBodyEt"/>
</if-not-empty>
<if-not-empty field="parameters.htmlBodyDataResourceId">
<set from-field="parameters.htmlBodyDataResourceId" field="updateHtmlBodyEt.dataResourceId"/>
<set from-field="parameters.htmlBody" field="updateHtmlBodyEt.textData"/>
<call-service service-name="updateElectronicText" in-map-name="updateHtmlBodyEt"/>
</if-not-empty>
</simple-method>
<simple-method method-name="createDownloadContent" short-description="Create Download as Content">
<set-service-fields service-name="createContent" map="parameters" to-map="createDownloadContent"/>
<set from-field="parameters.file" field="createDownload.dataResourceContent"/>
<call-service service-name="createOtherDataResource" in-map-name="createDownload">
<result-to-field result-name="dataResourceId" field="createDownloadContent.dataResourceId"/>
</call-service>
<call-service service-name="createContent" in-map-name="createDownloadContent">
<result-to-result result-name="contentId"/>
</call-service>
</simple-method>
<simple-method method-name="updateDownloadContent" short-description="Update Download Content">
<if-not-empty field="parameters.fileDataResourceId">
<set from-field="parameters.fileDataResourceId" field="updateFile.dataResourceId"/>
<set from-field="parameters.file" field="updateFile.dataResourceContent"/>
<call-service service-name="updateOtherDataResource" in-map-name="updateFile"/>
</if-not-empty>
</simple-method>
<simple-method method-name="createSimpleTextContent" short-description="Create Simple Text Content">
<set-service-fields service-name="createContent" map="parameters" to-map="createSimpleTextContent"/>
<set value="DOCUMENT" field="createSimpleTextContent.contentTypeId"/>
<set from-field="parameters.text" field="createSimpleText.textData"/>
<set-service-fields service-name="createDataResource" map="parameters" to-map="createSimpleTextDataResource"/>
<set value="ELECTRONIC_TEXT" field="createSimpleTextDataResource.dataResourceTypeId"/>
<set value="FTL" field="createSimpleTextDataResource.dataTemplateTypeId"/>
<call-service service-name="createDataResource" in-map-name="createSimpleTextDataResource">
<result-to-field result-name="dataResourceId" field="createSimpleText.dataResourceId"/>
<result-to-field result-name="dataResourceId" field="createSimpleTextContent.dataResourceId"/>
</call-service>
<call-service service-name="createElectronicText" in-map-name="createSimpleText"/>
<call-service service-name="createContent" in-map-name="createSimpleTextContent">
<result-to-result result-name="contentId"/>
</call-service>
</simple-method>
<simple-method method-name="updateSimpleTextContent" short-description="Update Simple Text Content">
<if-not-empty field="parameters.textDataResourceId">
<set from-field="parameters.textDataResourceId" field="updateSimpleText.dataResourceId"/>
<set from-field="parameters.text" field="updateSimpleText.textData"/>
<call-service service-name="updateElectronicText" in-map-name="updateSimpleText"/>
</if-not-empty>
</simple-method>
<simple-method method-name="createTopic" short-description="Create TOPIC type Content">
<make-value value-field="content" entity-name="Content"/>
<set from-field="parameters.newTopicId" field="content.contentId"/>
<set from-field="parameters.newTopicId" field="content.contentName"/>
<set from-field="parameters.newTopicDescription" field="content.description"/>
<set value="TOPIC" field="content.contentTypeId"/>
<now-timestamp field="content.lastModifiedDate"/>
<now-timestamp field="content.createdDate"/>
<set from-field="parameters.userLogin.userLoginId" field="content.lastModifiedByUserLogin"/>
<set from-field="parameters.userLogin.userLoginId" field="content.createdByUserLogin"/>
<create-value value-field="content"/>
</simple-method>
<!-- This method will create a skeleton content record from a data resource -->
<simple-method method-name="createContentFromDataResource" short-description="Create Content from DataResource Object">
<entity-one entity-name="DataResource" value-field="dataResource">
<field-map field-name="dataResourceId" from-field="parameters.dataResourceId"/>
</entity-one>
<if-empty field="dataResource">
<add-error>
<fail-property resource="ContentUiLabels" property="ContentDataResourceNotFound"/>
</add-error>
</if-empty>
<check-errors/>
<set-service-fields service-name="createContent" map="parameters" to-map="createContentMap"/>
<if-empty field="createContentMap.contentName">
<set field="createContentMap.contentName" from-field="dataResource.dataResourceName"/>
</if-empty>
<if-empty field="createContentMap.contentTypeId">
<set field="createContentMap.contentTypeId" value="DOCUMENT"/>
</if-empty>
<if-empty field="createContentMap.statusId">
<set field="createContentMap.statusId" value="CTNT_INITIAL_DRAFT"/>
</if-empty>
<if-empty field="createContentMap.mimeTypeId">
<set from-field="dataResource.mimeTypeId" field="createContentMap.mimeTypeId"/>
</if-empty>
<call-service service-name="createContent" in-map-name="createContentMap" break-on-error="false">
<result-to-field result-name="contentId" field="contentId"/>
</call-service>
<field-to-result field="contentId"/>
</simple-method>
<!-- This method first creates Content, DataResource and ElectronicText, ImageDataResource, etc. entities (if needed)
by calling persistContentAndAssoc.
It then takes the contentId coming out of that service, the passed in communicationEventId
and calls the "createCommEventContentAssoc" service to tie the CommunicationEvent and Content entities together.
-->
<simple-method method-name="createCommContentDataResource" short-description="Create CommunicationEvent and Content">
<!--
<check-permission permission="CONTENTMGR" action="_DELETE">
<fail-property resource="ContentUiLabels" property="ContentSecurityDeletePermission"/>
</check-permission>
<check-errors/>
-->
<now-timestamp field="nowTimestamp"/>
<set-service-fields service-name="persistContentAndAssoc" map="parameters" to-map="persistIn"/>
<!-- let's take a guess at what the dataResourceTypeId should be if it is empty -->
<if-empty field="persistIn.dataResourceTypeId">
<log level="info" message="persistIn.drMimeTypeId: ${persistIn.drMimeTypeId}"/>
<if-regexp expr="text.*" field="persistIn.drMimeTypeId">
<set field="persistIn.dataResourceTypeId" value="ELECTRONIC_TEXT"/>
<else>
<set field="persistIn.dataResourceTypeId" value="IMAGE_OBJECT"/>
</else>
</if-regexp>
</if-empty>
<log level="info" message="persistIn.dataResourceTypeId: ${persistIn.dataResourceTypeId}"/>
<call-service service-name="persistContentAndAssoc" in-map-name="persistIn">
<results-to-map map-name="persistOut"/>
</call-service>
<field-to-result field="persistOut.contentId" result-name="contentId"/>
<field-to-result field="persistOut.dataResourceId" result-name="dataResourceId"/>
<field-to-result field="persistOut.drDataResourceId" result-name="drDataResourceId"/>
<field-to-result field="persistOut.caContentIdTo" result-name="caContentIdTo"/>
<field-to-result field="persistOut.caContentId" result-name="caContentId"/>
<field-to-result field="persistOut.caContentAssocTypeId" result-name="caContentAssocTypeId"/>
<field-to-result field="persistOut.caFromDate" result-name="caFromDate"/>
<field-to-result field="persistOut.caSequenceNum" result-name="caSequenceNum"/>
<field-to-result field="persistOut.roleTypeList" result-name="roleTypeList"/>
<field-to-result field="persistOut.fromDate" result-name="fromDate"/>
<set field="mapIn.contentId" from-field="persistOut.contentId"/>
<set field="mapIn.communicationEventId" from-field="parameters.communicationEventId"/>
<set field="mapIn.sequenceNum" from-field="parameters.sequenceNum"/>
<call-service service-name="createCommEventContentAssoc" in-map-name="mapIn">
<result-to-result result-name="fromDate"/>
</call-service>
</simple-method>
<!-- This method first updates Content, DataResource and ElectronicText, ImageDataResource, etc. entities (if needed)
by calling persistContentAndAssoc. It then takes the passed in contentId, communicationEventId and fromDate primary keys
and calls the "updateCommEventContentAssoc" service to tie the CommunicationEvent and Content entities together.
-->
<simple-method method-name="updateCommContentDataResource" short-description="Update CommunicationEvent and Content">
<!--
<check-permission permission="CONTENTMGR" action="_DELETE">
<fail-property resource="ContentUiLabels" property="ContentSecurityDeletePermission"/>
</check-permission>
<check-errors/>
-->
<set-service-fields service-name="persistContentAndAssoc" map="parameters" to-map="persistIn"/>
<call-service service-name="persistContentAndAssoc" in-map-name="persistIn">
<results-to-map map-name="persistOut"/>
</call-service>
<set field="mapIn.contentId" from-field="persistOut.contentId"/>
<set field="mapIn.fromDate" from-field="parameters.fromDate"/>
<set field="mapIn.communicationEventId" from-field="parameters.communicationEventId"/>
<set field="mapIn.sequenceNum" from-field="parameters.sequenceNum"/>
<call-service service-name="updateCommEventContentAssoc" in-map-name="mapIn">
</call-service>
<field-to-result field="persistOut.contentId" result-name="contentId"/>
<field-to-result field="persistOut.dataResourceId" result-name="dataResourceId"/>
<field-to-result field="persistOut.drDataResourceId" result-name="drDataResourceId"/>
<field-to-result field="persistOut.caContentIdTo" result-name="caContentIdTo"/>
<field-to-result field="persistOut.caContentId" result-name="caContentId"/>
<field-to-result field="persistOut.caContentAssocTypeId" result-name="caContentAssocTypeId"/>
<field-to-result field="persistOut.caFromDate" result-name="caFromDate"/>
<field-to-result field="persistOut.caSequenceNum" result-name="caSequenceNum"/>
<field-to-result field="persistOut.roleTypeList" result-name="roleTypeList"/>
</simple-method>
<!-- This service ties CommunicationEvent and Content entities together along with the standard from/thruDate fields.
-->
<simple-method method-name="createCommEventContentAssoc" short-description="Create CommEventContentAssoc">
<make-value entity-name="CommEventContentAssoc" value-field="commEventContentAssoc"/>
<set-pk-fields value-field="commEventContentAssoc" map="parameters"/>
<set-nonpk-fields map="parameters" value-field="commEventContentAssoc"/>
<if-empty field="commEventContentAssoc.fromDate">
<now-timestamp field="commEventContentAssoc.fromDate"/>
</if-empty>
<create-value value-field="commEventContentAssoc"/>
<field-to-result field="commEventContentAssoc.fromDate" result-name="fromDate"/>
</simple-method>
<!-- This service would primarily be used to update the thruDate field.
-->
<simple-method method-name="updateCommEventContentAssoc" short-description="Update CommEventContentAssoc">
<make-value entity-name="CommEventContentAssoc" value-field="pkCommEventContentAssoc"/>
<set-pk-fields value-field="pkCommEventContentAssoc" map="parameters"/>
<find-by-primary-key entity-name="CommEventContentAssoc" map="pkCommEventContentAssoc" value-field="commEventContentAssoc"/>
<if-empty field="commEventContentAssoc">
<add-error>
<fail-property resource="ContentUiLabels" property="ContenCommEventContentAssocNotFoundForUpdate"/>
</add-error>
</if-empty>
<set-nonpk-fields map="parameters" value-field="commEventContentAssoc"/>
<store-value value-field="commEventContentAssoc"/>
</simple-method>
<simple-method method-name="removeCommEventContentAssoc" short-description="Delete CommEventContentAssoc">
<make-value entity-name="CommEventContentAssoc" value-field="pkCommEventContentAssoc"/>
<set-pk-fields value-field="pkCommEventContentAssoc" map="parameters"/>
<find-by-primary-key entity-name="CommEventContentAssoc" map="pkCommEventContentAssoc" value-field="commEventContentAssoc"/>
<if-empty field="commEventContentAssoc">
<add-error>
<fail-property resource="ContentUiLabels" property="ContenCommEventContentAssocNotFoundForDelete"/>
</add-error>
</if-empty>
<remove-value value-field="commEventContentAssoc"/>
</simple-method>
<!-- simply use createContent and the accoc will be created too" the service below +aca will create 2 contentAssocs-->
<!--simple-method method-name="createContentAndAssoc" short-description="Create content and associate with other content">
<set-service-fields service-name="createContent" map="parameters" to-map="contentData"/>
<call-service service-name="createContent" in-map-name="contentData">
<result-to-field result-name="contentId" field="newContentId"/>
</call-service>
<if-not-empty field="newContentId">
<set-service-fields service-name="createContentAssoc" map="parameters" to-map="assocData"/>
<set field="assocData.contentId" from-field="newContentId"/>
<call-service service-name="createContentAssoc" in-map-name="assocData">
<result-to-result result-name="contentId" service-result-name="contentIdFrom"/>
<result-to-result result-name="contentIdTo" service-result-name="contentIdTo"/>
</call-service>
<field-to-result field="newContentId" result-name="contentId"/>
</if-not-empty>
</simple-method-->
<!-- retrieve Data resource information -->
<simple-method method-name="getDataResource" short-description="get the content and relasted resource information" login-required="false">
<entity-one entity-name="DataResource" value-field="resultData.dataResource"/>
<if-not-empty field="resultData.dataResource">
<if-compare field="resultData.dataResource.dataResourceTypeId" value="ELECTRONIC_TEXT" operator="equals">
<get-related-one value-field="resultData.dataResource" relation-name="ElectronicText"
to-value-field="resultData.electronicText"/>
</if-compare>
<if-compare field="resultData.dataResource.dataResourceTypeId" value="IMAGE_OBJECT" operator="equals">
<get-related-one value-field="resultData.dataResource" relation-name="ImageDataResource"
to-value-field="resultData.imageDataResource"/>
</if-compare>
</if-not-empty>
<field-to-result field="resultData" result-name="resultData"/>
</simple-method>
<simple-method method-name="getContentAndDataResource" short-description="get the content and related resource information" login-required="false">
<entity-one entity-name="Content" value-field="resultDataContent.content">
<field-map field-name="contentId" from-field="parameters.contentId"/>
</entity-one>
<if-not-empty field="resultDataContent.content">
<if-not-empty field="resultDataContent.content.dataResourceId">
<set field="parameters.dataResourceId" from-field="resultDataContent.content.dataResourceId"/>
<call-simple-method method-name="getDataResource"/>
<set field="resultDataContent.dataResource" from-field="resultData.dataResource"/>
<set field="resultDataContent.electronicText" from-field="resultData.electronicText"/>
<set field="resultDataContent.imageDataResource" from-field="resultData.imageDataResource"/>
</if-not-empty>
<field-to-result field="resultDataContent" result-name="resultData"/>
</if-not-empty>
</simple-method>
<simple-method method-name="getPublicForumMessage" short-description="get the content and related resource information without security" login-required="false">
<set field="publicForumMessage" value="true"/>
<call-simple-method method-name="getContentAndDataResource"/>
</simple-method>
<!-- eca helper services -->
<simple-method method-name="checkContentAssocIds" short-description="Checks and prepares contentIdTo and contentId for ContentAssoc service">
<if>
<condition>
<and>
<not>
<if-empty field="parameters.contentIdFrom"/>
</not>
<not>
<if-empty field="parameters.contentId"/>
</not>
<if-empty field="parameters.contentIdTo"/>
</and>
</condition>
<then>
<field-to-result field="parameters.contentIdFrom" result-name="contentId"/>
<field-to-result field="parameters.contentId" result-name="contentIdTo"/>
<log level="info" message="Converted 'contentId' to 'contentIdTo' and 'contentIdFrom' to 'contentId'"/>
</then>
<else-if>
<condition>
<not>
<if-empty field="parameters.contentIdTo"/>
</not>
</condition>
<then>
<field-to-result field="parameters.contentIdTo" result-name="contentIdTo"/>
<field-to-result field="parameters.contentId" result-name="contentId"/>
<log level="info" message="Returned 'contentId' as 'contentId' and 'contentIdTo' as 'contentIdTo'"/>
</then>
</else-if>
<else>
<log level="warning" message="Illegal values passed; should be either contentIdTo/contentId or contentIdFrom/contentId :: ${parameters}"/>
</else>
</if>
</simple-method>
<simple-method method-name="createArticleContent" short-description="Post a new Content article Entry">
<set field="contentAssocTypeId" from-field="parameters.contentAssocTypeId"/>
<set field="origContentAssocTypeId" from-field="parameters.contentAssocTypeId"/>
<set field="ownerContentId" from-field="parameters.threadContentId"/>
<if-compare field="origContentAssocTypeId" operator="equals" value="PUBLISH_LINK">
<set field="ownerContentId" from-field="parameters.pubPtContentId"/>
</if-compare>
<set field="contentIdFrom" from-field="parameters.contentIdFrom"/>
<set field="pubPtContentId" from-field="parameters.pubPtContentId"/>
<call-object-method method-name="length" obj-field="parameters.textData" ret-field="textDataLen"/>
<log level="info" message="textDataLen:${textDataLen}"/>
<property-to-field resource="forum" property="descriptLen" field="descriptLen"/>
<set field="descriptLen" from-field="descriptLen" type="Integer"/>
<log level="info" message="descriptLen:${descriptLen}"/>
<call-class-method method-name="min" class-name="java.lang.Math" ret-field="subStringLen">
<field field="textDataLen" type="int"/>
<field field="descriptLen" type="int"/>
</call-class-method>
<log level="info" message="subStringLen:${subStringLen}"/>
<set field="zeroValue" value="0" type="Integer"/>
<call-object-method method-name="substring" obj-field="parameters.textData" ret-field="subDescript">
<field field="zeroValue" type="int"/>
<field field="subStringLen" type="int"/>
</call-object-method>
<log level="info" message="subDescript:${subDescript}"/>
<if-compare field="contentAssocTypeId" operator="equals" value="PUBLISH_LINK">
<set field="ownerContentId" from-field="pubPtContentId"/>
</if-compare>
<!-- determine of we need to create complex template structure or simple content structure -->
<if>
<condition>
<and>
<not>
<if-empty field="parameters.uploadedFile"/>
</not>
<not>
<if-empty field="parameters.textData"/>
</not>
</and>
</condition>
<then>
<!-- complex template structure (image & text) -->
<set field="createMain.dataResourceId" from-field="parameters.dataResourceId"/>
<set field="createMain.contentAssocTypeId" from-field="contentAssocTypeId"/>
<set field="createMain.contentName" from-field="parameters.contentName"/>
<set field="createMain.description" from-field="subDescript"/>
<set field="createMain.statusId" from-field="parameters.statusId"/>
<set field="createMain.contentIdFrom" from-field="contentIdFrom"/>
<set field="createMain.partyId" from-field="userLogin.partyId"/>
<set field="createMain.ownerContentId" from-field="ownerContentId"/>
<set field="createMain.dataTemplateTypeId" value="SCREEN_COMBINED"/>
<set field="createMain.mapKey" value="MAIN"/>
<call-service service-name="createContent" in-map-name="createMain">
<result-to-field result-name="contentId" field="contentId"/>
</call-service>
<!-- reset contentIdFrom to new contentId -->
<set field="contentAssocTypeId" value="SUB_CONTENT"/>
<set field="contentIdFrom" from-field="contentId"/>
</then>
</if>
<if>
<condition>
<not>
<if-empty field="parameters.uploadedFile"/>
</not>
</condition>
<then>
<!-- create image data -->
<set field="createImage.dataResourceTypeId" value="LOCAL_FILE"/>
<set field="createImage.dataTemplateTypeId" value="NONE"/>
<set field="createImage.mapKey" value="IMAGE"/>
<set field="createMain.ownerContentId" from-field="ownerContentId"/>
<set field="createImage.contentName" from-field="parameters.contentName"/>
<set field="createImage.description" from-field="subDescript"/>
<set field="createImage.statusId" from-field="parameters.statusId"/>
<set field="createImage.contentAssocTypeId" from-field="contentAssocTypeId"/>
<set field="createImage.contentIdFrom" from-field="contentIdFrom"/>
<set field="createImage.partyId" from-field="userLogin.partyId"/>
<set field="createImage.uploadedFile" from-field="parameters.uploadedFile"/>
<set field="createImage._uploadedFile_fileName" from-field="parameters._uploadedFile_fileName"/>
<set field="createImage._uploadedFile_contentType" from-field="parameters._uploadedFile_contentType"/>
<call-service service-name="createContentFromUploadedFile" in-map-name="createImage">
<result-to-field result-name="contentId" field="imageContentId"/>
</call-service>
<if-empty field="contentId">
<set field="contentIdFrom" from-field="imageContentId"/>
<set field="contentId" from-field="imageContentId"/>
<set field="contentAssocTypeId" value="SUB_CONTENT"/>
</if-empty>
</then>
</if>
<if>
<condition>
<not>
<if-empty field="parameters.textData"/>
</not>
</condition>
<then>
<!-- create text data -->
<set field="createText.dataResourceTypeId" value="ELECTRONIC_TEXT"/>
<set field="createText.dataTemplateTypeId" value="NONE"/>
<set field="createText.mapKey" value="MAIN"/>
<set field="createText.ownerContentId" from-field="ownerContentId"/>
<set field="createText.contentName" from-field="parameters.contentName"/>
<set field="createText.description" from-field="subDescript"/>
<set field="createText.statusId" from-field="parameters.statusId"/>
<set field="createText.contentAssocTypeId" from-field="contentAssocTypeId"/>
<set field="createText.textData" from-field="parameters.textData"/>
<set field="createText.contentIdFrom" from-field="contentIdFrom"/>
<set field="createText.partyId" from-field="userLogin.partyId"/>
<log level="info" message="calling createTextContent with map: ${createText}"/>
<call-service service-name="createTextContent" in-map-name="createText">
<result-to-field result-name="contentId" field="textContentId"/>
</call-service>
<if-empty field="contentId">
<set field="contentIdFrom" from-field="textContentId"/>
<set field="contentId" from-field="textContentId"/>
<set field="contentAssocTypeId" value="SUB_CONTENT"/>
</if-empty>
</then>
</if>
<!-- we should have a primary (at least) contentId -->
<if>
<condition>
<and>
<not>
<if-empty field="contentId"/>
</not>
<not>
<if-empty field="parameters.summaryData"/>
</not>
</and>
</condition>
<then>
<!-- create the summary data -->
<set field="createSummary.dataResourceTypeId" value="ELECTRONIC_TEXT"/>
<set field="createSummary.dataTemplateTypeId" value="NONE"/>
<set field="createSummary.mapKey" value="SUMMARY"/>
<set field="createSummary.ownerContentId" from-field="ownerContentId"/>
<set field="createSummary.contentName" from-field="parameters.contentName"/>
<set field="createSummary.description" from-field="parameters.description"/>
<set field="createSummary.statusId" from-field="parameters.statusId"/>
<set field="createSummary.contentAssocTypeId" from-field="contentAssocTypeId"/>
<set field="createSummary.textData" from-field="parameters.summaryData"/>
<set field="createSummary.contentIdFrom" from-field="contentIdFrom"/>
<set field="createSummary.partyId" from-field="userLogin.partyId"/>
<call-service service-name="createTextContent" in-map-name="createSummary"/>
</then>
</if>
<!-- If a response, still link it to the publish point -->
<if-compare field="origContentAssocTypeId" operator="equals" value="RESPONSE">
<set field="contentAssocMap.contentId" from-field="pubPtContentId"/>
<set field="contentAssocMap.contentIdTo" from-field="contentId"/>
<set field="contentAssocMap.contentAssocTypeId" value="RESPONSE"/>
<log level="info" message="contentAssocMap:${contentAssocMap.contentId}"/>
<call-service service-name="createContentAssoc" in-map-name="contentAssocMap"/>
</if-compare>
<field-to-result field="contentId"/>
</simple-method>
<simple-method method-name="getSubContentWithPermCheck" short-description="Get sub content and perform permission check on each record">
<set field="filterByDate" from-field="parameters.filterByDate" default-value="true" type="Boolean"/>
<set field="useCache" from-field="parameters.useCache" default-value="true" type="Boolean"/>
<entity-condition entity-name="ContentAssocViewTo" list="viewList" filter-by-date="${filterByDate}" use-cache="${useCache}">
<condition-list combine="and">
<condition-expr field-name="contentIdStart" from-field="parameters.contentId"/>
<condition-expr field-name="caContentAssocTypeId" from-field="parameters.contentAssocTypeId" ignore-if-empty="true"/>
<condition-expr field-name="caMapKey" from-field="parameters.mapKey" ignore-if-empty="true"/>
</condition-list>
</entity-condition>
<iterate list="viewList" entry="view">
<set field="hasPermission" value="true" type="Boolean"/>
<if>
<condition>
<and>
<not>
<if-empty field="parameters.mainAction"/>
</not>
<not>
<if-empty field="parameters.userLogin"/>
</not>
</and>
</condition>
<then>
<set field="inMap.contentId" from-field="parameters.contentId"/>
<set field="inMap.mainAction" from-field="parameters.mainAction"/>
<set field="inMap.userLogin" from-field="parameters.userLogin"/>
<set field="inMap.contentOperationId" from-field="parameters.contentOperationId" default-value="CONTENT_CREATE"/>
<call-service service-name="genericContentPermission" in-map-name="inMap" include-user-login="true">
<result-to-field result-name="hasPermission"/>
</call-service>
</then>
</if>
<if-compare field="hasPermission" operator="equals" value="true" type="Boolean">
<set field="contentViewList[]" from-field="view"/>
</if-compare>
</iterate>
<field-to-result field="contentViewList" result-name="subContentList"/>
</simple-method>
<simple-method method-name="getSubSubContentWithPermCheck" short-description="Get sub content and perform permission check on each record">
<set-service-fields service-name="getSubContentWithPermCheck" map="parameters" to-map="inMap"/>
<call-service service-name="getSubContentWithPermCheck" in-map-name="inMap">
<result-to-field result-name="subContentList"/>
</call-service>
<iterate list="subContentList" entry="view">
<entity-condition list="viewList" entity-name="ContentAssocViewTo" filter-by-date="true" use-cache="${useCache}">
<condition-list combine="and">
<condition-expr field-name="contentIdStart" from-field="view.caContentIdTo"/>
<condition-expr field-name="caContentAssocTypeId" from-field="parameters.subContentAssocTypeId" ignore-if-empty="true"/>
<condition-expr field-name="caMapKey" from-field="parameters.subMapKey" ignore-if-empty="true"/>
</condition-list>
</entity-condition>
<clear-field field="view2"/>
<first-from-list list="viewList" entry="view2"/>
<clear-field field="map"/>
<set field="map.contentIdFrom" from-field="view.contentId"/>
<set field="map.dataResourceIdFrom" from-field="view.dataResourceId"/>
<set field="map.contentId" from-field="view2.contentId"/>
<set field="map.contentName" from-field="view2.contentName"/>
<set field="map.description" from-field="view2.description"/>
<entity-one entity-name="ElectronicText" value-field="electronicText">
<field-map field-name="dataResourceId" from-field="view2.dataResourceId"/>
</entity-one>
<set field="map.textData" from-field="electronicText.textData"/>
<set field="contentViewList[]" from-field="map"/>
</iterate>
<field-to-result field="subContentList" result-name="subContentList"/>
<field-to-result field="contentViewList" result-name="subSubContentList"/>
</simple-method>
<simple-method method-name="forceIndexContentKeywords" short-description="induce all the keywords of a content">
<entity-one entity-name="Content" value-field="content"/>
<call-class-method class-name="org.apache.ofbiz.content.content.ContentKeywordIndex" method-name="forceIndexKeywords">
<field field="content" type="org.apache.ofbiz.entity.GenericValue"/>
</call-class-method>
</simple-method>
<simple-method method-name="deleteContentKeywords" short-description="delete all the keywords of a content">
<entity-one entity-name="Content" value-field="content"/>
<remove-related value-field="content" relation-name="ContentKeyword"/>
</simple-method>
<simple-method method-name="indexContentKeywords" short-description="Index the Keywords for a Content" login-required="false">
<!-- this service is meant to be called from an entity ECA for entities that include a contentId -->
<!-- if it is the Content entity itself triggering this action, then a [contentInstance] parameter
will be passed and we can save a few cycles looking that up -->
<set from-field="parameters.contentInstance" field="contentInstance"/>
<if-empty field="contentInstance">
<set from-field="parameters.contentId" field="findContentMap.contentId"/>
<find-by-primary-key entity-name="Content" map="findContentMap" value-field="contentInstance"/>
</if-empty>
<!-- induce keywords-->
<call-class-method class-name="org.apache.ofbiz.content.content.ContentKeywordIndex" method-name="indexKeywords">
<field field="contentInstance" type="org.apache.ofbiz.entity.GenericValue"/>
</call-class-method>
</simple-method>
<simple-method method-name="createContentAlternativeUrl" short-description="Create Content Alternative URLs.">
<set field="defaultLocaleString" from-field="parameters.locale" default-value="en"/>
<set field="contents" type="List"/>
<if>
<condition>
<or>
<if-empty field="parameters.contentId"/>
<if-compare operator="equals" value="null" field="parameters.contentId"></if-compare>
</or>
</condition>
<then>
<entity-condition entity-name="Content" list="contents">
<condition-list combine="and">
<condition-expr field-name="contentName" operator="not-equals" from-field="nullField"/>
<condition-list combine="or">
<condition-expr field-name="contentTypeId" operator="equals" value="DOCUMENT"/>
<condition-expr field-name="contentTypeId" operator="equals" value="WEB_SITE_PUB_PT"/>
</condition-list>
</condition-list>
<select-field field-name="contentId"/>
<select-field field-name="contentName"/>
<select-field field-name="localeString"/>
</entity-condition>
</then>
<else>
<entity-condition entity-name="Content" list="contents">
<condition-list combine="and">
<condition-expr field-name="contentName" operator="not-equals" from-field="nullField"/>
<condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId"/>
<condition-list combine="or">
<condition-expr field-name="contentTypeId" operator="equals" value="DOCUMENT"/>
<condition-expr field-name="contentTypeId" operator="equals" value="WEB_SITE_PUB_PT"/>
</condition-list>
</condition-list>
<select-field field-name="contentId"/>
<select-field field-name="contentName"/>
<select-field field-name="localeString"/>
</entity-condition>
</else>
</if>
<iterate list="contents" entry="content">
<set field="localeString" from-field="content.localeString" default-value="${defaultLocaleString}"/>
<entity-condition entity-name="ContentAssocDataResourceViewTo" list="contentAssocDataResources">
<condition-list combine="and">
<condition-expr field-name="caContentAssocTypeId" operator="equals" value="ALTERNATIVE_URL"/>
<condition-expr field-name="contentIdStart" operator="equals" from-field="content.contentId"/>
<condition-expr field-name="localeString" operator="equals" from-field="localeString"/>
</condition-list>
<select-field field-name="contentIdStart"/>
<select-field field-name="dataResourceId"/>
<select-field field-name="localeString"/>
<select-field field-name="drObjectInfo"/>
<select-field field-name="caFromDate"/>
<select-field field-name="caThruDate"/>
</entity-condition>
<filter-list-by-date list="contentAssocDataResources" from-field-name="caFromDate" thru-field-name="caThruDate"/>
<if-empty field="contentAssocDataResources">
<if-not-empty field="content.contentName">
<call-class-method method-name="invalidCharacter" class-name="org.apache.ofbiz.common.UrlServletHelper" ret-field="uri">
<field field="content.contentName"/>
</call-class-method>
<if-not-empty field="uri">
<sequenced-id sequence-name="DataResource" field="dataResourceCtx.dataResourceId"/>
<set field="dataResourceCtx.dataResourceTypeId" value="URL_RESOURCE"/>
<set field="dataResourceCtx.localeString" from-field="localeString"/>
<set field="dataResourceCtx.objectInfo" value="/${uri}-${content.contentId}-content"/>
<set field="dataResourceCtx.statusId" value="CTNT_IN_PROGRESS"/>
<call-service service-name="createDataResource" in-map-name="dataResourceCtx" break-on-error="false" include-user-login="true">
<result-to-field result-name="dataResourceId" field="dataResourceId"/>
</call-service>
<if-not-empty field="dataResourceId">
<set field="contentCtx.dataResourceId" from-field="dataResourceId"/>
<set field="contentCtx.statusId" value="CTNT_IN_PROGRESS"/>
<set field="contentCtx.localeString" from-field="localeString"/>
<call-service service-name="createContent" in-map-name="contentCtx" break-on-error="false" include-user-login="true">
<result-to-field result-name="contentId" field="contentIdTo"/>
</call-service>
<if-not-empty field="contentIdTo">
<set field="createContentAssocCtx.contentId" from-field="content.contentId"/>
<set field="createContentAssocCtx.contentIdTo" from-field="contentIdTo"/>
<set field="createContentAssocCtx.contentAssocTypeId" value="ALTERNATIVE_URL"/>
<call-service service-name="createContentAssoc" in-map-name="createContentAssocCtx" include-user-login="true" break-on-error="false"/>
</if-not-empty>
</if-not-empty>
<set field="contentCreated" value="Y"/>
<field-to-result field="contentCreated" result-name="contentCreated"/>
</if-not-empty>
</if-not-empty>
<else>
<if-empty field="contentAssocDataResources[0].drObjectInfo">
<if-not-empty field="content.contentName">
<call-class-method method-name="invalidCharacter" class-name="org.apache.ofbiz.common.UrlServletHelper" ret-field="uri">
<field field="content.contentName"/>
</call-class-method>
<if-not-empty field="uri">
<set field="dataResourceCtx.dataResourceId" from-field="contentAssocDataResources[0].dataResourceId"/>
<set field="dataResourceCtx.objectInfo" value="/${uri}-${content.contentId}-content"/>
<call-service service-name="updateDataResource" in-map-name="dataResourceCtx" break-on-error="false" include-user-login="true"/>
<set field="contentCreated" value="Y"/>
<field-to-result field="contentCreated" result-name="contentCreated"/>
</if-not-empty>
</if-not-empty>
<else>
<set field="contentCreated" value="N"/>
<field-to-result field="contentCreated" result-name="contentCreated"/>
</else>
</if-empty>
</else>
</if-empty>
</iterate>
</simple-method>
<simple-method method-name="createMissingContentAltUrls" short-description="create missing content alternative urls.">
<now-timestamp field="now"/>
<set field="contentsNotUpdated" value="0" type="Integer"/>
<set field="contentsUpdated" value="0" type="Integer"/>
<if-not-empty field="parameters.prodCatalogId">
<entity-and entity-name="ProdCatalogCategory" list="prodCatalogCategoryList" filter-by-date="false">
<field-map field-name="prodCatalogId" from-field="parameters.prodCatalogId"/>
</entity-and>
<!-- Get all categories -->
<set field="parameters.productCategories" value="${groovy: [];}" type="List"/>
<iterate list="prodCatalogCategoryList" entry="prodCatalogCategory">
<set field="rootProductCategoryId" from-field="prodCatalogCategory.productCategoryId"/>
<entity-and entity-name="ProductCategoryRollup" list="productCategoryRollupList" filter-by-date="true">
<field-map field-name="parentProductCategoryId" from-field="rootProductCategoryId"/>
</entity-and>
<set field="parameters.parentProductCategoryId" from-field="rootProductCategoryId"/>
<call-simple-method method-name="createMissingCategoryContentAltUrlInline"/>
</iterate>
<iterate list="parameters.productCategories" entry="productCategoryList">
<!-- Create Content Alternative URLs for Product Category Content -->
<entity-condition entity-name="ProductCategoryContentAndInfo" list="productCategoryContentAndInfoList" filter-by-date="true" use-cache="true">
<condition-list combine="and">
<condition-expr field-name="productCategoryId" from-field="productCategoryList.productCategoryId"/>
<condition-expr field-name="prodCatContentTypeId" operator="not-equals" value="ALTERNATIVE_URL"/>
</condition-list>
<order-by field-name="-fromDate"/>
</entity-condition>
<iterate list="productCategoryContentAndInfoList" entry="productCategoryContentAndInfo">
<set field="createMissingCategoryContentAltUrlsMap.contentId" from-field="productCategoryContentAndInfo.contentId"/>
<call-service service-name="createContentAlternativeUrl" in-map-name="createMissingCategoryContentAltUrlsMap">
<result-to-field result-name="contentCreated" field="contentCreated"/>
</call-service>
<if-compare operator="equals" value="Y" field="contentCreated">
<calculate field="contentsUpdated" type="Integer">
<calcop operator="add" field="contentsUpdated">
<number value="1"/>
</calcop>
</calculate>
</if-compare>
<if-compare operator="equals" value="N" field="contentCreated">
<calculate field="contentsNotUpdated" type="Integer">
<calcop operator="add" field="contentsNotUpdated">
<number value="1"/>
</calcop>
</calculate>
</if-compare>
</iterate>
<!-- Create Content Alternative URLs for Product Content -->
<entity-condition entity-name="ProductCategoryMember" list="productCategoryMemberList" filter-by-date="true" use-cache="true">
<condition-list combine="and">
<condition-expr field-name="productCategoryId" from-field="productCategoryList.productCategoryId"/>
</condition-list>
<order-by field-name="-fromDate"/>
</entity-condition>
<iterate list="productCategoryMemberList" entry="productCategoryMember">
<set field="product.productId" from-field="productCategoryMember.productId"/>
<entity-condition entity-name="ProductContentAndInfo" list="productContentAndInfoList" filter-by-date="true" use-cache="true">
<condition-list combine="and">
<condition-expr field-name="productId" from-field="product.productId"/>
<condition-expr field-name="productContentTypeId" operator="not-equals" value="ALTERNATIVE_URL"/>
</condition-list>
<order-by field-name="-fromDate"/>
</entity-condition>
<iterate list="productContentAndInfoList" entry="productContentAndInfo">
<set field="createMissingProductContentAltUrlsMap.contentId" from-field="productContentAndInfo.contentId"/>
<call-service service-name="createContentAlternativeUrl" in-map-name="createMissingProductContentAltUrlsMap">
<result-to-field result-name="contentCreated" field="contentCreated"/>
</call-service>
<if-compare operator="equals" value="Y" field="contentCreated">
<calculate field="contentsUpdated" type="Integer">
<calcop operator="add" field="contentsUpdated">
<number value="1"/>
</calcop>
</calculate>
</if-compare>
<if-compare operator="equals" value="N" field="contentCreated">
<calculate field="contentsNotUpdated" type="Integer">
<calcop operator="add" field="contentsNotUpdated">
<number value="1"/>
</calcop>
</calculate>
</if-compare>
</iterate>
</iterate>
</iterate>
</if-not-empty>
<!-- Create Content Alternative URLs for Website Content -->
<entity-and list="webSiteContents" entity-name="WebSiteContent" filter-by-date="true">
<field-map field-name="webSiteId" from-field="parameters.webSiteId"/>
</entity-and>
<iterate list="webSiteContents" entry="webSiteContent">
<entity-and list="subContents" entity-name="ContentAssoc" filter-by-date="true">
<field-map field-name="contentId" from-field="webSiteContent.contentId"/>
</entity-and>
<iterate list="subContents" entry="subContent">
<set field="createMissingContentAltUrlsMap.contentId" from-field="subContent.contentIdTo"/>
<call-service service-name="createContentAlternativeUrl" in-map-name="createMissingContentAltUrlsMap">
<result-to-field result-name="contentCreated" field="contentCreated"/>
</call-service>
<if-compare operator="equals" value="Y" field="contentCreated">
<calculate field="contentsUpdated" type="Integer">
<calcop operator="add" field="contentsUpdated">
<number value="1"/>
</calcop>
</calculate>
</if-compare>
<if-compare operator="equals" value="N" field="contentCreated">
<calculate field="contentsNotUpdated" type="Integer">
<calcop operator="add" field="contentsNotUpdated">
<number value="1"/>
</calcop>
</calculate>
</if-compare>
<entity-and entity-name="ContentAssoc" list="contentAssocs" filter-by-date="true">
<field-map field-name="contentId" from-field="subContent.contentIdTo"/>
</entity-and>
<iterate list="contentAssocs" entry="contentAssoc">
<set field="createMissingContentAltUrlsMap.contentId" from-field="contentAssoc.contentIdTo"/>
<call-service service-name="createContentAlternativeUrl" in-map-name="createMissingContentAltUrlsMap">
<result-to-field result-name="contentCreated" field="contentCreated"/>
</call-service>
<if-compare operator="equals" value="Y" field="contentCreated">
<calculate field="contentsUpdated" type="Integer">
<calcop operator="add" field="contentsUpdated">
<number value="1"/>
</calcop>
</calculate>
</if-compare>
<if-compare operator="equals" value="N" field="contentCreated">
<calculate field="contentsNotUpdated" type="Integer">
<calcop operator="add" field="contentsNotUpdated">
<number value="1"/>
</calcop>
</calculate>
</if-compare>
</iterate>
</iterate>
</iterate>
<field-to-result field="contentsNotUpdated" result-name="contentsNotUpdated"/>
<field-to-result field="contentsUpdated" result-name="contentsUpdated"/>
</simple-method>
<simple-method method-name="createMissingCategoryContentAltUrlInline" short-description="create missing category alternative inline">
<entity-and entity-name="ProductCategoryRollup" list="productCategoryRollups" filter-by-date="true">
<field-map field-name="parentProductCategoryId" from-field="parameters.parentProductCategoryId"/>
</entity-and>
<iterate list="productCategoryRollups" entry="productCategoryRollup">
<!-- append product category to list -->
<entity-one entity-name="ProductCategory" value-field="productCategory">
<field-map field-name="productCategoryId" from-field="productCategoryRollup.productCategoryId"/>
</entity-one>
<field-to-list list="parameters.productCategories" field="productCategory"/>
<!-- find rollup product categories -->
<set field="parameters.parentProductCategoryId" from-field="productCategoryRollup.productCategoryId"/>
<call-simple-method method-name="createMissingCategoryContentAltUrlInline"/>
<check-errors/>
</iterate>
</simple-method>
</simple-methods>