⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fieldprocess.pm

📁 普通的ETL工具
💻 PM
字号:
# vim:ts=4 sw=4
# ----------------------------------------------------------------------------------------------------
#  Name		: ETL::Pequel3::Type::Section::FieldProcess.pm
#  Created	: 22 June 2006
#  Author	: Mario Gaffiero (gaffie)
#
# Copyright 1999-2007 Mario Gaffiero.
# 
# This file is part of Pequel(TM).
# 
# Pequel is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
# 
# Pequel is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with Pequel; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
# ----------------------------------------------------------------------------------------------------
# Modification History
# When          Version     Who     What
# ----------------------------------------------------------------------------------------------------
package ETL::Pequel3::Type::Section::FieldProcess;
require 5.005_62;
use strict;
use warnings;
use ETL::Pequel3::Type::Section;
# ----------------------------------------------------------------------------------------------------
{
	package ETL::Pequel3::Type::Section::FieldProcess::Abstract;
	use base qw(ETL::Pequel3::Type::Section::Abstract);
	use Class::STL::ClassMembers qw( fields ),
		Class::STL::ClassMembers::DataMember->new(name => 'target_mem_name', default => 'section_name'),
		Class::STL::ClassMembers::DataMember->new(name => 'item_type', default => 'ETL::Pequel3::Type::Section::FieldProcess::Item'),
		Class::STL::ClassMembers::DataMember->new(name => 'element_type', default => "@{[ __PACKAGE__ ]}");
	use Class::STL::ClassMembers::Constructor;
	sub new_extra
	{
		my $self = shift;
		$self->fields($self->pequel_ref()->catalogue()->fieldsets()->process_fields()->new(
			pequel_ref => $self->pequel_ref()))
		if (defined($self->pequel_ref()));
	}

	package ETL::Pequel3::Type::Section::FieldProcess::Item;
	use base qw(ETL::Pequel3::Type::Section::Item::Abstract);
	use Class::STL::ClassMembers;
	use Class::STL::ClassMembers::Constructor;
	sub new_extra
	{
		my $self = shift;
		$self->attributes()->push_back(
			ETL::Pequel3::Type::Properties::FieldName->new(required => 1),
			$self->attributes()->factory(name => 'operator', default => '='),
			$self->attributes()->factory(name => 'calc_exp', required => 1)
		);
	}
}
# ----------------------------------------------------------------------------------------------------
{
	package ETL::Pequel3::Type::Section::FieldProcess;
	use base qw(ETL::Pequel3::Type::Section::FieldProcess::Abstract);
	use Class::STL::ClassMembers
		Class::STL::ClassMembers::DataMember->new(name => 'section_name', default => 'field_process'),
		Class::STL::ClassMembers::DataMember->new(name => 'element_type', default => "@{[ __PACKAGE__ ]}"),
		Class::STL::ClassMembers::DataMember->new(name => 'description', default => 'Use this section to perform additional formatting/processing on input/output fields. Please refer to the specific F<field_process_on_input> and F<field_process_on_output> section type descriptions for detailed information.');
	use Class::STL::ClassMembers::Constructor;
	sub new_extra
	{
		my $self = shift;
		$self->attributes()->push_back(
			ETL::Pequel3::Type::Properties::On->new(),
		);
		return $self;
	}
	sub select
	{
		my $self = shift;
		my %p = @_;
		$self->err()->user_error(10211, "Section '@{[ 
			$self->section_name() ]}' select() function requires 'on' parameter!")
			unless (exists($p{on}));
		return $self->pequel_ref()->section("@{[ $self->section_name() ]}_on_@{[ lc($p{on}) ]}")->select(@_);
	}
}
# ----------------------------------------------------------------------------------------------------
{
	package ETL::Pequel3::Type::Section::FieldProcessOnInput;
	use base qw(ETL::Pequel3::Type::Section::FieldProcess::Abstract);
	use Class::STL::ClassMembers
		Class::STL::ClassMembers::DataMember->new(name => 'section_name', default => 'field_process_on_input'),
		Class::STL::ClassMembers::DataMember->new(name => 'element_type', default => "@{[ __PACKAGE__ ]}"),
		Class::STL::ClassMembers::DataMember->new(name => 'description', default => 'Use this section to perform additional formatting/processing on input fields. These statements will be performed after the input record is read and right after the input derived fields have been calculated. The same target input field may appear repeatedly. To perform a regular expression substitution operation specify B<=~> for the I<operator>.');
	use Class::STL::ClassMembers::Constructor;
	sub prepare
	{
		my $self = shift;
		$self->SUPER::prepare(@_);
		$self->fields()->map_input($self->items(), $self->pequel_ref()->input()->input_fields());
	}
	sub parse
	{
		my $self = shift;
		foreach ($self->fields()->to_array()) {
			$_->calc_exp_raw($self->pequel_ref()->parser_input()->used_by($_)->translate($_->calc_exp())->raw());
		}
	}
}
# ----------------------------------------------------------------------------------------------------
{
	package ETL::Pequel3::Type::Section::FieldProcessOnOutput;
	use base qw(ETL::Pequel3::Type::Section::FieldProcess::Abstract);
	use Class::STL::ClassMembers
		Class::STL::ClassMembers::DataMember->new(name => 'section_name', default => 'field_process_on_output'),
		Class::STL::ClassMembers::DataMember->new(name => 'element_type', default => "@{[ __PACKAGE__ ]}"),
		Class::STL::ClassMembers::DataMember->new(name => 'description', default => 'Use this section to perform additional formatting/processing on output fields. These statements will be performed after the I<dedup_on_output> section and before the I<reject_output_record> section. The same target output field may appear repeatedly. To perform a regular expression substitution operation specify B<=~> for the I<operator>.');
	use Class::STL::ClassMembers::Constructor;
	sub prepare
	{
		my $self = shift;
		$self->SUPER::prepare(@_);
		$self->fields()->map_output($self->items(), $self->pequel_ref()->output()->output_fields());
	}
	sub parse
	{
		my $self = shift;
		foreach ($self->fields()->to_array()) {
			$_->calc_exp_raw($self->pequel_ref()->parser_output()->used_by($_)->translate($_->calc_exp())->raw());
		}
	}
}
# ----------------------------------------------------------------------------------------------------
1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -