<commit_before>using Arkivverket.Arkade.Core.Addml.Definitions;
using Arkivverket.Arkade.Core.Addml.Processes;

namespace Arkivverket.Arkade.Core.Addml
{
    public class AddmlProcessRunner
    {
        private FieldProcessRunner _fieldProcessRunner;
        private FileProcessRunner _fileProcessRunner;
        private ProcessManager _processManager;
        private RecordProcessRunner _recordProcessRunner;

        public void Init(AddmlDefinition addmlDefinition)
        {
            _processManager = new ProcessManager(addmlDefinition);
            _fileProcessRunner = new FileProcessRunner(_processManager);
            _recordProcessRunner = new RecordProcessRunner(_processManager);
            _fieldProcessRunner = new FieldProcessRunner(_processManager);
        }

        public void RunProcesses(FlatFile file)
        {
            _fileProcessRunner.RunProcesses(file);
        }

        public void RunProcesses(FlatFile file, Record record)
        {
            _fileProcessRunner.RunProcesses(file, record);
            _recordProcessRunner.RunProcesses(record);
        }

        public void RunProcesses(FlatFile file, Field field)
        {
            _fileProcessRunner.RunProcesses(file, field);
            _fieldProcessRunner.RunProcesses(field);
        }

        public TestSuite GetTestSuite()
        {
            var testSuite = new TestSuite();

            foreach (IAddmlProcess addmlProcess in _processManager.GetAllProcesses())
            {
                // ControlForeignKey needs to access results of CollectPrimaryKey process
                // Consider moving this to ProcessManager.InstantiateProcesses()
                if (addmlProcess.GetType() == typeof(ControlForeignKey))
                {
                    LoadCollectedPrimaryKeysIntoControlForeignKeyProcess(addmlProcess);
                }

                testSuite.AddTestRun(addmlProcess.GetTestRun());
            }

            return testSuite;
        }

        private void LoadCollectedPrimaryKeysIntoControlForeignKeyProcess(IAddmlProcess addmlProcess)
        {
            CollectPrimaryKey collectPrimaryKeyProcess = (CollectPrimaryKey) _processManager.GetProcessInstanceByName(CollectPrimaryKey.Name);

            ((ControlForeignKey) addmlProcess).GetCollectedPrimaryKeys(collectPrimaryKeyProcess);
        }

        public void EndOfFile(FlatFile file)
        {
            _fileProcessRunner.EndOfFile(file);
            _recordProcessRunner.EndOfFile(file);
            _fieldProcessRunner.EndOfFile(file);
        }
        
    }
}<commit_msg>Hide CollectPrimaryKey process from the test report<commit_after>using Arkivverket.Arkade.Core.Addml.Definitions;
using Arkivverket.Arkade.Core.Addml.Processes;

namespace Arkivverket.Arkade.Core.Addml
{
    public class AddmlProcessRunner
    {
        private FieldProcessRunner _fieldProcessRunner;
        private FileProcessRunner _fileProcessRunner;
        private ProcessManager _processManager;
        private RecordProcessRunner _recordProcessRunner;

        public void Init(AddmlDefinition addmlDefinition)
        {
            _processManager = new ProcessManager(addmlDefinition);
            _fileProcessRunner = new FileProcessRunner(_processManager);
            _recordProcessRunner = new RecordProcessRunner(_processManager);
            _fieldProcessRunner = new FieldProcessRunner(_processManager);
        }

        public void RunProcesses(FlatFile file)
        {
            _fileProcessRunner.RunProcesses(file);
        }

        public void RunProcesses(FlatFile file, Record record)
        {
            _fileProcessRunner.RunProcesses(file, record);
            _recordProcessRunner.RunProcesses(record);
        }

        public void RunProcesses(FlatFile file, Field field)
        {
            _fileProcessRunner.RunProcesses(file, field);
            _fieldProcessRunner.RunProcesses(field);
        }

        public TestSuite GetTestSuite()
        {
            var testSuite = new TestSuite();

            foreach (IAddmlProcess addmlProcess in _processManager.GetAllProcesses())
            {
                // ControlForeignKey needs to access results of CollectPrimaryKey process
                // Consider moving this to ProcessManager.InstantiateProcesses()
                if (addmlProcess.GetType() == typeof(ControlForeignKey))
                {
                    LoadCollectedPrimaryKeysIntoControlForeignKeyProcess(addmlProcess);
                }

                // CollectPrimaryKey is internal and should not be part of the test report
                if (addmlProcess.GetType() != typeof(CollectPrimaryKey))
                    testSuite.AddTestRun(addmlProcess.GetTestRun());
            }

            return testSuite;
        }

        private void LoadCollectedPrimaryKeysIntoControlForeignKeyProcess(IAddmlProcess addmlProcess)
        {
            CollectPrimaryKey collectPrimaryKeyProcess = (CollectPrimaryKey) _processManager.GetProcessInstanceByName(CollectPrimaryKey.Name);

            ((ControlForeignKey) addmlProcess).GetCollectedPrimaryKeys(collectPrimaryKeyProcess);
        }

        public void EndOfFile(FlatFile file)
        {
            _fileProcessRunner.EndOfFile(file);
            _recordProcessRunner.EndOfFile(file);
            _fieldProcessRunner.EndOfFile(file);
        }
        
    }
}
{'fraction_non_alphanumeric': 0.06154704351059873, 'fraction_numerical': 0.0, 'mean_word_length': 2.4547206165703277, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4819998', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1280, 'n_words': 239}