Dataset.php 5.43 KB
Newer Older
1
<?php declare(strict_types=1);
François Agneray's avatar
François Agneray committed
2
3
4
5
6
7
8
9
10
/*
 * This file is part of ANIS SERVER API.
 *
 * (c) François Agneray <francois.agneray@lam.fr>
 * (c) Chrystel Moreau <chrystel.moreau@lam.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
11
namespace App\Entity\Metamodel;
François Agneray's avatar
François Agneray committed
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72

use Doctrine\Common\Collections\ArrayCollection;

/**
 * @Entity
 * @Table(name="dataset")
 */
class Dataset implements \JsonSerializable
{
    /**
     * @var string
     *
     * @Id
     * @Column(type="string", nullable=false)
     */
    protected $name;
    
    /**
     * @var string
     *
     * @Column(type="string", name="table_ref", nullable=false)
     */
    protected $tableRef;
    
    /**
     * @var string
     *
     * @Column(type="string", nullable=false)
     */
    protected $label;
    
    /**
     * @var string
     *
     * @Column(type="text", nullable=true)
     */
    protected $description;
    
    /**
     * @var integer
     *
     * @Column(type="integer", nullable=false)
     */
    protected $display;
    
    /**
     * @var integer
     *
     * @Column(type="integer", nullable=true)
     */
    protected $count;
    
    /**
     * @var bool
     *
     * @Column(type="boolean", nullable=true)
     */
    protected $vo;

    /**
     * @var string
François Agneray's avatar
François Agneray committed
73
     *
François Agneray's avatar
François Agneray committed
74
75
76
     * @Column(type="string", name="data_path", nullable=true)
     */
    protected $dataPath;
François Agneray's avatar
François Agneray committed
77
78
79
80
81
82
83

    /**
     * @var bool
     *
     * @Column(type="boolean", name="selectable_raw", nullable=false)
     */
    protected $selectableRaw;
François Agneray's avatar
François Agneray committed
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
    
    /**
     * @var Anis\Entity\Project
     *
     * @ManyToOne(targetEntity="Project", inversedBy="datasets")
     * @JoinColumn(name="project_name", referencedColumnName="name", nullable=false)
     */
    protected $project;

    /**
     * @var Anis\Entity\Project
     *
     * @ManyToOne(targetEntity="DatasetFamily", inversedBy="datasets")
     * @JoinColumn(name="id_dataset_family", referencedColumnName="id", nullable=true)
     */
    protected $datasetFamily;
    
    /**
     * @var Anis\Entity\Attribute[]
     *
     * @OneToMany(targetEntity="Attribute", mappedBy="dataset", cascade={"remove"})
     */
    protected $attributes;
    
    /**
     * @var Anis\Entity\File[]
     *
     * @OneToMany(targetEntity="File", mappedBy="dataset", cascade={"remove"})
     */
    protected $files;
    
    /**
     * @var Anis\Entity\DatasetPrivileges
     *
     * @OneToMany(targetEntity="DatasetPrivileges", mappedBy="dataset")
     */
    protected $datasetPrivileges;

    public function __construct($name)
    {
        $this->name = $name;
        $this->attributes = new ArrayCollection;
    }
    
    public function getName()
    {
        return $this->name;
    }
    
    public function getTableRef()
    {
        return $this->tableRef;
    }
    
    public function setTableRef($tableRef)
    {
        return $this->tableRef = $tableRef;
    }
    
    public function getLabel()
    {
        return $this->label;
    }
    
    public function setLabel($label)
    {
        $this->label = $label;
    }
    
    public function getDescription()
    {
        return $this->description;
    }
    
    public function setDescription($description)
    {
        $this->description = $description;
    }
    
    public function getDisplay()
    {
        return $this->display;
    }
    
    public function setDisplay($display)
    {
        $this->display = (int) $display;
    }
    
    public function getCount()
    {
        return $this->count;
    }
    
    public function setCount($count)
    {
        $this->count = (int) $count;
    }
    
    public function getVo()
    {
        return $this->vo;
    }
    
    public function setVo($vo)
    {
        $this->vo = (bool) $vo;
    }
    
    public function getDataPath()
    {
        return $this->dataPath;
    }

    public function setDataPath($dataPath)
    {
        $this->dataPath = $dataPath;
    }

François Agneray's avatar
François Agneray committed
203
204
205
206
207
208
209
210
211
212
    public function getSelectableRaw()
    {
        return $this->selectableRaw;
    }

    public function setSelectableRaw($selectableRaw)
    {
        $this->selectableRaw = $selectableRaw;
    }

François Agneray's avatar
François Agneray committed
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
    public function getProject()
    {
        return $this->project;
    }
    
    public function setProject(Project $project)
    {
        $this->project = $project;
    }

    public function getDatasetFamily()
    {
        return $this->datasetFamily;
    }

    public function setDatasetFamily($datasetFamily)
    {
        $this->datasetFamily = $datasetFamily;
    }
    
    public function getAttributes()
    {
        return $this->attributes;
    }
    
    public function getFiles()
    {
        return $this->files;
    }
    
    public function getJoins()
    {
        return $this->joins;
    }
    
    public function getDatasetPrivileges()
    {
        return $this->datasetPrivileges;
    }

    public function jsonSerialize()
    {
        return [
            'name' => $this->getName(),
            'table_ref' => $this->getTableRef(),
            'label' => $this->getLabel(),
            'description' => $this->getDescription(),
            'display' => $this->getDisplay(),
            'count' => $this->getCount(),
            'vo' => $this->getVo(),
            'data_path' => $this->getDataPath(),
François Agneray's avatar
François Agneray committed
264
            'selectable_raw' => $this->getSelectableRaw(),
François Agneray's avatar
François Agneray committed
265
266
267
268
269
            'project_name' => $this->getProject()->getName(),
            'id_dataset_family' => $this->getDatasetFamily()->getId()
        ];
    }
}