package nl.hippo.cms.wizard;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import nl.hippo.cms.wizard.aspects.Aspects;
import nl.hippo.cms.wizard.aspects.PropertyAspect;
import nl.hippo.cms.wizard.aspects.ComponentAspect;
import nl.hippo.cms.wizard.aspects.XpathAspect;
/**
* Helper class that is passed through the selected component path with the Component.fillResult() function,
* to collect the data needed to create the new document.
*
* @author a.bogaart@hippo.nl
*
*/
public class WizardResult {
private String type;
private StringBuffer path = new StringBuffer();
private String name;
private String extension;
private String sourceURI = "";
private String workflowName = Constants.DEFAULT_RESOURCE_WORKFLOW;
private String pipeline = "";
private List xpaths = new ArrayList();
private List properties = new ArrayList();
private boolean propertiesResult = false;
private boolean xpathsResult = false;
private String resultAction;
private List ids = new ArrayList();
public String getResultAction() {
return resultAction;
}
public void setResultAction(String resultAction) {
this.resultAction = resultAction;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPath() {
return path.toString();
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public void setSourceURI(String sourceURI) {
this.sourceURI = sourceURI;
}
public String getSourceURI() {
return sourceURI;
}
public String getDocumentURI() {
String tmpPath = this.path + Constants.URI_DELIMITER + this.name + Constants.FILE_DELIMITER + this.extension;
return tmpPath;
}
public String getWorkflowName() {
return workflowName;
}
public void setWorkflowName(String workflowName) {
this.workflowName = workflowName;
}
public String getPipeline() {
return pipeline;
}
public void setPipeline(String pipeline) {
this.pipeline = pipeline;
}
public void addId(String id) {
ids.add(id);
// addXpaths(aspects.getXpaths(id));
// addProperties(aspects.getProperties(id));
}
public List getProperties() {
return properties;
}
public List getXpaths() {
return xpaths;
}
public boolean isPropertiesResult() {
return propertiesResult;
}
public void setPropertiesResult(boolean propertiesResult) {
this.propertiesResult = propertiesResult;
}
public boolean isXpathsResult() {
return xpathsResult;
}
public void setXpathsResult(boolean xpathsResult) {
this.xpathsResult = xpathsResult;
}
public void debug() {
System.out.println("***************** New Document ********************");
System.out.println("Name: " + getName());
System.out.println("Extension: " + getExtension());
System.out.println("Type: " + getType());
System.out.println("Path: " + getPath());
System.out.println("DocURI: " + getDocumentURI());
System.out.println("Pipeline: " + getPipeline());
System.out.println("SourceURI: " + getSourceURI());
System.out.println("WorkflowName: " + getWorkflowName());
System.out.println("");
System.out.println("***************** xpaths ********************");
System.out.println(getXpaths());
System.out.println("");
System.out.println("***************** properties ********************");
System.out.println(getProperties());
}
/**
* @param newPath
*/
public void addPath(String newPath) {
if (newPath.startsWith("/")) {
path.delete(0, path.length());
} else {
path.append("/");
}
path.append(newPath);
}
/**
* @param newPath
*/
public void addLowerCasePath(String newPath) {
if (newPath.startsWith("/")) {
path.delete(0, path.length());
} else {
path.append("/");
}
path.append(newPath.toLowerCase());
}
public void addXpath(XpathAspect xpath) {
xpaths.add(xpath);
}
public void addProperty(PropertyAspect aspect) {
properties.add(aspect);
}
public void handleAspects(Aspects aspects) {
Iterator it = ids.iterator();
while(it.hasNext()) {
String id = (String) it.next();
List myAspects = (List)aspects.getAspectsById(id);
if(myAspects != null) {
Iterator it2 = myAspects.iterator();
while(it2.hasNext()) {
ComponentAspect asp = (ComponentAspect)it2.next();
asp.fillResult(this);
}
}
}
}
}
|