import java.io.*; import java.util.*; public class Gen_pr_log { protected PrintWriter file; protected String filename; protected CodeGenerator theGenerator; protected Database schema; protected void OpenFile(String filename) { try { file = new PrintWriter( new FileWriter(filename) ); theGenerator.RegisterFile(filename); } catch(IOException e) { System.err.println("GENJAVA-F-BADOUTPUT: " + filename + " - " + e.getMessage()); System.exit(-1); } } Gen_pr_log(CodeGenerator generator) throws IOException { theGenerator = generator; schema = theGenerator.getTheSchema(); } void Generate_pr_log() { filename = new String(Genjava.directory); filename += Genjava.filesep; filename += "Pr_log.java"; OpenFile(filename); file.println("/**"); file.println(" * This class generates the log information for the schema"); file.println(" * @author Genjava v2.0"); file.println(" */"); file.println(""); file.println("import java.io.*;") ; file.println("import java.util.*;") ; file.println(""); file.println(" public class Pr_log{"); file.println(" protected static BufferedWriter hcg_logfileptr;"); file.println(" protected String hcg_logfile;"); file.println(" protected Database theSchema;"); file.println(""); gen_constructor(); gen_logstr(); gen_time_initialize(); gen_logwait(); gen_log_sleep(); gen_pr_startlog(); gen_pr_stoplog(); gen_log_do_add(); gen_log_do_delete(); gen_log_do_set_int(); gen_log_do_set_float(); gen_log_do_set_str(); gen_replay_log(); gen_pr_replay(); file.println("}"); file.close(); } void gen_constructor() { file.println(" /**"); file.println(" * Constructor"); file.println(" **/"); file.println(" public Pr_log(Database newSchema)"); file.println(" {"); file.println(" theSchema=newSchema;"); file.println(" }"); file.println(""); } void gen_time_initialize() { file.println(" /**"); file.println(" * Sets the timestamp global with the current time and clear the time_flag "); file.println(" **/"); file.println(" public static void time_initialize()"); file.println(" {"); file.println(" GlobalVarsBean.setStart_time();"); file.println(" }//end of time_initialize"); file.println(""); } void gen_logwait() { file.println(" /**"); file.println(" * This method computes the wait time between the log events,"); file.println(" * updates the wait time and posts the wait log entry to the log file"); file.println(" **/"); file.println(""); file.println(" public static void logwait()"); file.println(" { "); file.println(" if(GlobalVarsBean.getHcg_log()!=1)"); file.println(" System.exit(1); // the hcg_log option is not set to 1"); file.println(""); file.println(" //Computing the logtime"); file.println(" long logtime; // the difference since the last log event, we write this in the log file"); file.println(""); file.println(" // Time Difference = time Stored in the GlobalVarsBean - Current Time"); file.println(" logtime=System.currentTimeMillis()-GlobalVarsBean.getTime();"); file.println(""); file.println(" //update the time value in GlobalVarsBean"); file.println(" GlobalVarsBean.setTime(logtime);"); file.println(""); file.println(" //update the stored time (hcg_logtime"); file.println(" GlobalVarsBean.setStart_time();"); file.println(""); file.println(" //Write the string into the logfile"); file.println(""); file.println(" String logwait_str=\"WA \"+logtime;"); file.println(" logstr(logwait_str);"); file.println("}//end of logwait"); file.println(""); }//End Gen_logwait void gen_log_sleep() { file.println(" /**"); file.println(" * This method pauses the execution of the program for the specified "); file.println(" * amount of time "); file.println(" * @param msecs - the time to sleep in milliseconds "); file.println(" **/"); file.println(" public void log_sleep(long msecs)"); file.println(" {"); file.println(" try"); file.println(" {"); file.println(" Thread.sleep(msecs);"); file.println(" }"); file.println(" catch(InterruptedException e)"); file.println(" {"); file.println(" System.out.println(\"Wait time inturrupted:\"+e);"); file.println(" }"); file.println(" }//end of log_sleep"); file.println(""); } void gen_logstr() { file.println(" /**"); file.println(" * This method writes the given string into the log file"); file.println(" * @param text - contains the string to be printed "); file.println(" * to the log file. "); file.println(" * "); file.println(" * This function writes the text string to the logfile"); file.println(" * if logging is active "); file.println(" * "); file.println(" **/"); file.println(" public static void logstr(String text)"); file.println(" {"); file.println(" if (GlobalVarsBean.getHcg_log() == 1) "); file.println(" {"); file.println(" try{"); file.println(" hcg_logfileptr.write(text);"); file.println(" hcg_logfileptr.newLine();"); file.println(" hcg_logfileptr.flush();"); file.println(" }catch(Exception e){}"); file.println(" }"); file.println(" }//end of logstr"); file.println(""); } void gen_pr_startlog() { file.println(" /**"); file.println(" *"); file.println(" * This method is used to start a logging session."); file.println(" * It opens a logfile and dumps a current copy of the database"); file.println(" * Returns true if successful else false "); file.println(" *"); file.println(" **/"); file.println(" public boolean pr_startlog (String file_name)"); file.println(" {"); file.println(" String DB1string = \"DB1.dat\";"); file.println(" String logfileDB1_name;"); file.println(" String temp_file_name;"); file.println(" int i;"); file.println(""); file.println(" /* check that logging is off - if not, return without starting log*/"); file.println(" try"); file.println(" {"); file.println(" if (GlobalVarsBean.getHcg_log()!=0) throw new GenException(\"pr_startlog called when logging was not off.\");"); file.println(""); file.println(" /* opening the file */"); file.println(" if(file_name.indexOf(\".\")>0)"); file.println(" hcg_logfile=file_name.substring(0,file_name.indexOf(\".\"));"); file.println(" else"); file.println(" hcg_logfile=file_name;"); file.println(" temp_file_name=hcg_logfile+\".txt\";"); file.println(" hcg_logfileptr = new BufferedWriter(new FileWriter(temp_file_name) );"); file.println(""); file.println(" /*Database saved to name of log file + \"DB1\" */"); file.println(" logfileDB1_name=hcg_logfile+DB1string;"); file.println(" try{ theSchema.dump(logfileDB1_name);}catch(Exception e){System.out.println(e);}"); file.println(""); file.println(" /* Initiate logging by setting global hcg_log = 1 */"); file.println(" GlobalVarsBean.setHcg_log(1);"); file.println(""); file.println(" /* Log call to pr_startlog as first record */"); file.println(" logstr(\"SR\");"); file.println(""); file.println(" time_initialize();"); file.println(""); file.println(" }catch(Exception e)"); file.println(" {"); file.println(" e.getMessage();"); file.println(" }"); file.println(" return true;"); file.println(" }/* End pr_startlog */"); file.println(""); }//End Gen_pr_startlog void gen_pr_stoplog() { file.println(" /**"); file.println(" *"); file.println(" * This method is used to stop a logging session."); file.println(" * It optionally dumps a current copy of the database and closes"); file.println(" * the logfile"); file.println(" * Returns true if successful, false if any error"); file.println(" **/"); file.println(" public boolean pr_stoplog(boolean dump_flag)"); file.println(" {"); file.println(" String DB2string =\"DB2.dat\";"); file.println(" String logfileDB2_name;"); file.println(" /* check that logging is active - if not, return without stopping log*/"); file.println(" try"); file.println(" {"); file.println(" if (GlobalVarsBean.getHcg_log()!=1) throw new GenException(\"pr_stoplog called without starting log.\");"); file.println(""); file.println(" /* Generate Wait statement */"); file.println(" logwait();"); file.println(""); file.println(" /* Log pr_stoplog */"); file.println(" logstr(\"SP\");"); file.println(""); file.println(" /* Terminate logging by setting global hcg_log = 0 */"); file.println(" GlobalVarsBean.setHcg_log(0);"); file.println(""); file.println(" /* Database saved to name of log file + \"DB2\" */"); file.println(" if (dump_flag)"); file.println(" {"); file.println(" logfileDB2_name=hcg_logfile+DB2string;"); file.println(" theSchema.dump(logfileDB2_name);"); file.println(" }"); file.println(""); file.println(" hcg_logfileptr.close();"); file.println(" }catch(Exception e)"); file.println(" {"); file.println(" e.getMessage();"); file.println(" }"); file.println(" return true;"); file.println(" }//end of pr_stoplog"); file.println(""); } /* End pr_stoplog*/ void gen_replay_log() { file.println(" /**"); file.println(" * This method is used to parse the logfile and execute"); file.println(" * the action of the log entry."); file.println(" *"); file.println(" * @param logfile - logfile to replay"); file.println(" * @param near_realtime - flag indicates to"); file.println(" * replay in near realtime"); file.println(" * 0 = not real time"); file.println(" * 1 = real time"); file.println(" * Returns True if successful, false if any error"); file.println(" *"); file.println(" **/"); file.println(""); file.println(" public boolean replay_log(String logfile,int near_realtime)"); file.println(" {"); file.println(" int idx;"); file.println(" String line;"); file.println(" BufferedReader logfile_fp;"); file.println(""); file.println(" /* check variables */"); file.println(" if ((near_realtime != 1) && (near_realtime !=0)){"); file.println(" System.out.println(\"replay_log: warning invalid value of near_realtime \"+near_realtime);"); file.println(" System.out.println(\"Default = 0 (Ignore Wait Commands).\");"); file.println(" near_realtime = 0;"); file.println(" }"); file.println(""); file.println(" try{"); file.println(" /* open the log file */"); file.println(" logfile_fp = new BufferedReader( new FileReader(logfile) );"); file.println(""); file.println(" /* check for the logfile header format */"); file.println(" line = logfile_fp.readLine();"); file.println(" if (! line.equals(\"SR\"))"); file.println(" {"); file.println(" System.out.println(\"The log file does not have a SR entry\");"); file.println(" return false;"); file.println(" }"); file.println(""); file.println(" line = logfile_fp.readLine();"); file.println(" while(!line.equals(null))"); file.println(" {"); file.println(" StringTokenizer strtok = new StringTokenizer(line, \" \");"); file.println(" String token= strtok.nextToken();"); file.println(" if (token.equals(\"LD\")){"); file.println(" String datafileName = strtok.nextToken();"); file.println(" theSchema.load(datafileName);"); file.println(" System.out.println(\"Found LD entry, datafile loaded\");"); file.println(" }else{"); file.println(" if (token.equals(\"SP\")){"); file.println(" System.out.println(\"Successful completion of log parsing \");"); file.println(" return true;"); file.println(" }else{"); file.println(" if (token.equals(\"WA\")){"); file.println(" String tok2 = strtok.nextToken();"); file.println(" int waitTime = 0;"); file.println(" if (!tok2.equals(\"0\"))"); file.println(" waitTime = Integer.valueOf(tok2).intValue();"); file.println(" System.out.println(\"Found a WaitTime entry with \"+waitTime+\" milliseconds\");"); file.println(" if((near_realtime ==1) && (waitTime > 0))"); file.println(" log_sleep(waitTime);"); file.println(" }else{"); file.println(" if (token.equals(\"DL\")){"); file.println(" String pkey = strtok.nextToken();"); file.println(" log_do_delete(pkey);"); file.println(" System.out.println(\"Found a delete entry with pkey \"+pkey);"); file.println(" }else{"); file.println(" if (token.equals(\"PR_SET_INT\")){"); file.println(" System.out.println(\"PR_SET_INT entry found: \"+line);"); file.println(" String table = strtok.nextToken();"); file.println(" String field = strtok.nextToken();"); file.println(" int newIntValue = Integer.valueOf(strtok.nextToken()).intValue();"); file.println(" log_do_set_int(table, field, newIntValue);"); file.println(" }else{"); file.println(" if (token.equals(\"PR_SET_FLT\")){"); file.println(" System.out.println(\"PR_SET_FLT entry found: \"+line);"); file.println(" String table = strtok.nextToken();"); file.println(" String field = strtok.nextToken();"); file.println(" float newFloatValue = Float.valueOf(strtok.nextToken()).floatValue();"); file.println(" log_do_set_float(table, field, newFloatValue);"); file.println(" }else{"); file.println(" if (token.equals(\"PR_SET_STR\")){"); file.println(" System.out.println(\"PR_SET_STR entry found: \"+line);"); file.println(" String table = strtok.nextToken();"); file.println(" String field = strtok.nextToken();"); file.println(" String newStrValue = strtok.nextToken();"); file.println(" log_do_set_str(table, field, newStrValue);"); file.println(" }else{"); file.println(" System.out.println(\"Add entry found: \"+line);"); file.println(" log_do_add(line);"); file.println(" }}}}}}}"); file.println(""); file.println(" line = logfile_fp.readLine();"); file.println(" }//end of while"); file.println(" logfile_fp.close();"); file.println(""); file.println(" }catch(Exception e)"); file.println(" {"); file.println(" e.getMessage();"); file.println(" }"); file.println(" return true;"); file.println(" }//end of reply_log"); file.println(""); }//End gen_pr_log() void gen_pr_replay() { file.println(" /**"); file.println(" * Function: pr_replay"); file.println(" *"); file.println(" * This method is used to replay a logsession based on"); file.println(" * a log file. It will destroy the current database,"); file.println(" * replace the DB from the start of the log session,"); file.println(" * reproduce the DB modifications based on the logfile."); file.println(" *"); file.println(" * @param logfile - the name of the logfile to replay"); file.println(" * @param near_realtime - a boolean flag indicating if"); file.println(" * the replay should approx realtime"); file.println(" * 0 - no near_realtime playback"); file.println(" * 1 - playback in near-realtime"); file.println(" * @param take_endsnapshot - a boolean flag indicating if the"); file.println(" * database should be dumped at the"); file.println(" * end of the replay."); file.println(" * 0 - do not take the end DB snapshot"); file.println(" * 1 - take the end DB snapshot"); file.println(" * Return true if successful, false otherwise"); file.println(" **/"); file.println(""); file.println(" public boolean pr_replay(String logfile,int near_realtime,int take_endsnapshot)"); file.println(" {"); file.println(" String endDumpFileName;"); file.println(" String logfileDB1_name;"); file.println(" boolean retval;"); file.println(" try"); file.println(" {"); file.println(" //if (GlobalVarsBean.getHcg_log()!=1) throw new GenException(\"pr_stoplog called without starting log.\");"); file.println(""); file.println(" /* set replay to be on & save logfilename*/"); file.println(" GlobalVarsBean.setHcg_log(2);"); file.println(" hcg_logfile = logfile;"); file.println(" if (logfile == null) {"); file.println(" System.out.println(\"pr_replay error: null log file\");"); file.println(" GlobalVarsBean.setHcg_log(0);"); file.println(" return(false);"); file.println(" }"); file.println(""); file.println(" /* generate the data files */"); file.println(" hcg_logfile=logfile.substring(0,logfile.indexOf(\".\"));"); file.println(" logfileDB1_name=hcg_logfile+\"DB1.dat\";"); file.println(""); file.println(" /* initialize & load the database */"); file.println(" theSchema.initialize();"); file.println(" theSchema.load(logfileDB1_name);"); file.println(""); file.println(" /* replay the log */"); file.println(" hcg_logfile = hcg_logfile+\".txt\";"); file.println(" if (!(retval = replay_log(hcg_logfile,near_realtime))) {"); file.println(" return(retval);"); file.println(" }"); file.println(""); file.println(" /* take final snapshot */"); file.println(" if (take_endsnapshot==1) {"); file.println(" endDumpFileName=logfile.substring(0,logfile.indexOf(\".\"));"); file.println(" endDumpFileName=endDumpFileName+\"DB3.dat\";"); file.println(" theSchema.dump(endDumpFileName);"); file.println(" }"); file.println(""); file.println(" GlobalVarsBean.setHcg_log(0);"); file.println(" }catch(Exception e)"); file.println(" {"); file.println(" return false;"); file.println(" }"); file.println(" return (true);"); file.println(" }//end of pr_replay"); file.println(""); } void gen_log_do_add() { file.println(" /**"); file.println(" * This method adds a record into a table in the database."); file.println(" * @param line - A String which contains the data to be added to the table."); file.println(" * - It should be a space seperated string of field values."); file.println(" * Returns boolean - true if successful"); file.println(" * false if unsuccessful"); file.println(" **/"); file.println(" public boolean log_do_add(String line)"); file.println(" {"); file.println(" StringTokenizer strtok = new StringTokenizer(line);"); file.println(" String pkey = strtok.nextToken();"); file.println(" int tableIndex = theSchema.FindTblIdx(pkey);"); file.println(""); file.println(" switch(tableIndex)"); file.println(" {"); TT TTcurr; TTcurr = schema.TTtab.getFirstRow(); int i = 0; while ( TTcurr != null ) { file.print(" case "); file.println(i+":{ "); i++; file.println(" "+TTcurr.getTTabb()+" "+ TTcurr.getTTabb()+"curr = new "+TTcurr.getTTabb()+"();"); file.println(" "+TTcurr.getTTabb()+"curr.setSchema(theSchema);"); file.println(" "+TTcurr.getTTabb()+"curr.setTable(theSchema."+TTcurr.getTTabb()+"tab);"); file.println(" "+TTcurr.getTTabb()+"curr.setPkid(new Key(pkey, theSchema));"); RC TAcurr = (TA)TTcurr.TAid_fcp; file.println(" String token;"); TAcurr = ((TA)TAcurr).TTid_fpp; while( (TAcurr != null) && (TAcurr != TTcurr)) { file.println(" token = strtok.nextToken();"); if (((TA)TAcurr).getFtype().charAt(0) == 'i'){ file.println(" int fieldValue = Integer.valueOf(token).intValue();"); file.println(" "+TTcurr.getTTabb()+"curr.set"+((TA)TAcurr).getFname()+"(fieldValue);"); }else{ if (((TA)TAcurr).getFtype().charAt(0) == 'f'){ file.println(" float fieldValue = Float.valueOf(token).floatValue();"); file.println(" "+TTcurr.getTTabb()+"curr.set"+((TA)TAcurr).getFname()+"(fieldValue);"); }else{ if (((TA)TAcurr).getFtype().charAt(0) == 't'){ file.println(" "+TTcurr.getTTabb()+"curr.set"+((TA)TAcurr).getFname()+"(token);"); }else{ if(((TA)TAcurr).getIsKey().charAt(0) != '0' ){ if (!(((TA)TAcurr).getFname().substring(0,2).equals(TTcurr.getTTabb()))) { file.println(" "+TTcurr.getTTabb()+"curr.set"+((TA)TAcurr).getFname()+"(new Key(token, theSchema));"); } }}}} TAcurr = ((TA)TAcurr).TTid_fpp; }//end of while file.println(" "+TTcurr.getTTabb()+"curr.addRow();"); file.println(" }//end of case"); TTcurr = schema.TTtab.getNextRow(TTcurr); } file.println(" }//end of switch"); file.println(" return true;"); file.println(" }//end of log_do_add"); file.println(""); } void gen_log_do_delete() { file.println(" /**"); file.println(" * This method deletes a row in the table."); file.println(" * @param pkey - the primary key of the row to be deleted"); file.println(" * Returns boolean - true if successful"); file.println(" * - False if unsuccessful"); file.println(" *"); file.println(" **/"); file.println(" public boolean log_do_delete(String pkey)"); file.println(" {"); file.println(" int tableIndex = theSchema.FindTblIdx(pkey);"); file.println(" switch(tableIndex)"); file.println(" {"); TT TTcurr; TTcurr = schema.TTtab.getFirstRow(); int i = 0; while ( TTcurr != null ) { file.print(" case "); file.println(i+":{ "); i++; file.println(" "+TTcurr.getTTabb() +" "+TTcurr.getTTabb()+"curr = theSchema."+TTcurr.getTTabb()+"tab.getFirstRow();"); file.println(" while("+TTcurr.getTTabb()+"curr != null ) {"); file.println(" if("+TTcurr.getTTabb()+"curr.getPkid().toString().compareTo(pkey) == 0)"); file.println(" break;"); file.println(" "+TTcurr.getTTabb()+"curr = theSchema."+TTcurr.getTTabb()+"tab.getNextRow("+TTcurr.getTTabb()+"curr);"); file.println(" }"); file.println(" if( "+TTcurr.getTTabb()+"curr != null )"); file.println(" "+TTcurr.getTTabb()+"curr.deleteRow();"); file.println(" }//end of case"); TTcurr = schema.TTtab.getNextRow(TTcurr); } file.println(" }//end of switch"); file.println(" return true;"); file.println(" }// end of log_do_delete"); file.println(""); } void gen_log_do_set_int() { file.println(" /**"); file.println(" * This method sets an integer field in any row of a table"); file.println(" * @param pkey - the Primary key of the row in which the field value is to be changed"); file.println(" * @param fieldname - The name of the field whose value is to be changed"); file.println(" * @param newVal - The new value to be changed to"); file.println(" *"); file.println(" **/"); file.println(" public void log_do_set_int(String pkey,String fieldname, int newVal)"); file.println(" {"); file.println(" int tableIndex = theSchema.FindTblIdx(pkey);"); file.println(" switch(tableIndex)"); file.println(" {"); TT TTcurr; TTcurr = schema.TTtab.getFirstRow(); int i = 0; while ( TTcurr != null ) { file.print(" case "); file.println(i+":{ "); i++; file.println(" "+TTcurr.getTTabb()+" "+TTcurr.getTTabb()+"curr = theSchema."+TTcurr.getTTabb()+"tab.getFirstRow();"); file.println(" while( "+TTcurr.getTTabb()+"curr != null ) {"); file.println(" if( "+TTcurr.getTTabb()+"curr.getPkid().toString().compareTo(pkey) == 0)"); file.println(" break;"); file.println(" "+TTcurr.getTTabb()+"curr = theSchema."+TTcurr.getTTabb()+"tab.getNextRow("+TTcurr.getTTabb()+"curr);"); file.println(" }"); // Loop over each TA child of this TT RC TAcurr = (TA)TTcurr.TAid_fcp; while( (TAcurr != null) && (TAcurr != TTcurr)) { if (((TA)TAcurr).getFtype().charAt(0) == 'i'){ file.println(" if (\""+((TA)TAcurr).getFname()+"\".equals(fieldname))"); file.println(" "+TTcurr.getTTabb()+"curr.set"+((TA)TAcurr).getFname()+"(newVal);"); } TAcurr = ((TA)TAcurr).TTid_fpp; } file.println(" }//end of case"); TTcurr = schema.TTtab.getNextRow(TTcurr); } file.println(" }//end of switch"); file.println(" }//end of log_do_set_int"); file.println(""); } void gen_log_do_set_float() { file.println(" /**"); file.println(" * This method sets a float field in any row of a table"); file.println(" * @param pkey - the Primary key of the row in which the field value is to be changed"); file.println(" * @param fieldname - The name of the field whose value is to be changed"); file.println(" * @param newVal - The new value to be changed to"); file.println(" *"); file.println(" **/"); file.println(" public void log_do_set_float(String pkey,String fieldname, float newVal)"); file.println(" {"); file.println(" int tableIndex = theSchema.FindTblIdx(pkey);"); file.println(" switch(tableIndex)"); file.println(" {"); TT TTcurr; TTcurr = schema.TTtab.getFirstRow(); int i = 0; while ( TTcurr != null ) { file.print(" case "); file.println(i+":{ "); i++; file.println(" "+TTcurr.getTTabb()+" "+TTcurr.getTTabb()+"curr = theSchema."+TTcurr.getTTabb()+"tab.getFirstRow();"); file.println(" while( "+TTcurr.getTTabb()+"curr != null ) {"); file.println(" if( "+TTcurr.getTTabb()+"curr.getPkid().toString().compareTo(pkey) == 0)"); file.println(" break;"); file.println(" "+TTcurr.getTTabb()+"curr = theSchema."+TTcurr.getTTabb()+"tab.getNextRow("+TTcurr.getTTabb()+"curr);"); file.println(" }"); // Loop over each TA child of this TT RC TAcurr = (TA)TTcurr.TAid_fcp; while( (TAcurr != null) && (TAcurr != TTcurr)) { if (((TA)TAcurr).getFtype().charAt(0) == 'f'){ file.println(" if (\""+((TA)TAcurr).getFname()+"\".equals(fieldname))"); file.println(" "+TTcurr.getTTabb()+"curr.set"+((TA)TAcurr).getFname()+"(newVal);"); } TAcurr = ((TA)TAcurr).TTid_fpp; } file.println(" }//end of case"); TTcurr = schema.TTtab.getNextRow(TTcurr); } file.println(" }//end of switch"); file.println(" }//end of log_do_set_float"); file.println(""); } void gen_log_do_set_str() { file.println(" /**"); file.println(" * This method sets a String field in any row of a table"); file.println(" * @param pkey - the Primary key of the row in which the field value is to be changed"); file.println(" * @param fieldname - The name of the field whose value is to be changed"); file.println(" * @param newVal - The new value to be changed to"); file.println(" *"); file.println(" **/"); file.println(" public void log_do_set_str(String pkey,String fieldname, String newVal)"); file.println(" {"); file.println(" int tableIndex = theSchema.FindTblIdx(pkey);"); file.println(" switch(tableIndex)"); file.println(" {"); TT TTcurr; TTcurr = schema.TTtab.getFirstRow(); int i = 0; while ( TTcurr != null ) { file.print(" case "); file.println(i+":{ "); i++; file.println(" "+TTcurr.getTTabb()+" "+TTcurr.getTTabb()+"curr = theSchema."+TTcurr.getTTabb()+"tab.getFirstRow();"); file.println(" while( "+TTcurr.getTTabb()+"curr != null ) {"); file.println(" if( "+TTcurr.getTTabb()+"curr.getPkid().toString().compareTo(pkey) == 0)"); file.println(" break;"); file.println(" "+TTcurr.getTTabb()+"curr = theSchema."+TTcurr.getTTabb()+"tab.getNextRow("+TTcurr.getTTabb()+"curr);"); file.println(" }"); // Loop over each TA child of this TT RC TAcurr = (TA)TTcurr.TAid_fcp; while( (TAcurr != null) && (TAcurr != TTcurr)) { if (((TA)TAcurr).getFtype().charAt(0) == 't'){ file.println(" if (\""+((TA)TAcurr).getFname()+"\".equals(fieldname))"); file.println(" "+TTcurr.getTTabb()+"curr.set"+((TA)TAcurr).getFname()+"(newVal);"); } TAcurr = ((TA)TAcurr).TTid_fpp; } file.println(" }//end of case"); TTcurr = schema.TTtab.getNextRow(TTcurr); } file.println(" }//end of switch"); file.println(" }//end of log_do_set_str"); file.println(""); } }