-
Notifications
You must be signed in to change notification settings - Fork 4
MOGLiCC Tutorial Part A
Let's see how easily MOGLiCC can be set up:
1 - Download latest release and unzip it.
2 - Execute the MOGLiCC start script (this will make MOGLiCC to extract the embedded default data and to process these data).
3 - Move to the subdirectory ./input/StandardModelProvider, delete all files, and create a the new file SQLModelfile.txt with following content:
model SQLInsertData
class REMITTER
4 - Execute the start script and open ./report/generation.report to see that for all three generators the same message is reported: "No model matching input artefact found. Nothing to do."
5 - Move to the subdirectory ./input/VelocityModelBasedLineInserter and delete all subdirectories. Thereafter, create the new directory ./input/VelocityModelBasedLineInserter/SQLInsertScript (this represents a new input artefact for the VelocityModelBasedLineInserter) and there create the file Main.tpl with following content:
@TargetDir <applicationRootDir>
@TargetFileName insert.sql
@NameOfValidModel SQLInsertData
#set( $classDescriptorList = $model.getClassDescriptorList() )
#foreach( $classDescriptor in $classDescriptorList )
INSERT INTO $classDescriptor.name (id,name) VALUES ('id1','Peter Pepper');
#end
The first three lines represent the template header with meta information. The second four lines represent the template body. The three lines starting with the number sign are Velocity instructions to iterate over all classes of the model.
6 - Execute the start script and you will find the file insert.sql next to the start script. The sql file contains:
INSERT INTO REMITTER (id,name) VALUES ('id1','Peter Pepper');
7 - Now add the second class ORDER to your model file SQLModelfile.txt:
model SQLInsertData
class REMITTER
class ORDER
Restart MOGLiCC. This appears to create the same result. But why? - Wait, what's wrong? - Well, have a look into the generation report (see step 4) and see: "insert.sql did already exist and was NOT overwritten in 'applicationRootDir'". Ah ok, we have to allow MOGLiCC to overwrite the result file.
8 - Add the following line to your template header:
@CreateNew true
Restart MOGLiCC and you see two insert commands in the target file. Now, the preparation is finished and the basic setup of MOGLiCC is done. Let's see how to create a realistic use case.