-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work in progress: now went to cloud foundry and cloudant.
- Loading branch information
Showing
19 changed files
with
446 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
applications: | ||
- name: boks-run | ||
memory: 320MB | ||
instances: 1 | ||
path: target/run-0.0.1-SNAPSHOT.jar | ||
services: | ||
- boks-run-cloudant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,45 @@ | ||
package be.boks; | ||
|
||
import java.io.IOException; | ||
|
||
import org.ektorp.CouchDbConnector; | ||
import org.ektorp.CouchDbInstance; | ||
import org.ektorp.http.HttpClient; | ||
import org.ektorp.http.StdHttpClient; | ||
import org.ektorp.impl.StdCouchDbConnector; | ||
import org.ektorp.impl.StdCouchDbInstance; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.annotation.Bean; | ||
|
||
@SpringBootApplication | ||
public class RunApplication { | ||
|
||
private static final String DATABASE_NAME = "boks-run"; | ||
@Value("${vcap.services.boks-run-cloudant.credentials.host:}") | ||
private String host; | ||
@Value("${vcap.services.boks-run-cloudant.credentials.username:}") | ||
private String username; | ||
@Value("${vcap.services.boks-run-cloudant.credentials.password:}") | ||
private String password; | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(RunApplication.class, args); | ||
} | ||
|
||
@Bean | ||
public CouchDbConnector couchDb() throws IOException { | ||
HttpClient httpClient = new StdHttpClient.Builder() | ||
.url("https://" + host).port(443).username(username) | ||
.password(password).build(); | ||
|
||
CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient); | ||
|
||
CouchDbConnector db = new StdCouchDbConnector(DATABASE_NAME, dbInstance); | ||
db.createDatabaseIfNotExists(); | ||
|
||
return db; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package be.boks.domain; | ||
|
||
import java.io.Serializable; | ||
|
||
import org.springframework.data.annotation.Id; | ||
|
||
public class Club implements Serializable { | ||
|
||
private static final long serialVersionUID = -1535672487981334177L; | ||
|
||
@Id | ||
private Long id; | ||
|
||
private String name; | ||
|
||
private String type = "club"; | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Long id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package be.boks.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.ektorp.support.GenericRepository; | ||
|
||
import be.boks.domain.Club; | ||
|
||
public interface ClubRepository extends GenericRepository<Club> { | ||
|
||
List<Club> getClubs(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package be.boks.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.ektorp.CouchDbConnector; | ||
import org.ektorp.support.CouchDbRepositorySupport; | ||
import org.ektorp.support.View; | ||
import org.ektorp.support.Views; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import be.boks.domain.Club; | ||
|
||
@Repository | ||
@Views({ | ||
@View(name = "all", map = "function(doc) { if (doc.type == 'club' ) emit( null, doc )}") | ||
}) | ||
public class ClubRepositoryImpl extends CouchDbRepositorySupport<Club> implements ClubRepository { | ||
|
||
@Autowired | ||
public ClubRepositoryImpl(CouchDbConnector db) { | ||
super(Club.class, db); | ||
initStandardDesignDocument(); | ||
} | ||
|
||
@Override | ||
public List<Club> getClubs() { | ||
return queryView("all"); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/be/boks/repository/RunnerRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package be.boks.repository; | ||
|
||
import java.util.List; | ||
|
||
import org.ektorp.CouchDbConnector; | ||
import org.ektorp.support.CouchDbRepositorySupport; | ||
import org.ektorp.support.View; | ||
import org.ektorp.support.Views; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import be.boks.domain.Runner; | ||
|
||
@Repository | ||
@Views({ | ||
@View(name = "all", map = "function(doc) { if (doc.type == 'runner' ) emit( null, doc )}") | ||
}) | ||
public class RunnerRepositoryImpl extends CouchDbRepositorySupport<Runner> implements RunnerRepository { | ||
|
||
|
||
@Autowired | ||
public RunnerRepositoryImpl(CouchDbConnector db) { | ||
super(Runner.class, db); | ||
initStandardDesignDocument(); | ||
} | ||
|
||
@Override | ||
public List<Runner> getAll() { | ||
return queryView("all"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,29 @@ | ||
package be.boks.rest; | ||
|
||
import java.util.List; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import be.boks.domain.Club; | ||
import be.boks.service.ClubService; | ||
|
||
@RestController | ||
@RequestMapping("/club") | ||
public class ClubController { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(ClubController.class); | ||
|
||
@Autowired | ||
private ClubService clubService; | ||
|
||
@RequestMapping(method=RequestMethod.GET) | ||
public List<Club> getClubs() { | ||
LOGGER.info("Getting the clubs information."); | ||
return clubService.getAll(); | ||
} | ||
} |
Oops, something went wrong.