BrightSide Workbench Full Report + Source Code
org.turro.dossier.offer.OffersVM Class Reference

Public Member Functions

void init (@ExecutionArgParam("dossierId") String dossierId)
 
void upload (@BindingParam("offer") DossierOffer offer, @BindingParam("medias") Media medias[])
 
void download (@BindingParam("document") Document document)
 
void deleteDoc (@BindingParam("document") Document document)
 
void delete (@BindingParam("offer") DossierOffer offer)
 
void create ()
 
void accept (@BindingParam("offer") DossierOffer offer)
 
void decline (@BindingParam("offer") DossierOffer offer)
 
List< DossierOffergetModel ()
 
boolean canUpload (DossierOffer offer)
 
boolean canDelete (DossierOffer offer)
 
boolean canCreate ()
 
boolean canAccept (DossierOffer offer)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 60 of file OffersVM.java.

Member Function Documentation

◆ accept()

void org.turro.dossier.offer.OffersVM.accept ( @BindingParam("offer") DossierOffer  offer)

Definition at line 152 of file OffersVM.java.

152  {
153  Messages.confirmAcceptation().add(offer.getDescription()).paragraph()
154  .add(I_.get("This action will accept the offer and send a notification.")).show(() -> {
155  offer.setAccepted(true);
156  offer.setDeclined(false);
157  getDao().saveObject(offer);
158  IElephantEntity iee = Entities.getController(dossier);
159  PushSenders.getPool()
160  .addContact(offer.getDossier().getDefaultResponsible())
161  .addContact(offer.getBidder())
162  .send(I_.get("Offer"), I_.get("Accepted"), iee.getEntityUrl());
163  MailSenders.getPool().setRoot("/offers")
164  .addContact(offer.getDossier().getDefaultResponsible())
165  .addContact(offer.getBidder())
166  .silentSendTemplate(iee, "accepted", I_.get("Accepted"));
167  });
168  }
Here is the call graph for this function:

◆ canAccept()

boolean org.turro.dossier.offer.OffersVM.canAccept ( DossierOffer  offer)

Definition at line 222 of file OffersVM.java.

222  {
223  return canAll && !(offer.isAccepted() || offer.isDeclined());
224  }
Here is the call graph for this function:

◆ canCreate()

boolean org.turro.dossier.offer.OffersVM.canCreate ( )

Definition at line 218 of file OffersVM.java.

218  {
219  return canCreate;
220  }

◆ canDelete()

boolean org.turro.dossier.offer.OffersVM.canDelete ( DossierOffer  offer)

Definition at line 214 of file OffersVM.java.

214  {
215  return canAll || !(offer.isAccepted() || offer.isDeclined());
216  }
Here is the call graph for this function:

◆ canUpload()

boolean org.turro.dossier.offer.OffersVM.canUpload ( DossierOffer  offer)

Definition at line 208 of file OffersVM.java.

208  {
209  return canAll ||
210  (canAddWorking && !(offer.isAccepted() || offer.isDeclined())) ||
211  (canAddFinal && offer.isAccepted());
212  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create()

void org.turro.dossier.offer.OffersVM.create ( )

Definition at line 119 of file OffersVM.java.

119  {
120  if(!canCreate) return;
121  Dialogs.title(I_.get("New offer"))
122  .width("800px")
123  .height("220px")
124  .addField(DialogField.field("Description").lines(5).maxLength(1000))
125  .onOk((dialogs) -> {
126  String description = dialogs.getValue("Description", String.class);
127  if(!Strings.isBlank(description)) {
128  DossierOffer offer = new DossierOffer();
129  offer.setDossier(dossier);
130  offer.setCreation(new Date());
131  offer.setDescription(description);
132  offer.setBidderId(contact.getId());
133  offer = getDao().saveEntity(offer);
134  BindUtils.postNotifyChange(null, null, OffersVM.this, "model");
135  IElephantEntity iee = Entities.getController(dossier);
136  PushSenders.getPool()
137  .addContact(offer.getDossier().getDefaultResponsible())
138  .addContact(offer.getBidder())
139  .send(I_.get("Offer"), I_.get("New offer"), iee.getEntityUrl());
140  MailSenders.getPool().setRoot("/offers")
141  .addContact(offer.getDossier().getDefaultResponsible())
142  .addContact(offer.getBidder())
143  .silentSendTemplate(iee, "new", I_.get("New offer"));
144  }
145  })
146  .emptyCancel()
147  .show();
148  }
Here is the call graph for this function:

◆ decline()

void org.turro.dossier.offer.OffersVM.decline ( @BindingParam("offer") DossierOffer  offer)

Definition at line 172 of file OffersVM.java.

172  {
173  Messages.confirmProcess().add(offer.getDescription()).paragraph()
174  .add(I_.get("This action will decline the offer and send a notification.")).show(() -> {
175  offer.setAccepted(false);
176  offer.setDeclined(true);
177  getDao().saveObject(offer);
178  IElephantEntity iee = Entities.getController(dossier);
179  PushSenders.getPool()
180  .addContact(offer.getDossier().getDefaultResponsible())
181  .addContact(offer.getBidder())
182  .send(I_.get("Offer"), I_.get("Declined"), iee.getEntityUrl());
183  MailSenders.getPool().setRoot("/offers")
184  .addContact(offer.getDossier().getDefaultResponsible())
185  .addContact(offer.getBidder())
186  .silentSendTemplate(iee, "declined", I_.get("Declined"));
187  });
188  }
Here is the call graph for this function:

◆ delete()

void org.turro.dossier.offer.OffersVM.delete ( @BindingParam("offer") DossierOffer  offer)

Definition at line 110 of file OffersVM.java.

110  {
111  Messages.confirmDeletion().add(offer.getDescription()).show(() -> {
112  offer.getFolder().remove();
113  getDao().deleteObject(offer);
114  BindUtils.postNotifyChange(null, null, OffersVM.this, "model");
115  });
116  }
void deleteObject(Object obj)
Definition: Dao.java:162
Here is the call graph for this function:

◆ deleteDoc()

void org.turro.dossier.offer.OffersVM.deleteDoc ( @BindingParam("document") Document  document)

Definition at line 102 of file OffersVM.java.

102  {
103  Messages.confirmDeletion().add(document.name()).show(() -> {
104  document.delete();
105  BindUtils.postNotifyChange(null, null, OffersVM.this, "model");
106  });
107  }
Here is the call graph for this function:

◆ download()

void org.turro.dossier.offer.OffersVM.download ( @BindingParam("document") Document  document)

Definition at line 97 of file OffersVM.java.

97  {
98  new FileWrapper(document.document()).download();
99  }
Here is the call graph for this function:

◆ getModel()

List<DossierOffer> org.turro.dossier.offer.OffersVM.getModel ( )

Definition at line 190 of file OffersVM.java.

190  {
191  if(prepareValues()) {
192  model = SqlClause.select("p")
193  .from("DossierOffer p")
194  .where().equal("p.dossier", dossier)
195  .startIf(!canAll)
196  .and().equal("p.bidderId", contact.getId())
197  .endIf()
198  .dao(getDao())
199  .resultList(DossierOffer.class);
200  if(!model.isEmpty()) canCreate = false;
201  return model;
202  }
203  return Collections.EMPTY_LIST;
204  }
Here is the call graph for this function:

◆ init()

void org.turro.dossier.offer.OffersVM.init ( @ExecutionArgParam("dossierId") String  dossierId)

Definition at line 68 of file OffersVM.java.

68  {
69  if(Strings.isBlank(dossierId)) {
70  dossierId = Executions.getCurrent().getParameter("dossierId");
71  }
72  this.dossier = getDao().find(Dossier.class, Long.valueOf(dossierId));
73  this.visual = DossierVisualElements.load().getElement("Offers");
74  }
VisualElement getElement(String name)
Here is the call graph for this function:

◆ upload()

void org.turro.dossier.offer.OffersVM.upload ( @BindingParam("offer") DossierOffer  offer,
@BindingParam("medias") Media  medias[] 
)

Definition at line 78 of file OffersVM.java.

78  {
79  if(canUpload(offer)) {
80  Folder folder = offer.getFolder();
81  for(Media media : medias) {
82  Medias.toFolder(media, folder);
83  }
84  IElephantEntity iee = Entities.getController(dossier);
85  PushSenders.getPool()
86  .addContact(offer.getDossier().getDefaultResponsible())
87  .addContact(offer.getBidder())
88  .send(I_.get("Offer"), I_.get("New documents"), iee.getEntityUrl());
89  MailSenders.getPool().setRoot("/offers")
90  .addContact(offer.getDossier().getDefaultResponsible())
91  .addContact(offer.getBidder())
92  .silentSendTemplate(iee, "newdocs", I_.get("New documents"));
93  }
94  }
boolean canUpload(DossierOffer offer)
Definition: OffersVM.java:208
Here is the call graph for this function:

The documentation for this class was generated from the following file: