.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Required to disable full justification in groff 1.23.0. .if n .ds AD l .\" ======================================================================== .\" .IX Title "DlfSchema 3pm" .TH DlfSchema 3pm 2025-09-28 "Lire 2.1.1" "LogReport's Lire Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Lire::DlfSchema \- Interface to Lire DLF Schema XML specifications .SH SYNOPSIS .IX Header "SYNOPSIS" In DLF converters: .PP .Vb 1 \& use Lire::DlfSchema; \& \& my $schema = Lire::DlfSchema::load_schema( "email" ); \& my $fields = $schema\->fields(); \& \& my $dlf_id = $schema\->field( \*(Aqdlf_id\*(Aq ); \& my $dlf_src = $schema\->field( \*(Aqdlf_source\*(Aq ); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module is the interface to the Lire DLF Schemas defined in XML files. A schema defines the order of the fields along with their names, descriptions and types. .PP Each DlfSchema have at least two predefined fields: .IP dlf_id 4 .IX Item "dlf_id" This is an integer which uniquely identify a DLF record in its stream. Its used to link the record to its extended schemas fields and also to link the record to the derived schemas records. .IP dlf_source 4 .IX Item "dlf_source" This is an identifier which can be used to track the record the ImportJob that created it. .SH "ACCESSING A SCHEMA OBJECT" .IX Header "ACCESSING A SCHEMA OBJECT" The way to access a schema for a superservice is through the \&\fBload_schema()\fR module function. You use it like this: .PP .Vb 1 \& my $schema = Lire::DlfSchema::load_schema( $superservice); .Ve .PP This function will return a schema object which can then be used to query information about the schema. This function will \fBdie()\fR on error. .ie n .SS "has_superservice( $superservice )" .el .SS "has_superservice( \f(CW$superservice\fP )" .IX Subsection "has_superservice( $superservice )" Returns true if there is superservice named \f(CW$schema_name\fR available. An error will be thrown if the schema name isn\*(Aqt valid for a superservice. .ie n .SS "has_schema( $schema_name )" .el .SS "has_schema( \f(CW$schema_name\fP )" .IX Subsection "has_schema( $schema_name )" Returns true if there is \f(CW$schema_name\fR available. An error will be thrown if the schema name isn\*(Aqt valid. .SS \fBsuperservices()\fP .IX Subsection "superservices()" Returns the name of the available superservices in an array. .SS \fBschemas()\fP .IX Subsection "schemas()" Returns the name of the available schemas in an array. .SH "SCHEMA OBJECT METHODS" .IX Header "SCHEMA OBJECT METHODS" .SS \fBid()\fP .IX Subsection "id()" .Vb 1 \& my $id = $schema\->id(); .Ve .PP This method will return the id of the schema. This will be the superservice\*(Aqs name for superservice\*(Aqs main schema. (There are other types of schemas (derived and extended schemas) for which the id will be different than the superservice\*(Aqs name.) .SS \fBsuperservice()\fP .IX Subsection "superservice()" .Vb 1 \& my $super = $schema\->superservice(); .Ve .PP This method will return the superservice\*(Aqs name of the schema. .SS "title( [$new_title] )" .IX Subsection "title( [$new_title] )" This method will return (or change) the human readable title of the schema. (This is the content of the title element in the XML specification.) .SS "description( [$new_description] )" .IX Subsection "description( [$new_description] )" This method will return (or change) the description of the schema. (This is the content of the description element in the XML specification.) Be aware that this will most likely contain DocBook markup. .SS \fBfield_by_pos()\fP .IX Subsection "field_by_pos()" .Vb 1 \& my $field = $schema\->field_by_pos( 0 ); .Ve .PP This method takes an integer as parameter and return the field at that position in the schema. Fields are indexed starting at 0. This method will \fBdie()\fR if an invalid position is passed as parameter. .PP The method returns a \fBLire::Field\fR\|(3pm) object. .ie n .SS "add_field( $field )" .el .SS "add_field( \f(CW$field\fP )" .IX Subsection "add_field( $field )" Adds the Lire::Field \f(CW$field\fR to this schema. .SS \fBhas_field()\fP .IX Subsection "has_field()" .Vb 3 \& if ( $schema\->has_field( \*(Aqtest ) ) { \& print "schema has field \*(Aqtest\*(Aq\en"; \& } .Ve .PP This method takes a string as parameter and returns a boolean value. That value will be true if there is a field in the schema with that name, it will be false otherwise. .SS \fBfield()\fP .IX Subsection "field()" .Vb 1 \& my $field = $schema\->field( \*(Aqfrom_email\*(Aq ); .Ve .PP This method takes a field\*(Aqs name as parameter and returns the \&\fBLire::Field\fR\|(3pm) object describing that field in the schema. The method will \fBdie()\fR if there is no field with that name in the schema. .SS \fBfields()\fP .IX Subsection "fields()" .Vb 2 \& my $fields = $schema\->fields(); \& my @fields = $schema\->fields(); .Ve .PP In array context, this method will return an array containing all the fields (as \fBLire::Field\fR\|(3pm) objects) in the schema. The order of the fields in the array is the order of the fields in the schema. .PP In scalar context, it will return an array reference. This method is more efficient than creating an array. DO NOT MODIFY THE RETURNED ARRAY. .SS \fBfield_names()\fP .IX Subsection "field_names()" Returns the name of the fields in this schema. The names are in the same order than the fields. .SS \fBfield_count()\fP .IX Subsection "field_count()" .Vb 1 \& my $number_of_field = $schema\->field_count; .Ve .PP This method returns the number of fields in the schema. .SS \fBtimestamp_field()\fP .IX Subsection "timestamp_field()" .Vb 1 \& my $time_field = $schema\->timestamp_field; .Ve .PP This method will return the \fBLire::Field\fR\|(3pm) object representing the timestamp field in the schema. The timestamp field is the one that defines the sort order of the DLF records. .SS \fBis_schema_compatible()\fP .IX Subsection "is_schema_compatible()" .Vb 1 \& if ( $schema\->is_schema_compatible( $other_schema ) ) { \& \& } .Ve .PP This method takes a \fBLire::DlfSchema\fR\|(3pm) object as parameter and returns a boolean value. That value will be true if the schema passed as parameter is compatible with the other, it will be false otherwise. .PP For a superservice\*(Aqs schema, the only compatible schema is an object representing the same superservice\*(Aqs schema. .ie n .SS "can_join_schema( $schema )" .el .SS "can_join_schema( \f(CW$schema\fP )" .IX Subsection "can_join_schema( $schema )" Returns true if \f(CW$schema\fR can be joined with this schema. For a DlfSchema, this will be true only when \f(CW$schema\fR is an ExtendedSchema of this schema. .SH "SQL Related Methods" .IX Header "SQL Related Methods" These methods are used to map DLF record into SQL tables. .SS \fBsql_table()\fP .IX Subsection "sql_table()" Returns the SQL table used to hold the DLF records of this schema. .ie n .SS "create_sql_schema( $dlf_store, [ $remove ] )" .el .SS "create_sql_schema( \f(CW$dlf_store\fP, [ \f(CW$remove\fP ] )" .IX Subsection "create_sql_schema( $dlf_store, [ $remove ] )" This will create the SQL schemas necessary to hold the DLF records for this schema in the Lire::DlfStore. If \f(CW$remove\fR is true, a DROP TABLE will be done before creating the schema. .ie n .SS "needs_sql_schema_migration( $dlf_store )" .el .SS "needs_sql_schema_migration( \f(CW$dlf_store\fP )" .IX Subsection "needs_sql_schema_migration( $dlf_store )" This method will return true if the SQL schema isn\*(Aqt up\-to\-date in the DlfStore. The method \fBmigrate_sql_schema()\fR can be used to bring the schema up to date. .ie n .SS "migrate_sql_schema( $dlf_store )" .el .SS "migrate_sql_schema( \f(CW$dlf_store\fP )" .IX Subsection "migrate_sql_schema( $dlf_store )" Updates the SQL schemas to the current version. .ie n .SS "dlf_query( $sort_spec )" .el .SS "dlf_query( \f(CW$sort_spec\fP )" .IX Subsection "dlf_query( $sort_spec )" Returns a Lire::DlfQuery object which can be use to return all DLF records sorted according to \f(CW$sort_spec\fR. Sort spec is a white\-space delimited list of sort field names. They must be present in the current schema. If the field\*(Aqs name is prefixed by \*(Aq\-\*(Aq, descending sort order will be used. .SS \fBinsert_sql_query()\fP .IX Subsection "insert_sql_query()" Returns the INSERT SQL statement that should be used to insert DLF records in the stream. A DBI::st handle prepared with that query needs to be passed as parameter to \fBexecute_insert_query()\fR. .ie n .SS "sql_clean_query( $with_time )" .el .SS "sql_clean_query( \f(CW$with_time\fP )" .IX Subsection "sql_clean_query( $with_time )" Returns the DELETE statement that can be use to delete the DLF records in this schema. If \f(CW$with_time\fR is true, the query can be use for selective cleaning. One bind timestamp parameter should be passed when the query is executed and all records which are older than this timestamp will be deleted. .SS \fBsql_clean_period_query()\fP .IX Subsection "sql_clean_period_query()" Returns the DELETE statement that can be use to delete the DLF records in this schema. The query should be passed two bind parameters. These parameters will be the time boundaries between which records should be deleted from the schema. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBLire::Field\fR\|(3pm), \fBLire::ExtendedSchema\fR\|(3pm), \fBLire::DlfConverter\fR\|(3pm), \&\fBLire::DerivedSchema\fR\|(3pm) .SH AUTHOR .IX Header "AUTHOR" .Vb 1 \& Francis J. Lacoste .Ve .SH VERSION .IX Header "VERSION" \&\f(CW$Id:\fR DlfSchema.pm,v 1.58 2006/07/23 13:16:28 vanbaal Exp $ .SH COPYRIGHT .IX Header "COPYRIGHT" Copyright (C) 2001, 2002, 2004 Stichting LogReport Foundation LogReport@LogReport.org .PP This file is part of Lire. .PP Lire 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; either version 2 of the License, or (at your option) any later version. .PP This program 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. .PP You should have received a copy of the GNU General Public License along with this program (see COPYING); if not, check with http://www.gnu.org/copyleft/gpl.html.