1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2014 SURFnet bv |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\StepupMiddleware\ApiBundle\Identity\Entity; |
20
|
|
|
|
21
|
|
|
use Doctrine\ORM\Mapping as ORM; |
22
|
|
|
use JsonSerializable; |
23
|
|
|
use Surfnet\Stepup\Identity\Value\CommonName; |
24
|
|
|
use Surfnet\Stepup\Identity\Value\Email; |
25
|
|
|
use Surfnet\Stepup\Identity\Value\IdentityId; |
26
|
|
|
use Surfnet\Stepup\Identity\Value\Institution; |
27
|
|
|
use Surfnet\Stepup\Identity\Value\NameId; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @ORM\Table(name="view_ra_candidate") |
31
|
|
|
* @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaCandidateRepository", readOnly=true) |
32
|
|
|
*/ |
33
|
|
|
///** |
34
|
|
|
// * @ORM\Entity(repositoryClass="Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaCandidateRepository") |
35
|
|
|
// * @ORM\Table( |
36
|
|
|
// * indexes={ |
37
|
|
|
// * @ORM\Index(name="idx_ra_candidate_institution", columns={"institution"}), |
38
|
|
|
// * @ORM\Index(name="idx_ra_candidate_name_id", columns={"name_id"}), |
39
|
|
|
// * @ORM\Index(name="idxft_ra_candidate_email", columns={"email"}, flags={"FULLTEXT"}), |
40
|
|
|
// * @ORM\Index(name="idxft_ra_candidate_commonname", columns={"common_name"}, flags={"FULLTEXT"}), |
41
|
|
|
// * @ORM\Index(name="idx_ra_institution", columns={"ra_institution"}) |
42
|
|
|
// * }, |
43
|
|
|
// * uniqueConstraints={ |
44
|
|
|
// * @ORM\UniqueConstraint(name="idx_ra_candidate_unique_identity_institution", columns={"identity_id", "ra_institution"}) |
45
|
|
|
// * } |
46
|
|
|
// * ) |
47
|
|
|
// */ |
48
|
|
|
class RaCandidate implements JsonSerializable |
|
|
|
|
49
|
|
|
{ |
50
|
|
|
/** |
51
|
|
|
* @ORM\Id |
52
|
|
|
* @ORM\Column(length=36) |
53
|
|
|
* |
54
|
|
|
* @var string |
55
|
|
|
*/ |
56
|
|
|
public $identityId; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @ORM\Id |
60
|
|
|
* @ORM\Column(type="institution") |
61
|
|
|
* |
62
|
|
|
* @var Institution |
63
|
|
|
*/ |
64
|
|
|
public $raInstitution; |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @ORM\Column(type="institution") |
68
|
|
|
* |
69
|
|
|
* @var \Surfnet\Stepup\Identity\Value\Institution |
70
|
|
|
*/ |
71
|
|
|
public $institution; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @ORM\Column(type="stepup_name_id") |
75
|
|
|
* |
76
|
|
|
* @var \Surfnet\Stepup\Identity\Value\NameId |
77
|
|
|
*/ |
78
|
|
|
public $nameId; |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @ORM\Column(type="stepup_common_name") |
82
|
|
|
* |
83
|
|
|
* @var \Surfnet\Stepup\Identity\Value\CommonName |
84
|
|
|
*/ |
85
|
|
|
public $commonName; |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @ORM\Column(type="stepup_email") |
89
|
|
|
* |
90
|
|
|
* @var \Surfnet\Stepup\Identity\Value\Email |
91
|
|
|
*/ |
92
|
|
|
public $email; |
93
|
|
|
|
94
|
|
|
private function __construct() {} |
95
|
|
|
|
96
|
|
|
public static function nominate( |
97
|
|
|
IdentityId $identityId, |
98
|
|
|
Institution $institution, |
99
|
|
|
NameId $nameId, |
100
|
|
|
CommonName $commonName, |
101
|
|
|
Email $email, |
102
|
|
|
Institution $raInstitution |
103
|
|
|
) { |
104
|
|
|
$candidate = new self(); |
105
|
|
|
$candidate->identityId = (string) $identityId; |
106
|
|
|
$candidate->institution = $institution; |
107
|
|
|
$candidate->nameId = $nameId; |
108
|
|
|
$candidate->commonName = $commonName; |
109
|
|
|
$candidate->email = $email; |
110
|
|
|
$candidate->raInstitution = $raInstitution; |
111
|
|
|
|
112
|
|
|
return $candidate; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
View Code Duplication |
public function jsonSerialize() |
|
|
|
|
116
|
|
|
{ |
117
|
|
|
return [ |
118
|
|
|
'identity_id' => $this->identityId, |
119
|
|
|
'institution' => $this->institution, |
120
|
|
|
'common_name' => $this->commonName, |
121
|
|
|
'email' => $this->email, |
122
|
|
|
'name_id' => $this->nameId, |
123
|
|
|
'ra_institution' => $this->raInstitution, |
124
|
|
|
]; |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|