Ptt1819 Assignment2

Metaprogramming for Validation

Task

You've learned how mapping technologies work. Your next task is to validate for restricted subsets that generated artifacts correctly correspond to their input artifacts. As a simplification, data models always correspond to trees (the 101company data model defines a tree structure). There are always one-to-one traces. E.g., one part of a POJO has one corresponding part in an XSD schema file.

  • Choose one of the tasks below.
    • Search for a Demo example (e.g., 101 contributions)
No Contribution Group
1 ANTLR - Grammar rule to code Nils und André
2 XSD to Java-POJO Stab
3 Java Object to XML Philipp und Bartosz
4 Java Object to JSON Tim und Anita
(5) Java to SQL-DDL

Details

For two input files return true, if the correspondence is correct. Otherwise, return false. Use the following technologies for metaprogramming. The absolute minimum requirement for passing assignment 2 is given.

  1. ANTLR grammar to code
    1. Parse grammars like Company.g4, using an existing ANTLR-Parser.
    2. Process the generated Java code in the <Name>BaseListener using Java Parser
    3. At least, show that for every Parser-rule (not Lexer-rule) name, a dedicated stub-method was generated in the BaseListener.
  2. XSD to Java-POJO.
    1. Parse XSD using DOM
    2. Parse Java code using Java Parser
    3. At least, show that every Java class has its corresponding XSD counterpart.
  3. Java-Object to XML
    1. Process Java-Objects using Java's reflection API.
    2. Process XML using DOM.
    3. At least, show that for every object in the input object-tree there exists a counterpart in the XML file.
  4. Java-Object to JSON
    1. Process Java-Objects using Java's reflection API.
    2. Process JSON using GSON.
    3. At least, show that for every object in the input object-tree there exists a counterpart in the JSON-file.
  5. Java to SQL-DDL:
    1. Beware!! For projects using Hibernate or JPA, you will first need to find out how to retrieve the generated Create-Statement. Then, you can proceed.
    2. Process Java code using Java Parser.
    3. Process SQL code using ANTLR
    4. At least show: One create statement exists for every class and every object-to-object association.

Submission

  • Create a new git-repository. Send the link to ed.znelbok-inu|znieh#ed.znelbok-inu|znieh via E-Mail.
    • In a Readme file: Explain the specific problem that you solve with an example. Explain how you solve it.
    • Use Maven or Gradle for building your project.
    • Have at least two distinct test cases. One with the 101companies model and one additional data model that you may define yourself.