ibm-odm

Creating a domain where a single label maps to multiple values


My input data has attributes for which multiple values can refer to a single business-friendly verbalization (domain label). I am trying to figure out how to represent this in Rule Designer. I'm new to ODM and still learning the ropes -- currently using ODM 8.8.1 (distributed / Java).

Imagine mapping ZIP code prefixes to their state. For example, ZIP codes beginning with 967 and 968 are Hawaii. In a nutshell, I want to express the rule as "if the ZIP code prefix is Hawaii..." rather than comparisons to 967 and 968. In domain terms, 967 and 968 are the real underlying attribute values, and Hawaii is the verbalization label. But obviously BOM-to-XOM expects a single return, and it wouldn't be correct to arbitrarily choose 967 or 968.

My actual scenario is far more complex involving long strings of cryptic code-values that the users would never know or recognize, but the concept is identical. In some cases a label can map to 15 or 20 underlying values.

Is this possible with ODM domains? (I am pretty sure it could be done on the other side with a decision table but I'm really trying to solve it as a domain problem for now.)


Solution

  • Your best approach here is to create a XOM or BOM class to map the state to the prefixes and then wrap that with the verbalization you want. I will illustrate with an example that maps zipcodes to states.

    Example:

    1. Setup an enum or domain with your states:

    public enum States
    {
    	AL,
    	AK,
    	AZ
      // etc
     }

    1. Make a class for your zipcodes:

    public class Zipcode
    {
    	private String zipcode;
    
    	public String getZipcode()
    	{
    		return zipcode;
    	}
    
    	public void setZipcode(String zipcode)
    	{
    		this.zipcode = zipcode;
    	}
    	
    }

    1. Create an extender class to perform the mapping of zipcodes to states:

    public class ZipToStateMap
    {
    	private Map<String, States> zipToStateMap = new HashMap<String, States>();
    	
    	public ZipToStateMap()
    	{
    		zipToStateMap.put("99553", States.AK);
    		zipToStateMap.put("99571", States.AK);
    		// etc
    	}
    	
    	public States getStateFromZip(String zip)
    	{
    		return zipToStateMap.get(zip);
    	}
    	
    	public boolean zipIsInState(String zip, States state)
    	{
    		return this.getStateFromZip(zip) == state;
    	}
    	
    }

    1. Create a virtual bom method that uses the ZipToState:zipIsInState() extender:

    virtual bom method image

    1. Write a rule using your new mapping:

    enter image description here