No announcement yet.
  • Filter
  • Time
Clear All
new posts

    Passing some extra parameters to a serverObject Java class


    I am reading a legacy database which has quite a few fields which are dates or times, and are stored variously as decimal or maybe an integer, or even character, 7, or maybe 8 digits. There will also be time fields similarly. I have written a Java class and method to process a dsResponse and reformat as a proper date. I have added a serverObject section to my ds.xml file. This all works fine.

    However, I don't want to write a class for each field, what I want to do it pass in the name of the date field to the class on the serverObject ui.xml so I can use the same Java class and it will know which field to pull out of the dsResponse. I have tried various ways of doing this and read through the quick start guide as well and the Javadocs, but to no avail.

    Can this be done, if so how? Perhaps there is a better way.

    Thanks, Mark.

    Hi maw ,

    if the conversion is easy and if the DB supports this, a TO_DATE in a customSelectExpression is (again) the preferred solution - again with a simpleType - , so that you only need to reference the type in your .ds.xml.
    Otherwise you can link the the same serverObject from different .ds.xml.

    You can also create a base serverObject and let your normal serverObjects extend it in Java. Then you can call some super.method().
    This super class can have a list of DataSourceName + Fieldname, which tells on which object that super method should act. Then you need to list those fields only there.
    Or create a simpleType with a special name, extending text - then iterate your DataSource fields, and if a fieldType matches, do the replacement. This is then very declarative.

    But if possible I'd go the customSelectExpression way. Perhaps you can create a function in your legacy DB system to convert string to date?

    Best regards