├── config-microservice ├── manifest.yml ├── src │ └── main │ │ ├── docker │ │ └── Dockerfile │ │ ├── java │ │ └── services │ │ │ └── Application.java │ │ └── resources │ │ ├── application.yml │ │ └── bootstrap.yml └── pom.xml ├── ui-search ├── src │ ├── main │ │ ├── docker │ │ │ └── Dockerfile │ │ ├── java │ │ │ └── service │ │ │ │ ├── models │ │ │ │ ├── Genre.java │ │ │ │ ├── Product.java │ │ │ │ ├── Rating.java │ │ │ │ ├── User.java │ │ │ │ └── Movie.java │ │ │ │ ├── clients │ │ │ │ ├── UserClient.java │ │ │ │ ├── RatingClient.java │ │ │ │ └── MovieClient.java │ │ │ │ ├── Application.java │ │ │ │ └── ui │ │ │ │ ├── MovieUI.java │ │ │ │ └── UserUI.java │ │ └── resources │ │ │ ├── bootstrap.yml │ │ │ └── application.yml │ └── test │ │ └── java │ │ └── service │ │ └── DemoApplicationTests.java └── pom.xml ├── rating-microservice ├── src │ └── main │ │ ├── docker │ │ └── Dockerfile │ │ ├── resources │ │ ├── bootstrap.yml │ │ └── application.yml │ │ └── java │ │ └── service │ │ ├── data │ │ ├── repositories │ │ │ ├── UserRepository.java │ │ │ ├── RatingRepository.java │ │ │ └── ProductRepository.java │ │ └── domain │ │ │ ├── entity │ │ │ ├── Product.java │ │ │ └── User.java │ │ │ └── rels │ │ │ └── Rating.java │ │ ├── config │ │ └── GraphDatabaseConfiguration.java │ │ └── Application.java └── pom.xml ├── api-gateway-microservice ├── src │ └── main │ │ ├── docker │ │ └── Dockerfile │ │ ├── resources │ │ ├── bootstrap.yml │ │ └── application.yml │ │ └── java │ │ └── services │ │ └── Application.java └── pom.xml ├── user-microservice ├── src │ └── main │ │ ├── docker │ │ └── Dockerfile │ │ ├── resources │ │ ├── static │ │ │ ├── import-users.cypher │ │ │ └── users.csv │ │ ├── bootstrap.yml │ │ └── application.yml │ │ └── java │ │ └── service │ │ ├── data │ │ ├── repositories │ │ │ └── UserRepository.java │ │ ├── config │ │ │ ├── CouchbaseConfiguration.java │ │ │ └── CachingConfiguration.java │ │ └── domain │ │ │ └── entity │ │ │ └── User.java │ │ └── Application.java ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── pom.xml ├── movie-microservice ├── src │ └── main │ │ ├── docker │ │ └── Dockerfile │ │ ├── resources │ │ ├── bootstrap.yml │ │ ├── schema-hsqldb.sql │ │ ├── schema-mysql.sql │ │ └── application.yml │ │ └── java │ │ └── service │ │ ├── data │ │ ├── repositories │ │ │ └── MovieRepository.java │ │ └── domain │ │ │ ├── Genre.java │ │ │ └── Movie.java │ │ ├── Application.java │ │ └── config │ │ └── ApplicationConfig.java └── pom.xml ├── discovery-microservice ├── src │ └── main │ │ ├── docker │ │ └── Dockerfile │ │ ├── resources │ │ ├── bootstrap.yml │ │ └── application.yml │ │ └── java │ │ └── services │ │ └── Application.java └── pom.xml ├── .gitignore ├── manifest.yml ├── docker └── docker-compose.yml ├── pom.xml ├── README.md └── LICENSE /config-microservice/manifest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | applications: 3 | - name: config-microservice 4 | host: config-microservice-${random-word} 5 | memory: 512M 6 | instances: 1 7 | path: target/config-microservice-0.1.0.jar 8 | -------------------------------------------------------------------------------- /ui-search/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD ui-search-0.1.0.jar app.jar 4 | RUN bash -c 'touch /app.jar' 5 | EXPOSE 9006 6 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] 7 | -------------------------------------------------------------------------------- /rating-microservice/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD rating-microservice-0.1.0.jar app.jar 4 | RUN bash -c 'touch /app.jar' 5 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] 6 | -------------------------------------------------------------------------------- /api-gateway-microservice/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD api-gateway-microservice-0.1.0.jar app.jar 4 | RUN bash -c 'touch /app.jar' 5 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] 6 | -------------------------------------------------------------------------------- /user-microservice/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD user-microservice-0.1.0.jar app.jar 4 | RUN bash -c 'touch /app.jar' 5 | EXPOSE 9000 6 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] 7 | -------------------------------------------------------------------------------- /config-microservice/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD config-microservice-0.1.0.jar app.jar 4 | RUN bash -c 'touch /app.jar' 5 | EXPOSE 8888 6 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] 7 | -------------------------------------------------------------------------------- /movie-microservice/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD movie-microservice-0.1.0.jar app.jar 4 | RUN bash -c 'touch /app.jar' 5 | EXPOSE 9000 6 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] 7 | -------------------------------------------------------------------------------- /discovery-microservice/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:8 2 | VOLUME /tmp 3 | ADD discovery-microservice-0.1.0.jar app.jar 4 | RUN bash -c 'touch /app.jar' 5 | EXPOSE 8761 6 | ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"] 7 | -------------------------------------------------------------------------------- /user-microservice/src/main/resources/static/import-users.cypher: -------------------------------------------------------------------------------- 1 | LOAD CSV WITH HEADERS FROM "http://localhost:9000/users.csv" AS csvLine 2 | MERGE (user:User:_User { id: csvLine.id, age: toInt(csvLine.age), gender: csvLine.gender, occupation: csvLine.occupation, zipcode: csvLine.zipcode }) -------------------------------------------------------------------------------- /user-microservice/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Mar 15 13:48:01 EDT 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-bin.zip 7 | -------------------------------------------------------------------------------- /ui-search/src/main/java/service/models/Genre.java: -------------------------------------------------------------------------------- 1 | package service.models; 2 | 3 | /** 4 | * Created by kennybastani on 8/17/15. 5 | */ 6 | public class Genre { 7 | String name; 8 | 9 | public String getName() { 10 | return name; 11 | } 12 | 13 | public void setName(String name) { 14 | this.name = name; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | 14 | .gradle/ 15 | .idea/ 16 | 17 | *.db/ 18 | 19 | *.iml 20 | 21 | build/ 22 | target/ 23 | *.prefs 24 | *.classpath 25 | .settings/ 26 | .factorypath 27 | 28 | .project 29 | -------------------------------------------------------------------------------- /user-microservice/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: docker 4 | --- 5 | spring: 6 | profiles: cloud 7 | application: 8 | name: user 9 | encrypt: 10 | failOnError: false 11 | --- 12 | spring: 13 | profiles: docker 14 | application: 15 | name: user 16 | cloud: 17 | config: 18 | uri: http://configserver:8888 19 | enabled: false 20 | encrypt: 21 | failOnError: false -------------------------------------------------------------------------------- /discovery-microservice/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: docker 4 | --- 5 | spring: 6 | profiles: cloud 7 | application: 8 | name: discovery 9 | cloud: 10 | config: 11 | uri: http://config-99.cfapps.io 12 | encrypt: 13 | failOnError: false 14 | --- 15 | spring: 16 | profiles: docker 17 | application: 18 | name: discovery 19 | cloud: 20 | config: 21 | uri: http://192.168.59.103:8888 22 | encrypt: 23 | failOnError: false -------------------------------------------------------------------------------- /ui-search/src/main/java/service/models/Product.java: -------------------------------------------------------------------------------- 1 | package service.models; 2 | 3 | public class Product { 4 | private Long id; 5 | private String knownId; 6 | 7 | public Long getId() { 8 | return id; 9 | } 10 | 11 | public void setId(Long id) { 12 | this.id = id; 13 | } 14 | 15 | public String getKnownId() { 16 | return knownId; 17 | } 18 | 19 | public void setKnownId(String knownId) { 20 | this.knownId = knownId; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /api-gateway-microservice/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: cloud 4 | --- 5 | 6 | spring: 7 | profiles: cloud 8 | application: 9 | name: gateway 10 | cloud: 11 | config: 12 | uri: http://config-99.cfapps.io/ 13 | encrypt: 14 | failOnError: false 15 | 16 | --- 17 | 18 | spring: 19 | profiles: docker 20 | application: 21 | name: gateway 22 | cloud: 23 | config: 24 | uri: http://configserver:8888 25 | encrypt: 26 | failOnError: false -------------------------------------------------------------------------------- /movie-microservice/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: docker 4 | --- 5 | spring: 6 | profiles: cloud 7 | application: 8 | name: movie 9 | cloud: 10 | config: 11 | uri: http://config-99.cfapps.io/ 12 | encrypt: 13 | failOnError: false 14 | --- 15 | spring: 16 | profiles: docker 17 | application: 18 | name: movie 19 | cloud: 20 | config: 21 | uri: http://configserver:8888 22 | enabled: false 23 | encrypt: 24 | failOnError: false -------------------------------------------------------------------------------- /ui-search/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: cloud 4 | --- 5 | spring: 6 | profiles: 7 | name: cloud 8 | application: 9 | name: moviesui 10 | cloud: 11 | config: 12 | uri: http://config-99.cfapps.io/ 13 | encrypt: 14 | failOnError: false 15 | --- 16 | spring: 17 | profiles: docker 18 | application: 19 | name: moviesui 20 | cloud: 21 | config: 22 | uri: http://configserver:8888 23 | enabled: false 24 | encrypt: 25 | failOnError: false -------------------------------------------------------------------------------- /rating-microservice/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: docker 4 | --- 5 | spring: 6 | profiles: 7 | name: cloud 8 | application: 9 | name: rating 10 | cloud: 11 | config: 12 | uri: http://config-99.cfapps.io/ 13 | enabled: true 14 | encrypt: 15 | failOnError: false 16 | --- 17 | spring: 18 | profiles: docker 19 | application: 20 | name: rating 21 | cloud: 22 | config: 23 | uri: http://configserver:8888 24 | enabled: false 25 | encrypt: 26 | failOnError: false -------------------------------------------------------------------------------- /movie-microservice/src/main/resources/schema-hsqldb.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS movie_genre; 2 | DROP TABLE IF EXISTS genre; 3 | DROP TABLE IF EXISTS movie; 4 | 5 | CREATE TABLE genre 6 | ( 7 | id BIGINT PRIMARY KEY NOT NULL, 8 | name VARCHAR(30) NOT NULL 9 | ); 10 | CREATE TABLE movie 11 | ( 12 | id BIGINT PRIMARY KEY NOT NULL, 13 | released BIGINT, 14 | title VARCHAR(255) NOT NULL, 15 | timestamp DATETIME, 16 | video INT, 17 | url VARCHAR(255) NOT NULL 18 | ); 19 | CREATE TABLE movie_genre 20 | ( 21 | movies_id BIGINT NOT NULL, 22 | genres_id BIGINT DEFAULT 0 NOT NULL, 23 | PRIMARY KEY (movies_id, genres_id) 24 | ); 25 | -------------------------------------------------------------------------------- /discovery-microservice/src/main/java/services/Application.java: -------------------------------------------------------------------------------- 1 | package services; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.builder.SpringApplicationBuilder; 6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 7 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; 8 | 9 | @SpringBootApplication 10 | @EnableEurekaServer 11 | @EnableEurekaClient 12 | @Slf4j 13 | public class Application { 14 | public static void main(String[] args) { 15 | new SpringApplicationBuilder(Application.class).web(true).run(args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ui-search/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: cloud 4 | --- 5 | spring: 6 | profiles: cloud 7 | server: 8 | port: 1111 9 | eureka: 10 | client: 11 | serviceUrl: 12 | defaultZone: http://discovery-77.cfapps.io/eureka/ 13 | instance: 14 | hostname: ui-search-77.cfapps.io 15 | nonSecurePort: 80 16 | ribbon: 17 | eureka: 18 | enabled: true 19 | --- 20 | spring: 21 | profiles: docker 22 | server: 23 | port: 1111 24 | eureka: 25 | client: 26 | serviceUrl: 27 | defaultZone: http://discovery:8761/eureka/ 28 | instance: 29 | preferIpAddress: true 30 | ribbon: 31 | eureka: 32 | enabled: true -------------------------------------------------------------------------------- /config-microservice/src/main/java/services/Application.java: -------------------------------------------------------------------------------- 1 | package services; 2 | 3 | import org.springframework.boot.autoconfigure.SpringBootApplication; 4 | import org.springframework.boot.builder.SpringApplicationBuilder; 5 | import org.springframework.cloud.config.server.EnableConfigServer; 6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient; 7 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 8 | 9 | @SpringBootApplication 10 | @EnableConfigServer 11 | @EnableEurekaClient 12 | @EnableZuulProxy 13 | public class Application { 14 | public static void main(String[] args) { 15 | new SpringApplicationBuilder(Application.class).web(true).run(args); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ui-search/src/test/java/service/DemoApplicationTests.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.test.context.ActiveProfiles; 6 | import org.springframework.test.context.web.WebAppConfiguration; 7 | import org.springframework.boot.test.SpringApplicationConfiguration; 8 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 9 | 10 | @RunWith(SpringJUnit4ClassRunner.class) 11 | @SpringApplicationConfiguration(classes = Application.class) 12 | @WebAppConfiguration 13 | @ActiveProfiles({"development"}) 14 | public class DemoApplicationTests { 15 | 16 | @Test 17 | public void contextLoads() { 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /movie-microservice/src/main/resources/schema-mysql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS movie_genre; 2 | DROP TABLE IF EXISTS genre; 3 | DROP TABLE IF EXISTS movie; 4 | 5 | CREATE TABLE genre 6 | ( 7 | id BIGINT PRIMARY KEY NOT NULL, 8 | name VARCHAR(30) NOT NULL 9 | ); 10 | CREATE TABLE movie 11 | ( 12 | id BIGINT PRIMARY KEY NOT NULL, 13 | released BIGINT, 14 | title VARCHAR(255) NOT NULL, 15 | timestamp DATETIME, 16 | video INT, 17 | url VARCHAR(255) NOT NULL 18 | ); 19 | CREATE TABLE movie_genre 20 | ( 21 | movies_id BIGINT NOT NULL, 22 | genres_id BIGINT DEFAULT 0 NOT NULL, 23 | PRIMARY KEY (movies_id, genres_id) 24 | ); 25 | 26 | CREATE UNIQUE INDEX unique_id ON genre (id); 27 | CREATE UNIQUE INDEX unique_id ON movie (id); 28 | -------------------------------------------------------------------------------- /movie-microservice/src/main/java/service/data/repositories/MovieRepository.java: -------------------------------------------------------------------------------- 1 | package service.data.repositories; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.jpa.repository.JpaRepository; 6 | import org.springframework.data.repository.query.Param; 7 | import service.data.domain.Movie; 8 | 9 | /** 10 | * @author Kenny Bastani 11 | * 12 | * The Movie repository exposes a collection of movie records with their genres 13 | */ 14 | public interface MovieRepository extends JpaRepository { 15 | Page findByTitleContainingIgnoreCase(@Param("title")String title, Pageable pageable); 16 | Page findByIdIn(@Param("ids")Long[] ids, Pageable pageable); 17 | } 18 | -------------------------------------------------------------------------------- /user-microservice/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: docker 4 | --- 5 | spring: 6 | profiles: cloud 7 | server: 8 | port: 9000 9 | eureka: 10 | client: 11 | serviceUrl: 12 | defaultZone: http://discovery-77.cfapps.io/eureka/ 13 | instance: 14 | hostname: user-77.cfapps.io 15 | nonSecurePort: 80 16 | ribbon: 17 | eureka: 18 | enabled: true 19 | aws: 20 | s3: 21 | url: https://s3.amazonaws.com/dataset-demos 22 | --- 23 | spring: 24 | profiles: docker 25 | server: 26 | port: 9000 27 | eureka: 28 | client: 29 | serviceUrl: 30 | defaultZone: http://discovery:8761/eureka/ 31 | instance: 32 | preferIpAddress: true 33 | ribbon: 34 | eureka: 35 | enabled: true 36 | aws: 37 | s3: 38 | url: https://s3.amazonaws.com/dataset-demos -------------------------------------------------------------------------------- /movie-microservice/src/main/java/service/data/domain/Genre.java: -------------------------------------------------------------------------------- 1 | package service.data.domain; 2 | 3 | import javax.persistence.*; 4 | import java.io.Serializable; 5 | 6 | @Entity 7 | @Table(name = "genre") 8 | public class Genre implements Serializable { 9 | 10 | private static final long serialVersionUID = -1952735933715107252L; 11 | 12 | @Id 13 | @Column(name = "id") 14 | @GeneratedValue 15 | Long id; 16 | 17 | @Column(name = "name") 18 | String name; 19 | 20 | public Genre() { 21 | } 22 | 23 | public Long getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Long id) { 28 | this.id = id; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /movie-microservice/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: docker 4 | --- 5 | spring: 6 | profiles: cloud 7 | jpa: 8 | show_sql: false 9 | database: MYSQL 10 | hibernate: 11 | ddl-auto: none 12 | server: 13 | port: 9006 14 | eureka: 15 | client: 16 | serviceUrl: 17 | defaultZone: http://discovery-77.cfapps.io/eureka/ 18 | instance: 19 | hostname: movie-77.cfapps.io 20 | nonSecurePort: 80 21 | ribbon: 22 | eureka: 23 | enabled: true 24 | --- 25 | spring: 26 | profiles: docker 27 | jpa: 28 | show_sql: false 29 | hibernate: 30 | ddl-auto: none 31 | datasource: 32 | platform: hsqldb 33 | server: 34 | port: 1111 35 | eureka: 36 | client: 37 | serviceUrl: 38 | defaultZone: http://discovery:8761/eureka/ 39 | instance: 40 | preferIpAddress: true 41 | ribbon: 42 | eureka: 43 | enabled: true -------------------------------------------------------------------------------- /rating-microservice/src/main/java/service/data/repositories/UserRepository.java: -------------------------------------------------------------------------------- 1 | package service.data.repositories; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.neo4j.annotation.Query; 6 | import org.springframework.data.repository.PagingAndSortingRepository; 7 | import org.springframework.data.repository.query.Param; 8 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 9 | import service.data.domain.entity.User; 10 | 11 | @RepositoryRestResource(collectionResourceRel = "users", path = "users") 12 | public interface UserRepository extends PagingAndSortingRepository { 13 | @Override 14 | @Query("MATCH (u:User) RETURN u") 15 | Page findAll(Pageable pageable); 16 | 17 | @Override 18 | @Query("MATCH (u:User) WHERE id(u) = {id} RETURN u") 19 | User findOne(@Param(value = "id") Long id); 20 | } 21 | -------------------------------------------------------------------------------- /api-gateway-microservice/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: cloud 4 | --- 5 | 6 | spring: 7 | profiles: cloud 8 | server: 9 | port: 10000 10 | endpoints: 11 | restart: 12 | enabled: true 13 | shutdown: 14 | enabled: true 15 | health: 16 | sensitive: false 17 | eureka: 18 | instance: 19 | hostname: gateway-77.cfapps.io 20 | nonSecurePort: 80 21 | client: 22 | registerWithEureka: true 23 | fetchRegistry: true 24 | serviceUrl: 25 | defaultZone: http://discovery-77.cfapps.io/eureka/ 26 | 27 | --- 28 | 29 | spring: 30 | profiles: docker 31 | server: 32 | port: 10000 33 | endpoints: 34 | restart: 35 | enabled: true 36 | shutdown: 37 | enabled: true 38 | health: 39 | sensitive: false 40 | eureka: 41 | client: 42 | serviceUrl: 43 | defaultZone: http://discovery:8761/eureka/ 44 | instance: 45 | preferIpAddress: true 46 | ribbon: 47 | eureka: 48 | enabled: true -------------------------------------------------------------------------------- /discovery-microservice/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: docker 4 | --- 5 | spring: 6 | profiles: cloud 7 | cloud: 8 | config: 9 | discovery: 10 | enabled: true 11 | server: 12 | port: 8761 13 | endpoints: 14 | restart: 15 | enabled: true 16 | shutdown: 17 | enabled: true 18 | health: 19 | sensitive: false 20 | eureka: 21 | instance: 22 | hostname: discovery 23 | client: 24 | registerWithEureka: false 25 | fetchRegistry: false 26 | serviceUrl: 27 | defaultZone: http://discovery-77.cfapps.io/eureka/ 28 | --- 29 | spring: 30 | profiles: docker 31 | server: 32 | port: 8761 33 | endpoints: 34 | restart: 35 | enabled: true 36 | shutdown: 37 | enabled: true 38 | health: 39 | sensitive: true 40 | eureka: 41 | instance: 42 | hostname: discovery 43 | preferIpAddress: true 44 | client: 45 | registerWithEureka: true 46 | fetchRegistry: false 47 | serviceUrl: 48 | defaultZone: http://discovery:8761/eureka/ -------------------------------------------------------------------------------- /api-gateway-microservice/src/main/java/services/Application.java: -------------------------------------------------------------------------------- 1 | package services; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.builder.SpringApplicationBuilder; 6 | import org.springframework.cloud.netflix.sidecar.EnableSidecar; 7 | import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; 8 | import org.springframework.hateoas.hal.Jackson2HalModule; 9 | 10 | import javax.annotation.PostConstruct; 11 | 12 | @SpringBootApplication 13 | @EnableSidecar 14 | public class Application { 15 | @Autowired 16 | private RepositoryRestMvcConfiguration restConfiguration; 17 | 18 | public static void main(String[] args) { 19 | new SpringApplicationBuilder(Application.class).web(true).run(args); 20 | } 21 | 22 | @PostConstruct 23 | public void postConstructConfiguration() { 24 | restConfiguration.objectMapper().registerModule(new Jackson2HalModule()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ui-search/src/main/java/service/models/Rating.java: -------------------------------------------------------------------------------- 1 | package service.models; 2 | 3 | public class Rating { 4 | Long id; 5 | User user; 6 | Movie product; 7 | Integer rating; 8 | Long timestamp; 9 | 10 | public Long getId() { 11 | return id; 12 | } 13 | 14 | public void setId(Long id) { 15 | this.id = id; 16 | } 17 | 18 | public User getUser() { 19 | return user; 20 | } 21 | 22 | public void setUser(User user) { 23 | this.user = user; 24 | } 25 | 26 | public Movie getProduct() { 27 | return product; 28 | } 29 | 30 | public void setProduct(Movie product) { 31 | this.product = product; 32 | } 33 | 34 | public Integer getRating() { 35 | return rating; 36 | } 37 | 38 | public void setRating(Integer rating) { 39 | this.rating = rating; 40 | } 41 | 42 | public Long getTimestamp() { 43 | return timestamp; 44 | } 45 | 46 | public void setTimestamp(Long timestamp) { 47 | this.timestamp = timestamp; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ui-search/src/main/java/service/models/User.java: -------------------------------------------------------------------------------- 1 | package service.models; 2 | 3 | public class User { 4 | Long id; 5 | String age; 6 | String gender; 7 | String occupation; 8 | String zipcode; 9 | 10 | public Long getId() { 11 | return id; 12 | } 13 | 14 | public void setId(Long id) { 15 | this.id = id; 16 | } 17 | 18 | public String getAge() { 19 | return age; 20 | } 21 | 22 | public void setAge(String age) { 23 | this.age = age; 24 | } 25 | 26 | public String getGender() { 27 | return gender; 28 | } 29 | 30 | public void setGender(String gender) { 31 | this.gender = gender; 32 | } 33 | 34 | public String getOccupation() { 35 | return occupation; 36 | } 37 | 38 | public void setOccupation(String occupation) { 39 | this.occupation = occupation; 40 | } 41 | 42 | public String getZipcode() { 43 | return zipcode; 44 | } 45 | 46 | public void setZipcode(String zipcode) { 47 | this.zipcode = zipcode; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ui-search/src/main/java/service/models/Movie.java: -------------------------------------------------------------------------------- 1 | package service.models; 2 | 3 | public class Movie { 4 | private Long id; 5 | private String title; 6 | private String url; 7 | private Genre[] genres; 8 | private String knownId; 9 | 10 | public Long getId() { 11 | return id; 12 | } 13 | 14 | public void setId(Long id) { 15 | this.id = id; 16 | } 17 | 18 | public String getTitle() { 19 | return title; 20 | } 21 | 22 | public void setTitle(String title) { 23 | this.title = title; 24 | } 25 | 26 | public String getUrl() { 27 | return url; 28 | } 29 | 30 | public void setUrl(String url) { 31 | this.url = url; 32 | } 33 | 34 | public Genre[] getGenres() { 35 | return genres; 36 | } 37 | 38 | public void setGenres(Genre[] genres) { 39 | this.genres = genres; 40 | } 41 | 42 | public String getKnownId() { 43 | return knownId; 44 | } 45 | 46 | public void setKnownId(String knownId) { 47 | this.knownId = knownId; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ui-search/src/main/java/service/clients/UserClient.java: -------------------------------------------------------------------------------- 1 | package service.clients; 2 | 3 | import service.models.User; 4 | import org.springframework.cloud.netflix.feign.FeignClient; 5 | import org.springframework.hateoas.PagedResources; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RequestBody; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | 12 | import java.util.List; 13 | 14 | @FeignClient("user") 15 | public interface UserClient { 16 | @RequestMapping(method = RequestMethod.GET, value = "/users") 17 | PagedResources findAll(); 18 | 19 | @RequestMapping(method = RequestMethod.GET, value = "/users/{id}") 20 | List findById(@PathVariable("id") String id); 21 | 22 | @RequestMapping(method = RequestMethod.POST, value = "/users", 23 | consumes = MediaType.APPLICATION_JSON_VALUE, 24 | produces = MediaType.APPLICATION_JSON_VALUE) 25 | void createUser(@RequestBody User user); 26 | } 27 | -------------------------------------------------------------------------------- /rating-microservice/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: docker 4 | --- 5 | spring: 6 | profiles: cloud 7 | cloud: 8 | config: 9 | enabled: true 10 | server: 11 | port: 9004 12 | neo4j: 13 | uri: http://ec2-52-10-122-143.us-west-2.compute.amazonaws.com:7474/db/data/ 14 | username: neo4j 15 | password: graphdb 16 | bootstrap: false 17 | aws: 18 | s3: 19 | url: https://s3.amazonaws.com/dataset-demos 20 | eureka: 21 | client: 22 | serviceUrl: 23 | defaultZone: http://discovery-77.cfapps.io/eureka/ 24 | instance: 25 | hostname: rating-77.cfapps.io 26 | nonSecurePort: 80 27 | ribbon: 28 | eureka: 29 | enabled: true 30 | --- 31 | spring: 32 | profiles: docker 33 | server: 34 | port: 9004 35 | neo4j: 36 | uri: http://localhost:7474/db/data/ 37 | username: neo4j 38 | password: graphdb 39 | bootstrap: true 40 | aws: 41 | s3: 42 | url: https://s3.amazonaws.com/dataset-demos 43 | eureka: 44 | client: 45 | serviceUrl: 46 | defaultZone: http://discovery:8761/eureka/ 47 | instance: 48 | preferIpAddress: true 49 | ribbon: 50 | eureka: 51 | enabled: true -------------------------------------------------------------------------------- /movie-microservice/src/main/java/service/Application.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; 9 | import org.springframework.hateoas.hal.Jackson2HalModule; 10 | import service.data.domain.Movie; 11 | 12 | import javax.annotation.PostConstruct; 13 | 14 | @SpringBootApplication 15 | @ComponentScan(basePackages = { "service.config", "service.data" }) 16 | @EnableZuulProxy 17 | public class Application { 18 | 19 | public static void main(String[] args) { 20 | SpringApplication.run(Application.class, args); 21 | } 22 | 23 | @Autowired 24 | private RepositoryRestMvcConfiguration repositoryRestConfiguration; 25 | 26 | @PostConstruct 27 | public void postConstructConfiguration() { 28 | repositoryRestConfiguration.config().exposeIdsFor(Movie.class); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /user-microservice/src/main/java/service/data/repositories/UserRepository.java: -------------------------------------------------------------------------------- 1 | package service.data.repositories; 2 | 3 | import service.data.domain.entity.User; 4 | import org.springframework.cache.annotation.CacheEvict; 5 | import org.springframework.cache.annotation.Cacheable; 6 | import org.springframework.data.neo4j.repository.GraphRepository; 7 | import org.springframework.data.repository.query.Param; 8 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 9 | 10 | import java.util.List; 11 | 12 | @RepositoryRestResource(collectionResourceRel = "users", path = "users") 13 | public interface UserRepository extends GraphRepository { 14 | 15 | @Override 16 | @CacheEvict(value = "cache", key = "#p0.id") 17 | U save(U entity); 18 | 19 | @Override 20 | @CacheEvict(value = "cache", key = "#p0", beforeInvocation = true) 21 | void delete(Long aLong); 22 | 23 | @Override 24 | @CacheEvict(value = "cache", key = "#p0.id", beforeInvocation = true) 25 | void delete(User entity); 26 | 27 | @Override 28 | @Cacheable(value = "cache", key = "#p0") 29 | User findOne(Long aLong); 30 | 31 | List findByZipcode(@Param("4") String zipcode); 32 | } 33 | -------------------------------------------------------------------------------- /rating-microservice/src/main/java/service/data/repositories/RatingRepository.java: -------------------------------------------------------------------------------- 1 | package service.data.repositories; 2 | 3 | import service.data.domain.rels.Rating; 4 | import org.springframework.data.domain.Page; 5 | import org.springframework.data.domain.Pageable; 6 | import org.springframework.data.neo4j.annotation.Query; 7 | import org.springframework.data.repository.PagingAndSortingRepository; 8 | import org.springframework.data.repository.query.Param; 9 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 10 | import org.springframework.data.rest.core.annotation.RestResource; 11 | 12 | @RepositoryRestResource(collectionResourceRel = "ratings", path = "ratings") 13 | public interface RatingRepository extends 14 | PagingAndSortingRepository { 15 | @Query(value = "MATCH (n:User)-[r:Rating]->() RETURN r") 16 | Page findAll(Pageable pageable); 17 | 18 | @Query(value = "MATCH (n:User)-[r:Rating]->() WHERE n.knownId = {id} RETURN r") 19 | Page findByUserId(@Param(value = "id") String id, Pageable pageable); 20 | 21 | @Query(value = "MATCH (n:User)-[r:Rating]->() WHERE n.knownId = {id} RETURN avg(toFloat(r.rating))") 22 | Double getAverageRating(@Param(value = "id") String id); 23 | } 24 | -------------------------------------------------------------------------------- /manifest.yml: -------------------------------------------------------------------------------- 1 | --- 2 | applications: 3 | - name: config 4 | memory: 512M 5 | instances: 1 6 | host: config-99 7 | domain: cfapps.io 8 | path: ./config-microservice/target/config-microservice-0.1.0.jar 9 | - name: discovery 10 | memory: 512M 11 | instances: 1 12 | host: discovery-77 13 | domain: cfapps.io 14 | path: ./discovery-microservice/target/discovery-microservice-0.1.0.jar 15 | - name: gateway 16 | memory: 512M 17 | instances: 1 18 | host: gateway-77 19 | domain: cfapps.io 20 | path: ./api-gateway-microservice/target/api-gateway-microservice-0.1.0.jar 21 | - name: movie 22 | memory: 1G 23 | instances: 1 24 | timeout: 180 25 | host: movie-77 26 | domain: cfapps.io 27 | path: ./movie-microservice/target/movie-microservice-0.1.0.jar 28 | services: 29 | - mysql 30 | - name: rating 31 | memory: 1G 32 | instances: 1 33 | host: rating-77 34 | domain: cfapps.io 35 | path: ./rating-microservice/target/rating-microservice-0.1.0.jar 36 | - name: user 37 | memory: 1G 38 | instances: 1 39 | host: user-77 40 | domain: cfapps.io 41 | path: ./user-microservice/target/user-microservice-0.1.0.jar 42 | - name: moviesui 43 | memory: 1G 44 | instances: 1 45 | timeout: 180 46 | host: movies-search-77 47 | domain: cfapps.io 48 | path: ./ui-search/target/ui-search-0.1.0.jar 49 | 50 | -------------------------------------------------------------------------------- /config-microservice/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: cloud 4 | --- 5 | spring: 6 | profiles: 7 | name: cloud 8 | cloud: 9 | config: 10 | discovery: 11 | enabled: true 12 | server: 13 | git: 14 | uri: https://github.com/kbastani/spring-boot-microservice-config 15 | health: 16 | repositories: 17 | movie: 18 | label: master 19 | profiles: cloud 20 | rating: 21 | label: master 22 | profiles: cloud 23 | server: 24 | port: 8888 25 | info: 26 | description: Config Server 27 | url: https://github.com/kbastani/spring-cloud-microservice-example 28 | --- 29 | spring: 30 | profiles: 31 | name: docker 32 | cloud: 33 | config: 34 | discovery: 35 | enabled: true 36 | server: 37 | git: 38 | uri: https://github.com/kbastani/spring-boot-microservice-config 39 | health: 40 | repositories: 41 | movie: 42 | label: master 43 | profiles: cloud 44 | rating: 45 | label: master 46 | profiles: cloud 47 | server: 48 | port: 8888 49 | info: 50 | description: Config Server 51 | url: https://github.com/kbastani/spring-cloud-microservice-example -------------------------------------------------------------------------------- /ui-search/src/main/java/service/clients/RatingClient.java: -------------------------------------------------------------------------------- 1 | package service.clients; 2 | 3 | import service.models.Movie; 4 | import org.springframework.cloud.netflix.feign.FeignClient; 5 | import org.springframework.hateoas.PagedResources; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.web.bind.annotation.PathVariable; 8 | import org.springframework.web.bind.annotation.RequestBody; 9 | import org.springframework.web.bind.annotation.RequestMapping; 10 | import org.springframework.web.bind.annotation.RequestMethod; 11 | import service.models.Product; 12 | 13 | import java.util.List; 14 | 15 | @FeignClient("rating") 16 | public interface RatingClient { 17 | @RequestMapping(method = RequestMethod.GET, value = "/ratings") 18 | PagedResources findAll(); 19 | 20 | @RequestMapping(method = RequestMethod.GET, value = "/products/search/findProductsByUser?id={id}") 21 | PagedResources findProductsByUser(@PathVariable("id") String id); 22 | 23 | @RequestMapping(method = RequestMethod.GET, value = "/movies/{id}") 24 | List findById(@PathVariable("id") String id); 25 | 26 | @RequestMapping(method = RequestMethod.POST, value = "/movies", 27 | consumes = MediaType.APPLICATION_JSON_VALUE, 28 | produces = MediaType.APPLICATION_JSON_VALUE) 29 | void createMovie(@RequestBody Movie movie); 30 | } 31 | -------------------------------------------------------------------------------- /rating-microservice/src/main/java/service/data/repositories/ProductRepository.java: -------------------------------------------------------------------------------- 1 | package service.data.repositories; 2 | 3 | import org.springframework.data.domain.Page; 4 | import org.springframework.data.domain.Pageable; 5 | import org.springframework.data.neo4j.annotation.Query; 6 | import org.springframework.data.repository.PagingAndSortingRepository; 7 | import org.springframework.data.repository.query.Param; 8 | import org.springframework.data.rest.core.annotation.RepositoryRestResource; 9 | import org.springframework.data.rest.core.annotation.RestResource; 10 | import service.data.domain.entity.Product; 11 | 12 | @RepositoryRestResource(collectionResourceRel = "products", path = "products") 13 | public interface ProductRepository extends PagingAndSortingRepository { 14 | 15 | @Override 16 | @Query("MATCH (p:Product) RETURN p") 17 | Page findAll(Pageable pageable); 18 | 19 | @Query(value = "MATCH ()-[r:Rating]->(p:Product) WHERE p.knownId = {id} RETURN avg(toFloat(r.rating))") 20 | Double getAverageRating(@Param(value = "id") String id); 21 | 22 | @Query(value = "MATCH (u:User)-[r:Rating]->(p:Product) WHERE u.knownId = {id} RETURN p") 23 | Page findProductsByUser(@Param(value = "id") String id, Pageable pageable); 24 | 25 | @Override 26 | @Query("MATCH (p:Product) WHERE id(p) = {id} RETURN p") 27 | Product findOne(@Param(value = "id") Long id); 28 | } 29 | -------------------------------------------------------------------------------- /rating-microservice/src/main/java/service/data/domain/entity/Product.java: -------------------------------------------------------------------------------- 1 | package service.data.domain.entity; 2 | 3 | import org.springframework.data.neo4j.annotation.GraphId; 4 | import org.springframework.data.neo4j.annotation.Indexed; 5 | import org.springframework.data.neo4j.annotation.NodeEntity; 6 | 7 | @NodeEntity 8 | public class Product { 9 | @GraphId 10 | private Long id; 11 | 12 | public Product() { 13 | } 14 | 15 | @Indexed 16 | private String knownId; 17 | 18 | public String getKnownId() { 19 | return knownId; 20 | } 21 | 22 | public void setKnownId(String knownId) { 23 | this.knownId = knownId; 24 | } 25 | 26 | public Long getId() { 27 | return id; 28 | } 29 | 30 | public void setId(Long id) { 31 | this.id = id; 32 | } 33 | 34 | @Override 35 | public boolean equals(Object o) { 36 | if (this == o) return true; 37 | if (o == null || getClass() != o.getClass()) return false; 38 | 39 | Product product = (Product) o; 40 | 41 | return !(id != null ? !id.equals(product.id) : product.id != null); 42 | 43 | } 44 | 45 | @Override 46 | public int hashCode() { 47 | return id != null ? id.hashCode() : 0; 48 | } 49 | 50 | @Override 51 | public String toString() { 52 | return "Product{" + 53 | "id=" + id + 54 | '}'; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /rating-microservice/src/main/java/service/data/domain/entity/User.java: -------------------------------------------------------------------------------- 1 | package service.data.domain.entity; 2 | 3 | import org.springframework.data.neo4j.annotation.GraphId; 4 | import org.springframework.data.neo4j.annotation.Indexed; 5 | import org.springframework.data.neo4j.annotation.NodeEntity; 6 | 7 | @NodeEntity 8 | public class User { 9 | @GraphId 10 | private Long id; 11 | 12 | public User() { 13 | } 14 | 15 | public Long getId() { 16 | return id; 17 | } 18 | 19 | public void setId(Long id) { 20 | this.id = id; 21 | } 22 | 23 | @Indexed 24 | private String knownId; 25 | 26 | public String getKnownId() { 27 | return knownId; 28 | } 29 | 30 | public void setKnownId(String knownId) { 31 | this.knownId = knownId; 32 | } 33 | 34 | @Override 35 | public boolean equals(Object o) { 36 | if (this == o) return true; 37 | if (o == null || getClass() != o.getClass()) return false; 38 | 39 | User user = (User) o; 40 | 41 | if (id != null ? !id.equals(user.id) : user.id != null) return false; 42 | 43 | return true; 44 | } 45 | 46 | @Override 47 | public int hashCode() { 48 | return id != null ? id.hashCode() : 0; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "User{" + 54 | "id=" + id + 55 | '}'; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ui-search/src/main/java/service/clients/MovieClient.java: -------------------------------------------------------------------------------- 1 | package service.clients; 2 | 3 | import service.models.Movie; 4 | import org.springframework.cloud.netflix.feign.FeignClient; 5 | import org.springframework.hateoas.PagedResources; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.web.bind.annotation.*; 8 | 9 | import java.util.List; 10 | 11 | @FeignClient("movie") 12 | public interface MovieClient { 13 | @RequestMapping( 14 | method = RequestMethod.GET, 15 | value = "/movies") 16 | PagedResources findAll(); 17 | 18 | @RequestMapping( 19 | method = RequestMethod.GET, 20 | value = "/movies/search/findByTitleContainingIgnoreCase?title={title}") 21 | PagedResources findByTitleContainingIgnoreCase(@PathVariable("title") String title); 22 | 23 | @RequestMapping( 24 | method = RequestMethod.GET, 25 | value = "/movies/{id}") 26 | List findById(@PathVariable("id") String id); 27 | 28 | @RequestMapping(method = RequestMethod.GET, 29 | value = "/movies/search/findByIdIn?ids={ids}") 30 | PagedResources findByIds(@PathVariable("ids") String ids); 31 | 32 | @RequestMapping(method = RequestMethod.POST, value = "/movies", 33 | consumes = MediaType.APPLICATION_JSON_VALUE, 34 | produces = MediaType.APPLICATION_JSON_VALUE) 35 | void createMovie(@RequestBody Movie movie); 36 | } 37 | -------------------------------------------------------------------------------- /docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | config: 3 | image: kbastani/config-microservice 4 | hostname: configServer 5 | links: 6 | - discovery 7 | ports: 8 | - "8888:8888" 9 | environment: 10 | - SPRING_PROFILES_ACTIVE=docker 11 | discovery: 12 | image: kbastani/discovery-microservice 13 | hostname: discovery 14 | ports: 15 | - "8761:8761" 16 | environment: 17 | - SPRING_PROFILES_ACTIVE=docker 18 | gateway: 19 | image: kbastani/api-gateway-microservice 20 | hostname: gateway 21 | links: 22 | - discovery 23 | - config 24 | - user 25 | - rating 26 | - movie 27 | ports: 28 | - "10000:10000" 29 | environment: 30 | - SPRING_PROFILES_ACTIVE=docker 31 | movie: 32 | hostname: movie 33 | image: kbastani/movie-microservice 34 | links: 35 | - discovery 36 | - config 37 | ports: 38 | - "9006:9006" 39 | environment: 40 | - SPRING_PROFILES_ACTIVE=docker 41 | moviesui: 42 | image: kbastani/ui-search 43 | links: 44 | - discovery 45 | - config 46 | ports: 47 | - "1111:1111" 48 | environment: 49 | - SPRING_PROFILES_ACTIVE=docker 50 | rating: 51 | hostname: rating 52 | image: kbastani/rating-microservice 53 | links: 54 | - discovery 55 | - config 56 | ports: 57 | - "9004:9004" 58 | environment: 59 | - SPRING_PROFILES_ACTIVE=docker 60 | user: 61 | hostname: user 62 | image: kbastani/user-microservice 63 | links: 64 | - discovery 65 | - config 66 | environment: 67 | - SPRING_PROFILES_ACTIVE=docker -------------------------------------------------------------------------------- /config-microservice/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | profiles: 3 | active: cloud 4 | --- 5 | spring: 6 | profiles: cloud 7 | application: 8 | name: configServer 9 | cloud: 10 | config: 11 | server: 12 | git: 13 | uri: https://github.com/kbastani/spring-boot-microservice-config 14 | encrypt: 15 | failOnError: false 16 | eureka: 17 | instance: 18 | statusPageUrlPath: ${management.context-path}/info 19 | healthCheckUrlPath: ${management.context-path}/health 20 | hostname: config-99.cfapps.io 21 | nonSecurePort: 80 22 | metadataMap: 23 | instanceId: ${vcap.application.instance_id:${spring.application.name}:${spring.application.instance_id:${server.port}}} 24 | client: 25 | registerWithEureka: true 26 | fetchRegistry: true 27 | serviceUrl: 28 | defaultZone: http://discovery-77.cfapps.io/eureka/ 29 | info: 30 | description: Config Server 31 | url: https://github.com/kbastani/spring-cloud-microservice-example 32 | --- 33 | spring: 34 | profiles: docker 35 | application: 36 | name: configServer 37 | cloud: 38 | config: 39 | server: 40 | git: 41 | uri: https://github.com/kbastani/spring-boot-microservice-config 42 | encrypt: 43 | failOnError: false 44 | eureka: 45 | instance: 46 | statusPageUrlPath: ${management.context-path}/info 47 | healthCheckUrlPath: ${management.context-path}/health 48 | hostname: configServer 49 | preferIpAddress: true 50 | defaultZone: http://192.168.59.103:8761/eureka/ 51 | client: 52 | registerWithEureka: true 53 | fetchRegistry: true 54 | serviceUrl: 55 | defaultZone: http://192.168.59.103:8761/eureka/ 56 | info: 57 | description: Config Server 58 | url: https://github.com/kbastani/spring-cloud-microservice-example -------------------------------------------------------------------------------- /movie-microservice/src/main/java/service/config/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package service.config; 2 | 3 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 7 | import org.springframework.orm.jpa.JpaTransactionManager; 8 | import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; 9 | import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; 10 | import org.springframework.transaction.PlatformTransactionManager; 11 | import org.springframework.transaction.annotation.EnableTransactionManagement; 12 | 13 | import javax.persistence.EntityManagerFactory; 14 | import javax.sql.DataSource; 15 | 16 | @Configuration 17 | @EnableJpaRepositories(basePackages = "service.data.repositories") 18 | @EnableTransactionManagement 19 | @EnableConfigurationProperties 20 | public class ApplicationConfig { 21 | 22 | @Bean 23 | public EntityManagerFactory entityManagerFactory(DataSource dataSource) { 24 | HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); 25 | vendorAdapter.setGenerateDdl(true); 26 | 27 | LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean(); 28 | factory.setJpaVendorAdapter(vendorAdapter); 29 | factory.setPackagesToScan("service.data.domain"); 30 | factory.setDataSource(dataSource); 31 | factory.afterPropertiesSet(); 32 | 33 | return factory.getObject(); 34 | } 35 | 36 | @Bean 37 | public PlatformTransactionManager transactionManager(DataSource dataSource) { 38 | JpaTransactionManager txManager = new JpaTransactionManager(); 39 | txManager.setEntityManagerFactory(entityManagerFactory(dataSource)); 40 | return txManager; 41 | } 42 | } -------------------------------------------------------------------------------- /movie-microservice/src/main/java/service/data/domain/Movie.java: -------------------------------------------------------------------------------- 1 | package service.data.domain; 2 | 3 | import org.springframework.data.rest.core.annotation.RestResource; 4 | 5 | import javax.persistence.*; 6 | import java.io.Serializable; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | @Entity 11 | @Table(name = "movie") 12 | public class Movie implements Serializable { 13 | 14 | private static final long serialVersionUID = -2952735933715107252L; 15 | 16 | @Id 17 | @Column(name = "id") 18 | @GeneratedValue 19 | Long id; 20 | 21 | @Column 22 | String title; 23 | 24 | @Column 25 | Long released; 26 | 27 | @Column 28 | String url; 29 | 30 | @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) 31 | @JoinTable(name = "movie_genre", 32 | inverseJoinColumns = { 33 | @JoinColumn 34 | (name = "genres_id", referencedColumnName = "id") 35 | }, 36 | joinColumns = { 37 | @JoinColumn 38 | (name = "movies_id", referencedColumnName = "id") 39 | }) 40 | @RestResource(exported = true) 41 | List genres = new ArrayList(); 42 | 43 | public Movie() { 44 | this(null); 45 | } 46 | 47 | public Movie(Long id) { 48 | this.setId(id); 49 | } 50 | 51 | public Long getId() { 52 | return id; 53 | } 54 | 55 | public void setId(Long id) { 56 | this.id = id; 57 | } 58 | 59 | public String getTitle() { 60 | return title; 61 | } 62 | 63 | public void setTitle(String title) { 64 | this.title = title; 65 | } 66 | 67 | public Long getReleased() { 68 | return released; 69 | } 70 | 71 | public void setReleased(Long released) { 72 | this.released = released; 73 | } 74 | 75 | public String getUrl() { 76 | return url; 77 | } 78 | 79 | public void setUrl(String url) { 80 | this.url = url; 81 | } 82 | 83 | public List getGenres() { 84 | 85 | return genres; 86 | } 87 | 88 | public void setGenres(List genres) { 89 | this.genres = genres; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /user-microservice/src/main/java/service/data/config/CouchbaseConfiguration.java: -------------------------------------------------------------------------------- 1 | package data.config; 2 | 3 | import com.couchbase.client.CouchbaseClient; 4 | import net.spy.memcached.FailureMode; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.data.couchbase.cache.CouchbaseCacheManager; 8 | import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration; 9 | import org.springframework.data.couchbase.core.CouchbaseFactoryBean; 10 | 11 | import java.util.Arrays; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | 15 | /** 16 | * Created by kennybastani on 7/31/15. 17 | */ 18 | public class CouchbaseConfiguration extends AbstractCouchbaseConfiguration { 19 | @Value("${couchbase.cluster.bucket:default}") 20 | private String bucketName; 21 | 22 | @Value("${couchbase.cluster.password:}") 23 | private String password; 24 | 25 | @Value("${couchbase.cluster.ip:couchbase}") 26 | private String ip; 27 | 28 | @Value("${couchbase.cluster.ttl:90}") 29 | private Integer timeout; 30 | 31 | @Override 32 | protected List bootstrapHosts() { 33 | return Arrays.asList(ip); 34 | } 35 | 36 | @Override 37 | protected String getBucketName() { 38 | return "default"; 39 | } 40 | 41 | @Override 42 | protected String getBucketPassword() { 43 | return password; 44 | } 45 | 46 | @Bean(name = "couchbaseCacheManager") 47 | public CouchbaseCacheManager couchbaseCacheManager() { 48 | HashMap instances = new HashMap<>(); 49 | 50 | try { 51 | instances.put("cache", couchbaseFactoryBean().getObject()); 52 | } catch (Exception e) { 53 | e.printStackTrace(); 54 | } 55 | 56 | HashMap ttl = new HashMap<>(); 57 | ttl.put("cache", timeout); 58 | 59 | return new CouchbaseCacheManager(instances, ttl); 60 | } 61 | 62 | @Bean 63 | public CouchbaseFactoryBean couchbaseFactoryBean() { 64 | CouchbaseFactoryBean couchbaseFactoryBean = new CouchbaseFactoryBean(); 65 | couchbaseFactoryBean.setOpTimeout(timeout); 66 | couchbaseFactoryBean.setBucket(bucketName); 67 | couchbaseFactoryBean.setPassword(password); 68 | 69 | couchbaseFactoryBean.setHost(ip); 70 | couchbaseFactoryBean.setFailureMode(String.valueOf(FailureMode.Cancel)); 71 | 72 | return couchbaseFactoryBean; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /ui-search/src/main/java/service/Application.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import com.fasterxml.jackson.databind.DeserializationFeature; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import com.vaadin.spring.annotation.EnableVaadin; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.boot.context.web.SpringBootServletInitializer; 10 | import org.springframework.cloud.netflix.feign.EnableFeignClients; 11 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 12 | import org.springframework.context.annotation.Bean; 13 | import org.springframework.hateoas.hal.Jackson2HalModule; 14 | import org.springframework.http.HttpStatus; 15 | import org.springframework.http.MediaType; 16 | import org.springframework.http.ResponseEntity; 17 | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; 18 | import org.springframework.stereotype.Controller; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.servlet.config.annotation.EnableWebMvc; 21 | 22 | import javax.servlet.http.HttpServletResponse; 23 | import java.io.IOException; 24 | 25 | @SpringBootApplication 26 | @EnableFeignClients(basePackages = "service.clients") 27 | @EnableWebMvc 28 | @EnableAutoConfiguration 29 | @EnableZuulProxy 30 | @EnableVaadin 31 | @Controller 32 | public class Application extends SpringBootServletInitializer { 33 | 34 | public static void main(String[] args) { 35 | SpringApplication.run(Application.class, args); 36 | } 37 | 38 | @Bean 39 | public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { 40 | MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter(); 41 | jsonConverter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json")); 42 | ObjectMapper objectMapper = new ObjectMapper(); 43 | objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); 44 | objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); 45 | objectMapper.registerModule(new Jackson2HalModule()); 46 | jsonConverter.setObjectMapper(objectMapper); 47 | return jsonConverter; 48 | } 49 | 50 | @RequestMapping("/") 51 | public ResponseEntity home(HttpServletResponse response) throws IOException { 52 | response.sendRedirect("/movies"); 53 | return new ResponseEntity(HttpStatus.PERMANENT_REDIRECT); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /user-microservice/src/main/java/service/Application.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import org.neo4j.graphdb.GraphDatabaseService; 4 | import org.neo4j.graphdb.factory.GraphDatabaseFactory; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.boot.CommandLineRunner; 7 | import org.springframework.boot.SpringApplication; 8 | import org.springframework.boot.autoconfigure.SpringBootApplication; 9 | import org.springframework.cloud.netflix.hystrix.EnableHystrix; 10 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 11 | import org.springframework.context.ConfigurableApplicationContext; 12 | import org.springframework.context.annotation.Bean; 13 | import org.springframework.data.neo4j.config.EnableNeo4jRepositories; 14 | import org.springframework.data.neo4j.config.Neo4jConfiguration; 15 | import org.springframework.data.rest.core.config.RepositoryRestConfiguration; 16 | import org.springframework.hateoas.Link; 17 | import org.springframework.hateoas.Resource; 18 | import org.springframework.hateoas.ResourceProcessor; 19 | import service.data.domain.entity.User; 20 | 21 | @SpringBootApplication 22 | @EnableNeo4jRepositories 23 | @EnableZuulProxy 24 | @EnableHystrix 25 | public class Application extends Neo4jConfiguration { 26 | 27 | // Used to bootstrap the Neo4j database with demo data 28 | @Value("${aws.s3.url}") 29 | String datasetUrl; 30 | 31 | public Application() { 32 | setBasePackage("service"); 33 | } 34 | 35 | @Bean(destroyMethod = "shutdown") 36 | public GraphDatabaseService graphDatabaseService() { 37 | return new GraphDatabaseFactory().newEmbeddedDatabase("user.db"); 38 | } 39 | 40 | public static void main(String[] args) { 41 | ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args); 42 | 43 | RepositoryRestConfiguration restConfiguration = ctx.getBean("config", RepositoryRestConfiguration.class); 44 | restConfiguration.exposeIdsFor(User.class); 45 | } 46 | 47 | @Bean 48 | public CommandLineRunner commandLineRunner() { 49 | return strings -> { 50 | // Import graph data for users 51 | String userImport = String.format("LOAD CSV WITH HEADERS FROM \"%s/users.csv\" AS csvLine\n" + 52 | "MERGE (user:User:_User { id: csvLine.id, age: toInt(csvLine.age), gender: csvLine.gender, occupation: csvLine.occupation, zipcode: csvLine.zipcode })", datasetUrl); 53 | 54 | neo4jTemplate().query(userImport, null).finish(); 55 | }; 56 | } 57 | 58 | @Bean 59 | public ResourceProcessor> movieProcessor() { 60 | return new ResourceProcessor>() { 61 | @Override 62 | public Resource process(Resource resource) { 63 | 64 | resource.add(new Link("/movie/movies", "movies")); 65 | return resource; 66 | } 67 | }; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /user-microservice/src/main/java/service/data/domain/entity/User.java: -------------------------------------------------------------------------------- 1 | package service.data.domain.entity; 2 | 3 | import org.neo4j.graphdb.Direction; 4 | import org.springframework.data.neo4j.annotation.*; 5 | 6 | import java.io.Serializable; 7 | import java.util.Set; 8 | 9 | @NodeEntity 10 | public class User implements Serializable { 11 | 12 | private static final long serialVersionUID = -100759321281659379L; 13 | 14 | @GraphId 15 | Long id; 16 | 17 | private String age; 18 | private String gender; 19 | private String occupation; 20 | private String zipcode; 21 | 22 | public User() { } 23 | 24 | @Fetch 25 | @RelatedTo(type = "FOLLOWS", direction = Direction.OUTGOING, elementClass = User.class) 26 | Set follows; 27 | 28 | @Fetch 29 | @RelatedTo(type = "FOLLOWS", direction = Direction.INCOMING, elementClass = User.class) 30 | Set followers; 31 | 32 | public String getAge() { 33 | return age; 34 | } 35 | 36 | public void setAge(String age) { 37 | this.age = age; 38 | } 39 | 40 | public String getGender() { 41 | return gender; 42 | } 43 | 44 | public void setGender(String gender) { 45 | this.gender = gender; 46 | } 47 | 48 | public String getOccupation() { 49 | return occupation; 50 | } 51 | 52 | public void setOccupation(String occupation) { 53 | this.occupation = occupation; 54 | } 55 | 56 | public String getZipcode() { 57 | return zipcode; 58 | } 59 | 60 | public void setZipcode(String zipcode) { 61 | this.zipcode = zipcode; 62 | } 63 | 64 | public Long getId() { 65 | return id; 66 | } 67 | 68 | @Override 69 | public boolean equals(Object o) { 70 | if (this == o) return true; 71 | if (o == null || getClass() != o.getClass()) return false; 72 | 73 | User user = (User) o; 74 | 75 | if (id != null ? !id.equals(user.id) : user.id != null) return false; 76 | if (age != null ? !age.equals(user.age) : user.age != null) return false; 77 | if (gender != null ? !gender.equals(user.gender) : user.gender != null) return false; 78 | if (occupation != null ? !occupation.equals(user.occupation) : user.occupation != null) return false; 79 | if (zipcode != null ? !zipcode.equals(user.zipcode) : user.zipcode != null) return false; 80 | if (follows != null ? !follows.equals(user.follows) : user.follows != null) return false; 81 | return !(followers != null ? !followers.equals(user.followers) : user.followers != null); 82 | 83 | } 84 | 85 | @Override 86 | public int hashCode() { 87 | int result = id != null ? id.hashCode() : 0; 88 | result = 31 * result + (age != null ? age.hashCode() : 0); 89 | result = 31 * result + (gender != null ? gender.hashCode() : 0); 90 | result = 31 * result + (occupation != null ? occupation.hashCode() : 0); 91 | result = 31 * result + (zipcode != null ? zipcode.hashCode() : 0); 92 | result = 31 * result + (follows != null ? follows.hashCode() : 0); 93 | result = 31 * result + (followers != null ? followers.hashCode() : 0); 94 | return result; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /rating-microservice/src/main/java/service/data/domain/rels/Rating.java: -------------------------------------------------------------------------------- 1 | package service.data.domain.rels; 2 | 3 | import service.data.domain.entity.User; 4 | import service.data.domain.entity.Product; 5 | import org.springframework.data.neo4j.annotation.*; 6 | 7 | @RelationshipEntity(type = "Rating") 8 | public class Rating { 9 | @GraphId 10 | Long id; 11 | 12 | @StartNode 13 | private User user; 14 | 15 | @EndNode 16 | private Product product; 17 | 18 | @Indexed 19 | String knownId; 20 | 21 | Long timestamp; 22 | Integer rating; 23 | 24 | public Rating() { 25 | } 26 | 27 | public Long getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Long id) { 32 | this.id = id; 33 | } 34 | 35 | public User getUser() { 36 | return user; 37 | } 38 | 39 | public void setUser(User user) { 40 | this.user = user; 41 | } 42 | 43 | public Product getProduct() { 44 | return product; 45 | } 46 | 47 | public void setProduct(Product product) { 48 | this.product = product; 49 | } 50 | 51 | public Long getTimestamp() { 52 | return timestamp; 53 | } 54 | 55 | public void setTimestamp(Long timestamp) { 56 | this.timestamp = timestamp; 57 | } 58 | 59 | public Integer getRating() { 60 | return rating; 61 | } 62 | 63 | public void setRating(Integer rating) { 64 | this.rating = rating; 65 | } 66 | 67 | @Override 68 | public boolean equals(Object o) { 69 | if (this == o) return true; 70 | if (o == null || getClass() != o.getClass()) return false; 71 | 72 | Rating rating1 = (Rating) o; 73 | 74 | if (id != null ? !id.equals(rating1.id) : rating1.id != null) return false; 75 | if (user != null ? !user.equals(rating1.user) : rating1.user != null) return false; 76 | if (product != null ? !product.equals(rating1.product) : rating1.product != null) return false; 77 | if (knownId != null ? !knownId.equals(rating1.knownId) : rating1.knownId != null) return false; 78 | if (timestamp != null ? !timestamp.equals(rating1.timestamp) : rating1.timestamp != null) return false; 79 | return !(rating != null ? !rating.equals(rating1.rating) : rating1.rating != null); 80 | 81 | } 82 | 83 | @Override 84 | public int hashCode() { 85 | int result = id != null ? id.hashCode() : 0; 86 | result = 31 * result + (user != null ? user.hashCode() : 0); 87 | result = 31 * result + (product != null ? product.hashCode() : 0); 88 | result = 31 * result + (knownId != null ? knownId.hashCode() : 0); 89 | result = 31 * result + (timestamp != null ? timestamp.hashCode() : 0); 90 | result = 31 * result + (rating != null ? rating.hashCode() : 0); 91 | return result; 92 | } 93 | 94 | @Override 95 | public String toString() { 96 | return "Rating{" + 97 | "id=" + id + 98 | ", user=" + user + 99 | ", product=" + product + 100 | ", knownId='" + knownId + '\'' + 101 | ", timestamp=" + timestamp + 102 | ", rating=" + rating + 103 | '}'; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /discovery-microservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | discovery-microservice 7 | 0.1.0 8 | jar 9 | 10 | 11 | org.kbastani 12 | spring-cloud-microservice-example-parent 13 | 0.1.0-SNAPSHOT 14 | 15 | 16 | 17 | kbastani 18 | 19 | 20 | 21 | 22 | org.springframework.cloud 23 | spring-cloud-starter-eureka-server 24 | 25 | 26 | org.springframework.cloud 27 | spring-cloud-config-server 28 | 29 | 30 | org.springframework.cloud 31 | spring-cloud-starter-eureka 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-data-rest 36 | 37 | 38 | org.projectlombok 39 | lombok 40 | 41 | 42 | 43 | 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-maven-plugin 48 | 49 | 50 | 51 | repackage 52 | 53 | 54 | 55 | 56 | 57 | com.spotify 58 | docker-maven-plugin 59 | 0.2.3 60 | 61 | 62 | package 63 | 64 | build 65 | 66 | 67 | 68 | 69 | ${docker.image.prefix}/${project.artifactId} 70 | ${project.basedir}/src/main/docker 71 | 72 | 73 | / 74 | ${project.build.directory} 75 | ${project.build.finalName}.jar 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /rating-microservice/src/main/java/service/config/GraphDatabaseConfiguration.java: -------------------------------------------------------------------------------- 1 | package service.config; 2 | 3 | import org.neo4j.graphdb.GraphDatabaseService; 4 | import org.neo4j.graphdb.factory.GraphDatabaseFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.boot.context.properties.ConfigurationProperties; 8 | import org.springframework.boot.context.properties.EnableConfigurationProperties; 9 | import org.springframework.boot.env.YamlPropertySourceLoader; 10 | import org.springframework.context.annotation.AdviceMode; 11 | import org.springframework.context.annotation.Bean; 12 | import org.springframework.context.annotation.Configuration; 13 | import org.springframework.core.env.Environment; 14 | import org.springframework.data.neo4j.config.EnableNeo4jRepositories; 15 | import org.springframework.data.neo4j.config.Neo4jConfiguration; 16 | import org.springframework.data.neo4j.rest.SpringCypherRestGraphDatabase; 17 | import org.springframework.transaction.annotation.EnableTransactionManagement; 18 | 19 | import java.util.Arrays; 20 | 21 | /** 22 | * @author Kenny Bastani 23 | * 24 | * Manages the configuration for a Neo4j graph database server 25 | */ 26 | @EnableNeo4jRepositories(basePackages = "service.data") 27 | @EnableTransactionManagement(mode = AdviceMode.PROXY) 28 | @EnableConfigurationProperties 29 | @Configuration 30 | @ConfigurationProperties 31 | public class GraphDatabaseConfiguration extends Neo4jConfiguration { 32 | 33 | @Value("${neo4j.uri}") 34 | private String url; 35 | 36 | @Value("${neo4j.username}") 37 | private String username; 38 | 39 | @Value("${neo4j.password}") 40 | private String password; 41 | 42 | @Autowired 43 | Environment environment; 44 | 45 | public GraphDatabaseConfiguration() { 46 | super(); 47 | setBasePackage("service.data", "service.config"); 48 | } 49 | 50 | public String getUrl() { 51 | return url; 52 | } 53 | 54 | public void setUrl(String url) { 55 | this.url = url; 56 | } 57 | 58 | public String getUsername() { 59 | return username; 60 | } 61 | 62 | public void setUsername(String username) { 63 | this.username = username; 64 | } 65 | 66 | public String getPassword() { 67 | return password; 68 | } 69 | 70 | public void setPassword(String password) { 71 | this.password = password; 72 | } 73 | 74 | @Autowired(required = true) 75 | @Override 76 | public void setGraphDatabaseService(GraphDatabaseService graphDatabaseService) { 77 | super.setGraphDatabaseService(graphDatabaseService); 78 | } 79 | 80 | @Bean 81 | public static YamlPropertySourceLoader yamlPropertySourceLoader() { 82 | return new YamlPropertySourceLoader(); 83 | } 84 | 85 | @Bean(destroyMethod = "shutdown") 86 | public GraphDatabaseService graphDatabaseService() { 87 | if(Arrays.asList(environment.getActiveProfiles()).contains("cloud")) { 88 | // Connect to external Neo4j server 89 | setGraphDatabaseService(new SpringCypherRestGraphDatabase(url, username, password)); 90 | } else { 91 | // Connect to local ephemeral database 92 | return new GraphDatabaseFactory().newEmbeddedDatabase("user.db"); 93 | } 94 | 95 | return getGraphDatabaseService(); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /config-microservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | config-microservice 8 | 0.1.0 9 | jar 10 | 11 | config-microservice 12 | 13 | 14 | org.kbastani 15 | spring-cloud-microservice-example-parent 16 | 0.1.0-SNAPSHOT 17 | 18 | 19 | 20 | kbastani 21 | 22 | 23 | 24 | 25 | org.springframework.cloud 26 | spring-cloud-starter 27 | 28 | 29 | org.springframework.cloud 30 | spring-cloud-starter-zuul 31 | 32 | 33 | org.springframework.cloud 34 | spring-cloud-config-server 35 | 36 | 37 | org.springframework.cloud 38 | spring-cloud-starter-eureka 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-starter-data-rest 43 | 44 | 45 | 46 | 47 | 48 | 49 | org.springframework.boot 50 | spring-boot-maven-plugin 51 | 52 | 53 | 54 | repackage 55 | 56 | 57 | 58 | 59 | 60 | com.spotify 61 | docker-maven-plugin 62 | 0.2.3 63 | 64 | 65 | package 66 | 67 | build 68 | 69 | 70 | 71 | 72 | ${docker.image.prefix}/${project.artifactId} 73 | ${project.basedir}/src/main/docker 74 | 75 | 76 | / 77 | ${project.build.directory} 78 | ${project.build.finalName}.jar 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /api-gateway-microservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | api-gateway-microservice 8 | 0.1.0 9 | jar 10 | 11 | 12 | org.kbastani 13 | spring-cloud-microservice-example-parent 14 | 0.1.0-SNAPSHOT 15 | 16 | 17 | 18 | kbastani 19 | 20 | 21 | 22 | 23 | org.springframework.cloud 24 | spring-cloud-starter-zuul 25 | 26 | 27 | org.springframework.cloud 28 | spring-cloud-starter-eureka 29 | 30 | 31 | org.springframework.cloud 32 | spring-cloud-netflix-sidecar 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-config-server 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-data-rest 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.springframework.boot 52 | spring-boot-maven-plugin 53 | 54 | 55 | 56 | repackage 57 | 58 | 59 | 60 | 61 | 62 | com.spotify 63 | docker-maven-plugin 64 | 0.2.3 65 | 66 | 67 | package 68 | 69 | build 70 | 71 | 72 | 73 | 74 | ${docker.image.prefix}/${project.artifactId} 75 | ${project.basedir}/src/main/docker 76 | 77 | 78 | / 79 | ${project.build.directory} 80 | ${project.build.finalName}.jar 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /user-microservice/src/main/java/service/data/config/CachingConfiguration.java: -------------------------------------------------------------------------------- 1 | package service.data.config; 2 | 3 | import com.google.common.collect.Lists; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Qualifier; 8 | import org.springframework.cache.Cache; 9 | import org.springframework.cache.CacheManager; 10 | import org.springframework.cache.annotation.CachingConfigurer; 11 | import org.springframework.cache.annotation.EnableCaching; 12 | import org.springframework.cache.concurrent.ConcurrentMapCache; 13 | import org.springframework.cache.interceptor.CacheErrorHandler; 14 | import org.springframework.cache.interceptor.CacheResolver; 15 | import org.springframework.cache.interceptor.KeyGenerator; 16 | import org.springframework.cache.interceptor.SimpleKeyGenerator; 17 | import org.springframework.cache.support.CompositeCacheManager; 18 | import org.springframework.cache.support.SimpleCacheManager; 19 | import org.springframework.context.annotation.Bean; 20 | import org.springframework.context.annotation.Configuration; 21 | 22 | import java.util.Collections; 23 | import java.util.List; 24 | 25 | @EnableCaching 26 | @Configuration 27 | public class CachingConfiguration implements CachingConfigurer { 28 | 29 | @Qualifier("couchbaseCacheManager") 30 | @Autowired(required = false) 31 | CacheManager couchbaseCacheManager; 32 | 33 | final Logger logger = LoggerFactory.getLogger(CachingConfigurer.class); 34 | 35 | @Bean 36 | @Override 37 | public CacheManager cacheManager() { 38 | CompositeCacheManager compositeCacheManager = new CompositeCacheManager(); 39 | 40 | List cacheManagers = Lists.newArrayList(); 41 | 42 | SimpleCacheManager simpleCacheManager = new SimpleCacheManager(); 43 | simpleCacheManager.setCaches(Collections.singletonList( 44 | new ConcurrentMapCache("cache") 45 | )); 46 | 47 | if (this.couchbaseCacheManager != null) { 48 | cacheManagers.add(this.couchbaseCacheManager); 49 | cacheManagers.add(simpleCacheManager); 50 | } 51 | 52 | compositeCacheManager.setCacheManagers(cacheManagers); 53 | compositeCacheManager.setFallbackToNoOpCache(true); 54 | 55 | return compositeCacheManager; 56 | } 57 | 58 | @Bean 59 | @Override 60 | public CacheResolver cacheResolver() { 61 | return null; 62 | } 63 | 64 | @Bean 65 | @Override 66 | public KeyGenerator keyGenerator() { 67 | return new SimpleKeyGenerator(); 68 | } 69 | 70 | @Bean 71 | @Override 72 | public CacheErrorHandler errorHandler() { 73 | return new CacheErrorHandler() { 74 | 75 | @Override 76 | public void handleCacheGetError(RuntimeException exception, Cache cache, Object key) { 77 | logger.warn(cache.getName(), exception); 78 | } 79 | 80 | @Override 81 | public void handleCachePutError(RuntimeException exception, Cache cache, Object key, Object value) { 82 | logger.warn(cache.getName(), exception); 83 | } 84 | 85 | @Override 86 | public void handleCacheEvictError(RuntimeException exception, Cache cache, Object key) { 87 | logger.warn(cache.getName(), exception); 88 | } 89 | 90 | @Override 91 | public void handleCacheClearError(RuntimeException exception, Cache cache) { 92 | logger.warn(cache.getName(), exception); 93 | } 94 | }; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.kbastani 7 | spring-cloud-microservice-example-parent 8 | 0.1.0-SNAPSHOT 9 | pom 10 | 11 | 12 | user-microservice 13 | discovery-microservice 14 | api-gateway-microservice 15 | config-microservice 16 | movie-microservice 17 | ui-search 18 | rating-microservice 19 | 20 | 21 | 22 | org.springframework.cloud 23 | spring-cloud-starter-parent 24 | Brixton.BUILD-SNAPSHOT 25 | 26 | 27 | 28 | 29 | UTF-8 30 | 1.8 31 | 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-actuator 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-starter-test 45 | test 46 | 47 | 48 | 49 | 50 | 51 | spring-snapshots 52 | Spring Snapshots 53 | http://repo.spring.io/libs-snapshot 54 | 55 | true 56 | 57 | 58 | 59 | spring-snapshots-continuous 60 | Spring Snapshots Continuous 61 | http://repo.spring.io/libs-snapshot-continuous-local 62 | 63 | true 64 | 65 | 66 | 67 | spring-milestones 68 | Spring Milestones 69 | http://repo.spring.io/libs-milestone-local 70 | 71 | false 72 | 73 | 74 | 75 | spring-releases 76 | Spring Releases 77 | http://repo.spring.io/libs-release-local 78 | 79 | false 80 | 81 | 82 | 83 | 84 | 85 | spring-snapshots 86 | Spring Snapshots 87 | http://repo.spring.io/libs-snapshot-local 88 | 89 | true 90 | 91 | 92 | 93 | spring-milestones 94 | Spring Milestones 95 | http://repo.spring.io/libs-milestone-local 96 | 97 | false 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /movie-microservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | movie-microservice 7 | 0.1.0 8 | jar 9 | 10 | 11 | org.kbastani 12 | spring-cloud-microservice-example-parent 13 | 0.1.0-SNAPSHOT 14 | 15 | 16 | 17 | kbastani 18 | 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-data-rest 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-data-jpa 32 | 33 | 34 | org.springframework.cloud 35 | spring-cloud-config-server 36 | 37 | 38 | org.springframework.cloud 39 | spring-cloud-starter-eureka 40 | 41 | 42 | org.springframework.cloud 43 | spring-cloud-starter-zuul 44 | 45 | 46 | org.projectlombok 47 | lombok 48 | 49 | 50 | mysql 51 | mysql-connector-java 52 | 53 | 54 | org.hsqldb 55 | hsqldb 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | org.springframework.boot 64 | spring-boot-maven-plugin 65 | 66 | 67 | 68 | repackage 69 | 70 | 71 | 72 | 73 | 74 | com.spotify 75 | docker-maven-plugin 76 | 0.2.3 77 | 78 | 79 | package 80 | 81 | build 82 | 83 | 84 | 85 | 86 | ${docker.image.prefix}/${project.artifactId} 87 | ${project.basedir}/src/main/docker 88 | 89 | 90 | / 91 | ${project.build.directory} 92 | ${project.build.finalName}.jar 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spring Cloud Polyglot Persistence Example Project 2 | 3 | An example project that demonstrates an end-to-end cloud-native application with multiple backing services using Spring Cloud. 4 | 5 | Demonstrated concepts: 6 | 7 | * Polyglot persistence 8 | * Service discovery 9 | * API gateway 10 | 11 | ## Docker 12 | 13 | Each service is built and composed using Docker. A docker compose file allows you to run this example locally on your machine. The recommended system memory for this example is about 5GB. 14 | 15 | ## Polyglot Persistence 16 | 17 | One of the core concepts of this example project is how polyglot persistence can be approached in practice. Microservices in the project use their own database, while integrating with the data from other services through REST or a message bus. 18 | 19 | * Neo4j (graph) 20 | * MySQL (relational) 21 | 22 | ## Movie Ratings 23 | 24 | This example project focuses on movies and ratings. Take a look at the companion blog post listed here: [Polyglot Persistence with Spring Cloud and Docker](http://www.kennybastani.com) 25 | 26 | ### Data Services 27 | 28 | ![http://i.imgur.com/aQYGZFy.png](http://i.imgur.com/aQYGZFy.png) 29 | 30 | ### Domain Data 31 | 32 | ![http://i.imgur.com/VlwSw2q.png](http://i.imgur.com/VlwSw2q.png) 33 | 34 | In the graph data model above we can see the common entities that we need to expose from our services. The nodes represent the domain entities within our movie application. 35 | 36 | * User 37 | * Movie 38 | * Genre 39 | 40 | The connections between these entities give us a good idea of our boundaries that we need to consider when designing our microservices. For instance, we may have a requirement to analyze the ratings data between movies and users to generate movie recommendations. 41 | 42 | For this example project we will use three data services: 43 | 44 | * Rating Service (Neo4j) 45 | * Movie Service (MySQL) 46 | * User Service (Neo4j) 47 | 48 | ## Microservice Architecture 49 | 50 | This example project demonstrates how to build a new cloud-native application using microservices. Since each microservice in the project is a module of a single parent project, developers have the advantage of being able to run and develop with each microservice running on their local machine. 51 | 52 | ## Service discovery 53 | 54 | This project contains two discovery services, one on Netflix Eureka, and the other uses Consul from Hashicorp. Having multiple discovery services provides the opportunity to use one (Consul) as a DNS provider for the cluster, and the other (Eureka) as a proxy-based API gateway. 55 | 56 | ## API Gateway 57 | 58 | Each microservice will coordinate with Eureka to retrieve API routes for the entire cluster. Using this strategy each microservice in a cluster can be load balanced and exposed through one API gateway. Each service will automatically discover and route API requests to the service that owns the route. This proxying technique is equally helpful when developing user interfaces, as the full API of the platform is available through its own host as a proxy. 59 | 60 | ## Run it on PivotalCF 61 | 62 | * Requirements: Maven 3, Java 8, Docker, Docker Compose 63 | 64 | * Download Docker if you haven’t already. Follow the instructions found [here] (https://docs.docker.com/installation/), to get Docker up and running on your development machine. You will also need to install [Docker Compose] (https://docs.docker.com/compose/), the installation guide can be found [here] (https://docs.docker.com/compose/install/) 65 | 66 | * Clone the repo: 67 | 68 | > $ git clone https://github.com/kbastani/spring-cloud-polyglot-persistence-example.git 69 | 70 | * Building the project: 71 | 72 | To build the project, from the terminal, run the following command at the root of the project. 73 | 74 | > $ mvn clean install (from project root dir) 75 | 76 | * Push to PivotalCF 77 | 78 | Edit manifest.yml to use your domain name instead of cfapps.io 79 | 80 | Make sure a MySQL service instance is present in the space you are pushing to, with name "mysql" 81 | 82 | > $ cf push (from the project root dir) 83 | 84 | That's it! 85 | 86 | 87 | # License 88 | 89 | This project is licensed under Apache License 2.0. 90 | -------------------------------------------------------------------------------- /rating-microservice/src/main/java/service/Application.java: -------------------------------------------------------------------------------- 1 | package service; 2 | 3 | import lombok.extern.slf4j.Slf4j; 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.boot.CommandLineRunner; 9 | import org.springframework.boot.SpringApplication; 10 | import org.springframework.boot.autoconfigure.SpringBootApplication; 11 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy; 12 | import org.springframework.context.annotation.Bean; 13 | import org.springframework.context.annotation.ComponentScan; 14 | import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; 15 | import org.springframework.hateoas.hal.Jackson2HalModule; 16 | import service.config.GraphDatabaseConfiguration; 17 | import service.data.domain.entity.Product; 18 | import service.data.domain.entity.User; 19 | import service.data.domain.rels.Rating; 20 | 21 | import javax.annotation.PostConstruct; 22 | 23 | @SpringBootApplication 24 | @ComponentScan({ "service.data", "service.config" }) 25 | @EnableZuulProxy 26 | @Slf4j 27 | public class Application { 28 | 29 | final Logger logger = LoggerFactory.getLogger(Application.class); 30 | 31 | @Autowired 32 | RepositoryRestMvcConfiguration restConfiguration; 33 | 34 | // Used to bootstrap the Neo4j database with demo data 35 | @Value("${aws.s3.url}") 36 | String datasetUrl; 37 | 38 | @Value("${neo4j.bootstrap}") 39 | Boolean bootstrap; 40 | 41 | public static void main(String[] args) { 42 | System.setProperty("org.neo4j.rest.read_timeout", "250"); 43 | SpringApplication.run(Application.class, args); 44 | } 45 | 46 | @PostConstruct 47 | public void postConstructConfiguration() { 48 | // Expose ids for the domain entities having repositories 49 | logger.info("Exposing IDs on repositories..."); 50 | restConfiguration.config().exposeIdsFor(User.class); 51 | restConfiguration.config().exposeIdsFor(Product.class); 52 | restConfiguration.config().exposeIdsFor(Rating.class); 53 | 54 | // Register the ObjectMapper module for properly rendering HATEOAS REST repositories 55 | logger.info("Registering Jackson2HalModule..."); 56 | restConfiguration.objectMapper().registerModule(new Jackson2HalModule()); 57 | } 58 | 59 | /** 60 | * Bootstrap the Neo4j database with demo dataset. This can run multiple times without 61 | * duplicating data. 62 | * 63 | * @param graphDatabaseConfiguration is the graph database configuration to communicate with the Neo4j server 64 | * @return a {@link CommandLineRunner} instance with the method delegate to execute 65 | */ 66 | @Bean 67 | public CommandLineRunner commandLineRunner(GraphDatabaseConfiguration graphDatabaseConfiguration) { 68 | return strings -> { 69 | if(bootstrap) { 70 | logger.info("Creating index on User(id) and Product(id)..."); 71 | graphDatabaseConfiguration.neo4jTemplate().query("CREATE INDEX ON :User(id)", null).finish(); 72 | graphDatabaseConfiguration.neo4jTemplate().query("CREATE INDEX ON :Product(id)", null).finish(); 73 | logger.info("Importing ratings data..."); 74 | 75 | // Import graph data for movie ratings 76 | String userImport = String.format("USING PERIODIC COMMIT 20000\n" + 77 | "LOAD CSV WITH HEADERS FROM \"%s/ratings.csv\" AS csvLine\n" + 78 | "MERGE (user:User:_User { id: toInt(csvLine.userId) })\n" + 79 | "ON CREATE SET user.__type__=\"User\", user.className=\"data.domain.nodes.User\", user.knownId = csvLine.userId\n" + 80 | "MERGE (product:Product:_Product { id: toInt(csvLine.movieId) })\n" + 81 | "ON CREATE SET product.__type__=\"Product\", product.className=\"data.domain.nodes.Product\", product.knownId = csvLine.movieId\n" + 82 | "MERGE (user)-[r:Rating]->(product)\n" + 83 | "ON CREATE SET r.timestamp = toInt(csvLine.timestamp), r.rating = toInt(csvLine.rating), r.knownId = csvLine.userId + \"_\" + csvLine.movieId, r.__type__ = \"Rating\", r.className = \"data.domain.rels.Rating\"", datasetUrl); 84 | 85 | graphDatabaseConfiguration.neo4jTemplate().query(userImport, null).finish(); 86 | logger.info("Import complete"); 87 | } 88 | }; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /user-microservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | user-microservice 6 | 0.1.0 7 | jar 8 | 9 | 10 | org.kbastani 11 | spring-cloud-microservice-example-parent 12 | 0.1.0-SNAPSHOT 13 | 14 | 15 | 16 | kbastani 17 | 18 | 19 | 20 | 21 | org.springframework.data 22 | spring-data-couchbase 23 | 24 | 25 | org.springframework.data 26 | spring-data-commons 27 | 28 | 29 | org.springframework 30 | spring-context-support 31 | 32 | 33 | org.springframework.data 34 | spring-data-rest-core 35 | 36 | 37 | org.springframework.data 38 | spring-data-rest-distribution 39 | 2.4.0.BUILD-SNAPSHOT 40 | pom 41 | 42 | 43 | org.springframework.data 44 | spring-data-rest-hal-browser 45 | 46 | 47 | org.springframework.data 48 | spring-data-rest-webmvc 49 | 50 | 51 | org.springframework.data 52 | spring-data-neo4j 53 | 54 | 55 | org.springframework.cloud 56 | spring-cloud-starter-zuul 57 | 58 | 59 | org.springframework.cloud 60 | spring-cloud-starter-eureka 61 | 62 | 63 | org.hibernate 64 | hibernate-validator 65 | 66 | 67 | joda-time 68 | joda-time 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-maven-plugin 78 | 79 | 80 | 81 | repackage 82 | 83 | 84 | 85 | 86 | 87 | com.spotify 88 | docker-maven-plugin 89 | 0.2.3 90 | 91 | 92 | package 93 | 94 | build 95 | 96 | 97 | 98 | 99 | ${docker.image.prefix}/${project.artifactId} 100 | ${project.basedir}/src/main/docker 101 | 102 | 103 | / 104 | ${project.build.directory} 105 | ${project.build.finalName}.jar 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /ui-search/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | ui-search 6 | 0.1.0 7 | jar 8 | 9 | ui-search 10 | User interface example for Spring Vaadin using movies data 11 | 12 | 13 | org.kbastani 14 | spring-cloud-microservice-example-parent 15 | 0.1.0-SNAPSHOT 16 | 17 | 18 | 19 | UTF-8 20 | 1.8 21 | kbastani 22 | 23 | 24 | 25 | 26 | com.vaadin 27 | vaadin-spring-boot-starter 28 | 1.0.0.beta3 29 | 30 | 31 | org.springframework.cloud 32 | spring-cloud-starter 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-feign 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-starter-eureka 41 | 42 | 43 | org.springframework.cloud 44 | spring-cloud-starter-zuul 45 | 46 | 47 | joda-time 48 | joda-time 49 | 50 | 51 | org.springframework.hateoas 52 | spring-hateoas 53 | 54 | 55 | 56 | 57 | 58 | 59 | org.springframework.boot 60 | spring-boot-maven-plugin 61 | 62 | 63 | 64 | repackage 65 | 66 | 67 | 68 | 69 | 70 | com.spotify 71 | docker-maven-plugin 72 | 0.2.3 73 | 74 | 75 | package 76 | 77 | build 78 | 79 | 80 | 81 | 82 | ${docker.image.prefix}/${project.artifactId} 83 | ${project.basedir}/src/main/docker 84 | 85 | 86 | / 87 | ${project.build.directory} 88 | ${project.build.finalName}.jar 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | spring-snapshots 99 | Spring Snapshots 100 | https://repo.spring.io/snapshot 101 | 102 | true 103 | 104 | 105 | 106 | spring-milestones 107 | Spring Milestones 108 | https://repo.spring.io/milestone 109 | 110 | false 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | com.vaadin 119 | vaadin-bom 120 | 7.4.5 121 | pom 122 | import 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /rating-microservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 4.0.0 7 | 0.1.0 8 | jar 9 | rating-microservice 10 | 11 | 12 | org.kbastani 13 | spring-cloud-microservice-example-parent 14 | 0.1.0-SNAPSHOT 15 | 16 | 17 | 18 | kbastani 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-data-rest 29 | 30 | 31 | org.springframework.cloud 32 | spring-cloud-config-server 33 | 34 | 35 | org.springframework.cloud 36 | spring-cloud-starter-eureka 37 | 38 | 39 | org.springframework.cloud 40 | spring-cloud-starter-zuul 41 | 42 | 43 | org.springframework.data 44 | spring-data-neo4j 45 | 3.4.0.RC1 46 | 47 | 48 | org.hibernate 49 | hibernate-validator 50 | 51 | 52 | org.springframework.data 53 | spring-data-neo4j-rest 54 | 3.3.0.M1 55 | 56 | 57 | org.projectlombok 58 | lombok 59 | 60 | 61 | 62 | 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-maven-plugin 67 | 68 | 69 | 70 | repackage 71 | 72 | 73 | 74 | 75 | 76 | com.spotify 77 | docker-maven-plugin 78 | 0.2.3 79 | 80 | 81 | package 82 | 83 | build 84 | 85 | 86 | 87 | 88 | ${docker.image.prefix}/${project.artifactId} 89 | ${project.basedir}/src/main/docker 90 | 91 | 92 | / 93 | ${project.build.directory} 94 | ${project.build.finalName}.jar 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | spring-snapshots 105 | Spring Snapshots 106 | http://repo.spring.io/libs-snapshot-local 107 | 108 | true 109 | 110 | 111 | 112 | spring-milestones 113 | Spring Milestones 114 | http://repo.spring.io/libs-milestone-local 115 | 116 | false 117 | 118 | 119 | 120 | spring-releases 121 | Spring Releases 122 | http://repo.spring.io/libs-release-local 123 | 124 | false 125 | 126 | 127 | 128 | 129 | 130 | spring-snapshots 131 | Spring Snapshots 132 | http://repo.spring.io/libs-snapshot-local 133 | 134 | true 135 | 136 | 137 | 138 | spring-milestones 139 | Spring Milestones 140 | http://repo.spring.io/libs-milestone-local 141 | 142 | false 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /ui-search/src/main/java/service/ui/MovieUI.java: -------------------------------------------------------------------------------- 1 | package service.ui; 2 | 3 | 4 | import service.clients.MovieClient; 5 | import service.models.Genre; 6 | import service.models.Movie; 7 | import com.vaadin.annotations.Theme; 8 | import com.vaadin.annotations.Title; 9 | import com.vaadin.annotations.VaadinServletConfiguration; 10 | import com.vaadin.data.util.BeanItemContainer; 11 | import com.vaadin.data.util.converter.Converter; 12 | import com.vaadin.event.ShortcutAction; 13 | import com.vaadin.event.ShortcutListener; 14 | import com.vaadin.server.VaadinRequest; 15 | import com.vaadin.server.VaadinServlet; 16 | import com.vaadin.spring.annotation.SpringUI; 17 | import com.vaadin.ui.*; 18 | import com.vaadin.ui.renderers.HtmlRenderer; 19 | import org.springframework.beans.factory.annotation.Autowired; 20 | 21 | import javax.servlet.annotation.WebServlet; 22 | import java.util.Arrays; 23 | import java.util.Locale; 24 | import java.util.Objects; 25 | 26 | @SpringUI(path = "/movies") 27 | @Title("Movies") 28 | @Theme("valo") 29 | public class MovieUI extends UI { 30 | 31 | private static final long serialVersionUID = -3540851800967573466L; 32 | 33 | TextField filter = new TextField(); 34 | Grid movieList = new Grid(); 35 | 36 | @Autowired 37 | MovieClient movieClient; 38 | 39 | @Override 40 | protected void init(VaadinRequest request) { 41 | configureComponents(); 42 | buildLayout(); 43 | } 44 | 45 | private void configureComponents() { 46 | filter.setInputPrompt("Search movies..."); 47 | movieList.setContainerDataSource(new BeanItemContainer<>(Movie.class)); 48 | movieList.setColumnOrder("id", "title", "genres", "url"); 49 | movieList.removeColumn("knownId"); 50 | 51 | filter.addShortcutListener(new ShortcutListener("Press enter to submit...", ShortcutAction.KeyCode.ENTER, null) { 52 | @Override 53 | public void handleAction(Object sender, Object target) { 54 | refreshMovies(filter.getValue()); 55 | } 56 | }); 57 | 58 | movieList.getColumn("genres").setRenderer(new HtmlRenderer(), 59 | new Converter() { 60 | @Override 61 | public Genre[] convertToModel(String value, Class targetType, Locale locale) 62 | throws Converter.ConversionException { 63 | return null; 64 | } 65 | 66 | @Override 67 | public String convertToPresentation(Genre[] value, Class targetType, Locale locale) throws ConversionException { 68 | StringBuilder sb = new StringBuilder(); 69 | Arrays.asList(value).forEach(a -> sb.append("").append(a.getName()).append("")); 70 | return sb.toString(); 71 | } 72 | 73 | @Override 74 | public Class getModelType() { 75 | return Genre[].class; 76 | } 77 | 78 | @Override 79 | public Class getPresentationType() { 80 | return String.class; 81 | } 82 | }); 83 | 84 | // Set the custom link renderer for movies 85 | movieList.getColumn("url").setRenderer(new HtmlRenderer(), 86 | new Converter() { 87 | @Override 88 | public String convertToModel(String value, 89 | Class targetType, Locale locale) 90 | throws Converter.ConversionException { 91 | return "not implemented"; 92 | } 93 | 94 | @Override 95 | public String convertToPresentation(String value, 96 | Class targetType, Locale locale) 97 | throws Converter.ConversionException { 98 | return "" + value + ""; 100 | } 101 | 102 | @Override 103 | public Class getModelType() { 104 | return String.class; 105 | } 106 | 107 | @Override 108 | public Class getPresentationType() { 109 | return String.class; 110 | } 111 | }); 112 | refreshMovies(); 113 | } 114 | 115 | private void buildLayout() { 116 | HorizontalLayout actions = new HorizontalLayout(filter); 117 | actions.setWidth("100%"); 118 | filter.setWidth("100%"); 119 | actions.setExpandRatio(filter, 1); 120 | VerticalLayout left = new VerticalLayout(actions, movieList); 121 | left.setSizeFull(); 122 | movieList.setSizeFull(); 123 | left.setExpandRatio(movieList, 1); 124 | HorizontalLayout mainLayout = new HorizontalLayout(left); 125 | mainLayout.setSizeFull(); 126 | mainLayout.setExpandRatio(left, 1); 127 | setContent(mainLayout); 128 | } 129 | 130 | void refreshMovies() { 131 | refreshMovies(filter.getValue()); 132 | } 133 | 134 | private void refreshMovies(String stringFilter) { 135 | if(!Objects.equals(stringFilter.trim(), "")) { 136 | movieList.setContainerDataSource(new BeanItemContainer<>( 137 | Movie.class, movieClient 138 | .findByTitleContainingIgnoreCase(stringFilter) 139 | .getContent())); 140 | } 141 | } 142 | 143 | @WebServlet(urlPatterns = "/movies") 144 | @VaadinServletConfiguration(ui = MovieUI.class, productionMode = false) 145 | public static class MoviesServlet extends VaadinServlet { 146 | private static final long serialVersionUID = -20248435329898675L; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /ui-search/src/main/java/service/ui/UserUI.java: -------------------------------------------------------------------------------- 1 | package service.ui; 2 | 3 | 4 | import com.vaadin.annotations.Theme; 5 | import com.vaadin.annotations.Title; 6 | import com.vaadin.annotations.VaadinServletConfiguration; 7 | import com.vaadin.data.util.BeanItemContainer; 8 | import com.vaadin.data.util.converter.Converter; 9 | import com.vaadin.event.ShortcutAction; 10 | import com.vaadin.event.ShortcutListener; 11 | import com.vaadin.server.VaadinRequest; 12 | import com.vaadin.server.VaadinServlet; 13 | import com.vaadin.shared.ui.grid.HeightMode; 14 | import com.vaadin.spring.annotation.SpringUI; 15 | import com.vaadin.ui.*; 16 | import com.vaadin.ui.renderers.HtmlRenderer; 17 | import org.springframework.beans.factory.annotation.Autowired; 18 | import service.clients.MovieClient; 19 | import service.clients.RatingClient; 20 | import service.clients.UserClient; 21 | import service.models.Genre; 22 | import service.models.Movie; 23 | import service.models.Product; 24 | import service.models.User; 25 | 26 | import javax.servlet.annotation.WebServlet; 27 | import java.util.Arrays; 28 | import java.util.List; 29 | import java.util.Locale; 30 | import java.util.Objects; 31 | import java.util.stream.Collectors; 32 | 33 | @SpringUI(path = "/users") 34 | @Title("Users") 35 | @Theme("valo") 36 | public class UserUI extends UI { 37 | 38 | private static final long serialVersionUID = -3540851800967573466L; 39 | 40 | TextField filter = new TextField(); 41 | Grid items = new Grid(); 42 | Grid ratings = new Grid(); 43 | 44 | @Autowired 45 | MovieClient movieClient; 46 | 47 | @Autowired 48 | UserClient userClient; 49 | 50 | @Autowired 51 | RatingClient ratingClient; 52 | 53 | @Override 54 | protected void init(VaadinRequest request) { 55 | configureComponents(); 56 | buildLayout(); 57 | } 58 | 59 | private void configureComponents() { 60 | items.setContainerDataSource(new BeanItemContainer<>(User.class, userClient.findAll().getContent())); 61 | items.setColumnOrder("age", "gender", "occupation", "zipcode"); 62 | items.removeColumn("id"); 63 | ratings.setContainerDataSource(new BeanItemContainer<>(Movie.class)); 64 | ratings.setColumnOrder("id", "title", "genres", "url"); 65 | ratings.removeColumn("knownId"); 66 | ratings.removeColumn("id"); 67 | 68 | filter.addShortcutListener(new ShortcutListener("Press enter to submit...", ShortcutAction.KeyCode.ENTER, null) { 69 | @Override 70 | public void handleAction(Object sender, Object target) { 71 | refreshUsers(filter.getValue()); 72 | } 73 | }); 74 | 75 | items.setSelectionMode(Grid.SelectionMode.SINGLE); 76 | items.addSelectionListener(e -> { 77 | populateMovies(((User) items.getSelectedRow()).getId()); 78 | }); 79 | 80 | 81 | ratings.getColumn("genres").setRenderer(new HtmlRenderer(), 82 | new Converter() { 83 | @Override 84 | public Genre[] convertToModel(String value, Class targetType, Locale locale) 85 | throws ConversionException { 86 | return null; 87 | } 88 | 89 | @Override 90 | public String convertToPresentation(Genre[] value, Class targetType, Locale locale) throws ConversionException { 91 | StringBuilder sb = new StringBuilder(); 92 | Arrays.asList(value).forEach(a -> sb.append("").append(a.getName()).append("")); 93 | return sb.toString(); 94 | } 95 | 96 | @Override 97 | public Class getModelType() { 98 | return Genre[].class; 99 | } 100 | 101 | @Override 102 | public Class getPresentationType() { 103 | return String.class; 104 | } 105 | }); 106 | 107 | // Set the custom link renderer for movies 108 | ratings.getColumn("url").setRenderer(new HtmlRenderer(), 109 | new Converter() { 110 | @Override 111 | public String convertToModel(String value, 112 | Class targetType, Locale locale) 113 | throws ConversionException { 114 | return "not implemented"; 115 | } 116 | 117 | @Override 118 | public String convertToPresentation(String value, 119 | Class targetType, Locale locale) 120 | throws ConversionException { 121 | return "" + value + ""; 123 | } 124 | 125 | @Override 126 | public Class getModelType() { 127 | return String.class; 128 | } 129 | 130 | @Override 131 | public Class getPresentationType() { 132 | return String.class; 133 | } 134 | }); 135 | refreshUsers(); 136 | } 137 | 138 | /** 139 | * Populates the grid of movie records that the user has reviewed 140 | * 141 | * @param userId is the ID record of the user 142 | */ 143 | private void populateMovies(Long userId) { 144 | 145 | // Get the movies that this user has rated 146 | List productList = ratingClient.findProductsByUser(userId.toString()) 147 | .getContent() 148 | .stream() 149 | .collect(Collectors.toList()); 150 | 151 | // Translate those records to movie records 152 | ratings.setContainerDataSource(new BeanItemContainer<>(Movie.class, 153 | movieClient.findByIds(productList.stream().map(a -> a.getKnownId()).collect(Collectors.joining(","))).getContent())); 154 | } 155 | 156 | private void buildLayout() { 157 | VerticalLayout left = new VerticalLayout(items); 158 | left.setSizeFull(); 159 | items.setSizeFull(); 160 | left.setExpandRatio(items, 1); 161 | ratings.setHeightMode(HeightMode.CSS); 162 | ratings.setHeight("100%"); 163 | HorizontalLayout mainLayout = new HorizontalLayout(left, ratings); 164 | mainLayout.setSizeFull(); 165 | mainLayout.setExpandRatio(left, 1); 166 | setContent(mainLayout); 167 | } 168 | 169 | void refreshUsers() { 170 | refreshUsers(filter.getValue()); 171 | } 172 | 173 | private void refreshUsers(String stringFilter) { 174 | if (!Objects.equals(stringFilter.trim(), "")) { 175 | items.setContainerDataSource(new BeanItemContainer<>(User.class, userClient.findAll().getContent())); 176 | 177 | } 178 | } 179 | 180 | @WebServlet(urlPatterns = "/users") 181 | @VaadinServletConfiguration(ui = UserUI.class, productionMode = false) 182 | public static class UsersServlet extends VaadinServlet { 183 | 184 | } 185 | } 186 | -------------------------------------------------------------------------------- /user-microservice/src/main/resources/static/users.csv: -------------------------------------------------------------------------------- 1 | id,age,gender,occupation,zipcode 2 | 1,"24","M","technician","85711" 3 | 2,"53","F","other","94043" 4 | 3,"23","M","writer","32067" 5 | 4,"24","M","technician","43537" 6 | 5,"33","F","other","15213" 7 | 6,"42","M","executive","98101" 8 | 7,"57","M","administrator","91344" 9 | 8,"36","M","administrator","05201" 10 | 9,"29","M","student","01002" 11 | 10,"53","M","lawyer","90703" 12 | 11,"39","F","other","30329" 13 | 12,"28","F","other","06405" 14 | 13,"47","M","educator","29206" 15 | 14,"45","M","scientist","55106" 16 | 15,"49","F","educator","97301" 17 | 16,"21","M","entertainment","10309" 18 | 17,"30","M","programmer","06355" 19 | 18,"35","F","other","37212" 20 | 19,"40","M","librarian","02138" 21 | 20,"42","F","homemaker","95660" 22 | 21,"26","M","writer","30068" 23 | 22,"25","M","writer","40206" 24 | 23,"30","F","artist","48197" 25 | 24,"21","F","artist","94533" 26 | 25,"39","M","engineer","55107" 27 | 26,"49","M","engineer","21044" 28 | 27,"40","F","librarian","30030" 29 | 28,"32","M","writer","55369" 30 | 29,"41","M","programmer","94043" 31 | 30,"7","M","student","55436" 32 | 31,"24","M","artist","10003" 33 | 32,"28","F","student","78741" 34 | 33,"23","M","student","27510" 35 | 34,"38","F","administrator","42141" 36 | 35,"20","F","homemaker","42459" 37 | 36,"19","F","student","93117" 38 | 37,"23","M","student","55105" 39 | 38,"28","F","other","54467" 40 | 39,"41","M","entertainment","01040" 41 | 40,"38","M","scientist","27514" 42 | 41,"33","M","engineer","80525" 43 | 42,"30","M","administrator","17870" 44 | 43,"29","F","librarian","20854" 45 | 44,"26","M","technician","46260" 46 | 45,"29","M","programmer","50233" 47 | 46,"27","F","marketing","46538" 48 | 47,"53","M","marketing","07102" 49 | 48,"45","M","administrator","12550" 50 | 49,"23","F","student","76111" 51 | 50,"21","M","writer","52245" 52 | 51,"28","M","educator","16509" 53 | 52,"18","F","student","55105" 54 | 53,"26","M","programmer","55414" 55 | 54,"22","M","executive","66315" 56 | 55,"37","M","programmer","01331" 57 | 56,"25","M","librarian","46260" 58 | 57,"16","M","none","84010" 59 | 58,"27","M","programmer","52246" 60 | 59,"49","M","educator","08403" 61 | 60,"50","M","healthcare","06472" 62 | 61,"36","M","engineer","30040" 63 | 62,"27","F","administrator","97214" 64 | 63,"31","M","marketing","75240" 65 | 64,"32","M","educator","43202" 66 | 65,"51","F","educator","48118" 67 | 66,"23","M","student","80521" 68 | 67,"17","M","student","60402" 69 | 68,"19","M","student","22904" 70 | 69,"24","M","engineer","55337" 71 | 70,"27","M","engineer","60067" 72 | 71,"39","M","scientist","98034" 73 | 72,"48","F","administrator","73034" 74 | 73,"24","M","student","41850" 75 | 74,"39","M","scientist","T8H1N" 76 | 75,"24","M","entertainment","08816" 77 | 76,"20","M","student","02215" 78 | 77,"30","M","technician","29379" 79 | 78,"26","M","administrator","61801" 80 | 79,"39","F","administrator","03755" 81 | 80,"34","F","administrator","52241" 82 | 81,"21","M","student","21218" 83 | 82,"50","M","programmer","22902" 84 | 83,"40","M","other","44133" 85 | 84,"32","M","executive","55369" 86 | 85,"51","M","educator","20003" 87 | 86,"26","M","administrator","46005" 88 | 87,"47","M","administrator","89503" 89 | 88,"49","F","librarian","11701" 90 | 89,"43","F","administrator","68106" 91 | 90,"60","M","educator","78155" 92 | 91,"55","M","marketing","01913" 93 | 92,"32","M","entertainment","80525" 94 | 93,"48","M","executive","23112" 95 | 94,"26","M","student","71457" 96 | 95,"31","M","administrator","10707" 97 | 96,"25","F","artist","75206" 98 | 97,"43","M","artist","98006" 99 | 98,"49","F","executive","90291" 100 | 99,"20","M","student","63129" 101 | 100,"36","M","executive","90254" 102 | 101,"15","M","student","05146" 103 | 102,"38","M","programmer","30220" 104 | 103,"26","M","student","55108" 105 | 104,"27","M","student","55108" 106 | 105,"24","M","engineer","94043" 107 | 106,"61","M","retired","55125" 108 | 107,"39","M","scientist","60466" 109 | 108,"44","M","educator","63130" 110 | 109,"29","M","other","55423" 111 | 110,"19","M","student","77840" 112 | 111,"57","M","engineer","90630" 113 | 112,"30","M","salesman","60613" 114 | 113,"47","M","executive","95032" 115 | 114,"27","M","programmer","75013" 116 | 115,"31","M","engineer","17110" 117 | 116,"40","M","healthcare","97232" 118 | 117,"20","M","student","16125" 119 | 118,"21","M","administrator","90210" 120 | 119,"32","M","programmer","67401" 121 | 120,"47","F","other","06260" 122 | 121,"54","M","librarian","99603" 123 | 122,"32","F","writer","22206" 124 | 123,"48","F","artist","20008" 125 | 124,"34","M","student","60615" 126 | 125,"30","M","lawyer","22202" 127 | 126,"28","F","lawyer","20015" 128 | 127,"33","M","none","73439" 129 | 128,"24","F","marketing","20009" 130 | 129,"36","F","marketing","07039" 131 | 130,"20","M","none","60115" 132 | 131,"59","F","administrator","15237" 133 | 132,"24","M","other","94612" 134 | 133,"53","M","engineer","78602" 135 | 134,"31","M","programmer","80236" 136 | 135,"23","M","student","38401" 137 | 136,"51","M","other","97365" 138 | 137,"50","M","educator","84408" 139 | 138,"46","M","doctor","53211" 140 | 139,"20","M","student","08904" 141 | 140,"30","F","student","32250" 142 | 141,"49","M","programmer","36117" 143 | 142,"13","M","other","48118" 144 | 143,"42","M","technician","08832" 145 | 144,"53","M","programmer","20910" 146 | 145,"31","M","entertainment","V3N4P" 147 | 146,"45","M","artist","83814" 148 | 147,"40","F","librarian","02143" 149 | 148,"33","M","engineer","97006" 150 | 149,"35","F","marketing","17325" 151 | 150,"20","F","artist","02139" 152 | 151,"38","F","administrator","48103" 153 | 152,"33","F","educator","68767" 154 | 153,"25","M","student","60641" 155 | 154,"25","M","student","53703" 156 | 155,"32","F","other","11217" 157 | 156,"25","M","educator","08360" 158 | 157,"57","M","engineer","70808" 159 | 158,"50","M","educator","27606" 160 | 159,"23","F","student","55346" 161 | 160,"27","M","programmer","66215" 162 | 161,"50","M","lawyer","55104" 163 | 162,"25","M","artist","15610" 164 | 163,"49","M","administrator","97212" 165 | 164,"47","M","healthcare","80123" 166 | 165,"20","F","other","53715" 167 | 166,"47","M","educator","55113" 168 | 167,"37","M","other","L9G2B" 169 | 168,"48","M","other","80127" 170 | 169,"52","F","other","53705" 171 | 170,"53","F","healthcare","30067" 172 | 171,"48","F","educator","78750" 173 | 172,"55","M","marketing","22207" 174 | 173,"56","M","other","22306" 175 | 174,"30","F","administrator","52302" 176 | 175,"26","F","scientist","21911" 177 | 176,"28","M","scientist","07030" 178 | 177,"20","M","programmer","19104" 179 | 178,"26","M","other","49512" 180 | 179,"15","M","entertainment","20755" 181 | 180,"22","F","administrator","60202" 182 | 181,"26","M","executive","21218" 183 | 182,"36","M","programmer","33884" 184 | 183,"33","M","scientist","27708" 185 | 184,"37","M","librarian","76013" 186 | 185,"53","F","librarian","97403" 187 | 186,"39","F","executive","00000" 188 | 187,"26","M","educator","16801" 189 | 188,"42","M","student","29440" 190 | 189,"32","M","artist","95014" 191 | 190,"30","M","administrator","95938" 192 | 191,"33","M","administrator","95161" 193 | 192,"42","M","educator","90840" 194 | 193,"29","M","student","49931" 195 | 194,"38","M","administrator","02154" 196 | 195,"42","M","scientist","93555" 197 | 196,"49","M","writer","55105" 198 | 197,"55","M","technician","75094" 199 | 198,"21","F","student","55414" 200 | 199,"30","M","writer","17604" 201 | 200,"40","M","programmer","93402" 202 | 201,"27","M","writer","E2A4H" 203 | 202,"41","F","educator","60201" 204 | 203,"25","F","student","32301" 205 | 204,"52","F","librarian","10960" 206 | 205,"47","M","lawyer","06371" 207 | 206,"14","F","student","53115" 208 | 207,"39","M","marketing","92037" 209 | 208,"43","M","engineer","01720" 210 | 209,"33","F","educator","85710" 211 | 210,"39","M","engineer","03060" 212 | 211,"66","M","salesman","32605" 213 | 212,"49","F","educator","61401" 214 | 213,"33","M","executive","55345" 215 | 214,"26","F","librarian","11231" 216 | 215,"35","M","programmer","63033" 217 | 216,"22","M","engineer","02215" 218 | 217,"22","M","other","11727" 219 | 218,"37","M","administrator","06513" 220 | 219,"32","M","programmer","43212" 221 | 220,"30","M","librarian","78205" 222 | 221,"19","M","student","20685" 223 | 222,"29","M","programmer","27502" 224 | 223,"19","F","student","47906" 225 | 224,"31","F","educator","43512" 226 | 225,"51","F","administrator","58202" 227 | 226,"28","M","student","92103" 228 | 227,"46","M","executive","60659" 229 | 228,"21","F","student","22003" 230 | 229,"29","F","librarian","22903" 231 | 230,"28","F","student","14476" 232 | 231,"48","M","librarian","01080" 233 | 232,"45","M","scientist","99709" 234 | 233,"38","M","engineer","98682" 235 | 234,"60","M","retired","94702" 236 | 235,"37","M","educator","22973" 237 | 236,"44","F","writer","53214" 238 | 237,"49","M","administrator","63146" 239 | 238,"42","F","administrator","44124" 240 | 239,"39","M","artist","95628" 241 | 240,"23","F","educator","20784" 242 | 241,"26","F","student","20001" 243 | 242,"33","M","educator","31404" 244 | 243,"33","M","educator","60201" 245 | 244,"28","M","technician","80525" 246 | 245,"22","M","student","55109" 247 | 246,"19","M","student","28734" 248 | 247,"28","M","engineer","20770" 249 | 248,"25","M","student","37235" 250 | 249,"25","M","student","84103" 251 | 250,"29","M","executive","95110" 252 | 251,"28","M","doctor","85032" 253 | 252,"42","M","engineer","07733" 254 | 253,"26","F","librarian","22903" 255 | 254,"44","M","educator","42647" 256 | 255,"23","M","entertainment","07029" 257 | 256,"35","F","none","39042" 258 | 257,"17","M","student","77005" 259 | 258,"19","F","student","77801" 260 | 259,"21","M","student","48823" 261 | 260,"40","F","artist","89801" 262 | 261,"28","M","administrator","85202" 263 | 262,"19","F","student","78264" 264 | 263,"41","M","programmer","55346" 265 | 264,"36","F","writer","90064" 266 | 265,"26","M","executive","84601" 267 | 266,"62","F","administrator","78756" 268 | 267,"23","M","engineer","83716" 269 | 268,"24","M","engineer","19422" 270 | 269,"31","F","librarian","43201" 271 | 270,"18","F","student","63119" 272 | 271,"51","M","engineer","22932" 273 | 272,"33","M","scientist","53706" 274 | 273,"50","F","other","10016" 275 | 274,"20","F","student","55414" 276 | 275,"38","M","engineer","92064" 277 | 276,"21","M","student","95064" 278 | 277,"35","F","administrator","55406" 279 | 278,"37","F","librarian","30033" 280 | 279,"33","M","programmer","85251" 281 | 280,"30","F","librarian","22903" 282 | 281,"15","F","student","06059" 283 | 282,"22","M","administrator","20057" 284 | 283,"28","M","programmer","55305" 285 | 284,"40","M","executive","92629" 286 | 285,"25","M","programmer","53713" 287 | 286,"27","M","student","15217" 288 | 287,"21","M","salesman","31211" 289 | 288,"34","M","marketing","23226" 290 | 289,"11","M","none","94619" 291 | 290,"40","M","engineer","93550" 292 | 291,"19","M","student","44106" 293 | 292,"35","F","programmer","94703" 294 | 293,"24","M","writer","60804" 295 | 294,"34","M","technician","92110" 296 | 295,"31","M","educator","50325" 297 | 296,"43","F","administrator","16803" 298 | 297,"29","F","educator","98103" 299 | 298,"44","M","executive","01581" 300 | 299,"29","M","doctor","63108" 301 | 300,"26","F","programmer","55106" 302 | 301,"24","M","student","55439" 303 | 302,"42","M","educator","77904" 304 | 303,"19","M","student","14853" 305 | 304,"22","F","student","71701" 306 | 305,"23","M","programmer","94086" 307 | 306,"45","M","other","73132" 308 | 307,"25","M","student","55454" 309 | 308,"60","M","retired","95076" 310 | 309,"40","M","scientist","70802" 311 | 310,"37","M","educator","91711" 312 | 311,"32","M","technician","73071" 313 | 312,"48","M","other","02110" 314 | 313,"41","M","marketing","60035" 315 | 314,"20","F","student","08043" 316 | 315,"31","M","educator","18301" 317 | 316,"43","F","other","77009" 318 | 317,"22","M","administrator","13210" 319 | 318,"65","M","retired","06518" 320 | 319,"38","M","programmer","22030" 321 | 320,"19","M","student","24060" 322 | 321,"49","F","educator","55413" 323 | 322,"20","M","student","50613" 324 | 323,"21","M","student","19149" 325 | 324,"21","F","student","02176" 326 | 325,"48","M","technician","02139" 327 | 326,"41","M","administrator","15235" 328 | 327,"22","M","student","11101" 329 | 328,"51","M","administrator","06779" 330 | 329,"48","M","educator","01720" 331 | 330,"35","F","educator","33884" 332 | 331,"33","M","entertainment","91344" 333 | 332,"20","M","student","40504" 334 | 333,"47","M","other","V0R2M" 335 | 334,"32","M","librarian","30002" 336 | 335,"45","M","executive","33775" 337 | 336,"23","M","salesman","42101" 338 | 337,"37","M","scientist","10522" 339 | 338,"39","F","librarian","59717" 340 | 339,"35","M","lawyer","37901" 341 | 340,"46","M","engineer","80123" 342 | 341,"17","F","student","44405" 343 | 342,"25","F","other","98006" 344 | 343,"43","M","engineer","30093" 345 | 344,"30","F","librarian","94117" 346 | 345,"28","F","librarian","94143" 347 | 346,"34","M","other","76059" 348 | 347,"18","M","student","90210" 349 | 348,"24","F","student","45660" 350 | 349,"68","M","retired","61455" 351 | 350,"32","M","student","97301" 352 | 351,"61","M","educator","49938" 353 | 352,"37","F","programmer","55105" 354 | 353,"25","M","scientist","28480" 355 | 354,"29","F","librarian","48197" 356 | 355,"25","M","student","60135" 357 | 356,"32","F","homemaker","92688" 358 | 357,"26","M","executive","98133" 359 | 358,"40","M","educator","10022" 360 | 359,"22","M","student","61801" 361 | 360,"51","M","other","98027" 362 | 361,"22","M","student","44074" 363 | 362,"35","F","homemaker","85233" 364 | 363,"20","M","student","87501" 365 | 364,"63","M","engineer","01810" 366 | 365,"29","M","lawyer","20009" 367 | 366,"20","F","student","50670" 368 | 367,"17","M","student","37411" 369 | 368,"18","M","student","92113" 370 | 369,"24","M","student","91335" 371 | 370,"52","M","writer","08534" 372 | 371,"36","M","engineer","99206" 373 | 372,"25","F","student","66046" 374 | 373,"24","F","other","55116" 375 | 374,"36","M","executive","78746" 376 | 375,"17","M","entertainment","37777" 377 | 376,"28","F","other","10010" 378 | 377,"22","M","student","18015" 379 | 378,"35","M","student","02859" 380 | 379,"44","M","programmer","98117" 381 | 380,"32","M","engineer","55117" 382 | 381,"33","M","artist","94608" 383 | 382,"45","M","engineer","01824" 384 | 383,"42","M","administrator","75204" 385 | 384,"52","M","programmer","45218" 386 | 385,"36","M","writer","10003" 387 | 386,"36","M","salesman","43221" 388 | 387,"33","M","entertainment","37412" 389 | 388,"31","M","other","36106" 390 | 389,"44","F","writer","83702" 391 | 390,"42","F","writer","85016" 392 | 391,"23","M","student","84604" 393 | 392,"52","M","writer","59801" 394 | 393,"19","M","student","83686" 395 | 394,"25","M","administrator","96819" 396 | 395,"43","M","other","44092" 397 | 396,"57","M","engineer","94551" 398 | 397,"17","M","student","27514" 399 | 398,"40","M","other","60008" 400 | 399,"25","M","other","92374" 401 | 400,"33","F","administrator","78213" 402 | 401,"46","F","healthcare","84107" 403 | 402,"30","M","engineer","95129" 404 | 403,"37","M","other","06811" 405 | 404,"29","F","programmer","55108" 406 | 405,"22","F","healthcare","10019" 407 | 406,"52","M","educator","93109" 408 | 407,"29","M","engineer","03261" 409 | 408,"23","M","student","61755" 410 | 409,"48","M","administrator","98225" 411 | 410,"30","F","artist","94025" 412 | 411,"34","M","educator","44691" 413 | 412,"25","M","educator","15222" 414 | 413,"55","M","educator","78212" 415 | 414,"24","M","programmer","38115" 416 | 415,"39","M","educator","85711" 417 | 416,"20","F","student","92626" 418 | 417,"27","F","other","48103" 419 | 418,"55","F","none","21206" 420 | 419,"37","M","lawyer","43215" 421 | 420,"53","M","educator","02140" 422 | 421,"38","F","programmer","55105" 423 | 422,"26","M","entertainment","94533" 424 | 423,"64","M","other","91606" 425 | 424,"36","F","marketing","55422" 426 | 425,"19","M","student","58644" 427 | 426,"55","M","educator","01602" 428 | 427,"51","M","doctor","85258" 429 | 428,"28","M","student","55414" 430 | 429,"27","M","student","29205" 431 | 430,"38","M","scientist","98199" 432 | 431,"24","M","marketing","92629" 433 | 432,"22","M","entertainment","50311" 434 | 433,"27","M","artist","11211" 435 | 434,"16","F","student","49705" 436 | 435,"24","M","engineer","60007" 437 | 436,"30","F","administrator","17345" 438 | 437,"27","F","other","20009" 439 | 438,"51","F","administrator","43204" 440 | 439,"23","F","administrator","20817" 441 | 440,"30","M","other","48076" 442 | 441,"50","M","technician","55013" 443 | 442,"22","M","student","85282" 444 | 443,"35","M","salesman","33308" 445 | 444,"51","F","lawyer","53202" 446 | 445,"21","M","writer","92653" 447 | 446,"57","M","educator","60201" 448 | 447,"30","M","administrator","55113" 449 | 448,"23","M","entertainment","10021" 450 | 449,"23","M","librarian","55021" 451 | 450,"35","F","educator","11758" 452 | 451,"16","M","student","48446" 453 | 452,"35","M","administrator","28018" 454 | 453,"18","M","student","06333" 455 | 454,"57","M","other","97330" 456 | 455,"48","M","administrator","83709" 457 | 456,"24","M","technician","31820" 458 | 457,"33","F","salesman","30011" 459 | 458,"47","M","technician","Y1A6B" 460 | 459,"22","M","student","29201" 461 | 460,"44","F","other","60630" 462 | 461,"15","M","student","98102" 463 | 462,"19","F","student","02918" 464 | 463,"48","F","healthcare","75218" 465 | 464,"60","M","writer","94583" 466 | 465,"32","M","other","05001" 467 | 466,"22","M","student","90804" 468 | 467,"29","M","engineer","91201" 469 | 468,"28","M","engineer","02341" 470 | 469,"60","M","educator","78628" 471 | 470,"24","M","programmer","10021" 472 | 471,"10","M","student","77459" 473 | 472,"24","M","student","87544" 474 | 473,"29","M","student","94708" 475 | 474,"51","M","executive","93711" 476 | 475,"30","M","programmer","75230" 477 | 476,"28","M","student","60440" 478 | 477,"23","F","student","02125" 479 | 478,"29","M","other","10019" 480 | 479,"30","M","educator","55409" 481 | 480,"57","M","retired","98257" 482 | 481,"73","M","retired","37771" 483 | 482,"18","F","student","40256" 484 | 483,"29","M","scientist","43212" 485 | 484,"27","M","student","21208" 486 | 485,"44","F","educator","95821" 487 | 486,"39","M","educator","93101" 488 | 487,"22","M","engineer","92121" 489 | 488,"48","M","technician","21012" 490 | 489,"55","M","other","45218" 491 | 490,"29","F","artist","V5A2B" 492 | 491,"43","F","writer","53711" 493 | 492,"57","M","educator","94618" 494 | 493,"22","M","engineer","60090" 495 | 494,"38","F","administrator","49428" 496 | 495,"29","M","engineer","03052" 497 | 496,"21","F","student","55414" 498 | 497,"20","M","student","50112" 499 | 498,"26","M","writer","55408" 500 | 499,"42","M","programmer","75006" 501 | 500,"28","M","administrator","94305" 502 | 501,"22","M","student","10025" 503 | 502,"22","M","student","23092" 504 | 503,"50","F","writer","27514" 505 | 504,"40","F","writer","92115" 506 | 505,"27","F","other","20657" 507 | 506,"46","M","programmer","03869" 508 | 507,"18","F","writer","28450" 509 | 508,"27","M","marketing","19382" 510 | 509,"23","M","administrator","10011" 511 | 510,"34","M","other","98038" 512 | 511,"22","M","student","21250" 513 | 512,"29","M","other","20090" 514 | 513,"43","M","administrator","26241" 515 | 514,"27","M","programmer","20707" 516 | 515,"53","M","marketing","49508" 517 | 516,"53","F","librarian","10021" 518 | 517,"24","M","student","55454" 519 | 518,"49","F","writer","99709" 520 | 519,"22","M","other","55320" 521 | 520,"62","M","healthcare","12603" 522 | 521,"19","M","student","02146" 523 | 522,"36","M","engineer","55443" 524 | 523,"50","F","administrator","04102" 525 | 524,"56","M","educator","02159" 526 | 525,"27","F","administrator","19711" 527 | 526,"30","M","marketing","97124" 528 | 527,"33","M","librarian","12180" 529 | 528,"18","M","student","55104" 530 | 529,"47","F","administrator","44224" 531 | 530,"29","M","engineer","94040" 532 | 531,"30","F","salesman","97408" 533 | 532,"20","M","student","92705" 534 | 533,"43","M","librarian","02324" 535 | 534,"20","M","student","05464" 536 | 535,"45","F","educator","80302" 537 | 536,"38","M","engineer","30078" 538 | 537,"36","M","engineer","22902" 539 | 538,"31","M","scientist","21010" 540 | 539,"53","F","administrator","80303" 541 | 540,"28","M","engineer","91201" 542 | 541,"19","F","student","84302" 543 | 542,"21","M","student","60515" 544 | 543,"33","M","scientist","95123" 545 | 544,"44","F","other","29464" 546 | 545,"27","M","technician","08052" 547 | 546,"36","M","executive","22911" 548 | 547,"50","M","educator","14534" 549 | 548,"51","M","writer","95468" 550 | 549,"42","M","scientist","45680" 551 | 550,"16","F","student","95453" 552 | 551,"25","M","programmer","55414" 553 | 552,"45","M","other","68147" 554 | 553,"58","M","educator","62901" 555 | 554,"32","M","scientist","62901" 556 | 555,"29","F","educator","23227" 557 | 556,"35","F","educator","30606" 558 | 557,"30","F","writer","11217" 559 | 558,"56","F","writer","63132" 560 | 559,"69","M","executive","10022" 561 | 560,"32","M","student","10003" 562 | 561,"23","M","engineer","60005" 563 | 562,"54","F","administrator","20879" 564 | 563,"39","F","librarian","32707" 565 | 564,"65","M","retired","94591" 566 | 565,"40","M","student","55422" 567 | 566,"20","M","student","14627" 568 | 567,"24","M","entertainment","10003" 569 | 568,"39","M","educator","01915" 570 | 569,"34","M","educator","91903" 571 | 570,"26","M","educator","14627" 572 | 571,"34","M","artist","01945" 573 | 572,"51","M","educator","20003" 574 | 573,"68","M","retired","48911" 575 | 574,"56","M","educator","53188" 576 | 575,"33","M","marketing","46032" 577 | 576,"48","M","executive","98281" 578 | 577,"36","F","student","77845" 579 | 578,"31","M","administrator","M7A1A" 580 | 579,"32","M","educator","48103" 581 | 580,"16","M","student","17961" 582 | 581,"37","M","other","94131" 583 | 582,"17","M","student","93003" 584 | 583,"44","M","engineer","29631" 585 | 584,"25","M","student","27511" 586 | 585,"69","M","librarian","98501" 587 | 586,"20","M","student","79508" 588 | 587,"26","M","other","14216" 589 | 588,"18","F","student","93063" 590 | 589,"21","M","lawyer","90034" 591 | 590,"50","M","educator","82435" 592 | 591,"57","F","librarian","92093" 593 | 592,"18","M","student","97520" 594 | 593,"31","F","educator","68767" 595 | 594,"46","M","educator","M4J2K" 596 | 595,"25","M","programmer","31909" 597 | 596,"20","M","artist","77073" 598 | 597,"23","M","other","84116" 599 | 598,"40","F","marketing","43085" 600 | 599,"22","F","student","R3T5K" 601 | 600,"34","M","programmer","02320" 602 | 601,"19","F","artist","99687" 603 | 602,"47","F","other","34656" 604 | 603,"21","M","programmer","47905" 605 | 604,"39","M","educator","11787" 606 | 605,"33","M","engineer","33716" 607 | 606,"28","M","programmer","63044" 608 | 607,"49","F","healthcare","02154" 609 | 608,"22","M","other","10003" 610 | 609,"13","F","student","55106" 611 | 610,"22","M","student","21227" 612 | 611,"46","M","librarian","77008" 613 | 612,"36","M","educator","79070" 614 | 613,"37","F","marketing","29678" 615 | 614,"54","M","educator","80227" 616 | 615,"38","M","educator","27705" 617 | 616,"55","M","scientist","50613" 618 | 617,"27","F","writer","11201" 619 | 618,"15","F","student","44212" 620 | 619,"17","M","student","44134" 621 | 620,"18","F","writer","81648" 622 | 621,"17","M","student","60402" 623 | 622,"25","M","programmer","14850" 624 | 623,"50","F","educator","60187" 625 | 624,"19","M","student","30067" 626 | 625,"27","M","programmer","20723" 627 | 626,"23","M","scientist","19807" 628 | 627,"24","M","engineer","08034" 629 | 628,"13","M","none","94306" 630 | 629,"46","F","other","44224" 631 | 630,"26","F","healthcare","55408" 632 | 631,"18","F","student","38866" 633 | 632,"18","M","student","55454" 634 | 633,"35","M","programmer","55414" 635 | 634,"39","M","engineer","T8H1N" 636 | 635,"22","M","other","23237" 637 | 636,"47","M","educator","48043" 638 | 637,"30","M","other","74101" 639 | 638,"45","M","engineer","01940" 640 | 639,"42","F","librarian","12065" 641 | 640,"20","M","student","61801" 642 | 641,"24","M","student","60626" 643 | 642,"18","F","student","95521" 644 | 643,"39","M","scientist","55122" 645 | 644,"51","M","retired","63645" 646 | 645,"27","M","programmer","53211" 647 | 646,"17","F","student","51250" 648 | 647,"40","M","educator","45810" 649 | 648,"43","M","engineer","91351" 650 | 649,"20","M","student","39762" 651 | 650,"42","M","engineer","83814" 652 | 651,"65","M","retired","02903" 653 | 652,"35","M","other","22911" 654 | 653,"31","M","executive","55105" 655 | 654,"27","F","student","78739" 656 | 655,"50","F","healthcare","60657" 657 | 656,"48","M","educator","10314" 658 | 657,"26","F","none","78704" 659 | 658,"33","M","programmer","92626" 660 | 659,"31","M","educator","54248" 661 | 660,"26","M","student","77380" 662 | 661,"28","M","programmer","98121" 663 | 662,"55","M","librarian","19102" 664 | 663,"26","M","other","19341" 665 | 664,"30","M","engineer","94115" 666 | 665,"25","M","administrator","55412" 667 | 666,"44","M","administrator","61820" 668 | 667,"35","M","librarian","01970" 669 | 668,"29","F","writer","10016" 670 | 669,"37","M","other","20009" 671 | 670,"30","M","technician","21114" 672 | 671,"21","M","programmer","91919" 673 | 672,"54","F","administrator","90095" 674 | 673,"51","M","educator","22906" 675 | 674,"13","F","student","55337" 676 | 675,"34","M","other","28814" 677 | 676,"30","M","programmer","32712" 678 | 677,"20","M","other","99835" 679 | 678,"50","M","educator","61462" 680 | 679,"20","F","student","54302" 681 | 680,"33","M","lawyer","90405" 682 | 681,"44","F","marketing","97208" 683 | 682,"23","M","programmer","55128" 684 | 683,"42","M","librarian","23509" 685 | 684,"28","M","student","55414" 686 | 685,"32","F","librarian","55409" 687 | 686,"32","M","educator","26506" 688 | 687,"31","F","healthcare","27713" 689 | 688,"37","F","administrator","60476" 690 | 689,"25","M","other","45439" 691 | 690,"35","M","salesman","63304" 692 | 691,"34","M","educator","60089" 693 | 692,"34","M","engineer","18053" 694 | 693,"43","F","healthcare","85210" 695 | 694,"60","M","programmer","06365" 696 | 695,"26","M","writer","38115" 697 | 696,"55","M","other","94920" 698 | 697,"25","M","other","77042" 699 | 698,"28","F","programmer","06906" 700 | 699,"44","M","other","96754" 701 | 700,"17","M","student","76309" 702 | 701,"51","F","librarian","56321" 703 | 702,"37","M","other","89104" 704 | 703,"26","M","educator","49512" 705 | 704,"51","F","librarian","91105" 706 | 705,"21","F","student","54494" 707 | 706,"23","M","student","55454" 708 | 707,"56","F","librarian","19146" 709 | 708,"26","F","homemaker","96349" 710 | 709,"21","M","other","N4T1A" 711 | 710,"19","M","student","92020" 712 | 711,"22","F","student","15203" 713 | 712,"22","F","student","54901" 714 | 713,"42","F","other","07204" 715 | 714,"26","M","engineer","55343" 716 | 715,"21","M","technician","91206" 717 | 716,"36","F","administrator","44265" 718 | 717,"24","M","technician","84105" 719 | 718,"42","M","technician","64118" 720 | 719,"37","F","other","V0R2H" 721 | 720,"49","F","administrator","16506" 722 | 721,"24","F","entertainment","11238" 723 | 722,"50","F","homemaker","17331" 724 | 723,"26","M","executive","94403" 725 | 724,"31","M","executive","40243" 726 | 725,"21","M","student","91711" 727 | 726,"25","F","administrator","80538" 728 | 727,"25","M","student","78741" 729 | 728,"58","M","executive","94306" 730 | 729,"19","M","student","56567" 731 | 730,"31","F","scientist","32114" 732 | 731,"41","F","educator","70403" 733 | 732,"28","F","other","98405" 734 | 733,"44","F","other","60630" 735 | 734,"25","F","other","63108" 736 | 735,"29","F","healthcare","85719" 737 | 736,"48","F","writer","94618" 738 | 737,"30","M","programmer","98072" 739 | 738,"35","M","technician","95403" 740 | 739,"35","M","technician","73162" 741 | 740,"25","F","educator","22206" 742 | 741,"25","M","writer","63108" 743 | 742,"35","M","student","29210" 744 | 743,"31","M","programmer","92660" 745 | 744,"35","M","marketing","47024" 746 | 745,"42","M","writer","55113" 747 | 746,"25","M","engineer","19047" 748 | 747,"19","M","other","93612" 749 | 748,"28","M","administrator","94720" 750 | 749,"33","M","other","80919" 751 | 750,"28","M","administrator","32303" 752 | 751,"24","F","other","90034" 753 | 752,"60","M","retired","21201" 754 | 753,"56","M","salesman","91206" 755 | 754,"59","F","librarian","62901" 756 | 755,"44","F","educator","97007" 757 | 756,"30","F","none","90247" 758 | 757,"26","M","student","55104" 759 | 758,"27","M","student","53706" 760 | 759,"20","F","student","68503" 761 | 760,"35","F","other","14211" 762 | 761,"17","M","student","97302" 763 | 762,"32","M","administrator","95050" 764 | 763,"27","M","scientist","02113" 765 | 764,"27","F","educator","62903" 766 | 765,"31","M","student","33066" 767 | 766,"42","M","other","10960" 768 | 767,"70","M","engineer","00000" 769 | 768,"29","M","administrator","12866" 770 | 769,"39","M","executive","06927" 771 | 770,"28","M","student","14216" 772 | 771,"26","M","student","15232" 773 | 772,"50","M","writer","27105" 774 | 773,"20","M","student","55414" 775 | 774,"30","M","student","80027" 776 | 775,"46","M","executive","90036" 777 | 776,"30","M","librarian","51157" 778 | 777,"63","M","programmer","01810" 779 | 778,"34","M","student","01960" 780 | 779,"31","M","student","K7L5J" 781 | 780,"49","M","programmer","94560" 782 | 781,"20","M","student","48825" 783 | 782,"21","F","artist","33205" 784 | 783,"30","M","marketing","77081" 785 | 784,"47","M","administrator","91040" 786 | 785,"32","M","engineer","23322" 787 | 786,"36","F","engineer","01754" 788 | 787,"18","F","student","98620" 789 | 788,"51","M","administrator","05779" 790 | 789,"29","M","other","55420" 791 | 790,"27","M","technician","80913" 792 | 791,"31","M","educator","20064" 793 | 792,"40","M","programmer","12205" 794 | 793,"22","M","student","85281" 795 | 794,"32","M","educator","57197" 796 | 795,"30","M","programmer","08610" 797 | 796,"32","F","writer","33755" 798 | 797,"44","F","other","62522" 799 | 798,"40","F","writer","64131" 800 | 799,"49","F","administrator","19716" 801 | 800,"25","M","programmer","55337" 802 | 801,"22","M","writer","92154" 803 | 802,"35","M","administrator","34105" 804 | 803,"70","M","administrator","78212" 805 | 804,"39","M","educator","61820" 806 | 805,"27","F","other","20009" 807 | 806,"27","M","marketing","11217" 808 | 807,"41","F","healthcare","93555" 809 | 808,"45","M","salesman","90016" 810 | 809,"50","F","marketing","30803" 811 | 810,"55","F","other","80526" 812 | 811,"40","F","educator","73013" 813 | 812,"22","M","technician","76234" 814 | 813,"14","F","student","02136" 815 | 814,"30","M","other","12345" 816 | 815,"32","M","other","28806" 817 | 816,"34","M","other","20755" 818 | 817,"19","M","student","60152" 819 | 818,"28","M","librarian","27514" 820 | 819,"59","M","administrator","40205" 821 | 820,"22","M","student","37725" 822 | 821,"37","M","engineer","77845" 823 | 822,"29","F","librarian","53144" 824 | 823,"27","M","artist","50322" 825 | 824,"31","M","other","15017" 826 | 825,"44","M","engineer","05452" 827 | 826,"28","M","artist","77048" 828 | 827,"23","F","engineer","80228" 829 | 828,"28","M","librarian","85282" 830 | 829,"48","M","writer","80209" 831 | 830,"46","M","programmer","53066" 832 | 831,"21","M","other","33765" 833 | 832,"24","M","technician","77042" 834 | 833,"34","M","writer","90019" 835 | 834,"26","M","other","64153" 836 | 835,"44","F","executive","11577" 837 | 836,"44","M","artist","10018" 838 | 837,"36","F","artist","55409" 839 | 838,"23","M","student","01375" 840 | 839,"38","F","entertainment","90814" 841 | 840,"39","M","artist","55406" 842 | 841,"45","M","doctor","47401" 843 | 842,"40","M","writer","93055" 844 | 843,"35","M","librarian","44212" 845 | 844,"22","M","engineer","95662" 846 | 845,"64","M","doctor","97405" 847 | 846,"27","M","lawyer","47130" 848 | 847,"29","M","student","55417" 849 | 848,"46","M","engineer","02146" 850 | 849,"15","F","student","25652" 851 | 850,"34","M","technician","78390" 852 | 851,"18","M","other","29646" 853 | 852,"46","M","administrator","94086" 854 | 853,"49","M","writer","40515" 855 | 854,"29","F","student","55408" 856 | 855,"53","M","librarian","04988" 857 | 856,"43","F","marketing","97215" 858 | 857,"35","F","administrator","V1G4L" 859 | 858,"63","M","educator","09645" 860 | 859,"18","F","other","06492" 861 | 860,"70","F","retired","48322" 862 | 861,"38","F","student","14085" 863 | 862,"25","M","executive","13820" 864 | 863,"17","M","student","60089" 865 | 864,"27","M","programmer","63021" 866 | 865,"25","M","artist","11231" 867 | 866,"45","M","other","60302" 868 | 867,"24","M","scientist","92507" 869 | 868,"21","M","programmer","55303" 870 | 869,"30","M","student","10025" 871 | 870,"22","M","student","65203" 872 | 871,"31","M","executive","44648" 873 | 872,"19","F","student","74078" 874 | 873,"48","F","administrator","33763" 875 | 874,"36","M","scientist","37076" 876 | 875,"24","F","student","35802" 877 | 876,"41","M","other","20902" 878 | 877,"30","M","other","77504" 879 | 878,"50","F","educator","98027" 880 | 879,"33","F","administrator","55337" 881 | 880,"13","M","student","83702" 882 | 881,"39","M","marketing","43017" 883 | 882,"35","M","engineer","40503" 884 | 883,"49","M","librarian","50266" 885 | 884,"44","M","engineer","55337" 886 | 885,"30","F","other","95316" 887 | 886,"20","M","student","61820" 888 | 887,"14","F","student","27249" 889 | 888,"41","M","scientist","17036" 890 | 889,"24","M","technician","78704" 891 | 890,"32","M","student","97301" 892 | 891,"51","F","administrator","03062" 893 | 892,"36","M","other","45243" 894 | 893,"25","M","student","95823" 895 | 894,"47","M","educator","74075" 896 | 895,"31","F","librarian","32301" 897 | 896,"28","M","writer","91505" 898 | 897,"30","M","other","33484" 899 | 898,"23","M","homemaker","61755" 900 | 899,"32","M","other","55116" 901 | 900,"60","M","retired","18505" 902 | 901,"38","M","executive","L1V3W" 903 | 902,"45","F","artist","97203" 904 | 903,"28","M","educator","20850" 905 | 904,"17","F","student","61073" 906 | 905,"27","M","other","30350" 907 | 906,"45","M","librarian","70124" 908 | 907,"25","F","other","80526" 909 | 908,"44","F","librarian","68504" 910 | 909,"50","F","educator","53171" 911 | 910,"28","M","healthcare","29301" 912 | 911,"37","F","writer","53210" 913 | 912,"51","M","other","06512" 914 | 913,"27","M","student","76201" 915 | 914,"44","F","other","08105" 916 | 915,"50","M","entertainment","60614" 917 | 916,"27","M","engineer","N2L5N" 918 | 917,"22","F","student","20006" 919 | 918,"40","M","scientist","70116" 920 | 919,"25","M","other","14216" 921 | 920,"30","F","artist","90008" 922 | 921,"20","F","student","98801" 923 | 922,"29","F","administrator","21114" 924 | 923,"21","M","student","E2E3R" 925 | 924,"29","M","other","11753" 926 | 925,"18","F","salesman","49036" 927 | 926,"49","M","entertainment","01701" 928 | 927,"23","M","programmer","55428" 929 | 928,"21","M","student","55408" 930 | 929,"44","M","scientist","53711" 931 | 930,"28","F","scientist","07310" 932 | 931,"60","M","educator","33556" 933 | 932,"58","M","educator","06437" 934 | 933,"28","M","student","48105" 935 | 934,"61","M","engineer","22902" 936 | 935,"42","M","doctor","66221" 937 | 936,"24","M","other","32789" 938 | 937,"48","M","educator","98072" 939 | 938,"38","F","technician","55038" 940 | 939,"26","F","student","33319" 941 | 940,"32","M","administrator","02215" 942 | 941,"20","M","student","97229" 943 | 942,"48","F","librarian","78209" 944 | 943,"22","M","student","77841" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------