/
PrintSpoolerBP.java
317 lines (306 loc) · 12.4 KB
/
PrintSpoolerBP.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
package it.cnr.contab.reports.bp;
import it.cnr.contab.config00.bulk.Parametri_enteBulk;
import it.cnr.contab.config00.bulk.ServizioPecBulk;
import it.cnr.contab.config00.sto.bulk.CdrBulk;
import it.cnr.contab.config00.sto.bulk.CdsBulk;
import it.cnr.contab.config00.sto.bulk.Tipo_unita_organizzativaHome;
import it.cnr.contab.config00.sto.bulk.UnitaOrganizzativaPecBulk;
import it.cnr.contab.config00.sto.bulk.Unita_organizzativaBulk;
import it.cnr.contab.reports.bulk.Print_spoolerBulk;
import it.cnr.contab.utenze00.bp.CNRUserContext;
import it.cnr.contab.util.Utility;
import it.cnr.jada.action.ActionContext;
import it.cnr.jada.action.BusinessProcessException;
import it.cnr.jada.action.Config;
import it.cnr.jada.action.HttpActionContext;
import it.cnr.jada.bulk.BulkInfo;
import it.cnr.jada.bulk.ValidationException;
import it.cnr.jada.comp.ComponentException;
import it.cnr.jada.firma.DatiPEC;
import it.cnr.jada.firma.FirmaInfos;
import it.cnr.jada.util.jsp.Button;
import it.cnr.jada.util.jsp.JSPUtils;
import java.rmi.RemoteException;
import java.util.Arrays;
import javax.ejb.EJBException;
import javax.servlet.http.HttpServletRequest;
/**
* Insert the type's description here.
* Creation date: (11/04/2002 17:28:04)
* @author: CNRADM
*/
public class PrintSpoolerBP extends it.cnr.jada.util.action.SelezionatoreListaBP implements FirmaInfos {
private boolean signEnabled;
private boolean signFile;
private DatiPEC datiPEC = new DatiPEC();
public static String PEC_PROTOCOLLO = "PROTOCOLLO";
public static String PEC_BILANCIO = "BILANCIO";
/**
* SpoolerStatusBP constructor comment.
* @param function java.lang.String
*/
public PrintSpoolerBP() {
super();
table.setMultiSelection(true);
//table = new it.cnr.jada.util.jsp.Table("main");
//table.setMultiSelection(true);
//table.setOnselect("javascript:select");
//table.setReadonly(true);
//table.setStatus(it.cnr.jada.util.action.FormController.EDIT);
//table.setEditableOnFocus(false);
//table.setOrderable(null);
setBulkInfo(BulkInfo.getBulkInfo(Print_spoolerBulk.class));
//setColumns(BulkInfo.getBulkInfo(Print_spoolerBulk.class).getColumnFieldPropertyDictionary());
//table.setSelectable(true);
//table.setReadonly(true);
//table.setName("main");
}
public it.cnr.contab.reports.ejb.OfflineReportComponentSession createComponentSession() throws BusinessProcessException {
return
(it.cnr.contab.reports.ejb.OfflineReportComponentSession)createComponentSession(
"BREPORTS_EJB_OfflineReportComponentSession",
it.cnr.contab.reports.ejb.OfflineReportComponentSession.class);
}
public it.cnr.jada.util.jsp.Button[] createToolbar() {
Button[] toolbar = new Button[4];
int i = 0;
toolbar[i++] = new it.cnr.jada.util.jsp.Button(it.cnr.jada.util.Config.getHandler().getProperties(getClass()),"Toolbar.refresh");
toolbar[i++] = new it.cnr.jada.util.jsp.Button(it.cnr.jada.util.Config.getHandler().getProperties(getClass()),"Toolbar.print");
toolbar[i++] = new it.cnr.jada.util.jsp.Button(it.cnr.jada.util.Config.getHandler().getProperties(getClass()),"Toolbar.delete");
toolbar[i++] = new it.cnr.jada.util.jsp.Button(it.cnr.jada.util.Config.getHandler().getProperties(getClass()),"Toolbar.close");
return toolbar;
}
protected void init(Config config,ActionContext context) throws BusinessProcessException {
super.init(config,context);
Print_spoolerBulk print_spooler = new Print_spoolerBulk();
print_spooler.setTiVisibilita(print_spooler.TI_VISIBILITA_UTENTE);
setModel(context,print_spooler);
refresh(context);
}
public boolean isPrintButtonEnabled() {
return
getFocusedElement() != null &&
((Print_spoolerBulk)getFocusedElement()).isEseguita();
}
public boolean isSignButtonEnabled() {
return
getFocusedElement() != null &&
((Print_spoolerBulk)getFocusedElement()).isEseguita();
}
public void refresh(ActionContext context) throws BusinessProcessException {
try {
setIterator(context,createComponentSession().queryJobs(
context.getUserContext(),
((Print_spoolerBulk)getModel()).getTiVisibilita()));
} catch(Throwable e) {
throw new BusinessProcessException(e);
}
}
/* 11/09/2009 R.P. Eliminato per impostare il model e visualizzare le info della mail
*
* Riscritto perchè in questo caso non voglio che quando l'utente
* seleziona una riga nel selezionatore venga anche impostato
* il modello del BulkBP
protected void setFocusedElement(it.cnr.jada.action.ActionContext context,Object element) throws it.cnr.jada.action.BusinessProcessException {
OggettoBulk model = getModel();
super.setFocusedElement(context,element);
setModel(context,model);
}
*/
public void writeToolbar(javax.servlet.jsp.PageContext pageContext) throws java.io.IOException,javax.servlet.ServletException {
Button[] toolbar = getToolbar();
Print_spoolerBulk print_spool = (Print_spoolerBulk)getFocusedElement();
if (print_spool != null && Print_spoolerBulk.STATO_ESEGUITA.equalsIgnoreCase(print_spool.getStato()))
toolbar[1].setHref("doPrint('"+ JSPUtils.getAppRoot((HttpServletRequest) pageContext.getRequest()) + "offline_report/"+print_spool.getNomeFile()+"?pg="+print_spool.getPgStampa().longValue()+"')");
else
toolbar[1].setHref(null);
writeToolbar(pageContext.getOut(), toolbar);
}
public void sign(ActionContext context) throws BusinessProcessException {
try {
caricaDatiPEC(context);
setSignEnabled(true);
setSignFile(true);
} catch(Throwable e) {
throw new BusinessProcessException(e);
}
}
public boolean isSignEnabled() {
return signEnabled;
}
public void setSignEnabled(boolean signEnabled) {
this.signEnabled = signEnabled;
}
public boolean isSignFile() {
return signFile;
}
public void setSignFile(boolean signFile) {
this.signFile = signFile;
}
public String getFileName() {
Print_spoolerBulk print_spool = (Print_spoolerBulk)getFocusedElement();
if (print_spool != null)
return print_spool.getNomeFile();
else
return (null);
}
public String getDownloadFile(javax.servlet.jsp.PageContext pageContext) {
Print_spoolerBulk print_spool = (Print_spoolerBulk)getFocusedElement();
if (print_spool != null && print_spool.STATO_ESEGUITA.equalsIgnoreCase(print_spool.getStato()))
return JSPUtils.buildAbsoluteUrl(
pageContext,
null,
"offline_report/"+print_spool.getNomeFile());
else
return (null);
}
public String getPgStampa() {
Print_spoolerBulk print_spool = (Print_spoolerBulk)getFocusedElement();
if (print_spool!=null)
return ""+print_spool.getPgStampa().longValue();
else
return null;
}
public String getUploadFile(javax.servlet.jsp.PageContext pageContext) {
String actionExtension = pageContext.getServletConfig().getInitParameter("extension");
if(actionExtension == null)
actionExtension = ".do";
String path = getDefaultAction()+actionExtension;
return JSPUtils.buildAbsoluteUrl(
pageContext,
null,
path);
}
public boolean isEMailEnabled(){
if (this.getModel()!=null && ((Print_spoolerBulk)this.getModel()).getFlEmail() != null && (((Print_spoolerBulk)this.getModel()).getFlEmail()))
return true;
return false;
}
public String descrizione() {
Print_spoolerBulk pbulk = (Print_spoolerBulk) getFocusedElement();
if (pbulk!=null)
return pbulk.getDsStampa();
return null;
}
public DatiPEC datiPEC() {
return datiPEC;
}
public void caricaDatiPEC(ActionContext context) throws ValidationException {
Print_spoolerBulk pbulk = (Print_spoolerBulk) getFocusedElement();
String cdServizioPEC=null;
if (pbulk!=null)
cdServizioPEC = pbulk.getCd_servizio_pec();
boolean testMode=true;
Parametri_enteBulk parametriEnte = null;
try {
parametriEnte = Utility.createParametriEnteComponentSession().getParametriEnte(context.getUserContext());
} catch (ComponentException e) {
handleException(e);
} catch (EJBException e) {
handleException(e);
} catch (RemoteException e) {
handleException(e);
}
// PEC del protocollo
ServizioPecBulk servizioPecProtocollo = null;
try {
servizioPecProtocollo = Utility.createParametriEnteComponentSession().getServizioPec(context.getUserContext(),PEC_PROTOCOLLO);
} catch (ComponentException e) {
handleException(e);
} catch (EJBException e) {
handleException(e);
} catch (RemoteException e) {
handleException(e);
}
if (servizioPecProtocollo == null)
throw new ValidationException("Non è presente l'email per l'invio della posta certificata per l'ufficio del Protocollo. Impossibile procedere!");
// PEC derivata dalla stampa specifica
ServizioPecBulk servizioPec = null;
try {
servizioPec = Utility.createParametriEnteComponentSession().getServizioPec(context.getUserContext(),cdServizioPEC);
} catch (ComponentException e) {
handleException(e);
} catch (EJBException e) {
handleException(e);
} catch (RemoteException e) {
handleException(e);
}
if (servizioPec == null)
throw new ValidationException("L'ufficio di competenza per l'invio della posta certificata non è definito. Impossibile procedere!");
if (!parametriEnte.getTipo_db().equals(Parametri_enteBulk.DB_PRODUZIONE)){
testMode=true;
}
CdsBulk cds = null;
Unita_organizzativaBulk uo = null;
CdrBulk cdr = null;
try {
cds = Utility.createParametriEnteComponentSession().getCds(context.getUserContext(),CNRUserContext.getCd_cds((CNRUserContext)context.getUserContext()));
uo = Utility.createParametriEnteComponentSession().getUo(context.getUserContext(),CNRUserContext.getCd_unita_organizzativa((CNRUserContext)context.getUserContext()));
cdr = Utility.createParametriEnteComponentSession().getCdr(context.getUserContext(),CNRUserContext.getCd_cdr((CNRUserContext)context.getUserContext()));
} catch (ComponentException e) {
handleException(e);
} catch (EJBException e) {
handleException(e);
} catch (RemoteException e) {
handleException(e);
}
String cdUoPec = null;
if (cds.getCd_tipo_unita().equals(
Tipo_unita_organizzativaHome.TIPO_UO_SAC)) {
datiPEC.setCds("000");
datiPEC.setDsCds("CNR - Consiglio Nazionale delle Ricerche");
datiPEC.setUo(CNRUserContext
.getCd_unita_organizzativa((CNRUserContext) context
.getUserContext()));
datiPEC.setDsUo(uo.getDs_unita_organizzativa());
cdUoPec = CNRUserContext
.getCd_unita_organizzativa((CNRUserContext) context
.getUserContext());
} else {
datiPEC.setCds(CNRUserContext.getCd_cds((CNRUserContext) context
.getUserContext()));
datiPEC.setDsCds(cds.getDs_unita_organizzativa());
datiPEC.setUo(CNRUserContext.getCd_cds((CNRUserContext) context
.getUserContext()));
datiPEC.setDsUo(cds.getDs_unita_organizzativa());
cdUoPec = CNRUserContext.getCd_cds((CNRUserContext) context
.getUserContext());
}
UnitaOrganizzativaPecBulk uoPec = null;
try {
uoPec = Utility.createParametriEnteComponentSession().getUnitaOrganizzativaPec(context.getUserContext(),cdUoPec);
} catch (ComponentException e) {
handleException(e);
} catch (EJBException e) {
handleException(e);
} catch (RemoteException e) {
handleException(e);
}
if (uoPec == null || (uoPec.getEmailPec().equals("") && uoPec.getEmailPecDirettore().equals("")))
throw new ValidationException("L'indirizzo email di posta certificata per la unità organizzativa "+cdUoPec+" non è definito. Impossibile procedere!");
if (!pbulk.getDs_oggetto_pec().equals(""))
datiPEC.setOggetto(pbulk.getDs_oggetto_pec());
else
datiPEC.setOggetto(descrizione());
datiPEC.setDenominazioneServizio(servizioPec.getDsServizio());
if (testMode){
datiPEC.setEmailProtocollo(servizioPecProtocollo.getEmailTest());
datiPEC.setEmailServizio(servizioPec.getEmailTest());
}else{
datiPEC.setEmailProtocollo(servizioPecProtocollo.getEmail());
datiPEC.setEmailProtocollo2(servizioPecProtocollo.getEmail2());
datiPEC.setEmailProtocollo3(servizioPecProtocollo.getEmail3());
datiPEC.setEmailServizio(servizioPec.getEmail());
datiPEC.setEmailServizio2(servizioPec.getEmail2());
datiPEC.setEmailServizio3(servizioPec.getEmail3());
datiPEC.setEmailIstituto(uoPec.getEmailPec());
datiPEC.setEmailIstituto2(uoPec.getEmailPecDirettore());
}
}
public void rendiPersistente(String file) {
// TODO Auto-generated method stub
}
public String tipoPersistenza() {
return TIPO_PERSISTENZA_INTERNA;
}
}