BrightSide Workbench Full Report + Source Code
ChangePhaseNotification.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2017 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.dossier.project;
20 
21 import java.util.Collection;
22 import java.util.EnumSet;
23 import org.turro.action.Contacts;
24 import org.turro.assistant.AssistantSet;
25 import org.turro.dossier.entity.Dossier;
26 import org.turro.dossier.entity.IDossierParticipant;
27 import org.turro.i18n.I_;
28 import org.turro.marker.ElephantMarker;
29 import org.turro.phase.PhaseDefinition;
30 import org.turro.phase.PhaseType;
31 import org.turro.plugin.contacts.IContact;
32 
38 
40  super(dossier);
41  }
42 
43  @Override
44  public void sendNotification() {
45  super.send("change-phase", I_.get("Changed to") + ": " + I_.get(dossier.getProject().getPhaseDefinition().getName()));
46  }
47 
48  @Override
51  AssistantSet as = new AssistantSet();
52  Collection<IDossierParticipant> coordinators = dossier.getParticipationsList().getCoordinators();
53  for(IDossierParticipant coordinator : coordinators) {
54  as.addContact(coordinator.getIContact(), coordinator);
55  }
56  Collection<IDossierParticipant> responsibles = dossier.getDirectOwners();
57  for(IDossierParticipant responsible : responsibles) {
58  as.addContact(responsible.getIContact(), responsible);
59  }
60  for(IContact c : Contacts.getBySyndication("brightside_admin")) {
61  as.addContact(c, null);
62  }
64  for(IContact c : Contacts.getBySyndication("patron")) {
65  as.addContact(c, null);
66  }
67  }
69  Collection<IDossierParticipant> offerers = dossier.getParticipationsList().getOfferers();
70  for(IDossierParticipant offerer : offerers) {
71  as.addContact(offerer.getIContact(), offerer);
72  }
73  }
74  if(phase.anyTypeMatch(EnumSet.of(PhaseType.EXECUTION, PhaseType.ARCHIVE))) {
75  Collection<IDossierParticipant> offerers = dossier.getParticipationsList().getBeneficiaries();
76  for(IDossierParticipant offerer : offerers) {
77  as.addContact(offerer.getIContact(), offerer);
78  }
79  }
81  for(IContact c : Contacts.getBySyndication("partner")) {
82  as.addContact(c, null);
83  }
84  for(IContact c : Contacts.getBySyndication("collaborator_privileged")) {
85  as.addContact(c, null);
86  }
87  }
89  for(IDossierParticipant comissioners : dossier.getFullParticipants()) {
90  as.addContact(comissioners.getIContact(), comissioners);
91  }
92  }
93  return as;
94  }
95 
96  @Override
97  protected void initMarker(ElephantMarker marker) {
98  }
99 
100 }
static List< IContact > getBySyndication(String syndication)
Definition: Contacts.java:130
void addContact(IContact contact, Object relationEntity)
ParticipantSet< IDossierParticipant > getFullParticipants()
Definition: Dossier.java:399
List< IDossierParticipant > getDirectOwners()
Definition: Dossier.java:591
DossierParticipationsList getParticipationsList()
Definition: Dossier.java:436
static String get(String msg)
Definition: I_.java:41
boolean anyTypeMatch(Collection< PhaseType > types)