Library Service Guide
What you'll build
You will build a service managing books, authors and subscriptions.
What you’ll need
A Java™ Development Kit (JDK) installed. We recommend AdoptOpenJDK version 11 or 8.
Apache Maven version 3.1 or later installed.
An Integrated Developer Environment (IDE)
Popular choices include IntelliJ IDEA, Spring Tools, Visual Studio Code, or Eclipse, and many more.
A FlexiCore based server running locally or on an accessible server.
One-click, no prerequisites installation is available for Linux (AMD64, ARM64) and Windows (AMD64) here
A Docker image with fully installed FlexiCore and prerequisites is available here
Library Management project is dependent on People Management project , please complete the people management guide.
managing entities for this phase:
Create a new Maven Project with the following structure:
update your pom.xml from here
Open up the project in your IDE and create the Book.java
file in the src/main/java/com/flexicore/example/library/model
folder. Now change the contents of the file by adding the extra method and annotations shown in the code below. You can copy and paste the code or just type it.
Book
object inherits from Baseclass
since we want to be able to govern permissions for itOpen up the project in your IDE and create the Author.java
file in the src/main/java/com/flexicore/example/library/model
folder. Now change the contents of the file by adding the extra method and annotations shown in the code below. You can copy and paste the code or just type it.
if you haven’t completed the People Management Project it is required to compile library model.
Open up the project in your IDE and create the Subscription.java
file in the src/main/java/com/flexicore/example/library/model
folder. Now change the contents of the file by adding the extra method and annotations shown in the code below. You can copy and paste the code or just type it.
OffsetDateTime
typed fields are annotated by@Column(columnDefinition = "timestamp with time zone")
to tell our database to save the date information with time zone.copy persistence.xml content from here.
this will allow automatic generation of JPA metamodels required to implement Criteria API based queries.
./mvn install
./cp target/library-model-1.0.0-jar /home/flexicore/entities
create a maven project with the following structure:
update your pom.xml from here
lets define objects that will be consumed by our api:
BookCreate
– this object will contain all required details for creating a Book it will also inherit from BaseclassCreate
object as we would like to extend Baseclass
capabilitiesBookUpdate
– this object will extend BookCreate
object and id of the book to updateBookFilter
– this object will be sent by the client when fetching Books containing filtering options on them.AuthorCreate
– this object will contain all required details for creating an Author it will also inherit from PersonCreate
object as we would like to extend Person
capabilitiesAuthorUpdate
– this object will extend AuthorCreate
object and id of the Author to updateAuthorFilter
– this object will be sent by the client when fetching Authors containing filtering options on them.SubscriptionCreate
– this object will contain all required details for creating an Subscription it will also inherit from BaseclassCreate
object as we would like to extend Baseclass capabilitiesSubscriptionUpdate
– this object will extend SubscriptionCreate
object and id of the Subscription to updateSubscriptionFilter
– this object will be sent by the client when fetching Subscriptions containing filtering options on them.
lets define the repositories that will be used to fetch and save books, authors and subscriptions from the database.
@Extension
annotation to allow FlexiCore to load it as a plugin @PluginInfo
annotation to allow future versioning support@Component
annotation to let spring know it is a bean.AbstractRepositoryPlugin
which provides easy method for access control and out of the box methods for persisting objectsBook/Author/Subscription
both are calling the relevant addBookPredicates/addAuthorPredicates/addSubscriptionPredicates
which adds the required predicates , all access control predicates are automatically added when countAllFiltered
and getAllFiltered
are calledaddBookPredicates/addAuthorPredicates/addSubscriptionPredicates
uses JPA Criteria Api to filter data based on BookFilter/AuthorFilter/SubscriptionFilter
objects we have created in previous phase.lets define the services that will be used by other plugins and REST api (or any other API implementations for that matter)
lets define the REST services that will expose REST API that our clients will use:
Success Stories