People Service Guide
What you'll build
You will build a simple service that allows managing people.
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
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 Person.java
file in the src/main/java/com/flexicore/examples/person/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.
Person
object inherits from Baseclass
since we want to be able to govern permissions for itcopy persistence.xml content from here.
this will allow automatic generation of JPA metamodels required to implement Criteria API based queries.
./mvn install
./cp target/person-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:
PersonCreate
– this object will contain all required details for creating a person it will also inherit from BaseclassCreate
object as we would like to extend Baseclass
capabilitiesPersonUpdate
– this object will extend PersonCreate
object and id of the person to updatePersonFilter
– this object will be sent by the client when fetching people containing filtering options.lets define the repository that will be used to fetch and save people from 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 objectsaddPersonPredicates
which adds the required predicates , all access control predicates are automatically added when countAllFiltered
and getAllFiltered
are calledaddPersonPredicates
uses JPA Criteria Api to filter data based on PersonFilter
object we have created in previous phase , it is empty as we currently have not specific filters.lets define the service that will be used by other plugins and REST api (or any other API implementations for that matter)
lets define the REST service that will expose REST api that our clients will use:
Success Stories