return step;
}
public WorkflowStep findStepByContentlet(Contentlet contentlet) throws DotDataException {
WorkflowStep step = cache.getStep(contentlet);
final WorkflowScheme scheme = this.findSchemeForStruct(contentlet.getStructureInode());
if ((step == null) || !step.getSchemeId().equals(scheme.getId())) {
try {
final DotConnect db = new DotConnect();
db.setSQL(sql.SELECT_STEP_BY_CONTENTLET);
db.addParam(contentlet.getIdentifier());
step = (WorkflowStep) this.convertListToObjects(db.loadObjectResults(), WorkflowStep.class).get(0);
} catch (final Exception e) {
Logger.debug(this.getClass(), e.getMessage());
}
if (step == null) {
try {
step = this.findSteps(scheme).get(0);
} catch (final Exception e) {
throw new DotDataException("Unable to find workflow step for content id:" + contentlet.getIdentifier());
}
}
// if the existing task belongs to another workflow schema, update
// to the latest schema
if (!step.getSchemeId().equals(scheme.getId())) {
step = this.findSteps(scheme).get(0);
final DotConnect db = new DotConnect();
db.setSQL(sql.RESET_CONTENTLET_STEPS);
db.addParam(step.getId());
db.addParam(contentlet.getIdentifier());