on 06-06-2018 10:20 AM
Hi,
I'm writing a trigger with trigger point 'Before Definition Change'.
I want to log the content of the source before the change is applied:
import java.text.MessageFormat;
import com.redwood.scheduler.api.model.JobDefinition;
{
Object o = jcsTriggerContext.getSchedulerEntity();
if (o instanceof JobDefinition)
{
JobDefinition jobDef = ((JobDefinition) o);
String msg = jobDef.getName() + "'s source will be changed. Now it's: " + jobDef.<getSource()>;
jcsOutLog.info(msg);
}
}
Could <getSource()> be replaced with something, so I could get the needed content?
Is there a reference guide where I could see the methods of the JobDefinition class?
Regards, Alexander
Now it works - thanks!
Regards, Alexander
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
JobDefinitionWithSource is indeed not the correct Object type. You need Script instead:
JobDefinitionRelatedObject jdro = jd.getJobDefinitionRelatedObject();
if (jdro instanceof Script)
{
String scriptSource = ((Script)jdro).getSource();
}
Regards Gerben
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I tried the mentioned solution, but when I test with a job definition that has RedwoodScript defined, it's still of type JobDefinition (and not JobDefinitionWithSource).
How could I create an object of type JobDefinitionWithSource?
Regards, Alexander
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please check apidoc for more details about methods, you can find under configuration->Software .
Please refer below code which can help you to get jobdefinition source.
if (jd1.getJobDefinitionRelatedObject() instanceof JobDefinitionWithSource) { JobDefinitionWithSource jds = (JobDefinitionWithSource)jd1.getJobDefinitionRelatedObject(); jcsOut.println(jd1.getName() + ";" + jds.getSource());
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.