package com.cloudbees.plugins.flow;

import hudson.model.Cause;

/**
 * @author: <a hef="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
 */
public class FlowCause extends Cause {

    private final transient FlowRun flowRun;

    public FlowCause(FlowRun flowRun) {
        this.flowRun = flowRun;
    }

    @Override
    public String getShortDescription() {
        return "Started by build flow " + flowRun.toString();
    }
}

@@ -56,16 +56,46 @@
 l.Cause;
+%0Aimport jenkins.model.Jenkins;
 %0A%0A/**%0A *
@@ -225,14 +225,8 @@
 ate 
-final 
 tran
@@ -249,16 +249,49 @@
 owRun;%0A%0A
+    private final String cause;%0A%0A
     publ
@@ -354,16 +354,449 @@
 lowRun;%0A
+        this.cause = flowRun.getParent().getFullName() + %22#%22 + flowRun.getNumber();%0A    %7D%0A%0A    public FlowRun getFlowRun() %7B%0A        if (this.flowRun == null) %7B%0A            int i = cause.lastIndexOf('#');%0A            BuildFlow flow = Jenkins.getInstance().getItemByFullName(cause.substring(0,i), BuildFlow.class);%0A            flowRun = flow.getBuildByNumber(Integer.parseInt(cause.substring(i+1)));%0A        %7D%0A        return flowRun;%0A
     %7D%0A%0A 
@@ -896,26 +896,13 @@
 %22 + 
-flowRun.toString()
+cause
 ;%0A  

fix a NullPointer to render FlowCause after jenkins restart