Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions admin-ui/src/main/java/eu/knowledge/engine/admin/MetadataKB.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,20 @@ public MetadataKB(String id, String name, String description) {
this.metaGraphPattern = new GraphPattern(this.prefixes, META_GRAPH_PATTERN_STR);

// create the correct Knowledge Interactions
this.aKI = new AskKnowledgeInteraction(new CommunicativeAct(), this.metaGraphPattern, null, false, true,
false, MatchStrategy.ENTRY_LEVEL);
this.aKI = new AskKnowledgeInteraction(new CommunicativeAct(), this.metaGraphPattern, "ask-metadata", false,
true, false, MatchStrategy.ENTRY_LEVEL);
this.rKINew = new ReactKnowledgeInteraction(
new CommunicativeAct(new HashSet<Resource>(Arrays.asList(Vocab.NEW_KNOWLEDGE_PURPOSE)),
new HashSet<Resource>(Arrays.asList(Vocab.INFORM_PURPOSE))),
this.metaGraphPattern, null);
this.metaGraphPattern, null, "react-to-new-metadata");
this.rKIChanged = new ReactKnowledgeInteraction(
new CommunicativeAct(new HashSet<Resource>(Arrays.asList(Vocab.CHANGED_KNOWLEDGE_PURPOSE)),
new HashSet<Resource>(Arrays.asList(Vocab.INFORM_PURPOSE))),
this.metaGraphPattern, null);
this.metaGraphPattern, null, "react-to-changed-metadata");
this.rKIRemoved = new ReactKnowledgeInteraction(
new CommunicativeAct(new HashSet<Resource>(Arrays.asList(Vocab.REMOVED_KNOWLEDGE_PURPOSE)),
new HashSet<Resource>(Arrays.asList(Vocab.INFORM_PURPOSE))),
this.metaGraphPattern, null);
this.metaGraphPattern, null, "react-to-removed-metadata");

// register the knowledge interactions with the smart connector.
this.register(this.aKI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,32 +95,32 @@ public MetaKnowledgeBaseImpl(LoggerProvider loggerProvider, MessageRouter aMessa
(anAKI, anAnswerExchangeInfo) -> this.fillMetaBindings(anAnswerExchangeInfo.getIncomingBindings()),
true);

this.metaAskKI = new AskKnowledgeInteraction(new CommunicativeAct(), this.metaGraphPattern, null, true, true, false,
MatchStrategy.ENTRY_LEVEL);
this.metaAskKI = new AskKnowledgeInteraction(new CommunicativeAct(), this.metaGraphPattern, null, true, true,
false, MatchStrategy.ENTRY_LEVEL);
this.knowledgeBaseStore.register(this.metaAskKI, true);

this.metaPostNewKI = new PostKnowledgeInteraction(
new CommunicativeAct(new HashSet<>(Arrays.asList(Vocab.INFORM_PURPOSE)),
new HashSet<>(Arrays.asList(Vocab.NEW_KNOWLEDGE_PURPOSE))),
this.metaGraphPattern, null, null, true, true, MatchStrategy.ENTRY_LEVEL);
this.metaGraphPattern, null, "post-new", true, true, MatchStrategy.ENTRY_LEVEL);
this.knowledgeBaseStore.register(this.metaPostNewKI, true);

this.metaPostChangedKI = new PostKnowledgeInteraction(
new CommunicativeAct(new HashSet<>(Arrays.asList(Vocab.INFORM_PURPOSE)),
new HashSet<>(Arrays.asList(Vocab.CHANGED_KNOWLEDGE_PURPOSE))),
this.metaGraphPattern, null, null, true, true, MatchStrategy.ENTRY_LEVEL);
this.metaGraphPattern, null, "post-changed", true, true, MatchStrategy.ENTRY_LEVEL);
this.knowledgeBaseStore.register(this.metaPostChangedKI, true);

this.metaPostRemovedKI = new PostKnowledgeInteraction(
new CommunicativeAct(new HashSet<>(Arrays.asList(Vocab.INFORM_PURPOSE)),
new HashSet<>(Arrays.asList(Vocab.REMOVED_KNOWLEDGE_PURPOSE))),
this.metaGraphPattern, null, null, true, true, MatchStrategy.ENTRY_LEVEL);
this.metaGraphPattern, null, "post-removed", true, true, MatchStrategy.ENTRY_LEVEL);
this.knowledgeBaseStore.register(this.metaPostRemovedKI, true);

this.metaReactNewKI = new ReactKnowledgeInteraction(
new CommunicativeAct(new HashSet<>(Arrays.asList(Vocab.NEW_KNOWLEDGE_PURPOSE)),
new HashSet<>(Arrays.asList(Vocab.INFORM_PURPOSE))),
this.metaGraphPattern, null, null, true, true, MatchStrategy.ENTRY_LEVEL);
this.metaGraphPattern, null, "react-new", true, true, MatchStrategy.ENTRY_LEVEL);
this.knowledgeBaseStore.register(this.metaReactNewKI, (aRKI, aReactExchangeInfo) -> {
var postingKi = aReactExchangeInfo.getPostingKnowledgeInteractionId();
var itShouldBeThis = this.knowledgeBaseStore.getMetaId(aReactExchangeInfo.getPostingKnowledgeBaseId(),
Expand All @@ -140,7 +140,7 @@ public MetaKnowledgeBaseImpl(LoggerProvider loggerProvider, MessageRouter aMessa
this.metaReactChangedKI = new ReactKnowledgeInteraction(
new CommunicativeAct(new HashSet<>(Arrays.asList(Vocab.CHANGED_KNOWLEDGE_PURPOSE)),
new HashSet<>(Arrays.asList(Vocab.INFORM_PURPOSE))),
this.metaGraphPattern, null, null, true, true, MatchStrategy.ENTRY_LEVEL);
this.metaGraphPattern, null, "react-changed", true, true, MatchStrategy.ENTRY_LEVEL);
this.knowledgeBaseStore.register(this.metaReactChangedKI, (aRKI, aReactExchangeInfo) -> {
var postingKi = aReactExchangeInfo.getPostingKnowledgeInteractionId();
var itShouldBeThis = this.knowledgeBaseStore.getMetaId(aReactExchangeInfo.getPostingKnowledgeBaseId(),
Expand All @@ -160,7 +160,7 @@ public MetaKnowledgeBaseImpl(LoggerProvider loggerProvider, MessageRouter aMessa
this.metaReactRemovedKI = new ReactKnowledgeInteraction(
new CommunicativeAct(new HashSet<>(Arrays.asList(Vocab.REMOVED_KNOWLEDGE_PURPOSE)),
new HashSet<>(Arrays.asList(Vocab.INFORM_PURPOSE))),
this.metaGraphPattern, null, null, true, true, MatchStrategy.ENTRY_LEVEL);
this.metaGraphPattern, null, "react-removed", true, true, MatchStrategy.ENTRY_LEVEL);
this.knowledgeBaseStore.register(this.metaReactRemovedKI, (aRKI, aReactExchangeInfo) -> {
var postingKi = aReactExchangeInfo.getPostingKnowledgeInteractionId();
var itShouldBeThis = this.knowledgeBaseStore.getMetaId(aReactExchangeInfo.getPostingKnowledgeBaseId(),
Expand Down Expand Up @@ -410,8 +410,8 @@ private OtherKnowledgeBase constructOtherKnowledgeBaseFromBindingSet(BindingSet
var kiMeta = model.listObjectsOfProperty(ki, Vocab.IS_META).next();

boolean isMeta = kiMeta.asLiteral().getBoolean();
assert isMeta == kiMeta.toString().contains("true")
: "If the text contains 'true' (=" + kiMeta + ") then the boolean should be true.";
assert isMeta == kiMeta.toString().contains("true") : "If the text contains 'true' (=" + kiMeta
+ ") then the boolean should be true.";

this.LOG.trace("meta: {} = {}", FmtUtils.stringForNode(kiMeta.asNode()), isMeta);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import eu.knowledge.engine.smartconnector.api.GraphPattern;
import eu.knowledge.engine.smartconnector.api.MatchStrategy;
import eu.knowledge.engine.smartconnector.api.Vocab;
import eu.knowledge.engine.smartconnector.impl.SmartConnectorImpl;

public class KnowledgeNetwork {

Expand Down Expand Up @@ -77,7 +78,7 @@ private void startAndWaitForReady() {

// register our state check Knowledge Interaction on each Smart Connecotr
GraphPattern gp = new GraphPattern(this.prefixMapping,
// @formatter:off
// @formatter:off
"?kb rdf:type kb:KnowledgeBase .", "?kb kb:hasName ?name .", "?kb kb:hasDescription ?description .",
"?kb kb:hasKnowledgeInteraction ?ki .", "?ki rdf:type ?kiType .", "?ki kb:isMeta ?isMeta .",
"?ki kb:hasCommunicativeAct ?act .", "?act rdf:type kb:CommunicativeAct .",
Expand Down Expand Up @@ -156,4 +157,17 @@ public CompletableFuture<Void> stop() {
this.knowledgeBases.clear();
return CompletableFuture.allOf(kbStoppedFutures.toArray(new CompletableFuture<?>[kbStoppedFutures.size()]));
}

/**
* Removes the given KB from this network object, but does not stop it.
*
* It can be stopped manually using the {@link SmartConnectorImpl#stop()}
* method.
*
* @param aKb An existing knowledge base that should be removed.
*/
public void removeKB(KnowledgeBaseImpl aKb) {
this.knowledgeInteractionMetadata.remove(aKb);
this.knowledgeBases.remove(aKb);
}
}