Exemplo n.º 1
0
        private MarcDirectory ParseDirectory(string mrcContent, MarcLeader mrcLdr)
        {
            const int ldrLength           = 24;
            const int dirTerminatorLength = 1;
            var       dirLength           = int.Parse(mrcLdr.BaseAddressOfData) - ldrLength - dirTerminatorLength;
            var       mrcDir = new MarcDirectory(mrcContent, ldrLength, dirLength, mrcLdr);

            v_RowsDirectory.AddRange(mrcDir.GetDirArray());
            return(mrcDir);
        }
Exemplo n.º 2
0
        private bool ParseVarDataFields(MarcDirectory mrcDir)
        {
            //foreach (var dirEntry in mrcDir.DirEntryList.OrderBy(x => x.Order))
            foreach (var dirEntry in mrcDir.DirEntryList)   // do not reorder LOC mrc files which may have slightly different ordering.
            {
                // skip control fields:
                if (dirEntry.Id.StartsWith("00"))
                {
                    continue;
                }

                var varDataField = MarcViewerTools.GetVariableDataField(dirEntry);
                if (varDataField == null)
                {
                    continue;
                }

                // populate variable data fields table:
                v_RowsVarData.Add(new[] { varDataField.Id, varDataField.ToInd1String(), varDataField.ToInd2String(), varDataField.ToSubfieldString() });
            }

            return(true);
        }
Exemplo n.º 3
0
        private bool ParseControlFields(MarcLeader mrcLdr, MarcDirectory mrcDir)
        {
            var ctrlSupported   = new[] { "001", "003", "005", "006", "007", "008" };
            var fieldIdList     = mrcDir.DirEntryList.Select(x => x.Id).Where(x => x.StartsWith("00")).ToList();
            var ctrlUnsupported = fieldIdList.Except(ctrlSupported).ToList();

            if (ctrlUnsupported.Count > 0)
            {
                return(false);
            }

            // parse 001:
            var dirEntries001 = mrcDir.DirEntryList.SingleOrDefault(x => x.Id == "001")?.DataChars?.SkipLast(1)?.ToList();  // remove field terminator.

            if (dirEntries001 != null)
            {
                if (dirEntries001.Count != 13 || !dirEntries001.ToString().StartsWith("BIB-"))
                {
                    //throw new c_ParseException("Only predictivebib.org records supported.", c_StatusCode.InvalidCredentials);  // custom exception.
                }
                var mrc001 = new Marc001(dirEntries001);
                v_RowsControl.AddRange(mrc001.GetCtrlArray());
                //v_RowsControl.Add(new[] { "\u2009", "\u2009", "\u2009", "\u2009" });
            }

            // parse 003:
            var dirEntries003 = mrcDir.DirEntryList.SingleOrDefault(x => x.Id == "003")?.DataChars?.SkipLast(1)?.ToList();  // remove field terminator.

            if (dirEntries003 != null)
            {
                var mrc003 = new Marc003(dirEntries003);
                v_RowsControl.AddRange(mrc003.GetCtrlArray());
                //v_RowsControl.Add(new[] { "\u2009", "\u2009", "\u2009", "\u2009" });
            }

            // parse 005:
            var dirEntries005 = mrcDir.DirEntryList.SingleOrDefault(x => x.Id == "005")?.DataChars?.SkipLast(1)?.ToList();  // remove field terminator.

            if (dirEntries005 != null)
            {
                var mrc005 = new Marc005(dirEntries005);
                v_RowsControl.AddRange(mrc005.GetCtrlArray());
                //v_RowsControl.Add(new[] { "\u2009", "\u2009", "\u2009", "\u2009" });
            }

            // parse 006 (repeatable):
            foreach (var dirEntries in mrcDir.DirEntryList.Where(x => x.Id == "006"))
            {
                var dirEntries006 = dirEntries.DataChars?.SkipLast(1)?.ToList();  // remove field terminator.
                if (dirEntries006 != null)
                {
                    var mrc006 = new Marc006(dirEntries006);
                    v_RowsControl.AddRange(mrc006.Material.GetCtrlArray());
                    //v_RowsControl.Add(new[] { "\u2009", "\u2009", "\u2009", "\u2009" });
                }
            }

            // parse 007 (repeatable):
            foreach (var dirEntries in mrcDir.DirEntryList.Where(x => x.Id == "007"))
            {
                var dirEntries007 = dirEntries.DataChars?.SkipLast(1)?.ToList();  // remove field terminator.
                if (dirEntries007 != null)
                {
                    var mrc007 = new Marc007(dirEntries007);
                    v_RowsControl.AddRange(mrc007.Material.GetCtrlArray());
                    //v_RowsControl.Add(new[] { "\u2009", "\u2009", "\u2009", "\u2009" });
                }
            }

            // parse 008:
            var dirEntries008 = mrcDir.DirEntryList.SingleOrDefault(x => x.Id == "008")?.DataChars?.SkipLast(1)?.ToList();  // remove field terminator.

            if (dirEntries008 != null)
            {
                var mrc008 = new Marc008(mrcLdr.materialType, dirEntries008);
                v_RowsControl.AddRange(mrc008.GetCtrlArray());
                //v_RowsVarCtrl.Add(new[] { "\u2009", "\u2009", "\u2009", "\u2009" });
            }

            return(true);
        }