Object mapping , any pattern ?

Discussions

General J2EE: Object mapping , any pattern ?

  1. Object mapping , any pattern ? (3 messages)

    Every system needs some kind of object mapping. One of the classic example would be when the Business object model and the data model does not match. Consider a example where system is communicating with CICS based host. System has a busineed object with attributes firstName , lastName, streetNo,streetName,City,State and zipCode. To store this data in CICS this syetm can communicate with the CICS based host by sending message such as
    FNAME=;LNAME=;ADDR1=;ADDR2=;CITY=;STATE=;CODE=;
    There is a mismatch between the attributes on business object and keywords in message. And to resolve this mismatch it needs something describing this mapping . Are there any patterns to handle such scenario or are there any tools.
    XSLT could be a solution but to use XSLT the preson object needs to be convertated in DOM object and then write XSL.

    I think this is genuine problem every system implements in one form or another . Any suggestions ? thoghts ?

    Thanks
    Sunil

    Threaded Messages (3)

  2. not a pattern[ Go to top ]

    This is not a pattern at all. You are looking for a tool or spec. If all you are looking for is a way to turn one keyword into another then a simple property file can suffice, i.e.

    # conversions
    name=NAME
    fName=FIRST_NAME

    Bruce
  3. more thoughts[ Go to top ]

    Also, do NOT uses xslt. Why would you use this ? You have no xml. You want to create xml just for search and replace ? No way. Just use String.repalce() (or whatever). C'mon.

    Bruce
  4. Interface[ Go to top ]

    You might want to use something like this to map your Java objects with your Cobol programs.

    http://www.javaworld.com/javaworld/jw-10-2000/jw-1006-legacy.html

    I would'nt use XSL in your case since your inputs aren't XML. It would be overkill to transform your inputs into XML just to use an XSL transformation.

    The only XML you will have in your case will be used to map your COBOL parameter to your Java attributes. It's pretty straightforward to implement.

    You could create a JDBC style interface to set your values, it would map directly with your inputs. Ie:

    Also, do not use a property file because it will get messy as you will probably want to handle array of objects, you will have to come up with something unatural. XML easily handle collections and hierarchy.

    CobolTransaction trx = new CobolTransaction();
    trx.setString("firstName", employee.getFirstName());
    trx.setString("lastName", employee.getLastName());

    // Handle array with something like this
    CobolArray raisesHistory = trx.initArray("raisesHistory");
    Iterator raisesIt = employee.getRaisesHistory().iterator();
    while(raisesIt.hasNext()){
       raisesHistory.addRow();
       raisesHistory.setString("year", ...);
       ...
       raisesIt.next();
    }