Author: adrianc
Date: Sat Sep 3 00:38:25 2011 New Revision: 1164773 URL: http://svn.apache.org/viewvc?rev=1164773&view=rev Log: Added two new services - copyWorkEffort and copyWorkEffortAssocs. The copyWorkEffort service can be used as a replacement for the duplicateWorkEffort service. Modified: ofbiz/trunk/applications/workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml ofbiz/trunk/applications/workeffort/servicedef/services.xml Modified: ofbiz/trunk/applications/workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml?rev=1164773&r1=1164772&r2=1164773&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml (original) +++ ofbiz/trunk/applications/workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml Sat Sep 3 00:38:25 2011 @@ -209,6 +209,71 @@ under the License. <remove-value value-field="lookedUpValue"/> </simple-method> + <simple-method method-name="copyWorkEffort" short-description="Copy a WorkEffort"> + <entity-one entity-name="WorkEffort" value-field="sourceWorkEffort"> + <field-map field-name="workEffortId" from-field="parameters.sourceWorkEffortId" /> + </entity-one> + <if-empty field="sourceWorkEffort"> + <set field="errorString" value="sourceWorkEffortId = ${parameters.sourceWorkEffortId}" /> + <add-error> + <fail-property resource="WorkEffortUiLabels" property="WorkEffortNotFound" /> + </add-error> + <check-errors /> + </if-empty> + <set field="targetWorkEffortId" from-field="parameters.targetWorkEffortId" /> + <if-empty field="targetWorkEffortId"> + <sequenced-id sequence-name="WorkEffort" field="targetWorkEffortId" /> + </if-empty> + <set-service-fields service-name="createWorkEffort" to-map="createWorkEffortCtx" map="sourceWorkEffort" /> + <set field="createWorkEffortCtx.workEffortId" from-field="targetWorkEffortId" /> + <set field="createWorkEffortCtx.userLogin" from-field="parameters.userLogin" /> + <call-service service-name="createWorkEffort" in-map-name="createWorkEffortCtx" /> + <check-errors /> + <entity-one entity-name="WorkEffort" value-field="targetWorkEffort"> + <field-map field-name="workEffortId" from-field="targetWorkEffortId" /> + </entity-one> + <set field="copyWorkEffortAssocs" from-field="parameters.copyWorkEffortAssocs" default-value="N" /> + <if-compare field="copyWorkEffortAssocs" operator="equals" value="Y"> + <set-service-fields service-name="copyWorkEffortAssocs" to-map="copyWorkEffortAssocsCtx" map="parameters" /> + <set field="copyWorkEffortAssocsCtx.targetWorkEffortId" from-field="targetWorkEffortId" /> + <call-service service-name="copyWorkEffortAssocs" in-map-name="copyWorkEffortAssocsCtx" /> + <check-errors /> + </if-compare> + <set field="copyRelatedValues" from-field="parameters.copyRelatedValues" default-value="N" /> + <if-compare field="copyRelatedValues" operator="equals" value="Y"> + <set field="excludeExpiredRelations" from-field="parameters.excludeExpiredRelations" default-value="N" /> + <set field="modelRelationList" from-field="groovy:delegator.getModelEntity('WorkEffort').getRelationsManyList();" /> + <iterate entry="modelRelation" list="modelRelationList"> + <set field="relatedEntityName" from-field="groovy:modelRelation.getRelEntityName();" /> + <if-compare field="relatedEntityName" operator="not-equals" value="WorkEffortAssoc"> + <set field="relationName" from-field="groovy:modelRelation.getCombinedName();" /> + <set field="keyMap" from-field="groovy:modelRelation.findKeyMap('workEffortId');" set-if-null="true" /> + <if-not-empty field="keyMap"> + <set field="relatedIdFieldName" from-field="groovy:keyMap.getRelFieldName();" /> + <get-related relation-name="${relationName}" list="relationValues" value-field="sourceWorkEffort" /> + <if-compare field="excludeExpiredRelations" operator="equals" value="Y"> + <set field="fromDateModelField" from-field="groovy:delegator.getModelEntity(relatedEntityName).getField('fromDate');" set-if-null="true" /> + <if-not-empty field="fromDateModelField"> + <filter-list-by-date list="relationValues" /> + </if-not-empty> + </if-compare> + <iterate entry="relatedValue" list="relationValues"> + <clone-value value-field="relatedValue" new-value-field="newRelatedValue" /> + <set field="newRelatedValue[relatedIdFieldName]" from-field="targetWorkEffortId" /> + <make-value value-field="newRelatedPks" entity-name="${relatedEntityName}" /> + <set-pk-fields value-field="newRelatedPks" map="newRelatedValue" /> + <find-by-primary-key entity-name="${relatedEntityName}" map="newRelatedPks" value-field="duplicateCheck" /> + <if-empty field="duplicateCheck"> + <create-value value-field="newRelatedValue" /> + </if-empty> + </iterate> + </if-not-empty> + </if-compare> + </iterate> + </if-compare> + <field-to-result field="targetWorkEffortId" result-name="workEffortId" /> + </simple-method> + <!-- communication event workeffort --> <simple-method method-name="makeCommunicationEventWorkEffort" short-description="Make a Communication Event WorkEffort"> <make-value entity-name="CommunicationEventWorkEff" value-field="lookupMap"/> @@ -676,6 +741,35 @@ under the License. <remove-value value-field="lookedUpValue"/> </simple-method> + <simple-method method-name="copyWorkEffortAssocs" short-description="Copy WorkEffort associations"> + <set field="deepCopy" from-field="parameters.deepCopy" default-value="N" /> + <set field="excludeExpiredAssocs" from-field="parameters.excludeExpiredAssocs" default-value="N" /> + <entity-and entity-name="WorkEffortAssoc" list="workEffortAssocs"> + <field-map field-name="workEffortIdFrom" from-field="parameters.sourceWorkEffortId" /> + </entity-and> + <if-compare field="excludeExpiredAssocs" operator="equals" value="Y"> + <filter-list-by-date list="workEffortAssocs" /> + </if-compare> + <iterate entry="workEffortAssoc" list="workEffortAssocs"> + <set field="workEffortIdTo" from-field="workEffortAssoc.workEffortIdTo" /> + <if-compare field="deepCopy" operator="equals" value="Y"> + <clear-field field="copyWorkEffortCtx" /> + <set-service-fields service-name="copyWorkEffort" to-map="copyWorkEffortCtx" map="parameters" /> + <clear-field field="copyWorkEffortCtx.targetWorkEffortId"/> + <set field="copyWorkEffortCtx.sourceWorkEffortId" from-field="workEffortIdTo" /> + <set field="copyWorkEffortCtx.copyWorkEffortAssocs" value="Y" /> + <call-service service-name="copyWorkEffort" in-map-name="copyWorkEffortCtx"> + <result-to-field result-name="workEffortId" field="workEffortIdTo" /> + </call-service> + <check-errors /> + </if-compare> + <clone-value value-field="workEffortAssoc" new-value-field="newWorkEffortAssoc" /> + <set field="newWorkEffortAssoc.workEffortIdFrom" from-field="parameters.targetWorkEffortId" /> + <set field="newWorkEffortAssoc.workEffortIdTo" from-field="workEffortIdTo" /> + <create-value value-field="newWorkEffortAssoc" /> + </iterate> + </simple-method> + <simple-method method-name="createWorkEffortGoodStandard" short-description="Create a link between a WorkEffort and a Product"> <entity-one entity-name="WorkEffortGoodStandard" value-field="lookedUpValue"/> <if-not-empty field="lookedUpValue"> Modified: ofbiz/trunk/applications/workeffort/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/servicedef/services.xml?rev=1164773&r1=1164772&r2=1164773&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/servicedef/services.xml (original) +++ ofbiz/trunk/applications/workeffort/servicedef/services.xml Sat Sep 3 00:38:25 2011 @@ -86,6 +86,33 @@ under the License. <auto-attributes mode="IN" include="pk" optional="false"/> </service> + <service name="copyWorkEffort" engine="simple" auth="true" transaction-timeout="300" + location="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml" invoke="copyWorkEffort"> + <description>Copies an existing WorkEffort to a new WorkEffort.</description> + <attribute name="sourceWorkEffortId" mode="IN" type="String" optional="false"> + <description>The ID of the WorkEffort to copy from.</description> + </attribute> + <attribute name="targetWorkEffortId" mode="IN" type="String" optional="true"> + <description>The ID of the WorkEffort copy. If empty a new WorkEffort ID will be created.</description> + </attribute> + <attribute name="copyWorkEffortAssocs" mode="IN" type="String" optional="true"> + <description>Copy WorkEffort associations (Y/N). Only child WorkEffort associations will be copied.</description> + </attribute> + <attribute name="deepCopy" mode="IN" type="String" optional="true"> + <description>Copy associated WorkEfforts (Y/N). Used only when copyWorkEffortAssocs = Y.</description> + </attribute> + <attribute name="excludeExpiredAssocs" mode="IN" type="String" optional="true"> + <description>Exclude expired associated WorkEfforts from copying (Y/N). Used only when copyWorkEffortAssocs = Y.</description> + </attribute> + <attribute name="copyRelatedValues" mode="IN" type="String" optional="true"> + <description>Copy WorkEffort related values (Y/N).</description> + </attribute> + <attribute name="excludeExpiredRelations" mode="IN" type="String" optional="true"> + <description>Exclude expired WorkEffort related values from copying (Y/N). Used only when copyRelatedValues = Y.</description> + </attribute> + <attribute name="workEffortId" mode="OUT" type="String" optional="false" /> + </service> + <service name="duplicateWorkEffort" engine="simple" location="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml" invoke="duplicateWorkEffort" auth="true"> <description>Duplicate a Work Effort. If workEffortId is empty a new workEffortId will be generated.</description> @@ -301,6 +328,30 @@ under the License. <permission-service service-name="workEffortGenericPermission" main-action="UPDATE"/> <auto-attributes include="pk" mode="IN" optional="false"/> </service> + + <service name="copyWorkEffortAssocs" engine="simple" auth="true" transaction-timeout="300" + location="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml" invoke="copyWorkEffortAssocs"> + <description>Copies WorkEffortAssocs from one WorkEffort to another WorkEffort. Only child WorkEffort associations will be copied.</description> + <attribute name="sourceWorkEffortId" mode="IN" type="String" optional="false"> + <description>The ID of the WorkEffort to copy the associations from.</description> + </attribute> + <attribute name="targetWorkEffortId" mode="IN" type="String" optional="true"> + <description>The ID of the WorkEffort to copy the associations to.</description> + </attribute> + <attribute name="deepCopy" mode="IN" type="String" optional="true"> + <description>Copy associated WorkEfforts (Y/N).</description> + </attribute> + <attribute name="excludeExpiredAssocs" mode="IN" type="String" optional="true"> + <description>Exclude expired WorkEffort associations from copying (Y/N).</description> + </attribute> + <attribute name="copyRelatedValues" mode="IN" type="String" optional="true"> + <description>Copy WorkEffort related values (Y/N). Used only when deepCopy = Y.</description> + </attribute> + <attribute name="excludeExpiredRelations" mode="IN" type="String" optional="true"> + <description>Exclude expired WorkEffort related values from copying (Y/N). Used only when deepCopy = Y.</description> + </attribute> + </service> + <service name="createWorkEffortAndAssoc" engine="simple" location="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml" invoke="createWorkEffortAndAssoc" auth="true"> <description>Creates a WorkEffort entity and WorkEffortAssoc</description> <auto-attributes include="pk" mode="INOUT" optional="true" entity-name="WorkEffort"/> |
Free forum by Nabble | Edit this page |