| <?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="createBlogEntry" short-description="Create a new Blog Entry"> |
| <set field="contentAssocTypeId" value="PUBLISH_LINK"/> |
| <set field="ownerContentId" from-field="parameters.blogContentId"/> |
| <set field="contentIdFrom" from-field="parameters.blogContentId"/> |
| <if-empty field="parameters.statusId"> |
| <set field="parameters.statusId" value="CTNT_INITIAL_DRAFT"/> |
| </if-empty> |
| <if-empty field="parameters.templateDataResourceId"> |
| <set field="parameters.templateDataResourceId" value="BLOG_TPL_TOPLEFT"/> |
| </if-empty> |
| |
| <!-- determine of we need to create complex template structure or simple content structure --> |
| <if-empty field="parameters.contentName"> |
| <add-error> |
| <fail-property resource="ContentUiLabels" property="ContentArticleNameIsMissing"/> |
| </add-error> |
| </if-empty> |
| <check-errors/> |
| <!-- complex template structure (image & text) --> |
| <set field="createMain.dataResourceId" from-field="parameters.templateDataResourceId"/> |
| <set field="createMain.contentAssocTypeId" from-field="contentAssocTypeId"/> |
| <set field="createMain.contentName" from-field="parameters.contentName"/> |
| <set field="createMain.description" from-field="parameters.description"/> |
| <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"/> |
| |
| <if-not-empty field="parameters._uploadedFile_fileName"> |
| <!-- upload a picture --> |
| <set field="createImage.dataResourceTypeId" value="LOCAL_FILE"/> |
| <set field="createImage.dataTemplateTypeId" value="NONE"/> |
| <set field="createImage.mapKey" value="IMAGE"/> |
| <set field="createImage.ownerContentId" from-field="ownerContentId"/> |
| <set field="createImage.contentName" from-field="parameters.contentName"/> |
| <set field="createImage.description" from-field="parameters.description"/> |
| <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.isPublic" value="Y"/> |
| <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-not-empty> |
| |
| <if-not-empty field="parameters.articleData"> |
| <!-- create text data --> |
| <set field="createText.dataResourceTypeId" value="ELECTRONIC_TEXT"/> |
| <set field="createText.contentPurposeTypeId" value="ARTICLE"/> |
| <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="parameters.description"/> |
| <set field="createText.statusId" from-field="parameters.statusId"/> |
| <set field="createText.contentAssocTypeId" from-field="contentAssocTypeId"/> |
| <set field="createText.textData" from-field="parameters.articleData"/> |
| <set field="createText.contentIdFrom" from-field="contentIdFrom"/> |
| <set field="createText.partyId" from-field="userLogin.partyId"/> |
| <set field="createText.mapKey" value="ARTICLE"/> |
| <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-not-empty> |
| |
| <if-not-empty field="contentId"> |
| <if-not-empty field="parameters.summaryData"> |
| <!-- create the summary data --> |
| <set field="createSummary.dataResourceTypeId" value="ELECTRONIC_TEXT"/> |
| <set field="createSummary.contentPurposeTypeId" value="ARTICLE"/> |
| <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"/> |
| </if-not-empty> |
| </if-not-empty> |
| |
| <field-to-result field="contentIdFrom" result-name="contentId"/> |
| <field-to-result field="parameters.blogContentId" result-name="blogContentId"/> |
| </simple-method> |
| |
| <simple-method method-name="updateBlogEntry" short-description="Update a existing Blog Entry"> |
| <set field="showNoResult" value="Y"/> |
| <call-simple-method method-name="getBlogEntry"/> |
| <if> |
| <condition> |
| <or> |
| <if-compare-field field="parameters.contentName" operator="not-equals" to-field="contentName"/> |
| <if-compare-field field="parameters.description" operator="not-equals" to-field="description"/> |
| <if-compare-field field="parameters.summaryData" operator="not-equals" to-field="summaryData"/> |
| <if-compare-field field="parameters.templateDataResourceId" operator="not-equals" to-field="templateDataResourceId"/> |
| <if-compare-field field="parameters.statusId" operator="not-equals" to-field="statusId"/> |
| </or> |
| </condition> |
| <then> |
| <set-service-fields service-name="updateContent" map="parameters" to-map="updContent"/> |
| <set field="updContent.dataResourceId" from-field="parameters.templateDataResourceId"/> |
| <call-service service-name="updateContent" in-map-name="updContent"/> |
| <if-compare-field field="parameters.statusId" operator="not-equals" to-field="statusId"> |
| <if-not-empty field="imageContent"> |
| <set field="imageContent.status.Id" from-field="parameters.statusId"/> |
| <store-value value-field="imageContent"/> |
| </if-not-empty> |
| </if-compare-field> |
| </then> |
| </if> |
| |
| <!-- new article text --> |
| <if-empty field="articleText"> |
| <if-not-empty field="parameters.articleData"> |
| <set field="ownerContentId" from-field="parameters.blogContentId"/> |
| <set field="contentAssocTypeId" value="SUB_CONTENT"/> |
| <set field="contentIdFrom" from-field="contentId"/> |
| <set field="createText.dataResourceTypeId" value="ELECTRONIC_TEXT"/> |
| <set field="createText.contentPurposeTypeId" value="ARTICLE"/> |
| <set field="createText.dataTemplateTypeId" value="NONE"/> |
| <set field="createText.mapKey" value="ARTICLE"/> |
| <set field="createText.ownerContentId" from-field="ownerContentId"/> |
| <set field="createText.contentName" from-field="parameters.contentName"/> |
| <set field="createText.description" from-field="parameters.description"/> |
| <set field="createText.statusId" from-field="parameters.statusId"/> |
| <set field="createText.contentAssocTypeId" from-field="contentAssocTypeId"/> |
| <set field="createText.textData" from-field="parameters.articleData"/> |
| <set field="createText.contentIdFrom" from-field="contentIdFrom"/> |
| <set field="createText.partyId" from-field="userLogin.partyId"/> |
| <call-service service-name="createTextContent" in-map-name="createText"/> |
| </if-not-empty> |
| </if-empty> |
| |
| <!-- update article text --> |
| <if-not-empty field="articleText"> |
| <if-compare-field field="parameters.articleData" operator="not-equals" to-field="articleData"> |
| <set field="articleText.textData" from-field="parameters.articleData"/> |
| <store-value value-field="articleText"/> |
| </if-compare-field> |
| </if-not-empty> |
| |
| <!-- create summary text --> |
| <if-empty field="summaryData"> |
| <if-not-empty field="parameters.summaryData"> |
| <!-- create the summary data --> |
| <set field="ownerContentId" from-field="parameters.blogContentId"/> |
| <set field="contentAssocTypeId" value="SUB_CONTENT"/> |
| <set field="contentIdFrom" from-field="contentId"/> |
| <set field="createSummary.dataResourceTypeId" value="ELECTRONIC_TEXT"/> |
| <set field="createSummary.contentPurposeTypeId" value="ARTICLE"/> |
| <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"/> |
| </if-not-empty> |
| </if-empty> |
| |
| <!-- update summary text --> |
| <if-not-empty field="summaryData"> |
| <if-compare-field field="parameters.summaryData" operator="not-equals" to-field="summaryData"> |
| <set field="summaryText.textData" from-field="parameters.summaryData"/> |
| <store-value value-field="summaryText"/> |
| </if-compare-field> |
| </if-not-empty> |
| |
| <if-not-empty field="parameters._uploadedFile_fileName"> |
| <if-not-empty field="imageContent"> |
| <entity-and entity-name="ContentAssoc" list="oldAssocs" filter-by-date="true"> |
| <field-map field-name="contentId" from-field="contentId"/> |
| <field-map field-name="contentIdTo" from-field="imageContent.contentId"/> |
| <field-map field-name="mapKey" value="IMAGE"/> |
| </entity-and> |
| <first-from-list list="oldAssocs" entry="oldAssoc"/> |
| <now-timestamp field="oldAssoc.thruDate"/> |
| <store-value value-field="oldAssoc"/> |
| </if-not-empty> |
| <!-- upload a picture --> |
| <set field="createImage.dataResourceTypeId" value="LOCAL_FILE"/> |
| <set field="createImage.dataTemplateTypeId" value="NONE"/> |
| <set field="createImage.mapKey" value="IMAGE"/> |
| <set field="createImage.ownerContentId" from-field="parameters.contentId"/> |
| <set field="createImage.contentName" from-field="parameters.contentName" default-value="${contentName}"/> |
| <set field="createImage.description" from-field="parameters.description" default-value="${description}"/> |
| <set field="createImage.statusId" from-field="parameters.statusId" default-value="${statusId}"/> |
| <set field="createImage.contentAssocTypeId" value="SUB_CONTENT"/> |
| <set field="createImage.contentIdFrom" from-field="parameters.contentId"/> |
| <set field="createImage.partyId" from-field="userLogin.partyId"/> |
| <set field="createImage.isPublic" value="Y"/> |
| <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"/> |
| </if-not-empty> |
| <field-to-result field="parameters.contentId" result-name="contentId"/> |
| <field-to-result field="parameters.blogContentId" result-name="blogContentId"/> |
| </simple-method> |
| |
| <simple-method method-name="getOwnedOrPublishedBlogEntries" short-description="Get blog entries that the user owns or are published"> |
| <entity-condition entity-name="ContentAssocViewTo" use-cache="false" list="unfilteredList"> |
| <condition-list combine="and"> |
| <condition-expr field-name="contentIdStart" operator="equals" from-field="parameters.contentId"/> |
| <condition-expr field-name="caContentAssocTypeId" operator="equals" value="PUBLISH_LINK"/> |
| </condition-list> |
| <order-by field-name="caFromDate DESC"/> |
| </entity-condition> |
| <filter-list-by-date list="unfilteredList" to-list="blogItems"/> |
| <set field="blogList[]"/> |
| <iterate list="blogItems" entry="blogItem"> |
| <set-service-fields service-name="genericContentPermission" map="blogItem" to-map="mapIn"/> |
| <set field="mapIn.ownerContentId" from-field="parameters.contentId"/> |
| <set field="mapIn.mainAction" value="VIEW"/> |
| <call-service service-name="genericContentPermission" in-map-name="mapIn"> |
| <result-to-field result-name="hasPermission" field="hasPermission"/> |
| </call-service> |
| <if-compare field="hasPermission" operator="equals" value="true" type="Boolean"> |
| <set field="blogList[]" from-field="blogItem"/> |
| <else> |
| <set field="mapIn.mainAction" value="UPDATE"/> |
| <call-service service-name="genericContentPermission" in-map-name="mapIn"> |
| <result-to-field result-name="hasPermission" field="hasPermission"/> |
| </call-service> |
| <if-compare field="hasPermission" operator="equals" value="true" type="Boolean"> |
| <set field="blogList[]" from-field="blogItem"/> |
| </if-compare> |
| </else> |
| </if-compare> |
| </iterate> |
| <field-to-result field="blogList" result-name="blogList"/> |
| <field-to-result field="parameters.blogContentId" result-name="blogContentId"/> |
| </simple-method> |
| |
| <simple-method method-name="getBlogEntry" short-description="Get all the info for a blog article"> |
| <if-empty field="parameters.contentId"> |
| <field-to-result field="parameters.blogContentId" result-name="blogContentId"/> |
| <return/> |
| </if-empty> |
| <entity-one entity-name="Content" value-field="content"/> |
| <get-related value-field="content" relation-name="FromContentAssoc" list="rawAssocs"/> |
| <filter-list-by-date list="rawAssocs" to-list="assocs"/> |
| <iterate list="assocs" entry="assoc"> |
| <if-compare field="assoc.mapKey" value="ARTICLE" operator="equals"> |
| <get-related-one value-field="assoc" relation-name="ToContent" to-value-field="mainContent"/> |
| <get-related-one value-field="mainContent" relation-name="DataResource" to-value-field="dataResource"/> |
| <get-related-one value-field="dataResource" relation-name="ElectronicText" to-value-field="articleText"/> |
| </if-compare> |
| <if-compare field="assoc.mapKey" value="SUMMARY" operator="equals"> |
| <get-related-one value-field="assoc" relation-name="ToContent" to-value-field="summaryContent"/> |
| <get-related-one value-field="summaryContent" relation-name="DataResource" to-value-field="dataResource"/> |
| <get-related-one value-field="dataResource" relation-name="ElectronicText" to-value-field="summaryText"/> |
| </if-compare> |
| <if-compare field="assoc.mapKey" value="IMAGE" operator="equals"> |
| <get-related-one value-field="assoc" relation-name="ToContent" to-value-field="imageContent"/> |
| </if-compare> |
| </iterate> |
| <if-empty field="showNoResult"> |
| <field-to-result field="content.contentId" result-name="contentId"/> |
| <field-to-result field="content.contentName" result-name="contentName"/> |
| <field-to-result field="content.description" result-name="description"/> |
| <field-to-result field="content.statusId" result-name="statusId"/> |
| <if-not-empty field="imageContent"> |
| <field-to-result field="content.dataResourceId" result-name="templateDataResourceId"/> |
| </if-not-empty> |
| <field-to-result field="articleText.textData" result-name="articleData"/> |
| <field-to-result field="summaryText.textData" result-name="summaryData"/> |
| <field-to-result field="imageContent.contentId" result-name="imageContentId"/> |
| <field-to-result field="mainContent.contentId" result-name="articleContentId"/> |
| <field-to-result field="summaryContent.contentId" result-name="summaryContentId"/> |
| <field-to-result field="parameters.blogContentId" result-name="blogContentId"/> |
| <else> |
| <set from-field="content.contentId" field="contentId"/> |
| <set from-field="content.contentName" field="contentName"/> |
| <set from-field="content.description" field="description"/> |
| <set from-field="content.statusId" field="statusId"/> |
| <set from-field="content.dataResourceId" field="templateDataResourceId"/> |
| <set from-field="articleText.textData" field="articleData"/> |
| <set from-field="summaryText.textData" field="summaryData"/> |
| <set from-field="imageContent.dataResourceId" field="imageDataResourceId"/> |
| </else> |
| </if-empty> |
| </simple-method> |
| |
| </simple-methods> |