Skip to content

Commit

Permalink
[GEWISDB] Move any Member association to SubDecision itself
Browse files Browse the repository at this point in the history
Changes from GEWISDB upstream, see GEWIS/gewisdb#363. Necessary for
GDPR export functionality.
  • Loading branch information
tomudding committed Dec 24, 2023
1 parent d8225a5 commit 83fe855
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 104 deletions.
30 changes: 30 additions & 0 deletions module/Decision/src/Model/SubDecision.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ enumType: MeetingTypes::class,
#[Column(type: 'text')]
protected string $content;

/**
* The member involved in this sub-decision.
*
* Not all sub-decisions require this, as such it is nullable. However, sub-decisions that need the guarantee that
* this is not null or need to specify an inverse side can do so using an association override.
*/
#[ManyToOne(targetEntity: Member::class)]
#[JoinColumn(
name: 'lidnr',
referencedColumnName: 'lidnr',
nullable: true,
)]
protected ?Member $member = null;

/**
* Get the decision.
*/
Expand Down Expand Up @@ -205,6 +219,22 @@ public function setNumber(int $number): void
$this->number = $number;
}

/**
* Get the member.
*/
public function getMember(): ?Member
{
return $this->member;
}

/**
* Set the member.
*/
public function setMember(Member $member): void
{
$this->member = $member;
}

/**
* Get the content.
*/
Expand Down
38 changes: 14 additions & 24 deletions module/Decision/src/Model/SubDecision/Board/Installation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,27 @@
use Decision\Model\BoardMember;
use Decision\Model\Member;
use Decision\Model\SubDecision;
use Doctrine\ORM\Mapping\AssociationOverride;
use Doctrine\ORM\Mapping\AssociationOverrides;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToOne;

/**
* Installation as board member.
*/
#[Entity]
#[AssociationOverrides([
new AssociationOverride(
name: 'member',
joinColumns: new JoinColumn(
name: 'lidnr',
referencedColumnName: 'lidnr',
nullable: false,
),
),
])]
class Installation extends SubDecision
{
/**
Expand All @@ -26,21 +37,6 @@ class Installation extends SubDecision
#[Column(type: 'string')]
protected string $function;

/**
* Member.
*
* Note that only members that are older than 18 years can be board members.
* Also, honorary, external and extraordinary members cannot be board members.
* (See the Statuten, Art. 13 Lid 2.
*/
// TODO: Inversed relation
#[ManyToOne(targetEntity: Member::class)]
#[JoinColumn(
name: 'lidnr',
referencedColumnName: 'lidnr',
)]
protected Member $member;

/**
* The date at which the installation is in effect.
*/
Expand Down Expand Up @@ -92,20 +88,14 @@ public function setFunction(string $function): void

/**
* Get the member.
*
* @psalm-suppress InvalidNullableReturnType
*/
public function getMember(): Member
{
return $this->member;
}

/**
* Set the member.
*/
public function setMember(Member $member): void
{
$this->member = $member;
}

/**
* Get the date.
*/
Expand Down
29 changes: 0 additions & 29 deletions module/Decision/src/Model/SubDecision/Budget.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,16 @@
namespace Decision\Model\SubDecision;

use DateTime;
use Decision\Model\Member;
use Decision\Model\SubDecision;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;

/**
* Budget decision.
*/
#[Entity]
class Budget extends SubDecision
{
/**
* Budget author.
*/
#[ManyToOne(targetEntity: Member::class)]
#[JoinColumn(
name: 'lidnr',
referencedColumnName: 'lidnr',
)]
protected Member $author;

/**
* Name of the budget.
*/
Expand Down Expand Up @@ -61,22 +48,6 @@ class Budget extends SubDecision
#[Column(type: 'boolean')]
protected bool $changes;

/**
* Get the author.
*/
public function getAuthor(): Member
{
return $this->author;
}

/**
* Set the author.
*/
public function setAuthor(Member $author): void
{
$this->author = $author;
}

/**
* Get the name.
*/
Expand Down
37 changes: 15 additions & 22 deletions module/Decision/src/Model/SubDecision/Installation.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,29 @@
use Decision\Model\OrganMember;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping\AssociationOverride;
use Doctrine\ORM\Mapping\AssociationOverrides;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToMany;
use Doctrine\ORM\Mapping\OneToOne;

/**
* Installation into organ.
*/
#[Entity]
#[AssociationOverrides([
new AssociationOverride(
name: 'member',
joinColumns: new JoinColumn(
name: 'lidnr',
referencedColumnName: 'lidnr',
nullable: false,
),
inversedBy: 'installations',
),
])]
class Installation extends FoundationReference
{
/**
Expand All @@ -27,19 +39,6 @@ class Installation extends FoundationReference
#[Column(type: 'string')]
protected string $function;

/**
* Member.
*/
#[ManyToOne(
targetEntity: Member::class,
inversedBy: 'installations',
)]
#[JoinColumn(
name: 'lidnr',
referencedColumnName: 'lidnr',
)]
protected Member $member;

/**
* Reappointment subdecisions if this installation was prolonged (can be done multiple times).
*
Expand Down Expand Up @@ -92,20 +91,14 @@ public function setFunction(string $function): void

/**
* Get the member.
*
* @psalm-suppress InvalidNullableReturnType
*/
public function getMember(): Member
{
return $this->member;
}

/**
* Set the member.
*/
public function setMember(Member $member): void
{
$this->member = $member;
}

/**
* Get the reappointments, if they exist.
*
Expand Down
29 changes: 0 additions & 29 deletions module/Decision/src/Model/SubDecision/Key/Granting.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,11 @@
use Decision\Model\SubDecision;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\OneToOne;

#[Entity]
class Granting extends SubDecision
{
/**
* The member who is granted a keycode of GEWIS.
*/
#[ManyToOne(targetEntity: Member::class)]
#[JoinColumn(
name: 'lidnr',
referencedColumnName: 'lidnr',
nullable: true,
)]
protected ?Member $grantee = null;

/**
* Till when the keycode is granted.
*/
Expand All @@ -52,22 +39,6 @@ class Granting extends SubDecision
)]
protected Keyholder $keyholder;

/**
* Get the grantee.
*/
public function getGrantee(): ?Member
{
return $this->grantee;
}

/**
* Set the grantee.
*/
public function setGrantee(Member $grantee): void
{
$this->grantee = $grantee;
}

/**
* Get the date.
*/
Expand Down

0 comments on commit 83fe855

Please sign in to comment.