↓ Skip to main content

Groovy

ATG Module Diagram Generator

·302 words·2 mins
I have found local clone of this repo while cleaning up the disk. The source was originally residing in private repo on Bitbucket which I moved to GitHub: https://github.com/miroadamy/atgdiagram What it does # Groovy scripts: https://github.com/miroadamy/atgdiagram/blob/master/src/listATGModules.groovy https://github.com/miroadamy/atgdiagram/blob/master/src/ATGModule.groovy that scan local ATG installation, discover modules and generate the PlantUML file representing it, for example - https://github.com/miroadamy/atgdiagram/blob/master/uml/test2.uml Using ATG_ROOT from environment variable $ATG_ROOT: /opt/ATG/ATG10.0.2 Using /opt/ATG/ATG10.0.2 installation Dependants of module TWeStore.eStore => [DCS.Search.Query, B2CCommerce, DAF.Search.Query, DAF.Search.Base, DCS.Search.common, DPS.Search.Index, DAF.Search.common, DAS-UI, DCS.Search.Index, DPS, DCS, DCS.Search.CustomCatalogs, DCS.Search.CustomCatalogs.Query, DCS.Search.CustomCatalogs.Index, DAF.Search.Routing, DCS.Search.CustomCatalogs.common, DAF.Search.Index, DSS, DCS.CustomCatalogs, DAS] @startuml Object TWeStore_eStore Object DCS Object B2CCommerce Object DCS_Search_CustomCatalogs Object DAF_Search_Routing Object DCS_CustomCatalogs Object DPS Object DCS_Search_CustomCatalogs_Query Object DAF_Search_Base Object DCS_Search_CustomCatalogs_Index Object DSS Object DAS_UI Object DCS_Search_Query Object DCS_Search_CustomCatalogs_common Object DAS Object DCS_Search_Index Object DAF_Search_Query Object DCS_Search_common Object DPS_Search_Index Object DAF_Search_Index Object DAF_Search_common TWeStore_eStore <|-- DCS TWeStore_eStore <|-- DCS_CustomCatalogs TWeStore_eStore <|-- B2CCommerce TWeStore_eStore <|-- DCS_Search_CustomCatalogs TWeStore_eStore <|-- DAF_Search_Routing DCS <|-- DPS DCS <|-- DSS B2CCommerce <|-- DCS DCS_Search_CustomCatalogs <|-- DCS_Search_CustomCatalogs_Index DCS_Search_CustomCatalogs <|-- DCS_Search_CustomCatalogs_Query DAF_Search_Routing <|-- DAS_UI DAF_Search_Routing <|-- DAF_Search_Base DCS_CustomCatalogs <|-- DCS DPS <|-- DAS DCS_Search_CustomCatalogs_Query <|-- DCS_Search_Query DCS_Search_CustomCatalogs_Query <|-- DCS_Search_CustomCatalogs_common DAF_Search_Base <|-- DAS_UI DCS_Search_CustomCatalogs_Index <|-- DCS_Search_Index DCS_Search_CustomCatalogs_Index <|-- DCS_Search_CustomCatalogs_common DSS <|-- DPS DAS_UI <|-- DAS DCS_Search_Query <|-- DAF_Search_Query DCS_Search_Query <|-- DCS_Search_common DCS_Search_Query <|-- DCS DCS_Search_CustomCatalogs_common <|-- DCS_Search_common DCS_Search_CustomCatalogs_common <|-- DCS_CustomCatalogs DCS_Search_Index <|-- DPS_Search_Index DCS_Search_Index <|-- DCS_Search_common DCS_Search_Index <|-- DCS DAF_Search_Query <|-- DAF_Search_common DCS_Search_common <|-- DAF_Search_common DCS_Search_common <|-- DCS DPS_Search_Index <|-- DPS DPS_Search_Index <|-- DAF_Search_Index DAF_Search_Index <|-- DAS_UI DAF_Search_Index <|-- DAF_Search_Base DAF_Search_common <|-- DAS_UI DAF_Search_common <|-- DAF_Search_Base DAF_Search_common <|-- DAF_Search_Routing @enduml This UML file is the processed by PlantUML

ATG Repository structure visualizer

·311 words·2 mins
The groovy script does parse the XML files (scraped from dyn-admin, or output of the XML combine) and produces file in the syntax of Plant UML - http://plantuml.sourceforge.net if (args.size() == 0) { println "Usage: groovy extractItems.groovy XMLFILE-IN-GSA-FORMAT.xml" System.exit(1) } def gsaFile = new XmlSlurper().parseText(new File(args[0]).text) def desc = gsaFile.'item-descriptor' def processItemDescriptor(myDesc) { def info = [:] def tables = [] def props = [:] def descriptors = [:] for (table in myDesc.table) { String tableName = table.@name.text() tables += tableName // collect table's properties for (prop in table.property) { String name = "${prop.@name.text()}(${tableName})".replaceAll(/[ -]/, '_') props[name] = [:] if ("${prop.@'required'.text()}" != "") { props[name]['required'] = "${prop.@'required'.text()}" } if ("${prop.@'hidden'.text()}" != "") { props[name]['hidden'] = "${prop.@'hidden'.text()}" } if ("${prop.@'item-type'.text()}" != "") { props[name]['item-type'] = "${prop.@'item-type'.text()}" descriptors["${prop.@name.text()}"] = "${prop.@'item-type'.text().replaceAll(/[ -]/, '_')}" } } } info['tables'] = tables // scan for properties outside of tables for (prop in myDesc.property) { String name = "${prop.@name.text()}".replaceAll(/[ -]/, '_') props[name] = [:] if ("${prop.@'item-type'.text()}" != "") { props[name]['item-type'] = "${prop.@'item-type'.text()}" } } info['properties'] = props info['descriptors'] = descriptors return info } println "Got ${desc.size()} item-descriptors" println "@startuml" for (idesc in desc) { def info = processItemDescriptor(idesc) def name = "${idesc.@name.text().replaceAll(/[ -]/, '_')}" println "\nclass ${name} {" for (p in info.tables) println "\t"+p println ".." for (p in info.properties) println "\t"+p println "}" for (p in info.descriptors?.keySet()) println "\t ${name} *-- ${info.descriptors[p]} : ${p}" } println "@enduml" The generation (requires installed dot tools)

Recreate txt base graph generator

Graphviz # This time using brew ➜ DPS brew install graphviz ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/graphviz-2.38.0.mavericks.bottle.tar.gz ######################################################################## 100.0% ==> Pouring graphviz-2.38.0.mavericks.bottle.tar.gz 🍺 /usr/local/Cellar/graphviz/2.38.0: 469 files, 68M ➜ DPS dot -V dot - graphviz version 2.38.0 (20140413.2041) ➜ DPS Schema Spy # From http://sourceforge.net/projects/schemaspy/files/schemaspy/SchemaSpy%205.0.0/ To /opt/diagram Run: diagram java -jar ./schemaSpy_5.0.0.jar -cp .:/Users/miro/lib/jdbc/mysql-connector-java-5.1.26-bin.jar -t mysql -o library -host localhost -u training -db training_dev01 -p training

ATG Groovy TDD

·63 words·1 min
Got it working. It is a bit rough around the edges, but functional. The two components http://localhost:8080/dyn/admin/nucleus/thinkwrap/twatg/script/GroovyDemoScript/ http://localhost:8080/dyn/admin/nucleus/thinkwrap/twatg/script/GroovyScriptRunner/ The are not started via Initial, but that is not a problem. The script tested: class ThatsGroovyDude implements com.thinkwrap.twatg.script.RunnableScript { atg.nucleus.Nucleus nuc = atg.nucleus.Nucleus.getGlobalNucleus(); public String run() { String s = ""; nuc.configPathNames.each { s += "${it}\n" } return "Hello World!\n\n" + s; } }

GVM

Installed GVM from: http://gvmtool.net ~ $ curl -s get.gvmtool.net | bash Thanks for using _____/\\\\\\\\\\\\__/\\\________/\\\__/\\\\____________/\\\\_ ___/\\\//////////__\/\\\_______\/\\\_\/\\\\\\________/\\\\\\_ __/\\\_____________\//\\\______/\\\__\/\\\//\\\____/\\\//\\\_ _\/\\\____/\\\\\\\__\//\\\____/\\\___\/\\\\///\\\/\\\/_\/\\\_ _\/\\\___\/////\\\___\//\\\__/\\\____\/\\\__\///\\\/___\/\\\_ _\/\\\_______\/\\\____\//\\\/\\\_____\/\\\____\///_____\/\\\_ _\/\\\_______\/\\\_____\//\\\\\______\/\\\_____________\/\\\_ _\//\\\\\\\\\\\\/_______\//\\\_______\/\\\_____________\/\\\_ __\////////////__________\///________\///______________\///__ Will now attempt installing... Looking for a previous installation of GVM... Looking for JAVA_HOME... Validating JAVA_HOME... Looking for unzip... Looking for curl... Installing gvm scripts... Create distribution directories... Create candidate directories... Download script archive... Extract script archive... Install scripts... Make init script executable... Prime config file... Attempt update of bash profiles... Updated existing /Users/miro/.bash_profile Updated existing /Users/miro/.profile Updated existing /Users/miro/.bashrc Attempt update of zsh profiles... Created and initialised /Users/miro/.zshrc Clean up local variables... All done! Please open a new terminal, or run the following in the existing one: source "/Users/miro/.gvm/bin/gvm-init.sh" Then issue the following command: gvm help Enjoy!!! Using # binsh $ gvm current Using: groovy: 2.0.6 grails: 2.2.0 griffon: 1.1.0 gradle: 1.3 vertx: 1.3.0.final Fix for zsh # http://blog.andresteingress.com/2012/12/14/gvm-the-groovy-environment-manager/

ATG module graph

Notes from weekend hack: # Project is in Bitbucket - https://bitbucket.org/miroadamy/atgdiagram/overview Run # in Diagrams/ATGDiagram Radegast:ATGDiagram miro$ groovy -cp src src/listATGModules.groovy -e -m TWeStore.eStore >uml/test2.uml Radegast:ATGDiagram miro$ ./processUml.sh uml/test2.uml Radegast:ATGDiagram miro$ open uml/test2.png Radegast:ATGDiagram miro$ => Output test2.uml the ‘.’ in names is converted to ‘_’ - GraphViz does not like it the ‘-’ in names detto Using ATG_ROOT from environment variable $ATG_ROOT: /opt/ATG/ATG10.0.2 Using /opt/ATG/ATG10.0.2 installation Dependants of module TWeStore.eStore => [DCS.Search.Query, B2CCommerce, DAF.Search.Query, DAF.Search.Base, DCS.Search.common, DPS.Search.Index, DAF.Search.common, DAS-UI, DCS.Search.Index, DPS, DCS, DCS.Search.CustomCatalogs, DCS.Search.CustomCatalogs.Query, DCS.Search.CustomCatalogs.Index, DAF.Search.Routing, DCS.Search.CustomCatalogs.common, DAF.Search.Index, DSS, DCS.CustomCatalogs, DAS] @startuml Object TWeStore_eStore Object DCS Object B2CCommerce Object DCS_Search_CustomCatalogs Object DAF_Search_Routing Object DCS_CustomCatalogs Object DPS Object DCS_Search_CustomCatalogs_Query Object DAF_Search_Base Object DCS_Search_CustomCatalogs_Index Object DSS Object DAS_UI Object DCS_Search_Query Object DCS_Search_CustomCatalogs_common Object DAS Object DCS_Search_Index Object DAF_Search_Query Object DCS_Search_common Object DPS_Search_Index Object DAF_Search_Index Object DAF_Search_common TWeStore_eStore <|-- DCS TWeStore_eStore <|-- DCS_CustomCatalogs TWeStore_eStore <|-- B2CCommerce TWeStore_eStore <|-- DCS_Search_CustomCatalogs TWeStore_eStore <|-- DAF_Search_Routing DCS <|-- DPS DCS <|-- DSS B2CCommerce <|-- DCS DCS_Search_CustomCatalogs <|-- DCS_Search_CustomCatalogs_Index DCS_Search_CustomCatalogs <|-- DCS_Search_CustomCatalogs_Query DAF_Search_Routing <|-- DAS_UI DAF_Search_Routing <|-- DAF_Search_Base DCS_CustomCatalogs <|-- DCS DPS <|-- DAS DCS_Search_CustomCatalogs_Query <|-- DCS_Search_Query DCS_Search_CustomCatalogs_Query <|-- DCS_Search_CustomCatalogs_common DAF_Search_Base <|-- DAS_UI DCS_Search_CustomCatalogs_Index <|-- DCS_Search_Index DCS_Search_CustomCatalogs_Index <|-- DCS_Search_CustomCatalogs_common DSS <|-- DPS DAS_UI <|-- DAS DCS_Search_Query <|-- DAF_Search_Query DCS_Search_Query <|-- DCS_Search_common DCS_Search_Query <|-- DCS DCS_Search_CustomCatalogs_common <|-- DCS_Search_common DCS_Search_CustomCatalogs_common <|-- DCS_CustomCatalogs DCS_Search_Index <|-- DPS_Search_Index DCS_Search_Index <|-- DCS_Search_common DCS_Search_Index <|-- DCS DAF_Search_Query <|-- DAF_Search_common DCS_Search_common <|-- DAF_Search_common DCS_Search_common <|-- DCS DPS_Search_Index <|-- DPS DPS_Search_Index <|-- DAF_Search_Index DAF_Search_Index <|-- DAS_UI DAF_Search_Index <|-- DAF_Search_Base DAF_Search_common <|-- DAS_UI DAF_Search_common <|-- DAF_Search_Base DAF_Search_common <|-- DAF_Search_Routing @enduml Visualization (uml/test2.png) #

Bye bye Ruby, hello Groovy

·1049 words·5 mins
I first time discovered Ruby back in 2006 (yes, I know, I was late to the game), and immediately fell in love with it. The dynamic nature of the language, the consistency, pure esthaetics and practicality certainly changed the way how I saw software development and programming languages. Since that time, I made several attempts to integrate Ruby into my professional life and make it part of the toolbox. It was cool to play with Ruby in my spare time, but I wanted to use it on projects whose main development language/platform was mainly Java. Use it as scripting, glue language. Use it as toolkit language to e.g. generate test data, access databases, convert files, build projects and maybe even build a piece of Web applications (admin apps for example).

Trying out Groovy with Oracle database

·815 words·4 mins
There is a saying that necessity is the mother of invention. Such necessity happened last week and forced me to try out the Groovy language. The trigger was need for creating good data set for testing changes in a full text search. I had to locate few hundred of obsolete technical documents to be used as test data, dump the metadata as well as the BLOB data to disc, create INSERT sql scripts and loader that would from Ant pre-load the database with the test set and insert the BLOB's. It is fairly simple task, the issue were boundary conditions:

Showstopper issue with JRuby ?

·606 words·3 mins
After some break, I dusted off the Ruby to try out one interesting idea Peter presented yesterday that literally ASKS for Rails. So I grabbed the latest and greatest RubyNetBeans from Ruby Hudson. For some reason it stopped updates on January 26th so the latest version I have got was build 6327. It is bundled with JRuby 1.1RC1 and the Rails version that comes preinstalled is 1.2.6. Using the menu Tools -> Ruby Gems, they can be easily upgraded to latest and greatest 2.0.2.