5 Replies Latest reply: Feb 6, 2014 11:10 AM by Justin B-Oracle RSS

    Unable to cast objects in SQL DM 4.0 Transformation Script

    Justin B-Oracle

      Hi,

       

      In SQL DM 3.3, I am able to cast objects but in SQL DM 4.0.0.833 and groovy 2.0.0 I am not.

       

      Here is an example, the code doesn't execute past the StorageDesignOracle cast. Model is a accessable from the class so that isn't the issue

       

      StorageDesignOracle d = (StorageDesignOracle) model.getStorageDesign();

       

      import groovy.swing.SwingBuilder;

      import java.awt.event.ActionListener;

      import java.awt.event.ActionEvent;

      import oracle.dbtools.crest.model.design.storage.oracle.StorageDesignOracle;

      import oracle.dbtools.crest.model.design.relational.RelationalDesign;

       

      new GUI(model);

       

      /**

      * Method will construct the GUI components

      */

       

      class GUI{

          RelationalDesign model = null;

       

          public GUI(RelationalDesign model){

              this.model = model;

              initGUI();

          }

       

          private void initGUI(){

              SwingBuilder.build {

                  frame(title: 'Add Sequence', size: [400,250], visible:true ) {

                      button(id:'btnAddSequence', text:'Add Sequence');

                  }

                  btnAddSequence.addActionListener(new ButtonAddSequenceListener());

              }

          }

         

          private void log(String str){

              oracle.dbtools.crest.swingui.ApplicationView.log(str);

          }

       

          class ButtonAddSequenceListener implements ActionListener{

       

              public ButtonAddSequenceListener(){

                  log("ButtonAddSequenceListener initialized");

              }

             

              @Override

              public void actionPerformed(ActionEvent e) {

                  log("before get storage design");

                  StorageDesignOracle d = (StorageDesignOracle) model.getStorageDesign();

                  log("after get storage design");

              }

          }

      }

        • 1. Re: Unable to cast objects in SQL DM 4.0 Transformation Script
          Philip Stoyanov-Oracle

          Hi Justin,

           

          is it set to Oracle in relational model properties dialog?

          Can you get the name of StorageDesign you are receiving - getName() and RDBMS type using getRDBMSType()

          My guess is that your system data types directory doesn't contain defaultRDBMSSites.xml and types.xml distributed with Data Modeler 4.0

           

          Philip

          • 2. Re: Unable to cast objects in SQL DM 4.0 Transformation Script
            Justin B-Oracle

            I have added this to the action performed method

             

                 @Override

                    public void actionPerformed(ActionEvent e) {

                        log("before storage design");

                        log("Name: " + model.getStorageDesign().getName());

                        log("Type: " + model.getStorageDesign().getRDBMSType());

                        StorageDesignOracle d =  (StorageDesignOracle) model.getStorageDesign();

                        log("after storage design");

                    }

             

            Here is the output... still doesn't make it to after storage design:

            2014-02-05 09:20:14 - before storage design

            2014-02-05 09:20:14 - Name: Oracle Database 11g

            2014-02-05 09:20:14 - Type: Oracle Database 11g

             

             

             

            What do you mean "system data types directory doesn't contain defaultRDBMSSites.xml and types.xml"?

            /drives/c/Program Files (x86)/datamodeler/datamodeler/datamodeler/types

            ls -l

            total 247

            -rwx------    1 Administ UsersGrp     28651 Jan 31 13:43 custom_report_templates.xml

            -rwx------    1 Administ UsersGrp      1399 Jan 31 13:43 defaultRDBMSSites.xml

            -rwx------    1 Administ UsersGrp     14852 Jan 31 13:43 dl_settings.xml

            -rwx------    1 Administ UsersGrp    327491 Feb  4 13:42 dr_custom_scripts.xml

            -rwx------    1 Administ UsersGrp     45865 Jan 31 13:43 old_defaultdomains.xml

            -rwx------    1 Administ UsersGrp        74 Feb  4 13:43 saved_search.xml

            -rwx------    1 Administ UsersGrp     73740 Jan 31 13:43 types.xml

            • 3. Re: Unable to cast objects in SQL DM 4.0 Transformation Script
              Philip Stoyanov-Oracle

              your code work for me with groovy 2.2.1 and Java32(1.7.0_15) and Java64(1.7.0_40) - I have "after get storage design" in Log window.

              One observation - your frame stay active but I got message "transformation finished" - probably you should use something modal otherwise your UI won't have access to the context.

              What do you mean "system data types directory doesn't contain defaultRDBMSSites.xml and types.xml"?

              You can change location of types directory (it's "system data types directory") in prefer3ences - "Tools>Preferences>Data Modeler" - it's possible that location there (if set) doesn't contain valid files (probably files distributed with DM 3.3).

               

              Philip

              • 4. Re: Unable to cast objects in SQL DM 4.0 Transformation Script
                Justin B-Oracle

                Hi

                 

                Java(TM) Platform1.7.0_51
                Oracle IDE4.0.0.833
                Versioning Support4.0.0.833

                 

                I have updated my version of groovy and java and I still see the problem. I was able to find a workaround though which I find strange.

                If I add StorageDesignOracle sdo = null; at the beginning of the class, the code works fine... If I comment out the declaration, the script quits and does not give me an error message

                 

                Here is the output:

                2014-02-06 10:55:13 - Java Version: 1.7.0_51

                2014-02-06 10:55:13 - Groovy Version: 2.2.1

                2014-02-06 10:55:15 - before get storage design

                 

                Here is the code

                import groovy.swing.SwingBuilder;

                import java.awt.event.ActionListener;

                import java.awt.event.ActionEvent;

                import oracle.dbtools.crest.model.design.storage.oracle.StorageDesignOracle;

                import oracle.dbtools.crest.model.design.relational.RelationalDesign;

                 

                new GUI(model);

                 

                /**

                * Method will construct the GUI components

                */

                 

                class GUI{

                    RelationalDesign model = null;

                    //StorageDesignOracle sdo = null;

                 

                    public GUI(RelationalDesign model){

                               log("Java Version: " + System.getProperty("java.version"));

                            log("Groovy Version: " + new groovy.lang.GroovySystem().getVersion());

                        this.model = model;

                        initGUI();

                    }

                 

                    private void initGUI(){

                        SwingBuilder.build {

                            frame(title: 'Add Sequence', size: [400,250], visible:true ) {

                                button(id:'btnAddSequence', text:'Add Sequence');

                            }

                            btnAddSequence.addActionListener(new ButtonAddSequenceListener());

                        }

                    }

                 

                    private void log(String str){

                        oracle.dbtools.crest.swingui.ApplicationView.log(str);

                    }

                 

                    class ButtonAddSequenceListener implements ActionListener{

                      

                         @Override

                        public void actionPerformed(ActionEvent e) {

                                try{

                                    log("before get storage design");

                                    StorageDesignOracle d = (StorageDesignOracle) model.getStorageDesign();

                                    log("after get storage design");

                                }catch(Exception ex){

                                    log("Error: " + ex.toString());

                                }

                        }

                    }

                }

                 

                After I uncomment line 15, which is StorageDesignOracle sdo = null... I get the below output

                 

                2014-02-06 10:55:06 - Java Version: 1.7.0_51

                2014-02-06 10:55:06 - Groovy Version: 2.2.1

                2014-02-06 10:55:07 - before get storage design

                2014-02-06 10:55:07 - after get storage design

                • 5. Re: Unable to cast objects in SQL DM 4.0 Transformation Script
                  Justin B-Oracle

                  I have also checked Tools -> Preferences -> Data Modeler and all the paths on this page are empty