You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
API v2 aims at specifying and harmonizing the endpoints between all
SDKs. It also adds an hotels endpoint.
The frontend is developed separately at:
https://github.com/couchbaselabs/try-cb-frontend/tree/v2.0.0
The API spec is in:
https://github.com/couchbaselabs/try-cb-frontend/blob/v2.0.0/documentation/try-cb-api-spec-v2.adoc
The `try-cb-frontend` project is up to date with Angular2 2.0.0 GA, is
versioned `v2.0.0` as well and is bundled and embedded in the backend
by this commit.
squashed commit, main changes:
---------------------------------------
* Added an Hotel service/controller to do FTS/subdoc
* support location-only search, keyword search in content/desc,
location only search is done by providing "*" as a description.
* added Result class, notion of context (for hotels)
* Standardize result JSON structure through Error and Result
* Return empty list if user document exists but has no flights
* fix error codes for flight booking, check bookings
* airport and flightPath endpoints modified according to v2
* flighPaths adds random price to each route
* v2: login/signup separated POST endpoints, token authentication support
* accounts now in default bucket & can expire (configurable)
* add context message for signup
* make sure to return an empty collection if no user document
* remove Angular1/api v1 frontend
* Added try-cb-frontend bundled files
Copy file name to clipboardExpand all lines: README.md
+42-28Lines changed: 42 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,27 +1,29 @@
1
1
# Couchbase Java Travel-Sample Application
2
-
This is a sample application for getting started with Couchbase Server 4.0. The application runs a single page UI for
3
-
demonstrating SQL for Documents (N1QL) querying capabilities. It uses Couchbase Server 4.0 (developer preview or later)
4
-
together with Spring Boot, Angular and Bootstrap.
2
+
This is a sample application for getting started with Couchbase Server 4.5. The application runs a single page UI for
3
+
demonstrating SQL for Documents (N1QL) and Full Text Search (FTS) querying capabilities. It uses Couchbase Server 4.5
4
+
together with Spring Boot, Angular2 and Bootstrap.
5
5
6
6
The application is a flight planner that allows the user to search for and select a flight route (including the
7
7
return flight) based on airports and dates. Airport selection is done dynamically using an angular autocomplete box
8
-
bound to N1QL queries on the server side. Date selection uses date time pickers and then searches for applicable air
9
-
flight routes from a previously populated database.
8
+
bound to N1QL queries on the server side. After selecting a date, it then searches for applicable air flight routes from
9
+
a previously populated database. An additional page allows users to search for Hotels using less structured keywords.
10
10
11
11

12
12
13
13
## Prerequisites
14
14
The following pieces need to be in place in order to run the application.
15
15
16
-
1. Couchbase Server 4.0 DP or later with the `travel-sample` bucket.
16
+
1. Couchbase Server 4.5 or later with the `travel-sample` bucket.
17
17
2. Java 6 or later
18
18
3. Maven 3 or later
19
19
20
20
If you want to run the application from your IDE rather than from the command line you also need your IDE set up to
21
21
work with maven-based projects. We recommend running IntelliJ IDEA, but Eclipse or Netbeans will also work.
22
22
23
+
Note that the project uses Lombok, so code generation through annotation processing must be enabled.
24
+
23
25
## Running the Application
24
-
To download the application you can either download [the archive](https://github.com/couchbaselabs/try-cb-java/archive/master.zip) or
26
+
To download the application you can either download [the archive](https://github.com/couchbaselabs/try-cb-java/archive/2.0.0.zip) or
2015-04-07 13:28:18.186 INFO 64284 --- [lication.main()] trycb.Application : Starting Application on daschlbook.local with PID 64284 (/Users/michael/couchbase/try-cb-java/target/classes started by michael in /Users/michael/couchbase/try-cb-java)
58
-
2015-04-07 13:28:18.234 INFO 64284 --- [lication.main()] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@52f887ba: startup date [Tue Apr 07 13:28:18 CEST 2015]; root of context hierarchy
2015-04-07 13:28:21.043 INFO 64284 --- [ cb-io-1-1] com.couchbase.client.core.node.Node : Connected to Node localhost
62
-
2015-04-07 13:28:21.354 INFO 64284 --- [-computations-5] c.c.c.core.config.ConfigurationProvider : Opened bucket travel-sample
63
-
2015-04-07 13:28:21.559 INFO 64284 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@52f887ba: startup date [Tue Apr 07 13:28:18 CEST 2015]; root of context hierarchy
64
-
2015-04-07 13:28:21.622 INFO 64284 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/flightPath/findAll],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.List<java.util.Map<java.lang.String, java.lang.Object>> trycb.Application.all(java.lang.String,java.lang.String,java.lang.String) throws java.lang.Exception
65
-
2015-04-07 13:28:21.623 INFO 64284 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/airport/findAll],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.List<java.util.Map<java.lang.String, java.lang.Object>> trycb.Application.airports(java.lang.String)
66
-
2015-04-07 13:28:21.624 INFO 64284 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
67
-
2015-04-07 13:28:21.624 INFO 64284 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
68
-
...
69
-
2015-04-07 13:28:21.853 INFO 64284 --- [lication.main()] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
70
-
2015-04-07 13:28:21.854 INFO 64284 --- [lication.main()] trycb.Application : Started Application in 3.943 seconds (JVM running for 8.494)
55
+
:: Spring Boot :: (v1.2.5.RELEASE)
56
+
57
+
2016-09-12 14:15:36.438 INFO 64357 --- [lication.main()] trycb.Application : Starting Application on SimonBookPro.local with PID 64357 (/Users/edralzar/dev/couchbase/misc/try-cb-java/target/classes started by edralzar in /Users/edralzar/dev/couchbase/misc/try-cb-java)
58
+
2016-09-12 14:15:37.606 INFO 64357 --- [lication.main()] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
59
+
2016-09-12 14:15:37.979 INFO 64357 --- [lication.main()] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-09-12 14:15:38.062 INFO 64357 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
62
+
2016-09-12 14:15:38.063 INFO 64357 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1594 ms
2016-09-12 14:15:39.456 INFO 64357 --- [ cb-io-1-1] com.couchbase.client.core.node.Node : Connected to Node localhost
65
+
2016-09-12 14:15:39.822 INFO 64357 --- [-computations-1] c.c.c.core.config.ConfigurationProvider : Opened bucket travel-sample
66
+
2016-09-12 14:15:39.895 INFO 64357 --- [-computations-5] c.c.c.core.config.ConfigurationProvider : Opened bucket default
67
+
2016-09-12 14:15:39.905 INFO 64357 --- [lication.main()] trycb.util.StartupPreparations : Ensuring all Indexes are created.
68
+
2016-09-12 14:15:40.017 INFO 64357 --- [lication.main()] trycb.util.StartupPreparations : All indexes are already in place, nothing to build
69
+
2016-09-12 14:15:40.183 INFO 64357 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6f7e827: startup date [Mon Sep 12 14:15:36 CEST 2016]; root of context hierarchy
70
+
2016-09-12 14:15:40.232 INFO 64357 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/airports]}" onto public org.springframework.http.ResponseEntity<? extends trycb.model.IValue> trycb.web.AirportController.airports(java.lang.String)
71
+
2016-09-12 14:15:40.233 INFO 64357 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/flightPaths/{from}/{to}]}" onto public org.springframework.http.ResponseEntity<? extends trycb.model.IValue> trycb.web.FlightPathController.all(java.lang.String,java.lang.String,java.lang.String)
72
+
2016-09-12 14:15:40.234 INFO 64357 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/hotel/],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<? extends trycb.model.IValue> trycb.web.HotelController.findAllHotels()
73
+
2016-09-12 14:15:40.234 INFO 64357 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/hotel/{description}/{location}/],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<? extends trycb.model.IValue> trycb.web.HotelController.findHotelsByDescriptionAndLocation(java.lang.String,java.lang.String)
74
+
2016-09-12 14:15:40.234 INFO 64357 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/hotel/{description}/],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<? extends trycb.model.IValue> trycb.web.HotelController.findHotelsByDescription(java.lang.String)
75
+
2016-09-12 14:15:40.235 INFO 64357 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/user/{username}/flights],methods=[POST]}" onto public org.springframework.http.ResponseEntity<? extends trycb.model.IValue> trycb.web.UserController.book(java.lang.String,java.lang.String,java.lang.String)
76
+
2016-09-12 14:15:40.235 INFO 64357 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/user/{username}/flights],methods=[GET]}" onto public java.lang.Object trycb.web.UserController.booked(java.lang.String,java.lang.String)
77
+
2016-09-12 14:15:40.235 INFO 64357 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/user/login],methods=[POST]}" onto public org.springframework.http.ResponseEntity<? extends trycb.model.IValue> trycb.web.UserController.login(java.util.Map<java.lang.String, java.lang.String>)
78
+
2016-09-12 14:15:40.235 INFO 64357 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/api/user/signup],methods=[POST]}" onto public org.springframework.http.ResponseEntity<? extends trycb.model.IValue> trycb.web.UserController.createLogin(java.lang.String)
79
+
2016-09-12 14:15:40.236 INFO 64357 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
80
+
2016-09-12 14:15:40.236 INFO 64357 --- [lication.main()] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
81
+
2016-09-12 14:15:40.398 INFO 64357 --- [lication.main()] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
82
+
2016-09-12 14:15:40.400 INFO 64357 --- [lication.main()] trycb.Application : Started Application in 4.172 seconds (JVM running for 16.45)
71
83
```
72
84
73
85
Note that when you run the application for the first time, it will make sure that all indexes are created for best
@@ -87,8 +99,10 @@ can check the command line which prints all the executed N1QL queries:
87
99
```
88
100
89
101
## Custom Options
90
-
By default it will connect to the `travel-sample` bucket on `127.0.0.1`. You can conveniently change those options through
91
-
the command line on bootstrap:
102
+
By default it will connect to the `travel-sample` bucket on `127.0.0.1`. It will however separate user account data into
103
+
the `default` bucket (and these documents can be set to expire). All these options can be tuned in the
104
+
`src/main/resources/application.properties`. You can also conveniently change those options through the command line at
0 commit comments