19 package org.turro.visual;
21 import java.util.Collection;
22 import java.util.EnumSet;
23 import java.util.HashSet;
25 import org.turro.dossier.dossier.ParticipantSet;
26 import org.turro.dossier.entity.Dossier;
27 import org.turro.dossier.entity.Issue;
28 import org.turro.dossier.entity.IssueResolution;
29 import org.turro.dossier.entity.IssueType;
30 import org.turro.dossier.entity.ParticipantRole;
31 import org.turro.phase.PhaseType;
32 import org.turro.plugin.contacts.IContact;
40 private Set<Integer> phases;
41 private EnumSet<PhaseType> phaseTypes;
42 private EnumSet<ParticipantRole> roles;
43 private HashSet<String> discriminators;
44 private Boolean showAllAttachments, showParticipants, showAllIssues, receiveAllEmails, bindingVote,
45 driver, coordinator, beneficiary, offerer, research, funding, support;
46 private Boolean directOwner, participates, branchAdmin;
53 this.showAllAttachments = showAllAttachments;
58 this.showParticipants = showParticipants;
63 this.showAllIssues = showAllIssues;
68 this.receiveAllEmails = receiveAllEmails;
73 this.bindingVote = bindingVote;
83 this.coordinator = coordinator;
88 this.beneficiary = beneficiary;
93 this.offerer = offerer;
98 this.research = research;
103 this.funding = funding;
108 this.support = support;
113 this.directOwner = directOwner;
118 this.participates = participates;
123 this.branchAdmin = branchAdmin;
130 phases =
new HashSet<>();
138 if(phaseTypes ==
null) {
139 phaseTypes = EnumSet.of(type);
141 phaseTypes.add(type);
148 roles = EnumSet.of(role);
156 if(discriminators ==
null) {
157 discriminators =
new HashSet<>();
159 discriminators.add(discriminator);
165 return roles ==
null && discriminators ==
null && participates ==
null &&
166 directOwner ==
null && branchAdmin ==
null && showAllAttachments ==
null &&
167 showParticipants ==
null && showAllIssues ==
null && receiveAllEmails ==
null &&
168 bindingVote ==
null && driver ==
null && coordinator ==
null &&
169 beneficiary ==
null && offerer ==
null && research ==
null &&
170 funding ==
null && support ==
null;
184 return checkRoles(dpl, contact) ||
185 checkDiscriminators(dpl, contact) ||
186 checkAttributes(dpl, contact) ||
187 checkDirectOwner(entity, contact) ||
188 checkBranchAdmin(entity, contact) ||
189 checkParticipates(dpl, contact);
195 getScript().addVariable(
"dossier", entity);
197 return super.checkEval(entity, contact);
205 if(dpl.
isRole(contact, role)) {
213 private boolean checkDiscriminators(ParticipantSet dpl, IContact contact) {
214 if(discriminators !=
null) {
215 for(String discriminator : discriminators) {
216 if(dpl.isParticipantByDiscriminator(contact, discriminator)) {
224 private boolean checkAttributes(ParticipantSet dpl, IContact contact) {
225 return (showAllAttachments ==
null ?
false : showAllAttachments.equals(dpl.isShowAllAttachments(contact))) ||
226 (showParticipants ==
null ? false : showParticipants.equals(dpl.isShowParticipants(contact))) ||
227 (showAllIssues ==
null ?
false : showAllIssues.equals(dpl.isShowAllIssues(contact))) ||
228 (receiveAllEmails ==
null ?
false : receiveAllEmails.equals(dpl.isReceiveAllEmails(contact))) ||
229 (bindingVote ==
null ?
false : bindingVote.equals(dpl.isBindingVote(contact))) ||
230 (driver ==
null ?
false : driver.equals(dpl.isDriver(contact))) ||
231 (coordinator ==
null ?
false : coordinator.equals(dpl.isCoordinator(contact))) ||
232 (beneficiary ==
null ?
false : beneficiary.equals(dpl.isBeneficiary(contact))) ||
233 (offerer ==
null ?
false : offerer.equals(dpl.isOfferer(contact))) ||
234 (research ==
null ?
false : research.equals(dpl.isResearch(contact))) ||
235 (funding ==
null ?
false : funding.equals(dpl.isFunding(contact))) ||
236 (support ==
null ?
false : support.equals(dpl.isSupport(contact))) ||
237 (branchAdmin ==
null ?
false : branchAdmin.equals(dpl.isAdmin(contact)));
240 private boolean checkParticipates(ParticipantSet dpl, IContact contact) {
241 return isNullOrFalse(participates) ? false : dpl.isParticipant(contact);
244 private boolean checkDirectOwner(Dossier dossier, IContact contact) {
245 return isNullOrFalse(directOwner) ? false : dossier.isDirectOwner(contact);
248 private boolean checkBranchAdmin(Dossier dossier, IContact contact) {
249 return isNullOrFalse(branchAdmin) ? false : dossier.isBranchAdmin(contact);
boolean isRole(IContact contact, ParticipantRole role)
boolean isDirectOwner(IContact contact)
ParticipantSet< IDossierParticipant > getFullParticipants()
Collection< Issue > getIssuesByType(IssueType type)
boolean isBranchAdmin(IContact contact)
IssueResolution getResolution()
ParticipantSet< IssueParticipant > getIssueParticipants()
PhaseDefinition getPhaseDefinition()
boolean anyTypeMatch(Collection< PhaseType > types)
boolean canCreateOffer(Dossier dossier, IContact contact)
DossierVisualElement setDriver(Boolean driver)
DossierVisualElement setDirectOwner(Boolean directOwner)
boolean isWinReporter(Issue issue, IContact contact)
boolean canShowOffer(Issue issue, IContact contact)
boolean canShowAddDocsOffer(Issue issue, IContact contact)
DossierVisualElement setResearch(Boolean research)
DossierVisualElement setShowParticipants(Boolean showParticipants)
boolean canAddFinalOffer(Dossier dossier, IContact contact)
DossierVisualElement setShowAllIssues(Boolean showAllIssues)
DossierVisualElement addPhase(int phase)
DossierVisualElement addDiscriminator(String discriminator)
boolean participatesAs(Dossier dossier, String discriminator, IContact contact)
boolean canShowOffer(Dossier dossier, IContact contact)
DossierVisualElement setFunding(Boolean funding)
DossierVisualElement addRole(ParticipantRole role)
boolean isInComission(Dossier dossier, IContact contact)
DossierVisualElement setBranchAdmin(Boolean branchAdmin)
boolean participates(Dossier dossier, IContact contact)
boolean isOwnResponsible(Issue issue, IContact contact)
DossierVisualElement setCoordinator(Boolean coordinator)
boolean emptyEntityConstraints()
DossierVisualElement(String name, DossierVisualElements factory)
boolean isPartner(IContact contact)
boolean canShowUploadOffer(Dossier dossier, IContact contact)
DossierVisualElement setParticipates(Boolean participates)
boolean isDirectOwner(Dossier dossier, IContact contact)
boolean checkAnyMatch(Dossier entity, IContact contact)
DossierVisualElement setBindingVote(Boolean bindingVote)
boolean checkEval(Dossier entity, IContact contact)
DossierVisualElement setOfferer(Boolean offerer)
boolean isWinResponsible(Issue issue, IContact contact)
Collection< Issue > getIssuesByType(Dossier dossier, String type)
DossierVisualElement setShowAllAttachments(Boolean showAllAttachments)
DossierVisualElement setSupport(Boolean support)
boolean canAddWorkingOffer(Dossier dossier, IContact contact)
boolean isOwnReporter(Issue issue, IContact contact)
DossierVisualElement setBeneficiary(Boolean beneficiary)
boolean isPatron(IContact contact)
boolean isAdministrator(Dossier dossier, IContact contact)
DossierVisualElement addPhaseType(PhaseType type)
boolean checkAllMatch(Dossier entity, IContact contact)
DossierVisualElement setReceiveAllEmails(Boolean receiveAllEmails)
VisualElement getElement(String name)
boolean checkContact(IContact contact)
boolean isNullOrFalse(Boolean value)