use of org.cristalise.kernel.lifecycle.instance.stateMachine.StateMachine in project kernel by cristal-ise.
the class StateMachineCache method buildObject.
@Override
public StateMachine buildObject(String name, int version, ItemPath path, String data) throws InvalidDataException {
try {
StateMachine thisStateMachine = (StateMachine) Gateway.getMarshaller().unmarshall(data);
thisStateMachine.validate();
thisStateMachine.setName(name);
thisStateMachine.setVersion(version);
thisStateMachine.setItemPath(path);
return thisStateMachine;
} catch (Exception ex) {
Logger.error(ex);
throw new InvalidDataException("Could not unmarshall State Machine '" + name + "' v" + version + ": " + ex.getMessage());
}
}
use of org.cristalise.kernel.lifecycle.instance.stateMachine.StateMachine in project kernel by cristal-ise.
the class Job method getTransition.
public Transition getTransition() {
if (transition != null && transitionResolved == false) {
Logger.msg(8, "Job.getTransition() - actProps:" + actProps);
try {
StateMachine sm = LocalObjectLoader.getStateMachine(actProps);
transition = sm.getTransition(transition.getId());
transitionResolved = true;
} catch (Exception e) {
Logger.error(e);
return transition;
}
}
return transition;
}
use of org.cristalise.kernel.lifecycle.instance.stateMachine.StateMachine in project kernel by cristal-ise.
the class StandardClient method getRequiredStateMachine.
/**
* CRISTAL-iSE clients should use the StateMachine information to implement application logic. This method loads the
* required StateMachine using different cristal-ise configuration.
*
* @param propPrefix the Property Name prefix to find client specific configuration
* @param namesSpaceDefault default value to load bootstrap file if no configuration was provided
* @param bootfileDefault default value to load bootstrap file if no configuration was provided
* @return the initialised StateMachine object
* @throws InvalidDataException Missing/Incorrect configuration data
*/
protected static StateMachine getRequiredStateMachine(String propPrefix, String namesSpaceDefault, String bootfileDefault) throws InvalidDataException {
if (StringUtils.isBlank(propPrefix))
throw new InvalidDataException("propertyPrefix must contain a value");
String smName = Gateway.getProperties().getString(propPrefix + ".StateMachine.name");
int smVersion = Gateway.getProperties().getInt(propPrefix + ".StateMachine.version");
try {
if (StringUtils.isNotBlank(smName) && smVersion != -1) {
return LocalObjectLoader.getStateMachine(smName, smVersion);
} else {
Logger.warning("StandardClient.getRequiredStateMachine() - SM Name and/or Version was not specified, trying to load from bootsrap resource.");
String stateMachineNS = Gateway.getProperties().getString(propPrefix + ".StateMachine.namespace", namesSpaceDefault);
String stateMachinePath = Gateway.getProperties().getString(propPrefix + ".StateMachine.bootfile", bootfileDefault);
return (StateMachine) Gateway.getMarshaller().unmarshall(Gateway.getResource().getTextResource(stateMachineNS, stateMachinePath));
}
} catch (Exception e) {
Logger.error(e);
throw new InvalidDataException(e.getMessage());
}
}
use of org.cristalise.kernel.lifecycle.instance.stateMachine.StateMachine in project kernel by cristal-ise.
the class MainTest method testStateMachine.
@Test
public void testStateMachine() throws Exception {
Logger.msg("Validating test state machine");
String smXml = FileStringUtility.url2String(MainTest.class.getResource("/TestStateMachine.xml"));
StateMachine sm = (StateMachine) Gateway.getMarshaller().unmarshall(smXml);
sm.validate();
assert sm.isCoherent() : "Test StateMachine is reporting that it is not coherent";
}
Aggregations