BrightSide Workbench Full Report + Source Code
DossierEdit.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 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 package org.turro.dossier.zul.dossier;
19 
20 import java.util.Date;
21 import java.util.Iterator;
22 import org.turro.auth.Authentication;
23 import org.turro.contacts.Contact;
24 import org.turro.dossier.dossier.DossierWrapper;
25 import org.turro.dossier.entity.Dossier;
26 import org.turro.dossier.entity.DossierVersion;
27 import org.turro.dossier.entity.Participant;
28 import org.turro.dossier.entity.ParticipantRole;
29 import org.turro.elephant.zkoss.ModalWindow;
30 import org.turro.log.SystemLogType;
31 import org.turro.log.SystemLogger;
32 
37 public class DossierEdit extends ModalWindow {
38 
39  private Contact subject;
40 
41  public DossierEdit() throws InterruptedException {
42  super();
43  }
44 
45  public DossierEdit(String title, String border, boolean closable) throws InterruptedException {
46  super(title, border, closable);
47  }
48 
49  public void setSubject(Contact newValue) {
50  subject = newValue;
51  }
52 
53  public Dossier applyChanges(Dossier dossier) {
54  if(dossier.getId() == null && dossier.getParticipants().isEmpty()) {
55  DossierWrapper dw = new DossierWrapper(dossier);
56  if(!dw.isOwner() && !dw.isAssistant()) {
58  }
59  }
60  if(subject != null) {
61  Participant s = new Participant();
62  s.setCreation(new Date());
63  s.setIdContact(subject.getId());
64  s.setName(subject.getName());
66  s.setDossier(dossier);
67  dossier.getParticipants().add(s);
68  }
69  Iterator<DossierVersion> it = dossier.getVersions().iterator();
70  while(it.hasNext()) {
71  DossierVersion or = it.next();
72  if(or.isEmpty()) {
73  or.setDossier(null);
74  it.remove();
75  }
76  }
77  dossier = new DossierWrapper(dossier).save();
79  dossier.getFullDescription());
80  return dossier;
81  }
82 
83 }
Participant addOwner(IContact contact)
Definition: Dossier.java:525
Set< Participant > getParticipants()
Definition: Dossier.java:175
Set< DossierVersion > getVersions()
Definition: Dossier.java:215
void setIdContact(String idContact)
void setDossier(Dossier dossier)
void setRole(ParticipantRole role)
Dossier applyChanges(Dossier dossier)
DossierEdit(String title, String border, boolean closable)
static ISystemLogger getInstance()
void doLog(SystemLogType type, Object entity, String comment, Serializable data)