java.lang.Object
net.datenwerke.rs.scripting.service.scripting.scriptservices.GlobalsWrapper

public class GlobalsWrapper extends Object
Is exposed as GLOBALS to any ReportServer script. This object provides access to ReportServer functionality by exposing ReportServer services and shortcuts for scripts to access entities and files from the file system.
  • Field Details

    • services

      public Map<String,Object> services
    • vars

      public Map<String,Object> vars
    • injector

      public Injector injector
    • injectorProvider

      public <any> injectorProvider
  • Constructor Details

  • Method Details

    • getInstance

      public <T> T getInstance(Class<T> type)
      Requests an instance from the
      invalid reference
      Injector
      Returns:
      the service
    • getProvider

      public <T> <any> getProvider(Class<T> type)
      Requests an
      invalid reference
      Provider
      from the
      invalid reference
      Injector
      Returns:
      the service
    • getRsService

      @Deprecated public <T> T getRsService(Class<T> type)
      Deprecated.
      Requests an instance from the
      invalid reference
      Injector
      Returns:
      the service
      See Also:
    • getRsServiceProvider

      @Deprecated public <T> <any> getRsServiceProvider(Class<T> type)
      Deprecated.
      Requests an
      invalid reference
      Provider
      from the
      invalid reference
      Injector
      Returns:
      the service
      See Also:
    • exec

      public Object exec(String path) throws ScriptEngineException

      Executes the script at the given path.

      Note that if the script contains classes, you can not use these directly. You can use loadClass(String, String) and loadClasses(String, List) in this case.

      Refer to the following examples: nested classes and multiple classes.

      Parameters:
      path - path to the script
      Returns:
      the result of the script execution
      Throws:
      ScriptEngineException
    • exec

      public Object exec(String path, String arguments) throws ScriptEngineException

      Executes the script at the given path passing on the supplied arguments.

      Note that if the script contains classes, you can not use these directly. You can use loadClass(String, String) and loadClasses(String, List) in this case.

      Refer to the following examples: nested classes and multiple classes.

      Parameters:
      path - path to the script
      arguments - arguments for the execution
      Returns:
      the result of the script execution
      Throws:
      ScriptEngineException
    • read

      public String read(String identifier)
      Reads in the file at the given path
      Parameters:
      identifier - path to file
      Returns:
      the result as string
    • loadClass

      public Class<?> loadClass(String path, String className) throws ScriptEngineException
      Loads a class found in the given .groovy file
      Parameters:
      path - path to the .groovy file.
      className - the fully qualified name of the desired class. In case the class does not contain a package declaration, you can use the class's name directly.
      Returns:
      the loaded class definition
      Throws:
      ScriptEngineException - if the class cannot be found or something else went wrong
    • loadClasses

      public List<Class<?>> loadClasses(String path, List<String> classNames) throws ScriptEngineException
      Loads a list of classes found in the given .groovy file
      Parameters:
      path - path to the .groovy file.
      classNames - the fully qualified names of the desired classes. In case the classes does not contain a package declaration, you can use the classes' names directly.
      Returns:
      the loaded class definitions
      Throws:
      ScriptEngineException - if the classes cannot be found or something else went wrong
    • newInstance

      public Object newInstance(Class<?> clazz) throws ScriptEngineException
      Creates a new instance of the given type using the no-argument constructor.
      Parameters:
      clazz - the type of the object to instantiate
      Returns:
      a new instance of the given type
      Throws:
      ScriptEngineException - if something went wrong during instantiation
    • newInstance

      public Object newInstance(Class<?> clazz, List<Class<?>> types, List<Object> params) throws ScriptEngineException
      Creates a new instance of the given type using the constructor with the given parameters.
      Parameters:
      clazz - the type of the object to instantiate
      types - the types of the constructor parameters
      params - the values of the constructor parameters
      Returns:
      a new instance of the given type
      Throws:
      ScriptEngineException - if something went wrong during instantiation
    • write

      public void write(String identifier, String data)
      Writes data into a file
    • findEntity

      public <T> T findEntity(Class<T> type, Object id)
      Tries to find the entity by id.
    • getEntitiesByType

      public <T> List<T> getEntitiesByType(Class<T> type)
      Returns all entities of a given type
    • getEntityManager

      public EntityManager getEntityManager()
      Returns an
      invalid reference
      EntityManager
    • getEntityManagerProvider

      public <any> getEntityManagerProvider()
      Returns an
      invalid reference
      Provider
      of an
      invalid reference
      EntityManager
    • execCmd

      public CommandResult execCmd(String command) throws TerminalException
      Executes a terminal command
      Throws:
      TerminalException
    • findObject

      public Object findObject(String objectLocation, Class<? extends Right>... rights) throws ObjectResolverException
      Locates an object and observes the supplied rights.
      Throws:
      ObjectResolverException
    • findObjects

      public Collection<Object> findObjects(String objectLocation, Class<? extends Right>... rights) throws ObjectResolverException
      Searches for objects and observes the supplied rights.
      Throws:
      ObjectResolverException