Skip to content

Commit 2f8e0b5

Browse files
committed
Fallback to topic graph is GetAttributes() can't find AttributeDescriptor
Ideally, all `AttributeDescriptor`s will be available via as a result of the recent updates which update the cache of both `GetContentTypeDescriptors()` (a9ea634) and `ContentTypeDescriptor.AttributeDescriptors` (b0c5a5e) on `Save()`, `Delete()`, and `Move()`. When doing recusive `Save()`s of large topic graphs—as is common when importing data using the new **OnTopic Data Exchange**—it is possible, however, that the `AttributeDescriptors` cache will be out-of-date if a `ContentTypeDescriptor` has been updated in memory, but not persisted at the time that a dependency `Topic` tries to implement it. We face a similar issue with content types, and thus update the `GetContentTypeDescriptors()` reactively in `GetAttributes()` and `GetUnmatchedAttributes()` (408d01a). We can do something similar for `AttributeDescriptors` in `GetAttributes()`. This satisfies the attributes-related requirements of the newly proposed feature enhancement: Discover in-memory ContentTypeDescriptor, AttributeDescriptor on Save() (#18).
1 parent c0c8dd9 commit 2f8e0b5

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

OnTopic/Repositories/TopicRepositoryBase.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,12 @@ protected IEnumerable<AttributeValue> GetAttributes(Topic topic, bool? isExtende
492492
var key = attributeValue.Key;
493493
var attribute = (AttributeDescriptor?)null;
494494

495+
//Reset cached attribute descriptors just in case a new attribute has been added
496+
if (!contentType.AttributeDescriptors.Contains(key)) {
497+
contentType.ResetAttributeDescriptors();
498+
}
499+
500+
//Attempt to retrieve the corresponding attribute descriptor
495501
if (contentType.AttributeDescriptors.Contains(key)) {
496502
attribute = contentType.AttributeDescriptors[key];
497503
}

0 commit comments

Comments
 (0)