Thursday, 4 February 2016

Building Lemma using XText

The main way to build a new language/DSL using XText is to first define the grammar.

Initially we create a basic grammar as follows:

grammar com.beenleigh.lemma.Lemma with org.eclipse.xtext.common.Terminals

This is an import statement for the entities - such as ID - which are defined in the XText Terminals grammar.
generate lemma "http://www.beenleigh.com/lemma/Lemma"

Lemmamodel :
    (elements += AbstractItem)*
;

Here we are defining the overall language, which consists of zero or more DataItems, the exact structure is yet to be defined.

DataModel:
    'DataModel' name = QualifiedName '{'
    (elements += AbstractItem)*
    '}'
;







The DataModel is a uniquely identified metamodel for a particular dataset, and so it is acting in the same way as a package is for java, or as a namespace is for XML. It can contain any number of Lemma entities, or AbstractItems.


AbstractItem:
    DataModel | DataClass | DataType | Import
;

Currently we can compose a DataModel of Imports, DataClasses and DataTypes - although later we may expand this to include DataElements and other DataItems.

QualifiedName:
        ID('.' ID)*
;

This allows an ID to consist of name sections, separated by a 'dot'.
Import:
    'import' importedNamespace = QualifiedNameWithWildcard
;

QualifiedNameWithWildcard:
    QualifiedName '.*'?
;
This allows us to import other DataModels, or rather components from other data models into the DataModel, using the ID system already loosely defined. For an individual registry these id's would be completely unique and implemented as IRI's.


DataType:
    'datatype' name = ID
;

This allows is to uniquely identify a DataType - or type, normally these would be given as "int", "char", etc

DataClass:
    'DataClass' name = ID ('extends' superType = [DataClass])? '{'
      (dataelements += DataElement)*
      '}'
;

This allows us to implement DataClasses, which can "extend" other DataClasses, for Lemma this means a kind of subtyping, since we are not - as yet - including operations in the language.

DataElement:
    (many ?= 'many')? name = ID ':' type = [DataType|QualifiedName]
;


 This relies on the xtext "Terminals" package, so the ID is simply a string, and is defined in that package. We need the ID to be unique, not just any old name, however that can be better enforced in the code generator.

First we take the XText grammar and generate artefacts:
















And then we take the XText file and generate the Lemma editor/environment:


















This means that after opening a new instance of eclipse (with these plugins referenced) we can start to write in Lemma, and eclipse will act as an editor:





This gives a basis for this data language, now we need to transform some XSD datasets into it and begin work on using model driven engineering to build new applications.







Tuesday, 6 August 2013

Spring MVC Notes


First we need to set up the gradle environment.

On a mac/unix environment the easiest way to edit file is using vi - a terminal based file editor - although it takes a little practice if arriving from a windows based environment - essentially the main thing to remember are that there are 2 modes - a viewing mode (default) and an editing/insert mode - you switch between the two by pressing I to get into edit mode, and then press Esc to get out.  To quit you type in :q!, but to quit and write everything you've just changed type in :wq!.  Best to goto an online vi crib sheet and play around a bit.

1. Setup gradle - download and unzip
2. Open terminal, and type in vi .profile
3. Goto a suitable line and type I (for Insert)
4. Type PATH=$PATH:/Users/software/gradle1.6/bin
5. then Esc (change mode) and :wq! - to write and quit vi.
6. Shut down the terminal and open another one up and test it by typing in gradle.

Now go off to the code directory and run gradle to build the environment.

>gradle build

to do a build - and that should be it, gradle takes care of versioning and building - in a similar way to maven.




Mysql

Startup:

shell> mysqladmin -u root password "newpwd"
shell> mysqladmin -u root -h host_name password "newpwd"
 
mysql> CREATE USER 'mdr'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'mdr'@'localhost' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)



Friday, 7 June 2013

Roo persistence

Trying to get Roo to persist files - using byte array in Java, Hibernate and Postgres.

so far no luck, so trying Mysql.

First install on macbook - change path.

sudo vi /etc/path

add in the path to the download of mysql5.*

then change admin passwords: 

mysqladmin -u root password 'newpassword'

and set up a test database - back in through the command line:

mysql -u root -p 'newpassword'

>CREATE DATABASE mdrlite;

>CREATE USER 'mdradmin'@'localhost' IDENTIFIED BY 'password'

> GRANT ALL PRIVILEGES ON mdrlite.* TO 'mdradmin'@'%'  (so it can be accessed from anywhere)


So now we set up a roo instance and try out the byte array code again....but we get the same problem again :-(

e.g.





which is all down to not importing the javax.persstence.Lob in the java file.







Saturday, 1 December 2012

AWS

A bit of a struggle getting access to my AWS instance. After Azure AWS is rather more work, Azure has a windows remote connection, so it just a matter of connecting, and then using the windows user interface - easy!

AWS is command line on, since only port 22 and 80 are open by default, although Azure did involve re-setting up the fairwall, and access to the VM, so to be fair there is still configuration to do with Azure.

SSH on AWS is relatively straightforward, since it mentioned from the "connect" window, simply type the suggested parameters from Terminal, although you must ensure that SSH can 'see' the PEM file - either login from the same directory, or enter the details into the .bashrc file.

ssh -i mykey.pem ec2-user@ec2-XX-XX-XXX-XX.compute-X.amazonaws.com


SFTP is a bit more difficult, and it took me a while to find the right set of switches to get sftp to 'see' the PEM file. In this case we need to enter:

sftp -oIdentityFile=/fullpathtomykey/mykey.pem ec2-user@ec2-XX-XX-XX-XX.compute-X.amazonaws.com
for some reason running this in the same directory as the key file doesn't work, the full path needs to be added in.

I've uploaded the latest version of Nutch, however it seems that instead of un-archiving itself into a "nutch" directory, it does so in the current directory - which was not intended.  As a result I have had to remove all traces of files/directories and then mkdir a new nutch sub directory, cd into it and do the tar-zxvf from there.....however rm -r doesn't work, so I needed
rm rf docs/
It seems that every version of linux requires different options, anyhow we need the 'force' option here to remove stuff....

ROO

I've decided to build the latest version of the MDR using some domain-driven tools, and the first to go is Spring ROO. I want to then compare this to building with MS Lightswitch - on the .NET domain, and Apache ISIS again in the Java domain. It may be interesting to look at GRAILS and Ruby as alternatives - the only problem is time....too much to do....

Thursday, 27 September 2012

SBMF2012 - Brazilian Formal Methods Symposium

Well, after a while of not coding and a lot of reading and paper writing a few days in the sun......and an award!?  (Fifth Best Paper of the conference - arguably room for improvement, but clearly better than a kick in the teeth.....and since it's my first contribution to a published academic paper I'm quite chuffed....read it here....http://www.springerlink.com/content/wxu50184400j2347/)



Now a bit more paper writing and perhaps a little kite surfing.