1 5 package com.teamkonzept.publishing.markups.db.queries; 6 7 import java.sql.*; 8 9 import com.teamkonzept.db.*; 10 import com.teamkonzept.webman.mainint.db.queries.markups.*; 11 import com.teamkonzept.webman.mainint.db.queries.properties.*; 12 13 import org.apache.log4j.Category; 14 15 public class TKMarkupPropPut extends CompositeQuery { 16 17 static final Category CAT = Category.getInstance(TKMarkupPropPut.class.getName()); 18 19 TKQuery insert1 = null; 20 TKQuery insert2 = null; 21 TKQuery insert3 = null; 22 23 protected void initConcreteCompositeQuery()throws SQLException { 24 registerQuery( DeleteProperty1.class); 25 registerQuery( DeleteProperty2.class); 26 registerQuery( DeleteProperty3.class); 27 insert1 = registerQuery( InsertProperty1.class); 28 insert2 = registerQuery( InsertProperty2.class); 29 insert3 = registerQuery( InsertProperty3.class); 30 } 31 32 public boolean beforeExecution(int i) { 33 TKQuery q = getQuery(i); 34 if (q.equals(insert1)) { 35 try { 36 TKQuery selectMax = TKDBManager.newQuery(SelectMaxProperty.class); 37 selectMax.execute(); 38 ResultSet rs = selectMax.fetchResultSet(); 39 int max = 0; 40 if (rs != null && rs.next()) { 41 max = rs.getInt(1); 42 } 43 CAT.debug("max property: " + max); 44 insert1.setQueryParams("PROPERTY_MAX", new Integer (max)); 45 insert2.setQueryParams("PROPERTY_MAX", new Integer (max+1)); 46 insert3.setQueryParams("PROPERTY_MAX", new Integer (max+2)); 47 } 48 catch (SQLException sqle) { 49 CAT.error("Exception while retrieving max property value", sqle); 50 return false; 51 } 52 } 53 return true; 54 } 55 56 } 57 58 | Popular Tags |