com.novell.zos.jdl
Class ComputedFact

java.lang.Object
  extended by com.novell.zos.jdl.ComputedFact

public class ComputedFact
extends java.lang.Object

ComputedFact is the base class for creating custom Computed Facts.

Computed Facts provide the ability to create custom calculations that extend the built-in factsets for a Grid Object. The Computed Fact is meant to be used in constraints.

Example to calculate how many instances of the job named "foo" that the user in the current job context is running. This value of this computed fact can be used in a constraint to limit the number of instances of a particular job that a user can run:

  class ActiveFooJobs(ComputedFact):

      def compute(self):
          count = 0
          ctx = self.getContext()
          if ctx == None:
              print "No context"
          else:
              jobInstance = ctx.getJobInstance()
              if jobInstance == None:
                  print "No job instance in context"
              else:
                  activejobs = getMatrix().getActiveJobs()
                  for j in activejobs:
                      state = j.getFact("jobinstance.state.string")
                      if j.getFact("job.id") == "foo" and \
                          j.getFact("user.id") == ctx.getFact("user.id") and \
                          (state == "Running" or state == "Starting"):
                          count+=1
          return count
In order to use a Computed Fact you must create a class that subclasses ComputedFact in a file and deploy that file to the server. The ComputedFact subclass name is not required to match the Computed Fact filename. The filename is the defined Computed Fact name. To use the Computed Fact, you must create a linked fact referencing the deployed ComputedFact. The linked fact is then used in constraints.


Method Summary
 ComputedFactContext getContext()
          Retrieve the context object for this Computed Fact instance.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getContext

public ComputedFactContext getContext()
Retrieve the context object for this Computed Fact instance.

The context object allows read-only access to the Grid Objects in the evaluation context. For example, when a computed fact is evaluated in the context of a Start constraint, the context object provides access to the Job Instance's factset.

Returns:
ComputedFactContext for this computed fact evaluation. None if there is no context


Copyright (c) 2011 Novell, Inc. All rights reserved.