Exemplo n.º 1
0
        /// <inheritdoc/>
        public override IEnumerable <Clue> BuildClues(ExecutionContext context, IExternalSearchQuery query, IExternalSearchQueryResult result, IExternalSearchRequest request)
        {
            var organizationCode = this.GetOriginEntityCode(result.As <PermIdSocialResponse>());
            var organizationClue = new Clue(organizationCode, context.Organization);

            this.PopulateMetadata(organizationClue.Data.EntityData, result.As <PermIdSocialResponse>());

            yield return(organizationClue);

            if (result.As <PermIdSocialResponse>().Data.AdditionalInfo != null)
            {
                foreach (var person in result.As <PermIdSocialResponse>().Data.AdditionalInfo)
                {
                    var personCode = this.GetPersonEntityCode(person);
                    var personClue = new Clue(personCode, context.Organization);

                    this.PopulatePersonMetadata(personClue.Data.EntityData, person);

                    var personToOrganizationEdge = new EntityEdge(new EntityReference(personCode), new EntityReference(organizationCode), EntityEdgeType.WorksFor);
                    personClue.Data.EntityData.OutgoingEdges.Add(personToOrganizationEdge);

                    yield return(personClue);
                }
            }
        }
Exemplo n.º 2
0
        /// <inheritdoc/>
        public override IEnumerable <Clue> BuildClues(ExecutionContext context, IExternalSearchQuery query, IExternalSearchQueryResult result, IExternalSearchRequest request)
        {
            var resultItem = result.As <Result>();

            string id;

            if (request.QueryParameters.ContainsKey(Core.Data.Vocabularies.Vocabularies.CluedInOrganization.CodesCVR))
            {
                id = request.QueryParameters.GetValue(Core.Data.Vocabularies.Vocabularies.CluedInOrganization.CodesCVR).FirstOrDefault();
            }
            else
            {
                id = resultItem.Data.ActualAddress.AccessAddressId;
            }

            var code = new EntityCode(EntityType.Organization, CodeOrigin.CluedIn, id);

            var clue = new Clue(code, context.Organization);

            clue.Data.OriginProviderDefinitionId = Id;

            PopulateMetadata(clue.Data.EntityData, resultItem, request);

            yield return(clue);
        }
Exemplo n.º 3
0
        /// <summary>Gets the primary entity metadata.</summary>
        /// <param name="context">The context.</param>
        /// <param name="result">The result.</param>
        /// <param name="request">The request.</param>
        /// <returns>The primary entity metadata.</returns>
        public override IEntityMetadata GetPrimaryEntityMetadata(ExecutionContext context,
                                                                 IExternalSearchQueryResult result,
                                                                 IExternalSearchRequest request)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            using (context.Log.BeginScope("{0} {1}: request {2}, result {3}", GetType().Name, "GetPrimaryEntityMetadata", request, result))
            {
                var metadata = CreateMetadata(result.As <VatLayerResponse>());

                context.Log.LogInformation("Primary entity meta data created, Name: '{Name}' OriginEntityCode: '{OriginEntityCode}'", metadata.Name, metadata.OriginEntityCode.Origin.Code);

                return(metadata);
            }
        }
Exemplo n.º 4
0
        /// <inheritdoc/>
        public override IEntityMetadata GetPrimaryEntityMetadata(ExecutionContext context, IExternalSearchQueryResult result, IExternalSearchRequest request)
        {
            var resultItem = result.As <Result>();

            if (resultItem == null)
            {
                return(null);
            }

            return(CreateMetadata(resultItem, request));
        }
Exemplo n.º 5
0
        /// <inheritdoc/>
        public override IEntityMetadata GetPrimaryEntityMetadata(ExecutionContext context, IExternalSearchQueryResult result, IExternalSearchRequest request)
        {
            var resultItem = result.As <PermIdSocialResponse>();

            if (resultItem == null)
            {
                return(null);
            }

            return(this.CreateMetadata(resultItem));
        }
Exemplo n.º 6
0
        public void LogResult(ExecutionContext context, IExternalSearchQuery query, IExternalSearchQueryResult result)
        {
            using (var systemContext = context.ApplicationContext.System.CreateExecutionContext())
            {
                var dataStore  = systemContext.Organization.DataStores.GetDataStore <ExternalSearchClearBitLogRecord>();
                var resultItem = result.As <CompanyAutocompleteResult>();
                var record     = this.CreateRecord(context, query, result, resultItem.Data);

                dataStore.InsertOrUpdate(systemContext, record);
            }
        }
Exemplo n.º 7
0
        /// <inheritdoc/>
        public override IEnumerable <Clue> BuildClues(ExecutionContext context, IExternalSearchQuery query, IExternalSearchQueryResult result, IExternalSearchRequest request)
        {
            var resultItem = result.As <GleifResponse>();

            var code = this.GetOriginEntityCode(resultItem.Data.Data.First()?.Attributes.Lei);

            var clue = new Clue(code, context.Organization);

            this.PopulateMetadata(clue.Data.EntityData, resultItem, request);

            return(new[] { clue });
        }
Exemplo n.º 8
0
        /// <summary>Builds the clues.</summary>
        /// <param name="context">The context.</param>
        /// <param name="query">The query.</param>
        /// <param name="result">The result.</param>
        /// <param name="request">The request.</param>
        /// <returns>The clues.</returns>
        public override IEnumerable <Clue> BuildClues(ExecutionContext context, IExternalSearchQuery query, IExternalSearchQueryResult result, IExternalSearchRequest request)
        {
            var resultItem = result.As <CompanyNew>();

            var code = new EntityCode(EntityType.Organization, GetCodeOrigin(), resultItem.Data.company_number);

            var clue = new Clue(code, context.Organization);

            clue.Data.OriginProviderDefinitionId = Id;

            PopulateMetadata(clue.Data.EntityData, resultItem.Data);
            yield return(clue);
        }
Exemplo n.º 9
0
        public override IEnumerable <Clue> BuildClues(ExecutionContext context, IExternalSearchQuery query, IExternalSearchQueryResult result, IExternalSearchRequest request)
        {
            var resultItem = result.As <User>();

            var code = GetOriginEntityCode(resultItem);

            var clue = new Clue(code, context.Organization);

            PopulateMetadata(clue.Data.EntityData, resultItem);

            // If necessary, you can create multiple clues and return them.

            return(new[] { clue });
        }
Exemplo n.º 10
0
        /// <summary>Builds the clues.</summary>
        /// <param name="context">The context.</param>
        /// <param name="query">The query.</param>
        /// <param name="result">The result.</param>
        /// <param name="request">The request.</param>
        /// <returns>The clues.</returns>
        public override IEnumerable <Clue> BuildClues(ExecutionContext context, IExternalSearchQuery query, IExternalSearchQueryResult result, IExternalSearchRequest request)
        {
            var resultItem = result.As <Person>();

            var code = this.GetOriginEntityCode(resultItem);

            var clue = new Clue(code, context.Organization);

            clue.Data.OriginProviderDefinitionId = this.Id;

            this.PopulateMetadata(clue.Data.EntityData, resultItem);
            this.DownloadPreviewImage(context, resultItem.Data.avatar, clue);

            return(new[] { clue });
        }
Exemplo n.º 11
0
        public void LogResult(ExecutionContext context, IExternalSearchQuery query, IExternalSearchQueryResult result)
        {
            using (var systemContext = context.ApplicationContext.System.CreateExecutionContext())
            {
                var dataStore  = systemContext.Organization.DataStores.GetDataStore <ExternalSearchGoogleKnowledgeGraphLogRecord>();
                var resultItem = result.As <Result>();

                if (resultItem.Data.id == null && resultItem.Data.name == null && resultItem.Data.description == null)
                {
                    return;
                }

                var record = this.CreateRecord(context, query, result, resultItem.Data);

                dataStore.InsertOrUpdate(systemContext, record);
            }
        }
Exemplo n.º 12
0
        /// <summary>Builds the clues.</summary>
        /// <param name="context">The context.</param>
        /// <param name="query">The query.</param>
        /// <param name="result">The result.</param>
        /// <param name="request">The request.</param>
        /// <returns>The clues.</returns>
        public override IEnumerable <Clue> BuildClues(ExecutionContext context,
                                                      IExternalSearchQuery query,
                                                      IExternalSearchQueryResult result,
                                                      IExternalSearchRequest request)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            if (result == null)
            {
                throw new ArgumentNullException(nameof(result));
            }

            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            using (context.Log.BeginScope("{0} {1}: query {2}, request {3}, result {4}", GetType().Name, "BuildClues", query, request, result))
            {
                var resultItem = result.As <VatLayerResponse>();
                var dirtyClue  = request.CustomQueryInput.ToString();
                var code       = GetOriginEntityCode(resultItem);
                var clue       = new Clue(code, context.Organization);
                if (!string.IsNullOrEmpty(dirtyClue))
                {
                    clue.Data.EntityData.Codes.Add(new EntityCode(EntityType.Organization, CodeOrigin.CluedIn.CreateSpecific("vatlayer"), dirtyClue));
                }
                PopulateMetadata(clue.Data.EntityData, resultItem);

                context.Log.LogInformation("Clue produced, Id: '{Id}' OriginEntityCode: '{OriginEntityCode}' RawText: '{RawText}'", clue.Id, clue.OriginEntityCode, clue.RawText);

                return(new[] { clue });
            }
        }
Exemplo n.º 13
0
        /// <summary>Gets the primary entity metadata.</summary>
        /// <param name="context">The context.</param>
        /// <param name="result">The result.</param>
        /// <param name="request">The request.</param>
        /// <returns>The primary entity metadata.</returns>
        public override IEntityMetadata GetPrimaryEntityMetadata(ExecutionContext context, IExternalSearchQueryResult result, IExternalSearchRequest request)
        {
            var resultItem = result.As <CompanyNew>();

            return(CreateMetadata(resultItem));
        }
Exemplo n.º 14
0
        /// <summary>Gets the primary entity metadata.</summary>
        /// <param name="context">The context.</param>
        /// <param name="result">The result.</param>
        /// <param name="request">The request.</param>
        /// <returns>The primary entity metadata.</returns>
        public override IEntityMetadata GetPrimaryEntityMetadata(ExecutionContext context, IExternalSearchQueryResult result, IExternalSearchRequest request)
        {
            var resultItem = result.As <MappingResponse>();

            return(this.CreateMetadata(resultItem));
        }