Author: jonesde
Date: Thu Jul 24 00:08:10 2008 New Revision: 679288 URL: http://svn.apache.org/viewvc?rev=679288&view=rev Log: Expanded entity-auto engine to support auto fromDate; a bunch more changes to example component services to eliminate implementations possible so far; now there are just a few left Added: ofbiz/trunk/framework/example/servicedef/secas.xml (with props) Removed: ofbiz/trunk/framework/example/script/org/ofbiz/example/feature/ Modified: ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml ofbiz/trunk/framework/example/servicedef/services.xml ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/EntityAutoEngine.java Modified: ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml?rev=679288&r1=679287&r2=679288&view=diff ============================================================================== --- ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml (original) +++ ofbiz/trunk/framework/example/script/org/ofbiz/example/example/ExampleServices.xml Thu Jul 24 00:08:10 2008 @@ -21,16 +21,6 @@ <simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd"> <!-- Example methods --> - <simple-method method-name="createExample" short-description="create a Example"> - <make-value entity-name="Example" value-name="newEntity"/> - <sequenced-id-to-env sequence-name="Example" env-name="newEntity.exampleId"/> <!-- get the next sequenced ID --> - <field-to-result field-name="newEntity.exampleId" result-name="exampleId"/> - <set-nonpk-fields map-name="parameters" value-name="newEntity"/> - <create-value value-name="newEntity"/> - - <set-service-fields service-name="createExampleStatus" map-name="newEntity" to-map-name="createExampleStatusMap"/> - <call-service service-name="createExampleStatus" in-map-name="createExampleStatusMap"/> - </simple-method> <simple-method method-name="updateExample" short-description="update a Example"> <entity-one entity-name="Example" value-name="lookedUpValue"/> @@ -50,19 +40,11 @@ <check-errors/> </if-empty> </if-not-empty> - - <!-- before we set the nonpk fields, if the statusId is different save a status history record --> - <set-service-fields service-name="createExampleStatus" map-name="parameters" to-map-name="createExampleStatusMap"/> - <call-service service-name="createExampleStatus" in-map-name="createExampleStatusMap"/> </if-compare-field> <set-nonpk-fields map-name="parameters" value-name="lookedUpValue"/> <store-value value-name="lookedUpValue"/> </simple-method> - <simple-method method-name="deleteExample" short-description="delete a Example"> - <entity-one entity-name="Example" value-name="lookedUpValue"/> - <remove-value value-name="lookedUpValue"/> - </simple-method> <simple-method method-name="createExampleStatus" short-description="create a ExampleItem"> <now-timestamp-to-env env-name="nowTimestamp"/> Added: ofbiz/trunk/framework/example/servicedef/secas.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/servicedef/secas.xml?rev=679288&view=auto ============================================================================== --- ofbiz/trunk/framework/example/servicedef/secas.xml (added) +++ ofbiz/trunk/framework/example/servicedef/secas.xml Thu Jul 24 00:08:10 2008 @@ -0,0 +1,30 @@ +<?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. +--> + +<service-eca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/service-eca.xsd"> + <eca service="createExample" event="return"> + <action service="createExampleStatus" mode="sync"/> + </eca> + <eca service="updateExample" event="return"> + <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/> + <action service="createExampleStatus" mode="sync"/> + </eca> +</service-eca> Propchange: ofbiz/trunk/framework/example/servicedef/secas.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: ofbiz/trunk/framework/example/servicedef/secas.xml ------------------------------------------------------------------------------ svn:keywords = "Date Rev Author URL Id" Propchange: ofbiz/trunk/framework/example/servicedef/secas.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: ofbiz/trunk/framework/example/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/servicedef/services.xml?rev=679288&r1=679287&r2=679288&view=diff ============================================================================== --- ofbiz/trunk/framework/example/servicedef/services.xml (original) +++ ofbiz/trunk/framework/example/servicedef/services.xml Thu Jul 24 00:08:10 2008 @@ -25,8 +25,7 @@ <version>1.0</version> <!-- Example & Related Services --> - <service name="createExample" default-entity-name="Example" engine="simple" - location="component://example/script/org/ofbiz/example/example/ExampleServices.xml" invoke="createExample" auth="true"> + <service name="createExample" default-entity-name="Example" engine="entity-auto" invoke="create" auth="true"> <description>Create a Example</description> <permission-service service-name="exampleGenericPermission" main-action="CREATE"/> <auto-attributes include="pk" mode="OUT" optional="false"/> @@ -43,8 +42,7 @@ <auto-attributes include="nonpk" mode="IN" optional="true"/> <attribute name="oldStatusId" type="String" mode="OUT" optional="false"/> </service> - <service name="deleteExample" default-entity-name="Example" engine="simple" - location="component://example/script/org/ofbiz/example/example/ExampleServices.xml" invoke="deleteExample" auth="true"> + <service name="deleteExample" default-entity-name="Example" engine="entity-auto" invoke="delete" auth="true"> <description>Delete a Example</description> <permission-service service-name="exampleGenericPermission" main-action="DELETE"/> <auto-attributes include="pk" mode="IN" optional="false"/> @@ -80,45 +78,39 @@ </service> <!-- ExampleFeature Services --> - <service name="createExampleFeature" default-entity-name="ExampleFeature" engine="simple" - location="component://example/script/org/ofbiz/example/feature/ExampleFeatureServices.xml" invoke="createExampleFeature" auth="true"> + <service name="createExampleFeature" default-entity-name="ExampleFeature" engine="entity-auto" invoke="create" auth="true"> <description>Create a ExampleFeature</description> <permission-service service-name="exampleGenericPermission" main-action="CREATE"/> <auto-attributes include="pk" mode="OUT" optional="false"/> <auto-attributes include="nonpk" mode="IN" optional="true"/> <override name="description" optional="false"/> </service> - <service name="updateExampleFeature" default-entity-name="ExampleFeature" engine="simple" - location="component://example/script/org/ofbiz/example/feature/ExampleFeatureServices.xml" invoke="updateExampleFeature" auth="true"> + <service name="updateExampleFeature" default-entity-name="ExampleFeature" engine="entity-auto" invoke="update" auth="true"> <description>Update a ExampleFeature</description> <permission-service service-name="exampleGenericPermission" main-action="UPDATE"/> <auto-attributes include="pk" mode="IN" optional="false"/> <auto-attributes include="nonpk" mode="IN" optional="true"/> </service> - <service name="deleteExampleFeature" default-entity-name="ExampleFeature" engine="simple" - location="component://example/script/org/ofbiz/example/feature/ExampleFeatureServices.xml" invoke="deleteExampleFeature" auth="true"> + <service name="deleteExampleFeature" default-entity-name="ExampleFeature" engine="entity-auto" invoke="delete" auth="true"> <description>Delete a ExampleFeature</description> <permission-service service-name="exampleGenericPermission" main-action="DELETE"/> <auto-attributes include="pk" mode="IN" optional="false"/> </service> - <service name="createExampleFeatureAppl" default-entity-name="ExampleFeatureAppl" engine="simple" - location="component://example/script/org/ofbiz/example/feature/ExampleFeatureServices.xml" invoke="createExampleFeatureAppl" auth="true"> + <service name="createExampleFeatureAppl" default-entity-name="ExampleFeatureAppl" engine="entity-auto" invoke="create" auth="true"> <description>Create a ExampleFeatureAppl</description> <permission-service service-name="exampleGenericPermission" main-action="CREATE"/> <auto-attributes include="pk" mode="IN" optional="false"/> <auto-attributes include="nonpk" mode="IN" optional="true"/> <override name="fromDate" optional="true"/> </service> - <service name="updateExampleFeatureAppl" default-entity-name="ExampleFeatureAppl" engine="simple" - location="component://example/script/org/ofbiz/example/feature/ExampleFeatureServices.xml" invoke="updateExampleFeatureAppl" auth="true"> + <service name="updateExampleFeatureAppl" default-entity-name="ExampleFeatureAppl" engine="entity-auto" invoke="update" auth="true"> <description>Update a ExampleFeatureAppl</description> <permission-service service-name="exampleGenericPermission" main-action="UPDATE"/> <auto-attributes include="pk" mode="IN" optional="false"/> <auto-attributes include="nonpk" mode="IN" optional="true"/> </service> - <service name="deleteExampleFeatureAppl" default-entity-name="ExampleFeatureAppl" engine="simple" - location="component://example/script/org/ofbiz/example/feature/ExampleFeatureServices.xml" invoke="deleteExampleFeatureAppl" auth="true"> + <service name="deleteExampleFeatureAppl" default-entity-name="ExampleFeatureAppl" engine="entity-auto" invoke="delete" auth="true"> <description>Delete a ExampleFeatureAppl</description> <permission-service service-name="exampleGenericPermission" main-action="DELETE"/> <auto-attributes include="pk" mode="IN" optional="false"/> Modified: ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/EntityAutoEngine.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/EntityAutoEngine.java?rev=679288&r1=679287&r2=679288&view=diff ============================================================================== --- ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/EntityAutoEngine.java (original) +++ ofbiz/trunk/framework/service/src/org/ofbiz/service/engine/EntityAutoEngine.java Thu Jul 24 00:08:10 2008 @@ -23,6 +23,7 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.GeneralException; +import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.entity.GenericValue; import org.ofbiz.entity.finder.PrimaryKeyFinder; @@ -212,6 +213,15 @@ "4. all pk fields are IN for a manually specified primary key"); } + // handle the case where there is a fromDate in the pk of the entity, and it is optional or undefined in the service def, populate automatically + ModelField fromDateField = modelEntity.getField("fromDate"); + if (fromDateField != null && fromDateField.getIsPk()) { + ModelParam fromDateParam = modelService.getParam("fromDate"); + if (fromDateParam == null || (fromDateParam.isOptional() && context.get("fromDate") == null)) { + newEntity.set("fromDate", UtilDateTime.nowTimestamp()); + } + } + newEntity.setNonPKFields(context, true); newEntity.create(); } else if ("update".equals(modelService.invoke)) { |
Free forum by Nabble | Edit this page |