-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
341 additions
and
37 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @CluedIn-io/Back-End |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
### Fixes | ||
|
||
### Features | ||
+ Implement Provider Model AB#5044 |
52 changes: 52 additions & 0 deletions
52
...ternalSearch.Providers.KnowledgeGraph.Provider/KnowledgeGraphProviderProviderComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Reflection; | ||
using Castle.MicroKernel.Registration; | ||
using CluedIn.Core; | ||
using CluedIn.Core.Providers; | ||
using CluedIn.Core.Server; | ||
using CluedIn.ExternalSearch.Providers.KnowledgeGraph; | ||
using ComponentHost; | ||
using Constants = CluedIn.ExternalSearch.Providers.KnowledgeGraph.Constants; | ||
|
||
namespace CluedIn.Provider.KnowledgeGraph | ||
{ | ||
[Component(Constants.ComponentName, "Providers", ComponentType.Service, ServerComponents.ProviderWebApi, Components.Server, Components.DataStores, Isolation = ComponentIsolation.NotIsolated)] | ||
public sealed class KnowledgeGraphProviderProviderComponent : ServiceApplicationComponent<IServer> | ||
{ | ||
/********************************************************************************************************** | ||
* CONSTRUCTOR | ||
**********************************************************************************************************/ | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="KnowledgeGraphProviderProviderComponent" /> class. | ||
/// </summary> | ||
/// <param name="componentInfo">The component information.</param> | ||
public KnowledgeGraphProviderProviderComponent(ComponentInfo componentInfo) : base(componentInfo) | ||
{ | ||
// Dev. Note: Potential for compiler warning here ... CA2214: Do not call overridable methods in constructors | ||
// this class has been sealed to prevent the CA2214 waring being raised by the compiler | ||
Container.Register(Component.For<KnowledgeGraphProviderProviderComponent>().Instance(this)); | ||
} | ||
|
||
/********************************************************************************************************** | ||
* METHODS | ||
**********************************************************************************************************/ | ||
|
||
/// <summary>Starts this instance.</summary> | ||
public override void Start() | ||
{ | ||
var asm = Assembly.GetAssembly(typeof(KnowledgeGraphProviderProviderComponent)); | ||
Container.Register(Types.FromAssembly(asm).BasedOn<IProvider>().WithServiceFromInterface().If(t => !t.IsAbstract).LifestyleSingleton()); | ||
|
||
State = ServiceState.Started; | ||
} | ||
|
||
/// <summary>Stops this instance.</summary> | ||
public override void Stop() | ||
{ | ||
if (State == ServiceState.Stopped) | ||
return; | ||
|
||
State = ServiceState.Stopped; | ||
} | ||
} | ||
} |
123 changes: 123 additions & 0 deletions
123
src/ExternalSearch.Providers.KnowledgeGraph.Provider/KnowledgeGraphSearchProviderProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using CluedIn.Core; | ||
using CluedIn.Core.Crawling; | ||
using CluedIn.Core.Data.Relational; | ||
using CluedIn.Core.ExternalSearch; | ||
using CluedIn.Core.Providers; | ||
using CluedIn.Core.Webhooks; | ||
using CluedIn.ExternalSearch; | ||
using CluedIn.ExternalSearch.Providers.KnowledgeGraph; | ||
using CluedIn.Providers.Models; | ||
using Constants = CluedIn.ExternalSearch.Providers.KnowledgeGraph.Constants; | ||
|
||
namespace CluedIn.Provider.KnowledgeGraph | ||
{ | ||
public class KnowledgeGraphSearchProviderProvider : ProviderBase, IExtendedProviderMetadata, IExternalSearchProviderProvider | ||
{ | ||
public IExternalSearchProvider ExternalSearchProvider { get; } | ||
|
||
public KnowledgeGraphSearchProviderProvider([System.Diagnostics.CodeAnalysis.NotNull] ApplicationContext appContext) : base(appContext, GetMetaData()) | ||
{ | ||
ExternalSearchProvider = appContext.Container.ResolveAll<IExternalSearchProvider>().Single(n => n.Id == Constants.ProviderId); | ||
} | ||
|
||
private static IProviderMetadata GetMetaData() | ||
{ | ||
return new ProviderMetadata | ||
{ | ||
Id = Constants.ProviderId, | ||
Name = Constants.ProviderName, | ||
ComponentName = Constants.ComponentName, | ||
AuthTypes = new List<string>(), | ||
SupportsConfiguration = true, | ||
SupportsAutomaticWebhookCreation = false, | ||
SupportsWebHooks = false, | ||
Type = "Enricher" | ||
}; | ||
} | ||
|
||
public override async Task<CrawlJobData> GetCrawlJobData(ProviderUpdateContext context, IDictionary<string, object> configuration, Guid organizationId, Guid userId, Guid providerDefinitionId) | ||
{ | ||
if (configuration == null) | ||
throw new ArgumentNullException(nameof(configuration)); | ||
|
||
var result = new KnowledgeGraphExternalSearchJobData(configuration); | ||
|
||
return await Task.FromResult(result); | ||
} | ||
|
||
public override Task<bool> TestAuthentication(ProviderUpdateContext context, IDictionary<string, object> configuration, Guid organizationId, Guid userId, Guid providerDefinitionId) | ||
{ | ||
return Task.FromResult(true); | ||
} | ||
|
||
public override Task<ExpectedStatistics> FetchUnSyncedEntityStatistics(Core.ExecutionContext context, IDictionary<string, object> configuration, Guid organizationId, Guid userId, Guid providerDefinitionId) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
|
||
public override async Task<IDictionary<string, object>> GetHelperConfiguration(ProviderUpdateContext context, CrawlJobData jobData, Guid organizationId, Guid userId, Guid providerDefinitionId) | ||
{ | ||
if (jobData is KnowledgeGraphExternalSearchJobData result) | ||
{ | ||
return await Task.FromResult(result.ToDictionary()); | ||
} | ||
|
||
throw new InvalidOperationException($"Unexpected data type for KnowledgeGraphExternalSearchJobData, {jobData.GetType()}"); | ||
} | ||
|
||
public override Task<IDictionary<string, object>> GetHelperConfiguration(ProviderUpdateContext context, CrawlJobData jobData, Guid organizationId, Guid userId, Guid providerDefinitionId, string folderId) | ||
{ | ||
return GetHelperConfiguration(context, jobData, organizationId, userId, providerDefinitionId); | ||
} | ||
|
||
public override Task<AccountInformation> GetAccountInformation(Core.ExecutionContext context, CrawlJobData jobData, Guid organizationId, Guid userId, Guid providerDefinitionId) | ||
{ | ||
return Task.FromResult(new AccountInformation(providerDefinitionId.ToString(), providerDefinitionId.ToString())); | ||
} | ||
|
||
public override string Schedule(DateTimeOffset relativeDateTime, bool webHooksEnabled) | ||
{ | ||
return $"{relativeDateTime.Minute} 0/23 * * *"; | ||
} | ||
|
||
public override Task<IEnumerable<WebHookSignature>> CreateWebHook(Core.ExecutionContext context, CrawlJobData jobData, IWebhookDefinition webhookDefinition, IDictionary<string, object> config) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override Task<IEnumerable<WebhookDefinition>> GetWebHooks(Core.ExecutionContext context) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override Task DeleteWebHook(Core.ExecutionContext context, CrawlJobData jobData, IWebhookDefinition webhookDefinition) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override Task<CrawlLimit> GetRemainingApiAllowance(Core.ExecutionContext context, CrawlJobData jobData, Guid organizationId, Guid userId, Guid providerDefinitionId) | ||
{ | ||
if (jobData == null) throw new ArgumentNullException(nameof(jobData)); | ||
return Task.FromResult(new CrawlLimit(-1, TimeSpan.Zero)); | ||
} | ||
|
||
public override IEnumerable<string> WebhookManagementEndpoints(IEnumerable<string> ids) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override bool ScheduleCrawlJobs => false; | ||
public string Icon { get; } = Constants.Icon; | ||
public string Domain { get; } = Constants.Domain; | ||
public string About { get; } = Constants.About; | ||
public AuthMethods AuthMethods { get; } = Constants.AuthMethods; | ||
public IEnumerable<Control> Properties { get; } = Constants.Properties; | ||
public Guide Guide { get; } = Constants.Guide; | ||
public new IntegrationType Type { get; } = Constants.IntegrationType; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...nalSearch.Providers.KnowledgeGraph.Provider/Provider.ExternalSearch.KnowledgeGraph.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="CluedIn.Core" /> | ||
<PackageReference Include="ComponentHost" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\ExternalSearch.Providers.KnowledgeGraph\ExternalSearch.Providers.KnowledgeGraph.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using CluedIn.Core.Data.Relational; | ||
using CluedIn.Core.Providers; | ||
|
||
namespace CluedIn.ExternalSearch.Providers.KnowledgeGraph | ||
{ | ||
public static class Constants | ||
{ | ||
public const string ComponentName = "KnowledgeGraph"; | ||
public const string ProviderName = "Knowledge Graph"; | ||
public static readonly Guid ProviderId = Core.Constants.ExternalSearchProviders.GoogleKnowledgeGraphId; | ||
|
||
public static string About { get; set; } = "Knowledge Graph is an enricher which allows you to find entities using the Google Knowledge Graph API"; | ||
public static string Icon { get; set; } = "Resources.knowledge_graph.svg"; | ||
public static string Domain { get; set; } = "https://developers.google.com/knowledge-graph"; | ||
|
||
public static AuthMethods AuthMethods { get; set; } = new AuthMethods | ||
{ | ||
token = new List<Control>() | ||
{ | ||
|
||
} | ||
}; | ||
|
||
public static IEnumerable<Control> Properties { get; set; } = new List<Control>() | ||
{ | ||
// NOTE: Leaving this commented as an example - BF | ||
//new() | ||
//{ | ||
// displayName = "Some Data", | ||
// type = "input", | ||
// isRequired = true, | ||
// name = "someData" | ||
//} | ||
}; | ||
|
||
public static Guide Guide { get; set; } = null; | ||
public static IntegrationType IntegrationType { get; set; } = IntegrationType.Enrichment; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/ExternalSearch.Providers.KnowledgeGraph/Directory.Build.props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project> | ||
<Import Project="..\Directory.Build.props" /> | ||
|
||
<PropertyGroup> | ||
<IsTestProject>false</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
|
||
<!-- <RepositoryUrl>TODO</RepositoryUrl> --> | ||
<RepositoryType>git</RepositoryType> | ||
<PublishRepositoryUrl>true</PublishRepositoryUrl> | ||
|
||
<!-- Legacy NuGet symbols format, ref: https://docs.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg --> | ||
<SymbolPackageFormat>symbols.nupkg</SymbolPackageFormat> | ||
<IncludeSymbols>true</IncludeSymbols> | ||
|
||
</PropertyGroup> | ||
|
||
</Project> |
4 changes: 2 additions & 2 deletions
4
...nalSearch.Providers.KnowledgeGraph.csproj → ...nalSearch.Providers.KnowledgeGraph.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.