diff options
Diffstat (limited to 'src/com/p4square/grow/backend/GrowBackend.java')
-rw-r--r-- | src/com/p4square/grow/backend/GrowBackend.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/com/p4square/grow/backend/GrowBackend.java b/src/com/p4square/grow/backend/GrowBackend.java index 533cf09..45e0fa2 100644 --- a/src/com/p4square/grow/backend/GrowBackend.java +++ b/src/com/p4square/grow/backend/GrowBackend.java @@ -15,6 +15,13 @@ import org.restlet.routing.Router; import com.p4square.grow.config.Config; import com.p4square.grow.backend.db.CassandraDatabase; +import com.p4square.grow.backend.db.CassandraKey; +import com.p4square.grow.backend.db.CassandraProviderImpl; + +import com.p4square.grow.model.Question; + +import com.p4square.grow.provider.Provider; +import com.p4square.grow.provider.QuestionProvider; import com.p4square.grow.backend.resources.AccountResource; import com.p4square.grow.backend.resources.BannerResource; @@ -29,11 +36,15 @@ import com.p4square.grow.backend.resources.TrainingResource; * @author Jesse Morgan <jesse@jesterpm.net> */ public class GrowBackend extends Application { + private static final String DEFAULT_COLUMN = "value"; + private final static Logger LOG = Logger.getLogger(GrowBackend.class); private final Config mConfig; private final CassandraDatabase mDatabase; + private final Provider<String, Question> mQuestionProvider; + public GrowBackend() { this(new Config()); } @@ -41,6 +52,13 @@ public class GrowBackend extends Application { public GrowBackend(Config config) { mConfig = config; mDatabase = new CassandraDatabase(); + + mQuestionProvider = new QuestionProvider<CassandraKey>(new CassandraProviderImpl<Question>(mDatabase, "strings", Question.class)) { + @Override + public CassandraKey makeKey(String questionId) { + return new CassandraKey("/questions/" + questionId, DEFAULT_COLUMN); + } + }; } @Override @@ -102,6 +120,10 @@ public class GrowBackend extends Application { return mDatabase; } + public Provider<String, Question> getQuestionProvider() { + return mQuestionProvider; + } + /** * Stand-alone main for testing. */ |