|
From: <tr...@us...> - 2003-08-05 23:49:30
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv25766/src/com/babeldoc/core/pipeline/stage
Modified Files:
CallStagePipelineStage.java RouterPipelineStage.java
Log Message:
Enhanced the callstage stage and added some comments to router stage
Index: CallStagePipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/CallStagePipelineStage.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** CallStagePipelineStage.java 27 Jun 2003 02:19:59 -0000 1.6
--- CallStagePipelineStage.java 5 Aug 2003 23:49:27 -0000 1.7
***************
*** 69,72 ****
--- 69,73 ----
import com.babeldoc.core.option.ConfigOption;
import com.babeldoc.core.option.IConfigOptionType;
+ import com.babeldoc.core.option.BooleanConfigOptionType;
import com.babeldoc.core.pipeline.*;
***************
*** 87,90 ****
--- 88,92 ----
/** The single configuration option */
public static final String CALL_STAGE = "callStage";
+ public static final String DISCARD_RESULTS = "discardResults";
/**
***************
*** 104,108 ****
ArrayList options = new ArrayList();
options.add(new ConfigOption(CALL_STAGE, IConfigOptionType.STRING,
! null, false, I18n.get("core.pipeline.stage.callstage.callStage")));
return options;
--- 106,112 ----
ArrayList options = new ArrayList();
options.add(new ConfigOption(CALL_STAGE, IConfigOptionType.STRING,
! null, true, I18n.get("core.pipeline.stage.callstage.callStage")));
! options.add(new ConfigOption(DISCARD_RESULTS, IConfigOptionType.BOOLEAN,
! "true", false, I18n.get("core.pipeline.stage.callstage.discard")));
return options;
***************
*** 122,139 ****
public PipelineStageResult[] process() throws PipelineException {
String callStage = getOptions(CALL_STAGE);
- ArrayList alist = new ArrayList();
- PipelineFactoryFactory.process(callStage, this.getDocument(),
- this.getTicket(), alist);
! // Convert from the called PipelineStageResult.name which is null to the
! // actual next pipelinestage name
! PipelineStageResult[] docs = (PipelineStageResult[]) alist.toArray(new PipelineStageResult[alist.size()]);
! String name = this.getNextPipelineStageName();
! for (int i = 0; i < docs.length; ++i) {
! docs[i].setNamePipelineStage(name);
! }
! return docs;
}
}
--- 126,151 ----
public PipelineStageResult[] process() throws PipelineException {
String callStage = getOptions(CALL_STAGE);
! if(this.hasOption(DISCARD_RESULTS)&&this.getOptions(DISCARD_RESULTS).equals(BooleanConfigOptionType.TRUE)) {
! PipelineDocument pdoc = (PipelineDocument)this.getDocument().clone();
! PipelineFactoryFactory.process(callStage, this.getDocument(),
! this.getTicket(), null);
! this.setDocument(pdoc);
! return this.processHelper();
! } else {
! ArrayList alist = new ArrayList();
! PipelineFactoryFactory.process(callStage, this.getDocument(),
! this.getTicket(), alist);
! // Convert from the called PipelineStageResult.name which is null to the
! // actual next pipelinestage name
! PipelineStageResult[] docs = (PipelineStageResult[]) alist.toArray(new PipelineStageResult[alist.size()]);
! String name = this.getNextPipelineStageName();
! for (int i = 0; i < docs.length; ++i) {
! docs[i].setNamePipelineStage(name);
! }
! return docs;
! }
}
}
Index: RouterPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/RouterPipelineStage.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** RouterPipelineStage.java 15 Jul 2003 15:07:53 -0000 1.10
--- RouterPipelineStage.java 5 Aug 2003 23:49:27 -0000 1.11
***************
*** 67,80 ****
import com.babeldoc.core.I18n;
import com.babeldoc.core.option.*;
! import com.babeldoc.core.pipeline.PipelineStage;
! import com.babeldoc.core.pipeline.PipelineStageInfo;
! import com.babeldoc.core.pipeline.PipelineStageType;
! import java.util.ArrayList;
! import java.util.Collection;
! import java.util.TreeMap;
! import java.util.Iterator;
! import java.util.HashMap;
/**
--- 67,75 ----
import com.babeldoc.core.I18n;
+ import com.babeldoc.core.NameValuePair;
import com.babeldoc.core.option.*;
! import com.babeldoc.core.pipeline.*;
! import java.util.*;
/**
***************
*** 107,137 ****
public RouterPipelineStage() {
super(new PipelineStageInfo() {
! public String getName() {
! return "Router";
! }
! public String getDescription() {
! return I18n.get("100110");
! }
! public Collection getTypeSpecificOptions() {
! ArrayList options = new ArrayList();
! /**
! * Define the type of the complex configuration option - it has one
! * subtype and the subtype accepts values of service type:
! * PipelineStage
! */
! IConfigOptionType routerType = new ComplexConfigOptionType(new ConfigOption[] { new ConfigOption(
! NEXT_STAGE_NAME,
! new ServiceTypeConfigOptionType(
! PipelineStageType.SERVICE_PREFIX), I18n.get("100111")) });
! //add specific options
! options.add(new ConfigOption(NEXTSTAGE, routerType, I18n.get("100111")));
! return options;
! }
! });
}
--- 102,132 ----
public RouterPipelineStage() {
super(new PipelineStageInfo() {
! public String getName() {
! return "Router";
! }
! public String getDescription() {
! return I18n.get("100110");
! }
! public Collection getTypeSpecificOptions() {
! ArrayList options = new ArrayList();
! /**
! * Define the type of the complex configuration option - it has one
! * subtype and the subtype accepts values of service type:
! * PipelineStage
! */
! IConfigOptionType routerType = new ComplexConfigOptionType(new ConfigOption[]{new ConfigOption(
! NEXT_STAGE_NAME,
! new ServiceTypeConfigOptionType(
! PipelineStageType.SERVICE_PREFIX), I18n.get("100111"))});
! //add specific options
! options.add(new ConfigOption(NEXTSTAGE, routerType, I18n.get("100111")));
! return options;
! }
! });
}
***************
*** 144,171 ****
* @throws com.babeldoc.core.pipeline.PipelineException
*/
! public com.babeldoc.core.pipeline.PipelineStageResult[] process()
! throws com.babeldoc.core.pipeline.PipelineException {
! com.babeldoc.core.NameValuePair[] stages = this.getOptionList(new String[] { NEXTSTAGE });
! com.babeldoc.core.NameValuePair[] orders = this.getOptionList(new String[]{ORDER});
!
! HashMap orderByStageName = new HashMap();
! if (orders != null) {
! for (int i = 0; i < orders.length; i++) {
! String stage = orders[i].getName();
! String orderStr = orders[i].getValue();
! Integer order = null;
! try {
! order = new Integer(orderStr);
! }
! catch (NumberFormatException nfe) {
! order = new Integer(stage.hashCode());
! }
! orderByStageName.put(stage, order);
! }
}
!
! TreeMap tm = new TreeMap();
! // Now templatize and enrich the document
if ((stages != null) && (stages.length > 0)) {
for (int i = 0; i < stages.length; ++i) {
--- 139,169 ----
* @throws com.babeldoc.core.pipeline.PipelineException
*/
! public PipelineStageResult[] process()
! throws PipelineException {
! NameValuePair[] stages = this.getOptionList(new String[]{NEXTSTAGE});
! NameValuePair[] orders = this.getOptionList(new String[]{ORDER});
!
! Map orderByStageName = getOrders(orders);
!
! // Now get the routes, optionally ordered.
! Map tm = getOrderedRoutes(stages, orderByStageName);
!
! // If one or more routes where selected, then build the array
! if (tm.size() > 0) {
! int index = 0;
! PipelineStageResult[] results = new PipelineStageResult[tm.size()];
! for (Iterator i = tm.keySet().iterator(); i.hasNext();) {
! Object key = i.next();
! results[index++] = (PipelineStageResult) tm.get(key);
! }
!
! return results;
! } else {
! return super.processHelper();
}
! }
! private Map getOrderedRoutes(NameValuePair[] stages, Map orderByStageName) {
! Map tm = new TreeMap();
if ((stages != null) && (stages.length > 0)) {
for (int i = 0; i < stages.length; ++i) {
***************
*** 174,200 ****
if (Boolean.valueOf(script).booleanValue()) {
! Integer order = (Integer)orderByStageName.get(stage);
if (order == null) {
! order = new Integer(stage.hashCode());
}
! com.babeldoc.core.pipeline.PipelineStageResult psr = new com.babeldoc.core.pipeline.PipelineStageResult(stage, getDocument(), getTicket());
tm.put(order, psr);
}
}
}
! // If one or more routes where selected, then build the array
! if (tm.size() > 0) {
! int index = 0;
! com.babeldoc.core.pipeline.PipelineStageResult[] results = new com.babeldoc.core.pipeline.PipelineStageResult[tm.size()];
! for (Iterator i = tm.keySet().iterator(); i.hasNext(); ) {
! Object key = i.next();
! results[index++] = (com.babeldoc.core.pipeline.PipelineStageResult)tm.get(key);
! }
!
! return results;
! } else {
! return super.processHelper();
}
}
}
--- 172,203 ----
if (Boolean.valueOf(script).booleanValue()) {
! Integer order = (Integer) orderByStageName.get(stage);
if (order == null) {
! order = new Integer(stage.hashCode());
}
! PipelineStageResult psr = new PipelineStageResult(stage, getDocument(), getTicket());
tm.put(order, psr);
}
}
}
+ return tm;
+ }
! private Map getOrders(NameValuePair[] orders) {
! Map orderByStageName = new HashMap();
! if (orders != null) {
! for (int i = 0; i < orders.length; i++) {
! String stage = orders[i].getName();
! String orderStr = orders[i].getValue();
! Integer order = null;
! try {
! order = new Integer(orderStr);
! } catch (NumberFormatException nfe) {
! order = new Integer(stage.hashCode());
! }
! orderByStageName.put(stage, order);
! }
}
+ return orderByStageName;
}
}
|