Configuration Settings

From Opentaps Wiki

Jump to: navigation, search

In opentaps 1.4.0 and earlier versions, configurations were usually in the form of .properties files, and they could be obtained by using the org.ofbiz.base.util.UtilProperties class. An example is:

boolean shipmentUpsSaveCertificationInfo = "true".equals(UtilProperties.getPropertyValue("shipment", "shipment.ups.save.certification.info"));

which obtains the property: shipment.ups.save.certification.info=true

from shipment.properties in applications/product/config/shipment.properties

Beginning in opentaps 1.4.1, a new OpentapsConfiguration entity is introduced to hold configuration data in the database. This entity is keyed on OpentapsConfigurationType for the values which can be configured, and the values are printed when they are stored in the database. An example of this are some of the properties defined for the Opentaps Concur Integration:

<OpentapsConfigurationType configTypeId="CONCUR_CONFIG" description="Concur integration configuration"/>
<OpentapsConfigurationType configTypeId="CONCUR_REIMB_PAYMENT_TYPE_ID" parentConfigTypeId="CONCUR_CONFIG" description="Default Payment.paymentTypeId for concur reimbursements"/>
<OpentapsConfigurationType configTypeId="CONCUR_REIMB_PAYMENT_METHOD_ID" parentConfigTypeId="CONCUR_CONFIG" description="Default Payment.paymentMethodId  for concur reimbursements"/>

The values for the configuration properties can be loaded with entity engine XML (or other database loading scripts):

<OpentapsConfiguration configTypeId="CONCUR_REIMB_PAYMENT_TYPE_ID" value="REIMBURSEMENT"/>
<OpentapsConfiguration configTypeId="CONCUR_REIMB_PAYMENT_METHOD_ID" value="COCHECKING" comments="By default, reimbursements are made from the Company Checking account"/>

To use them in your code, use the Infrastructure.getConfigurationValue method:

 String reimbursementPaymentTypeId = infrastructure.getConfigurationValue("CONCUR_REIMB_PAYMENT_TYPE_ID");
 String reimbursementPaymentMethodId = infrastructure.getConfigurationValue("CONCUR_REIMB_PAYMENT_METHOD_ID");

Overtime, we plan to set up user interface for configuration entities, and also to migrate existing code to them. This should give us a better way to manage system configurations.

Default Values

If no configuration is found for your configuration type, the default value from Infrastructure.getConfigurationValue(configTypeId, defaultValue) method will be used. If no defaultValue method parameter was supplied, or if you called the Infrastructure.getConfiguredValue(configTypeId) method, the defaultValue in your OpentapsConfigurationType will be used. This allows you to set a universal default value, like this:

<OpentapsConfigurationType configTypeId="TEST_CONFIG_UNCONFIGURED_TYPE" description="For testing" defaultValue="Default value 2"/>    

which can always be over-ridden in your code with the Infrastructure.getConfigurationValue(configTypeId, defaultValue) method when necessary.

method.



© Open Source Strategies, Inc. Development of this documentation site is sponsored by Open Source Strategies, Inc.
Help support opentaps with a subscription to this documentation site.