Commit dafd3c96 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Fix : Méthode manquante pour la commande de synchronisation des personnes avec l'option --purge

Up : Les personnes à supprimer mais liée à un Lot de travail sont correctement indiquées
Fix : La liaison entre une personne et une notification ne bloque plus la suppression
Fix : La liaison entre une personne et un document uploadé ne bloque plus la suppression
Note : Ce patch implique une mise à jour du schema de la base
parent 9a914658
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -201,6 +201,10 @@ class ConnectorPersonREST extends AbstractConnector
                    if ($this->getOptionPurge()) {
                        $activeIn = [];

                        if (count($personOscarToDelete->getWorkPackages()) > 0) {
                            $activeIn[] = "feuille de temps";
                        }

                        if (count($personOscarToDelete->getActivities()) > 0) {
                            $activeIn[] = "activité";
                        }
+1 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ abstract class AbstractVersionnedDocument
     *
     * @var Person
     * @ORM\ManyToOne(targetEntity="Person")
     * @ORM\JoinColumn(onDelete="SET NULL")
     */
    private $person;

+2 −1
Original line number Diff line number Diff line
@@ -34,7 +34,8 @@ class NotificationPerson

    /**
     * @var Person
     * @ORM\ManyToOne(targetEntity="Person")
     * @ORM\ManyToOne(targetEntity="Person", inversedBy="notifications")
     * @ORM\JoinColumn(onDelete="CASCADE")
     */
    private $person;

+21 −6
Original line number Diff line number Diff line
@@ -87,7 +87,6 @@ class OrganizationPerson implements ILoggable
    }



    public function getRole()
    {
        if ($this->getRoleObj()) {
@@ -96,7 +95,8 @@ class OrganizationPerson implements ILoggable
        return "rôle inconnu";
    }

    public function isPrincipal(){
    public function isPrincipal()
    {
        if ($this->getRoleObj()) {
            return $this->getRoleObj()->isPrincipal();
        }
@@ -139,7 +139,8 @@ class OrganizationPerson implements ILoggable
        return $this;
    }

    public function idLeader() {
    public function idLeader()
    {
        return in_array($this->getRole(), ['Responsable']);
    }

@@ -152,4 +153,18 @@ class OrganizationPerson implements ILoggable
    {
        return $this->getOrganization();
    }

    public function __toString(): string
    {
        return sprintf(
            "OrganizationPerson[%s-%s] %s > %s (%s)",
            $this->getId(),
            $this->getOrigin(),
            $this->getOrganization(),
            $this->getPerson(),
            $this->getRoleObj()
        );
    }


}
+27 −0
Original line number Diff line number Diff line
@@ -129,6 +129,15 @@ class Person implements ResourceInterface
     */
    protected $activities;

    /**
     * Activités de recherche
     *
     * @var ArrayCollection
     * @ORM\OneToMany(targetEntity="NotificationPerson", mappedBy="person")
     */

    protected $notifications;

    /**
     * Organization
     *
@@ -395,6 +404,24 @@ class Person implements ResourceInterface
        return $this;
    }

    /**
     * Retourne uniquement les affectations (PersonOrganization)
     * issue de la synchronisation.
     *
     * @return OrganizationPerson[]
     */
    public function getOrganizationsSync(): array
    {
        $syncOrganizations = [];
        /** @var OrganizationPerson $organizationPerson */
        foreach ($this->getOrganizations() as $organizationPerson) {
            if( $organizationPerson->isSync() ){
                $syncOrganizations[] = $organizationPerson;
            }
        }
        return $syncOrganizations;
    }


    public function getLeadedOrganizations()
    {