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;
009:
010: //base classes
011: import java.io.IOException;
012: import java.util.ArrayList;
013:
014: //project specific classes
015: import org.jfolder.common.UnexpectedSystemException;
016: import org.jfolder.common.utils.misc.MiscHelper;
017: import org.jfolder.common.utils.xml.XMLHelper;
018: import org.jfolder.common.web.template.ConsoleParameterContext;
019: import org.jfolder.common.web.template.SubmitActionContext;
020: import org.jfolder.common.web.template.SubmitActionParameters;
021: import org.jfolder.console.base.ConsolePageContext;
022: import org.jfolder.console.base.ConsolePageParameters;
023: import org.jfolder.console.base.ConsolePageSession;
024: import org.jfolder.project.model.ProjectSystem;
025: import org.jfolder.workflow.model.dms.WorkflowDocumentGroup;
026: import org.jfolder.workflow.model.dms.WorkflowDocumentInstance;
027: import org.jfolder.workflow.model.dms.WorkflowDocumentSet;
028: import org.jfolder.workflow.model.instance.WorkflowInstance;
029: import org.jfolder.workflow.model.trigger.WorkflowTrigger;
030:
031: //other classes
032:
033: public class AdminManualTriggerContext extends ConsolePageContext {
034:
035: private final static String BUTTON__GO_BACK = "BUTTON__GO_BACK";
036: private final static String BUTTON__FIRE_TRIG = "BUTTON__FIRE_TRIG";
037: private final static String BUTTON__CREATE = "BUTTON__CREATE";
038: private final static String BUTTON__REM_GROUP = "BUTTON__REM_GROUP";
039: private final static String BUTTON__REM_INST = "BUTTON__REM_INST";
040: private final static String BUTTON__ADD = "BUTTON__ADD";
041:
042: private final static String NINTH_PARAMETER = ("getPageComponent('"
043: + ConsolePageParameters.TRIGGER_TEXT + "').value");
044: //
045: private final static String TENTH_PARAMETER = ("getPageComponent('"
046: + ConsolePageParameters.TRIGGER_APPLICATION + "').value");
047:
048: private AdminManualTriggerContext(ConsolePageSession inCps) {
049:
050: super (inCps);
051: }
052:
053: public final static AdminManualTriggerContext newInstance(
054: ConsolePageSession inCps) {
055:
056: return new AdminManualTriggerContext(inCps);
057: }
058:
059: public String getFromPage() {
060: return ConsolePageParameters.SERVLET_MANUAL_TRIGGER;
061: }
062:
063: public String getHandle() {
064: return NULL_HANDLE;
065: }
066:
067: public String getHandleExtension() {
068: throw new UnexpectedSystemException(
069: "This function should not be called in this class");
070: }
071:
072: protected void renderConsolePage() throws IOException {
073:
074: ConsolePageSession cs = getConsolePageSession();
075: //ProjectApplicationSet was =
076: // getConsoleSession().getProjectApplicationSet();
077: WorkflowInstance wi = cs.getWorkflowInstance();
078: WorkflowTrigger td = wi.getWorkflowTrigger();
079: WorkflowDocumentSet wds = wi.getWorkflowDocumentSet();
080:
081: startCommonPage();
082: startEnclosingTableAndRowAndCell(alignCenter(null));
083: //
084: startAndEndStretchTableAndRowAndCell("<hr/>");
085: //
086: startTable(3);
087: startRow();
088: startAndEndCell(2, "Manual Trigger", getFontStyle(20, ARIAL,
089: BLACK));
090: startCell(1, alignCenter(null));
091: //
092: SubmitActionContext sacGoBack = createSac();
093: sacGoBack.setGoToPage(ConsolePageParameters.SERVLET_CONSOLE);
094: //
095: sacGoBack.addAction(ConsoleParameterContext.FIRST_INPUT,
096: singleQuotes(SubmitActionParameters.RETURN));
097: sacGoBack.addAction(ConsoleParameterContext.SECOND_INPUT,
098: singleQuotes(SubmitActionParameters.MANUAL_TRIGGER));
099: createButton(BUTTON__GO_BACK, "Go Back", 150,
100: submitActionCall(sacGoBack), null, null, null, null);
101: //
102: endCell();
103: endRow();
104: endTable();
105: //
106: startAndEndStretchTableAndRowAndCell("<hr/>");
107: //
108: startTable(3);
109: startRow();
110: startCell(3, alignCenter(null));
111: simpleAndPrint(createTextArea(
112: ConsolePageParameters.TRIGGER_TEXT, td
113: .getDataAsString(), null, getFontStyle(9,
114: COURIER, BLACK), new Integer(15), new Integer(
115: 40), null));
116: endCell();
117: endRow();
118: endTable();
119: //
120: startAndEndStretchTableAndRowAndCell("<hr/>");
121: //
122: startTable(3);
123: startRow();
124: startCell(1, getFontStyle(16, ARIAL, BLACK));
125: simpleAndPrint("Application");
126: endCell();
127: startCell(1, alignCenter(null));
128: //
129: ArrayList applicationLabels = new ArrayList();
130: ArrayList applicationValues = new ArrayList();
131: applicationLabels.add("(No Application)");
132: applicationValues.add("");
133: //
134: for (int i = 0; i < cs.getUserProjectSystemCount(); i++) {
135: ProjectSystem ps = cs.getUserProjectSystem(i);
136: applicationLabels.add(MiscHelper
137: .fixString(ps.getName(), 17));
138: applicationValues.add(ps.getName());
139: }
140: //
141: simpleAndPrint(createDropDownBox(
142: ConsolePageParameters.TRIGGER_APPLICATION,
143: applicationLabels, applicationValues, null,
144: getFontStyle(9, COURIER, BLACK), 0, null, null, null));
145: //
146: endCell();
147: startCell(1, alignCenter(null));
148: SubmitActionContext sacFire = createSac();
149: //
150: sacFire.addAction(ConsoleParameterContext.FIRST_INPUT,
151: singleQuotes(SubmitActionParameters.FIRE_TRIGGER));
152: createButton(BUTTON__FIRE_TRIG, "Fire Trigger", 150,
153: submitActionCall(sacFire), null, null, null, null);
154: endCell();
155: endRow();
156: endTable();
157: //
158: startAndEndStretchTableAndRowAndCell("<hr/>");
159: //
160: startTable(3);
161: startRow();
162: startAndEndCell(1, "New Document Group", getFontStyle(16,
163: ARIAL, BLACK));
164: startCell(1, alignCenter(null));
165: simpleAndPrint(createTextBox(
166: ConsolePageParameters.NEW_DOCUMENT_GROUP,
167: "DocGroupName", null, null, null, null, null));
168: endCell();
169: startCell(1, alignCenter(null));
170: //
171: SubmitActionContext sacCreateDocGroup = createSac();
172: //
173: sacCreateDocGroup.addAction(
174: ConsoleParameterContext.FIRST_INPUT,
175: singleQuotes(SubmitActionParameters.ADD));
176: sacCreateDocGroup.addAction(
177: ConsoleParameterContext.SECOND_INPUT,
178: singleQuotes(SubmitActionParameters.DOCUMENT));
179: sacCreateDocGroup.addAction(
180: ConsoleParameterContext.THIRD_INPUT,
181: singleQuotes(SubmitActionParameters.GROUP));
182: //
183: sacCreateDocGroup.addParameter(
184: ConsoleParameterContext.FIRST_INPUT,
185: "getPageComponent('"
186: + ConsolePageParameters.NEW_DOCUMENT_GROUP
187: + "').value");
188: createButton(BUTTON__CREATE, "Create", 150,
189: submitActionCall(sacCreateDocGroup), null, null, null,
190: null);
191: //
192: endCell();
193: endRow();
194: endTable();
195: //
196: //
197: for (int i = 0; i < wds.getDocumentGroupCount(); i++) {
198: startAndEndStretchTableAndRowAndCell("<hr/>");
199: WorkflowDocumentGroup nextDg = wds.getDocumentGroup(i);
200: String nextDgName = nextDg.getName();
201: startTable(3);
202: startRow();
203: startCell(2, null);
204: simpleAndPrint(nextDgName);
205: endCell();
206: startCell(1, alignCenter(null));
207: if (nextDg.isDeletable()) {
208: SubmitActionContext sacRemoveDocGroup = createSac();
209: //
210: sacRemoveDocGroup.addAction(
211: ConsoleParameterContext.FIRST_INPUT,
212: singleQuotes(SubmitActionParameters.DELETE));
213: sacRemoveDocGroup.addAction(
214: ConsoleParameterContext.SECOND_INPUT,
215: singleQuotes(SubmitActionParameters.DOCUMENT));
216: sacRemoveDocGroup.addAction(
217: ConsoleParameterContext.THIRD_INPUT,
218: singleQuotes(SubmitActionParameters.GROUP));
219: //
220: sacRemoveDocGroup.addParameter(
221: ConsoleParameterContext.FIRST_INPUT,
222: singleQuotes(nextDg.getName()));
223: createButton(BUTTON__REM_GROUP, "Remove", 150,
224: submitActionCall(sacRemoveDocGroup), null,
225: null, null, null);
226: } else {
227: simpleAndPrint(" ");
228: }
229: endCell();
230: endRow();
231: endTable();
232: //
233: //
234: int leftMargin = getLeftMargin();
235: setLeftMargin(leftMargin + 1);
236: startAndEndStretchTableAndRowAndCell("<hr/>");
237: if (nextDg.getDocumentCount() > 0) {
238: for (int j = 0; j < nextDg.getDocumentCount(); j++) {
239: WorkflowDocumentInstance nextDi = nextDg
240: .getDocument(j);
241: //
242: startTable(2);
243: startRow();
244: startCell(1);
245: simpleAndPrint(XMLHelper.fromStringToHTML(" ")
246: + nextDi.getName());
247: endCell();
248: startCell(1, alignCenter(null));
249: //
250: SubmitActionContext sacRemoveDocInstance = createSac();
251: //
252: sacRemoveDocInstance
253: .addAction(
254: ConsoleParameterContext.FIRST_INPUT,
255: singleQuotes(SubmitActionParameters.DELETE));
256: sacRemoveDocInstance
257: .addAction(
258: ConsoleParameterContext.SECOND_INPUT,
259: singleQuotes(SubmitActionParameters.DOCUMENT));
260: sacRemoveDocInstance
261: .addAction(
262: ConsoleParameterContext.THIRD_INPUT,
263: singleQuotes(SubmitActionParameters.INSTANCE));
264: //
265: sacRemoveDocInstance.addParameter(
266: ConsoleParameterContext.FIRST_INPUT,
267: singleQuotes(nextDg.getName()));
268: sacRemoveDocInstance.addParameter(
269: ConsoleParameterContext.SECOND_INPUT,
270: singleQuotes(nextDi.getName()));
271: createButton(BUTTON__REM_INST, "Remove", 150,
272: submitActionCall(sacRemoveDocInstance),
273: null, null, null, null);
274: //
275: endCell();
276: endRow();
277: endTable();
278: startAndEndStretchTableAndRowAndCell("<hr/>");
279: }
280: }
281: //
282: String createDocumentInstanceId = ConsolePageParameters.NEW_DOCUMENT_INSTANCE_PREFIX
283: + nextDgName;
284: //
285: startTable(2);
286: startRow();
287: startCell(1, alignCenter(null));
288: simpleAndPrint(createFileUpload(createDocumentInstanceId,
289: new Integer(5)));
290: endCell();
291: startCell(1, alignCenter(null));
292: SubmitActionContext sacCreateDocInstance = createSac();
293: //
294: sacCreateDocInstance.addAction(
295: ConsoleParameterContext.FIRST_INPUT,
296: singleQuotes(SubmitActionParameters.ADD));
297: sacCreateDocInstance.addAction(
298: ConsoleParameterContext.SECOND_INPUT,
299: singleQuotes(SubmitActionParameters.DOCUMENT));
300: sacCreateDocInstance.addAction(
301: ConsoleParameterContext.THIRD_INPUT,
302: singleQuotes(SubmitActionParameters.INSTANCE));
303: //
304: sacCreateDocInstance.addParameter(
305: ConsoleParameterContext.FIRST_INPUT,
306: singleQuotes(nextDgName));
307: sacCreateDocInstance.addParameter(
308: ConsoleParameterContext.SECOND_INPUT,
309: singleQuotes(createDocumentInstanceId));
310: createButton(BUTTON__ADD, "Add", 150,
311: submitActionCall(sacCreateDocInstance), null, null,
312: null, null);
313: endCell();
314: endRow();
315: endTable();
316: //
317: setLeftMargin(leftMargin);
318: //
319: }
320: //
321: ArrayList propNames = new ArrayList();
322: ArrayList propValues = new ArrayList();
323: for (int i = 0; i < td.getPropertyCount(); i++) {
324: propNames.add(td.getPropertyName(i));
325: propValues.add(td.getProperty(i));
326: }
327: //createStudioPropertiesControl(
328: // "", propNames, propValues, NINTH_PARAMETER, TENTH_PARAMETER);
329: startAndEndStretchTableAndRowAndCell("<hr/>");
330: //
331: endEnclosingTableAndRowAndCell();
332: endCommonPage();
333: }
334:
335: private SubmitActionContext createSac() {
336:
337: SubmitActionContext outValue = null;
338:
339: outValue = SubmitActionContext.newInstance(this);
340: outValue.addParameter(ConsoleParameterContext.FIRST_INPUT,
341: NINTH_PARAMETER);
342: outValue.addParameter(ConsoleParameterContext.SECOND_INPUT,
343: TENTH_PARAMETER);
344:
345: return outValue;
346: }
347: }
|