[OFBiz] SVN: r6751 - in trunk/applications/content: script/org/ofbiz/content/compdoc servicedef src/org/ofbiz/content webapp/content/WEB-INF widget/compdoc
byersa@svn.ofbiz.org
byersa at svn.ofbiz.org
Thu Feb 16 13:02:00 CST 2006
Author: byersa
Date: 2006-02-16 13:01:49 -0600 (Thu, 16 Feb 2006)
New Revision: 6751
Modified:
trunk/applications/content/script/org/ofbiz/content/compdoc/CompDocServices.xml
trunk/applications/content/servicedef/services.xml
trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java
trunk/applications/content/webapp/content/WEB-INF/controller.xml
trunk/applications/content/widget/compdoc/CompDocForms.xml
trunk/applications/content/widget/compdoc/CompDocMenus.xml
trunk/applications/content/widget/compdoc/CompDocScreens.xml
Log:
Upgraded cloneContentApprovals service to instantiate instance approvals from
the template approvals, if the instance approvals do not exist.
Add permission checking to persistDataResourceAndData service.
Modified: trunk/applications/content/script/org/ofbiz/content/compdoc/CompDocServices.xml
===================================================================
--- trunk/applications/content/script/org/ofbiz/content/compdoc/CompDocServices.xml 2006-02-16 17:38:39 UTC (rev 6750)
+++ trunk/applications/content/script/org/ofbiz/content/compdoc/CompDocServices.xml 2006-02-16 19:01:49 UTC (rev 6751)
@@ -509,8 +509,20 @@
<entity-one entity-name="Content" value-name="content">
<field-map field-name="contentId" env-name="parameters.contentId"/>
</entity-one>
- <set from-field="parameters.previousContentRevisionSeqId" field="previousContentRevisionSeqId" />
- <if-empty field-name="previousContentRevisionSeqId">
+ <set from-field="parameters.contentId" field="thisContentId" />
+ <set from-field="parameters.contentRevisionSeqId" field="thisContentRevisionSeqId" />
+ <log level="info" message="cloneContentApprovals(0)- previousContentRevisionSeqId : ${previousContentRevisionSeqId} "/>
+ <entity-condition entity-name="ContentRevision" list-name="contentRevisionList" use-cache="true">
+ <condition-list>
+ <condition-expr field-name="contentId" env-name="parameters.contentId" operator="equals"/>
+ <condition-expr field-name="contentRevisionSeqId" env-name="thisContentRevisionSeqId" operator="less"/>
+ </condition-list>
+ <order-by field-name="-contentRevisionSeqId"/>
+ </entity-condition>
+ <set from-field="contentRevisionList[0].contentRevisionSeqId" field="previousContentRevisionSeqId" />
+ <log level="info" message="cloneContentApprovals(1)- previousContentRevisionSeqId : ${previousContentRevisionSeqId} "/>
+
+ <!--
<calculate field-name="previousContentRevisionSeqId" type="Long">
<calcop operator="add">
<calcop operator="get" field-name="parameters.contentRevisionSeqId" />
@@ -525,16 +537,16 @@
<field field-name="previousContentRevisionSeqId" type="Long"/>
<field field-name="numericPadding" type="Integer" />
</call-class-method>
- </if-empty>
+ -->
<!-- get previous list of ContentApproval -->
<entity-and entity-name="ContentApproval" list-name="contentApprovalList">
- <field-map field-name="contentId" env-name="parameters.contentId"/>
+ <field-map field-name="contentId" env-name="thisContentId"/>
<field-map field-name="contentRevisionSeqId" env-name="previousContentRevisionSeqId"/>
</entity-and>
<!-- determine status of previous approvals -->
-
+ <!-- primaryApprovalStatusId is the applicable status from previous approvals -->
<set value="CNTAP_IN_PROCESS" field="primaryApprovalStatusId"/>
<iterate list-name="contentApprovalList" entry-name="existingContentApproval">
<set from-field="existingContentApproval.approvalStatusId" field="approvalStatusId"/>
@@ -577,12 +589,14 @@
</else-if>
</if>
</iterate>
+ <log level="info" message="cloneContentApprovals(2)- primaryApprovalStatusId : ${primaryApprovalStatusId} "/>
+ <log level="info" message="cloneContentApprovals(2)- contentApprovalList : ${contentApprovalList} "/>
<!-- conditionally set the contentApprovalId status of each entity -->
<iterate list-name="contentApprovalList" entry-name="existingContentApproval">
<clone-value value-name="existingContentApproval" new-value-name="contentApproval"/>
<log level="info" message="contentApproval 0: ${contentApproval}"/>
- <set from-field="parameters.contentRevisionSeqId" field="contentApproval.contentRevisionSeqId" />
+ <set from-field="thisContentRevisionSeqId" field="contentApproval.contentRevisionSeqId" />
<clear-field field-name="contentApproval.contentApprovalId" />
<log level="info" message="contentApproval 1: ${contentApproval}"/>
<make-next-seq-id seq-field-name="contentApprovalId" value-name="contentApproval"/>
@@ -640,6 +654,47 @@
<create-value value-name="contentApproval"/>
</iterate>
+
+ <!-- if an instance track, check to see if there any new or deleted records on the template -->
+ <if-compare field-name="content.contentTypeId" operator="equals" value="COMPDOC_INSTANCE">
+ <set from-field="content.instanceOfContentId" field="rootTemplateContentId" />
+ <entity-condition entity-name="ContentRevision" list-name="templateContentRevisionList" use-cache="true">
+ <condition-list>
+ <condition-expr field-name="contentId" env-name="rootTemplateContentId" operator="equals"/>
+ </condition-list>
+ <order-by field-name="-contentRevisionSeqId"/>
+ </entity-condition>
+ <set from-field="templateContentRevisionList[0].contentRevisionSeqId" field="latestContentRevisionSeqId" />
+ <entity-and entity-name="ContentApproval" list-name="templateContentApprovalList">
+ <field-map field-name="contentId" env-name="rootTemplateContentId"/>
+ <field-map field-name="contentRevisionSeqId" env-name="latestContentRevisionSeqId"/>
+ </entity-and>
+ <iterate list-name="templateContentApprovalList" entry-name="templateContentApproval">
+ <!-- look for this entity in newly created entities -->
+ <entity-condition entity-name="ContentApproval" list-name="newContentApprovalList">
+ <condition-list combine="and">
+ <condition-expr field-name="contentId" operator="equals" env-name="thisContentId"/>
+ <condition-expr field-name="contentRevisionSeqId" operator="equals" env-name="thisContentRevisionSeqId"/>
+ <condition-expr field-name="partyId" operator="equals" env-name="templateContentApproval.partyId" ignore-if-empty="false"/>
+ <condition-expr field-name="roleTypeId" operator="equals" env-name="templateContentApproval.roleTypeId" ignore-if-empty="false"/>
+ </condition-list>
+ </entity-condition>
+ <if-empty field-name="newContentApprovalList">
+ <clone-value value-name="templateContentApproval" new-value-name="contentApproval"/>
+ <log level="info" message="contentApproval 0b: ${contentApproval}"/>
+ <set from-field="thisContentRevisionSeqId" field="contentApproval.contentRevisionSeqId" />
+ <set from-field="thisContentId" field="contentApproval.contentId" />
+ <clear-field field-name="contentApproval.contentApprovalId" />
+ <log level="info" message="contentApproval 1b: ${contentApproval}"/>
+ <make-next-seq-id seq-field-name="contentApprovalId" value-name="contentApproval"/>
+ <set value="CNTAP_READY" field="contentApproval.approvalStatusId" />
+ <log level="info" message="contentApproval 2b: ${contentApproval}"/>
+ <create-value value-name="contentApproval"/>
+ </if-empty>
+ </iterate>
+
+ <!-- TODO: remove instance approvals that have been deleted from the template set -->
+ </if-compare>
</simple-method>
<simple-method method-name="hasApprovalPermission" short-description="Determine ContentApproval permission from passed value">
Modified: trunk/applications/content/servicedef/services.xml
===================================================================
--- trunk/applications/content/servicedef/services.xml 2006-02-16 17:38:39 UTC (rev 6750)
+++ trunk/applications/content/servicedef/services.xml 2006-02-16 19:01:49 UTC (rev 6751)
@@ -835,6 +835,35 @@
<attribute mode="INOUT" name="roleTypeList" optional="true" type="List"/>
</service>
+ <service name="persistDataResourceAndData" engine="java"
+ transaction-timout="72000"
+ location="org.ofbiz.content.ContentManagementServices" invoke="persistContentAndAssoc" auth="true">
+ <description>Persist a DataResource and data</description>
+ <auto-attributes entity-name="DataResource" include="all" mode="IN" optional="true">
+ <exclude field-name="dataResourceId"/>
+ </auto-attributes>
+ <auto-attributes entity-name="ElectronicText" include="all" mode="IN" optional="true">
+ <exclude field-name="dataResourceId"/>
+ </auto-attributes>
+ <attribute mode="INOUT" entity-name="Content" name="contentId" optional="true" type="String"/>
+ <attribute mode="INOUT" entity-name="DataResource" name="dataResourceId" optional="true" type="String"/>
+
+ <attribute mode="INOUT" entity-name="DataResource" name="drDataResourceId" optional="true" type="String"/>
+ <attribute mode="IN" name="rootDir" optional="true" type="String"/>
+ <attribute mode="IN" name="targetOperationList" optional="true" type="List"/>
+ <attribute mode="IN" name="contentPurposeList" optional="true" type="List"/>
+ <!-- it was a mistake to pass in List objects because it makes it difficult to use
+ the service in a request event, so I added new ones without removing lists -->
+ <attribute mode="IN" name="targetOperationString" optional="true" type="String"/>
+ <attribute mode="IN" name="contentPurposeString" optional="true" type="String"/>
+ <attribute mode="IN" name="userLogin" optional="true" type="GenericValue"/>
+ <attribute mode="IN" name="imageData" optional="true" type="org.ofbiz.entity.util.ByteWrapper"/>
+ <attribute mode="IN" name="_imageData_contentType" optional="true" type="String"/>
+ <attribute mode="IN" name="_imageData_fileName" optional="true" type="String"/>
+ <attribute mode="IN" name="forceElectronicText" optional="true" type="String"/>
+ <attribute mode="IN" name="displayFailCond" optional="true" type="Boolean"/>
+ </service>
+
<service name="persistContentWithRevision" engine="java"
transaction-timout="72000"
location="org.ofbiz.content.ContentManagementServices" invoke="persistContentWithRevision" auth="true">
Modified: trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java
===================================================================
--- trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java 2006-02-16 17:38:39 UTC (rev 6750)
+++ trunk/applications/content/src/org/ofbiz/content/ContentManagementServices.java 2006-02-16 19:01:49 UTC (rev 6751)
@@ -575,9 +575,19 @@
public static Map persistDataResourceAndData(DispatchContext dctx, Map context) {
+ GenericDelegator delegator = dctx.getDelegator();
+ LocalDispatcher dispatcher = dctx.getDispatcher();
+ String contentId = (String)context.get("contentId");
Map result = new HashMap();
try {
- result = persistDataResourceAndDataMethod(dctx, context);
+ GenericValue content = delegator.findByPrimaryKey("Content", UtilMisc.toMap("contentId", contentId));
+ ModelService checkPermModel = dispatcher.getDispatchContext().getModelService("checkContentPermission");
+ Map ctx = checkPermModel.makeValid(context, "IN");
+ Map thisResult = dispatcher.runSync("checkContentPermission", ctx);
+ String permissionStatus = (String)thisResult.get("permissionStatus");
+ if (UtilValidate.isNotEmpty(permissionStatus) && permissionStatus.equalsIgnoreCase("granted")) {
+ result = persistDataResourceAndDataMethod(dctx, context);
+ }
} catch (GenericServiceException e) {
return ServiceUtil.returnError(e.getMessage());
} catch (GenericEntityException e) {
Modified: trunk/applications/content/webapp/content/WEB-INF/controller.xml
===================================================================
--- trunk/applications/content/webapp/content/WEB-INF/controller.xml 2006-02-16 17:38:39 UTC (rev 6750)
+++ trunk/applications/content/webapp/content/WEB-INF/controller.xml 2006-02-16 19:01:49 UTC (rev 6751)
@@ -1058,6 +1058,17 @@
<response name="success" type="view" value="EditCompDoc"/>
<response name="error" type="view" value="EditCompDoc"/>
</request-map>
+ <request-map uri="uploadCompDocContent">
+ <security auth="true" https="true"/>
+ <event invoke="persistDataResourceAndData" path="" type="service"/>
+ <response name="success" type="view" value="ViewCompDocContent"/>
+ <response name="error" type="view" value="ViewCompDocContent"/>
+ </request-map>
+ <request-map uri="ViewCompDocContent">
+ <security auth="true" https="true"/>
+ <response name="success" type="view" value="ViewCompDocContent"/>
+ <response name="error" type="view" value="ViewCompDocContent"/>
+ </request-map>
<request-map uri="updateChildCompDocInstance">
<security auth="true" https="true"/>
<event invoke="persistCompDoc" path="" type="service"/>
@@ -1740,6 +1751,7 @@
<view-map name="EditRootCompDocContent" page="component://content/widget/compdoc/CompDocScreens.xml#EditRootCompDocContent" type="screen"/>
<view-map name="EditCompDocContentRole" page="component://content/widget/compdoc/CompDocScreens.xml#EditCompDocContentRole" type="screen"/>
<view-map name="ViewInstances" page="component://content/widget/compdoc/CompDocScreens.xml#ViewInstances" type="screen"/>
+ <view-map name="ViewCompDocContent" page="component://content/widget/compdoc/CompDocScreens.xml#ViewCompDocContent" type="screen"/>
<view-map name="ViewSimpleContent" page="" type="simplecontent"/>
<!-- end of view mappings -->
Modified: trunk/applications/content/widget/compdoc/CompDocForms.xml
===================================================================
--- trunk/applications/content/widget/compdoc/CompDocForms.xml 2006-02-16 17:38:39 UTC (rev 6750)
+++ trunk/applications/content/widget/compdoc/CompDocForms.xml 2006-02-16 19:01:49 UTC (rev 6751)
@@ -485,5 +485,16 @@
<hyperlink also-hidden="false" description="[Create]" target="EditContentRevisionItem"/>
</field>
</form>
+
+ <form name="UploadCompDocContent" type="upload" default-title-style="tableheadtext"
+ extends="dummy" target="uploadCompDocContent"
+ default-tooltip-style="tabletext" default-widget-style="tabletext" >
+ <field name="contentId" map-name="content"><hidden/></field>
+ <field name="dataResourceId" map-name="dataResource"><hidden/></field>
+ <field name="dataResourceTypeId" map-name="dataResource"><hidden/></field>
+ <field name="mimeTypeId" map-name="dataResource"><hidden/></field>
+ <field name="imageData" title="Browse"><file/></field>
+ <field name="submitButton" title="Upload" widget-style="smallSubmit"><submit/></field>
+ </form>
</forms>
Modified: trunk/applications/content/widget/compdoc/CompDocMenus.xml
===================================================================
--- trunk/applications/content/widget/compdoc/CompDocMenus.xml 2006-02-16 17:38:39 UTC (rev 6750)
+++ trunk/applications/content/widget/compdoc/CompDocMenus.xml 2006-02-16 19:01:49 UTC (rev 6751)
@@ -211,8 +211,11 @@
selected-menuitem-context-field-name="currentMenuItemName"
title="" type="simple">
<menu-item name="edit-inplace" title="${contentName}[${rootInstanceContentId}]" >
- <link target="EditRootComp?contentId=${rootInstanceContentId}&instanceOfContentId=${contentId}&currentContentTypeId=COMPDOC_INSTANCE"/>
+ <link target="EditCompDoc?contentId=${rootInstanceContentId}&contentRevisionSeqId=${contentRevisionSeqId}&rootInstanceRevSeqId=${rootInstanceRevSeqId}&rootTemplateRevSeqId=${rootTemplateRevSeqId}&rootTemplateContentId=${rootTemplateContentId}&rootInstanceContentId=${rootInstanceContentId}"/>
</menu-item>
+ <menu-item name="edit" title="[Edit]" >
+ <link target="EditCompDoc?contentId=${rootInstanceContentId}&contentRevisionSeqId=${contentRevisionSeqId}&rootInstanceRevSeqId=${rootInstanceRevSeqId}&rootTemplateRevSeqId=${rootTemplateRevSeqId}&rootTemplateContentId=${rootTemplateContentId}&rootInstanceContentId=${rootInstanceContentId}"/>
+ </menu-item>
<menu-item name="viewtree" title="View Template Tree">
<link target="ViewCompDocTemplateTree?rootTemplateRevSeqId=${rootTemplateRevSeqId}&rootTemplateContentId=${contentId}"/>
</menu-item>
Modified: trunk/applications/content/widget/compdoc/CompDocScreens.xml
===================================================================
--- trunk/applications/content/widget/compdoc/CompDocScreens.xml 2006-02-16 17:38:39 UTC (rev 6750)
+++ trunk/applications/content/widget/compdoc/CompDocScreens.xml 2006-02-16 19:01:49 UTC (rev 6751)
@@ -389,6 +389,15 @@
<decorator-screen name="commonCompDocDecorator" location="component://content/widget/CommonScreens.xml">
<decorator-section name="body">
<include-form name="EditChildCompDoc" location="component://content/widget/compdoc/CompDocForms.xml"/>
+ <section>
+ <condition>
+ <not><if-empty field-name="dataResource.dataResourceTypeId"/></not>
+ </condition>
+ <widgets>
+ <link target="ViewCompDocContent?contentId=${content.contentId}&contentRevisionSeqId=${contentRevisionSeqId}&rootTemplateContentId=${rootTemplateContentId}&rootTemplateRevSeqId=${rootTemplateRevSeqId}&rootInstanceContentId=${rootInstanceContentId}&rootInstanceRevSeqId=${rootInstanceRevSeqId}" text="View CompDoc Content" style="buttontext"/>
+ <include-form name="UploadCompDocContent" location="component://content/widget/compdoc/CompDocForms.xml"/>
+ </widgets>
+ </section>
</decorator-section>
</decorator-screen>
</widgets>
@@ -410,7 +419,7 @@
</condition-list>
<select-field field-name="rootRevisionContentId"/>
- <select-field field-name="itemContentId"/>
+ <select-field fieldViewCompDocContent-name="itemContentId"/>
<select-field field-name="maxRevisionSeqId"/>
<order-by field-name="-maxRevisionSeqId"/>
@@ -421,6 +430,15 @@
<decorator-screen name="commonCompDocDecorator" location="component://content/widget/CommonScreens.xml">
<decorator-section name="body">
<include-form name="EditChildCompDoc" location="component://content/widget/compdoc/CompDocForms.xml"/>
+ <section>
+ <condition>
+ <not><if-empty field-name="dataResource.dataResourceTypeId"/></not>
+ </condition>
+ <widgets>
+ <link target="ViewCompDocContent?contentId=${content.contentId}&contentRevisionSeqId=${contentRevisionSeqId}&rootTemplateContentId=${rootTemplateContentId}&rootTemplateRevSeqId=${rootTemplateRevSeqId}&rootInstanceContentId=${rootInstanceContentId}&rootInstanceRevSeqId=${rootInstanceRevSeqId}" text="View CompDoc Content" style="buttontext"/>
+ <include-form name="UploadCompDocContent" location="component://content/widget/compdoc/CompDocForms.xml"/>
+ </widgets>
+ </section>
</decorator-section>
</decorator-screen>
</widgets>
@@ -860,4 +878,39 @@
</section>
</screen>
+ <screen name="ViewCompDocContent">
+ <section>
+ <actions>
+ <entity-one entity-name="Content" value-name="content" use-cache="true"/>
+ <entity-one entity-name="DataResource" value-name="dataResource" use-cache="true">
+ <field-map field-name="dataResourceId" env-name="content.dataResourceId"/>
+ </entity-one>
+ </actions>
+ <widgets>
+ <section>
+ <condition>
+ <or>
+ <if-compare field-name="dataResource.dataResourceTypeId" operator="equals" value="SURVEY"/>
+ <if-compare field-name="dataResource.dataResourceTypeId" operator="equals" value="SURVEY_RESPONSE"/>
+ </or>
+ </condition>
+ <widgets>
+ </widgets>
+ </section>
+ <section>
+ <condition>
+ <not>
+ <or>
+ <if-compare field-name="dataResource.dataResourceTypeId" operator="equals" value="SURVEY"/>
+ <if-compare field-name="dataResource.dataResourceTypeId" operator="equals" value="SURVEY_RESPONSE"/>
+ </or>
+ </not>
+ </condition>
+ <widgets>
+ </widgets>
+ </section>
+ </widgets>
+ </section>
+ </screen>
+
</screens>
More information about the Svn
mailing list