partial commit due to monitor crash, moving to laptop
This commit is contained in:
@@ -42,6 +42,10 @@ public abstract class AbstractActionModel extends AbstractModel {
|
||||
// not mergeable
|
||||
}
|
||||
|
||||
protected void fillCopy(final AbstractActionModel copy) {
|
||||
copy.setOutputs(copyList(attributes));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the attributes
|
||||
*/
|
||||
|
||||
@@ -32,6 +32,14 @@ public abstract class AbstractMappingModel extends AbstractModel {
|
||||
|
||||
private String required;
|
||||
|
||||
protected AbstractMappingModel fillCopy(AbstractMappingModel copy) {
|
||||
copy.setName(name);
|
||||
copy.setValue(value);
|
||||
copy.setType(type);
|
||||
copy.setRequired(required);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
|
||||
@@ -59,7 +59,11 @@ public abstract class AbstractModel implements Model {
|
||||
*/
|
||||
protected Model merge(Model child, Model parent) {
|
||||
if (child == null) {
|
||||
return parent;
|
||||
if (parent == null) {
|
||||
return null;
|
||||
} else {
|
||||
return parent.createCopy();
|
||||
}
|
||||
} else if (parent == null) {
|
||||
return child;
|
||||
} else {
|
||||
@@ -93,7 +97,7 @@ public abstract class AbstractModel implements Model {
|
||||
if (parent == null) {
|
||||
return null;
|
||||
} else {
|
||||
return new LinkedList(parent);
|
||||
return copyList(parent);
|
||||
}
|
||||
} else if (parent == null) {
|
||||
return child;
|
||||
@@ -114,9 +118,9 @@ public abstract class AbstractModel implements Model {
|
||||
}
|
||||
if (!matchFound) {
|
||||
if (addAtEnd) {
|
||||
child.addLast(parentElement);
|
||||
child.addLast(parentElement.createCopy());
|
||||
} else {
|
||||
child.addFirst(parentElement);
|
||||
child.addFirst(parentElement.createCopy());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,4 +128,23 @@ public abstract class AbstractModel implements Model {
|
||||
}
|
||||
}
|
||||
|
||||
protected Model copy(Model model) {
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
return model.createCopy();
|
||||
}
|
||||
|
||||
protected LinkedList copyList(LinkedList list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
LinkedList copy = new LinkedList();
|
||||
for (Iterator it = list.iterator(); it.hasNext();) {
|
||||
Model model = (Model) it.next();
|
||||
copy.add(model.createCopy());
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,15 @@ public abstract class AbstractStateModel extends AbstractModel {
|
||||
|
||||
private LinkedList exceptionHandlers;
|
||||
|
||||
protected void fillCopy(AbstractStateModel copy) {
|
||||
copy.setId(id);
|
||||
copy.setParent(parent);
|
||||
copy.setAttributes(copyList(attributes));
|
||||
copy.setSecured((SecuredModel) copy(secured));
|
||||
copy.setOnEntryActions(copyList(onEntryActions));
|
||||
copy.setExceptionHandlers(copyList(exceptionHandlers));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
@@ -130,4 +139,4 @@ public abstract class AbstractStateModel extends AbstractModel {
|
||||
this.exceptionHandlers = exceptionHandlers;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,12 @@ public abstract class AbstractTransitionableStateModel extends AbstractStateMode
|
||||
|
||||
private LinkedList onExitActions;
|
||||
|
||||
protected void fillCopy(final AbstractTransitionableStateModel copy) {
|
||||
super.fillCopy(copy);
|
||||
copy.setTransitions(copyList(transitions));
|
||||
copy.setOnExitActions(copyList(onExitActions));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the transitions
|
||||
*/
|
||||
@@ -56,4 +62,4 @@ public abstract class AbstractTransitionableStateModel extends AbstractStateMode
|
||||
this.onExitActions = onExitActions;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,13 @@ public class ActionStateModel extends AbstractTransitionableStateModel {
|
||||
setActions(merge(getActions(), state.getActions(), false));
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
ActionStateModel copy = new ActionStateModel(getId());
|
||||
super.fillCopy(copy);
|
||||
copy.setActions(copyList(actions));
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actions
|
||||
*/
|
||||
@@ -69,4 +76,4 @@ public class ActionStateModel extends AbstractTransitionableStateModel {
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,12 @@ public class AttributeModel extends AbstractModel {
|
||||
setType(merge(getType(), attribute.getType()));
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
AttributeModel copy = new AttributeModel(name, value);
|
||||
copy.setType(type);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
|
||||
@@ -45,7 +45,11 @@ public class BeanImportModel extends AbstractModel {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
public Model createCopy() {
|
||||
return new BeanImportModel(resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the resource
|
||||
*/
|
||||
public String getResource() {
|
||||
|
||||
@@ -42,4 +42,9 @@ public class BinderModel extends AbstractModel {
|
||||
setBindings(merge(getBindings(), binder.getBindings()));
|
||||
}
|
||||
|
||||
}
|
||||
public Model createCopy() {
|
||||
BinderModel copy = new BinderModel();
|
||||
copy.setBindings(copyList(bindings));
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,11 @@ public class BindingModel extends AbstractModel {
|
||||
setRequired(merge(getRequired(), binding.getRequired()));
|
||||
}
|
||||
|
||||
public String getProperty() {
|
||||
public Model createCopy() {
|
||||
return new BindingModel(property, converter, required);
|
||||
}
|
||||
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,14 @@ public class DecisionStateModel extends AbstractStateModel {
|
||||
setOnExitActions(merge(getOnExitActions(), state.getOnExitActions(), false));
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
DecisionStateModel copy = new DecisionStateModel(getId());
|
||||
super.fillCopy(copy);
|
||||
copy.setIfs(copyList(ifs));
|
||||
copy.setOnExitActions(copyList(onExitActions));
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the ifs
|
||||
*/
|
||||
@@ -84,4 +92,4 @@ public class DecisionStateModel extends AbstractStateModel {
|
||||
this.onExitActions = onExitActions;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,15 @@ public class EndStateModel extends AbstractStateModel {
|
||||
setOutputs(merge(getOutputs(), state.getOutputs(), false));
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
EndStateModel copy = new EndStateModel(getId());
|
||||
super.fillCopy(copy);
|
||||
copy.setView(view);
|
||||
copy.setCommit(commit);
|
||||
copy.setOutputs(outputs);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the view
|
||||
*/
|
||||
|
||||
@@ -40,6 +40,14 @@ public class EvaluateModel extends AbstractActionModel {
|
||||
setExpression(expression);
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
EvaluateModel copy = new EvaluateModel(expression);
|
||||
super.fillCopy(copy);
|
||||
copy.setResult(result);
|
||||
copy.setResultType(resultType);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the expression
|
||||
*/
|
||||
|
||||
@@ -43,7 +43,11 @@ public class ExceptionHandlerModel extends AbstractModel {
|
||||
public void merge(Model model) {
|
||||
}
|
||||
|
||||
public String getBean() {
|
||||
public Model createCopy() {
|
||||
return new ExceptionHandlerModel(bean);
|
||||
}
|
||||
|
||||
public String getBean() {
|
||||
return bean;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,7 @@ import org.springframework.util.StringUtils;
|
||||
* <li>Instantiate a set of instance variables when started. (See {@link VarModel})
|
||||
* <li>Map input provided by callers that start it (See {@link InputModel})
|
||||
* <li>Return output to callers that end it. (See {@link OutputModel})
|
||||
* <li>Execute actions at start time and end time. (See {@link EvaluateModel}, {@link RenderModel} and
|
||||
* {@link SetModel})
|
||||
* <li>Execute actions at start time and end time. (See {@link EvaluateModel}, {@link RenderModel} and {@link SetModel})
|
||||
* <li>Define transitions shared by all states. (See {@link TransitionModel})
|
||||
* <li>Handle exceptions thrown by during flow execution. (See {@link ExceptionHandlerModel})
|
||||
* <li>Import one or more local bean definition files defining custom flow artifacts (such as actions, exception
|
||||
@@ -109,6 +108,31 @@ public class FlowModel extends AbstractModel {
|
||||
setBeanImports(merge(getBeanImports(), flow.getBeanImports()));
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
FlowModel copy = new FlowModel();
|
||||
copy.setAbstract(abztract);
|
||||
copy.setParent(parent);
|
||||
copy.setStartStateId(startStateId);
|
||||
copy.setAttributes(copyList(attributes));
|
||||
copy.setSecured((SecuredModel) copy(secured));
|
||||
if (secured != null) {
|
||||
copy.setSecured((SecuredModel) secured.createCopy());
|
||||
}
|
||||
if (persistenceContext != null) {
|
||||
copy.setPersistenceContext((PersistenceContextModel) persistenceContext.createCopy());
|
||||
}
|
||||
copy.setVars(copyList(vars));
|
||||
copy.setInputs(copyList(inputs));
|
||||
copy.setOutputs(copyList(outputs));
|
||||
copy.setOnStartActions(copyList(onStartActions));
|
||||
copy.setStates(copyList(states));
|
||||
copy.setGlobalTransitions(copyList(globalTransitions));
|
||||
copy.setOnEndActions(copyList(onEndActions));
|
||||
copy.setExceptionHandlers(copyList(exceptionHandlers));
|
||||
copy.setBeanImports(copyList(beanImports));
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the abstract
|
||||
*/
|
||||
@@ -348,4 +372,4 @@ public class FlowModel extends AbstractModel {
|
||||
this.beanImports = beanImports;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,12 @@ public class IfModel extends AbstractModel {
|
||||
setElse(merge(getElse(), conditional.getElse()));
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
IfModel copy = new IfModel(test, then);
|
||||
copy.setElse(elze);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the test
|
||||
*/
|
||||
|
||||
@@ -51,4 +51,9 @@ public class InputModel extends AbstractMappingModel {
|
||||
setRequired(merge(getRequired(), input.getRequired()));
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
InputModel copy = new InputModel(getName(), getValue());
|
||||
super.fillCopy(copy);
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,22 +17,32 @@ package org.springframework.webflow.engine.model;
|
||||
|
||||
/**
|
||||
* Interface defining models. All models must be able to handle merging of their content with an eligible model.
|
||||
*
|
||||
*
|
||||
* @author Scott Andrews
|
||||
*/
|
||||
public interface Model {
|
||||
|
||||
/**
|
||||
* Determine if the model is able to be merged into the current model
|
||||
* @param model the model to compare
|
||||
* @return true if able to merge
|
||||
*/
|
||||
public boolean isMergeableWith(Model model);
|
||||
/**
|
||||
* Determine if the model is able to be merged into the current model
|
||||
*
|
||||
* @param model the model to compare
|
||||
*
|
||||
* @return true if able to merge
|
||||
*/
|
||||
public boolean isMergeableWith(Model model);
|
||||
|
||||
/**
|
||||
* Merge the model into the current model
|
||||
* @param model the model to merge with
|
||||
*/
|
||||
public void merge(Model model);
|
||||
/**
|
||||
* Merge the model into the current model
|
||||
*
|
||||
* @param model the model to merge with
|
||||
*/
|
||||
public void merge(Model model);
|
||||
|
||||
/**
|
||||
* Create a deep copy of this model. Needed when merging models and collections.
|
||||
*
|
||||
* @return a deep copy of this model
|
||||
*/
|
||||
public Model createCopy();
|
||||
|
||||
}
|
||||
|
||||
@@ -51,4 +51,10 @@ public class OutputModel extends AbstractMappingModel {
|
||||
setRequired(merge(getRequired(), output.getRequired()));
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
InputModel copy = new InputModel(getName(), getValue());
|
||||
super.fillCopy(copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,4 +42,9 @@ public class PersistenceContextModel extends AbstractModel {
|
||||
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
return new PersistenceContextModel();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,12 @@ public class RenderModel extends AbstractActionModel {
|
||||
|
||||
private String fragments;
|
||||
|
||||
public Model createCopy() {
|
||||
RenderModel copy = new RenderModel(fragments);
|
||||
super.fillCopy(copy);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a render action model
|
||||
* @param fragments the fragments to render
|
||||
|
||||
@@ -58,6 +58,12 @@ public class SecuredModel extends AbstractModel {
|
||||
setMatch(merge(getMatch(), secured.getMatch()));
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
SecuredModel copy = new SecuredModel(attributes);
|
||||
copy.setMatch(match);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the attributes
|
||||
*/
|
||||
|
||||
@@ -42,6 +42,13 @@ public class SetModel extends AbstractActionModel {
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
final SetModel copy = new SetModel(name, value);
|
||||
super.fillCopy(copy);
|
||||
copy.setType(type);
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.webflow.engine.model;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* Model support for subflow states.
|
||||
* @author Scott Andrews
|
||||
@@ -67,6 +67,15 @@ public class SubflowStateModel extends AbstractTransitionableStateModel {
|
||||
setOutputs(merge(getOutputs(), state.getOutputs()));
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
final SubflowStateModel copy = new SubflowStateModel(getId(), subflow);
|
||||
super.fillCopy(copy);
|
||||
copy.setSubflowAttributeMapper(subflowAttributeMapper);
|
||||
copy.setInputs(copyList(inputs));
|
||||
copy.setOutputs(copyList(outputs));
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the subflow
|
||||
*/
|
||||
@@ -131,4 +140,4 @@ public class SubflowStateModel extends AbstractTransitionableStateModel {
|
||||
this.outputs = outputs;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.webflow.engine.model;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
* Model support for transitions.
|
||||
* <p>
|
||||
@@ -225,4 +225,4 @@ public class TransitionModel extends AbstractModel {
|
||||
public void setActions(LinkedList actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,11 @@ public class VarModel extends AbstractModel {
|
||||
setClassName(merge(getClassName(), var.getClassName()));
|
||||
}
|
||||
|
||||
/**
|
||||
public Model createCopy() {
|
||||
return new VarModel(name, className);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
|
||||
@@ -75,6 +75,23 @@ public class ViewStateModel extends AbstractTransitionableStateModel {
|
||||
setOnRenderActions(merge(getOnRenderActions(), state.getOnRenderActions(), false));
|
||||
}
|
||||
|
||||
public Model createCopy() {
|
||||
ViewStateModel copy = new ViewStateModel(getId());
|
||||
super.fillCopy(copy);
|
||||
copy.setView(view);
|
||||
copy.setRedirect(redirect);
|
||||
copy.setPopup(popup);
|
||||
copy.setModel(model);
|
||||
copy.setVars(copyList(vars));
|
||||
if (binder != null) {
|
||||
copy.setBinder((BinderModel) binder.createCopy());
|
||||
} else {
|
||||
copy.setBinder(null);
|
||||
}
|
||||
copy.setOnRenderActions(copyList(onRenderActions));
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the view
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user