KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > field > TKFieldTableRowOriented


1 package com.teamkonzept.field;
2
3 import java.util.*;
4 import com.teamkonzept.lib.*;
5 import com.teamkonzept.publishing.markups.*;
6 import com.teamkonzept.web.*;
7 import com.teamkonzept.field.db.*;
8 import com.teamkonzept.international.LanguageManager;
9
10 public class TKFieldTableRowOriented
11     extends TKFieldTableOriented
12 {
13     // $Id: TKFieldTableRowOriented.java,v 1.17 2001/09/21 14:22:06 uli Exp $
14

15     public static final String JavaDoc CLASS_ID = "FIELDTABLEROWORIENTED";
16
17
18     public TKFieldTableRowOriented() {}
19
20     public TKFieldTableRowOriented( String JavaDoc name, TKVector fields )
21     {
22         this( name, fields, null, null );
23     }
24
25
26     public TKFieldTableRowOriented(
27         String JavaDoc name,
28         TKVector fields,
29         TKBaseField rowEntry,
30         TKBaseField colEntry )
31     {
32         this( name, fields, rowEntry, colEntry, null );
33     }
34
35
36
37     public TKFieldTableRowOriented(
38         String JavaDoc name,
39         TKVector fields,
40         TKBaseField rowEntry,
41         TKBaseField colEntry ,
42         String JavaDoc showName )
43     {
44         initFieldTableRowOriented( "FIELDTABLEROWORIENTED", name, fields, rowEntry, colEntry, showName );
45     }
46
47     public final void initFieldTableRowOriented(
48         String JavaDoc fieldType,
49         String JavaDoc name,
50         TKVector fields,
51         TKBaseField rowEntry,
52         TKBaseField colEntry ,
53         String JavaDoc showName )
54     {
55         initFieldTableOriented( "FIELDTABLEROWORIENTED", name, fields, rowEntry, colEntry, showName );
56
57     }
58
59     /**
60      * Methode zur Definition Row-Orientierter Tabellen
61      */

62     public TKFieldGroup getDefGroup(TKFieldSwitch allSwitch, TKFieldSwitchList allSwitchList) {
63
64         TKBaseField [] groupTableArray = {
65             allSwitchList
66         };
67
68         //======================= Switch und Check =================//
69
//---- Eine Checkbox, falls "Yes" selectiert wurde ----//
70
TKVector singleCheckVector = new TKVector(2);
71         singleCheckVector.addElement(
72             new TKOptionFieldEntry( LanguageManager.getText(LANGUAGE_CONTEXT, "FIELDTABLE_CELL"), "CELL" ) );
73         singleCheckVector.addElement(
74             new TKOptionFieldEntry( LanguageManager.getText(LANGUAGE_CONTEXT, "FIELDTABLE_ROW_COLUMN"), "NOCELL" ) );
75
76
77         TKBaseField [] switchAndCheckArray = {
78             new TKSelectField( "ZUSATZ", LanguageManager.getText(LANGUAGE_CONTEXT, "FIELDTABLE_ADDINFO"),singleCheckVector ),
79             allSwitch
80         };
81
82         //======================= SPALTENINFOS =================//
83
//---- Gruppe wird erzeugt mit einer Switchauswahl und einer Checkbox ----//
84
TKFieldGroup switchAndCheckGroup =
85             new TKFieldGroup( TKFieldOption.CLASS_ID, new TKVector( switchAndCheckArray ), LanguageManager.getText(LANGUAGE_CONTEXT, "FIELDTABLE_INFOCOLUMN"));
86
87         //================== ZEILENINFOS =====================/
88
//---- Gruppe wird erzeugt mit einer Switchauswahl und einer Checkbox ----//
89
TKFieldGroup switchAndCheckGroup2 =
90             new TKFieldGroup( TKFieldOption.CLASS_ID, new TKVector( switchAndCheckArray ), LanguageManager.getText(LANGUAGE_CONTEXT, "FIELDTABLE_INFOROW") );
91
92         //========================= TABELLE ==================================//
93
TKFieldGroup groupGroupTable =
94             new TKFieldGroup( TKFieldGroup.CLASS_ID, new TKVector( groupTableArray ), LanguageManager.getText(LANGUAGE_CONTEXT, "FIELDTABLE_GROUPING"));
95
96         TKBaseField [] tableRowOrientedArray = {
97             new TKInputField( TKFieldTableRowOriented.NAME_KEY, 16, 80, LanguageManager.getText(LANGUAGE_CONTEXT, "FIELDTABLE_NAME"), TKInputField.CHECK_STRING),
98             new TKInputField( TKFieldTableRowOriented.SHOW_NAME_KEY, 50, 254, LanguageManager.getText(LANGUAGE_CONTEXT, "FIELDTABLE_SHOWNAME"), TKInputField.CHECK_STRING),
99             allSwitchList,
100             new TKFieldOption( "JANEINSPALTE", switchAndCheckGroup, LanguageManager.getText(LANGUAGE_CONTEXT, "FIELDTABLE_JANEINSPALTE")),
101             new TKFieldOption( "JANEINZEILE", switchAndCheckGroup2, LanguageManager.getText(LANGUAGE_CONTEXT, "FIELDTABLE_JANEINZEILE"))
102
103         };
104
105         TKFieldGroup tableRowOrientedGroup =
106             new TKFieldGroup( TKFieldTableRowOriented.CLASS_ID, new TKVector( tableRowOrientedArray ), LanguageManager.getText(LANGUAGE_CONTEXT, TKFieldTableRowOriented.CLASS_ID) );
107
108         return tableRowOrientedGroup;
109     }
110
111
112     //***********************************************************************
113
public Object JavaDoc compileData( String JavaDoc prefix, TKHashtable data, TKHashtable context )
114     {
115         int entryCount = fieldList.size();
116         if( entryCount == 0 ) return new TKFieldTableOrientedData(null, null, null);
117
118         TKVector result = new TKVector(1);
119         TKVector colVector = null;
120         prefix = subPrefix( prefix );
121
122         int tableSize = Integer.parseInt( (String JavaDoc)data.get(prefix+"SIZE") );
123
124
125         int cols = entryCount;
126         int rows = tableSize;
127
128         //-----------------------------------//
129
//---- Data fuer eine zusatz ROW ----//
130
//-----------------------------------//
131
TKVector rowInfoVector = null;
132         if(rowEntry != null) {
133
134             rowInfoVector = new TKVector();
135             for( int x=0; x< rows; x++ ) {
136                 rowInfoVector.addElement(rowEntry.compileData( prefix+PRE_ROWS+"."+x+".", data, context ));
137             }
138         }
139
140         //---------------------------------------//
141
//---- Data fuer eine zusatz COLUMN ----//
142
//---------------------------------------//
143
TKVector colInfoVector = null;
144         if((colEntry != null) && (cols > 0) ){
145             colInfoVector = new TKVector(cols);
146             if(rows > 0) {
147                 for( int x=0; x< cols; x++ ) {
148                     colInfoVector.addElement(colEntry.compileData( prefix+PRE_COLS+"."+x+".", data, context ));
149                 }
150             }
151             else {
152                 for( int x=0; x< cols; x++ ) {
153                     colInfoVector.addElement(colEntry.getDefault());
154                 }
155             }
156         }
157
158         //-----------------//
159
//---- tabelle ----//
160
//-----------------//
161
for(int x=0; x < tableSize; x++) {
162             colVector = new TKVector( entryCount );
163             for( int y=0; y<entryCount; y++ ) {
164                 TKBaseField field = (TKBaseField) fieldList.get( y );
165                 colVector.addElement(field.compileData(prefix+x+"."+y+".", data, context) );
166             }
167             result.addElement(colVector);
168         }
169         return new TKFieldTableOrientedData(result, rowInfoVector, colInfoVector);
170
171     }
172
173     public Object JavaDoc compileData( String JavaDoc prefix, TKMarkupNode data, TKHashtable context )
174     {
175         int entryCount = fieldList.size();
176
177         if( entryCount == 0 ) return new TKFieldTableOrientedData(null, null, null);
178
179         TKXmlMarkup markup = data == null ? null : (TKXmlMarkup) data.markup;
180         if (markup == null) { return null;}
181
182         if (!markup.name.equals (getName())) {
183             return null;
184         }
185
186         TKXmlTree tree = (TKXmlTree) data.tree;
187         if (tree == null) { return null;}
188
189         TKVector rowInfoVector = null;
190         TKVector colInfoVector = null;
191         TKVector result = null;
192
193         int x = 0;
194
195         for (int i = 0; i < tree.size(); i++) {
196
197             Object JavaDoc obj = tree.getSub(i);
198             if (obj == null) continue;
199
200             TKMarkupNode subNode = null;
201             TKXmlMarkup subMarkup = null;
202
203             if (obj instanceof TKXmlMarkup) { // Atomares Markup
204

205                 subMarkup = (TKXmlMarkup) obj;
206                 continue;
207
208             } else {
209                 subNode = (TKMarkupNode) obj;
210                 subMarkup = (TKXmlMarkup) subNode.markup;
211             }
212
213             if (subMarkup.name.equals ("CI")) {
214
215                 TKXmlTree subTree = (TKXmlTree) subNode.tree;
216                 if (subTree == null) { continue; }
217
218                 for (int j = 0; j < subTree.size(); j++) {
219
220                     Object JavaDoc subObj = subTree.getSub(j);
221                     if (subObj == null) continue;
222
223                     TKMarkupNode subSubNode = null;
224                     TKXmlMarkup subSubMarkup = null;
225
226                     if (subObj instanceof TKXmlMarkup) { // Atomares Markup
227

228                         subSubMarkup = (TKXmlMarkup) subObj;
229                         subSubNode = new TKMarkupNode (subSubMarkup,null);
230
231                     } else {
232                         subSubNode = (TKMarkupNode) subObj;
233                         subSubMarkup = (TKXmlMarkup) subSubNode.markup;
234                     }
235
236                     if (colInfoVector == null) colInfoVector = new TKVector();
237                     colInfoVector.addElement(colEntry.compileData( prefix+j+".", subSubNode, context ));
238                 }
239             }
240
241             else if (subMarkup.name.equals ("TR")) {
242
243                     TKVector colsResultVector = null;
244
245                 TKXmlTree subTree = (TKXmlTree) subNode.tree;
246                 if (subTree == null) { continue; }
247
248                 int y = 0;
249                 for (int j = 0; j < subTree.size(); j++) {
250
251
252                     Object JavaDoc subObj = subTree.getSub(j);
253                     if (subObj == null) continue;
254
255                     if (y >= entryCount) {
256
257                         break;
258                     }
259                     TKMarkupNode subSubNode = null;
260                     TKXmlMarkup subSubMarkup = null;
261
262                     if (subObj instanceof TKXmlMarkup) { // Atomares Markup
263

264                         subSubMarkup = (TKXmlMarkup) subObj;
265                         subSubNode = new TKMarkupNode (subSubMarkup,null);
266
267                     } else {
268                         subSubNode = (TKMarkupNode) subObj;
269                         subSubMarkup = (TKXmlMarkup) subSubNode.markup;
270                     }
271
272                     TKXmlTree subSubTree = (TKXmlTree) subSubNode.tree;
273                     Object JavaDoc subSubObj = subSubTree.getSingleSub();
274                     if (subSubObj == null) continue;
275
276                     TKMarkupNode subSubSubNode = null;
277                     TKXmlMarkup subSubSubMarkup = null;
278
279                     if (subSubObj instanceof TKXmlMarkup) { // Atomares Markup
280

281                         subSubSubMarkup = (TKXmlMarkup) subSubObj;
282                         subSubSubNode = new TKMarkupNode (subSubSubMarkup,null);
283
284                     } else {
285                         subSubSubNode = (TKMarkupNode) subSubObj;
286                         subSubSubMarkup = (TKXmlMarkup) subSubSubNode.markup;
287                     }
288
289                     if (subSubMarkup.name.equals ("RI")) {
290
291                         if (rowInfoVector == null) rowInfoVector = new TKVector();
292                         rowInfoVector.addElement(rowEntry.compileData( prefix+j+".", subSubSubNode, context ));
293                     } else {
294                         if (result == null) result = new TKVector();
295                         if (colsResultVector == null) {
296
297                             colsResultVector = new TKVector();
298                             result.addElement(colsResultVector);
299                         }
300
301                         TKBaseField field = (TKBaseField) fieldList.get( y );
302                         if (field == null)
303                             ;
304                         else colsResultVector.addElement
305                             (field.compileData( prefix+x+"."+y+".", subSubSubNode, context ));
306                         y++;
307                     }
308                 }
309
310                 x++;
311             }
312
313             else {
314                 ;
315             }
316         }
317
318         return new TKFieldTableOrientedData(result, rowInfoVector, colInfoVector);
319     }
320
321     public void fillIntoTemplate( TKHTMLTemplate t, Object JavaDoc data, String JavaDoc prefix )
322     {
323         TKFieldTableOrientedData dataClass = (TKFieldTableOrientedData) data;
324         TKVector dataVector = (TKVector) dataClass.contentData;
325         super.fillIntoTemplate( t, data, prefix );
326
327         if(dataVector == null) {
328             t.set("SIZE", "0");
329         }
330         else {
331             t.set("SIZE", String.valueOf(dataVector.size()) );
332             t.set("IS_OUTERLIST", Boolean.TRUE);
333         }
334
335         int rows = ( dataVector == null ? 0 : dataVector.size() );
336         int cols = fieldList.size();
337
338
339         if( (TKVector)dataClass.rowData != null )
340             t.set("IS_COLFORINFOS", Boolean.TRUE);
341
342         if( (TKVector)dataClass.colData != null )
343             t.set("IS_ROWFORINFOS", Boolean.TRUE);
344
345
346
347         t.setListIterator( new TKFieldTableRowOrientedIterator(
348             dataClass,
349             fieldList,
350             rowEntry,
351             colEntry,
352             subPrefix( prefix ),
353             t.getListIterator(),
354             "OUTERLIST",
355             "INNERLIST",
356             "ROWFORINFOLIST",
357             fieldType
358         ) );
359
360         //t.set( "FIELDTABLELIST", Boolean.TRUE );
361
}
362
363     public void fillIntoPresentation( TKHTMLTemplate t, Object JavaDoc data, String JavaDoc scope )
364     {
365         TKFieldTableOrientedData dataClass = (TKFieldTableOrientedData) data;
366         TKVector dataVector = (TKVector) dataClass.contentData;
367
368         t.set(scope+"."+getName()+".COLSIZE", String.valueOf( dataVector.size() ) );
369         t.set(scope+"."+getName()+".ROWSIZE", String.valueOf( fieldList.size() ) );
370
371         //---- tabellenlayout ----//
372
if( (TKVector)dataClass.rowData != null )
373                 t.set("IS_ROWENTRY", Boolean.TRUE);
374
375         if( (TKVector)dataClass.colData != null )
376                 t.set("IS_COLENTRY", Boolean.TRUE);
377
378         if(dataVector != null)
379         t.set("IS_OUTERLIST", Boolean.TRUE);
380
381         //--- Ueberschrift ----//
382
if(isRowCell == false)
383           t.set("HEADERROW", Boolean.TRUE);
384         if(isColCell == false)
385           t.set("HEADERCOL", Boolean.TRUE);
386
387         t.setListIterator( new TKTableRowShowIterator(
388             dataClass,
389             fieldList,
390             rowEntry,
391             colEntry,
392             scope,
393             getName(),
394             t.getListIterator(),
395             "OUTERLIST",
396             "INNERLIST",
397             "ROWFORINFOLIST"
398         ) );
399
400
401     }
402
403     //***********************************************************************
404
public Object JavaDoc modify( String JavaDoc action, String JavaDoc fieldPath, Object JavaDoc data, String JavaDoc prefix, StringBuffer JavaDoc destination )
405     {
406         TKFieldTableOrientedData dataClass = (TKFieldTableOrientedData) data;
407         TKVector dataVector = (TKVector) dataClass.contentData;
408
409
410         int pLength = prefix.length()+fieldName.length();
411
412         //--------------------------------------//
413
//----action betrifft Tabelle selbst----//
414
//--------------------------------------//
415
if(fieldPath.length() == pLength ) {
416             int entryCount = fieldList.size();
417             int dataVectorSize = dataVector.size();
418
419             if(action.equals("ADD")) {
420                 TKVector colVector = new TKVector( entryCount );
421
422                 //---- Zusatztrow ----//
423
if( rowEntry != null ) {
424                     dataClass.rowData.addElement(rowEntry.getDefault());
425                 }
426
427                 //---- Zusatzcol HAT FESTE Groesse fest!!! ----//
428

429                 for( int i=0; i<entryCount; i++ ) {
430                     TKBaseField field = (TKBaseField) fieldList.get( i );
431                     colVector.addElement(field.getDefault() );
432                 }
433                 dataVector.addElement(colVector);
434                 destination.append( prefix+fieldName+"."+(dataClass.contentData.size()-1)+".");
435             }
436         }
437         //----------------------------------------------------------//
438
//---- Action betrifft eine Zeile/Spalte der Tabelle -------//
439
//----------------------------------------------------------//
440
else if(fieldPath.length()-3 == pLength) {
441
442             int index = 0;
443             String JavaDoc subPath = fieldPath.substring( pLength+1 );
444             StringTokenizer getToken = new StringTokenizer( subPath, ".");
445             index = Integer.parseInt( (String JavaDoc)getToken.nextElement() );
446
447             if(action.equals("DELETE")) {
448                 if(index == 0)
449                     destination.append( prefix+fieldName+"."+index+".");
450                 else
451                     destination.append( prefix+fieldName+"."+(index-1)+".");
452                 data = actionIsDelete(dataClass, index);
453             }
454             if(action.equals("INSERT")) {
455                 destination.append( prefix+fieldName+"."+index+".");
456                 dataClass = actionIsInsert(dataClass, index);
457
458             }
459             if(action.equals("FIRST")) {
460                 destination.append( prefix+fieldName+"."+0+".");
461                 dataClass = actionIsFirst(dataClass, index);
462                 if(index != 0)
463                     data = actionIsDelete(dataClass, index+1);
464
465             }
466             if(action.equals("LAST")) {
467                 destination.append( prefix+fieldName+"."+(dataClass.contentData.size()-1)+".");
468                 dataClass = actionIsLast(dataClass, index);
469                 data = actionIsDelete(dataClass, index);
470
471             }
472             if(action.equals("FORWARD")) {
473                 if(index == dataClass.contentData.size()-1)
474                     destination.append( prefix+fieldName+"."+index+".");
475                 else
476                     destination.append( prefix+fieldName+"."+(index+1)+".");
477                 dataClass = actionIsForward(dataClass, index);
478                 if(index != dataClass.contentData.size()-1)
479                     data = actionIsDelete(dataClass, index);
480
481             }
482             if(action.equals("BACK")) {
483                 if(index == 0)
484                     destination.append( prefix+fieldName+"."+0+".");
485                 else
486                     destination.append( prefix+fieldName+"."+(index-1)+".");
487                 dataClass = actionIsBack(dataClass, index);
488                 if(index != 0)
489                     data = actionIsDelete(dataClass, index+1);
490             }
491
492
493         }
494         //-------------------------------------//
495
//---- action betrifft Sub-ELement ----//
496
//-------------------------------------//
497
else {
498
499             String JavaDoc subZusatz = fieldPath.substring( pLength+1);
500
501                     //---- modify des SubElementes in einer ZusatzRow ----//
502
if( subZusatz.startsWith( PRE_ROWS ) ) {
503                 subZusatz = subZusatz.substring( PRE_ROWS.length()+1 );
504                 int idxEnd = subZusatz.indexOf('.');
505                 String JavaDoc idxStr = subZusatz.substring( 0, idxEnd );
506                 int idx = Integer.parseInt( idxStr );
507
508                 dataClass.rowData.put( idx, rowEntry.modify(
509                     action, fieldPath, dataClass.rowData.get( idx ),
510                     prefix+fieldName+'.'+PRE_ROWS+"."+idx+'.', destination
511                 ) );
512
513             }
514             //---- modify des SubElementes in einer ZusatzCol ----//
515
else if( subZusatz.startsWith( PRE_COLS ) ) {
516                 subZusatz = subZusatz.substring( PRE_COLS.length()+1 );
517                 int idxEnd = subZusatz.indexOf('.');
518                 String JavaDoc idxStr = subZusatz.substring( 0, idxEnd );
519                 int idx = Integer.parseInt( idxStr );
520                 dataClass.colData.put( idx, colEntry.modify(
521                     action, fieldPath, dataClass.colData.get( idx ),
522                     prefix+fieldName+'.'+PRE_COLS+"."+idx+'.',
523                     destination
524                 ) );
525             }
526             //---- modify des SubElementes in einer Zelle ----//
527
else {
528                 String JavaDoc subName = fieldPath.substring( pLength+5);
529                 int idx = subName.indexOf('.');
530                 if(idx >= 0)
531                     subName = subName.substring(0,idx);
532                 TKBaseField field = (TKBaseField) tableFields.get( subName );
533
534                 String JavaDoc subPath = fieldPath.substring( pLength+1);
535
536                 StringTokenizer getToken = new StringTokenizer(subPath, ".");
537                 int rowIdx = Integer.parseInt( (String JavaDoc) getToken.nextElement() );
538                 int colIdx = Integer.parseInt( (String JavaDoc) getToken.nextElement() );
539
540
541                 TKVector rowVector = (TKVector) dataVector.elementAt(rowIdx);
542
543                 rowVector.put( colIdx, field.modify(
544                     action, fieldPath, rowVector.get(colIdx),
545                     prefix+fieldName+"."+rowIdx+"."+colIdx+".", destination
546                 ) );
547             }
548         }
549         return data;
550     }
551
552     public TKFieldTableOrientedData actionIsDelete( TKFieldTableOrientedData dataClass, int index )
553     {
554
555         dataClass.contentData.removeElementAt(index);
556
557         if( (colEntry != null) && (dataClass.contentData.isEmpty()) )
558             dataClass.colData = null;
559
560
561         if(rowEntry != null)
562             if (dataClass.contentData.isEmpty() )
563                 dataClass.rowData = null;
564             else
565                 dataClass.rowData.removeElementAt(index);
566
567         return dataClass;
568     }
569
570     //*************************************************************************************
571
public TKFieldTableOrientedData actionIsInsert( TKFieldTableOrientedData dataClass, int index )
572     {
573
574         TKVector newVector = new TKVector ();
575         for(int x = 0; x < fieldList.size(); x++) {
576             newVector.addElement( ( (TKBaseField)fieldList.elementAt(x)).getDefault());
577         }
578         dataClass.contentData.insertElementAt(newVector,index);
579
580         if(rowEntry != null)
581             dataClass.rowData.insertElementAt(rowEntry.getDefault(), index);
582
583         return dataClass;
584     }
585
586     //*************************************************************************************
587
public TKFieldTableOrientedData actionIsFirst( TKFieldTableOrientedData dataClass, int index )
588     {
589
590         if(index > 0) {
591             TKVector insertVector = (TKVector) dataClass.contentData.elementAt(index);
592             dataClass.contentData.insertElementAt(insertVector,0);
593
594             if(rowEntry != null)
595                 dataClass.rowData.insertElementAt(dataClass.rowData.elementAt(index), 0);
596         }
597             return dataClass;
598     }
599
600     //*************************************************************************************
601
public TKFieldTableOrientedData actionIsLast( TKFieldTableOrientedData dataClass, int index )
602     {
603         int size = dataClass.contentData.size();
604
605         TKVector insertVector = (TKVector) dataClass.contentData.elementAt(index);
606         dataClass.contentData.insertElementAt(insertVector,size);
607
608
609         if(rowEntry != null)
610             dataClass.rowData.insertElementAt(dataClass.rowData.elementAt(index), size);
611         return dataClass;
612     }
613
614     public TKFieldTableOrientedData actionIsBack( TKFieldTableOrientedData dataClass, int index )
615     {
616         if(index == 0) return dataClass;
617         if(index > 1) {
618             TKVector insertVector = (TKVector) dataClass.contentData.elementAt(index);
619             dataClass.contentData.insertElementAt(insertVector,index-1);
620
621             if(rowEntry != null)
622                 dataClass.rowData.insertElementAt(dataClass.rowData.elementAt(index), index-1);
623         }
624         else if(index == 1) {
625             dataClass = actionIsFirst(dataClass, index);
626         }
627         return dataClass;
628     }
629
630     public TKFieldTableOrientedData actionIsForward( TKFieldTableOrientedData dataClass, int index )
631     {
632         int size = dataClass.contentData.size();
633
634         if(index == size-1) return dataClass;
635
636         else {
637             TKVector insertVector = (TKVector) dataClass.contentData.elementAt(index);
638             dataClass.contentData.insertElementAt(insertVector,index+2);
639
640             if(rowEntry != null)
641                 dataClass.rowData.insertElementAt(dataClass.rowData.elementAt(index), index+2);
642         }
643         return dataClass;
644     }
645
646     //***********************************************************************
647
public int insertDataIntoDB( TKContentDBData db, Object JavaDoc data, int contentId, int leftNr )
648     {
649         int entryCount = fieldList.size();
650         if( entryCount == 0 ) return leftNr;
651
652         TKContentNodeTableData node = insertNewContentNode( db, contentId, leftNr );
653         int newNodeId = node.content_node_id;
654
655         TKFieldTableOrientedData dataClass = (TKFieldTableOrientedData) data;
656         TKVector dataVector = (TKVector) dataClass.contentData;
657
658         insertNewContentValue(db, contentId, newNodeId, 0, String.valueOf(dataVector != null ? dataVector.size() : 0));
659         leftNr++;
660
661         //---- InfoRow ----//
662
if(rowEntry != null) {
663             for (int x=0; x < dataVector.size(); x++) {
664                 node.right_nr = rowEntry.insertDataIntoDB( db, dataClass.rowData.elementAt(x), contentId, leftNr+1 )+1;
665             }
666         }
667
668         //------ InfoCol ----//
669
if(colEntry != null) {
670             for (int x=0; x < fieldList.size(); x++) {
671                 node.right_nr = colEntry.insertDataIntoDB( db, dataClass.colData.elementAt(x), contentId, leftNr+1 )+1;
672             }
673         }
674
675
676         //---- Table ----//
677
if(dataVector != null) {
678             for(int x= 0; x < dataVector.size(); x++) {
679                 for( int y=0; y< entryCount; y++ ) {
680                     TKBaseField field = (TKBaseField) fieldList.get( y );
681                     leftNr = field.insertDataIntoDB( db, ((TKVector) dataVector.elementAt(x)).elementAt(y), contentId, leftNr+1 );
682                     leftNr++;
683                 }
684             }
685         }
686
687         node.right_nr = leftNr;
688         return leftNr;
689
690     }
691
692     //***********************************************************************
693
public Object JavaDoc getDataFromDB( TKContentDBData db )
694     {
695         int entryCount = fieldList.size();
696         if( entryCount == 0 ) return new TKVector();
697
698         TKVector dataVector = new TKVector( );
699         TKContentNodeTableData node = getContentNodeFromDB( db );
700
701         TKContentValueTableData value0 = getContentNodeValueFromDB(db, node);
702         int dataVectorSize = Integer.parseInt( value0.value);
703
704         TKVector rowInfoVector = new TKVector(dataVectorSize );
705         TKVector colInfoVector = new TKVector(entryCount);
706
707
708         //---- Info Row ----//
709
if(rowEntry != null) {
710             for( int x=0; x< dataVectorSize; x++ ) {
711                 rowInfoVector.addElement(rowEntry.getDataFromDB( db ));
712             }
713         }
714         else rowInfoVector = null;
715
716
717         //---- Info Col ----//
718
if(colEntry != null) {
719             for( int x=0; x< entryCount; x++ ) {
720                 colInfoVector.addElement(colEntry.getDataFromDB( db ));
721             }
722         }
723         else colInfoVector = null;
724
725
726         //---- table ----//
727
for(int x=0; x < dataVectorSize; x++) {
728             TKVector colVector = new TKVector(entryCount);
729             for( int i=0; i < entryCount; i++ ) {
730                 TKBaseField field = (TKBaseField) fieldList.get( i );
731                 colVector.addElement(field.getDataFromDB( db ));
732             }
733             dataVector.addElement(colVector);
734         }
735
736         return new TKFieldTableOrientedData(dataVector, rowInfoVector, colInfoVector);
737     }
738
739 }
740
Popular Tags