[Fix] Fixed code due to changes in visitor behaviour in Strolch

This commit is contained in:
Robert von Burg 2018-02-27 18:02:04 +01:00
parent b211dc76f5
commit b1bfd621eb
6 changed files with 254 additions and 250 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/.settings/ /.settings/
/.classpath /.classpath
/.project /.project
*.iml

415
pom.xml
View File

@ -1,215 +1,232 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<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"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion> 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>li.strolch</groupId> <groupId>li.strolch</groupId>
<artifactId>strolch-bookshop</artifactId> <artifactId>strolch-bookshop</artifactId>
<version>0.1.0-SNAPSHOT</version> <version>0.1.0-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>strolch-bookshop</name>
<description>Bookshop built on Strolch</description>
<inceptionYear>2017</inceptionYear>
<properties> <name>strolch-bookshop</name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <description>Bookshop built on Strolch</description>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format> <inceptionYear>2017</inceptionYear>
<buildTimestamp>${maven.build.timestamp}</buildTimestamp>
<java-version>1.8</java-version> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.build.timestamp.format>yyyy-MM-dd HH:mm:ss</maven.build.timestamp.format>
<buildTimestamp>${maven.build.timestamp}</buildTimestamp>
<strolch.version>1.6.0-SNAPSHOT</strolch.version> <jdk.version>1.8</jdk.version>
<jersey.version>2.25.1</jersey.version>
<jaxrs.api.version>2.0</jaxrs.api.version>
<warFinalName>bookshop</warFinalName> <jersey.version>2.25.1</jersey.version>
<m2eclipse.wtp.contextRoot>${warFinalName}</m2eclipse.wtp.contextRoot> <slf4j.version>1.7.25</slf4j.version>
</properties> <logback.version>1.2.3</logback.version>
<petitparser.version>2.1.0</petitparser.version>
<hikaricp.version>2.7.1</hikaricp.version>
<postgresql.version>42.1.4</postgresql.version>
<gson.version>2.8.2</gson.version>
<annotation.version>1.3.1</annotation.version>
<javaxmail.version>1.6.0</javaxmail.version>
<serverlet.version>3.1.0</serverlet.version>
<jaxrs.api.version>2.1</jaxrs.api.version>
<dependencies> <junit.version>4.12</junit.version>
<!-- base --> <hamcrest.version>1.3</hamcrest.version>
<dependency> <mockito.version>2.0.8-beta</mockito.version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<!-- strolch --> <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<dependency> <maven-source-plugin.version>3.0.1</maven-source-plugin.version>
<groupId>li.strolch</groupId> <maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
<artifactId>li.strolch.utils</artifactId> <maven-war-plugin.version>3.1.0</maven-war-plugin.version>
<version>${strolch.version}</version>
</dependency>
<dependency>
<groupId>li.strolch</groupId>
<artifactId>li.strolch.privilege</artifactId>
<version>${strolch.version}</version>
</dependency>
<dependency>
<groupId>li.strolch</groupId>
<artifactId>li.strolch.model</artifactId>
<version>${strolch.version}</version>
</dependency>
<dependency>
<groupId>li.strolch</groupId>
<artifactId>li.strolch.agent</artifactId>
<version>${strolch.version}</version>
</dependency>
<dependency>
<groupId>li.strolch</groupId>
<artifactId>li.strolch.rest</artifactId>
<version>${strolch.version}</version>
</dependency>
<dependency>
<groupId>li.strolch</groupId>
<artifactId>li.strolch.service</artifactId>
<version>${strolch.version}</version>
</dependency>
<dependency>
<groupId>li.strolch</groupId>
<artifactId>li.strolch.testbase</artifactId>
<version>${strolch.version}</version>
<scope>test</scope>
</dependency>
<!-- utils --> <strolch.version>1.6.0-SNAPSHOT</strolch.version>
<dependency>
<groupId>com.github.petitparser.java-petitparser</groupId>
<artifactId>petitparser-core</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<!-- web --> <warFinalName>bookshop</warFinalName>
<dependency> <m2eclipse.wtp.contextRoot>${warFinalName}</m2eclipse.wtp.contextRoot>
<groupId>javax.servlet</groupId> </properties>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${jaxrs.api.version}</version>
</dependency>
<!-- testing --> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build> <!-- base -->
<resources> <dependency>
<!-- filter properties files, and copy the rest --> <groupId>org.slf4j</groupId>
<resource> <artifactId>slf4j-api</artifactId>
<directory>src/main/resources</directory> <version>${slf4j.version}</version>
<filtering>true</filtering> </dependency>
<includes> <dependency>
<include>**/*.properties</include> <groupId>ch.qos.logback</groupId>
</includes> <artifactId>logback-classic</artifactId>
</resource> <version>${logback.version}</version>
<resource> <scope>runtime</scope>
<directory>src/main/resources</directory> </dependency>
<filtering>false</filtering>
<excludes>
<exclude>**/*.properties</exclude>
</excludes>
</resource>
</resources>
<plugins> <!-- strolch -->
<plugin> <dependency>
<groupId>org.apache.maven.plugins</groupId> <groupId>li.strolch</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>li.strolch.utils</artifactId>
<version>3.0</version> <version>${strolch.version}</version>
<configuration> </dependency>
<source>${java-version}</source> <dependency>
<target>${java-version}</target> <groupId>li.strolch</groupId>
</configuration> <artifactId>li.strolch.privilege</artifactId>
</plugin> <version>${strolch.version}</version>
<plugin> </dependency>
<groupId>org.apache.maven.plugins</groupId> <dependency>
<artifactId>maven-war-plugin</artifactId> <groupId>li.strolch</groupId>
<version>2.4</version> <artifactId>li.strolch.model</artifactId>
<configuration> <version>${strolch.version}</version>
<failOnMissingWebXml>false</failOnMissingWebXml> </dependency>
<warName>${warFinalName}</warName> <dependency>
</configuration> <groupId>li.strolch</groupId>
</plugin> <artifactId>li.strolch.agent</artifactId>
</plugins> <version>${strolch.version}</version>
</build> </dependency>
<dependency>
<groupId>li.strolch</groupId>
<artifactId>li.strolch.rest</artifactId>
<version>${strolch.version}</version>
</dependency>
<dependency>
<groupId>li.strolch</groupId>
<artifactId>li.strolch.service</artifactId>
<version>${strolch.version}</version>
</dependency>
<dependency>
<groupId>li.strolch</groupId>
<artifactId>li.strolch.testbase</artifactId>
<version>${strolch.version}</version>
<scope>test</scope>
</dependency>
<repositories> <!-- utils -->
<!-- used by petit-parser --> <dependency>
<repository> <groupId>com.google.code.gson</groupId>
<id>jitpack.io</id> <artifactId>gson</artifactId>
<name>snapshots</name> <version>${gson.version}</version>
<url>https://jitpack.io</url> </dependency>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<profiles> <!-- web -->
<!-- active when building on eitch's machines --> <dependency>
<profile> <groupId>javax.servlet</groupId>
<id>m2e.eitchpc</id> <artifactId>javax.servlet-api</artifactId>
<activation> <version>${serverlet.version}</version>
<property> <scope>provided</scope>
<name>user.name</name> </dependency>
<value>eitch</value> <dependency>
</property> <groupId>javax.ws.rs</groupId>
<os> <artifactId>javax.ws.rs-api</artifactId>
<family>unix</family> <version>${jaxrs.api.version}</version>
</os> </dependency>
</activation> <dependency>
<properties> <groupId>org.glassfish.jersey.core</groupId>
<strolch.env>dev.eitchpc</strolch.env> <artifactId>jersey-common</artifactId>
</properties> <version>${jersey.version}</version>
</profile> </dependency>
<profile> <dependency>
<id>m2e.eitchmac</id> <groupId>org.glassfish.jersey.core</groupId>
<activation> <artifactId>jersey-server</artifactId>
<property> <version>${jersey.version}</version>
<name>user.name</name> </dependency>
<value>eitch</value> <dependency>
</property> <groupId>org.glassfish.jersey.containers</groupId>
<os> <artifactId>jersey-container-servlet</artifactId>
<family>mac</family> <version>${jersey.version}</version>
</os> </dependency>
</activation>
<properties> <!-- testing -->
<strolch.env>dev.eitchmac</strolch.env> <dependency>
</properties> <groupId>junit</groupId>
</profile> <artifactId>junit</artifactId>
</profiles> <version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<!-- filter properties files, and copy the rest -->
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<excludes>
<exclude>**/*.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>${warFinalName}</warName>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<!-- active when building on eitch's machines -->
<profile>
<id>m2e.eitchpc</id>
<activation>
<property>
<name>user.name</name>
<value>eitch</value>
</property>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<strolch.env>dev.eitchpc</strolch.env>
</properties>
</profile>
<profile>
<id>m2e.eitchmac</id>
<activation>
<property>
<name>user.name</name>
<value>eitch</value>
</property>
<os>
<family>mac</family>
</os>
</activation>
<properties>
<strolch.env>dev.eitchmac</strolch.env>
</properties>
</profile>
</profiles>
</project> </project>

View File

@ -1,42 +1,34 @@
package li.strolch.bookshop.rest; package li.strolch.bookshop.rest;
import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DELETE; import javax.ws.rs.*;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.Response.Status;
import java.util.List;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import li.strolch.bookshop.BookShopConstants; import li.strolch.bookshop.BookShopConstants;
import li.strolch.bookshop.query.BooksQuery; import li.strolch.bookshop.query.BooksQuery;
import li.strolch.bookshop.service.CreateBookService; import li.strolch.bookshop.service.CreateBookService;
import li.strolch.bookshop.service.RemoveBookService; import li.strolch.bookshop.service.RemoveBookService;
import li.strolch.bookshop.service.UpdateBookService; import li.strolch.bookshop.service.UpdateBookService;
import li.strolch.model.Resource; import li.strolch.model.Resource;
import li.strolch.model.json.StrolchElementToJsonVisitor; import li.strolch.model.json.StrolchRootElementToJsonVisitor;
import li.strolch.model.query.NameSelection; import li.strolch.model.query.NameSelection;
import li.strolch.model.query.OrSelection; import li.strolch.model.query.OrSelection;
import li.strolch.model.query.ParameterSelection; import li.strolch.model.query.ParameterSelection;
import li.strolch.model.query.ResourceQuery; import li.strolch.model.query.ResourceQuery;
import li.strolch.model.visitor.ResourceVisitor;
import li.strolch.persistence.api.StrolchTransaction; import li.strolch.persistence.api.StrolchTransaction;
import li.strolch.privilege.model.Certificate; import li.strolch.privilege.model.Certificate;
import li.strolch.rest.RestfulStrolchComponent; import li.strolch.rest.RestfulStrolchComponent;
import li.strolch.rest.StrolchRestfulConstants; import li.strolch.rest.StrolchRestfulConstants;
import li.strolch.rest.helper.ResponseUtil; import li.strolch.rest.helper.ResponseUtil;
import li.strolch.rest.util.JsonServiceArgument; import li.strolch.service.JsonServiceArgument;
import li.strolch.rest.util.JsonServiceResult; import li.strolch.service.JsonServiceResult;
import li.strolch.service.StringServiceArgument; import li.strolch.service.StringServiceArgument;
import li.strolch.service.api.ServiceHandler; import li.strolch.service.api.ServiceHandler;
import li.strolch.service.api.ServiceResult; import li.strolch.service.api.ServiceResult;
@ -62,17 +54,16 @@ public class BooksResource {
try (StrolchTransaction tx = RestfulStrolchComponent.getInstance().openTx(cert, getClass())) { try (StrolchTransaction tx = RestfulStrolchComponent.getInstance().openTx(cert, getClass())) {
// prepare the query // prepare the query
ResourceQuery<JsonObject> query = new BooksQuery<JsonObject>() // ResourceQuery<Resource> query = new BooksQuery<>();
// set transformation to JSON
.setVisitor(new StrolchElementToJsonVisitor().flat());
// prepare selections // prepare selections
if (StringHelper.isEmpty(queryS)) { if (StringHelper.isEmpty(queryS)) {
query.withAny(); query.withAny();
} else { } else {
OrSelection or = new OrSelection(); OrSelection or = new OrSelection();
or.with(ParameterSelection.stringSelection(BookShopConstants.BAG_PARAMETERS, or.with(ParameterSelection
BookShopConstants.PARAM_DESCRIPTION, queryS, StringMatchMode.ci())); .stringSelection(BookShopConstants.BAG_PARAMETERS, BookShopConstants.PARAM_DESCRIPTION, queryS,
StringMatchMode.ci()));
or.with(new NameSelection(queryS, StringMatchMode.ci())); or.with(new NameSelection(queryS, StringMatchMode.ci()));
// add selections // add selections
@ -80,13 +71,15 @@ public class BooksResource {
} }
// perform the query // perform the query
List<JsonObject> books = tx.doQuery(query); List<Resource> books = tx.doQuery(query);
// perform paging // perform paging
Paging<JsonObject> page = Paging.asPage(books, offset, limit); Paging<Resource> paging = Paging.asPage(books, offset, limit);
List<Resource> page = paging.getPage();
// return result // return result, transforming to JSON
return ResponseUtil.toResponse(StrolchRestfulConstants.DATA, page.getPage()); ResourceVisitor<JsonObject> visitor = new StrolchRootElementToJsonVisitor().flat().asResourceVisitor();
return ResponseUtil.listToResponse(StrolchRestfulConstants.DATA, page, a -> a.accept(visitor));
} }
} }
@ -107,7 +100,7 @@ public class BooksResource {
return ResponseUtil.toResponse(Status.NOT_FOUND, "Book " + id + " does not exist!"); return ResponseUtil.toResponse(Status.NOT_FOUND, "Book " + id + " does not exist!");
// transform to JSON // transform to JSON
JsonObject bookJ = book.accept(new StrolchElementToJsonVisitor().flat()); JsonObject bookJ = book.accept(new StrolchRootElementToJsonVisitor().flat());
// return // return
return ResponseUtil.toResponse(StrolchRestfulConstants.DATA, bookJ); return ResponseUtil.toResponse(StrolchRestfulConstants.DATA, bookJ);

View File

@ -1,15 +1,15 @@
package li.strolch.bookshop.service; package li.strolch.bookshop.service;
import com.google.gson.JsonObject; import static li.strolch.report.ReportConstants.BAG_RELATIONS;
import com.google.gson.JsonObject;
import li.strolch.bookshop.BookShopConstants; import li.strolch.bookshop.BookShopConstants;
import li.strolch.model.Resource; import li.strolch.model.Resource;
import li.strolch.model.json.FromFlatJsonVisitor; import li.strolch.model.json.FromFlatJsonVisitor;
import li.strolch.model.json.StrolchElementToJsonVisitor; import li.strolch.model.json.StrolchRootElementToJsonVisitor;
import li.strolch.persistence.api.AddResourceCommand;
import li.strolch.persistence.api.StrolchTransaction; import li.strolch.persistence.api.StrolchTransaction;
import li.strolch.rest.util.JsonServiceArgument; import li.strolch.service.JsonServiceArgument;
import li.strolch.rest.util.JsonServiceResult; import li.strolch.service.JsonServiceResult;
import li.strolch.service.api.AbstractService; import li.strolch.service.api.AbstractService;
public class CreateBookService extends AbstractService<JsonServiceArgument, JsonServiceResult> { public class CreateBookService extends AbstractService<JsonServiceArgument, JsonServiceResult> {
@ -37,19 +37,17 @@ public class CreateBookService extends AbstractService<JsonServiceArgument, Json
book = tx.getResourceTemplate(BookShopConstants.TYPE_BOOK); book = tx.getResourceTemplate(BookShopConstants.TYPE_BOOK);
// map all values from the JSON object into the new book element // map all values from the JSON object into the new book element
new FromFlatJsonVisitor().visit(book, arg.jsonElement.getAsJsonObject()); book.accept(new FromFlatJsonVisitor(arg.jsonElement.getAsJsonObject()).ignoreBag(BAG_RELATIONS));
// add command to store the resource // save changes
AddResourceCommand cmd = new AddResourceCommand(getContainer(), tx); tx.add(book);
cmd.setResource(book);
tx.addCommand(cmd);
// notify the TX that it should commit on close // notify the TX that it should commit on close
tx.commitOnClose(); tx.commitOnClose();
} }
// map the return value to JSON // map the return value to JSON
JsonObject result = book.accept(new StrolchElementToJsonVisitor().flat()); JsonObject result = book.accept(new StrolchRootElementToJsonVisitor().flat());
// and return the result // and return the result
return new JsonServiceResult(result); return new JsonServiceResult(result);

View File

@ -2,7 +2,6 @@ package li.strolch.bookshop.service;
import li.strolch.bookshop.BookShopConstants; import li.strolch.bookshop.BookShopConstants;
import li.strolch.model.Resource; import li.strolch.model.Resource;
import li.strolch.persistence.api.RemoveResourceCommand;
import li.strolch.persistence.api.StrolchTransaction; import li.strolch.persistence.api.StrolchTransaction;
import li.strolch.service.StringServiceArgument; import li.strolch.service.StringServiceArgument;
import li.strolch.service.api.AbstractService; import li.strolch.service.api.AbstractService;
@ -31,10 +30,8 @@ public class RemoveBookService extends AbstractService<StringServiceArgument, Se
// get the existing book // get the existing book
Resource book = tx.getResourceBy(BookShopConstants.TYPE_BOOK, arg.value, true); Resource book = tx.getResourceBy(BookShopConstants.TYPE_BOOK, arg.value, true);
// add command to remove the resource // save changes
RemoveResourceCommand cmd = new RemoveResourceCommand(getContainer(), tx); tx.remove(book);
cmd.setResource(book);
tx.addCommand(cmd);
// notify the TX that it should commit on close // notify the TX that it should commit on close
tx.commitOnClose(); tx.commitOnClose();

View File

@ -1,16 +1,16 @@
package li.strolch.bookshop.service; package li.strolch.bookshop.service;
import com.google.gson.JsonObject; import static li.strolch.report.ReportConstants.BAG_RELATIONS;
import com.google.gson.JsonObject;
import li.strolch.bookshop.BookShopConstants; import li.strolch.bookshop.BookShopConstants;
import li.strolch.model.Resource; import li.strolch.model.Resource;
import li.strolch.model.Tags.Json; import li.strolch.model.Tags.Json;
import li.strolch.model.json.FromFlatJsonVisitor; import li.strolch.model.json.FromFlatJsonVisitor;
import li.strolch.model.json.StrolchElementToJsonVisitor; import li.strolch.model.json.StrolchRootElementToJsonVisitor;
import li.strolch.persistence.api.StrolchTransaction; import li.strolch.persistence.api.StrolchTransaction;
import li.strolch.persistence.api.UpdateResourceCommand; import li.strolch.service.JsonServiceArgument;
import li.strolch.rest.util.JsonServiceArgument; import li.strolch.service.JsonServiceResult;
import li.strolch.rest.util.JsonServiceResult;
import li.strolch.service.api.AbstractService; import li.strolch.service.api.AbstractService;
import li.strolch.utils.dbc.DBC; import li.strolch.utils.dbc.DBC;
@ -43,19 +43,17 @@ public class UpdateBookService extends AbstractService<JsonServiceArgument, Json
book = tx.getResourceBy(BookShopConstants.TYPE_BOOK, arg.objectId, true); book = tx.getResourceBy(BookShopConstants.TYPE_BOOK, arg.objectId, true);
// map all values from the JSON object into the new book element // map all values from the JSON object into the new book element
new FromFlatJsonVisitor().visit(book, arg.jsonElement.getAsJsonObject()); book.accept(new FromFlatJsonVisitor(arg.jsonElement.getAsJsonObject()).ignoreBag(BAG_RELATIONS));
// add command to update the resource // save changes
UpdateResourceCommand cmd = new UpdateResourceCommand(getContainer(), tx); tx.update(book);
cmd.setResource(book);
tx.addCommand(cmd);
// notify the TX that it should commit on close // notify the TX that it should commit on close
tx.commitOnClose(); tx.commitOnClose();
} }
// map the return value to JSON // map the return value to JSON
JsonObject result = book.accept(new StrolchElementToJsonVisitor().flat()); JsonObject result = book.accept(new StrolchRootElementToJsonVisitor().flat());
// and return the result // and return the result
return new JsonServiceResult(result); return new JsonServiceResult(result);