Topic
10 replies Latest Post - ‏2014-02-27T22:26:36Z by bernard H
bernard H
bernard H
5 Posts
ACCEPTED ANSWER

Pinned topic TX Rule Formatter - enhancing map rule readability

‏2013-05-12T21:23:57Z |

Some TX map rules way readily become complex. A typical example is that of an extraction of a piece of an input data item that is in turn passed through validation tests in order to invoke variant functional maps, themselves often featuring a bunch of arguments. We get a sequence of commas and brackets () that isquite difficult to track visually in order to know which argument goes with which function, especially if the data item references become also quite long as it happens with XML documents.

I was quite disappointed not to find in the Transformation Extender perspective a utility like the auto-indent or formatting facility (ctrl-shft-F) in Eclipse that format nicely your java code or C code or XML document, etc... 

That has driven me to develop piece of java code to format a map rule. Then, I wrapped the formatter into an Eclipse plug in. At this stage, this is still a fairly brute plugin (it does not disappear when moving out from the Transformation Extender perspective, of better from a map editor tab), but it is already quite useful, and at a stage that calls for feedback in order to evolve.

Here are the details:

 

This Eclipse plug-in works both in Websphere Message Broker Toolkit and TX StudioThe plugin displays an an extra icon iconin the Eclipse menu bar. The plug-in uses indentation and argument counts to enhance the readability of map rules.

Tested with WTX 8.4.0.3 and Message Broker Toolkit 8.0.0.1.

Usage:

Within theTransformation Extender perspective, edit a map and select a mapping rule in an output card, then click on the icon to format the rule. The format is best viewed by choosing a fixed spacing font for the rule editor (as set via Window > Preferences > Transformation Extender > Map > fonts > Rule Bar View ).

Installation:

Simply copy the attached jar in the Eclipse plugin directory at stake.

  • In the broker Toolkit, the directory is like: \Program Files\IBM\Websphere Broker\plugins
  • in TX Studio, the directory is like: \Program Files\IBM\Websphere TX\DesignStudio\wtx_eclipse\eclipse\plugins

 

Your feedback is solicited.

Was I stupid and missing some readily available facility in TX that can format map rules?

Updated on 2013-05-12T21:27:33Z at 2013-05-12T21:27:33Z by bernard H
  • thorstenhirsch
    thorstenhirsch
    83 Posts
    ACCEPTED ANSWER

    Re: TX Rule Formatter - enhancing map rule readability

    ‏2013-05-15T16:35:15Z  in response to bernard H

    Hi Bernard, I installed your plugin, the icon appears, but it doesn't work. An unhandled event loop exception in the error log of eclipse appears every time I click the icon:

    eclipse.buildId=
    java.fullversion=JRE 1.6.0 IBM J9 2.4 Windows XP x86-32 jvmwi3260sr9-20110624_85526 (JIT enabled, AOT enabled)
    J9VM - 20110624_085526
    JIT  - r9_20101028_17488ifx17
    GC   - 20101027_AA
    BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_GB
    Framework arguments:  -user=C:\Program Files\wtx84
    Command-line arguments:  -os win32 -ws win32 -arch x86 -clean -user=C:\Program Files\wtx84


    Error
    Wed May 15 18:34:22 CEST 2013
    Unhandled event loop exception

    java.lang.LinkageError: Übertretung der Ladeeinschränkung: Ladeprogramm "org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader@46a246a2" hat zuvor das Laden für einen anderen Typ mit dem Namen "com/ibm/websphere/dtx/ui/me/editors/editparts/BaseEditPart", der durch Ladeprogramm "org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader@7b5f7b5f" definiert ist, eingeleitet.
        at java.lang.ClassLoader.defineClassImpl(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:275)
        at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
        at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:580)
        at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:550)
        at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:481)
        at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass_LockClassLoader(ClasspathManager.java:469)
        at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:449)
        at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
        at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:390)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:469)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
        at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
        at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:103)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
        at com.reverseXSL.TXextend.handlers.RuleFormatter.execute(RuleFormatter.java:70)
        at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
        at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
        at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
        at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
        at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
        at org.eclipse.ui.menus.CommandContributionItem.handleWidgetSelection(CommandContributionItem.java:820)
        at org.eclipse.ui.menus.CommandContributionItem.access$19(CommandContributionItem.java:806)
        at org.eclipse.ui.menus.CommandContributionItem$5.handleEvent(CommandContributionItem.java:796)
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
        at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
        at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
        at java.lang.reflect.Method.invoke(Method.java:611)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1384)
     

    Starting WTX with CleanExtenderStudio.bat did not fix this issue.

    Updated on 2013-05-15T16:35:50Z at 2013-05-15T16:35:50Z by thorstenhirsch
    • 5UXU_Bernard_Hauzeur
      1 Post
      ACCEPTED ANSWER

      Re: TX Rule Formatter - enhancing map rule readability

      ‏2013-05-22T20:49:34Z  in response to thorstenhirsch

      Thanks for this feedback and also for serving as early tester. Effectively, colleagues encountered the exact same problem when installing it in TX Studio, whereas the Broker Toolkit with TX for IS extension did work OK.

      I found the cause and fixed it. You'll find the updated version attached. Even a smaller file size as explained below.

      Technical explanation: the MapEditor plugin  that handles map rule editing does not formally export the Class interfaces used by my Rule Formatter plugin. IBM did not foresee such extensibility (and did not document it). MapEditor and associated classes were needed to run the plugin, and the Eclipse workbench in the Broker toolkit allowed loading a copy of these along with the rule formatter plugin. This is not the case of TX studio which apparently has more strict class loading policy, and therefore refuses loading a "duplicate" class instance. The true solution would be to expose the necessary plugin extension, but this does require hacking the Eclipse OSGI  settings... which I do not want to : I want the users to be able to add/remove the Rule Formatter plugin by just adding/removing the plugin jar. So the trick was to refactor the plugin code to use introspection on the MapEditor object family, which I tested successfully in both WMBT 8.0.0.1 and TX STudio 8.3.0.4.

      Keep me posted and thank you in advance to all candidate users.

      PS: do not forget to remove the previous plugin file (different name / serial number!) and replace by the attached.

      oooups: 5UXU_Bernard_Hauzeur (working at NMBS in BE) and Bernard H (self employed) is the same person...may reply to either

      Updated on 2013-05-22T21:00:17Z at 2013-05-22T21:00:17Z by 5UXU_Bernard_Hauzeur
  • vijji_WTX
    vijji_WTX
    118 Posts
    ACCEPTED ANSWER

    Re: TX Rule Formatter - enhancing map rule readability

    ‏2013-06-06T06:55:13Z  in response to bernard H

    Hi , Good to know about this feature and thanks a ton and appreciate for your effort and share. 

    I installed this .jar in my 8.3.0.4 and could not see the icon. searched in preferrences but no luck. Any clue to fix?

     

    reg

    Vijji

    • bernard H
      bernard H
      5 Posts
      ACCEPTED ANSWER

      Re: TX Rule Formatter - enhancing map rule readability

      ‏2013-06-06T21:54:05Z  in response to vijji_WTX

      Looks like there are subtleties linked to the visibility of plugins deposited under program files in some Windows 7 installations. I'm actively searching a solution with a colleague in trouble. I will keep you posted of course.

    • bernard H
      bernard H
      5 Posts
      ACCEPTED ANSWER

      Re: TX Rule Formatter - enhancing map rule readability (Windows 7 note)

      ‏2013-06-23T17:06:52Z  in response to vijji_WTX

      Here is a progress note on the visibility of the plugin in Windows7 installations.

      With an Installation that was NOT made under Program files(x86), I noted the following (based on latest plugin, cfr above May 22 version).

      For TX studio: If the plugin is copied into C:\IBM\WebSphere Studio IES V3.3\eclipse\plugins, then it is NOT visible. But instead, if copied within C:\IBM\WebSphere Transformation Extender 8.4\DesignStudio\wtx_eclipse\eclipse\plugins the plugin is visible and works well.

      Possibly important: the account under which this was checked is a local administrator of the system.

      For the Message Broker toolkit with TX for Integration servers extension, when copied into C:\IBM\WebsphereMBToolkitV8001\plugins then the plugin is visible and works.... still indeed under local administrator of the machine.

      When installed In Program files (x86) (i.e. 32bit), I noted the problem on a colleague PC with  Windows 7 and the UAC active and notably the virtual directories that completely fool up applications. There are various tips described in forums that could solve the issue, but so far I was unable to test them. I think that just taking ownership of the IBM installation location (and recursively everything under) and setting full access control for the user at stake would solve the issue without having to ressort to the brute force de-activation of all security protections...

       

      • Zamir_Juma
        Zamir_Juma
        2 Posts
        ACCEPTED ANSWER

        Re: TX Rule Formatter - enhancing map rule readability (Windows 7 note)

        ‏2014-01-16T21:46:49Z  in response to bernard H

        This type of tool would be great.. disappointed that something like this isn't built in.  I didn't have any luck getting it to run on WTX 8.3.0.5, I assume there must be some changes that prevent it from working.  Anyone have any alternatives?

      • thorstenhirsch
        thorstenhirsch
        83 Posts
        ACCEPTED ANSWER

        Re: TX Rule Formatter - enhancing map rule readability (Windows 7 note)

        ‏2014-02-12T10:05:55Z  in response to bernard H

        The new version (com.reverseXSL.TXextend_1.0.0.201305220000.jar) works for me in WTX 8.4.1.1. But I decided not to distribute it to the other developers here in my company, yet. I'd like to change some preferences concerning indentation and white space characters before/after brackets. But I guess it's a bunch of work to make all this stuff editable in the eclipse preferences...

        Bernard, what do you think about open-sourcing your software? We achieved to bring up a policy in my company that allows developers to contribute to open-source projects at work, even to GPL'ed projects.

  • jvanboga
    jvanboga
    414 Posts
    ACCEPTED ANSWER

    Re: TX Rule Formatter - enhancing map rule readability

    ‏2014-01-22T20:32:46Z  in response to bernard H

    Nice to have a tool for this for those preferring the java formatting. 

    My experience is that if a rule is so complex its challenging to read if should probably be broken into multiple functional or called maps depending on the needs.  The way the tool works is that poorly formated functions will cause the logic to fail.  Functions that can cause issues if formated poorly include 'extract', 'lookup', 'searchup'/down and sometimes substitute.  Too many, used inconsistently, in a single rule will compile but cause potential problems.

  • Ravi2014
    Ravi2014
    4 Posts
    ACCEPTED ANSWER

    Re: TX Rule Formatter - enhancing map rule readability

    ‏2014-02-27T10:43:40Z  in response to bernard H

    Is it works for WTX 8.2?

     

    • bernard H
      bernard H
      5 Posts
      ACCEPTED ANSWER

      Re: TX Rule Formatter - enhancing map rule readability

      ‏2014-02-27T22:26:36Z  in response to Ravi2014

      I haven't tried and have no clue. All the installations we made were 8.4.0.x. It's harmless to try as it consists of an Eclipse Plug-in, which can then be removed as easily as it is installed.

      Note that the most important is to have an installation of the Broker toolkit + TX for IS, and/or TX studio installed outside of the "program files" folder hierarchy as the Windows7 protection rules and 'roaming' virtual folders applied to the Program files folder do prevent a proper execution of the plugin for a reason I have not fully understood, even if we play with the ACL's. You may see the plug-in listed under /program files(x86)/IBM/...., but actually the file sits physically under C:\Users\<yourLogin>\AppData\Local\VirtualStore\... and the Eclipse application will never see it. cfr http://www.interworks.com/blogs/dsmith/2011/09/21/disabling-windows-7-virtual-store