Open Journal Systems  3.3.0
Filter Class Reference
Inheritance diagram for Filter:
DataObject CitationListTokenizerFilter CrosswalkFilter PersistableFilter ArticlePubMedXmlFilter CompositeFilter MetadataDataObjectAdapter NativeImportExportFilter PersistableTestFilter TemplateBasedFilter XSLTransformationFilter GenericMultiplexerFilter GenericSequencerFilter OtherCompositeFilter Dc11SchemaArticleAdapter MetadataDescriptionDummyAdapter DOAJJsonFilter NativeExportFilter NativeImportFilter

Public Member Functions

 __construct ($inputType, $outputType)
 
 addError ($message)
 
 clearErrors ()
 
execute (&$input, $returnErrors=false)
 
 getDisplayName ()
 
 getErrors ()
 
getInputType ()
 
getLastInput ()
 
getLastOutput ()
 
getOutputType ()
 
getRuntimeEnvironment ()
 
 getSequence ()
 
 hasErrors ()
 
 isCompatibleWithRuntimeEnvironment ()
 
process (&$input)
 
 setDisplayName ($displayName)
 
 setRuntimeEnvironment (&$runtimeEnvironment)
 
 setSequence ($seq)
 
 setTransformationType (&$inputType, &$outputType)
 
 supports (&$input, &$output)
 
 supportsAsInput (&$input)
 
- Public Member Functions inherited from DataObject
 __construct ()
 
 addSupportedMetadataAdapter ($metadataAdapter)
 
 extractMetadata ($metadataSchema)
 
 getAdditionalMetadataFieldNames ()
 
getAllData ()
 
 getDAO ()
 
getData ($key, $locale=null)
 
 getHasLoadableAdapters ()
 
 getId ()
 
 getLocaleMetadataFieldNames ()
 
 getLocalizedData ($key, $preferredLocale=null)
 
 getMetadataFieldNames ($translated=true)
 
 getSetMetadataFieldNames ($translated=true)
 
 getSupportedExtractionAdapters ()
 
 getSupportedInjectionAdapters ()
 
 getSupportedMetadataSchemas ()
 
 hasData ($key, $locale=null)
 
 injectMetadata ($metadataDescription)
 
 removeSupportedMetadataAdapter ($metadataSchemaName)
 
 setAllData (&$data)
 
 setData ($key, $value, $locale=null)
 
 setHasLoadableAdapters ($hasLoadableAdapters)
 
 setId ($id)
 
 unsetData ($key, $locale=null)
 
 upcastTo ($targetObject)
 

Static Public Member Functions

static supportedRuntimeEnvironmentSettings ()
 

Data Fields

 $_errors = array()
 
 $_input
 
 $_inputType
 
 $_output
 
 $_outputType
 
 $_runtimeEnvironment = false
 
- Data Fields inherited from DataObject
 $_data = array()
 
 $_extractionAdaptersLoaded = false
 
 $_hasLoadableAdapters = false
 
 $_injectionAdaptersLoaded = false
 
 $_metadataExtractionAdapters = array()
 
 $_metadataInjectionAdapters = array()
 

Detailed Description

Class that provides the basic template for a filter. Filters are generic data processors that take in a well-specified data type and return another well-specified data type.

Filters enable us to re-use data transformations between applications. Generic filter implementations can sequence, (de-)multiplex or iterate over other filters. Thereby filters can be nested and combined in many different ways to form complex and easy-to-customize data processing networks or pipelines.

NB: This also means that filters only make sense if they accept and return standardized formats that are understood by other filters. Otherwise the extra implementation effort for a filter won't result in improved code re-use.

Objects from different applications (e.g. Papers and Articles) can first be transformed by an application specific filter into a common format and then be processed by application agnostic import/export filters or vice versa. Filters can be used to pre-process data before it is indexed for search. They also provide a framework to customize the processing applied in citation parsing and lookup (i.e. which parsers and lookup sources should be applied).

Filters can be used stand-alone outside PKP applications.

The following is a complete list of all use-cases that have been identified for filters: 1) Decode/Encode

  • import/export: transform application objects (e.g. an Article object) into structured (rich) data formats (e.g. XML, OpenURL KEV, CSV) or vice versa.
  • parse: transform unstructured clob/blob data (e.g. a Word Document) into application objects (e.g. an Article plus Citation objects) or into structured data formats (e.g. XML).
  • render: transform application objects or structured clob/blob data into an unstructured document (e.g. PDF, HTML, Word Document).

2) Normalize

  • lookup: compare the data of a given entity (e.g. a bibliographic reference) with data from other sources (e.g. CrossRef) and use this to normalize data or improve data quality.
  • harvest: cleanse and normalize incoming meta-data

3) Map

  • cross-walk: transform one meta-data format into another. Meta-data can be represented as structured clob/blob data (e.g. XML) or as application objects (i.e. a MetadataRecord instance).
  • meta-data extraction: retrieve meta-data from OO entities (e.g. an Article) into a standardized meta-data record (e.g. NLM element-citation).
  • meta-data injection: inject data from a standardized meta-data record into application objects.

4) Convert documents

  • binary converters: wrap binary document converters (e.g. antidoc) in a well-defined and re-usable way.

5) Search

  • indexing: pre-process data (extract, tokenize, remove stopwords, stem) for indexing.
  • finding: pre-process queries (parse, tokenize, remove stopwords, stem) to access the index

Definition at line 78 of file Filter.inc.php.

Constructor & Destructor Documentation

◆ __construct()

Filter::__construct (   $inputType,
  $outputType 
)

Constructor

Receives input and output type that define the transformation.

See also
TypeDescription
Parameters
$inputTypestring a string representation of a TypeDescription
$outputTypestring a string representation of a TypeDescription

Reimplemented in CrosswalkFilter, MetadataDataObjectAdapter, and XSLTransformationFilter.

Definition at line 127 of file Filter.inc.php.

References setTransformationType().

Member Function Documentation

◆ addError()

Filter::addError (   $message)

◆ clearErrors()

Filter::clearErrors ( )

Clear all processing errors.

Definition at line 288 of file Filter.inc.php.

◆ execute()

& Filter::execute ( $input,
  $returnErrors = false 
)

Filters the given input.

Input and output of this method will be tested for compliance with the filter definition.

NB: sub-classes will not normally override this method.

Parameters
$inputmixed an input value that is supported by this filter
$returnErrorsboolean whether the value should be returned also if an error occurred
Returns
mixed a valid return value or null if an error occurred during processing

Definition at line 444 of file Filter.inc.php.

References $_output, HookRegistry\call(), fatalError(), isCompatibleWithRuntimeEnvironment(), process(), strtolower_codesafe(), supports(), and supportsAsInput().

◆ getDisplayName()

Filter::getDisplayName ( )

Get the display name

NB: The standard implementation of this method will initialize the display name with the filter class name. Subclasses can of course override this behavior by explicitly setting a display name.

Returns
string

Definition at line 155 of file Filter.inc.php.

References DataObject\getData(), DataObject\hasData(), and DataObject\setData().

◆ getErrors()

Filter::getErrors ( )

Get all filter errors

Returns
array

Definition at line 273 of file Filter.inc.php.

References $_errors.

◆ getInputType()

& Filter::getInputType ( )

Get the input type

Returns
TypeDescription

Definition at line 209 of file Filter.inc.php.

References $_inputType.

Referenced by MetadataDataObjectAdapter\__construct(), NativeExportFilter\supports(), and supports().

◆ getLastInput()

& Filter::getLastInput ( )

Get the last valid input processed by this filter.

This can be used for debugging internal filter state or for access to intermediate results when working with larger filter grids.

NB: The input will be set only after input validation so that you can be sure that you'll always find valid data here.

Returns
mixed

Definition at line 257 of file Filter.inc.php.

References $_input.

◆ getLastOutput()

& Filter::getLastOutput ( )

Get the last valid output produced by this filter.

This can be used for debugging internal filter state or for access to intermediate results when working with larger filter grids.

NB: The output will be set only after output validation so that you can be sure that you'll always find valid data here.

Returns
mixed

Definition at line 237 of file Filter.inc.php.

References $_output.

◆ getOutputType()

& Filter::getOutputType ( )

Get the output type

Returns
TypeDescription

Definition at line 217 of file Filter.inc.php.

References $_outputType.

Referenced by MetadataDataObjectAdapter\__construct(), NativeExportFilter\supports(), and supports().

◆ getRuntimeEnvironment()

& Filter::getRuntimeEnvironment ( )

Get the required runtime environment

Returns
RuntimeEnvironment

Definition at line 313 of file Filter.inc.php.

References $_runtimeEnvironment.

◆ getSequence()

Filter::getSequence ( )

Get the sequence id

Returns
integer

Definition at line 175 of file Filter.inc.php.

References DataObject\getData().

◆ hasErrors()

Filter::hasErrors ( )

Whether this filter has produced errors.

Returns
boolean

Definition at line 281 of file Filter.inc.php.

◆ isCompatibleWithRuntimeEnvironment()

Filter::isCompatibleWithRuntimeEnvironment ( )

Check whether the filter is compatible with the required runtime environment.

Returns
boolean

Reimplemented in CompositeFilter.

Definition at line 393 of file Filter.inc.php.

References DataObject\getData(), DataObject\hasData(), and supportedRuntimeEnvironmentSettings().

Referenced by execute().

◆ process()

& Filter::process ( $input)

◆ setDisplayName()

◆ setRuntimeEnvironment()

Filter::setRuntimeEnvironment ( $runtimeEnvironment)

Set the required runtime environment

Parameters
$runtimeEnvironmentRuntimeEnvironment

Definition at line 296 of file Filter.inc.php.

References DataObject\setData(), and supportedRuntimeEnvironmentSettings().

◆ setSequence()

Filter::setSequence (   $seq)

Set the sequence id

Parameters
$seqinteger

Definition at line 167 of file Filter.inc.php.

References DataObject\setData().

◆ setTransformationType()

Filter::setTransformationType ( $inputType,
$outputType 
)

Set the input/output type of this filter group.

Parameters
$inputTypeTypeDescription|string
$outputTypeTypeDescription|string
See also
TypeDescriptionFactory::instantiateTypeDescription() for more details

Definition at line 187 of file Filter.inc.php.

References TypeDescriptionFactory\getInstance().

Referenced by __construct().

◆ supportedRuntimeEnvironmentSettings()

static Filter::supportedRuntimeEnvironmentSettings ( )
static

Returns a static array with supported runtime environment settings and their default values.

Returns
array

Definition at line 489 of file Filter.inc.php.

Referenced by isCompatibleWithRuntimeEnvironment(), and setRuntimeEnvironment().

◆ supports()

Filter::supports ( $input,
$output 
)

Returns true if the given input and output objects represent a valid transformation for this filter.

This check must be type based. It can optionally include an additional stateful inspection of the given object instances.

If the output type is null then only check whether the given input type is one of the input types accepted by this filter.

The standard implementation provides full type based checking. Subclasses must implement any required stateful inspection of the provided objects.

Parameters
$inputmixed
$outputmixed
Returns
boolean

Reimplemented in NativeExportFilter.

Definition at line 358 of file Filter.inc.php.

References getInputType(), and getOutputType().

Referenced by execute(), and supportsAsInput().

◆ supportsAsInput()

Filter::supportsAsInput ( $input)

Returns true if the given input is supported by this filter. Otherwise returns false.

NB: sub-classes will not normally override this method.

Parameters
$inputmixed
Returns
boolean

Definition at line 383 of file Filter.inc.php.

References supports().

Referenced by execute().

Field Documentation

◆ $_errors

array Filter::$_errors = array()

a list of errors occurred while filtering

Definition at line 107 of file Filter.inc.php.

Referenced by getErrors().

◆ $_input

mixed Filter::$_input

Definition at line 95 of file Filter.inc.php.

Referenced by getLastInput().

◆ $_inputType

TypeDescription Filter::$_inputType

Definition at line 83 of file Filter.inc.php.

Referenced by getInputType().

◆ $_output

mixed Filter::$_output

Definition at line 101 of file Filter.inc.php.

Referenced by execute(), and getLastOutput().

◆ $_outputType

TypeDescription Filter::$_outputType

Definition at line 89 of file Filter.inc.php.

Referenced by getOutputType().

◆ $_runtimeEnvironment

RuntimeEnvironment Filter::$_runtimeEnvironment = false

the installation requirements required to run this filter instance, false on initialization.

Definition at line 116 of file Filter.inc.php.

Referenced by getRuntimeEnvironment().


The documentation for this class was generated from the following file: