01: // license-header java merge-point
02: /**
03: * This is only generated once! It will never be overwritten.
04: * You can (and have to!) safely modify it by hand.
05: */package org.andromda.samples.animalquiz.decisiontree;
06:
07: /**
08: * @see org.andromda.samples.animalquiz.decisiontree.DecisionService
09: */
10: public class DecisionServiceImpl
11: extends
12: org.andromda.samples.animalquiz.decisiontree.DecisionServiceBase {
13:
14: /**
15: * @see org.andromda.samples.animalquiz.decisiontree.DecisionService#getFirstQuestion()
16: */
17: protected org.andromda.samples.animalquiz.decisiontree.VODecisionItem handleGetFirstQuestion()
18: throws java.lang.Exception {
19: VODecisionItem item = (VODecisionItem) this
20: .getDecisionItemDao().findRoot(
21: DecisionItemDao.TRANSFORM_VODECISIONITEM);
22: if (item == null) {
23: item = (VODecisionItem) this .getAnimalDao().create(
24: DecisionItemDao.TRANSFORM_VODECISIONITEM,
25: "elephant", true);
26: }
27: return item;
28: }
29:
30: /**
31: * @see org.andromda.samples.animalquiz.decisiontree.DecisionService#getNextQuestion(java.lang.Long)
32: */
33: protected org.andromda.samples.animalquiz.decisiontree.VODecisionItem handleGetNextQuestion(
34: java.lang.Long itemId) throws java.lang.Exception {
35: return (VODecisionItem) this .getDecisionItemDao().load(
36: DecisionItemDao.TRANSFORM_VODECISIONITEM, itemId);
37: }
38:
39: /**
40: * @see org.andromda.samples.animalquiz.decisiontree.DecisionService#addNewAnimalWithQuestion(java.lang.String, java.lang.String, java.lang.Long)
41: */
42: protected void handleAddNewAnimalWithQuestion(
43: java.lang.String animalName, java.lang.String promptForYes,
44: java.lang.Long idOfLastNoDecision)
45: throws java.lang.Exception {
46: Animal newAnimal = (Animal) this .getAnimalDao().create(
47: animalName, false);
48: Question newQuestion = (Question) this .getQuestionDao().create(
49: promptForYes, false);
50: newQuestion.setYesSuccessor(newAnimal);
51:
52: DecisionItem lastNoDecision = this.getDecisionItemDao().load(
53: idOfLastNoDecision);
54: lastNoDecision.setNoSuccessor(newQuestion);
55: this.getAnimalDao().create(newAnimal);
56: this.getQuestionDao().create(newQuestion);
57: this.getAnimalDao().update(lastNoDecision);
58: }
59:
60: }
|