Open Journal Systems  2.4.4
 All Classes Namespaces Functions Variables Groups Pages
Filter Class Reference
Inheritance diagram for Filter:
DataObject CitationListTokenizerFilter CrosswalkFilter DateStringNormalizerFilter Nlm30CitationDemultiplexerFilter Nlm30PersonStringFilter PersistableFilter Nlm30Openurl10CrosswalkFilter Nlm30NameSchemaPersonStringFilter PersonStringNlm30NameSchemaFilter CompositeFilter MetadataDataObjectAdapter Mods34DescriptionXmlFilter Nlm30CitationSchemaFilter PersistableTestFilter TemplateBasedFilter XSLTransformationFilter

Public Member Functions

 addError ($message)
 
 clearErrors ()
 
execute (&$input)
 
 Filter ($inputType, $outputType)
 
 getDisplayName ()
 
 getErrors ()
 
getInputType ()
 
getLastInput ()
 
getLastOutput ()
 
getOutputType ()
 
getRuntimeEnvironment ()
 
 getSeq ()
 
 hasErrors ()
 
 isCompatibleWithRuntimeEnvironment ()
 
process (&$input)
 
 setDisplayName ($displayName)
 
 setRuntimeEnvironment (&$runtimeEnvironment)
 
 setSeq ($seq)
 
 setTransformationType (&$inputType, &$outputType)
 
 supportedRuntimeEnvironmentSettings ()
 
 supports (&$input, &$output)
 
 supportsAsInput (&$input)
 
- Public Member Functions inherited from DataObject
 addSupportedMetadataAdapter (&$metadataAdapter)
 
 DataObject ($callHooks=true)
 
extractMetadata (&$metadataSchema)
 
 getAdditionalMetadataFieldNames ()
 
getAllData ()
 
getData ($key, $locale=null)
 
 getHasLoadableAdapters ()
 
 getId ()
 
 getLocaleMetadataFieldNames ()
 
getLocalizedData ($key)
 
 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)
 
upcastTo (&$targetObject)
 

Additional Inherited Members

- Public Attributes inherited from DataObject
 $_data = 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.

Member Function Documentation

Filter::clearErrors ( )

Clear all processing errors.

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

& Filter::execute ( $input)

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
mixedan input value that is supported by this filter
Returns
mixed a valid return value or null if an error occurred during processing

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

References isCompatibleWithRuntimeEnvironment(), process(), supports(), and supportsAsInput().

Filter::Filter (   $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

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

References setTransformationType().

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 137 of file Filter.inc.php.

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

Referenced by Nlm30CitationSchemaFilter\callWebService(), Nlm30CitationSchemaFilter\getNlm30CitationDescriptionFromMetadataArray(), ParscitRawCitationNlm30CitationSchemaFilter\process(), ParaciteRawCitationNlm30CitationSchemaFilter\process(), and Nlm30CitationSchemaFilter\transformWebServiceResults().

Filter::getErrors ( )

Get all filter errors

Returns
array

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

& Filter::getInputType ( )
& 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 239 of file Filter.inc.php.

& 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 219 of file Filter.inc.php.

& Filter::getOutputType ( )

Get the output type

Returns
TypeDescription

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

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

& Filter::getRuntimeEnvironment ( )

Get the required runtime environment

Returns
RuntimeEnvironment

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

Filter::getSeq ( )

Get the sequence id

Returns
integer

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

References DataObject\getData().

Referenced by ParaciteRawCitationNlm30CitationSchemaFilter\process().

Filter::hasErrors ( )

Whether this filter has produced errors.

Returns
boolean

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

Filter::isCompatibleWithRuntimeEnvironment ( )

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

Returns
boolean

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

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

Referenced by execute().

& Filter::process ( $input)

This method performs the actual data processing. NB: sub-classes must implement this method.

Parameters
$inputmixed validated filter input data
Returns
mixed non-validated filter output or null if processing was not successful.

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

Referenced by execute().

Filter::setDisplayName (   $displayName)

Set the display name

Parameters
$displayNamestring

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

References DataObject\setData().

Referenced by CitationListTokenizerFilter\CitationListTokenizerFilter(), CompositeFilter\CompositeFilter(), CrossrefNlm30CitationSchemaFilter\CrossrefNlm30CitationSchemaFilter(), DateStringNormalizerFilter\DateStringNormalizerFilter(), MetadataDataObjectAdapter\MetadataDataObjectAdapter(), MetadataDescriptionDummyAdapter\MetadataDescriptionDummyAdapter(), Mods34DescriptionXmlFilter\Mods34DescriptionXmlFilter(), Nlm30CitationDemultiplexerFilter\Nlm30CitationDemultiplexerFilter(), Nlm30CitationSchemaAbntFilter\Nlm30CitationSchemaAbntFilter(), Nlm30CitationSchemaApaFilter\Nlm30CitationSchemaApaFilter(), Nlm30CitationSchemaMlaFilter\Nlm30CitationSchemaMlaFilter(), Nlm30CitationSchemaNlm30XmlFilter\Nlm30CitationSchemaNlm30XmlFilter(), Nlm30CitationSchemaOpenurl10CrosswalkFilter\Nlm30CitationSchemaOpenurl10CrosswalkFilter(), Nlm30CitationSchemaVancouverFilter\Nlm30CitationSchemaVancouverFilter(), Nlm30NameSchemaPersonStringFilter\Nlm30NameSchemaPersonStringFilter(), Openurl10Nlm30CitationSchemaCrosswalkFilter\Openurl10Nlm30CitationSchemaCrosswalkFilter(), PersonStringNlm30NameSchemaFilter\PersonStringNlm30NameSchemaFilter(), PKPSubmissionNlm30XmlFilter\PKPSubmissionNlm30XmlFilter(), PubmedNlm30CitationSchemaFilter\PubmedNlm30CitationSchemaFilter(), WorldcatNlm30CitationSchemaFilter\WorldcatNlm30CitationSchemaFilter(), and XSLTransformationFilter\XSLTransformationFilter().

Filter::setRuntimeEnvironment ( $runtimeEnvironment)

Set the required runtime environment

Parameters
$runtimeEnvironmentRuntimeEnvironment

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

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

Filter::setSeq (   $seq)

Set the sequence id

Parameters
$seqinteger

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

References DataObject\setData().

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 169 of file Filter.inc.php.

References TypeDescriptionFactory\getInstance().

Referenced by Filter().

Filter::supportedRuntimeEnvironmentSettings ( )

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

PHP4 workaround for missing static class members.

Returns
array

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

Referenced by isCompatibleWithRuntimeEnvironment(), and setRuntimeEnvironment().

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

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

References getInputType(), and getOutputType().

Referenced by execute(), and 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 365 of file Filter.inc.php.

References supports().

Referenced by execute().


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