1 package com.teamkonzept.webman.mainint; 2 3 import com.teamkonzept.lib.*; 4 5 import java.sql.*; 6 7 public class TKComponentIterator implements TKListIterator { 8 9 TKListIterator oldIterator; 10 String listName; 11 ResultSet rsPC; 12 TKDBResult rsDC, rsDR; 13 int currDC = 0; 14 int currDR = 0; 15 int idxDC, idxDR; 16 17 public TKComponentIterator( ResultSet rsPC, TKDBResult rsDC, TKDBResult rsDR, TKListIterator oldIterator, String listName ) 18 { 19 this.oldIterator = oldIterator; 20 this.listName = listName; 21 this.rsPC = rsPC; 22 this.rsDC = rsDC; 23 this.rsDR = rsDR; 24 this.idxDC = getCompIdx( (TKDBResultRow)(rsDC.get( currDC )), "PRESENTATION_COMPONENT_IDX" ); 25 this.idxDR = getCompIdx( (TKDBResultRow)(rsDR.get( currDR )), "SRC_PRESENTATION_COMPONENT_IDX" ); 26 } 27 28 public int getCompIdx( TKDBResultRow row, String name ) 29 { 30 if( row != null ) { 31 String sVal = (String ) row.getColumn( name ); 32 int val = Integer.parseInt( sVal ); 33 return val; 34 } 35 else return -1; 36 } 37 38 public boolean apply( TKTemplate template, int i, String currListName ) 39 { 40 if( currListName.equalsIgnoreCase( listName ) ) { 41 try { 42 if( !TKDBTemplate.prepareTemplate( rsPC,template ) ) return false; 43 44 int idxPC = rsPC.getInt( "PRESENTATION_COMPONENT_IDX" ); 45 if( (idxPC == idxDC) ) { if( !TKDBTemplate.prepareTemplate( (TKDBResultRow) rsDC.get( currDC ), template ) ) throw new Error (); 47 this.idxDC = getCompIdx( (TKDBResultRow)(rsDC.get( ++currDC )), "PRESENTATION_COMPONENT_IDX" ); 48 template.set( "FILLED", "Yes" ); 49 } 50 else if( idxPC == idxDR ) { if( !TKDBTemplate.prepareTemplate( (TKDBResultRow) rsDR.get( currDR ), template ) ) throw new Error (); 52 this.idxDR = getCompIdx( (TKDBResultRow)(rsDR.get( ++currDR )), "SRC_PRESENTATION_COMPONENT_IDX" ); 53 template.set( "FILLED", "Yes" ); 54 } 55 } 56 catch( SQLException e ) { 57 throw new Error ( e.getMessage() ); 58 } 59 return true; 60 } 61 else if( oldIterator != null ) { 62 return oldIterator.apply( template, i, currListName ); 63 } 64 else { 65 return false; 66 } 67 } 68 } 69 70
| Popular Tags
|