comparison develop/controllers/extractapp.php @ 12:e82ca7375e93

Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 16 Feb 2015 16:51:39 +0100
parents 3d6fba07bfbd
children cc36a20a68ab
comparison
equal deleted inserted replaced
11:3d6fba07bfbd 12:e82ca7375e93
3 class Extractapp extends BaseController { 3 class Extractapp extends BaseController {
4 protected function Index() { 4 protected function Index() {
5 $viewmodel = new ExtractappModel(); 5 $viewmodel = new ExtractappModel();
6 $this->ReturnView($viewmodel->Index(), true); 6 $this->ReturnView($viewmodel->Index(), true);
7 } 7 }
8 protected $viewmodel;
9
10
11 public function __construct($action, $urlvalues, $postdata){
12 parent::__construct($action, $urlvalues, $postdata);
13 $this->viewmodel = new ExtractappModel();
14 }
8 15
9 protected function TaggingText() { 16 protected function TaggingText() {
10 $viewmodel = new ExtractappModel(); 17 //$viewmodel = new ExtractappModel();
18 $viewmodel = $this->viewmodel;
19
11 switch ($this->postdata['func']) { 20 switch ($this->postdata['func']) {
12 case 'SaveFullText': 21 case 'SaveFullText':
13 $viewmodel->SaveFullText($this->postdata); 22 $viewmodel->SaveFullText($this->postdata);
14 $this->ReturnView($viewmodel->StartTagging($this->urlvalues), false); 23 $this->ReturnView($viewmodel->StartTagging(), false);
15 break; 24 break;
16 25 case 'SaveFullTextToLGService':
17 default: 26 echo "[Z] SaveFullTextToLGService! ";
27 $viewmodel->GetInfoFromPreviousPage($this->postdata);
28 $response = $viewmodel->SaveFullTextToLGService($this->postdata);
29
30 $viewmodel->UpdateInfoByResonseFromLGService($response); // update file_id, branch_id, user_id
31
32 $this->ReturnView($viewmodel->StartTagging(), false);
33 break;
34
35 case 'ContinueTagging':
36 echo "[Z] (Countinue tagging) ";
18 if ($this->postdata['topic']) { 37 if ($this->postdata['topic']) {
19 $viewmodel->SetTopic($this->postdata['topic']); 38 $viewmodel->SetTopic($this->postdata['topic']);
20 } 39 }
40 $viewmodel->GetInfoFromPreviousPage($this->postdata);
41 $this->ReturnView($viewmodel->StartTagging(), false);
42 break;
43 default: // first time visit extraction interface from LGService
21 // TODO: get the _post data from Jorge's service 44 // TODO: get the _post data from Jorge's service
22 $this->ReturnView($viewmodel->StartTagging($this->urlvalues), false); 45 echo "[Z] Welcome to Extraction Interface. ";
46
47 if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) {
48 // get text from fileId, from LGService
49 $viewmodel->GetTextFromFileId($this->postdata);
50 } else if ($this->postdata['sectionId'] != 0) {
51 // get text from sectionId from LGService
52 $viewmodel->GetTextFromSectionId($this->postdata);
53 } else if (is_numeric($this->urlvalues['id'])) {
54 // get text from local file system (for development stage only)
55 $viewmodel->GetTextFromLocal($this->urlvalues['id']);
56
57 // $this->ReturnView($viewmodel->StartTagging($this->urlvalues), false);
58 } else {
59 echo "wrong url!!";
60 return;
61 }
62
63 $this->ReturnView($viewmodel->StartTagging(), false);
23 break; 64 break;
24 } 65 }
25 // $this->ReturnView($viewmodel->StartTagging($this->urlvalues), false);
26 66
67
68
27 } 69 }
28 70
29 protected function ExportTable() { 71 protected function ExportTable() {
30 $viewmodel = new ExtractappModel(); 72 //$viewmodel = new ExtractappModel();
73 $viewmodel = $this->viewmodel;
31 $this->ReturnView($viewmodel->ExportTable($this->urlvalues, $this->postdata), false); 74 $this->ReturnView($viewmodel->ExportTable($this->urlvalues, $this->postdata), false);
32 75
33 } 76 }
34 77
35 protected function EditWordlist() { 78 protected function EditWordlist() {
36 $viewmodel = new ExtractappModel(); 79 // $viewmodel = new ExtractappModel();
80 $viewmodel = $this->viewmodel;
37 switch ($this->postdata['func']) { 81 switch ($this->postdata['func']) {
38 case 'AddNewList': 82 case 'AddNewList':
39 $this->ReturnView($viewmodel->AddNewList($this->postdata), false); 83 $this->ReturnView($viewmodel->AddNewList($this->postdata), false);
40 break; 84 break;
41 case 'SaveWordlist': 85 case 'SaveWordlist':
47 } 91 }
48 } 92 }
49 93
50 94
51 protected function EditTaglist() { 95 protected function EditTaglist() {
52 $viewmodel = new ExtractappModel(); 96 //$viewmodel = new ExtractappModel();
97 $viewmodel = $this->viewmodel;
53 switch ($this->postdata['func']) { 98 switch ($this->postdata['func']) {
54 case 'NewTagElement': 99 case 'NewTagElement':
55 $this->ReturnView($viewmodel->NewTagElement($this->postdata), false); 100 $this->ReturnView($viewmodel->NewTagElement($this->postdata), false);
56 break; 101 break;
57 case 'SaveTagElement': 102 case 'SaveTagElement':
66 } 111 }
67 } 112 }
68 113
69 114
70 protected function ConfigTagsInTopic() { 115 protected function ConfigTagsInTopic() {
71 $viewmodel = new ExtractappModel(); 116 //$viewmodel = new ExtractappModel();
117 $viewmodel = $this->viewmodel;
72 switch ($this->postdata['func']) { 118 switch ($this->postdata['func']) {
73 case '': 119 case 'somefunc':
74 120
75 break; 121 break;
76 default: 122 default:
77 $this->ReturnView($viewmodel->ConfigTagsInTopic($this->urlvalues,$this->postdata), false); 123 $this->ReturnView($viewmodel->ConfigTagsInTopic($this->postdata), false);
78 break; 124 break;
79 } 125 }
80 } 126 }
81 127
82 protected function TestAction() { 128 protected function TestAction() {