Server-side ID generation and project attribute validation
You can set up a template to use custom routines to generate ID values automatically, and to validate values entered on the Summary tab of an object.
The ID values that you can set up for automated generation include the identifiers for a project, plan, or program.
To define a custom ID generator, you must write a Java™ class that implements the com.unicacorp.uap.project.helper.PidGenerate interface. Within the template definition, you can then specify your Java™ class name as the value for pidGenClass attribute, and use the pidprefix attribute to include an optional prefix.
In a similar manner, you can also define custom routines to validate attribute values of a project, plan, or program. To define a custom validation routine, you must write a Java™ class that implements the following interface: com.unicacorp.uap.common.template.IdValidate.
Within the project template definition, you can then specify your Java™ class name as the value for validateClass attribute.
Example server-side ID generation
Assume that you have a custom marketing object type for offers. You want its template to generate a custom code for each offer instance that is created. The codes must have the following characteristics:
- The first number starts with 900001.
- The last number possible is 999999.
- Codes must be sequential.
To set up automated ID generation, you use the IdGenerate interface and follow these steps.
- Create a custom Java™ implementation
named CustomComponentPidGenerateImpl.java.
See Sample Java interface.
- This implementation uses a file, IDRange.properties, to hold the minimum and maximum values for the custom IDs.
- It uses a database table, CUST_GENIDS, to hold the current value of the custom ID for each object type that uses the class.
- Compile the class. The compiled class is named CustomComponentPidGenerateImpl.class.
- Copy the class file into the following directory:
<MarketingOperations_Home>\unwar\WEB-INF\classes\com\unica\uap\component\helper
- Create a file named IDRange.properties,
and add the following text to this file:
mktOBJId.min=900001
mktOBJId.max=999999
- Copy this file to the <Plan_Home>\unwar\WEB-INF directory.
- Using your database management program, create a table named CUST_GENIDS
with the following columns:
- ENTITY_NAME; string, length 50
- ID_VALUE; integer (all in file format)
- Restart your web server.
- Create or edit a template for the marketing object type, and open its Properties tab.
- In the ID Generation Class field, use the
fully qualified class name or canonical name to specify the custom
class, as shown here:
CustomComponentPidGenerateImpl
When you create the first offer from this template, note that its ID is 900001.