RESOLVED - issue SWF-545: Add support for merging a state in one flow model with a state in another
http://jira.springframework.org/browse/SWF-545 removed stateId defaulting for parent
This commit is contained in:
@@ -154,13 +154,12 @@ public class XmlFlowModelBuilder implements FlowModelBuilder {
|
||||
String flowId;
|
||||
String stateId;
|
||||
AbstractStateModel parentState = null;
|
||||
if (parent.contains("#")) {
|
||||
flowId = parent.substring(0, parent.indexOf("#")).trim();
|
||||
stateId = parent.substring(parent.indexOf("#") + 1).trim();
|
||||
} else {
|
||||
flowId = parent.trim();
|
||||
stateId = childState.getId();
|
||||
if (!parent.contains("#")) {
|
||||
throw new FlowModelBuilderException("Invalid parent syntax '" + parent
|
||||
+ "', should take form 'flowId#stateId'");
|
||||
}
|
||||
flowId = parent.substring(0, parent.indexOf("#")).trim();
|
||||
stateId = parent.substring(parent.indexOf("#") + 1).trim();
|
||||
try {
|
||||
parentState = modelLocator.getFlowModel(flowId).getStateById(stateId);
|
||||
if (parentState == null) {
|
||||
|
||||
@@ -284,11 +284,9 @@ The unique identifier of this state; must be unique to this flow.
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
Flow identifier to inherit from for this state only. By default, the inherited flow's state identifer will match this state's identifier.
|
||||
Flow identifier to inherit from for this state only.
|
||||
<p>
|
||||
For example <pre><state id="state" parent="flow"></pre> defaults to <pre><state id="state" parent="flow#state"></pre>.
|
||||
To inherit from a different identifier <pre><state id="state" parent="flow#other"></pre>
|
||||
</ul>
|
||||
For example <pre><state id="state" parent="flowId#stateId"></pre>
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
@@ -449,11 +447,9 @@ The unique identifier of this state; must be unique to this flow.
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
Flow identifier to inherit from for this state only. By default, the inherited flow's state identifer will match this state's identifier.
|
||||
Flow identifier to inherit from for this state only.
|
||||
<p>
|
||||
For example <pre><state id="state" parent="flow"></pre> defaults to <pre><state id="state" parent="flow#state"></pre>.
|
||||
To inherit from a different identifier <pre><state id="state" parent="flow#other"></pre>
|
||||
</ul>
|
||||
For example <pre><state id="state" parent="flowId#stateId"></pre>
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
@@ -651,11 +647,9 @@ The unique identifier of this state; must be unique to this flow.
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
Flow identifier to inherit from for this state only. By default, the inherited flow's state identifer will match this state's identifier.
|
||||
Flow identifier to inherit from for this state only.
|
||||
<p>
|
||||
For example <pre><state id="state" parent="flow"></pre> defaults to <pre><state id="state" parent="flow#state"></pre>.
|
||||
To inherit from a different identifier <pre><state id="state" parent="flow#other"></pre>
|
||||
</ul>
|
||||
For example <pre><state id="state" parent="flowId#stateId"></pre>
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
@@ -770,11 +764,9 @@ The unique identifier of this state; must be unique to this flow.
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
Flow identifier to inherit from for this state only. By default, the inherited flow's state identifer will match this state's identifier.
|
||||
Flow identifier to inherit from for this state only.
|
||||
<p>
|
||||
For example <pre><state id="state" parent="flow"></pre> defaults to <pre><state id="state" parent="flow#state"></pre>.
|
||||
To inherit from a different identifier <pre><state id="state" parent="flow#other"></pre>
|
||||
</ul>
|
||||
For example <pre><state id="state" parent="flowId#stateId"></pre>
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
@@ -878,11 +870,9 @@ The unique identifier of this state; must be unique to this flow.
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
<![CDATA[
|
||||
Flow identifier to inherit from for this state only. By default, the inherited flow's state identifer will match this state's identifier.
|
||||
Flow identifier to inherit from for this state only.
|
||||
<p>
|
||||
For example <pre><state id="state" parent="flow"></pre> defaults to <pre><state id="state" parent="flow#state"></pre>.
|
||||
To inherit from a different identifier <pre><state id="state" parent="flow#other"></pre>
|
||||
</ul>
|
||||
For example <pre><state id="state" parent="flowId#stateId"></pre>
|
||||
]]>
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
|
||||
@@ -172,7 +172,6 @@ public class XmlFlowModelBuilderTests extends TestCase {
|
||||
fail("A FlowModelConstructionException was expected");
|
||||
} catch (FlowModelConstructionException e) {
|
||||
// we want this
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,16 +196,20 @@ public class XmlFlowModelBuilderTests extends TestCase {
|
||||
assertEquals("otherview", ((ViewStateModel) flow.getStates().get(0)).getView());
|
||||
}
|
||||
|
||||
public void testStateMergeDefault() {
|
||||
ClassPathResource resourceChild = new ClassPathResource("flow-inheritance-state-child-default.xml", getClass());
|
||||
public void testStateMergeInvalidParentSyntax() {
|
||||
ClassPathResource resourceChild = new ClassPathResource("flow-inheritance-state-invalid-parent-syntax.xml",
|
||||
getClass());
|
||||
ClassPathResource resourceParent = new ClassPathResource("flow-inheritance-state-parent.xml", getClass());
|
||||
registry
|
||||
.registerFlowModel(new DefaultFlowModelHolder(new XmlFlowModelBuilder(resourceChild, registry), "child"));
|
||||
registry.registerFlowModel(new DefaultFlowModelHolder(new XmlFlowModelBuilder(resourceParent, registry),
|
||||
"parent"));
|
||||
FlowModel flow = registry.getFlowModel("child");
|
||||
assertEquals(1, flow.getStates().size());
|
||||
assertEquals("mainview", ((ViewStateModel) flow.getStates().get(0)).getView());
|
||||
try {
|
||||
registry.getFlowModel("child");
|
||||
fail("A FlowModelConstructionException was expected");
|
||||
} catch (FlowModelConstructionException e) {
|
||||
// we want this
|
||||
}
|
||||
}
|
||||
|
||||
public void testStateMergeParentFlowNotFound() {
|
||||
|
||||
Reference in New Issue
Block a user