summaryrefslogtreecommitdiff
path: root/framework/Wsat/pages/TWsatGenerateAR.php
blob: 3d4291e269d804f2c900e2f44a93603bb9851447 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php

/**
 * Description of Inicio
 *
 * @author daniels
 */
Prado::using("System.Wsat.TWsatARGenerator");

class TWsatGenerateAR extends TPage {

    public function generate($sender) {
        if ($this->IsValid) {
            $table_name = $this->table_name->Text;
            $class_prefix = $this->class_prefix->Text;
            $output_folder_ns = $this->output_folder->Text;

            try {
                $ar_generator = new TWsatARGenerator();
                $ar_generator->setOpFile($output_folder_ns);
                $ar_generator->setClasPrefix($class_prefix);

                if ($this->build_rel->Checked) {
                    $ar_generator->buildRelations();
                }
                if ($table_name != "*") {
                    $ar_generator->generate($table_name);
                } else {
                    $ar_generator->generateAll();
                }
                $this->success_panel->CssClass = "success_panel";
                $this->generation_msg->Text = "The code has been generated successfully.";
            } catch (Exception $ex) {
                $this->success_panel->CssClass = "exception_panel";
                $this->generation_msg->Text = $ex->getMessage();
            }
            $this->success_panel->Visible = true;
        }
    }

    public function preview($sender) {
//        $ar_generator = new TWsatARGenerator();
//        $ar_generator->renderAllTablesInformation();
         throw new THttpException(500, "Not implemented yet.");
    }

}

?>