Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExtractOwnershipProcessor"/> class.
 /// </summary>
 /// <param name="db">Joseki database implementation.</param>
 /// <param name="cache">Ownership in memory cache.</param>
 public ExtractOwnershipProcessor(JosekiDbContext db, IOwnershipCache cache)
 {
     this.db    = db;
     this.cache = cache;
     this.jsonSerializerSettings = new JsonSerializerSettings
     {
         NullValueHandling     = NullValueHandling.Ignore,
         MissingMemberHandling = MissingMemberHandling.Ignore,
     };
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="GetComponentDetailsHandler"/> class.
 /// </summary>
 /// <param name="db">Joseki database object.</param>
 /// <param name="cache">Score cache.</param>
 /// <param name="docsHandler">Knowledgebase items handler.</param>
 /// <param name="ownershipCache">Ownership cache using OwnershipEntity.</param>
 public GetComponentDetailsHandler(
     JosekiDbContext db,
     IInfrastructureScoreCache cache,
     GetKnowledgebaseItemsHandler docsHandler,
     IOwnershipCache ownershipCache)
 {
     this.db             = db;
     this.cache          = cache;
     this.docsHandler    = docsHandler;
     this.ownershipCache = ownershipCache;
 }
Esempio n. 3
0
        /// <summary>
        /// Returns an owner using a componentId.
        /// Uses IOwnershipCache to speed up lookup.
        /// </summary>
        /// <param name="cache">IOwnershipCache is cached Ownership table.</param>
        /// <param name="componentId">Id string of the component.</param>
        /// <returns>String as owner (email).</returns>
        public static async Task <string> GetOwner(this IOwnershipCache cache, string componentId)
        {
            var entries = await cache.GetEntries();

            IComponentId id = ComponentId.ComponentIdFactory(componentId);

            // more detailed component Id should be selected,
            // for this reason we first query the identity on object level.
            var objectOwner = entries.FirstOrDefault(x => x.ComponentId == id.ObjectLevel);

            if (!objectOwner.Equals(default) && !string.IsNullOrEmpty(objectOwner.Owner))
 /// <summary>
 /// Initializes a new instance of the <see cref="GetOverviewDetailsHandler"/> class.
 /// </summary>
 /// <param name="db">Joseki database object.</param>
 /// <param name="ownershipCache">Ownership cache using OwnershipEntity.</param>
 public GetOverviewDetailsHandler(JosekiDbContext db, IOwnershipCache ownershipCache)
 {
     this.db             = db;
     this.ownershipCache = ownershipCache;
 }