This article is about the RDF Entity Framework. It shows you how to setup a basic entity model using Semantics.Server.
Setting up Semantics.Server
The first step to setting up an entity model is configuing a Semantics.Server database with
the graphs that you will need to hold your entity model. We will use the Semantics.Server API in the
Semantics.SDK to do this.
Create a provider graph that will hold the information about your model setup.
SemanticServerModel entityStore = new SemanticServerModel(ConnectionString);
entityStore.Graphs.CreateMultiGraph("http://entitystore/graph-provider");
Create a graph to hold the facts about the entity instances.
entityStore.Graphs.CreateGraph("http://entitystore/graph-fact");
Create a graph to hold facts about the ontology.
entityStore.Graphs.CreateGraph("http://entitystore/graph-ontology");
Create a rulebase for your CBD description type.
entityStore.Rulebases.CreateRulebase("http://entitystore/rulebase-cbd-description", EntityProviderRulebase.ConciseBoundedDescription);
Setting up the Entity Model
We will use the ModelSetup helper class to defined a entity model for the Semantics.Server database we just setup.
First we define a URI for our model.
ModelSetup modelSetup = new ModelSetup("http://entitystore/model/model-1");
Map the fact graph into the entity model. This connects the logic graph name with the physical name.
GraphSetup factGraph = new GraphSetup(EntityGraphUri.Fact, true);
factGraph.AddTarget("http://entitystore/graph-fact");
modelSetup.AddGraph(factGraph);
Map the ontology graph into the entity model.
GraphSetup ontologyGraph = new GraphSetup(EntityGraphUri.Ontology, true);
ontologyGraph.AddTarget("http://entitystore/graph-ontology");
modelSetup.AddGraph(ontologyGraph);
Map the description graph onto the fact graph since we are not using any other entity data graphs in this model.
GraphSetup descriptionGraph = new GraphSetup(EntityGraphUri.Description);
descriptionGraph.AddTarget("http://entitystore/graph-fact");
modelSetup.AddDefaultGraph(descriptionGraph);
Create a description type based on our CBD rules.
DescriptionTypeSetup cbdType = new DescriptionTypeSetup("http://entitystore/model/model-1/type-default");
cbdType.AddRulebase("http://entitystore/rulebase-cbd-description");
modelSetup.AddDefaultDescriptionType(cbdType);
Create the entity model.
SemanticServerProvider provider = new SemanticServerProvider(ConnectionString);
provider.Settings.ProviderGraphUri = "http://entitystore/graph-provider";
EntityModel model = modelSetup.CreateEntityModel(provider);
That's it.
0 comments:
Post a Comment