<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Trifolia.Shared;
using Trifolia.Shared.ImportExport.Model;
using Trifolia.DB;

using VadsClient;
using Trifolia.Config;

namespace Trifolia.Import.Terminology.External
{
    public class PhinVadsValueSetImportProcessor<T,V> : BaseValueSetImportProcess<T,V>
            where T : ImportValueSet
            where V : ImportValueSetMember
    {
        private const int MEMBER_PAGE_SIZE = 5000;

        protected override T BaseFindValueSet(IObjectRepository tdb, string oid)
        {
            if (string.IsNullOrEmpty(oid))
                throw new ArgumentNullException("oid");

            oid = oid.Trim();       // Remove trailing spaces

            hessiancsharp.client.CHessianProxyFactory factory = new hessiancsharp.client.CHessianProxyFactory();
            VocabService vocabService = (VocabService)factory.Create(typeof(VocabService), AppSettings.PhinVadsServiceUrl);
            ValueSetResultDto valueSetResults = null;

            try
            {
                valueSetResults = vocabService.getValueSetByOid(oid);

                if (!string.IsNullOrEmpty(valueSetResults.errorText))
                    throw new ExternalSourceConnectionException();

                if (valueSetResults == null || valueSetResults.totalResults != 1)
                    return null;

                string searchOid = oid;<commit_msg>Adding additional logging to PHIN VADS import processor<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Trifolia.Shared;
using Trifolia.Shared.ImportExport.Model;
using Trifolia.DB;

using VadsClient;
using Trifolia.Config;

namespace Trifolia.Import.Terminology.External
{
    public class PhinVadsValueSetImportProcessor<T,V> : BaseValueSetImportProcess<T,V>
            where T : ImportValueSet
            where V : ImportValueSetMember
    {
        private const int MEMBER_PAGE_SIZE = 5000;

        protected override T BaseFindValueSet(IObjectRepository tdb, string oid)
        {
            if (string.IsNullOrEmpty(oid))
                throw new ArgumentNullException("oid");

            oid = oid.Trim();       // Remove trailing spaces

            Logging.Log.For(this).Trace("Creating client to connect to PHIN VADS at URL " + AppSettings.PhinVadsServiceUrl);

            hessiancsharp.client.CHessianProxyFactory factory = new hessiancsharp.client.CHessianProxyFactory();
            VocabService vocabService = (VocabService)factory.Create(typeof(VocabService), AppSettings.PhinVadsServiceUrl);
            ValueSetResultDto valueSetResults = null;

            try
            {
                Logging.Log.For(this).Trace("Retrieving value set from PHIN VADS");

                valueSetResults = vocabService.getValueSetByOid(oid);

                if (!string.IsNullOrEmpty(valueSetResults.errorText))
                    throw new ExternalSourceConnectionException();

                if (valueSetResults == null || valueSetResults.totalResults != 1)
                {
                    Logging.Log.For(this).Trace("No value set found when searching PHIN VADS for identifier " + oid);
                    return null;
                }

                Logging.Log.For(this).Trace("Successfully retrieved one value set from PHIN VADS");

                string searchOid = oid;
{'fraction_non_alphanumeric': 0.07690058479532164, 'fraction_numerical': 0.0029239766081871343, 'mean_word_length': 2.5524402907580477, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1090067', 'n_tokens_mistral': 953, 'n_tokens_neox': 893, 'n_words': 203}