Topic
15 replies Latest Post - ‏2013-12-16T14:42:26Z by DaveN
mark_laughton
mark_laughton
8 Posts
ACCEPTED ANSWER

Pinned topic ExplorerHelloWorld example - ICPSM class errors

‏2013-11-13T15:57:20Z |

Hi

Working my way through the "Extend the CICS Explorer" redbook and falling at a first hurdle with the ExplorerHelloWorld example on page 82/83 - I'm getting errors on this statement:

ICPSM cpsm = (ICPSM) UIPlugin.getDefault().getResourceManager

(UIPlugin.SYSTEM_MANAGER_CONNECTION_ID);

I've used Navidate -> Open Type to locate the ICPSM object and added

importcom.ibm.cics.core.model.ICPSM;

However this is different to what is shown in the Redbook, where ICPSM is shown in com.ibm.core.model, rather than com.ibm.cics.core.model.ICPSM.

The error is saying that method getResourceManager isnt found (something has changed since the redbook?), but I dont have the experience to know how to resolve this (newby!),

I'm using Eclipse Java EE IDE Juno SR2 and CICS Explorer 5.1 SDK.

Complete list of imports is:

import org.eclipse.jface.action.IAction;

import org.eclipse.jface.viewers.ISelection;

import org.eclipse.ui.IWorkbenchWindow;

import org.eclipse.ui.IWorkbenchWindowActionDelegate;

import org.eclipse.jface.dialogs.MessageDialog;

import com.ibm.cics.core.model.ICPSM;

import com.ibm.cics.core.ui.UIPlugin;

Appreciate any help...

Mark

  • DaveN
    DaveN
    71 Posts
    ACCEPTED ANSWER

    Re: ExplorerHelloWorld example - ICPSM class errors

    ‏2013-11-13T17:02:44Z  in response to mark_laughton

    Hi Mark,

    Sadly the Redbook was written in 2010 and things have changed a lot since then :-/

    In particular, the code to handle connections has been moved into the z/OS Explorer, you'll need to depend on the plug-in com.ibm.cics.core.connections (which comes from z/OS Explorer).

    In your run method, something like this will get you started:

            IConnectionService service = ConnectionsPlugin.getDefault().getConnectionService();
            ICPSM cpsm = (ICPSM) service.getConnectable(PluginConstants.CICS_SM_CONNECTION_CATEGORY_ID);
            if(cpsm.isConnected()) {
                MessageDialog.openInformation(
                        window.getShell(),
                        "ExplorerHelloWorld",
                        cpsm.getCICSplexes()[0].toString());
            }
    

    We get hold of the connections service and find the connected CICS SM connection, then cast the connectable to an ICPSM object - then you're pretty much up to speed with the book.

    You can interact with z/OS Explorer connections similarly, by doing:

    IZOSConnectable connectable = (IZOSConnectable) ConnectionsPlugin.getDefault().getConnectionService().getConnectable(ZOSFTPConnection.CATEGORY_ID);
    

    Dave

    • mark_laughton
      mark_laughton
      8 Posts
      ACCEPTED ANSWER

      Re: ExplorerHelloWorld example - ICPSM class errors

      ‏2013-11-14T09:46:53Z  in response to DaveN

      Hi Dave

      many many thanks - that works - I'm back on track. :)

      Aside from the Redbook are there any other sources of information about the CICS Explorer model (other than the class/interface descriptions), examples etc?

      I feel I'm missing something. I'm new to Eclipse development and obviously the Explorer SDK.

      cheers

      Mark

      • DaveN
        DaveN
        71 Posts
        ACCEPTED ANSWER

        Re: ExplorerHelloWorld example - ICPSM class errors

        ‏2013-11-15T09:47:40Z  in response to mark_laughton

        Hi Mark,

        You're not missing anything, I'm afraid. The Redbook was created against early versions of CICS Explorer. Since then there has been a lot of change!

        We did quite a bit of work for z/OS 2.1 to solidify the connections API and have produced Javadoc for it. This allows you to create your own connection types and manipulate connections.

        It would be useful to get an idea of whether you have a specific application in mind to write - I think there's an RFE for improving the documentation for the API, I'll see if I can find the number.

        • mark_laughton
          mark_laughton
          8 Posts
          ACCEPTED ANSWER

          Re: ExplorerHelloWorld example - ICPSM class errors

          ‏2013-11-15T18:58:39Z  in response to DaveN

          Hi Dave

          I guess I dont really have anything specific in mind yet, other than exploring the Explorer and understanding better what you can and can't do etc and maybe thinking about opportinuties to simplify some of the tasks we do or augment views.

          Although...I wrote a native Java application a few years back using AWT and 2D graphics classes, collecting topology and RTA data from the WUI 'data' interface to display a graphical topology view of our CICS and DB2 estate, along with the links between them - the hard work in that (apart from steep learning curve - my background is HLASM / COBOL / 3270) was the mechanics of drawing the view and retrieving / parsing data from the WUI.

          That seems like it'd be easier (and nicer/better integrated) done using CICS Explorer  - I quite fancy having a go at rewriting it...maybe....

          cheers

          Mark

           

          • DaveN
            DaveN
            71 Posts
            ACCEPTED ANSWER

            Re: ExplorerHelloWorld example - ICPSM class errors

            ‏2013-11-27T12:53:30Z  in response to mark_laughton

            Sounds interesting, Mark. Might be that we don't quite have all of the tables that you need, but keep us posted!

            We have some quite cool stuff for exploring the topology of your system in CICS DA (http://www-03.ibm.com/software/products/en/cics-deployment) - have you seen that?

            Updated on 2013-11-27T12:54:10Z at 2013-11-27T12:54:10Z by DaveN
            • mark_laughton
              mark_laughton
              8 Posts
              ACCEPTED ANSWER

              Re: ExplorerHelloWorld example - ICPSM class errors

              ‏2013-12-09T10:41:49Z  in response to DaveN

              Hi Dave

              Yes, spotted DA earlier this year - the graphical topology view looks similar to what I'm doing.

              So I've now got my basic 'view' working, drawing SWT widgets on a canvas to represent my systems, which I can drag around to position as I want.

              I guess I'll want to listen on selections in existing CICSrgn views to add systems to my model - either dran-n-drop or an 'add to topology view' pop-up menu. I've not coded that yet but doesn't seem too difficult (i hope!) - examples around on the WWW and in the Redbook. I've hardcoded adding systems to my model for the moment (the 'drawing' bit was more fun!). Connections between them will simply be 'discovered' when the view is refreshed.

              What I am struggling with is understanding enough about the CICS explorer model to be able to fetch both CICSRGN and CONNECT objects from CPSM (and later, RTA events). This also seems to have changed since the Redbook was published - CICSTypes is deprecated for example?

              So I was previously issuing WUI data imterface methods (for example):

              response = sendCommand("GET?OBJECT=CICSRGN&CONTEXT=" + theApp.getModel().getContext() + "&SCOPE=" + scope, null);

              response = sendCommand("FETCH?STUB="+stub+"&FIELDS=EYU_CICSNAME,CTSLEVEL,MVSSYSID,CICSSTATUS,CURRTASKS,MAXTASKS,SOSSTATUS.",

              null);

              where 'scope' is the system I'm querying the status of; and similar for CONNECT resource table.

              Would you give me a pointer as to how to do similar with the current Explorer model please? I've searched high and low for a working example...

              Thanks

              Mark

              • DaveN
                DaveN
                71 Posts
                ACCEPTED ANSWER

                Re: ExplorerHelloWorld example - ICPSM class errors

                ‏2013-12-10T10:49:55Z  in response to mark_laughton

                Hi Mark,

                That's some pretty low level code... Forming the URL yourself feels like heading down to the shed to fabricate a new oil filter for your car at annual service time...!

                At the moment, the simplest way to get hold of objects is using ICPSM.getDefinitions2, like this:

                        if (cpsm.isConnected()) {
                            try {
                                ICICSObject[] regionObjects = cpsm.getDefinitions2(RegionType.getInstance(), new Context("CICSEXP1"));
                                ICICSObject[] connectionObjects = cpsm.getDefinitions2(ConnectionType.getInstance(), new Context("CICSEXP1"));
                            } catch (CICSSystemManagerException e) {
                                e.printStackTrace();
                            }
                        }
                

                Or you can add a filter like this:

                            try {
                                FilteredContext context =  new FilteredContext(new Context("CICSEXP1"));
                                context.setAttributeValue(RegionType.TASK_COUNT, 3L);
                                ICICSObject[] regionObjects = cpsm.getDefinitions2(RegionType.getInstance(), context);
                                for (ICICSObject icicsObject : regionObjects) {
                                    MessageDialog.openInformation(
                                            window.getShell(),
                                            "Test",
                                            icicsObject.getName());
                                }
                            } catch (CICSSystemManagerException e) {
                                e.printStackTrace();
                            }
                

                We support scope like this:

                                Context plex = new Context("CICSEXP1");
                                IScopedContext scoped = new ScopedContext(plex, "Region1");
                

                IScopedContext is from com.ibm.cics.sm.comm.IScopedContext.

                Note that I'm not sure we'd consider this as API. By this what I'm saying is that it might change or not be available in future releases. Bear in mind, however, that we will always need to get resources from the server, so we are quite unlikely to take the function away, more likely to improve it to be more usable...!

                Dave

                • mark_laughton
                  mark_laughton
                  8 Posts
                  ACCEPTED ANSWER

                  Re: ExplorerHelloWorld example - ICPSM class errors

                  ‏2013-12-10T11:08:22Z  in response to DaveN

                  Hi Dave

                  I'd definately agreed with you on that! It is a documented 'client interface' though (just!) ...tucked away in the back of the WUI Interface Giude. It was all I had at the time (c.2008) :)

                  Many many thanks for this - it's the leg up I needed.  I'll give it a go!

                  "it might change or not be available in future releases." - undertsood - if it breaks I'll keep both halves. :)

                  thanks again - appreciate your time.

                  Mark

                  • DaveN
                    DaveN
                    71 Posts
                    ACCEPTED ANSWER

                    Re: ExplorerHelloWorld example - ICPSM class errors

                    ‏2013-12-10T11:11:52Z  in response to mark_laughton

                    No problem!

                    If it breaks, I hope it'll be because I can say "wow - check out the new, simple, way of doing it" :-)

                    • mark_laughton
                      mark_laughton
                      8 Posts
                      ACCEPTED ANSWER

                      Re: ExplorerHelloWorld example - ICPSM class errors

                      ‏2013-12-10T16:58:45Z  in response to DaveN

                      Hi Dave

                      getting there (slowly) - had a few problems with using correct imports which think I've solved now and retreving specific region objects.  Also realised I need to make my 'view' figure out which environment is being viewed and so display the correct topology map, wheres my non-Eclipse version you 'told' it which CICSplex you wanted to view (i.e. test/prod) so it connected to the relevent WUI server. Anyway...

                      Daft question - having retrieved, say, an array of Region objects, can I just then reference any of it's attributes by casting icicsObject to an IRegion object and using appropriate getters for that class e.g.?

                      for (ICICSObject icicsObject : regionObjects) {

                         IRegion region = (IRegion) icicsObject;

                      System.out.println(region.getTaskCount());

                      }

                      Must admit, Java generics are completely new to me and I'm finding a tad confusing - there's probably a 'better' way but I'm most definitely 'keep it simple'!

                      cheers

                      Mark

                       

                       

                      • DaveN
                        DaveN
                        71 Posts
                        ACCEPTED ANSWER

                        Re: ExplorerHelloWorld example - ICPSM class errors

                        ‏2013-12-10T20:47:34Z  in response to mark_laughton

                        Hi Mark,

                        I don't think you've even got as far as generics - that will truly blow your mind ;-) Panic when you see the < > angle brackets!

                        So with polymorphism, you're right - you view the objects as ICICSObject but that's just an interface which defines some generic behaviour (e.g. getName and getObjectType). As you say, the ICICSObject must be something more specific and IRegion is the most specific thing that your code will be able to get access to.

                        I think you could do the same kind of stuff by calling icicsObject.getAttributeValue(...) like this:

                        icicsObject.getAttributeValue(RegionType.CICS_START_TIME);
                        

                        But it is probably easier to program by casting to an IRegion because you can use auto-complete more effectively! Looks like you're well on the right track.

                        Dave

                        • mark_laughton
                          mark_laughton
                          8 Posts
                          ACCEPTED ANSWER

                          Re: ExplorerHelloWorld example - ICPSM class errors

                          ‏2013-12-12T12:47:29Z  in response to DaveN

                          Hi Dave

                          making progress - have basic view on which I can display systems and their respective connections. I'm adding systems to my view using a popup on class com.ibm.cics.core.model.internal.ManagedRegion and an 'Add system to view' action - that works but is tedious - I want to add mutliple systems in one operation.  

                          So I've defined a similar contribution to com.ibm.cics.core.model.internal.CICSRegionGroupDefinition which drives the same popup action class, and tests what type of object was selected in the CICSPlex Explorer tree view and acts accordingly.

                          The popup is driven ok , but I cant for the life of me figure out how to code the 'findrerences' method in CICSRegionGroupDefinition to retrieve 'systems in group' objects. I'll probably want to retrieve 'group in group' objects too.

                          I coded:

                            ICICSRegionGroupDefinition group = (ICICSRegionGroupDefinition) object;
                            ICICSRegionGroupDefinitionReference r = group.getCICSObjectReference();
                            ICICSObjectListFactory of = group.findReferences((IReferenceAttribute) r)

                          But get warning errors about 'raw types' on the findReferences stmt.

                          Its probably really simple (if you know how!). Could you point me in the right direction please?

                          appreciated...

                          Mark

                          • DaveN
                            DaveN
                            71 Posts
                            ACCEPTED ANSWER

                            Re: ExplorerHelloWorld example - ICPSM class errors

                            ‏2013-12-12T13:32:51Z  in response to mark_laughton

                            Hi Mark,

                            Just a quick reply - I don't think the findReferences method is the right one for this.

                            I think that with the current code you'd need to request the SystemSystemGroupEntryType and GroupSystemGroupEntryType objects to work out the group hierarchy.

                            Are you on our beta programme?

                            Dave

                            • mark_laughton
                              mark_laughton
                              8 Posts
                              ACCEPTED ANSWER

                              Re: ExplorerHelloWorld example - ICPSM class errors

                              ‏2013-12-16T10:59:59Z  in response to DaveN

                              Hi Dave

                              excellent, i'll take a look at that - thanks for the pointer. :)  

                              I guess an update of the Redbook isn't a 5 minute job but it''d maybe be great to have a small collection of "how to" examples, maybe as a sticky note on this forum?  I guess there's a very basic set of things most folks might want to do - pretty much the stuff covered in chapter 3 of the Redbook (i.e. obtaining a connection, retrieving basic objects from the equivalent CPSM resource tables, filtering, performing an action against a resource)...some of which we've covered in this thread :)

                              No, not on any Beta programme (wasnt aware of one tbh). I'd be interested, if you have any details...

                              cheers

                              Mark

                              • DaveN
                                DaveN
                                71 Posts
                                ACCEPTED ANSWER

                                Re: ExplorerHelloWorld example - ICPSM class errors

                                ‏2013-12-16T14:42:26Z  in response to mark_laughton

                                Hi Mark,

                                Yes - blog posts or similar are better candidates for this kind of "changes fairly frequently" (as in, more than once a decade!) information. It would be a good step to convert this exchange into a blog post!

                                If you're interested in learning more about the beta programme, even if only for information (the only way we can talk about our upcoming features is under NDA) then drop me an email at dave.nice@uk.ibm.com and I'll put you in touch with the right people.

                                Thanks!

                                Dave