Módulo:MARCimporter: mudanças entre as edições

Conteúdo deletado Conteúdo adicionado
Sem resumo de edição
fix formOfItem
 
(10 revisões intermediárias pelo mesmo usuário não estão sendo mostradas)
Linha 3:
-- um handler para registros em "MARC tags", uma configuração para registros
-- bibliográficos e uma configuração para registros de autoridade.
function p.record( frame )
-- recebe o registro, o terceiro argumento da Predefinição:MARCimporter
local record = frame.args[3] or ''
-- recebe o modo de normalização Unicode ("Sim" para ativar o modo NFD)
local isNFD = frame.args[2] or ''
-- inicializa as variáveis básicas do registro
local leader = ''
local baseAddressOfData = 0
local directory = 0''
local dataValuesGroup = ''
-- inicializa as variáveis auxiliares
local directoryEntry = 0''
local entryTag = 0''
local entryDataLength = 0''
local entryInitPosition = 0''
local dataField = {} -- Cada tabela que contém os dados dos campos. Formato:
-- { tag='', length='', initPosition='', data='', ind1='', ind2='' }
local dataFields = {} -- Tabela que contém cada tabela dataField. Formato:
-- { 1={}, 2={}, 3={}, 4={}, n={} }
local controlField001 = ''
local controlField003 = ''
local controlField006 = ''
local controlField007 = ''
local controlField008 = ''
local tag040 = ''
local firstTemplate = ''
local fieldTemplates = ''
local lastTemplate = '{{EndOfRecord}}</pre>'
local queryString = ''
local fieldQueryString = ''
local formLink = ''
local function normalizeData( data )
data = data
:gsub( '|(.)', ' $%1 ' ) -- substitui "|a" por " $a "
:gsub( '(%d)p%.', '%1 p.' ) -- // "1p." por "1 p."
:gsub( '(%d)cm', '%1 cm' ) -- // "1cm" por "1 cm"
:gsub( '(%d)ed%.', '%1 ed.' ) -- // "1ed." por "1 ed."
:gsub( '%.%s?%-$', '.' ) -- // ". -" por "."
:gsub( '(%$.*)(%$w.*)', '%2 %1' ) -- move o subcampo $w para a frente
:gsub( '(%s%$9%s.*)', '' ) -- remove o subcampo $9
:gsub( '(%$z.*)(%$u.*)', '%2 %1' ) -- move o subcampo $u para a frente
:gsub( '[\n\r]', '') -- remove line feed e carriage return
return data
end
if record:match( '^%d%d%d%d' )
then
-- == MARC ISO 2709 handler == --
-- O MediaWiki substitui caracteres de controle (RS, US, GS) pelo
-- caractere de "desconhecido" (losango com interrogação) e, aqui,
-- substituo esse caractere por um pipe (é necessário substituir
-- por um caractere da faixa ASCII).
record = record:gsub( '�', '|' )
-- verifica se a forma de normalização Unicode é a
-- Normalization Form Canonical Decomposition (NFD)
if isNFD == 'Sim'
then
record = mw.ustring.toNFD( record )
end
-- configuração das variáveis básicas do registro (via ISO 2709):
-- obtém o líder
leader = record:sub( 1, 24 ) or ''
--> 00898nam a2200277 a 4500
-- obtém o endereço base dos dados
baseAddressOfData = tonumber( leader:sub( 13, 17 ) ) or 0
--> 00277
-- obtém o diretório (-1 para não pegar RS)
directory = record:sub( 25, baseAddressOfData - 1 ) or 0''
--> 0010010000000050017000100080041000270200027000680400017000950...
-- obtém os dados dos campos em um único grupo
dataValuesGroup = record:sub( baseAddressOfData + 1 ) or ''
--> 278 até o final do registro
-- enquanto o tamanho do diretório for maior que 0...
while #directory > 0
do
directoryEntry = directory:sub( 1, 12 ) -- 245008100177
entryTag = directoryEntry:sub( 1, 3 ) -- 245
entryDataLength = directoryEntry:sub( 4, 7 ) -- 0081
entryInitPosition = directoryEntry:sub( 8, 12 ) -- 00177
-- cria uma tabela com os dados...
dataField = {
tag = entryTag,
length = entryDataLength,
initPosition = entryInitPosition
}
}
-- e insere cada tabela dataField na tabela dataFields
table.insert( dataFields, dataField )
-- esvazia o diretório de 12 em 12
directory = directory:sub( 13 )
end
-- para cada item da tabela dataFields...
for index, dataField in ipairs( dataFields )
do
-- configura as variáveis para uso na função string.sub( i, j )
-- (+1 porque em Lua se começa do 1, não do 0)
local i = dataFields[index].initPosition + 1
-- (-1 para não pegar RS)
local j = dataFields[index].initPosition + dataFields[index].length - 1
-- localiza o dado em dataValuesGroup, normaliza o dado
-- e armazena na tabela
dataFields[index].data = normalizeData( dataValuesGroup:sub( i, j ) )
-- armazena os campos de controle (00X) para posterior decomposição
if dataFields[index].tag == '006'
then
controlField006 = dataFields[index].data:gsub( '[|#$]', ' ' )
end
if dataFields[index].tag == '007'
then
controlField007 = dataFields[index].data:gsub( '[|#$\r]', ' ' )
end
if dataFields[index].tag == '008'
then
controlField008 = dataFields[index].data:gsub( '[|#$-]', ' ' )
end
end
else
-- == MARC tags handler == --
record = record
:gsub( ' ', ' ' ) -- LC bib handling (\t+\s)
:gsub( ' ', ' ' ) -- LC aut handling (\t)
:gsub( '    ', ' ' ) -- Pergamum handling (control fields) (non-breaking space)
:gsub( ' ', ' ' ) -- Pergamum handling (data fields) (non-breaking space)
record = record .. '\n'
if record:match( '^FMT' ) or record:match( '^LDR' ) -- Aleph handling
then
record = record:gsub( '\t', ' ' ) -- 1
:gsub( '^(FMT%s[A-Z].-\n)', '' ) -- 2
:gsub( 'LDR%s([0%s][0%s][0%s][0%s][0%s].-\n)', '000 %1' ) -- 3
:gsub( '\n(%d%d%d)%s(%$.%s)', '\n%1 %2' ) -- 4
:gsub( '\n(%d%d%d)(%d)', '\n%1 %2' ) -- 5
:gsub( '\n(%d%d%d%s%d%s)', '\n%1 ' ) -- 6 (manter essa ordem)
end
-- configuração das variáveis básicas do registro (via MARC tags):
-- obtém o líder
leader = record:match( '^000%s([%d%s][%d%s][%d%s][%d%s][%d%s].-)\n' ) or ''
leader = leader:gsub( '[|#$]', ' ' )
-- obtém os campos de controle
controlField001 = record:match( '\n001%s(.-)\n' ) or ''
controlField003 = record:match( '\n003%s(.-)\n' ) or ''
controlField003 = mw.text.trim(controlField003)
controlField006 = record:match( '\n006%s([a-z].-)\n' ) or ''
controlField006 = controlField006record:gsubmatch( '\n006%s([|#$a-z].-)\n',) 'or ' )'
controlField006 = controlField006:gsub('[|#$]', ' ')
controlField007 = record:match( '\n007%s([a-z].-)\n' ) or ''
controlField007 = controlField007record:gsubmatch( '[|#$\rn007%s([a-z].-)\n',) 'or ' )'
controlField007 = controlField007:gsub('[|#$\r]', ' ')
controlField008 = record:match( '008%s([%d%s][%d%s][%d%s][%d%s][%d%s][%d%s].-)\n' ) or ''
controlField008 = controlField008record:gsubmatch( '008%s([|#$-%d%s][%d%s][%d%s][%d%s][%d%s][%d%s].-)\n',) 'or ' )'
controlField008 = controlField008:gsub('[|#$-]', ' ')
-- para cada linha do registro, identifica o campo e seu conteúdo
-- para cada linha do registro, identifica o campo e seu conteúdo
-- (o conteúdo inclui os indicadores)
-- (o conteúdo inclui os indicadores)
for tagMatch, dataMatch in record:gmatch(
for tagMatch, dataMatch in record:gmatch(
'([0-8]%d%d) ([0-9_%s][0-9_%s] [$|].-)\n' )
'([0-8]%d%d) ([0-9_%s][0-9_%s] [$|].-)\n')
do
do
-- transforma o dado para o formato igual ao manipulado pelo
-- transforma o dado para o formato igual ao manipulado pelo
-- MARC ISO 2709 handler
-- MARC ISO 2709 handler
dataMatch = dataMatch:gsub( '%s?|(.)%s', '|%1' )
dataMatch = dataMatch:gsub('%s?|(.)%s', '|%1')
-- normaliza o dado
-- normaliza o dado
dataMatch = normalizeData(dataMatch)
dataMatch = normalizeData(dataMatch)
 
-- cria uma tabela com os dados...
dataField = {
tag = tagMatch,
data = dataMatch
}
}
-- e insere cada tabela dataField na tabela dataFields
table.insert( dataFields, dataField )
end
end
-- == Handler unificado == --
if leader:sub( 7, 7 ) == 'z' and (controlField003:lower():match( 'br') or controlField003:lower():match('br-rjbn'))
then
-- cria uma tabela com os dados...
dataField = {
tag = '670',
data = '## $a CA-BN ' .. os.date( '%Y' )
}
}
-- e insere a tabela dataField na tabela dataFields
table.insert( dataFields, dataField )
-- também mova o número de controle para o campo 035
dataField = {
tag = '035',
data = '## $a ' .. '(' .. controlField003 .. ')' .. controlField001
}
}
table.insert( dataFields, dataField )
end
-- função de ordenação dos campos
local function sortByTag ( a, b )
if ( a.tag < b.tag )
then
return true
elseif ( a.tag > b.tag )
then
return false
else
return a.originalOrder < b.originalOrder
end
end
-- para cada item da tabela dataFields...
for index, dataField in ipairs( dataFields )
do
-- verifica se a tag é a 040
if dataFields[index].tag == '040'
-- se for, adiciona o subcampo para a agência modificadora do registro
-- e marca como verdadeiro a presença deste campo
then
dataFields[index].data = dataFields[index].data .. ' $d BR-FlWIK'
tag040 = dataFields[index].data
end
-- verifica se a tag é uma das seguintes
if dataFields[index].tag == '092' or dataFields[index].tag == '595'
then
-- se for, exclua da tabela dataFields
table.remove( dataFields, index )
end
end
-- se o registro for da LC
-- se não há campo 040, então será criado agora
if leader:sub(7, 7) == 'z' and tag040:match('a DLC')
if tag040 == ''
then
-- cria uma tabela com os dados...
dataField = {
tag = '040670',
data = '## $a BRCA-FlWIKLC $b' por.. $c BR-FlWIKos.date('%Y')
}
}
-- e insere a tabela dataField na tabela dataFields
table.insert( dataFields, dataField )
end
-- se não há campo 040, então será criado agora
if leader:sub( 7, 7 ) == 'z' and tag040:match( 'a DLC' )
if tag040 == ''
then
then
-- cria uma tabela com os dados...
-- cria uma tabela com os dados...
dataField = {
dataField = {
tag = '670',
data = '## $a CA-LC ' ..tag os.date(= '%Y040' ),
data = '## $a BR-FlWIK $b por $c BR-FlWIK'
}
}
-- e insere a tabela dataField na tabela dataFields
-- e insere a tabela dataField na tabela dataFields
table.insert( dataFields, dataField )
table.insert(dataFields, dataField)
end
end
for index, dataField in ipairs( dataFields )
for index, dataField in ipairs(dataFields)
do
do
-- guarda a ordem original do campo para posterior inclusão de outros
-- campos (mantendoguarda a ordem original) do campo para posterior inclusão de outros
-- campos (mantendo a ordem original)
dataFields[index].originalOrder = index
dataFields[index].originalOrder = index
end
end
-- ordena os campos do registro
-- ordena os campos do registro
table.sort( dataFields, sortByTag )
for index, dataField in ipairstable.sort( dataFields, sortByTag)
for index, dataField in ipairs(dataFields)
do
do
-- se os campos forem maior que 009, então gerarão indicadores
-- se os campos forem maior que 009, então gerarão indicadores
if tonumber( dataFields[index].tag ) > 9
if tonumber(dataFields[index].tag) > 9
then
then
dataFields[index].ind1 =
dataFields[index].ind1 =
dataFields[index].data:sub( 1, 1 ):gsub( '[ _]', '#' )
dataFields[index].ind2data:sub(1, 1):gsub('[ _]', ='#')
dataFields[index].ind2 =
dataFields[index].data:sub( 2, 2 ):gsub( '[ _]', '#' )
dataFields[index].data:sub(2, 2):gsub('[ _]', '#')
end
end
-- se, também, os campos estiverem entre 010 e 830 (com exceção para 856),
-- se, também, os campos estiverem entre 010 e 830 (com exceção para 856),
-- criará a query string do link para o formulário e a sintaxe da
-- criará a query string do link para o formulário e a sintaxe da
-- Predefinição Field
-- Predefinição Field
if
if
tonumber( dataFields[index].tag ) == 10 or
tonumber( dataFields[index].tag ) >== 1210 andor
tonumber( dataFields[index].tag ) <> 83112 orand
tonumber( dataFields[index].tag ) ==< 831 856or
tonumber(dataFields[index].tag) == 856
then
then
-- query string maker (part 2), Predefinição Field
-- query string maker (part 2), Predefinição Field
fieldQueryString = fieldQueryString ..
fieldQueryString = fieldQueryString ..
'&Field[' .. index .. '][tag]=' .. dataField.tag ..
'&Field[' .. index .. '][ind1tag]=' .. dataField.ind1tag ..
'&Field[' .. index .. '][ind2ind1]=' .. dataField.ind2ind1 ..
'&Field[' .. index .. '][dataind2]=' .. mw.uri.encode( dataField.data:sub(ind2 4 ), 'PATH' )..
'&Field[' .. index .. '][data]=' .. mw.uri.encode(dataField.data:sub(4), 'PATH')
-- template string maker (part 2), Predefinição Field
-- template string maker (part 2), Predefinição Field
fieldTemplates = fieldTemplates .. '{{Field' ..
fieldTemplates = fieldTemplates .. '{{Field' ..
'\n|tag=' .. dataField.tag ..
'\n|ind1tag=' .. dataField.ind1tag ..
'\n|ind2ind1=' .. dataField.ind2ind1 ..
'\n|dataind2=' .. dataField.data:sub( 4 )ind2 ..
'\n|data=' .. dataField.data:sub(4) ..
'\n}}\n'
'\n}}\n'
end
end
end
if frame.args[1] == 'bib' or frame.args[1] == ''
if frame.args[1] == 'bib' or frame.args[1] == ''
then
then
-- inicializa as variáveis derivadas (registro bibliográfico)
-- inicializa as variáveis derivadas (registro bibliográfico)
-- líder
-- líder
local recordStatus = leader:sub( 6, 6 )
local typeOfRecordrecordStatus = leader:sub( 76, 7 6)
local bibliographicLeveltypeOfRecord = leader:sub( 87, 8 7)
local encodingLevelbibliographicLevel = leader:sub( 188, 18 8)
if local encodingLevel == 'leader:sub(18, '18)
if encodingLevel == ' '
then
then
encodingLevel = ''
encodingLevel = ''
end
end
local descriptiveCatalogingForm = leader:sub( 19, 19 )
if local descriptiveCatalogingForm == 'leader:sub(19, '19)
if descriptiveCatalogingForm == ' '
then
then
descriptiveCatalogingForm = ''
descriptiveCatalogingForm = ''
end
end
local multipartResourceRecordLevel = leader:sub( 20, 20 )
if local multipartResourceRecordLevel == 'leader:sub(20, '20)
if multipartResourceRecordLevel == ' '
then
then
multipartResourceRecordLevel = ''
multipartResourceRecordLevel = ''
end
end
-- control field 008
-- control field 008
local dateEnteredOnFile = controlField008:sub( 1, 6 )
local typeOfDatedateEnteredOnFile = controlField008:sub( 71, 7 6)
local date1typeOfDate = controlField008:sub( 87, 11 7)
local date2date1 = controlField008:sub( 128, 15 11)
local placeOfPublicationdate2 = controlField008:sub( 1612, 18 15)
local illustrationsplaceOfPublication = controlField008:sub( 1916, 19 18)
if local illustrations == 'controlField008:sub(19, '19)
if illustrations == ' '
then
then
illustrations = ''
illustrations = ''
end
end
local targetAudience = controlField008:sub( 23, 23 )
if local targetAudience == 'controlField008:sub(23, '23)
if targetAudience == ' '
then
then
targetAudience = ''
targetAudience = ''
end
end
local formOfItem = controlField008:sub( 24, 24 )
if local formOfItem == 'controlField008:sub(24, '24)
if formOfItem == ' '
then
then
formOfItem = 'r'
formOfItem = ''
end
end
local natureOfContents = controlField008:sub( 25, 25 )
if local natureOfContents == 'controlField008:sub(25, '25)
if natureOfContents == ' '
then
then
natureOfContents = ''
natureOfContents = ''
end
end
local governmentPublication = controlField008:sub( 29, 29 )
if governmentPublication == ' ' orlocal governmentPublication == '0'controlField008:sub(29, 29)
if governmentPublication == ' ' or governmentPublication == '0'
then
then
governmentPublication = ''
governmentPublication = ''
end
end
local conferencePublication = controlField008:sub( 30, 30 )
if local conferencePublication == '0'controlField008:sub(30, 30)
if conferencePublication == '0'
then
then
conferencePublication = ''
conferencePublication = ''
end
end
local festschrift = controlField008:sub( 31, 31 )
if local festschrift == '0'controlField008:sub(31, 31)
if festschrift == ' '
then
then
festschrift = ''
festschrift = ''
end
end
local index = controlField008:sub( 32, 32 )
if index == '0' orlocal index == 'controlField008:sub(32, '32)
if index == '0' or index == ' '
then
then
index = ''
index = ''
end
end
local literaryForm = controlField008:sub( 34, 34 )
if literaryForm == '0' orlocal literaryForm == 'controlField008:sub(34, '34)
if literaryForm == '0' or literaryForm == ' '
then
then
literaryForm = ''
literaryForm = ''
end
end
local biography = controlField008:sub( 35, 35 )
if local biography == 'controlField008:sub(35, '35)
if biography == ' '
then
then
biography = ''
biography = ''
end
end
local language = controlField008:sub( 36, 38 )
local modifiedRecordlanguage = controlField008:sub( 3936, 39 38)
local modifiedRecord = controlField008:sub(39, 39)
if modifiedRecord == ' ' or modifiedRecord:match( '\r' )
if modifiedRecord == ' ' or modifiedRecord:match('\r')
then
then
modifiedRecord = ''
modifiedRecord = ''
end
end
local catalogingSource = controlField008:sub( 40, 40 )
if local catalogingSource == 'controlField008:sub(40, '40)
if catalogingSource == ' '
then
then
catalogingSource = ''
catalogingSource = ''
end
end
-- query string maker (part 1), Predefinição BibRecord
-- query string maker (part 1), Predefinição BibRecord
queryString =
queryString =
'BibRecord[dateEnteredOnFile]=' .. dateEnteredOnFile ..
'&BibRecord[recordStatusdateEnteredOnFile]=' .. recordStatusdateEnteredOnFile ..
'&BibRecord[typeOfRecordrecordStatus]=' .. typeOfRecordrecordStatus ..
'&BibRecord[bibliographicLeveltypeOfRecord]=' .. bibliographicLeveltypeOfRecord ..
'&BibRecord[encodingLevelbibliographicLevel]=' .. encodingLevelbibliographicLevel ..
'&BibRecord[descriptiveCatalogingFormencodingLevel]=' .. descriptiveCatalogingFormencodingLevel ..
'&BibRecord[multipartResourceRecordLeveldescriptiveCatalogingForm]=' .. multipartResourceRecordLeveldescriptiveCatalogingForm ..
'&BibRecord[controlField006multipartResourceRecordLevel]=' .. controlField006multipartResourceRecordLevel ..
'&BibRecord[controlField007controlField006]=' .. controlField007controlField006 ..
'&BibRecord[typeOfDatecontrolField007]=' .. typeOfDatecontrolField007 ..
'&BibRecord[date1typeOfDate]=' .. date1typeOfDate ..
'&BibRecord[date2date1]=' .. date2date1 ..
'&BibRecord[placeOfPublicationdate2]=' .. placeOfPublicationdate2 ..
'&BibRecord[illustrationsplaceOfPublication]=' .. illustrationsplaceOfPublication ..
'&BibRecord[targetAudienceillustrations]=' .. targetAudienceillustrations ..
'&BibRecord[formOfItemtargetAudience]=' .. formOfItemtargetAudience ..
'&BibRecord[natureOfContentsformOfItem]=' .. natureOfContentsformOfItem ..
'&BibRecord[governmentPublicationnatureOfContents]=' .. governmentPublicationnatureOfContents ..
'&BibRecord[conferencePublicationgovernmentPublication]=' .. conferencePublicationgovernmentPublication ..
'&BibRecord[festschriftconferencePublication]=' .. festschriftconferencePublication ..
'&BibRecord[indexfestschrift]=' .. indexfestschrift ..
'&BibRecord[literaryFormindex]=' .. literaryFormindex ..
'&BibRecord[biographyliteraryForm]=' .. biographyliteraryForm ..
'&BibRecord[languagebiography]=' .. languagebiography ..
'&BibRecord[modifiedRecordlanguage]=' .. modifiedRecordlanguage ..
'&BibRecord[catalogingSourcemodifiedRecord]=' .. catalogingSourcemodifiedRecord ..
'&BibRecord[catalogingSource]=' .. catalogingSource ..
fieldQueryString
fieldQueryString
-- template string maker (part 1), Predefinição BibRecord
-- template string maker (part 1), Predefinição BibRecord
firstTemplate = '<pre>{{BibRecord\n' ..
firstTemplate = '<pre>{{BibRecord\n' ..
'|dateEnteredOnFile=' .. dateEnteredOnFile .. '\n' ..
'|recordStatusdateEnteredOnFile=' .. recordStatusdateEnteredOnFile .. '\n' ..
'|typeOfRecordrecordStatus=' .. typeOfRecordrecordStatus .. '\n' ..
'|bibliographicLeveltypeOfRecord=' .. bibliographicLeveltypeOfRecord .. '\n' ..
'|encodingLevelbibliographicLevel=' .. encodingLevelbibliographicLevel .. '\n' ..
'|descriptiveCatalogingFormencodingLevel=' .. descriptiveCatalogingFormencodingLevel .. '\n' ..
'|multipartResourceRecordLeveldescriptiveCatalogingForm=' .. multipartResourceRecordLeveldescriptiveCatalogingForm .. '\n' ..
'|controlField006multipartResourceRecordLevel=' .. controlField006multipartResourceRecordLevel .. '\n' ..
'|controlField007controlField006=' .. controlField007controlField006 .. '\n' ..
'|typeOfDatecontrolField007=' .. typeOfDatecontrolField007 .. '\n' ..
'|date1typeOfDate=' .. date1typeOfDate .. '\n' ..
'|date2date1=' .. date2date1 .. '\n' ..
'|placeOfPublicationdate2=' .. placeOfPublicationdate2 .. '\n' ..
'|illustrationsplaceOfPublication=' .. illustrationsplaceOfPublication .. '\n' ..
'|targetAudienceillustrations=' .. targetAudienceillustrations .. '\n' ..
'|formOfItemtargetAudience=' .. formOfItemtargetAudience .. '\n' ..
'|natureOfContentsformOfItem=' .. natureOfContentsformOfItem .. '\n' ..
'|governmentPublicationnatureOfContents=' .. governmentPublicationnatureOfContents .. '\n' ..
'|conferencePublicationgovernmentPublication=' .. conferencePublicationgovernmentPublication .. '\n' ..
'|festschriftconferencePublication=' .. festschriftconferencePublication .. '\n' ..
'|indexfestschrift=' .. indexfestschrift .. '\n' ..
'|literaryFormindex=' .. literaryFormindex .. '\n' ..
'|biographyliteraryForm=' .. biographyliteraryForm .. '\n' ..
'|languagebiography=' .. languagebiography .. '\n' ..
'|modifiedRecordlanguage=' .. modifiedRecordlanguage .. '\n' ..
'|modifiedRecord=' .. modifiedRecord .. '\n' ..
'|catalogingSource=' .. catalogingSource ..
'|catalogingSource=' .. catalogingSource ..
'\n}}\n'
'\n}}\n'
-- cria o botão para a importação do registro
-- cria o botão para a importação do registro
formLink = frame:callParserFunction{ name = '#formlink',
formLink = frame:callParserFunction { name = '#formlink',
args = { 'form=BibRecord', 'link text=Importar registro',
args = { 'form=BibRecord', 'link text=Importar registro',
'link type=post button', 'query string=' .. queryString } }
'link type=post button', 'query string=' .. queryString } }
else
else
-- inicializa as variáveis derivadas (registro de autoridade)
-- inicializa as variáveis derivadas (registro de autoridade)
-- líder
-- líder
local recordStatus = leader:sub( 6, 6 )
local encodingLevelrecordStatus = leader:sub( 186, 18 6)
if local encodingLevel == 'leader:sub(18, '18)
if encodingLevel == ' '
then
then
encodingLevel = ''
encodingLevel = ''
end
end
local punctuationPolicy = leader:sub( 19, 19 )
if punctuationPolicy == ' ' orlocal punctuationPolicy == '4'leader:sub(19, 19)
if punctuationPolicy == ' ' or punctuationPolicy == '4'
then
then
punctuationPolicy = ''
punctuationPolicy = ''
end
end
-- control field 008
-- control field 008
local dateEnteredOnFile = controlField008:sub( 1, 6 )
local directOrIndirectGeogSubdivdateEnteredOnFile = controlField008:sub( 71, 7 6)
if local directOrIndirectGeogSubdiv == 'controlField008:sub(7, '7)
if directOrIndirectGeogSubdiv == ' '
then
then
directOrIndirectGeogSubdiv = ''
directOrIndirectGeogSubdiv = ''
end
end
local romanizationScheme = controlField008:sub( 8, 8 )
local languageOfCatalogromanizationScheme = controlField008:sub( 98, 9 8)
if local languageOfCatalog == 'controlField008:sub(9, '9)
if languageOfCatalog == ' '
then
then
languageOfCatalog = ''
languageOfCatalog = ''
end
end
local kindOfRecord = controlField008:sub( 10, 10 )
local descriptiveCatalogingRuleskindOfRecord = controlField008:sub( 1110, 11 10)
local subjectHeadingSystemdescriptiveCatalogingRules = controlField008:sub( 1211, 12 11)
local typeOfSeriessubjectHeadingSystem = controlField008:sub( 1312, 13 12)
local numberedOrUnnumberedSeriestypeOfSeries = controlField008:sub( 1413, 14 13)
if local numberedOrUnnumberedSeries == 'controlField008:sub(14, '14)
if numberedOrUnnumberedSeries == ' '
then
then
numberedOrUnnumberedSeries = ''
numberedOrUnnumberedSeries = ''
end
end
local headingUseMainOrAddedEntry = controlField008:sub( 15, 15 )
local headingUseSubjectAddedEntryheadingUseMainOrAddedEntry = controlField008:sub( 1615, 16 15)
if local headingUseSubjectAddedEntry == 'controlField008:sub(16, '16)
if headingUseSubjectAddedEntry == ' '
then
then
headingUseSubjectAddedEntry = ''
headingUseSubjectAddedEntry = ''
end
end
local headingUseSeriesAddedEntry = controlField008:sub( 17, 17 )
local typeOfSubjectSubdivisionheadingUseSeriesAddedEntry = controlField008:sub( 1817, 18 17)
if typeOfSubjectSubdivisionheadingUseSeriesAddedEntry == ' '
then
headingUseSeriesAddedEntry = 'b'
typeOfSubjectSubdivision = ''
end
local typeOfGovernmentAgencytypeOfSubjectSubdivision = controlField008:sub( 2918, 29 18)
if typeOfGovernmentAgencytypeOfSubjectSubdivision == ' '
then
typeOfSubjectSubdivision = ''
typeOfGovernmentAgency = ''
end
local referenceEvaluationtypeOfGovernmentAgency = controlField008:sub( 3029, 30 29)
if referenceEvaluationtypeOfGovernmentAgency == ' '
then
typeOfGovernmentAgency = ''
referenceEvaluation = ''
end
local recordUpdateInProcessreferenceEvaluation = controlField008:sub( 3230, 32 30)
if referenceEvaluation == ' '
local undifferentiatedPersonalName = controlField008:sub( 33, 33 )
then
if undifferentiatedPersonalName == ' '
referenceEvaluation = ''
then
end
undifferentiatedPersonalName = ''
local recordUpdateInProcess = controlField008:sub(32, 32)
end
local levelOfEstablishmentundifferentiatedPersonalName = controlField008:sub( 3433, 34 33)
if levelOfEstablishmentundifferentiatedPersonalName == ' '
then
undifferentiatedPersonalName = ''
levelOfEstablishment = ''
end
local modifiedRecordlevelOfEstablishment = controlField008:sub( 3934, 39 34)
if levelOfEstablishment == ' '
if modifiedRecord == ' ' or modifiedRecord:match( '\r' )
then
levelOfEstablishment = ''
modifiedRecord = ''
end
local catalogingSourcemodifiedRecord = controlField008:sub( 4039, 40 39)
if modifiedRecord == ' ' or modifiedRecord:match('\r')
if catalogingSource == ' '
then
modifiedRecord = ''
catalogingSource = ''
end
local catalogingSource = controlField008:sub(40, 40)
-- query string maker (part 1), Predefinição AutRecord
if catalogingSource == ' '
queryString =
then
'AutRecord[dateEnteredOnFile]=' .. dateEnteredOnFile ..
catalogingSource = ''
'&AutRecord[recordStatus]=' .. recordStatus ..
end
'&AutRecord[encodingLevel]=' .. encodingLevel ..
-- query string maker (part 1), Predefinição AutRecord
'&AutRecord[punctuationPolicy]=' .. punctuationPolicy ..
queryString =
'&AutRecord[directOrIndirectGeogSubdiv]=' .. directOrIndirectGeogSubdiv ..
'&AutRecord[romanizationSchemedateEnteredOnFile]=' .. romanizationSchemedateEnteredOnFile ..
'&AutRecord[languageOfCatalogrecordStatus]=' .. languageOfCatalogrecordStatus ..
'&AutRecord[kindOfRecordencodingLevel]=' .. kindOfRecordencodingLevel ..
'&AutRecord[descriptiveCatalogingRulespunctuationPolicy]=' .. descriptiveCatalogingRulespunctuationPolicy ..
'&AutRecord[subjectHeadingSystemdirectOrIndirectGeogSubdiv]=' .. subjectHeadingSystemdirectOrIndirectGeogSubdiv ..
'&AutRecord[typeOfSeriesromanizationScheme]=' .. typeOfSeriesromanizationScheme ..
'&AutRecord[numberedOrUnnumberedSerieslanguageOfCatalog]=' .. numberedOrUnnumberedSerieslanguageOfCatalog ..
'&AutRecord[headingUseMainOrAddedEntrykindOfRecord]=' .. headingUseMainOrAddedEntrykindOfRecord ..
'&AutRecord[headingUseSubjectAddedEntrydescriptiveCatalogingRules]=' .. headingUseSubjectAddedEntrydescriptiveCatalogingRules ..
'&AutRecord[headingUseSeriesAddedEntrysubjectHeadingSystem]=' .. headingUseSeriesAddedEntrysubjectHeadingSystem ..
'&AutRecord[typeOfSubjectSubdivisiontypeOfSeries]=' .. typeOfSubjectSubdivisiontypeOfSeries ..
'&AutRecord[typeOfGovernmentAgencynumberedOrUnnumberedSeries]=' .. typeOfGovernmentAgencynumberedOrUnnumberedSeries ..
'&AutRecord[referenceEvaluationheadingUseMainOrAddedEntry]=' .. referenceEvaluationheadingUseMainOrAddedEntry ..
'&AutRecord[recordUpdateInProcessheadingUseSubjectAddedEntry]=' .. recordUpdateInProcessheadingUseSubjectAddedEntry ..
'&AutRecord[undifferentiatedPersonalNameheadingUseSeriesAddedEntry]=' .. undifferentiatedPersonalNameheadingUseSeriesAddedEntry ..
'&AutRecord[levelOfEstablishmenttypeOfSubjectSubdivision]=' .. levelOfEstablishmenttypeOfSubjectSubdivision ..
'&AutRecord[modifiedRecordtypeOfGovernmentAgency]=' .. modifiedRecordtypeOfGovernmentAgency ..
'&AutRecord[catalogingSourcereferenceEvaluation]=' .. catalogingSourcereferenceEvaluation ..
'&AutRecord[recordUpdateInProcess]=' .. recordUpdateInProcess ..
fieldQueryString
'&AutRecord[undifferentiatedPersonalName]=' .. undifferentiatedPersonalName ..
-- template string maker (part 1), Predefinição AutRecord
'&AutRecord[levelOfEstablishment]=' .. levelOfEstablishment ..
firstTemplate = '<pre>{{AutRecord\n' ..
'&AutRecord[modifiedRecord]=' .. modifiedRecord ..
'|dateEnteredOnFile=' .. dateEnteredOnFile .. '\n' ..
'&AutRecord[catalogingSource]=' .. catalogingSource ..
'|recordStatus=' .. recordStatus .. '\n' ..
fieldQueryString
'|encodingLevel=' .. encodingLevel .. '\n' ..
-- template string maker (part 1), Predefinição AutRecord
'|punctuationPolicy=' .. punctuationPolicy .. '\n' ..
firstTemplate = '<pre>{{AutRecord\n' ..
'|directOrIndirectGeogSubdiv=' .. directOrIndirectGeogSubdiv .. '\n' ..
'|romanizationSchemedateEnteredOnFile=' .. romanizationSchemedateEnteredOnFile .. '\n' ..
'|languageOfCatalogrecordStatus=' .. languageOfCatalogrecordStatus .. '\n' ..
'|kindOfRecordencodingLevel=' .. kindOfRecordencodingLevel .. '\n' ..
'|descriptiveCatalogingRulespunctuationPolicy=' .. descriptiveCatalogingRulespunctuationPolicy .. '\n' ..
'|subjectHeadingSystemdirectOrIndirectGeogSubdiv=' .. subjectHeadingSystemdirectOrIndirectGeogSubdiv .. '\n' ..
'|typeOfSeriesromanizationScheme=' .. typeOfSeriesromanizationScheme .. '\n' ..
'|numberedOrUnnumberedSerieslanguageOfCatalog=' .. numberedOrUnnumberedSerieslanguageOfCatalog .. '\n' ..
'|headingUseMainOrAddedEntrykindOfRecord=' .. headingUseMainOrAddedEntrykindOfRecord .. '\n' ..
'|headingUseSubjectAddedEntrydescriptiveCatalogingRules=' .. headingUseSubjectAddedEntrydescriptiveCatalogingRules .. '\n' ..
'|headingUseSeriesAddedEntrysubjectHeadingSystem=' .. headingUseSeriesAddedEntrysubjectHeadingSystem .. '\n' ..
'|typeOfSubjectSubdivisiontypeOfSeries=' .. typeOfSubjectSubdivisiontypeOfSeries .. '\n' ..
'|typeOfGovernmentAgencynumberedOrUnnumberedSeries=' .. typeOfGovernmentAgencynumberedOrUnnumberedSeries .. '\n' ..
'|referenceEvaluationheadingUseMainOrAddedEntry=' .. referenceEvaluationheadingUseMainOrAddedEntry .. '\n' ..
'|recordUpdateInProcessheadingUseSubjectAddedEntry=' .. recordUpdateInProcessheadingUseSubjectAddedEntry .. '\n' ..
'|undifferentiatedPersonalNameheadingUseSeriesAddedEntry=' .. undifferentiatedPersonalNameheadingUseSeriesAddedEntry .. '\n' ..
'|levelOfEstablishmenttypeOfSubjectSubdivision=' .. levelOfEstablishmenttypeOfSubjectSubdivision .. '\n' ..
'|modifiedRecordtypeOfGovernmentAgency=' .. modifiedRecordtypeOfGovernmentAgency .. '\n' ..
'|referenceEvaluation=' .. referenceEvaluation .. '\n' ..
'|catalogingSource=' .. catalogingSource ..
'|recordUpdateInProcess=' .. recordUpdateInProcess .. '\n' ..
'\n}}\n'
'|undifferentiatedPersonalName=' .. undifferentiatedPersonalName .. '\n' ..
-- cria o botão para a importação do registro
'|levelOfEstablishment=' .. levelOfEstablishment .. '\n' ..
formLink = frame:callParserFunction{ name = '#formlink',
'|modifiedRecord=' .. modifiedRecord .. '\n' ..
args = { 'form=AutRecord', 'link text=Importar registro',
'|catalogingSource=' .. catalogingSource ..
'link type=post button', 'query string=' .. queryString } }
'\n}}\n'
end
-- cria o botão para a importação do registro
-- retorna todos os valores para a predefinição {{MARCimporter}}
formLink = frame:callParserFunction { name = '#formlink',
return formLink, firstTemplate, fieldTemplates, lastTemplate
args = { 'form=AutRecord', 'link text=Importar registro',
'link type=post button', 'query string=' .. queryString } }
end
-- retorna todos os valores para a predefinição {{MARCimporter}}
return formLink, firstTemplate, fieldTemplates, lastTemplate
end
 
return p