Student: Federico Baldessari Email: federico.baldessari@studenti.unitn.it
The project is divided into 3 packages:
default package
: it containsXMLPeopleReader.java
that loads thepeople.xml
file and parses it using XPath to implement methods like getActivityDescription, getActivityPlace, printing all people in the list with details and more.jaxb
: it containsJaxbMarshaller.java
,JaxbUnMarshaller.java
,JsonMarshaller.java
that does the marshalling and un-marshallingmodel.generated
: it contains classes generated with JAXB XJC frompeople.xsd
that are used byJaxbMarshaller
,JaxbUnMarshaller
andJsonMarshaller
-
- "Extend the example above to include 20 people (maybe your friends with fake names)"
The result can be see in
src/people.xml
- "Extend the example above to include 20 people (maybe your friends with fake names)"
The result can be see in
-
- "Use XPath to implement methods like getActivityDescription and getActivityPlace. Use the person ID as parameter of the getters."
The functions are inside
XMLPeopleReader.java
- "Use XPath to implement methods like getActivityDescription and getActivityPlace. Use the person ID as parameter of the getters."
The functions are inside
-
- "Make a function that prints all people in the list with details."
The function is inside
XMLPeopleReader.java
. It was decided to print the people in the form:
using the private function printListPerson and printPerson------ Person info ------- -> person firstname Elia lastname Tasini birthdate 1993-01-02 -> activitypreference name Running description Sprint Running place Harena Stadium startdate 2017-09-13T11:50:00.0 --------------------------
- "Make a function that prints all people in the list with details."
The function is inside
-
- "Make a function that accepts the person id as parameter and prints the ActivityPreference of the person with that id."
The function is inside
XMLPeopleReader.java
. It was decided to use the same print format to print people details showing only activitypreference information
- "Make a function that accepts the person id as parameter and prints the ActivityPreference of the person with that id."
The function is inside
-
- "Make a function which accepts a date and an operator (=, > , <) as parameters and prints people which preferred activity start_date fulfill that condition (i.e., startdate>2017-13-10, startdate=2017-13-10, etc.)"
The function is inside
XMLPeopleReader.java
- "Make a function which accepts a date and an operator (=, > , <) as parameters and prints people which preferred activity start_date fulfill that condition (i.e., startdate>2017-13-10, startdate=2017-13-10, etc.)"
The function is inside
-
- "Create the XML schema XSD file for the example XML document of people."
The XSD file can be found in the root of the project
people.xsd
- "Create the XML schema XSD file for the example XML document of people."
The XSD file can be found in the root of the project
-
- "Write a java application that does the marshalling and un-marshalling using classes generated with JAXB XJC."
In the package
jaxb
:JaxbMarshaller.java
andJaxbUnMarshaller.java
uses classes generated with JAXB XJC inside packagemodel.generated
.JaxbUnMarshaller.java
generates a file 3people.xml in the root
- "Write a java application that does the marshalling and un-marshalling using classes generated with JAXB XJC."
In the package
-
- "Make your java application to convert also JSON (Create 3 persons using java and marshal them to JSON)"
In the package
jaxb
:JsonMarshaller
uses library jackson to generate file 3people.json. This is possible because classes inmodel.generated
uses JAXB annotation and Jackson allow use of JAXB annotations as an alternative (in addition to or instead of) standard Jackson annotations.
- "Make your java application to convert also JSON (Create 3 persons using java and marshal them to JSON)"
In the package
First clone the repository to a location of your choice by running:
git clone https://github.com/balde73/introsde-2017-assignment-1.git
cd introsde-2017-assignment-1
Now you are ready to execute
ant execute.evaluation
To make thing cleaner it is also possible to run a single step of the evaluation. Remember to run ant
before to compile classes and download libraries
// As default ant compiles and downloads everything needed
ant
// 1. Runs instruction 3 based on Lab 3
ant execute.step1
// 2. Runs instruction 4 based on Lab 3 with id = 5
ant execute.step2
// 3. Runs instruction 5 based on Lab 3 with startdate > 2017-10-13
ant execute.step3
// 4. > Runs instruction 7 based on Lab 4, executing marshaling to XML. Create 3 persons using java and marshal them to XML
ant execute.step4
// 5. > Runs instruction 7 based on Lab 4, executing un-marshaling from XML
ant execute.step5
// 6. > Runs instruction 8 based on Lab 4, executing marshaling to JSON. Create 3 persons using java and marshal them to JSON
ant execute.step6