Dataset.php 4.9 KB
Newer Older
1
2
<?php

François Agneray's avatar
François Agneray committed
3
/*
4
 * This file is part of Anis Server.
François Agneray's avatar
François Agneray committed
5
 *
6
 * (c) Laboratoire d'Astrophysique de Marseille / CNRS
François Agneray's avatar
François Agneray committed
7
8
9
10
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
11
12
13
declare(strict_types=1);

namespace App\Entity;
François Agneray's avatar
François Agneray committed
14

15
16
use Doctrine\Common\Collections\ArrayCollection;

François Agneray's avatar
François Agneray committed
17
18
19
20
21
22
23
24
25
26
27
28
29
/**
 * @Entity
 * @Table(name="dataset")
 */
class Dataset implements \JsonSerializable
{
    /**
     * @var string
     *
     * @Id
     * @Column(type="string", nullable=false)
     */
    protected $name;
François Agneray's avatar
François Agneray committed
30

François Agneray's avatar
François Agneray committed
31
32
33
34
35
36
    /**
     * @var string
     *
     * @Column(type="string", name="table_ref", nullable=false)
     */
    protected $tableRef;
François Agneray's avatar
François Agneray committed
37

François Agneray's avatar
François Agneray committed
38
39
40
41
42
43
    /**
     * @var string
     *
     * @Column(type="string", nullable=false)
     */
    protected $label;
François Agneray's avatar
François Agneray committed
44

François Agneray's avatar
François Agneray committed
45
46
47
48
49
50
    /**
     * @var string
     *
     * @Column(type="text", nullable=true)
     */
    protected $description;
François Agneray's avatar
François Agneray committed
51

François Agneray's avatar
François Agneray committed
52
    /**
François Agneray's avatar
François Agneray committed
53
     * @var int
François Agneray's avatar
François Agneray committed
54
55
56
57
     *
     * @Column(type="integer", nullable=false)
     */
    protected $display;
François Agneray's avatar
François Agneray committed
58

François Agneray's avatar
François Agneray committed
59
    /**
François Agneray's avatar
François Agneray committed
60
     * @var int
François Agneray's avatar
François Agneray committed
61
62
63
64
     *
     * @Column(type="integer", nullable=true)
     */
    protected $count;
François Agneray's avatar
François Agneray committed
65

François Agneray's avatar
François Agneray committed
66
67
68
69
70
71
72
73
74
    /**
     * @var bool
     *
     * @Column(type="boolean", nullable=true)
     */
    protected $vo;

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

François Agneray's avatar
François Agneray committed
80
81
82
83
84
85
    /**
     * @var string
     *
     * @Column(type="json", nullable=true)
     */
    protected $config;
86
87
88
89
90
91
92

    /**
     * @var bool
     *
     * @Column(type="boolean", nullable=false)
     */
    protected $public;
François Agneray's avatar
François Agneray committed
93

François Agneray's avatar
François Agneray committed
94
95
96
    /**
     * @var Anis\Entity\Project
     *
97
     * @ManyToOne(targetEntity="Project", inversedBy="datasets")
François Agneray's avatar
François Agneray committed
98
99
100
101
102
     * @JoinColumn(name="project_name", referencedColumnName="name", nullable=false)
     */
    protected $project;

    /**
François Agneray's avatar
François Agneray committed
103
     * @var Anis\Entity\DatasetFamily
François Agneray's avatar
François Agneray committed
104
     *
François Agneray's avatar
François Agneray committed
105
     * @ManyToOne(targetEntity="DatasetFamily", inversedBy="datasets")
François Agneray's avatar
François Agneray committed
106
     * @JoinColumn(name="id_dataset_family", referencedColumnName="id", nullable=false, onDelete="CASCADE")
François Agneray's avatar
François Agneray committed
107
108
     */
    protected $datasetFamily;
François Agneray's avatar
François Agneray committed
109

110
111
112
    /**
     * @var Anis\Entity\Attribute[]
     *
François Agneray's avatar
François Agneray committed
113
     * @OneToMany(targetEntity="Attribute", mappedBy="dataset")
114
115
     */
    protected $attributes;
François Agneray's avatar
François Agneray committed
116

François Agneray's avatar
François Agneray committed
117
    public function __construct(string $name)
François Agneray's avatar
François Agneray committed
118
119
    {
        $this->name = $name;
120
        $this->attributes = new ArrayCollection();
François Agneray's avatar
François Agneray committed
121
    }
François Agneray's avatar
François Agneray committed
122

François Agneray's avatar
François Agneray committed
123
    public function getName()
François Agneray's avatar
François Agneray committed
124
125
126
    {
        return $this->name;
    }
François Agneray's avatar
François Agneray committed
127

François Agneray's avatar
François Agneray committed
128
    public function getTableRef()
François Agneray's avatar
François Agneray committed
129
130
131
    {
        return $this->tableRef;
    }
François Agneray's avatar
François Agneray committed
132

François Agneray's avatar
François Agneray committed
133
    public function setTableRef($tableRef)
François Agneray's avatar
François Agneray committed
134
    {
François Agneray's avatar
WIP    
François Agneray committed
135
        $this->tableRef = $tableRef;
François Agneray's avatar
François Agneray committed
136
    }
François Agneray's avatar
François Agneray committed
137

François Agneray's avatar
François Agneray committed
138
    public function getLabel()
François Agneray's avatar
François Agneray committed
139
140
141
    {
        return $this->label;
    }
François Agneray's avatar
François Agneray committed
142

François Agneray's avatar
François Agneray committed
143
    public function setLabel($label)
François Agneray's avatar
François Agneray committed
144
145
146
    {
        $this->label = $label;
    }
François Agneray's avatar
François Agneray committed
147

François Agneray's avatar
François Agneray committed
148
    public function getDescription()
François Agneray's avatar
François Agneray committed
149
150
151
    {
        return $this->description;
    }
François Agneray's avatar
François Agneray committed
152

François Agneray's avatar
François Agneray committed
153
    public function setDescription($description)
François Agneray's avatar
François Agneray committed
154
155
156
    {
        $this->description = $description;
    }
François Agneray's avatar
François Agneray committed
157

François Agneray's avatar
François Agneray committed
158
    public function getDisplay()
François Agneray's avatar
François Agneray committed
159
160
161
    {
        return $this->display;
    }
François Agneray's avatar
François Agneray committed
162

François Agneray's avatar
François Agneray committed
163
    public function setDisplay($display)
François Agneray's avatar
François Agneray committed
164
    {
François Agneray's avatar
WIP    
François Agneray committed
165
        $this->display = $display;
François Agneray's avatar
François Agneray committed
166
    }
François Agneray's avatar
François Agneray committed
167

François Agneray's avatar
François Agneray committed
168
    public function getCount()
François Agneray's avatar
François Agneray committed
169
170
171
    {
        return $this->count;
    }
François Agneray's avatar
François Agneray committed
172

François Agneray's avatar
François Agneray committed
173
    public function setCount($count)
François Agneray's avatar
François Agneray committed
174
    {
François Agneray's avatar
WIP    
François Agneray committed
175
        $this->count = $count;
François Agneray's avatar
François Agneray committed
176
    }
François Agneray's avatar
François Agneray committed
177

François Agneray's avatar
François Agneray committed
178
    public function getVo()
François Agneray's avatar
François Agneray committed
179
180
181
    {
        return $this->vo;
    }
François Agneray's avatar
François Agneray committed
182

François Agneray's avatar
François Agneray committed
183
    public function setVo($vo)
François Agneray's avatar
François Agneray committed
184
    {
François Agneray's avatar
WIP    
François Agneray committed
185
        $this->vo = $vo;
François Agneray's avatar
François Agneray committed
186
    }
François Agneray's avatar
François Agneray committed
187

François Agneray's avatar
François Agneray committed
188
    public function getDataPath()
François Agneray's avatar
François Agneray committed
189
190
191
192
    {
        return $this->dataPath;
    }

François Agneray's avatar
François Agneray committed
193
    public function setDataPath($dataPath)
François Agneray's avatar
François Agneray committed
194
195
196
197
    {
        $this->dataPath = $dataPath;
    }

François Agneray's avatar
François Agneray committed
198
199
200
201
202
203
204
205
206
207
    public function getConfig()
    {
        return $this->config;
    }

    public function setConfig($config)
    {
        $this->config = $config;
    }

208
209
210
211
212
213
214
215
216
217
    public function getPublic()
    {
        return $this->public;
    }

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

François Agneray's avatar
François Agneray committed
218
    public function getProject()
François Agneray's avatar
François Agneray committed
219
220
221
    {
        return $this->project;
    }
François Agneray's avatar
François Agneray committed
222

François Agneray's avatar
François Agneray committed
223
    public function setProject($project)
François Agneray's avatar
François Agneray committed
224
225
226
227
    {
        $this->project = $project;
    }

François Agneray's avatar
François Agneray committed
228
    public function getDatasetFamily()
François Agneray's avatar
François Agneray committed
229
230
231
232
    {
        return $this->datasetFamily;
    }

François Agneray's avatar
François Agneray committed
233
    public function setDatasetFamily($datasetFamily)
François Agneray's avatar
François Agneray committed
234
235
236
237
    {
        $this->datasetFamily = $datasetFamily;
    }

238
    public function getAttributes()
239
240
241
242
    {
        return $this->attributes;
    }

François Agneray's avatar
François Agneray committed
243
244
245
246
247
248
249
250
251
252
253
    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
254
            'config' => $this->getConfig(),
255
            'public' => $this->getPublic(),
François Agneray's avatar
François Agneray committed
256
257
258
259
260
            'project_name' => $this->getProject()->getName(),
            'id_dataset_family' => $this->getDatasetFamily()->getId()
        ];
    }
}