<repo_name>chinhnk/TIES437-01<file_sep>/TIES437-service/src/main/java/ties437/service/entities/City.java
package ties437.service.entities;

import org.json.simple.JSONObject;
import ties437.service.commons.OntologyConstants;

/**
 * Created by chinhnk on 4/3/2017.
 */
public class City extends Entity{

    public static final String TYPE_URI = OntologyConstants.PREFIX_CB + "City";

    private String name;
    private double latitude;
    private double longitude;

    public City(String uri) {
        super(uri);
    }

    public City(String uri, String name, double latitude, double longitude) {
        super(uri);
        this.name = name;
        this.latitude = latitude;
        this.longitude = longitude;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    @Override
    public String toString() {
        return "City{" +
                "uri=" + uri +
                ", name='" + name + '\'' +
                ", latitude=" + latitude +
                ", longitude=" + longitude +
                '}';
    }

    public JSONObject toJSON() {
        JSONObject obj = new JSONObject();

        obj.put("uri", this.uri);
        obj.put("name", this.name);
        obj.put("latitude", this.latitude);
        obj.put("longitude", this.longitude);

        return obj;
    }
}
<file_sep>/TIES437-service/src/main/java/ties437/service/entities/Entity.java
package ties437.service.entities;

/**
 * Created by chinhnk on 4/3/2017.
 */
public class Entity {
    protected String uri;
//    private List<Literal>

    public Entity(String uri) {
        this.uri = uri;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Entity)) return false;

        Entity entity = (Entity) o;

        return getUri().equals(entity.getUri());

    }

    @Override
    public int hashCode() {
        return getUri().hashCode();
    }
}
<file_sep>/TIES437-service/src/main/java/ties437/service/servlets/CityServlet.java
package ties437.service.servlets;

import org.apache.jena.rdf.model.Model;
import org.json.simple.JSONArray;
import ties437.service.commons.RdfUtils;
import ties437.service.dao.CityDAO;
import ties437.service.entities.City;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * Created by chinhnk on 1/4/2016.
 */
@WebServlet("/city")
@MultipartConfig
public class CityServlet extends HttpServlet {

    public static final String PATH = "/city";

    public static final String RDF_FILE_RELATIVE_URL = "/resources/rdf/cottage-booking-data.rdf";

    private Model model;

    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);

        ServletContext context = config.getServletContext();
        String fullPath = context.getRealPath(RDF_FILE_RELATIVE_URL);
        // load data from rdf file
        this.model = RdfUtils.getModelFromRDF(fullPath);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        JSONArray cityArray = new JSONArray();
        List<City> cityList = CityDAO.getAll(this.model);
        
        for (City city : cityList) {
            cityArray.add(city.toJSON());
        }

        response.setCharacterEncoding("UTF-8");
        PrintWriter writer = response.getWriter();
        writer.print(cityArray);
    }
}
<file_sep>/TIES437-service/src/main/java/ties437/service/entities/Cottage.java
package ties437.service.entities;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import ties437.service.commons.OntologyConstants;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by chinhnk on 4/3/2017.
 */
public class Cottage extends Entity {

    public static final String TYPE_URI = OntologyConstants.PREFIX_CB + "Cottage";

    private String name;
    private double latitude;
    private double longitude;
    private double distanceToLake;
    private String imageURL;
    private List<Bedroom> bedroomList = new ArrayList<Bedroom>();
    private List<Booking> bookingList = new ArrayList<Booking>(); 

    public Cottage(String uri) {
        super(uri);
    }

    public Cottage(String uri, String name, double latitude, double longitude, double distanceToLake, String imageURL, List<Bedroom> bedroomList, List<Booking> bookingList) {
        super(uri);
        this.name = name;
        this.latitude = latitude;
        this.longitude = longitude;
        this.distanceToLake = distanceToLake;
        this.imageURL = imageURL;
        this.bedroomList = bedroomList;
        this.bookingList = bookingList;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getLatitude() {
        return latitude;
    }

    public void setLatitude(double latitude) {
        this.latitude = latitude;
    }

    public double getLongitude() {
        return longitude;
    }

    public void setLongitude(double longitude) {
        this.longitude = longitude;
    }

    public List<Bedroom> getBedroomList() {
        return bedroomList;
    }

    public void setBedroomList(List<Bedroom> bedroomList) {
        this.bedroomList = bedroomList;
    }

    public double getDistanceToLake() {
        return distanceToLake;
    }

    public void setDistanceToLake(double distanceToLake) {
        this.distanceToLake = distanceToLake;
    }

    public String getImageURL() {
        return imageURL;
    }

    public void setImageURL(String imageURL) {
        this.imageURL = imageURL;
    }

    public List<Booking> getBookingList() {
        return bookingList;
    }

    public void setBookingList(List<Booking> bookingList) {
        this.bookingList = bookingList;
    }

    @Override
    public String toString() {
        return "Cottage{" +
                "uri=" + uri +
                ", name='" + name + '\'' +
                ", latitude=" + latitude +
                ", longitude=" + longitude +
                ", distanceToLake=" + distanceToLake +
                ", imageURL='" + imageURL + '\'' +
                ", bedroomList=" + bedroomList +
                ", bookingList=" + bookingList +
                '}';
    }

    public JSONObject toJSON() {
        JSONObject obj = new JSONObject();

        obj.put("uri", this.uri);
        obj.put("name", this.name);
        obj.put("latitude", this.latitude);
        obj.put("longitude", this.longitude);
        obj.put("distanceToLake", this.distanceToLake);
        obj.put("imageURL", this.imageURL);

        JSONArray bedroomJsonArray = new JSONArray();
        for (Bedroom bedroom : this.bedroomList) {
            bedroomJsonArray.add(bedroom.toJSON());
        }
        obj.put("bedroomList", bedroomJsonArray);

        JSONArray bookingJsonArray = new JSONArray();
        for (Booking booking : this.bookingList) {
            bookingJsonArray.add(booking.toJSON());
        }
        obj.put("bookingList", bookingJsonArray);

        return obj;
    }
}
<file_sep>/TIES437-service/src/main/resources/application.properties
server.port = 8083
rdg.file.path = task2/rdg.rdf<file_sep>/TIES437-service/src/main/java/ties437/service/servlets/BookingServlet.java
package ties437.service.servlets;

import org.apache.jena.rdf.model.Model;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import ties437.service.commons.Constants;
import ties437.service.commons.RdfUtils;
import ties437.service.commons.Utils;
import ties437.service.dao.CityDAO;
import ties437.service.dao.CottageDAO;
import ties437.service.entities.Bedroom;
import ties437.service.entities.Booking;
import ties437.service.entities.City;
import ties437.service.entities.Cottage;

import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.MultipartConfig;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Created by chinhnk on 1/4/2016.
 */
@WebServlet("/booking")
@MultipartConfig
public class BookingServlet extends HttpServlet {

    public static final String PATH = "/booking";

    public static final String P_BOOKER_NAME = "bookerName";
    public static final String P_MIN_BEDROOM_COUNT = "minBedroomCount";
    public static final String P_MIN_TOTAL_PLACE_COUNT = "minTotalPlaceCount";
    public static final String P_MAX_DISTANCE_TO_LAKE = "maxDistanceToLake";
    public static final String P_CITY = "city";
    public static final String P_MAX_DISTANCE = "maxDistance";
    public static final String P_START_DATE_STRING = "startDateString";
    public static final String P_DURATION_DAY = "durationDay";
    public static final String P_FLEX_DAY = "flexDay";

    public static final String RDF_FILE_RELATIVE_URL = "/resources/rdf/cottage-booking-data.rdf";

    private Model model;

    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);

        ServletContext context = config.getServletContext();
        String fullPath = context.getRealPath(RDF_FILE_RELATIVE_URL);
        // load data from rdf file
        this.model = RdfUtils.getModelFromRDF(fullPath);
    }

    /**
     * required amount of places (people);
     * required amount of bedrooms;
     * max distance of a cottage from a lake (meters);
     * city (next to which cottage is located) and a max distance to that city from a cottage;
     * required amount of days;
     * starting day of a booking (dd.mm.yyyy) and max possible shift of it (+/- n days).
     * <p>
     * name of the booker;
     * booking number;
     * address of the cottage;
     * image of the cottage (URL of the image in the web);
     * actual amount of places in the cottage;
     * actual amount of bedrooms in the cottage;
     * actual distance to the lake (meters);
     * nearest city and a distance to it from the cottage;
     * booking period.
     */

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String bookerName = request.getParameter(P_BOOKER_NAME);

        int minBedroomCount = Integer.parseInt(request.getParameter(P_MIN_BEDROOM_COUNT));
        int minTotalPlaceCount = Integer.parseInt(request.getParameter(P_MIN_TOTAL_PLACE_COUNT));
        double maxDistanceToLake = Double.parseDouble(request.getParameter(P_MAX_DISTANCE_TO_LAKE));

        City city = CityDAO.getByURI(model, request.getParameter(P_CITY));
        double maxDistance = Double.parseDouble(request.getParameter(P_MAX_DISTANCE));

        String startDateString = request.getParameter(P_START_DATE_STRING);
        SimpleDateFormat formatter = new SimpleDateFormat(Constants.DATE_FORMAT_JS);

        Date startDate = null;
        try {
            startDate = formatter.parse(startDateString);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        int durationDay = Integer.parseInt(request.getParameter(P_DURATION_DAY));
        int flexDay = Integer.parseInt(request.getParameter(P_FLEX_DAY));

        JSONArray eligibleResponseArray = new JSONArray();
        List<Cottage> allCottageList = CottageDAO.getAll(this.model);
        for (Cottage cottage : allCottageList) {
            JSONObject eligibleResponse = getEligible(cottage, minBedroomCount, minTotalPlaceCount,
                    maxDistanceToLake, city, maxDistance, startDate, durationDay, flexDay);
            if (eligibleResponse != null) {
                eligibleResponse.put("bookerName", bookerName);
                System.out.println(eligibleResponse.toJSONString().replace("\\/", "/"));
                eligibleResponseArray.add(eligibleResponse);
            }
        }

        response.setCharacterEncoding("UTF-8");
        PrintWriter writer = response.getWriter();
        writer.print(eligibleResponseArray.toJSONString().replace("\\/", "/"));
    }

    public static void main(String[] args) throws Exception {

//        String dataSourcePath = "D:\\Future Data\\WISE\\Spring 2017\\TIES437 Everything to Everything Interfaces\\TIES437-01\\web\\resources\\rdf\\cottage-booking-data.rdf";
//        Model model = RdfUtils.getModelFromRDF(dataSourcePath);
//
//        String bookerName = "Pekka";
//
//        int minBedroomCount = 2;
//        int minTotalPlaceCount = 4;
//        double maxDistanceToLake = 200.0;
//
//        City city = CityDAO.getByURI(model, OntologyConstants.PREFIX_CBD + "Helsinki");
//        double maxDistance = 7.0;

        String startDateString = "07-08-2017";
        SimpleDateFormat formatter = new SimpleDateFormat(Constants.DATE_FORMAT_JS);

        Date startDate = formatter.parse(startDateString);
        System.out.println(startDate);
//        int durationDay = 5;
//        int flexDay = 2;
//
//        List<Cottage> allCottageList = CottageDAO.getAll(model);
//        for (Cottage cottage : allCottageList) {
//            JSONObject eligibleResponse = getEligible(cottage, minBedroomCount, minTotalPlaceCount,
//                    maxDistanceToLake, city, maxDistance, startDate, durationDay, flexDay);
//            if (eligibleResponse != null) {
//                eligibleResponse.put("bookerName", bookerName);
//                System.out.println(eligibleResponse.toJSONString().replace("\\/", "/"));
//            }
//        }

//
//        // Shit has
//        String queryString1 = "PREFIX cb: <http://users.jyu.fi/~chnguyen/TIES437/cottage-booking.owl#>\n" +
//                "PREFIX cbd: <http://localhost:8080/resources/rdf/cottage-booking-data.rdf#>\n" +
//                "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n" +
//                "\n" +
//                "SELECT ?cottage\n" +
//                "   (COUNT(DISTINCT ?bedroom) AS ?bedroomCount)\n" +
//                "   (SUM(?placeCount) AS ?totalPlaceCount)\n" +
//                "   ?distanceToLake\n" +
//                "WHERE {\n" +
//                "   ?cottage a cb:Cottage .\n" +
//                "   ?cottage cb:hasBedroom ?bedroom .\n" +
//                "   ?bedroom cb:hasPlaceCount ?placeCount .\n" +
//                "   ?cottage cb:hasDistanceToLake ?distanceToLake .\n" +
//                "   ?booking a cb:Booking .\n" +
//                "   FILTER NOT EXISTS {?booking cb:hasCottage ?cottage} .\n" +
//                "}\n" +
//                "GROUP BY ?cottage ?distanceToLake\n" +
//                "HAVING (\n" +
//                "   ?bedroomCount >= " + minBedroomCount + "\n" +
//                "   &&\n" +
//                "   ?totalPlaceCount >= " + minTotalPlaceCount + "\n" +
//                "   &&\n" +
//                "   ?distanceToLake <= " + maxDistanceToLake + "\n" +
//                ")";
//
//        String queryString =
//                "SELECT *\n" +
//                        "WHERE {\n" +
//                        "   ?s a <" + Bedroom.TYPE_URI + "> .\n" +
//                        "   ?s ?p ?o .\n" +
//                        "}\n";
//
//        String queryString2 = "PREFIX cb: <http://users.jyu.fi/~chnguyen/TIES437/cottage-booking.owl#>\n" +
//                "PREFIX cbd: <http://localhost:8080/resources/rdf/cottage-booking-data.rdf#>\n" +
//                "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n" +
//                "\n" +
//                "SELECT ?cottage\n" +
//                "   (COUNT(DISTINCT ?bedroom) AS ?bedroomCount)\n" +
//                "   (SUM(?placeCount) AS ?totalPlaceCount)\n" +
//                "   ?distanceToLake\n" +
//                "   ?booking\n" +
//                "   ?bookedStartDate\n" +
//                "WHERE {\n" +
//                "   ?cottage a cb:Cottage .\n" +
//
//                "   ?cottage cb:hasBedroom ?bedroom .\n" +
//                "   ?bedroom cb:hasPlaceCount ?placeCount .\n" +
//
//                "   ?cottage cb:hasDistanceToLake ?distanceToLake .\n" +
//
//                "   ?booking a cb:Booking .\n" +
//                "   ?booking cb:hasCottage ?cottage .\n" +
//                "   ?booking cb:hasStartDate ?bookedStartDate .\n" +
//                "   ?booking cb:hasEndDate ?bookedEndDate .\n" +
//                "   FILTER (\n" +
//                "       ?bookedStartDate < \"2017-07-08T12:00:00+02:00\"^^xsd:dateTime\n" +
//                "       ||\n" +
//                "       ?bookedEndDate > \"2017-07-02T12:00:00+02:00\"^^xsd:dateTime\n" +
//                "   ) .\n" +
//                "}\n" +
//                "GROUP BY ?cottage ?distanceToLake ?booking ?bookedStartDate";

        // cb:hasEndDate "2017-07-07T12:00:00+02:00"^^xsd:dateTime ;
        // cb:hasStartDate "2017-07-01T12:00:00+02:00"^^xsd:dateTime .

//        BookingServlet.runQuery(model, queryString);
//        BookingServlet.runQuery(model, queryString1);
//        BookingServlet.runQuery(model, queryString2);
    }

    private static JSONObject getEligible(Cottage cottage,
                                          int minBedroomCount,
                                          int minTotalPlaceCount,
                                          double maxDistanceToLake,
                                          City city, double maxDistance,
                                          final Date startDate, int durationDay, int flexDay) {
        // check bedroomCount
        if (cottage.getBedroomList().size() < minBedroomCount) {
            return null;
        }

        // check totalPlaceCount
        int totalPlaceCount = 0;
        for (Bedroom bedroom : cottage.getBedroomList()) {
            totalPlaceCount += bedroom.getPlaceCount();
        }
        if (totalPlaceCount < minTotalPlaceCount) {
            return null;
        }

        // check distanceToLake
        if (cottage.getDistanceToLake() > maxDistanceToLake) {
            return null;
        }

        // check distance
        double distance = Utils.distanceFromCoords(
                city.getLatitude(), city.getLongitude(),
                cottage.getLatitude(), cottage.getLongitude());
        if (distance > maxDistance) {
            return null;
        }

        // check date
        List<Date> possibleStartDateList = new ArrayList<Date>();
        if (!cottage.getBookingList().isEmpty()) {
            for (Booking booking : cottage.getBookingList()) {
                Date bookedStartDate = booking.getStartDate();
                Date bookedEndDate = booking.getEndDate();

                for (int i = -flexDay; i <= flexDay; i++) {
                    Date possibleStartDate = Utils.addDays(startDate, i);
                    Date possibleEndDate = Utils.addDays(possibleStartDate, durationDay);
                    if (!(((possibleStartDate.compareTo(bookedStartDate) >= 0) && (possibleStartDate.compareTo(bookedEndDate) <= 0))
                            || ((possibleEndDate.compareTo(bookedStartDate) >= 0) && (possibleEndDate.compareTo(bookedEndDate) <= 0)))) {
                        if (!possibleStartDateList.contains(possibleStartDate)) {
                            possibleStartDateList.add(possibleStartDate);
                        }
                    }
                }

                if (possibleStartDateList.isEmpty()) {
                    return null;
                }
            }
        } else {
            for (int i = -flexDay; i <= flexDay; i++) {
                Date possibleStartDate = Utils.addDays(startDate, i);
                possibleStartDateList.add(possibleStartDate);
            }
        }

        Collections.sort(possibleStartDateList, new Comparator<Date>() {
            public int compare(Date o1, Date o2) {
                return Long.compare(Utils.getDateDiff(startDate, o1), Utils.getDateDiff(startDate, o2));
            }
        });

        JSONObject obj = new JSONObject();

        DecimalFormat df = new DecimalFormat("#.##");

        obj.put("address", cottage.getName());
        obj.put("imageURL", cottage.getImageURL());
        obj.put("bedroomCount", cottage.getBedroomList().size());
        obj.put("totalPlaceCount", totalPlaceCount);
        obj.put("distanceToLake", df.format(cottage.getDistanceToLake()));
        obj.put("city", city.getName());
        obj.put("distance", df.format(distance));

        JSONArray possibleStartDateJsonArray = new JSONArray();
        SimpleDateFormat formatter = new SimpleDateFormat(Constants.DATE_FORMAT_JS);
        for (Date date : possibleStartDateList) {
            possibleStartDateJsonArray.add(formatter.format(date));
        }
        obj.put("possibleStartDateList", possibleStartDateJsonArray);

        return obj;
    }

}
<file_sep>/TIES437-service/src/main/java/ties437/service/commons/RdfUtils.java
package ties437.service.commons;

import org.apache.jena.query.*;
import org.apache.jena.rdf.model.*;
import org.apache.jena.reasoner.Derivation;
import org.apache.jena.reasoner.Reasoner;
import org.apache.jena.reasoner.rulesys.GenericRuleReasoner;
import org.apache.jena.reasoner.rulesys.Rule;

import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;

/**
 * Created by chinhnk on 4/3/2017.
 */
public class RdfUtils {

    public static final String KEYWORD_SELECT = "SELECT";
    public static final String KEYWORD_CONSTRUCT = "CONSTRUCT";
    public static final String KEYWORD_DESCRIBE = "DESCRIBE";
    public static final String KEYWORD_ASK = "ASK";

    public static final String RDFA_API_LINK = "http://rdf-translator.appspot.com/convert/rdfa/xml/";

    public static void main(String[] args) throws Exception {
//        String fileURL = "http%3A%2F%2Fusers.jyu.fi%2F~chnguyen%2FTIES452%2Ffinal%2Ffinal.xhtml";

        Model model = RdfUtils.getModelFromRDF("D:\\Future Data\\WISE\\Spring 2017\\TIES437 Everything to Everything Interfaces\\TIES437-01\\web\\resources\\rdf\\cottage-booking-data.rdf");

        // required amount of places (people);
        // required amount of bedrooms;
        // max distance of a cottage from a lake (meters);
        // city (next to which cottage is located) and a max distance to that city from a cottage;
        // required amount of days;
        // starting day of a booking (dd.mm.yyyy) and max possible shift of it (+/- n days).

        // name of the booker;
        // booking number;
        // address of the cottage;
        // image of the cottage (URL of the image in the web);
        // actual amount of places in the cottage;
        // actual amount of bedrooms in the cottage;
        // actual distance to the lake (meters);
        // nearest city and a distance to it from the cottage;
        // booking period.

        String queryString = "PREFIX cb: <http://users.jyu.fi/~chnguyen/TIES437/cottage-booking.owl#>\n" +
                "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n" +
                "\n" +
                "SELECT *\n" +
                "WHERE {\n" +
                "   <http://localhost:8080/resources/rdf/cottage-booking-data.rdf#Susiraja_82_1> ?p ?o .\n" +
                "}\n";

        RdfUtils.runQuery(model, queryString);
    }

    public static Model getModelFromRDFa(String fileURL) throws IOException {
        URL url = new URL(RDFA_API_LINK + fileURL);

        System.out.println("GET RDFa URL:");
        System.out.println(RDFA_API_LINK + fileURL);

        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("GET");

        if (conn.getResponseCode() != 200) {
            throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
        }

        BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
        String modelText = "";
        String line;
        while ((line = br.readLine()) != null) {
            modelText += line + "\n";
        }

        ByteArrayInputStream stream = new ByteArrayInputStream(modelText.getBytes());
        Model model = ModelFactory.createDefaultModel();
        model.read(stream, null);

        conn.disconnect();
        model.write(System.out, Constants.RDF_LANG);

        return model;
    }

    public static Model getModelFromRDF(String fileURL) {
        Model model = ModelFactory.createDefaultModel();
        try {
            model.read(new FileInputStream(fileURL), null, Constants.RDF_LANG);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return model;
    }

    public static InfModel applyRules(Model model, String ruleSrc) throws IOException {
        PrintWriter writer = new PrintWriter("temp.rules", "UTF-8");
        writer.println(ruleSrc);
        writer.close();

        List<Rule> rules = Rule.rulesFromURL("temp.rules");

        System.out.println(rules.size() + " rule(s).");

        Reasoner reasoner = new GenericRuleReasoner(rules);
        reasoner.setDerivationLogging(true);
        InfModel infModel = ModelFactory.createInfModel(reasoner, model);

        PrintWriter out = new PrintWriter(System.out);
        for (StmtIterator i = infModel.listStatements(); i.hasNext(); ) {
            Statement s = i.nextStatement();

            for (Iterator id = infModel.getDerivation(s); id.hasNext(); ) {
                System.out.println("Statement is " + s);
                Derivation derivation = (Derivation) id.next();
                derivation.printTrace(out, true);
            }
        }
        out.flush();

        return infModel;
    }

    public static String runQuery(Model model, String queryString) {
        String result = "";

        Dataset dataset = DatasetFactory.create(model);
        Query query = QueryFactory.create(queryString);
        QueryExecution queryExecution = QueryExecutionFactory.create(query, dataset);

        if (Pattern.compile(Pattern.quote(KEYWORD_SELECT), Pattern.CASE_INSENSITIVE).matcher(queryString).find()) {
            ResultSet resultSet = queryExecution.execSelect();
            String resultHead = "";
            String resultBody = "";
            boolean passFirstRow = false;
            while (resultSet.hasNext()) {
                QuerySolution row = resultSet.next();
                Iterator<String> varNamesIterator = row.varNames();
                while (varNamesIterator.hasNext()) {
                    String varName = varNamesIterator.next();
                    if (!passFirstRow) {
                        resultHead += varName + "\t";
                    }
                    resultBody += row.get(varName).toString() + "\t";
                }
                passFirstRow = true;
                resultBody += "\n";
            }
            result = resultHead + "\n" + resultBody;

        } else if (Pattern.compile(Pattern.quote(KEYWORD_ASK), Pattern.CASE_INSENSITIVE).matcher(queryString).find()) {
            boolean answer = queryExecution.execAsk();
            result = (answer) ? "Yes !!!" : "No...";

        } else if (Pattern.compile(Pattern.quote(KEYWORD_CONSTRUCT), Pattern.CASE_INSENSITIVE).matcher(queryString).find()) {
            Model resultModel = queryExecution.execConstruct();
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            resultModel.write(outputStream, Constants.RDF_LANG);
            result = outputStream.toString();

        } else if (Pattern.compile(Pattern.quote(KEYWORD_DESCRIBE), Pattern.CASE_INSENSITIVE).matcher(queryString).find()) {
            Model resultModel = queryExecution.execDescribe();
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            resultModel.write(outputStream, Constants.RDF_LANG);
            result = outputStream.toString();
        }

        System.out.println(result);

        return result;
    }
}
<file_sep>/TIES437-service/src/main/java/ties437/service/entities/Booking.java
package ties437.service.entities;

import org.json.simple.JSONObject;
import ties437.service.commons.OntologyConstants;

import java.util.Date;

/**
 * Created by chinhnk on 4/3/2017.
 */
public class Booking extends Entity {

    public static final String TYPE_URI = OntologyConstants.PREFIX_CB + "Booking";

    private String bookerName;
    private Date startDate;
    private Date endDate;

    public Booking(String uri) {
        super(uri);
    }

    public Booking(String uri, String bookerName, Date startDate, Date endDate) {
        super(uri);
        this.bookerName = bookerName;
        this.startDate = startDate;
        this.endDate = endDate;
    }

    public String getBookerName() {
        return bookerName;
    }

    public void setBookerName(String bookerName) {
        this.bookerName = bookerName;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    @Override
    public String toString() {
        return "Booking{" +
                "uri=" + uri +
                ", bookerName='" + bookerName + '\'' +
                ", startDate=" + startDate +
                ", endDate=" + endDate +
                '}';
    }

    public JSONObject toJSON() {
        JSONObject obj = new JSONObject();

        obj.put("uri", this.uri);
        obj.put("bookerName", this.bookerName);
        obj.put("startDate", this.startDate.toString());
        obj.put("endDate", this.endDate.toString());

        return obj;
    }
}
<file_sep>/TIES437-mediator/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>TIES437</groupId>
    <artifactId>TIES437-mediator</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>TIES437</groupId>
        <artifactId>TIES437</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
        </dependency>

        <!-- SSWAP - START -->
        <!--https://mvnrepository.com/artifact/org.antlr/antlr-runtime-->
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr-runtime</artifactId>
            <version>3.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/aopalliance/aopalliance -->
        <dependency>
            <groupId>aopalliance</groupId>
            <artifactId>aopalliance</artifactId>
            <version>1.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.hp.hpl.jena/arq -->
        <dependency>
            <groupId>com.hp.hpl.jena</groupId>
            <artifactId>arq</artifactId>
            <version>2.8.7</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.4</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-httpclient/commons-httpclient -->
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>3.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/net.sf.ehcache/ehcache-core -->
        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache-core</artifactId>
            <version>2.4.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.hibernate/ejb3-persistence -->
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>ejb3-persistence</artifactId>
            <version>1.0.2.GA</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>15.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.inject/guice -->
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>3.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.inject.extensions/guice-assistedinject -->
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-assistedinject</artifactId>
            <version>3.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.inject.extensions/guice-jmx -->
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-jmx</artifactId>
            <version>3.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.inject.extensions/guice-multibindings -->
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-multibindings</artifactId>
            <version>3.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.inject.extensions/guice-throwingproviders -->
        <dependency>
            <groupId>com.google.inject.extensions</groupId>
            <artifactId>guice-throwingproviders</artifactId>
            <version>3.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.ibm.icu/icu4j -->
        <dependency>
            <groupId>com.ibm.icu</groupId>
            <artifactId>icu4j</artifactId>
            <version>3.4.4</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.hp.hpl.jena/iri -->
        <dependency>
            <groupId>com.hp.hpl.jena</groupId>
            <artifactId>iri</artifactId>
            <version>0.8</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>3.14.0-GA</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.inject/javax.inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.hp.hpl.jena/jena -->
        <dependency>
            <groupId>com.hp.hpl.jena</groupId>
            <artifactId>jena</artifactId>
            <version>2.6.4</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.jgrapht/jgrapht-jdk1.5 -->
        <dependency>
            <groupId>org.jgrapht</groupId>
            <artifactId>jgrapht-jdk1.5</artifactId>
            <version>0.7.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.martiansoftware/jsap -->
        <dependency>
            <groupId>com.martiansoftware</groupId>
            <artifactId>jsap</artifactId>
            <version>2.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.json/json -->
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20140107</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/junit/junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.13</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-core -->
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-core</artifactId>
            <version>2.3.1</version>
        </dependency>
        <!--https://mvnrepository.com/artifact/org.openrdf.sesame/sesame-->
        <dependency>
            <groupId>org.openrdf.sesame</groupId>
            <artifactId>sesame</artifactId>
            <version>2.7.7</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.sun.xml/relaxngDatatype -->
        <dependency>
            <groupId>com.sun.xml</groupId>
            <artifactId>relaxngDatatype</artifactId>
            <version>1.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.hp.hpl.jena/sdb -->
        <dependency>
            <groupId>com.hp.hpl.jena</groupId>
            <artifactId>sdb</artifactId>
            <version>1.3.3</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/stax/stax-api -->
        <dependency>
            <groupId>stax</groupId>
            <artifactId>stax-api</artifactId>
            <version>1.0.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.codehaus.woodstox/wstx-asl -->
        <dependency>
            <groupId>org.codehaus.woodstox</groupId>
            <artifactId>wstx-asl</artifactId>
            <version>3.2.9</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/xerces/xercesImpl -->
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.7.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.sun.msv.datatype.xsd/xsdlib -->
        <dependency>
            <groupId>com.sun.msv.datatype.xsd</groupId>
            <artifactId>xsdlib</artifactId>
            <version>20060615</version>
        </dependency>

        <!-- aterm-java-1.6 -->
        <dependency>
            <groupId>aterm-java-1.6</groupId>
            <artifactId>aterm-java-1.6</artifactId>
            <scope>system</scope>
            <version>1.0</version>
            <systemPath>${basedir}\lib\aterm-java-1.6.jar</systemPath>
        </dependency>
        <!-- sswap -->
        <dependency>
            <groupId>sswap</groupId>
            <artifactId>sswap</artifactId>
            <scope>system</scope>
            <version>1.0</version>
            <systemPath>${basedir}\lib\sswap.jar</systemPath>
        </dependency>
        <!-- empire-0.8.3 -->
        <dependency>
            <groupId>empire-0.8.3</groupId>
            <artifactId>empire-0.8.3</artifactId>
            <scope>system</scope>
            <version>0.8.3</version>
            <systemPath>${basedir}\lib\empire-0.8.3.jar</systemPath>
        </dependency>
        <!-- empire-test-0.8.3 -->
        <dependency>
            <groupId>empire-test-0.8.3</groupId>
            <artifactId>empire-test-0.8.3</artifactId>
            <scope>system</scope>
            <version>0.8.3</version>
            <systemPath>${basedir}\lib\empire-test-0.8.3.jar</systemPath>
        </dependency>
        <!-- empire-jena-0.8.3 -->
        <dependency>
            <groupId>empire-jena-0.8.3</groupId>
            <artifactId>empire-jena-0.8.3</artifactId>
            <scope>system</scope>
            <version>0.8.3</version>
            <systemPath>${basedir}\lib\empire-jena-0.8.3.jar</systemPath>
        </dependency>
        <!-- empire-sesame-0.8.3 -->
        <dependency>
            <groupId>empire-sesame-0.8.3</groupId>
            <artifactId>empire-sesame-0.8.3</artifactId>
            <scope>system</scope>
            <version>0.8.3</version>
            <systemPath>${basedir}\lib\empire-sesame-0.8.3.jar</systemPath>
        </dependency>
        <!-- empire-sesame-test-0.8.3 -->
        <dependency>
            <groupId>empire-sesame-test-0.8.3</groupId>
            <artifactId>empire-sesame-test-0.8.3</artifactId>
            <scope>system</scope>
            <version>0.8.3</version>
            <systemPath>${basedir}\lib\empire-sesame-test-0.8.3.jar</systemPath>
        </dependency>
        <!-- empire-sesame-test-0.8.3 -->
        <dependency>
            <groupId>cp-common-fourstore-0.3.1</groupId>
            <artifactId>cp-common-fourstore-0.3.1</artifactId>
            <scope>system</scope>
            <version>0.3.1</version>
            <systemPath>${basedir}\lib\cp-common-fourstore-0.3.1.jar</systemPath>
        </dependency>
        <!-- cp-common-openrdf-2.0.1 -->
        <dependency>
            <groupId>cp-common-openrdf-2.0.1</groupId>
            <artifactId>cp-common-openrdf-2.0.1</artifactId>
            <scope>system</scope>
            <version>2.0.1</version>
            <systemPath>${basedir}\lib\cp-common-openrdf-2.0.1.jar</systemPath>
        </dependency>
        <!-- cp-common-utils-3.1.1.jar -->
        <dependency>
            <groupId>cp-common-utils-3.1.1</groupId>
            <artifactId>cp-common-utils-3.1.1</artifactId>
            <scope>system</scope>
            <version>3.1.1</version>
            <systemPath>${basedir}\lib\cp-common-utils-3.1.1.jar</systemPath>
        </dependency>
        <!-- cp-common-utils-1.1.jar -->
        <dependency>
            <groupId>cp-common-utils-1.1</groupId>
            <artifactId>cp-common-utils-1.1</artifactId>
            <scope>system</scope>
            <version>1.1</version>
            <systemPath>${basedir}\lib\cp-common-utils-1.1.jar</systemPath>
        </dependency>
        <!-- cp-common-utils-2.3.jar -->
        <dependency>
            <groupId>cp-common-utils-2.3</groupId>
            <artifactId>cp-common-utils-2.3</artifactId>
            <scope>system</scope>
            <version>2.3</version>
            <systemPath>${basedir}\lib\cp-common-utils-2.3.jar</systemPath>
        </dependency>
        <!-- cp-common-utils-2.4.1.1.jar -->
        <dependency>
            <groupId>cp-common-utils-2.4.1.1</groupId>
            <artifactId>cp-common-utils-2.4.1.1</artifactId>
            <scope>system</scope>
            <version>2.4.1.1</version>
            <systemPath>${basedir}\lib\cp-common-utils-2.4.1.1.jar</systemPath>
        </dependency>
        <!-- cp-common-utils-2.5.0.jar -->
        <dependency>
            <groupId>cp-common-utils-2.5.0</groupId>
            <artifactId>cp-common-utils-2.5.0</artifactId>
            <scope>system</scope>
            <version>2.5.0</version>
            <systemPath>${basedir}\lib\cp-common-utils-2.5.0.jar</systemPath>
        </dependency>
        <!-- cp-common-utils-3.0.jar -->
        <dependency>
            <groupId>cp-common-utils-3.0</groupId>
            <artifactId>cp-common-utils-3.0</artifactId>
            <scope>system</scope>
            <version>3.0</version>
            <systemPath>${basedir}\lib\cp-common-utils-3.0.jar</systemPath>
        </dependency>
        <!-- openrdf-sesame-2.7.7.jar -->
        <dependency>
            <groupId>openrdf-sesame-2.7.7</groupId>
            <artifactId>openrdf-sesame-2.7.7</artifactId>
            <scope>system</scope>
            <version>2.7.7</version>
            <systemPath>${basedir}\lib\openrdf-sesame-2.7.7.jar</systemPath>
        </dependency>

        <!-- owlapi and pellet since there is no specified version in the jars -->
        <!-- owlapi-bin.jar -->
        <dependency>
            <groupId>owlapi</groupId>
            <artifactId>owlapi</artifactId>
            <scope>system</scope>
            <version>3.2.4</version>
            <systemPath>${basedir}\lib\owlapi-bin.jar</systemPath>
        </dependency>
        <!-- pellet-cli.jar -->
        <dependency>
            <groupId>pellet-cli</groupId>
            <artifactId>pellet-cli</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-cli.jar</systemPath>
        </dependency>
        <!-- pellet-core.jar -->
        <dependency>
            <groupId>pellet-core</groupId>
            <artifactId>pellet-core</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-core.jar</systemPath>
        </dependency>
        <!--pellet-datatypes.jar-->
        <dependency>
            <groupId>pellet-datatypes</groupId>
            <artifactId>pellet-datatypes</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-datatypes.jar</systemPath>
        </dependency>
        <!--pellet-dig.jar-->
        <dependency>
            <groupId>pellet-dig</groupId>
            <artifactId>pellet-dig</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-dig.jar</systemPath>
        </dependency>
        <!--pellet-el.jar-->
        <dependency>
            <groupId>pellet-el</groupId>
            <artifactId>pellet-el</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-el.jar</systemPath>
        </dependency>
        <!--pellet-explanation.jar-->
        <dependency>
            <groupId>pellet-explanation</groupId>
            <artifactId>pellet-explanation</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-explanation.jar</systemPath>
        </dependency>
        <!--pellet-jena.jar-->
        <dependency>
            <groupId>pellet-jena</groupId>
            <artifactId>pellet-jena</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-jena.jar</systemPath>
        </dependency>
        <!--pellet-modularity.jar-->
        <dependency>
            <groupId>pellet-modularity</groupId>
            <artifactId>pellet-modularity</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-modularity.jar</systemPath>
        </dependency>
        <!--pellet-owlapi.jar-->
        <dependency>
            <groupId>pellet-owlapi</groupId>
            <artifactId>pellet-owlapi</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-owlapi.jar</systemPath>
        </dependency>
        <!--pellet-owlapiv3.jar-->
        <dependency>
            <groupId>pellet-owlapiv3</groupId>
            <artifactId>pellet-owlapiv3</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-owlapiv3.jar</systemPath>
        </dependency>
        <!--pellet-pellint.jar-->
        <dependency>
            <groupId>pellet-pellint</groupId>
            <artifactId>pellet-pellint</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-pellint.jar</systemPath>
        </dependency>
        <!--pellet-query.jar-->
        <dependency>
            <groupId>pellet-query</groupId>
            <artifactId>pellet-query</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-query.jar</systemPath>
        </dependency>
        <!--pellet-rules.jar-->
        <dependency>
            <groupId>pellet-rules</groupId>
            <artifactId>pellet-rules</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-rules.jar</systemPath>
        </dependency>
        <!--pellet-test.jar-->
        <dependency>
            <groupId>pellet-test</groupId>
            <artifactId>pellet-test</artifactId>
            <scope>system</scope>
            <systemPath>${basedir}\lib\pellet-test.jar</systemPath>
        </dependency>
        <!-- SSWAP - END -->
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>mvnrepository</id>
            <url>https://mvnrepository.com/repos</url>
        </repository>
    </repositories>

</project><file_sep>/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>TIES437</groupId>
    <artifactId>TIES437</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>TIES437-ui</module>
        <module>TIES437-service</module>
        <module>TIES437-mediator</module>
    </modules>

    <properties>
        <java.version>1.8</java.version>
        <spring.version>4.3.0.RELEASE</spring.version>
        <springboot.version>1.3.3.RELEASE</springboot.version>
        <logback.version>1.1.6</logback.version>
        <maven.resource.version>2.6</maven.resource.version>
        <maven.compiler.version>3.5.1</maven.compiler.version>
        <jackson.version>2.5.3</jackson.version>
        <javax.servlet.api.version>3.1.0</javax.servlet.api.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>${springboot.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-web</artifactId>
                <version>${spring.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-orm</artifactId>
                <version>${spring.version}</version>
            </dependency>

            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>${logback.version}</version>
            </dependency>

            <!-- JSON -->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${jackson.version}</version>
            </dependency>

            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>${javax.servlet.api.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.jena/jena-core -->
        <dependency>
            <groupId>org.apache.jena</groupId>
            <artifactId>jena-core</artifactId>
            <version>3.0.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.jena/jena-arq -->
        <dependency>
            <groupId>org.apache.jena</groupId>
            <artifactId>jena-arq</artifactId>
            <version>3.0.1</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.7</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.2</version>
        </dependency>

        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.rpc</groupId>
            <artifactId>javax.xml.rpc-api</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlet</artifactId>
            <version>9.3.10.v20160621</version>
        </dependency>

    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${springboot.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project><file_sep>/TIES437-mediator/src/main/java/ties437/mediator/Application.java
package ties437.mediator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;


/**
 * Created by V.Tsybulko on 17.04.2017.
 */
@SpringBootApplication
@ComponentScan(basePackages = {"ties437.mediator"})
public class Application extends SpringBootServletInitializer {

    final static Logger logger = LoggerFactory.getLogger(Application.class);


    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
        logger.info("Mediator started!");
    }
}
