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

📄 input.pm

📁 普通的ETL工具
💻 PM
字号:
# vim:ts=4 sw=4
# ----------------------------------------------------------------------------------------------------
#  Name		: ETL::Pequel3::Type::Section::Input.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::Input;
require 5.005_62;
use strict;
use warnings;
use ETL::Pequel3::Type::Section;
# ----------------------------------------------------------------------------------------------------
{
	package ETL::Pequel3::Type::Section::Input;
	use base qw(ETL::Pequel3::Type::Section::Abstract);
	use Class::STL::ClassMembers
		qw( 
			input_dataset
			input_fields 
		),
		Class::STL::ClassMembers::DataMember->new(name => 'target_mem_name', default => 'section_name'),
		Class::STL::ClassMembers::DataMember->new(name => 'section_name', default => 'input'),
		Class::STL::ClassMembers::DataMember->new(name => 'required', default => 1),
		Class::STL::ClassMembers::DataMember->new(name => 'item_type', default => 'ETL::Pequel3::Type::Section::Input::Item'),
		Class::STL::ClassMembers::DataMember->new(name => 'element_type', default => "@{[ __PACKAGE__ ]}"),
		Class::STL::ClassMembers::DataMember->new(name => 'description', default => "The I<input> section defines the format of the input data stream record -- each I<item> entry defines one field within the record. Any derived (calculated) fields must be placed after the last input field. The calculation expression can consist of (almost) any valid Perl statement, and can include references to other input field names. All macros are also available to calculation expressions. Each input field name must be unique.\n\n\nF<Transparent Field>\n\nA prefix of C<_> in the input field name causes that field to be I<transparent>; transparent fields will not be transfered to the output when the F<transfer> option is used.");
	use Class::STL::ClassMembers::Constructor;
	sub new_extra
	{
		my $self = shift;
		$self->input_fields($self->pequel_ref()->catalogue()->fieldsets()->input_fields()->new(
			pequel_ref => $self->pequel_ref()))
		if (defined($self->pequel_ref()));
		$self->attributes()->push_back(
			ETL::Pequel3::Type::Properties::DataSetSpec->new(), 
			ETL::Pequel3::Type::Properties::Transfer->new(),
		);
		return $self;
	}
	sub setup
	{
		my $self = shift;
		$self->select(); # create default input;
	}
	sub prepare
	{
		my $self = shift;
		$self->input_dataset($self->pequel_ref()->factories()->input_datasets()->factory(
			dataset_spec => $self->attributes()->dataset_spec(), 
			input_fields => $self->input_fields(),
			pequel_ref => $self->pequel_ref(),
		));

#?		return unless $self->user()->size();

#?		$self->err()->user_error(10221, "[@{[ 
#?			$self->pequel_ref()->script_filename() ]}] Empty input section not allowed!")
#?			if (
#?				$self->items()->size() == 0 
#?				&& $self->input_dataset()->datasource()->datasource_name() ne 'pequel'
#?				&& !$self->pequel_ref()->isa('ETL::Pequel3::User::TableLoader')
#?			);

		$self->input_fields()->dataset($self->input_dataset());
		$self->input_fields()->clear();
		$self->input_fields()->map_input($self->items());
		$self->input_dataset()->map_output(main => $self->pequel_ref());
		return $self;
	}
	sub parse
	{
		my $self = shift;
		foreach (grep(defined($_->calc_exp()), $self->input_fields()->to_array())) {
			$_->calc_exp_raw($self->pequel_ref()->parser_input()->used_by($_)->translate($_->calc_exp())->raw());
		}
	}
	package ETL::Pequel3::Type::Section::Input::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::PequelType->new(required => 0),
			ETL::Pequel3::Type::Properties::FieldName->new(required => 1),
			$self->attributes()->factory(name => 'operator'),
#>			$self->attributes()->factory(name => 'calc_exp', xml_type => 'CDATA'),
			$self->attributes()->factory(name => 'calc_exp', CDATA => 1),
#>			$self->attributes()->factory(name => 'data_xml_type', default => 'PCDATA', validate => '^(attr|PCDATA|CDATA)$'),
			$self->attributes()->factory(name => 'xml_type', default => 'PCDATA', validate => '^(attr|PCDATA|CDATA)$'),
		);
	}
}
# ----------------------------------------------------------------------------------------------------
1;

⌨️ 快捷键说明

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