[OFBiz] Users - New Simple-methods for adding custom entities

Adrian Crum adrianc at hlmksw.com
Tue Apr 5 12:58:53 EDT 2005


What you are trying to accomplish with this custom entity might exist 
already in OFBiz.

Ashish Hareet wrote:

> I'm trying to create a simple-method that will add my custom entites.
> I'm running into an error while adding data for the entites.
> Since all this was done by looking at existing OfBiz code with limited understanding of how or why,
> I'm gonna list all that I have done hoping that somebody would be kind enough 
> to help me catch my mistake
> 
> I'm using a Postgres db
> 
> Step 1 - Creating the entity def - This step creates the entity in the db as expected
> "entitymodel.xml"
> 	<entity entity-name="CustomerCreditInfo"
> 		package-name="org.ofbiz"
> 		title=" Credit information for Customers">
> 		<field name="partyId" type="id-ne"/>
> 		<field name="creditLimit" type="currency-amount"/>
> 		<field name="customerDiscount" type="numeric"/>
> 		<field name="creditHoldBadDebt" type="indicator"/>
> <!--		<field name="creditNote" type="very-long"/> -->
> 		<prim-key field="partyId"/>
> 		<relation type="one" fk-name="CUSTOMER_CREDIT_PARTY_GROUP" rel-entity-name="PartyGroup">
> 			<key-map field-name="partyId"/>
> 		</relation>
> 	</entity>
> 
> "entitygroup.xml"
> 	<entity-group group="org.ofbiz" entity="CustomerCreditInfo"/>
> 
> 
> Step 2 - Create a service to add entity data - No errors on startup after defining this service
> "services.xml"
> 	<service name="createCustomerCreditInfo" engine="simple"
> 		location="services/CustomerCreditInfo.xml" invoke="createCustomerCreditInfo" auth="true">
> 		<description>Creates the credit information for customer</description>
> 	</service>
> 
> "CustomerCreditInfo.xml"
> 	<simple-method method-name="createCustomerCreditInfo" 
> 		short-description="Creates the credit information for customer">
> 		<make-value value-name="newCreditInfo" entity-name="CustomerCreditInfo"/>
> 		<set-pk-fields map-name="parameters" value-name="newCreditInfo"/>
> 		<set-nonpk-fields map-name="parameters" value-name="newCreditInfo"/>
> 		<create-value value-name="newCreditInfo"/>
> 	</simple-method>
> 
> Step 3 - Make form(not form-widget) to collect & add the entity data - form is parsed & rendered properly
> "myform.xml"
> 		<call-map-processor
> 			xml-resource="customer/NewCustomerMapProc.xml"
> 			processor-name="creditInfoProc"
> 			in-map-name="parameters"
> 			out-map-name="creditInfo"/>
> 
> 
> 		<call-service service-name="createCustomerCreditInfo" in-map-name="creditInfo"/> 
> 
> "NewCustomerMapProc.xml"
> 	<simple-map-processor name="creditInfoProc">
> 		<process field="CREDIT_LIMIT">
> 			<copy to-field="creditLimit"/>
> 			<not-empty>
> 				<fail-message message="Credit limit is required"/>
> 			</not-empty>
> 		</process>
> 		<process field="CUSTOMER_DISCOUNT">
> 			<copy to-field="customerDiscount"/>
> 			<not-empty>
> 				<fail-message message="Customer discount is required"/>
> 			</not-empty>
> 		</process>
> 		<process field="CREDIT_HOLD_BAD_DEBT">
> 			<copy to-field="creditHoldBadDebt"/>
> 			<not-empty>
> 				<fail-message message="Credit hold/Bad debt needs to be selected"/>
> 			</not-empty>
> 		</process>
> 	</simple-map-processor>
> 
> 
> 
> 
>  
> _______________________________________________
> Users mailing list
> Users at lists.ofbiz.org
> http://lists.ofbiz.org/mailman/listinfo/users
> 


More information about the Users mailing list