001: /*
002: * JFolder, Copyright 2001-2006 Gary Steinmetz
003: *
004: * Distributable under LGPL license.
005: * See terms of license at gnu.org.
006: */
007:
008: package org.jfolder.console.web.admin.macro.execute;
009:
010: //base classes
011: import java.io.IOException;
012: import java.util.ArrayList;
013: import javax.servlet.ServletException;
014:
015: //project specific classes
016: import org.jfolder.common.function.WebPageTagPreferences;
017: import org.jfolder.common.tagging.ConceptRollupTag;
018: import org.jfolder.common.tagging.ConceptTagCharacteristic;
019: import org.jfolder.common.tagging.ConceptTagPreferences;
020: import org.jfolder.common.tagging.RootConceptTagHolder;
021: import org.jfolder.common.utils.misc.CommonSeparators;
022: import org.jfolder.common.utils.misc.MiscHelper;
023: import org.jfolder.common.utils.web.ParameterSet;
024: import org.jfolder.common.utils.xml.XMLHelper;
025: import org.jfolder.common.web.template.ConsoleParameterContext;
026: import org.jfolder.common.web.template.CreationParameterContext;
027: import org.jfolder.common.web.template.SubmitActionContext;
028: import org.jfolder.common.web.template.SubmitActionParameters;
029: import org.jfolder.console.base.BaseConsoleServlet;
030: import org.jfolder.console.base.ConsolePageContext;
031: import org.jfolder.console.base.ConsolePageParameters;
032: import org.jfolder.console.base.ConsolePageSession;
033: import org.jfolder.console.base.NamesForParentCpc;
034: import org.jfolder.console.macro.ConsoleMacro;
035: import org.jfolder.console.macro.ConsoleMacroTagHelper;
036: import org.jfolder.console.macro.v1.GoToAndChangeValueConsoleMacroTag;
037: import org.jfolder.console.macro.v1.GoToConsoleMacroTag;
038: import org.jfolder.console.macro.v1.OpenSectionIfClosedConsoleMacroTag;
039: import org.jfolder.console.macro.v1.RootV1ConsoleMacroTag;
040: import org.jfolder.console.macro.v1.SimpleClickConsoleMacroTag;
041: import org.jfolder.console.macro.v1.SubmitActionConsoleMacroTag;
042: import org.jfolder.security.model.UserHolder;
043:
044: //other classes
045:
046: public abstract class PetStoreDatabase extends CommonPetStoreActivity {
047:
048: //
049: protected PetStoreDatabase() {
050: }
051:
052: //
053: public final static void getDatabases(ArrayList inNames,
054: ArrayList inClasses) {
055: //
056: //
057: inNames.add("HypersonicSQL");
058: inClasses.add(PetStoreDatabaseForHypersonicSQL.class.getName());
059:
060: }
061:
062: //
063: public final static void createDatabase(
064: RootV1ConsoleMacroTag inRv1cmt, String inAppName,
065: String inClass) {
066: //
067: goToDatabaseAccess(inRv1cmt);
068: //
069: //
070: //
071: Class c = MiscHelper.getClassByName(inClass);
072: Object o = MiscHelper.newInstance(c);
073: PetStoreDatabase localPsd = ((PetStoreDatabase) o);
074: //
075: localPsd.dropAndCreateAllTables(inRv1cmt);
076: //
077: //
078: //
079: goToConsoleScreen(inRv1cmt);
080:
081: }
082:
083: private final static void goToDatabaseAccess(
084: RootV1ConsoleMacroTag inRv1cmt) {
085: //
086: //
087: ConceptTagCharacteristic currentActionCtchar = null;
088: String fromHandle = null;
089: String sourPage = null;
090: String destPage = null;
091: String treeState = null;
092: ////////////
093: fromHandle = NamesForParentCpc.getConsoleScreenCpcName();
094: sourPage = ConsolePageParameters.SERVLET_CONSOLE;
095: destPage = ConsolePageParameters.SERVLET_DATABASE_ACCESS;
096: treeState = getBaseTree();
097: //
098: currentActionCtchar = inRv1cmt.generateNextPage(fromHandle,
099: fromHandle, sourPage, destPage);
100: //
101: //
102: OpenSectionIfClosedConsoleMacroTag.newInstance(
103: currentActionCtchar, "(main),ADMINISTER",
104: "(main),ADMINISTER,[TOGGLE_CALLER],TOG_CALL__ADMIN");
105: //
106: OpenSectionIfClosedConsoleMacroTag
107: .newInstance(currentActionCtchar,
108: "(main),ADMINISTER,MONITOR",
109: "(main),ADMINISTER,MONITOR,[TOGGLE_CALLER],TOG_CALL__ADMIN_OTHER");
110: //
111: GoToConsoleMacroTag
112: .newInstance(currentActionCtchar,
113: "(main),ADMINISTER,MONITOR,[TABLE_BUTTON],BUTTON__DB_ACCESS");
114: SimpleClickConsoleMacroTag.newInstance(currentActionCtchar);
115: //
116: //
117: //
118: //
119: //
120: //
121: SubmitActionContext databaseAccessSac = SubmitActionContext
122: .newInstance(sourPage, fromHandle, fromHandle);
123: //
124: databaseAccessSac.addAction(
125: ConsoleParameterContext.FIRST_INPUT,
126: SubmitActionParameters.OPEN);
127: //
128: SubmitActionConsoleMacroTag.newInstance(currentActionCtchar,
129: databaseAccessSac);
130: //
131: }
132:
133: private final static void goToConsoleScreen(
134: RootV1ConsoleMacroTag inRv1cmt) {
135: //
136: //
137: //
138: ConceptTagCharacteristic currentActionCtchar = null;
139: String fromHandle = null;
140: String sourPage = null;
141: String destPage = null;
142: String treeState = null;
143: ////////////
144: fromHandle = NamesForParentCpc.getConsoleScreenCpcName();
145: sourPage = ConsolePageParameters.SERVLET_DATABASE_ACCESS;
146: destPage = ConsolePageParameters.SERVLET_CONSOLE;
147: treeState = getBaseTree();
148: //
149: currentActionCtchar = inRv1cmt.generateNextPage(fromHandle,
150: fromHandle, sourPage, destPage);
151: //
152: //
153: GoToConsoleMacroTag.newInstance(currentActionCtchar,
154: "(main),[TABLE_BUTTON],BUTTON__GO_BACK");
155: SimpleClickConsoleMacroTag.newInstance(currentActionCtchar);
156: //
157: //
158: //
159: //
160: //
161: //
162: SubmitActionContext goBackSac = SubmitActionContext
163: .newInstance(sourPage, fromHandle, fromHandle);
164: //
165: goBackSac.addAction(ConsoleParameterContext.FIRST_INPUT,
166: SubmitActionParameters.RETURN);
167: goBackSac.addAction(ConsoleParameterContext.SECOND_INPUT,
168: SubmitActionParameters.DATABASE_ACCESS);
169: //
170: SubmitActionConsoleMacroTag.newInstance(currentActionCtchar,
171: goBackSac);
172: //
173: }
174:
175: //
176: //
177: //
178: private final static void executeStatement(
179: RootV1ConsoleMacroTag inRv1cmt, String inStatement) {
180: //
181: //
182: //
183: ConceptTagCharacteristic currentActionCtchar = null;
184: String fromHandle = null;
185: String sourPage = null;
186: String destPage = null;
187: String treeState = null;
188: ////////////
189: fromHandle = NamesForParentCpc.getConsoleScreenCpcName();
190: sourPage = ConsolePageParameters.SERVLET_DATABASE_ACCESS;
191: destPage = ConsolePageParameters.SERVLET_DATABASE_ACCESS;
192: treeState = getBaseTree();
193: //
194: currentActionCtchar = inRv1cmt.generateNextPage(fromHandle,
195: fromHandle, sourPage, destPage);
196: //
197: //
198: //
199: //
200: inStatement = XMLHelper.fromStringToJSCData(inStatement);
201: //
202: //
203: //
204: GoToAndChangeValueConsoleMacroTag.newInstance(
205: currentActionCtchar, "(main),[DROP_DOWN_BOX],DATABASE",
206: "DefaultDatabase");
207: //
208: GoToAndChangeValueConsoleMacroTag.newInstance(
209: currentActionCtchar,
210: "(main),[DROP_DOWN_BOX],BREAK_MULTI", "TRUE");
211: //
212: GoToAndChangeValueConsoleMacroTag.newInstance(
213: currentActionCtchar, "(main),[TEXT_AREA],STATEMENT",
214: inStatement);
215: //
216: GoToConsoleMacroTag.newInstance(currentActionCtchar,
217: "(main),[TABLE_BUTTON],BUTTON__EXEC_STAT");
218: SimpleClickConsoleMacroTag.newInstance(currentActionCtchar);
219: //
220: //
221: //
222: //
223: //
224: SubmitActionContext sacExeStatement = SubmitActionContext
225: .newInstance(sourPage, fromHandle, fromHandle);
226: //
227: sacExeStatement.addAction(ConsoleParameterContext.FIRST_INPUT,
228: SubmitActionParameters.EXECUTE);
229: sacExeStatement.addAction(ConsoleParameterContext.SECOND_INPUT,
230: SubmitActionParameters.STATEMENT);
231: //
232: sacExeStatement.addParameter(
233: ConsoleParameterContext.FIRST_INPUT, "DefaultDatabase");
234: sacExeStatement.addParameter(
235: ConsoleParameterContext.SECOND_INPUT, "TRUE");
236: sacExeStatement.addParameter(
237: ConsoleParameterContext.THIRD_INPUT, "50");
238: sacExeStatement.addParameter(
239: ConsoleParameterContext.FOURTH_INPUT, inStatement);
240: //
241: //
242: //
243: //
244: SubmitActionConsoleMacroTag.newInstance(currentActionCtchar,
245: sacExeStatement);
246: //
247: }
248:
249: //
250: //
251: //
252: //
253: //
254: //
255: //
256: //
257: //
258: //
259: public final void dropAndCreateAllTables(
260: RootV1ConsoleMacroTag inRv1cmt) {
261: //
262: //
263: //
264: executeStatement(inRv1cmt, getDropAllTablesStatement());
265: //
266: //
267: executeStatement(inRv1cmt, appCarrRet(getCreateSupplierTable()));
268: executeStatement(inRv1cmt, appCarrRet(getCreateOrdersTable()));
269: executeStatement(inRv1cmt,
270: appCarrRet(getCreateOrderStatusTable()));
271: executeStatement(inRv1cmt, appCarrRet(getCreateCategoryTable()));
272: executeStatement(inRv1cmt, appCarrRet(getCreateProductTable()));
273: executeStatement(inRv1cmt, appCarrRet(getCreateSignonTable()));
274: executeStatement(inRv1cmt,
275: appCarrRet(getCreateBannerDataTable()));
276: executeStatement(inRv1cmt, appCarrRet(getCreateProfileTable()));
277: executeStatement(inRv1cmt, appCarrRet(getCreateAccountTable()));
278: executeStatement(inRv1cmt, appCarrRet(getCreateItemTable()));
279: executeStatement(inRv1cmt,
280: appCarrRet(getCreateInventoryTable()));
281: executeStatement(inRv1cmt, appCarrRet(getCreateLineItemTable()));
282: }
283:
284: //
285: //
286: private final String getDropAllTablesStatement() {
287:
288: StringBuffer outValue = new StringBuffer();
289:
290: //
291: outValue.append(appCarrRet(getDropLineItemTable()));
292: outValue.append(appCarrRet(getDropInventoryTable()));
293: outValue.append(appCarrRet(getDropItemTable()));
294: outValue.append(appCarrRet(getDropAccountTable()));
295: outValue.append(appCarrRet(getDropProfileTable()));
296: outValue.append(appCarrRet(getDropBannerDataTable()));
297: outValue.append(appCarrRet(getDropSignonTable()));
298: outValue.append(appCarrRet(getDropProductTable()));
299: outValue.append(appCarrRet(getDropCategoryTable()));
300: outValue.append(appCarrRet(getDropOrderStatusTable()));
301: outValue.append(appCarrRet(getDropOrdersTable()));
302: outValue.append(appCarrRet(getDropSupplierTable()));
303:
304: return outValue.toString();
305: }
306:
307: private final static String appCarrRet(String inValue) {
308: return (inValue + "\n");
309: }
310:
311: //private final static String generateDropAndCreateStatement(
312: // String inDropStatement, String inCreateStatement) {
313: //
314: // StringBuffer outValue = new StringBuffer();
315: //
316: // outValue.append(inDropStatement);
317: // outValue.append(";");
318: // outValue.append("\n");
319: // outValue.append(inCreateStatement);
320: // outValue.append(";");
321: // outValue.append("\n");
322: //
323: // return outValue.toString();
324: //}
325: //
326: //
327: //
328: //
329: public abstract String getDropSupplierTable();
330:
331: public abstract String getCreateSupplierTable();
332:
333: //
334: public abstract String getDropOrdersTable();
335:
336: public abstract String getCreateOrdersTable();
337:
338: //
339: public abstract String getDropOrderStatusTable();
340:
341: public abstract String getCreateOrderStatusTable();
342:
343: //
344: public abstract String getDropCategoryTable();
345:
346: public abstract String getCreateCategoryTable();
347:
348: //
349: public abstract String getDropProductTable();
350:
351: public abstract String getCreateProductTable();
352:
353: //
354: public abstract String getDropSignonTable();
355:
356: public abstract String getCreateSignonTable();
357:
358: //
359: public abstract String getDropBannerDataTable();
360:
361: public abstract String getCreateBannerDataTable();
362:
363: //
364: public abstract String getDropProfileTable();
365:
366: public abstract String getCreateProfileTable();
367:
368: //
369: public abstract String getDropAccountTable();
370:
371: public abstract String getCreateAccountTable();
372:
373: //
374: public abstract String getDropItemTable();
375:
376: public abstract String getCreateItemTable();
377:
378: //
379: public abstract String getDropInventoryTable();
380:
381: public abstract String getCreateInventoryTable();
382:
383: //
384: public abstract String getDropLineItemTable();
385:
386: public abstract String getCreateLineItemTable();
387: }
|