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:
Scott Andrews
2008-03-24 15:49:55 +00:00
parent dded1235b3
commit 03bb8c4863
4 changed files with 24 additions and 32 deletions

View File

@@ -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) {

View File

@@ -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>&lt;state id="state" parent="flow"&gt;</pre> defaults to <pre>&lt;state id="state" parent="flow#state"&gt;</pre>.
To inherit from a different identifier <pre>&lt;state id="state" parent="flow#other"&gt;</pre>
</ul>
For example <pre>&lt;state id="state" parent="flowId#stateId"&gt;</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>&lt;state id="state" parent="flow"&gt;</pre> defaults to <pre>&lt;state id="state" parent="flow#state"&gt;</pre>.
To inherit from a different identifier <pre>&lt;state id="state" parent="flow#other"&gt;</pre>
</ul>
For example <pre>&lt;state id="state" parent="flowId#stateId"&gt;</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>&lt;state id="state" parent="flow"&gt;</pre> defaults to <pre>&lt;state id="state" parent="flow#state"&gt;</pre>.
To inherit from a different identifier <pre>&lt;state id="state" parent="flow#other"&gt;</pre>
</ul>
For example <pre>&lt;state id="state" parent="flowId#stateId"&gt;</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>&lt;state id="state" parent="flow"&gt;</pre> defaults to <pre>&lt;state id="state" parent="flow#state"&gt;</pre>.
To inherit from a different identifier <pre>&lt;state id="state" parent="flow#other"&gt;</pre>
</ul>
For example <pre>&lt;state id="state" parent="flowId#stateId"&gt;</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>&lt;state id="state" parent="flow"&gt;</pre> defaults to <pre>&lt;state id="state" parent="flow#state"&gt;</pre>.
To inherit from a different identifier <pre>&lt;state id="state" parent="flow#other"&gt;</pre>
</ul>
For example <pre>&lt;state id="state" parent="flowId#stateId"&gt;</pre>
]]>
</xsd:documentation>
</xsd:annotation>

View File

@@ -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() {