cancel
Showing results for 
Search instead for 
Did you mean: 

Actions and Libraries

Former Member
0 Kudos

Hello,

I create an action, which will used by serval jobs. Now, I have outsourced this coding in a Custom_Actions Library. This library should containing all my actions, so that I can reuse actions by different jobs. But how I can use this library from the action tab?

Here what I have done:

1. Create library:

public class Actions  {
	  protected com.redwood.scheduler.api.model.SchedulerSession jcsSession;
	  protected PrintWriter jcsOut;
	  protected Job jcsJob;
	  
	  
	 public Actions(Job job, SchedulderSession jcsSession)
	{
                      // Call Class, create a object with the currentJob        
	 jcsJob = job;
                      jcsSession = jcsSession;
	}  
  
	public void checkJobLog(String searchPattern, PostRunningActionScriptObject jcsPostRunningContext)
	{
		String pattern = searchPattern;
		boolean patternFound = false;

		// Gehe über JobFiles
		for (Iterator it = jcsJob.getJobFiles(); it.hasNext();)
		{
			JobFile f = (JobFile) it.next();
			JobFileType fileType = f.getType();
			// Ist das Jobfile vom Typ Output?
			if (fileType.name().equalsIgnoreCase("Output"))
			{
				SearchResult result = null;
				SearchResultSet resultSet = null;
				// Suche im JobLog nach dem
				resultSet = f.search(pattern);
				// Prüfe ob etwas gefunden wurde.
				try
				{
					if (resultSet.next())
					{
						result = resultSet.getSearchResult();
						if (result.wasFound())
						{
							jcsPostRunningContext.setFinalStatus(JobStatus.Error);
							OperatorMessage operatorMessage = jcsSession.createOperatorMessage();
							operatorMessage.setFullText("Der Suchbegriff wurde gefunden");

						}
					}
				} catch (Exception e)
				{
					// TODO: handle exception
					OperatorMessage operatorMessage = jcsSession.createOperatorMessage();
					operatorMessage.setFullText("Fehler ist aufgetreten");
					jcsOut.println(operatorMessage.getFullText());
				}

			}
		}
	}
}

2. Create JobDefinition

On action tab I create a PostRunning Condition

Select Library: Custom_Action

Insert Coding:

{
//Create  a new Object actions
Actions a = new Action(jcsJob, jcsSession);
// Set searchPattern
String searchPattern = "*4711*";
// Call method checkJobLog with parameter
a.checkJobLog(searchPattern,jcsPostRunningContext);
}

If I want to save that I got always the message:

JCS-102183: Kompilierung für Job definition ZZ_UTIL_TEST10 action (type=Post Running) fehlgeschl: ZZ_UTIL_TEST10.java:user code 2:0:cannot resolve symbol symbol : class Actions location: class com.redwood.scheduler.custom.ZZ_UTIL_TEST10 Actions a = new Actions(jcsJob);
JCS-102183: Kompilierung für Job definition ZZ_UTIL_TEST10 action (type=Post Running) fehlgeschl: ZZ_UTIL_TEST10.java:user code 2:16:cannot resolve symbol symbol : class Actions location: class com.redwood.scheduler.custom.ZZ_UTIL_TEST10 Actions a = new Actions(jcsJob);
JCS-102183: Kompilierung für Job definition ZZ_UTIL_TEST10 action (type=Post Running) fehlgeschl: :2 errors

I have tried this in different ways, e.g.

- Import the library first.

- Without Construtor and calling the method directly

But doesn't possible to save it.

Any ideas what's wrong?

Kind Regards

Marc

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello,

I found my mistake.

import com.redwood.scheduler.custom.actions.Actions;
{

Actions a = new Actions(jcsJob);
String searchPattern = "*4711*";
a.checkJobLog(searchPattern,jcsPostRunningContext);
}

The import was wrong.

Kind Regards

Marc