001: package nl.hippo.cms.wizard;
002:
003: import java.util.ArrayList;
004: import java.util.Iterator;
005: import java.util.List;
006:
007: import nl.hippo.cms.wizard.aspects.Aspects;
008: import nl.hippo.cms.wizard.aspects.PropertyAspect;
009: import nl.hippo.cms.wizard.aspects.ComponentAspect;
010: import nl.hippo.cms.wizard.aspects.XpathAspect;
011:
012: /**
013: * Helper class that is passed through the selected component path with the Component.fillResult() function,
014: * to collect the data needed to create the new document.
015: *
016: * @author a.bogaart@hippo.nl
017: *
018: */
019: public class WizardResult {
020: private String type;
021: private StringBuffer path = new StringBuffer();
022: private String name;
023: private String extension;
024: private String sourceURI = "";
025: private String workflowName = Constants.DEFAULT_RESOURCE_WORKFLOW;
026: private String pipeline = "";
027:
028: private List xpaths = new ArrayList();
029: private List properties = new ArrayList();
030: private boolean propertiesResult = false;
031: private boolean xpathsResult = false;
032:
033: private String resultAction;
034:
035: private List ids = new ArrayList();
036:
037: public String getResultAction() {
038: return resultAction;
039: }
040:
041: public void setResultAction(String resultAction) {
042: this .resultAction = resultAction;
043: }
044:
045: public String getExtension() {
046: return extension;
047: }
048:
049: public void setExtension(String extension) {
050: this .extension = extension;
051: }
052:
053: public String getName() {
054: return name;
055: }
056:
057: public void setName(String name) {
058: this .name = name;
059: }
060:
061: public String getPath() {
062: return path.toString();
063: }
064:
065: public String getType() {
066: return type;
067: }
068:
069: public void setType(String type) {
070: this .type = type;
071: }
072:
073: public void setSourceURI(String sourceURI) {
074: this .sourceURI = sourceURI;
075: }
076:
077: public String getSourceURI() {
078: return sourceURI;
079: }
080:
081: public String getDocumentURI() {
082: String tmpPath = this .path + Constants.URI_DELIMITER
083: + this .name + Constants.FILE_DELIMITER + this .extension;
084: return tmpPath;
085: }
086:
087: public String getWorkflowName() {
088: return workflowName;
089: }
090:
091: public void setWorkflowName(String workflowName) {
092: this .workflowName = workflowName;
093: }
094:
095: public String getPipeline() {
096: return pipeline;
097: }
098:
099: public void setPipeline(String pipeline) {
100: this .pipeline = pipeline;
101: }
102:
103: public void addId(String id) {
104: ids.add(id);
105: // addXpaths(aspects.getXpaths(id));
106: // addProperties(aspects.getProperties(id));
107: }
108:
109: public List getProperties() {
110: return properties;
111: }
112:
113: public List getXpaths() {
114: return xpaths;
115: }
116:
117: public boolean isPropertiesResult() {
118: return propertiesResult;
119: }
120:
121: public void setPropertiesResult(boolean propertiesResult) {
122: this .propertiesResult = propertiesResult;
123: }
124:
125: public boolean isXpathsResult() {
126: return xpathsResult;
127: }
128:
129: public void setXpathsResult(boolean xpathsResult) {
130: this .xpathsResult = xpathsResult;
131: }
132:
133: public void debug() {
134: System.out
135: .println("***************** New Document ********************");
136: System.out.println("Name: " + getName());
137: System.out.println("Extension: " + getExtension());
138: System.out.println("Type: " + getType());
139: System.out.println("Path: " + getPath());
140: System.out.println("DocURI: " + getDocumentURI());
141: System.out.println("Pipeline: " + getPipeline());
142: System.out.println("SourceURI: " + getSourceURI());
143: System.out.println("WorkflowName: " + getWorkflowName());
144: System.out.println("");
145: System.out
146: .println("***************** xpaths ********************");
147: System.out.println(getXpaths());
148:
149: System.out.println("");
150: System.out
151: .println("***************** properties ********************");
152: System.out.println(getProperties());
153:
154: }
155:
156: /**
157: * @param newPath
158: */
159: public void addPath(String newPath) {
160: if (newPath.startsWith("/")) {
161: path.delete(0, path.length());
162: } else {
163: path.append("/");
164: }
165: path.append(newPath);
166: }
167:
168: /**
169: * @param newPath
170: */
171: public void addLowerCasePath(String newPath) {
172: if (newPath.startsWith("/")) {
173: path.delete(0, path.length());
174: } else {
175: path.append("/");
176: }
177: path.append(newPath.toLowerCase());
178: }
179:
180: public void addXpath(XpathAspect xpath) {
181: xpaths.add(xpath);
182: }
183:
184: public void addProperty(PropertyAspect aspect) {
185: properties.add(aspect);
186: }
187:
188: public void handleAspects(Aspects aspects) {
189: Iterator it = ids.iterator();
190: while (it.hasNext()) {
191: String id = (String) it.next();
192: List myAspects = (List) aspects.getAspectsById(id);
193: if (myAspects != null) {
194: Iterator it2 = myAspects.iterator();
195: while (it2.hasNext()) {
196: ComponentAspect asp = (ComponentAspect) it2.next();
197: asp.fillResult(this);
198: }
199: }
200: }
201: }
202: }
|