承接 hab/picarecord 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hab/picarecord

Composer 安装命令:

composer require hab/picarecord

包简介

Object oriented interface to Pica+ records, fields, and subfields

README 文档

README

[![Build Status](https://travis-ci.org/dmj/PicaRecord.svg?branch=master)](https://travis-ci.org/dmj/PicaRecord)

About

PicaRecord provides an object oriented interface to Pica+ records, fields, and subfields. It does not provide the means to read or write Pica+ records. In order to do so you need to install the packages PicaReader and PicaWriter that are available as dedicated composer packages.

PicaRecord is copyright (c) 2012-2019 by Herzog August Bibliothek Wolfenbüttel and released under the terms of the GNU General Public License v3.

Installation

You can install PicaRecord via Composer.

composer require hab/picarecord

Usage

Records, Fields, and Subfields

Subfields

Subfields are represented by the Subfield class. A Pica+ subfield is a cons (pair) of an alphanumeric case-sensitive ASCII character and a non-empty string value. The code of a subfield is considered to be immutable and the value must not be the empty string.

Fields

Field are represented by the Field class. A Pica+ field is an ordered list of subfields and partially identified[1] by two properties, the field tag and the field occurrence. Both properties are set on instantiation and considered to be immutable.

In the following text the field shorthand refers to a string consisting of the field tag, followed by a forward slash (ASCII 47) followed by two digits denoting the field occurrence. For example the field shorthand of the field 021A with an occurrence of 0 is 021A/00.

Retrieving subfields

Field::getSubfields() returns all subfields of a field when called with no arguments. To retrieve specific subfields you can pass an arbitrary number of arguments each representing a subfield code. If you do so the returned array will be constructed as follows:

Each element of the returned array corresponds to a subfield code in the argument list. If the field has a subfield with the specified code the element of the returned array contains the subfield. If the field does not have a subfield with the specified code the element of the returned array contains NULL. In order to retrieve multiple subfields with the same subfield code you need to repeat the subfield code in the argument list. The first occurrence of the code in the argument list refers to the first subfield with the specified code, the second occurrence to the second subfield and so on.

Because Field::getSubfields() when called with subfield codes as arguments returns an array with a known size (as much elements as arguments were passed to the function) you can conveniently use PHP’s list() operation.

Example: To retrieve the first and last name of the author encoded in the Pica+ field 028A/00 you can call Field::getSubfields() as follows:

list($firstName, $lastName, $personalName) = $field->getSubfields('d', 'a', '5');

Manipulating the subfield list

You can use Field::addSubfield() to add a field to the end of the subfield list. If the subfield is already part of the subfield list an InvalidArgumentException is thrown. For more sophisticated manipulations of a field’s subfield list you can use Field::setSubfields() to replace the subfield list of a field.

A subfield can be deleted using Field::removeSubfield() which takes the subfield to delete as sole argument and throws an InvalidArgumentException if the field does not contain the subfield.

Records

Record classes

PicaRecord provides classes for the four record types of title records, authority records, local records, and copy records. The relationship of title, local, and copy records is as follows: A title record may contain zero or more local records. Each local record may contain up to 99 copy records.

Local records can be identified by the internal library number (ILN) of the library they belong to and retrieved either by TitleRecord::getLocalRecord(), which returns an array of all local records, or TitleRecord::getLocalRecordByILN() which retrieves a single local record identifed by its first argument.

Copy records hold information about particular items (exemplars) and are identified by the number of the item in the local record. You can use LocalRecord::getCopyRecords() or LocalRecord::getLocalRecordByItemNumber() to retrieve an array with all copy records or a single copy record with a specified item number respectively.

All record classes implement the two methods Record::isEmpty() which returns TRUE if a record is empty (does not contain any fields) and Record::isValid() which performs a preliminary validation of the record.

Selecting and deleting fields

Record::getFields() returns all fields of the record when called without arguments. If you call it with the body of a regular expression as argument it will only return the fields whose shorthand is matched by the regular expression.

Record::select() provides a more generic access to a record’s fields. It takes a predicate function as argument and returns all fields that fullfill the predicate. A predicate function can be any valid PHP callback that takes a Field as argument and return TRUE if the field fullfills the predicate or otherwise FALSE.

Record::delete() deletes all fields that match a predicate function (see above).

If a record contains other records, i.e. if a record is a title or local record, Record::delete(), Record::select(), and Record::getFields() operate on all fields of the record, including the fields of the contained records.

Appending fields to a record

Append fields to an existing record is not as straightforward as selecting or deleting fields. Each record class has its own restrictions when it comes to appending a field to it via the Record::append() function:

  • you can only append fields with a level of 0 to title and authority records
  • you can append fields with a level of 1 to local records
  • you can only append fields with a level of 2 to copy records; as an additional restriction the occurrence value of the field must be equal to the item number of the copy record
Record classAllowed field level in append()
TitleRecordLevel 0
AuthorityRecordLevel 0
LocalRecordLevel 1
CopyRecordLevel 2

The attempt to add a field with a different level then the allowed level results in an InvalidArgumentException to be thrown.

Acknowledgments

Large parts of this package would not have been possible without studying the source of Pica::Record, an open source Perl library for handling Pica+ records by Jakob Voß, and the practical knowledge of our library’s catalogers.

Footnotes

[1] E.g. a title record may contain zero or more fields with tag 101@ and occurrence 00; fields with this shorthand indicate the start of a local record.

hab/picarecord 适用场景与选型建议

hab/picarecord 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.25k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 08 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 hab/picarecord 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hab/picarecord 我们能提供哪些服务?
定制开发 / 二次开发

基于 hab/picarecord 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 4.25k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 15
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2015-08-07