A simple JPA backend service that loads data from a CSV file and make it
accessible through Person
entity.
It can be easily upgraded to read/write from a real database instead of the CSV file.
You can modify the provided demo data from Persons.csv
located under
src/resources
.
##Watch step by step on how to use this backend in a Vaadin project
You can optain the maven dependecy from Vaain Directoy without any downloads or installs.
Platform and IDE independant, you can install this project locally using the following three commands:
$ git clone [email protected]:amahdy/person-service.git
$ cd person-service
$ mvn install
Or alternatively:
This project is easy to import into Eclipse from the eclipse-project branch. Here are the direct steps to get started:
Step 1) From Eclipse, open File, Import
Step 2) Select under Git, Projects from Git
Step 3) Select Clone URI
Step 4) Fill the URI with the repository's link
Step 5) Keep eclipse-project branch selected and unselect all other branches
Step 6) Specify a directory for the cloned copy of this project
Step 7) Select Import existing Eclipse projects
Step 8) Eclipse project will be detected and ready to be imported
Step 9) You will see the project files and Java classes
Step 10) Right click on the project, select Run As, Maven install
Step 11) You should get a BUILD SUCCESS in the Console, now the project is ready to be used locally
After installing this project locally, you can easily reference it by including it as a dependecy into the front-end project. Most porbably you will need to include JavaEE dependencies as well:
<dependencies>
...
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.vaadin.stepbystep</groupId>
<artifactId>person-service</artifactId>
<version>1.1</version>
</dependency>
...
</dependencies>
- Inject
PersonService
. - Call
loadData()
to load the data from the CSV file. - Call
getEntries()
to return a list ofPerson
. - Call
delete()
orsave()
to update a given entity.
@Inject
PersonService service;
@PostConstruct
void load() {
service.loadData();
container.bind(service.getEntries());
}