<commit_before>package whelk.util

import se.kb.libris.util.marc.MarcRecord
import se.kb.libris.util.marc.io.Iso2709Deserializer
import whelk.Document
import whelk.converter.MarcJSONConverter
import whelk.converter.marc.MarcFrameConverter

import java.sql.ResultSet
import java.sql.Timestamp
import java.text.Normalizer

public class VCopyToWhelkConverter {

    public static class VCopyDataRow {
        byte[] data
        boolean isDeleted
        Timestamp created
        Timestamp updated
        String collection
        int bib_id
        int auth_id
        int mfhd_id
        byte[] authdata
        String sigel

        public VCopyDataRow() {}

        public VCopyDataRow(ResultSet resultSet, String collection) {
            data = resultSet.getBytes('data')
            isDeleted = resultSet.getBoolean('deleted')
            created = resultSet.getTimestamp('create_date')
            updated = resultSet.getTimestamp('update_date')
            this.collection = collection
            bib_id = collection == 'bib' ? resultSet.getInt('bib_id') : 0
            auth_id = collection == 'auth' ? resultSet.getInt('auth_id') : 0
            mfhd_id = collection == 'hold' ? resultSet.getInt('mfhd_id') : 0
            authdata = collection == 'bib' ? resultSet.getBytes('auth_data') : null
            sigel = collection == "hold" ? resultSet.getString("shortname") : null
        }
    }


    static Map convert(List<VCopyDataRow> rows, MarcFrameConverter marcFrameConverter) {
        VCopyDataRow row = rows.last()

        Timestamp timestamp = row.updated >= row.created ? row.updated : row.created
        Map doc = getMarcDocMap(row.data)<commit_msg>Speculative fix for link finder.<commit_after>package whelk.util

import se.kb.libris.util.marc.MarcRecord
import se.kb.libris.util.marc.io.Iso2709Deserializer
import whelk.Document
import whelk.converter.MarcJSONConverter
import whelk.converter.marc.MarcFrameConverter

import java.sql.ResultSet
import java.sql.Timestamp
import java.text.Normalizer

public class VCopyToWhelkConverter {

    public static class VCopyDataRow {
        byte[] data
        boolean isDeleted
        Timestamp created
        Timestamp updated
        String collection
        int bib_id
        int auth_id
        int mfhd_id
        byte[] authdata
        String sigel

        public VCopyDataRow() {}

        public VCopyDataRow(ResultSet resultSet, String collection) {
            data = resultSet.getBytes('data')
            isDeleted = resultSet.getBoolean('deleted')
            created = resultSet.getTimestamp('create_date')
            updated = resultSet.getTimestamp('update_date')
            this.collection = collection
            bib_id = collection == 'bib' ? resultSet.getInt('bib_id') : 0
            auth_id = collection == 'auth' || collection == 'bib' ? resultSet.getInt('auth_id') : 0
            mfhd_id = collection == 'hold' ? resultSet.getInt('mfhd_id') : 0
            authdata = collection == 'bib' ? resultSet.getBytes('auth_data') : null
            sigel = collection == "hold" ? resultSet.getString("shortname") : null
        }
    }


    static Map convert(List<VCopyDataRow> rows, MarcFrameConverter marcFrameConverter) {
        VCopyDataRow row = rows.last()

        Timestamp timestamp = row.updated >= row.created ? row.updated : row.created
        Map doc = getMarcDocMap(row.data)
{'fraction_non_alphanumeric': 0.09174041297935104, 'fraction_numerical': 0.004129793510324484, 'mean_word_length': 2.718201754385965, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2010396', 'n_tokens_mistral': 994, 'n_tokens_neox': 947, 'n_words': 215}