KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > modules > base > BaseObject


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.modules.base;
7
8 import java.sql.SQLException JavaDoc;
9 import java.text.*;
10 import java.util.*;
11
12 import com.raptus.owxv3.*;
13 import com.raptus.owxv3.api.*;
14 import com.raptus.owxv3.api.components.*;
15 import com.raptus.owxv3.api.dataxs.*;
16 /**
17  * Contains
18  *
19  * <hr>
20  * <table width="100%" border="0">
21  * <tr>
22  * <td width="24%"><b>Filename</b></td><td width="76%">BaseObject.java</td>
23  * </tr>
24  * <tr>
25  * <td width="24%"><b>Author</b></td><td width="76%">Guy Z�rcher (gzuercher@raptus.com)</td>
26  * </tr>
27  * <tr>
28  * <td width="24%"><b>Date</b></td><td width="76%">20th of April 2001</td>
29  * </tr>
30  * </table>
31  * <hr>
32  * <table width="100%" border="0">
33  * <tr>
34  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
35  * </tr>
36  * </table>
37  * <hr>
38  */

39 public class BaseObject extends BusinessObject
40                         implements ComponentBusinessObject
41 {
42     /**
43      *
44      */

45     protected NwslistManager nwsList = null;
46
47     /**
48      *
49      */

50     protected GlobalResources gres = null;
51
52     /**
53      *
54      */

55     protected boolean previewEnabled = false;
56
57
58
59     /**
60      *
61      */

62     protected boolean propertiesEnabled = false;
63
64
65    
66     /**
67      *
68      */

69     protected boolean filesEnabled = false;
70
71
72     /**
73      *
74      */

75     protected int filesCount = 0;
76
77
78     /**
79      *
80      */

81     protected boolean picturesEnabled = false;
82
83
84     /**
85      *
86      */

87     protected int picturesCount = 0;
88
89     /**
90      *
91      */

92     protected boolean linksEnabled = false;
93
94
95     /**
96      *
97      */

98     protected int linksCount = 0;
99
100
101     /**
102      *
103      *
104      */

105     protected boolean categoriesEnabled=false;
106
107
108     /**
109      *
110      */

111     protected int categoryItemCount = 0;
112     
113     /**
114      *
115      */

116     protected boolean fieldsEnabled=false;
117     
118
119
120
121     /**
122      *
123      */

124     protected String JavaDoc sortField = null;
125
126     /**
127      *
128      */

129     protected boolean sortAscending = true;
130
131
132
133     /**
134      *
135      */

136     protected int entryCount = 0;
137     /**
138      *
139      */

140     
141     public BaseObject(VModule vm, Locale lcle)
142     {
143         super(vm, lcle);
144         
145         XMLConfigManager cm = XMLConfigManager.getInstance();
146         boolean v = vm.isVirtual();
147         String JavaDoc b = vm.getBaseModule();
148         gres = new GlobalResources();
149
150 // try
151
// {
152
// if exist property
153
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/properties/property?name=count","value"))
154           {
155             entryCount = cm.getIntegerByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/properties/property?name=count","value");
156 // LoggingManager.log("Entry count="+entryCount,this);
157
}
158           else
159           {
160               // check in base module
161
if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/properties/property?name=count","value"))
162               {
163                   entryCount = cm.getIntegerByTree("virtualhost/vmodules/vmodule?name="+b+"/properties/property?name=count","value");
164               }
165               else
166               {
167                 LoggingManager.log("ParseException while retrieving custom vm properties! (entryCount)" , this);
168               }
169           }
170 // entryCount= vm.getIntegerProperty(BaseConstants.VMODULE_PROPERTY_ENTRYCOUNT);
171
// }
172
// catch(ParseException e) {
173
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
174
// }
175
// try
176
// {
177
// previewEnabled = vm.getBooleanProperty(BaseConstants.VMODULE_PROPERTY_ENABLEPREVIEW);
178
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_preview/property?name=enable","value"))
179             {
180                 previewEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_preview/property?name=enable","value");
181             }
182             else
183             {
184                 // check in base module if this module is virtual
185
if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_preview/property?name=enable","value"))
186                 {
187                     previewEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_preview/property?name=enable","value");
188                 }
189                 else
190                 {
191                     LoggingManager.log("ParseException while retrieving custom vm properties! (previewEnabled)", this);
192                 }
193             }
194 // LoggingManager.log("Preview is "+previewEnabled,this);
195
// }
196
// catch(ParseException e) {
197
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
198
// }
199
// try
200
// {
201
// propertiesEnabled = vm.getBooleanProperty(BaseConstants.VMODULE_PROPERTY_ENABLEPROPERTIES);
202
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_entry/property?name=enable","value"))
203             {
204                 propertiesEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_entry/property?name=enable","value");
205             }
206             else
207             {
208                 if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_entry/property?name=enable","value"))
209                 {
210                     propertiesEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_entry/property?name=enable","value");
211                 }
212                 else
213                 {
214                     LoggingManager.log("ParseException while retrieving custom vm properties! (propertiesEnabled)", this);
215                 }
216             }
217 // LoggingManager.log("Entrt is "+propertiesEnabled,this);
218
// }
219
// catch(ParseException e) {
220
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
221
// }
222
// try
223
// {
224
// fieldsEnabled = vm.getBooleanProperty(BaseConstants.VMODULE_PROPERTY_ENABLEFIELDS);
225
// //LoggingManager.log("Fields="+fieldsEnabled,this);
226
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=enable","value"))
227             {
228                 fieldsEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=enable","value");
229             }
230             else
231             {
232                 if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_fields/property?name=enable","value"))
233                 {
234                     fieldsEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_fields/property?name=enable","value");
235                 }
236                 else
237                 {
238                     LoggingManager.log("ParseException while retrieving custom vm properties! (fieldsEnabled)", this);
239                 }
240             }
241 // LoggingManager.log("fields is "+fieldsEnabled,this);
242
// }
243
// catch(ParseException e) {
244
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
245
// }
246

247 // try
248
// {
249
// filesEnabled = vm.getBooleanProperty(BaseConstants.VMODULE_PROPERTY_ENABLEFILES);
250
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_files/property?name=enable","value"))
251             {
252                 filesEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_files/property?name=enable","value");
253             }
254             else
255             {
256                 if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_files/property?name=enable","value"))
257                 {
258                     filesEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_files/property?name=enable","value");
259                 }
260                 else
261                 {
262                     LoggingManager.log("ParseException while retrieving custom vm properties! (filesEnabled)", this);
263                 }
264             }
265 // LoggingManager.log("files is "+filesEnabled,this);
266
// }catch(ParseException e) {
267
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
268
// }
269
// try
270
// {
271
// filesCount=vm.getIntegerProperty(BaseConstants.VMODULE_PROPERTY_FILESCOUNT);
272
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_files/property?name=count","value"))
273             {
274                 filesCount = cm.getIntegerByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_files/property?name=count","value");
275             }
276             else
277             {
278                 if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_files/property?name=count","value"))
279                 {
280                     filesCount = cm.getIntegerByTree("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_files/property?name=count","value");
281                 }
282                 else
283                 {
284                     LoggingManager.log("ParseException while retrieving custom vm properties! (filesCount)", this);
285                 }
286             }
287 // LoggingManager.log("files count "+filesCount,this);
288
// }catch(ParseException e) {
289
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
290
// }
291
// try
292
// {
293
// picturesEnabled = vm.getBooleanProperty(BaseConstants.VMODULE_PROPERTY_ENABLEPICTURES);
294
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_pics/property?name=enable","value"))
295             {
296                 picturesEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_pics/property?name=enable","value");
297             }
298             else
299             {
300                 if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_pics/property?name=enable","value"))
301                 {
302                     picturesEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_pics/property?name=enable","value");
303                 }
304                 else
305                 {
306                     LoggingManager.log("ParseException while retrieving custom vm properties! (picturesEnabled)", this);
307                 }
308             }
309 // LoggingManager.log("files is "+filesEnabled,this);
310
// }catch(ParseException e) {
311
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
312
// }
313
// try
314
// {
315
// picturesCount=vm.getIntegerProperty(BaseConstants.VMODULE_PROPERTY_PICTURESCOUNT);
316
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_pics/property?name=count","value"))
317             {
318                 picturesCount = cm.getIntegerByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_pics/property?name=count","value");
319             }
320             else
321             {
322                 if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_pics/property?name=count","value"))
323                 {
324                     picturesCount = cm.getIntegerByTree("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_pics/property?name=count","value");
325                 }
326                 else
327                 {
328                     LoggingManager.log("ParseException while retrieving custom vm properties! (picturesCount)", this);
329                 }
330             }
331 // LoggingManager.log("pictures count "+picturesCount,this);
332
// }catch(ParseException e) {
333
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
334
// }
335
// try
336
// {
337
// linksEnabled = vm.getBooleanProperty(BaseConstants.VMODULE_PROPERTY_ENABLELINKS);
338
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_links/property?name=enable","value"))
339             {
340                 linksEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_links/property?name=enable","value");
341             }
342             else
343             {
344                 if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_links/property?name=enable","value"))
345                 {
346                     linksEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_links/property?name=enable","value");
347                 }
348                 else
349                 {
350                     LoggingManager.log("ParseException while retrieving custom vm properties! (linksEnabled)", this);
351                 }
352             }
353 // LoggingManager.log("links is "+filesEnabled,this);
354
// }catch(ParseException e) {
355
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
356
// }
357
// try
358
// {
359
// linksCount=vm.getIntegerProperty(BaseConstants.VMODULE_PROPERTY_LINKSCOUNT);
360
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_links/property?name=count","value"))
361             {
362                 linksCount = cm.getIntegerByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_links/property?name=count","value");
363             }
364             else
365             {
366                 if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_links/property?name=count","value"))
367                 {
368                     linksCount = cm.getIntegerByTree("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_links/property?name=count","value");
369                 }
370                 else
371                 {
372                     LoggingManager.log("ParseException while retrieving custom vm properties! (linksCount)", this);
373                 }
374             }
375 // LoggingManager.log("links count "+linksCount,this);
376
// }catch(ParseException e) {
377
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
378
// }
379
// try
380
// {
381
// categoriesEnabled=vm.getBooleanProperty(BaseConstants.VMODULE_PROPERTY_ENABLECATEGORIES);
382
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_categories/property?name=enable","value"))
383             {
384                 categoriesEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_categories/property?name=enable","value");
385             }
386             else
387             {
388                 if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_categories/property?name=enable","value"))
389                 {
390                     categoriesEnabled = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_categories/property?name=enable","value");
391                 }
392                 else
393                 {
394                     LoggingManager.log("ParseException while retrieving custom vm properties! (categoriesEnabled)", this);
395                 }
396             }
397 // LoggingManager.log("categories is "+categoriesEnabled,this);
398

399 // }catch(ParseException e) {
400
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
401
// }
402
// try
403
// {
404
// categoryItemCount=vm.getIntegerProperty(BaseConstants.VMODULE_PROPERTY_CATEGORYITEMCOUNT);
405
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_categories/property?name=count","value"))
406             {
407                 categoryItemCount = cm.getIntegerByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/component-properties/component-property?for=fc_categories/property?name=count","value");
408             }
409             else
410             {
411                 if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_categories/property?name=count","value"))
412                 {
413                     categoryItemCount = cm.getIntegerByTree("virtualhost/vmodules/vmodule?name="+b+"/component-properties/component-property?for=fc_categories/property?name=count","value");
414                 }
415                 else
416                 {
417                     LoggingManager.log("ParseException while retrieving custom vm properties! (categoryItemCount)", this);
418                 }
419             }
420 // LoggingManager.log("catitem count "+categoryItemCount,this);
421
// }catch(ParseException e) {
422
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
423
// }
424

425 // sortField = vm.getStringProperty(BaseConstants.VMODULE_PROPERTY_SORTFIELD);
426
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/properties/property?name=sort/property?name=field","value"))
427             {
428                 sortField = cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/properties/property?name=sort/property?name=field","value");
429             }
430             else
431             {
432                 if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/properties/property?name=sort/property?name=field","value"))
433                 {
434                     sortField = cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+b+"/properties/property?name=sort/property?name=field","value");
435                 }
436 // else
437
// {
438
// LoggingManager.log("ParseException while retrieving custom vm properties! (sortField)", this);
439
// }
440
}
441 // try
442
// {
443
// sortAscending = vm.getBooleanProperty(BaseConstants.VMODULE_PROPERTY_SORTASCENDING);
444
if(cm.existProperty("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/properties/property?name=sort/property?name=ascending","value"))
445             {
446                 sortAscending = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+vm.getIdentification()+"/properties/property?name=sort/property?name=ascending","value");
447             }
448             else
449             {
450                 if(v && cm.existProperty("virtualhost/vmodules/vmodule?name="+b+"/properties/property?name=sort/property?name=ascending","value"))
451                 {
452                     sortAscending = cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+b+"/properties/property?name=sort/property?name=ascending","value");
453                 }
454                 else
455                 {
456                     LoggingManager.log("ParseException while retrieving custom vm properties! (sortAscending)", this);
457                 }
458             }
459 // }
460
// catch(ParseException e) {
461
// LoggingManager.log("ParseException while retrieving custom vm properties!Error: "+e, this);
462
// }
463

464         if(sortField == null)
465             sortField = "entrydte";
466
467     }
468
469     public PubBaseEntry loadById(int id)
470     {
471         nwsList = new NwslistManager(vmodule.getIdentification());
472         nwsList.setDataSource(vmodule.getDatasource());
473
474         String JavaDoc table = nwsList.getTableID();
475         try
476         {
477             Nwslist entry = nwsList.loadByKey(id);
478
479             if( entry==null) return null;
480             
481
482             PubBaseEntry pne = new PubBaseEntry();
483             if(entry.getFlagentrydte())
484                 pne.setEntryDate( getLocaleFormattedDate(entry.getEntrydte()) );
485
486             /*pne.setTitle( gres.loadMessage(table, entry.getRowid(), BaseConstants.RESMSGFIELD_TITLE, locale) );
487             pne.setText( gres.loadMessage(table, entry.getRowid(), BaseConstants.RESMSGFIELD_TEXT, locale) );
488              */

489             pne.setFieldList( gres.loadFields(table,entry.getRowid()) );
490             pne.setLocalizedFieldList( gres.loadLocalizedFields(table, entry.getRowid()) );
491
492             if(linksEnabled && entry.getFlaglinks())
493                 pne.setLinkList( gres.loadURLsAndTitles(table, entry.getRowid(), BaseConstants.RESURLFIELD_URL,locale) );
494
495             if(filesEnabled && entry.getFlagfiles())
496                 pne.setFilesList( gres.loadLinkedFilesAndTitles(GlobalResources.FILETYPE_FILE,
497                 table, entry.getRowid(), BaseConstants.RESFILEFIELD_FILE, BaseConstants.RESFILEFIELD_LINK,locale) );
498
499             if(picturesEnabled && entry.getFlagpictures())
500                 pne.setPicList( gres.loadLinkedFilesAndTitles(GlobalResources.FILETYPE_PICTURE,
501                 table, entry.getRowid(), BaseConstants.RESPICFIELD_PIC,BaseConstants.RESPICFIELD_LINK,locale) );
502
503             return pne;
504         }
505         catch(SQLException JavaDoc e) {
506             LoggingManager.log("SQLException during retrieval of pub news entry! " + e.getMessage(), this);
507             return null;
508         }
509     }
510
511     /**
512      *
513      */

514     public Vector loadPubBaseListEntries(CategoryFilter filter)
515     {
516         Vector newsPubList = null;
517         nwsList = new NwslistManager(vmodule.getIdentification());
518         nwsList.setDataSource(vmodule.getDatasource());
519         String JavaDoc filt="";
520         if(filter != null)
521         {
522             Vector v = filter.getIDs();
523             if(v.size()>0)
524             {
525                 filt="(";
526                 int _i;
527                 for(_i=0;_i<v.size()-1;_i++)
528                 {
529                     Integer JavaDoc ii = (Integer JavaDoc)v.elementAt(_i);
530                     filt = filt+" rowid='"+ii.intValue()+"' or ";
531                 }
532                 Integer JavaDoc ii = (Integer JavaDoc)v.elementAt(_i);
533                 filt = filt+" rowid='"+ii.intValue()+"') AND";
534             }
535             else
536             {
537                 //LoggingManager.log("Filter size is 0",this);
538
filt="(rowid=0) AND";
539             }
540         }
541         else
542         {
543             //LoggingManager.log("Filter is null");
544
}
545
546         String JavaDoc table = nwsList.getTableID();
547         try
548         {
549             // fillup <newsList> with PubBaseBean objects ...
550
String JavaDoc where = filt+" flagVisible = true AND (flagtimedpub = false OR (flagtimedpub = true AND " +
551                            "( (showfrom = null OR showfrom<=now()) AND (showuntil = null OR showuntil > now()))) )";
552
553
554             Nwslist[] list = nwsList.loadByWhere(where, sortField + ((sortAscending) ? " ASC" : " DESC"), 0);
555
556             newsPubList = new Vector(list.length); // speed up allocation
557
boolean entry_valid=true;
558             for(int i = 0; i < list.length; i ++)
559             {
560                 Nwslist entry = list[i];
561                 entry_valid=true;
562                 PubBaseEntry pne = new PubBaseEntry();
563                 pne.setBaseID(entry.getRowid());
564
565
566                 if(entry.getFlagentrydte())
567                     pne.setEntryDate( getLocaleFormattedDate(entry.getEntrydte()) );
568
569                 pne.setFieldList( gres.loadFields(table,entry.getRowid()) );
570                 pne.setLocalizedFieldList( gres.loadLocalizedFields(table, entry.getRowid()) );
571
572                 if(linksEnabled && entry.getFlaglinks())
573                     pne.setLinkList( gres.loadURLsAndTitles(table, entry.getRowid(), BaseConstants.RESURLFIELD_URL,locale) );
574
575                 if(filesEnabled && entry.getFlagfiles())
576                     pne.setFilesList( gres.loadLinkedFilesAndTitles(GlobalResources.FILETYPE_FILE,
577                                      table, entry.getRowid(), BaseConstants.RESFILEFIELD_FILE,BaseConstants.RESFILEFIELD_LINK,locale) );
578
579                 if(picturesEnabled && entry.getFlagpictures())
580                     pne.setPicList( gres.loadLinkedFilesAndTitles(GlobalResources.FILETYPE_PICTURE,
581                                     table, entry.getRowid(), BaseConstants.RESPICFIELD_PIC,BaseConstants.RESPICFIELD_LINK,locale) );
582
583                 //newsPubList.insertElementAt(pne, 0); // insert reversed
584
newsPubList.addElement(pne);
585             }
586         }
587         catch(SQLException JavaDoc e) {
588             LoggingManager.log("SQLException during retrieval of pub news list! " + e.getMessage(), this);
589         }
590
591         nwsList = null;
592         return newsPubList;
593     }
594
595     /**
596      *Method for loading EABaseBeans to used in list entry screen
597      */

598     public Vector loadEABaseListEntries()
599     {
600         XMLConfigManager cm = XMLConfigManager.getInstance();
601         
602         Vector newsEAList = null;
603         nwsList = new NwslistManager(vmodule.getIdentification());
604         nwsList.setDataSource(vmodule.getDatasource());
605
606         String JavaDoc table = nwsList.getTableID();
607         try
608         {
609             // fillup <newsList> with PubBaseBean objects ...
610
String JavaDoc where = "flagVisible = false OR flagVisible = true";
611             Nwslist[] list = nwsList.loadByWhere(where, "entrydte DESC", 0);
612
613             newsEAList = new Vector(list.length); // speed up allocation
614
//String title=vmodule.getStringProperty(BaseConstants.VMODULE_PROPERTY_FIELDTITLE);
615
String JavaDoc title=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=titlefield","value");
616 // LoggingManager.log("Title field="+title,this);
617
for(int i = 0; i < list.length; i ++)
618             {
619                 Nwslist entry = list[i];
620
621                 EABaseListEntry eae = new EABaseListEntry();
622
623                 eae.setRowId(entry.getRowid());
624                 eae.setFlagVisible(entry.getFlagvisible());
625                 eae.setFlagEntryDte(entry.getFlagentrydte());
626                 eae.setFlagTimedPub(entry.getFlagtimedpub());
627
628                 eae.setFlagFiles(filesEnabled && entry.getFlagfiles());
629                 eae.setFlagLinks(linksEnabled && entry.getFlaglinks());
630                 eae.setFlagPics(picturesEnabled && entry.getFlagpictures());
631
632                 eae.setEntryDte( getLocaleFormattedDate(entry.getEntrydte()) );
633                 
634                 eae.setTitle( gres.loadField(table, entry.getRowid(), title, locale) );
635 // LoggingManager.log("Table is "+table+" title="+title+" rowid="+entry.getRowid()+":"+eae.getTitle(),this);
636
newsEAList.insertElementAt(eae, 0); // insert reversed
637
}
638         }
639         catch(SQLException JavaDoc e) {
640             LoggingManager.log("SQLException during retrieval of eAdmin news list! " + e.getMessage(), this);
641         }
642
643         nwsList = null;
644         //LoggingManager.log("Loaded " + newsEAList.size() + " list entries from vmodule " + vmodule.getIdentification(), this);
645
return newsEAList;
646     }
647
648  /**
649      *
650      */

651     public Vector loadEABaseListEntries(CategoryFilter filter)
652     {
653         Vector newsEAList = null;
654         nwsList = new NwslistManager(vmodule.getIdentification());
655         nwsList.setDataSource(vmodule.getDatasource());
656
657         String JavaDoc filt="";
658         if(filter != null)
659         {
660             Vector v = filter.getIDs();
661             if(v.size()>0)
662             {
663                 filt="(";
664                 int _i;
665                 for(_i=0;_i<v.size()-1;_i++)
666                 {
667                     Integer JavaDoc ii = (Integer JavaDoc)v.elementAt(_i);
668                     filt = filt+" rowid='"+ii.intValue()+"' or ";
669                 }
670                 Integer JavaDoc ii = (Integer JavaDoc)v.elementAt(_i);
671                 filt = filt+" rowid='"+ii.intValue()+"') AND";
672             }
673             else
674             {
675                 //LoggingManager.log("Filter size is 0");
676
filt="(rowid=0) AND";
677             }
678         }
679         else
680         {
681             //LoggingManager.log("Filter is null");
682
}
683
684         String JavaDoc table = nwsList.getTableID();
685         try
686         {
687             XMLConfigManager cm = XMLConfigManager.getInstance();
688             // fillup <newsList> with PubBaseBean objects ...
689
String JavaDoc where = filt+" (flagVisible = false OR flagVisible = true)";
690             //LoggingManager.log("where="+where);
691
Nwslist[] list = nwsList.loadByWhere(where, "entrydte DESC", 0);
692
693             newsEAList = new Vector(list.length); // speed up allocation
694
//String title=vmodule.getStringProperty(BaseConstants.VMODULE_PROPERTY_FIELDTITLE);
695
String JavaDoc title=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=titlefield","value");
696             //LoggingManager.log("]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]",this);
697
// LoggingManager.log("Title field is "+title,this);
698
for(int i = 0; i < list.length; i ++)
699             {
700                 Nwslist entry = list[i];
701
702                 EABaseListEntry eae = new EABaseListEntry();
703
704                 eae.setRowId(entry.getRowid());
705                 eae.setFlagVisible(entry.getFlagvisible());
706                 eae.setFlagEntryDte(entry.getFlagentrydte());
707                 eae.setFlagTimedPub(entry.getFlagtimedpub());
708
709                 eae.setFlagFiles(filesEnabled && entry.getFlagfiles());
710                 eae.setFlagLinks(linksEnabled && entry.getFlaglinks());
711                 eae.setFlagPics(picturesEnabled && entry.getFlagpictures());
712
713                 eae.setEntryDte( getLocaleFormattedDate(entry.getEntrydte()) );
714                 eae.setTitle( gres.loadField(table, entry.getRowid(), title, locale) );
715
716                 newsEAList.insertElementAt(eae, 0); // insert reversed
717
}
718         }
719         catch(SQLException JavaDoc e) {
720             LoggingManager.log("SQLException during retrieval of eAdmin news list! " + e.getMessage(), this);
721         }
722
723         nwsList = null;
724         LoggingManager.log("Loaded " + newsEAList.size() + " filtered list entries from vmodule " + vmodule.getIdentification(), this);
725         return newsEAList;
726     }
727
728     /**
729      *
730      */

731     public boolean isNewEntryAllowed()
732     {
733         if(entryCount==0) return true;
734
735         try
736         {
737             nwsList = new NwslistManager(vmodule.getIdentification());
738             nwsList.setDataSource(vmodule.getDatasource());
739             Nwslist[] list = nwsList.loadAll();
740             int currententries=list.length;
741             list=null;
742             nwsList=null;
743             if(currententries>=entryCount) return false;
744         }catch(SQLException JavaDoc e){
745             LoggingManager.log("SQLException during checking the count of entries! " + e.getMessage(), this);
746             return false;
747         }
748         return true;
749
750     }
751
752
753     protected void initFcFieldData(VModule vmodule, ComponentBean cb)
754     {
755         XMLConfigManager cm = XMLConfigManager.getInstance();
756         //initilizing field defintions too
757
try
758         {
759             //String[] fieldlist=vmodule.getStringArrayProperty(BaseConstants.VMODULE_PROPERTY_FIELDLIST);
760
String JavaDoc[] fieldlist = cm.getStringArrayByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=fieldlist", "fields");
761             //LoggingManager.log("####################################################Got "+fieldlist.length+" fields!",this);
762
String JavaDoc[] locales=vmodule.getLocales();
763             Hashtable h=new Hashtable();
764
765             if(fieldlist!=null)
766             {
767                 int i=0,j=0;
768                 //inserting simple field labels
769
for(i=0;i<locales.length;i++)
770                 {
771                     //LoggingManager.log(BaseConstants.VMODULE_PROPERTY_SIMPLEFIELDLABEL+locales[i]);
772
//h.put( locales[i],vmodule.getStringProperty(BaseConstants.VMODULE_PROPERTY_SIMPLEFIELDLABEL+locales[i]) );
773
h.put(locales[i], cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=simplefield/property?name=labels/label?locale="+locales[i],"value"));
774                 }
775                 ((CmpFieldsBean) cb).setSimpleFieldLabel(h);
776                 //String title=vmodule.getStringProperty(BaseConstants.VMODULE_PROPERTY_FIELDTITLE);
777
String JavaDoc title=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=titlefield", "value");
778                 if(title==null) title=fieldlist[0];
779                 ((CmpFieldsBean) cb).setTitleFieldName(title);
780
781                 String JavaDoc defVal=null;
782                 Hashtable defMLVal=null;
783                 Hashtable labels=null;
784                 boolean enabled=true;
785                 for(i=0;i<fieldlist.length;i++)
786                 {
787                     enabled=true;
788                     try
789                     {
790                         //enabled=vmodule.getBooleanProperty(fieldlist[i]+BaseConstants.VMODULE_PROPERTY_FIELDENABLED);
791
enabled=cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=fieldlist/field?name="+fieldlist[i],"enabled");
792                     }
793                     catch(Exception JavaDoc e){}
794                     
795                     if(enabled)
796                     {
797 // LoggingManager.log("Adding field definition:"+fieldlist[i],this);
798
FieldDefinition fd=new FieldDefinition();
799                         fd.setName(fieldlist[i]);
800                         //LoggingManager.log(fieldlist[i]+BaseConstants.VMODULE_PROPERTY_FIELDTYPE);
801
//fd.setType(vmodule.getStringProperty(fieldlist[i]+BaseConstants.VMODULE_PROPERTY_FIELDTYPE));
802
fd.setType(cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=fieldlist/field?name="+fieldlist[i],"type"));
803 // LoggingManager.log("Field type is "+cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=fieldlist/field?name="+fieldlist[i],"type"),this);
804

805                         //LoggingManager.log(fieldlist[i]+BaseConstants.VMODULE_PROPERTY_FIELDDEFAULT);
806
//defVal=vmodule.getStringProperty(fieldlist[i]+BaseConstants.VMODULE_PROPERTY_FIELDDEFAULT);
807
defVal=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=fieldlist/field?name="+fieldlist[i],"default");
808 // LoggingManager.log("Default value is "+defVal,this);
809
if(defVal!=null)
810                         {
811                            //checking if default value = 'now'
812
if( fd.getType() == Constants.FIELDTYPE_DATE )
813                             {
814                                 if(defVal.equalsIgnoreCase(Constants.DATEFIELD_NOW_IDENTIFIER))
815                                 {
816                                     SimpleDateFormat df=(SimpleDateFormat)DateFormat.getDateInstance(DateFormat.SHORT);
817                                     df.applyPattern(Constants.DEFAULT_DATEPATTERN);
818                                     defVal=df.format(new java.util.Date JavaDoc());
819                                 }
820                             }
821                             fd.setDefaultVal(defVal);
822                         }
823                         else
824                         {
825                             defMLVal=new Hashtable();
826                             //default values
827
for(j=0;j<locales.length;j++)
828                             {
829                                 //LoggingManager.log(fieldlist[i]+BaseConstants.VMODULE_PROPERTY_FIELDDEFAULT+"."+locales[j]);
830
//defMLVal.put (locales[j],vmodule.getStringProperty(fieldlist[i]+BaseConstants.VMODULE_PROPERTY_FIELDDEFAULT+"."+locales[j]) );
831
String JavaDoc val=cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=fieldlist/field?name="+fieldlist[i]+"/default?locale="+locales[j],"value");
832                                 if(val == null)
833                                 {
834                                     val="";
835                                 }
836                                 else
837                                 {
838                                     //cheinkg if default value = 'now'
839
if( fd.getType() == Constants.FIELDTYPE_DATE )
840                                     {
841                                         if(val.equalsIgnoreCase(Constants.DATEFIELD_NOW_IDENTIFIER))
842                                         {
843                                             SimpleDateFormat df=(SimpleDateFormat)DateFormat.getDateInstance(DateFormat.SHORT);
844                                             df.applyPattern(Constants.DEFAULT_DATEPATTERN);
845                                             val=df.format(new java.util.Date JavaDoc());
846                                         }
847                                     }
848                                 }//end else
849

850                                    
851                                 defMLVal.put(locales[j], val);
852                             }
853                             fd.setDefaultVal(defMLVal);
854
855                         }//end else
856

857                         //labels
858
labels=new Hashtable();
859                         for(j=0;j<locales.length;j++)
860                         {
861                             //LoggingManager.log(fieldlist[i]+BaseConstants.VMODULE_PROPERTY_FIELDLABEL+locales[j]);
862
//labels.put( locales[j],vmodule.getStringProperty(fieldlist[i]+BaseConstants.VMODULE_PROPERTY_FIELDLABEL+locales[j]) );
863
labels.put(locales[j], cm.getPropertyByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=fieldlist/field?name="+fieldlist[i]+"/label?locale="+locales[j],"value"));
864                         }
865                         fd.setLabel(labels);
866                         //LoggingManager.log(fieldlist[i]+BaseConstants.VMODULE_PROPERTY_FIELDWYSIWYG);
867
boolean wysiwyg=false;
868                         try
869                         {
870                             //wysiwyg=vmodule.getBooleanProperty(fieldlist[i]+BaseConstants.VMODULE_PROPERTY_FIELDWYSIWYG);
871
wysiwyg=cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=fieldlist/field?name="+fieldlist[i],"wysiwyg");
872                             
873                         }catch(Exception JavaDoc e){}
874                         fd.setWysiwyg(wysiwyg);
875                         
876                         boolean empty=false;
877                         try
878                         {
879                             //wysiwyg=vmodule.getBooleanProperty(fieldlist[i]+BaseConstants.VMODULE_PROPERTY_FIELDWYSIWYG);
880
empty=cm.getBooleanByTree("virtualhost/vmodules/vmodule?name="+vmodule.getIdentification()+"/component-properties/component-property?for=fc_fields/property?name=fieldlist/field?name="+fieldlist[i],"empty");
881                         }catch(Exception JavaDoc e){}
882                         fd.setEmpty(empty);
883                         
884                         ((CmpFieldsBean) cb).addFieldDefinition(fd);
885                     }//end if
886

887                 }//end for
888

889
890             }//end if
891
}
892         catch(Exception JavaDoc e)
893         {
894             LoggingManager.log("Error while loading field defintions from config file:"+e,this);
895             e.printStackTrace(System.out);
896         }
897     }//end initFcFieldData
898

899
900     /**
901      *
902      */

903     public boolean loadComponentData(ComponentContainer cc)
904     {
905         nwsList = new NwslistManager(vmodule.getIdentification());
906         nwsList.setDataSource(vmodule.getDatasource());
907
908         String JavaDoc table = nwsList.getTableID();
909
910         OwxurlsManager urlmanager=new OwxurlsManager();
911         String JavaDoc urltable=urlmanager.getTableID();
912         urlmanager=null;
913
914         OwxflinksManager filelinksmanager=new OwxflinksManager();
915         String JavaDoc filelinktable=filelinksmanager.getTableID();
916         filelinksmanager=null;
917
918         try
919         {
920             //cc.setChanged(false);
921
Nwslist entry = nwsList.loadByKey(cc.getDataID());
922             if(entry != null)
923             {
924                 // loop through all allocated components
925
if(cc.getComponents()!=null)
926                 {
927                     Enumeration enuCmps = cc.getComponents().elements();
928                     while(enuCmps.hasMoreElements())
929                     {
930                         ComponentBean cb = (ComponentBean) enuCmps.nextElement();
931                         cb.setCurrLocale(locale); // every one has a copy of the locale obj
932

933
934                         String JavaDoc cmpID = cb.getData().getID();
935                         if( cmpID.equals(BaseConstants.COMPONENT_ENTRY_ID) )
936                         {
937                             ((CmpEntryBean) cb).setEntryDte( getLocaleFormattedDate(entry.getEntrydte()) );
938                             ((CmpEntryBean) cb).setFlagEntryDte(entry.getFlagentrydte());
939                             ((CmpEntryBean) cb).setFlagTimedPub(entry.getFlagtimedpub());
940                             ((CmpEntryBean) cb).setShowFromDate( getLocaleFormattedDate(entry.getShowfrom()) );
941                             ((CmpEntryBean) cb).setShowFromTime( getLocaleFormattedTime(entry.getShowfrom()) );
942                             ((CmpEntryBean) cb).setShowUntilDate( getLocaleFormattedDate(entry.getShowuntil()) );
943                             ((CmpEntryBean) cb).setShowUntilTime( getLocaleFormattedTime(entry.getShowuntil()) );
944                             //((CmpEntryBean) cb).setValuesChanged(false);
945
}
946                         else if( cmpID.equals(BaseConstants.COMPONENT_FILES_ID) )
947                         {
948                             try
949                             {
950                                 FilesSelector fs = new FilesSelector(gres,vmodule.getLocales(),filelinktable,filesCount);
951                                 fs.loadLinkedFilesAndIds(gres, table, entry.getRowid(), BaseConstants.RESFILEFIELD_FILE);
952                                 ((CmpFilesBean) cb).setFilesSelector(fs);
953
954
955
956                             }
957                            catch(SQLException JavaDoc e) {
958                                 LoggingManager.log("Cannot initialize the FilesSelector for component " + cmpID, this);
959                             }
960                         }
961                         else if( cmpID.equals(BaseConstants.COMPONENT_PICS_ID) )
962                         {
963                             try
964                             {
965                                 PicturesSelector ps = new PicturesSelector(gres,vmodule.getLocales(),filelinktable,picturesCount);
966                                 ps.loadLinkedPictures(gres, table, entry.getRowid(), BaseConstants.RESPICFIELD_PIC);
967                                 ((CmpPicsBean) cb).setPicsSelector(ps);
968                             }
969                             catch(SQLException JavaDoc e) {
970                                 LoggingManager.log("Cannot initialize the PicturesSelector for component " + cmpID, this);
971                             }
972                         }
973                         else if( cmpID.equals(BaseConstants.COMPONENT_LINKS_ID) )
974                         {
975                             LinksSelector ls = new LinksSelector(vmodule.getLocales(),urltable,linksCount);
976                             ls.loadLinks(gres, table, entry.getRowid(), BaseConstants.RESURLFIELD_URL);
977
978
979                             ((CmpLinksBean) cb).setLinksSelector(ls);
980
981                         }
982                         else if( cmpID.equals(BaseConstants.COMPONENT_FIELDS_ID) )
983                         {
984
985                             FieldsSelector fs = new FieldsSelector(vmodule.getLocales());
986                             fs.loadFields( gres, table, entry.getRowid() );
987
988                             
989                             ((CmpFieldsBean) cb).setFieldsSelector(fs);
990                             
991                             initFcFieldData(vmodule,cb);
992                             
993                             
994                         }
995                         else if( cmpID.equals(BaseConstants.COMPONENT_CATEGORIES_ID) )
996                         {
997
998
999                             CategorySelector cs = new CategorySelector(vmodule.getLocales(),locale,vmodule.getIdentification(),categoryItemCount);
1000                            try
1001                            {
1002                                cs.loadLinkedCategories(table, entry.getRowid(), "");
1003                            }catch(SQLException JavaDoc e)
1004                            {
1005                                LoggingManager.log("Unable to load categories for item:"+entry.getRowid()+" error: "+e,this);
1006                            }
1007
1008
1009                            ((CmpCategoryBean) cb).setCategorySelector(cs);
1010
1011                        }
1012// else
1013
// LoggingManager.log("Unknown component used in this module! Please implement."+cmpID, this);
1014
}//end while
1015
}//end if
1016
}//end bigif
1017
}
1018        catch(SQLException JavaDoc e) {
1019            LoggingManager.log("SQLException during retrieval of pub news list! " + e.getMessage(), this);
1020            return false;
1021        }
1022
1023        nwsList = null;
1024// LoggingManager.log("Loaded entry id " + cc.getDataID() + " from vmodule " + vmodule.getIdentification(), this);
1025
return true;
1026    }
1027
1028    /**
1029     *
1030     */

1031    public boolean loadComponentDefaultData(ComponentContainer cc)
1032    {
1033
1034        OwxurlsManager urlmanager=new OwxurlsManager();
1035        String JavaDoc urltable=urlmanager.getTableID();
1036        urlmanager=null;
1037
1038        OwxflinksManager filelinksmanager=new OwxflinksManager();
1039        String JavaDoc filelinktable=filelinksmanager.getTableID();
1040        filelinksmanager=null;
1041
1042        // so it is a new record that has no ID yet
1043
cc.setDataID(ComponentConstants.COMPONENT_NEW_DATAID);
1044
1045        // loop through all allocated components
1046
if(cc.getComponents()!=null)
1047        {
1048            //cc.setChanged(false);
1049
Enumeration enuCmps = cc.getComponents().elements();
1050            while(enuCmps.hasMoreElements())
1051            {
1052                ComponentBean cb = (ComponentBean) enuCmps.nextElement();
1053                cb.setCurrLocale(locale); // every one has a copy of the locale obj
1054

1055                String JavaDoc cmpID = cb.getData().getID();
1056                //LoggingManager.log("Component id="+cmpID);
1057
if( cmpID.equals(BaseConstants.COMPONENT_ENTRY_ID) )
1058                {
1059                    ((CmpEntryBean) cb).setEntryDte( getLocaleFormattedDate( new java.util.Date JavaDoc() ) );
1060                    ((CmpEntryBean) cb).setFlagEntryDte(true);
1061                    ((CmpEntryBean) cb).setFlagTimedPub(false);
1062                    ((CmpEntryBean) cb).setShowFromDate("");
1063                    ((CmpEntryBean) cb).setShowFromTime("");
1064                    ((CmpEntryBean) cb).setShowUntilDate("");
1065                    ((CmpEntryBean) cb).setShowUntilTime("");
1066                    //((CmpEntryBean) cb).setValuesChanged(false);
1067
}
1068                else if( cmpID.equals(BaseConstants.COMPONENT_FILES_ID) )
1069                {
1070                    try
1071                    {
1072                        ((CmpFilesBean) cb).setFilesSelector( new FilesSelector(gres,vmodule.getLocales(),filelinktable,filesCount) );
1073                        //((CmpFilesBean) cb).setMsgsSelector( new MessagesSelector( vmodule.getLocales() ) );
1074
}
1075                    catch(SQLException JavaDoc e) {
1076                        LoggingManager.log("Cannot initialize the FilesSelector for component " + cmpID, this);
1077                    }
1078                }
1079                else if( cmpID.equals(BaseConstants.COMPONENT_PICS_ID) )
1080                {
1081                    try
1082                    {
1083                        ((CmpPicsBean) cb).setPicsSelector( new PicturesSelector(gres,vmodule.getLocales(),filelinktable,picturesCount) );
1084                    }
1085                    catch(SQLException JavaDoc e) {
1086                        LoggingManager.log("Cannot initialize the PicturesSelector for component " + cmpID, this);
1087                    }
1088                }
1089                else if( cmpID.equals(BaseConstants.COMPONENT_LINKS_ID) )
1090                {
1091                    ((CmpLinksBean) cb).setLinksSelector( new LinksSelector(vmodule.getLocales(),urltable,linksCount) );
1092
1093                }
1094                else if( cmpID.equals(BaseConstants.COMPONENT_FIELDS_ID) )
1095                {
1096                     FieldsSelector fs = new FieldsSelector(vmodule.getLocales());
1097                     ((CmpFieldsBean) cb).setFieldsSelector(fs);
1098                     initFcFieldData(vmodule,cb);
1099                    
1100                }
1101                else if( cmpID.equals(BaseConstants.COMPONENT_CATEGORIES_ID) )
1102                {
1103                    try
1104                    {
1105                        ((CmpCategoryBean) cb).setCategorySelector( new CategorySelector(vmodule.getLocales(),locale,vmodule.getIdentification(),categoryItemCount) );
1106                    }
1107                    catch(SQLException JavaDoc e) {
1108                        LoggingManager.log("Cannot initialize the PicturesSelector for component " + cmpID, this);
1109                    }
1110                }
1111// else
1112
// LoggingManager.log("Unknown component used in this module! Please implement.", this);
1113
}//end while
1114
}//end if
1115

1116       nwsList = null;
1117// LoggingManager.log("Loaded empty entry for vmodule " + vmodule.getIdentification(), this);
1118
return true;
1119    }
1120
1121
1122
1123    /**
1124     *
1125     */

1126    public boolean loadPreviewData(ComponentContainer cc, CmpPreviewBean previewbean)
1127    {
1128        // loop through all allocated components
1129
Enumeration enuCmps = cc.getComponents().elements();
1130        while(enuCmps.hasMoreElements())
1131        {
1132            ComponentBean cb = (ComponentBean) enuCmps.nextElement();
1133            String JavaDoc cmpID = cb.getData().getID();
1134            if( cmpID.equals(BaseConstants.COMPONENT_FIELDS_ID) )
1135            {
1136               /*previewbean.setTitle( ((CmpFieldsBean) cb).getMsgsSelector().getMessage(BaseConstants.RESMSGFIELD_TITLE,locale) );
1137               previewbean.setText( ((CmpFieldsBean) cb).getMsgsSelector().getMessage(BaseConstants.RESMSGFIELD_TEXT,locale) );
1138                
1139                */

1140                previewbean.setLinkedFields( ((CmpFieldsBean) cb).getFieldsSelector().getLinkedFields(locale) );
1141                
1142            }
1143            else if( cmpID.equals(BaseConstants.COMPONENT_FILES_ID) )
1144            {
1145               previewbean.setLinkedFiles( ((CmpFilesBean) cb).getFilesSelector().getLinkedFiles(locale) );
1146            }
1147            else if( cmpID.equals(BaseConstants.COMPONENT_PICS_ID) )
1148            {
1149               previewbean.setLinkedPics( ((CmpPicsBean) cb).getPicsSelector().getLinkedPics(locale) );
1150            }
1151            else if( cmpID.equals(BaseConstants.COMPONENT_LINKS_ID) )
1152            {
1153                previewbean.setLinkedUrls( ((CmpLinksBean) cb).getLinksSelector().getLinkList(locale) );
1154            }
1155
1156        }//end while
1157

1158        return true;
1159    }//end load
1160

1161
1162
1163
1164
1165    /**
1166     *
1167     */

1168    public boolean saveComponentData(ComponentContainer cc)
1169    {
1170        // is it a new record that has no ID yet or not
1171
nwsList = new NwslistManager(vmodule.getIdentification());
1172        nwsList.setDataSource(vmodule.getDatasource());
1173
1174        String JavaDoc table = nwsList.getTableID();
1175        int dataID = cc.getDataID();
1176        Nwslist newsEntry = null;
1177
1178
1179
1180        //since the Enumeration DOESN'T GUARENTEE am order of the elements
1181
//we have to make sure that first the Properties are saved and a new_id (if necesarry)
1182
//will be created
1183
Enumeration enuCmps = cc.getComponents().elements();
1184        while(enuCmps.hasMoreElements())
1185        {
1186            ComponentBean cb = (ComponentBean) enuCmps.nextElement();
1187
1188            String JavaDoc cmpID = cb.getData().getID();
1189            try
1190            {
1191                if( cmpID.equals(BaseConstants.COMPONENT_ENTRY_ID) )
1192                {
1193                    newsEntry = new Nwslist();
1194
1195                    // data manipulated by entry component
1196
newsEntry.setFlagentrydte( ((CmpEntryBean) cb).getFlagEntryDte() );
1197                    newsEntry.setFlagtimedpub( ((CmpEntryBean) cb).getFlagTimedPub() );
1198                    newsEntry.setEntrydte( getDateFromStrings( ((CmpEntryBean) cb).getEntryDte(), null ) );
1199
1200                    java.util.Date JavaDoc showFrom = ((CmpEntryBean) cb).getShowFrom();
1201                    if(showFrom != null) newsEntry.setShowfrom(showFrom);
1202
1203                    java.util.Date JavaDoc showUntil = ((CmpEntryBean) cb).getShowUntil();
1204                    if(showUntil != null) newsEntry.setShowuntil(showUntil);
1205
1206                    if(dataID == ComponentConstants.COMPONENT_NEW_DATAID)
1207                    {
1208                        // entry is new (create a new record)
1209
newsEntry.setIsNew(true);
1210
1211                        // default values for new records
1212
newsEntry.setFlagvisible(true);
1213                        newsEntry.setFlaglinks( false );
1214                        newsEntry.setFlagpictures( false );
1215                        newsEntry.setFlagfiles( false );
1216                    }
1217                    else if(dataID > ComponentConstants.COMPONENT_NEW_DATAID)
1218                    {
1219                        // entry is existing (update the record)
1220
newsEntry.setIsNew(false);
1221                        newsEntry.setRowid(dataID);
1222                    }
1223                    else
1224                    {
1225                        LoggingManager.log("Base entry has uninitialized data ID " + cc.getDataID(), this);
1226                        return false;
1227                    }
1228
1229                    // update modified fields in database
1230
nwsList.save(newsEntry);
1231
1232                    // reclaim record id again
1233
dataID = newsEntry.getRowid();
1234                    cc.setDataID(dataID);
1235                }//end if
1236
}catch(SQLException JavaDoc e)
1237            {
1238                LoggingManager.log("Cannot save news entry with data ID " + dataID +
1239                                   ". Exception: " + e.getMessage(), this);
1240                return false;
1241            }
1242        } // while
1243

1244
1245        //if the properties entry is disabled the new id is not generated
1246
//we need to check this case
1247

1248
1249        if(! propertiesEnabled)
1250        {
1251            try
1252            {
1253
1254                newsEntry = new Nwslist();
1255
1256
1257                if(dataID == ComponentConstants.COMPONENT_NEW_DATAID)
1258                {
1259                    // entry is new (create a new record)
1260
newsEntry.setIsNew(true);
1261
1262                    // default values for new records
1263

1264                    newsEntry.setFlagvisible(true);
1265                    newsEntry.setFlagtimedpub( false );
1266                    newsEntry.setFlaglinks( false );
1267                    newsEntry.setFlagpictures( false );
1268                    newsEntry.setFlagfiles( false );
1269
1270                    // update modified fields in database
1271
nwsList.save(newsEntry);
1272
1273                    // reclaim record id again
1274
dataID = newsEntry.getRowid();
1275                    cc.setDataID(dataID);
1276                }
1277                else if(dataID > ComponentConstants.COMPONENT_NEW_DATAID)
1278                {
1279                    // entry is existing (update the record)
1280
newsEntry.setIsNew(false);
1281                    newsEntry.setRowid(dataID);
1282                }
1283                else
1284                {
1285                    LoggingManager.log("Base entry has uninitialized data ID " + cc.getDataID(), this);
1286                    return false;
1287                }
1288
1289
1290
1291            }catch(SQLException JavaDoc e)
1292            {
1293                LoggingManager.log("Cannot save news entry with data ID " + dataID +
1294                                   ". Exception: " + e.getMessage(), this);
1295                return false;
1296            }
1297        }//end if
1298

1299
1300
1301        int linkedfiles=0;
1302        int linkedurls=0;
1303        int linkedpics=0;
1304
1305        // loop through all allocated components
1306
enuCmps = cc.getComponents().elements();
1307        while(enuCmps.hasMoreElements())
1308        {
1309            ComponentBean cb = (ComponentBean) enuCmps.nextElement();
1310
1311            String JavaDoc cmpID = cb.getData().getID();
1312            try
1313            {
1314
1315
1316
1317                if( cmpID.equals(BaseConstants.COMPONENT_FILES_ID) )
1318                {
1319                    ((CmpFilesBean) cb).getFilesSelector()
1320                                       .saveLinkedFiles(gres, table, dataID, BaseConstants.RESFILEFIELD_FILE);
1321                    linkedfiles=((CmpFilesBean) cb).getFilesSelector().getLinkedFiles().size();
1322                }
1323                else if( cmpID.equals(BaseConstants.COMPONENT_PICS_ID) )
1324                {
1325                    ((CmpPicsBean) cb).getPicsSelector()
1326                                      .saveLinkedPictures(gres, table, dataID, BaseConstants.RESPICFIELD_PIC);
1327                    linkedpics=((CmpPicsBean) cb).getPicsSelector().getLinkedPics().size();
1328                }
1329                else if( cmpID.equals(BaseConstants.COMPONENT_LINKS_ID) )
1330                {
1331                    ((CmpLinksBean) cb).getLinksSelector()
1332                                       .saveLinks(gres, table, dataID, BaseConstants.RESURLFIELD_URL);
1333                    linkedurls=((CmpLinksBean) cb).getLinksSelector().getList().size();
1334                }
1335                else if( cmpID.equals(BaseConstants.COMPONENT_FIELDS_ID) )
1336                {
1337                    ((CmpFieldsBean) cb).getFieldsSelector()
1338                                             .saveFields(gres, table, dataID);
1339                }
1340                     
1341                else if( cmpID.equals(BaseConstants.COMPONENT_CATEGORIES_ID) )
1342                {
1343                    try
1344                    {
1345                        ((CmpCategoryBean) cb).getCategorySelector()
1346                                       .saveCatLinks(table, dataID, "");
1347                    }catch(SQLException JavaDoc e)
1348                    {
1349                        LoggingManager.log("Error while adding item:"+dataID+" to a category!",this);
1350                    }
1351
1352                }
1353// else
1354
// LoggingManager.log("Unknown component used in this module! Please implement.", this);
1355
}
1356            catch(SQLException JavaDoc e) {
1357                LoggingManager.log("Cannot save news entry with data ID " + dataID +
1358                                   ". Exception: " + e.getMessage(), this);
1359                return false;
1360            }
1361        } // while
1362

1363
1364        if(linkedurls>0) newsEntry.setFlaglinks( true );
1365        if(linkedpics>0) newsEntry.setFlagpictures( true );
1366        if(linkedfiles>0) newsEntry.setFlagfiles( true );
1367        try
1368        {
1369            nwsList.save(newsEntry);
1370        }catch(SQLException JavaDoc e)
1371        {
1372            LoggingManager.log("Cannot save news entry with data ID " + dataID +
1373                               ". Exception: " + e.getMessage(), this);
1374            return false;
1375        }
1376        nwsList = null;
1377        LoggingManager.log("Saved entry id " + cc.getDataID() + " for vmodule " + vmodule.getIdentification(), this);
1378        return true;
1379    }
1380
1381    /**
1382     *
1383     */

1384    public boolean saveEABaseListEntryFlags(EABaseListEntry lstEntry)
1385    {
1386        int id = lstEntry.getRowId();
1387        if(id <= ComponentConstants.COMPONENT_NEW_DATAID)
1388            return false; // should be impossible to happen
1389

1390        // is it a new record that has no ID yet or not
1391
nwsList = new NwslistManager(vmodule.getIdentification());
1392        nwsList.setDataSource(vmodule.getDatasource());
1393
1394        Nwslist newsEntry = new Nwslist();
1395        try
1396        {
1397            newsEntry.setIsNew(false);
1398            newsEntry.setRowid(id);
1399            newsEntry.setFlagvisible(lstEntry.getFlagVisible());
1400            newsEntry.setFlagentrydte(lstEntry.getFlagEntryDte());
1401            newsEntry.setFlagtimedpub(lstEntry.getFlagTimedPub());
1402            newsEntry.setFlaglinks(lstEntry.getFlagLinks());
1403            newsEntry.setFlagpictures(lstEntry.getFlagPics());
1404            newsEntry.setFlagfiles(lstEntry.getFlagFiles());
1405
1406            nwsList.save(newsEntry);
1407        }
1408        catch(SQLException JavaDoc e) {
1409            LoggingManager.log("Cannot save news flags with data ID " + id +
1410                               ". Exception: " + e.getMessage(), this);
1411            return false;
1412        }
1413
1414        nwsList = null;
1415        return true;
1416    }
1417
1418    /**
1419     *
1420     */

1421    public boolean deleteEABaseListEntry(EABaseListEntry lstEntry)
1422    {
1423        int id = lstEntry.getRowId();
1424        if(id <= ComponentConstants.COMPONENT_NEW_DATAID)
1425            return false; // should be impossible to happen
1426

1427        // is it a new record that has no ID yet or not
1428
nwsList = new NwslistManager(vmodule.getIdentification());
1429        nwsList.setDataSource(vmodule.getDatasource());
1430
1431
1432        OwxurlsManager urlmanager=new OwxurlsManager();
1433        String JavaDoc urltable=urlmanager.getTableID();
1434        urlmanager=null;
1435
1436        OwxflinksManager filelinksmanager=new OwxflinksManager();
1437        String JavaDoc filelinktable=filelinksmanager.getTableID();
1438        filelinksmanager=null;
1439
1440        String JavaDoc table = nwsList.getTableID();
1441        try
1442        {
1443            // 1: delete all localized fields for entry
1444
gres.deleteLocalizedFields(table, id );
1445            /*gres.deleteMessages(table, id, BaseConstants.RESMSGFIELD_TITLE);
1446            gres.deleteMessages(table, id, BaseConstants.RESMSGFIELD_TEXT);
1447             */

1448            
1449            // 1: delete all fields for entry
1450

1451            gres.deleteFields(table,id);
1452
1453            // 2: delete all links to pictures for entry
1454
if(picturesEnabled)
1455            {
1456                Vector v=gres.deleteFileLinks(table, id, BaseConstants.RESPICFIELD_PIC);
1457                if(v!=null)
1458                    for(int i=0;i<v.size();i++)
1459                    {
1460                        Integer JavaDoc I=(Integer JavaDoc)v.get(i);
1461                        gres.deleteMessages(filelinktable, I.intValue(),BaseConstants.RESPICFIELD_LINK);
1462                    }
1463            }
1464
1465
1466
1467            // 3: delete all links to files for entry
1468
if(filesEnabled)
1469            {
1470                Vector v=gres.deleteFileLinks(table, id, BaseConstants.RESFILEFIELD_FILE);
1471                if(v!=null)
1472                    for(int i=0;i<v.size();i++)
1473                    {
1474                        Integer JavaDoc I=(Integer JavaDoc)v.get(i);
1475                        gres.deleteMessages(filelinktable, I.intValue(),BaseConstants.RESFILEFIELD_LINK);
1476                    }
1477            }
1478
1479            // 3: delete all URLs assigned to entry
1480
if(linksEnabled)
1481            {
1482                Vector v=gres.deleteURLs(table, id, BaseConstants.RESURLFIELD_URL);
1483                if(v!=null)
1484                    for(int i=0;i<v.size();i++)
1485                    {
1486                        Integer JavaDoc I=(Integer JavaDoc)v.get(i);
1487                        gres.deleteMessages(urltable, I.intValue(),BaseConstants.RESURLFIELD_URL);
1488                    }
1489            }
1490            
1491            //4: delete category links to this entry if any
1492

1493             gres.deleteCatLink(table,id);
1494
1495            // 5: delete the entry itself
1496
nwsList.deleteByKey(id);
1497        }
1498        catch(SQLException JavaDoc e) {
1499            LoggingManager.log("Cannot delete news entry with data ID " + id +
1500                               ". Exception: " + e.getMessage(), this);
1501            return false;
1502        }
1503
1504        nwsList = null;
1505        LoggingManager.log("Deleted entry id " + id + " from vmodule " + vmodule.getIdentification(), this);
1506        return true;
1507    }
1508
1509
1510     /**
1511     *
1512     */

1513    public boolean isPreviewEnabled() { return previewEnabled; }
1514
1515    /**
1516     *
1517     */

1518    public boolean arePropertiesEnabled() { return propertiesEnabled; }
1519
1520
1521    /**
1522     *
1523     */

1524    public boolean areFilesEnabled() { return filesEnabled; }
1525
1526
1527     /**
1528     *
1529     */

1530    public int getFilesCount() { return filesCount; }
1531
1532
1533    /**
1534     *
1535     */

1536    public boolean arePicturesEnabled() { return picturesEnabled; }
1537
1538
1539     /**
1540     *
1541     */

1542    public int getPicturesCount() { return picturesCount; }
1543
1544    /**
1545     *
1546     */

1547    public boolean areLinksEnabled() { return linksEnabled; }
1548
1549     /**
1550     *
1551     */

1552    public int getLinksCount() { return linksCount; }
1553
1554
1555
1556    /**
1557     *
1558     */

1559    public boolean areCategoriesEnabled() { return categoriesEnabled; }
1560
1561     /**
1562     *
1563     */

1564    public int getCategoryItemsCount() { return categoryItemCount; }
1565    
1566    /**
1567     *
1568     */

1569    public boolean areFieldsEnabled() { return fieldsEnabled; }
1570
1571}
1572
1573// eof
1574
Popular Tags