i am using protege 4 to create an ontology
if the question was not clear, here is an example :
Superclass is (thing)
Subclasses are as follow
(company) that has two data properties (company name) & (company abbreviation)
(social network)
(service)
an instance of company class is (macintosh) that has two data properties (macintosh) & (MAC)
an instance of social network class is (facebook)
an instance of service class is (adsence)
1# i want to say that mac has a logo
and facebook has a logo
so, logo has to be a class ? and if , how to relate an individual to a class by a relation ? is this possible to do ?
2# how to relate two individuals by a relation in protege ?
1
logo is a data property because logo itself has no properties and relations. It only has a value.
2
You will have to relate them while defining their classes first. Properties relate different classes. after that when you create an individual you will see a properties assertions panel. in this panel you can define relationships.
2
In Protégé 5 you can relate two individuals by going to the Class Expression editor of a selected individual and type:
<property> some {<individual>}
or
<property> value <individual>
For instance
hasPet value Tibbs
Where Tibbs is a specific individual.
Reference: http://protegeproject.github.io/protege/class-expression-syntax/
Related
Hi I have a simple problem.
My domain class is like this:
class Example {
long seq
hasMany = [example_array: ExampleData]
long count
}
class ExampleData {
String type
long description
static belongsTo = Example
static constraints = {
}
}
This results in 3 tables, like a many to many relation.
Why is this?
Thanks
The reason for the extra table is that you've modeled the relation only in one direction - an Example can access its ExampleData instances via the example_array Set that's added to your class bytecode because of the hasMany property, but an ExampleData instance has no way to reference its owning Example.
You added a belongsTo property, but only specified the class name. That's sufficient to configure ownership, cascaded deletes, etc. but doesn't provide a property in the class to access the Example instance.
If you change it to the other supported syntax it will work as you expected:
static belongsTo = [example: Example]
Here example will end up being the name of an Example property (and you can change it and/or example_array to any valid property name), which is basically the same as declaring
Example example
Now that both sides can access the other, the relationship is bidirectional and you no longer need the third table. That's because a 1-many is typically implemented using a foreign key in the child table, in this case in the table for ExampleData that points to the table for Example. That wasn't possible without a property in the class to wire up to that column, so the join table was necessary.
I believe that you have to map the BelongsTo, like this:
static belongsTo = [example:Example]
Hope it helps :)
From the definition of hasMany Grails will, by default, map this kind of relationship with a join table.That join table is the 3rd table you mentioned.No need to worry about that.
Well the one-to-many relationship is constructed by having additional table (i.e. Example_ExampleData) containing two columns each id fields from tables of the entities forming the relationship(i.e. Example and ExampleData).
The newly added table is child to parent tables – Example and ExampleData.
So in your case when you run your application the 3rd table gets created by Grails by default as your table relationship falls under the one-to-many relationship.
I have a bunch of questions regarding Java 8 and SDN4. I created a model in Neo4j v3.0, played a bit with Cypher queries, and now moved to creating a Spring Boot application. As i started coding classes in Java, I've begun to rethink some of my model as well. Here's some questions in my mind (and I haven't found an example explaining this):
Do you need to use Interfaces in Java, with SDN?For eg. I'd code a Product interface and then have my products implement it, but is that how it's done when working with labels?
This is somewhat tied to my question on inheritance - I'd usually have a ProductFamily that my Product would inherit from. At the database level its modeled as (:Product)-[PartOf]->(:ProductFamily), but in the code these would not be super/sub class.
Any examples of using Generics in a graph context?
Is there a way to define constraints on what relationships a node can have and their direction in Java?
I understand there is probably not one right answer, but there's precious little on the web, so hope to get enlightened here!
If you had a Product interface annotated with #NodeEntity, then the you'll have the Product label in addition to the label on your implementing class, which I assume is what you want. If your interface isn't annotated, then your implementing classes will not inherit a label from it.
Not sure what you mean- if you say you have a ProductFamily that Product inherits from, but in the code it would not be a super/sub class?
Based on your graph model, if you want (:Product)-[PartOf]->(:ProductFamily) then you will have a Product class that maintains a reference to a ProductFamily class, and that reference annotated with #Relationship. If the Product class inherits from ProductFamily then persisting the Product will result in two labels- Product and ProductFamily because a Product IS-A ProductFamily.
How do you see yourself using generics- the answer really depends on that. Some cases are supported, some are not (an example of something not supported right now is equivalent of template.createRelationBetween in SDN4)
Yes, via the #Relationship annotation which accepts a type and direction. Note that this annotation only constrains your domain model, but you could very well flout this by creating relationships in another direction via a custom query.
My Grails domain model consists of something like the following:
Competition - with name String property
Club - with name String property
Team - with club and competition properties
Game - with teamOne and teamTwo properties
I'm looking to create a Game form that contains the following:
a competition drop-down
a team one drop-down
a team two drop-down
For my team drop-downs though I wish to just have a list of Club names e.g. ${Club.all}
However, I then wish to have some interceptor that will use the Competition and Club name to construct the appropriate Team before the Game entity is constructed
I do not wish to introduce any Ajax/Javascript to my application, I want to keep the UI work as minimal as possible.
How can I achieve this?
You could use the beforeInterceptor available in controllers. I'm not exactly sure if this is what you are looking for, but it sounds like you can do what you describe.
I am using Protege 5.0.0 for developing an ontology. Part of the Ontology is shown in figure at the link:
http://imgur.com/Yq6EF3i
For the given Ontology I have created classes OperatingRange,OperatingPowerRange,and ValueRange. Also, properties hasOperatingProperty, hasValue and other properties are created. I am facing problem in the following:
For ssn:hasOperatingProperty, I am using OpertingRange class as domain and ssn:OperatingPowerRange class as range.Now, according to figure should I set ssn:hasOperatingProperty as domain for ssn:hasValue? I tried to do the same but Protege is not showing any option for this.
What is the meaning of "can be" and "all of" written below some properties in the above figure?
For the unitOfMeasure property should I set ssn:hasvalue as domain and unit:Volt as range?
I believe the pattern:
'propertyName'
can be
one of
'className'
is a way to represent restrictions, which are class expressions, and should be read as: at least one object property assertion with property 'propertyName' exists, and the individual in that assertion is an instance of 'className'.
'can be' and 'one of' are to be read as 'can be one of' - meaning an existential quantification. 'can be' 'all of' is universal quantification.
Regarding unitOfMeasure, you cannot have a property as a domain for another property, unless the second property (hasValue in your case) is an annotation property. Using unit:Volt as range sounds correct.
Edit: to answer the comment, you need to add a class expression do the domain. In Protege you do this by clicking on the domain tab, and choosing the type of restriction, the property along which it acts and the type you expect to be a filler (can be Thing). See the picture for reference.
Is there a way to add more belongs-to relationships to an imported GORM domain class? Specifically, I'm attempting to use table-per-class to extend a shared subclass, but if I do this in two (or more) locations, and the locations do not have knowledge of each-other then things like:
set.addToParents(parentSet)
Start leading to:
org.hibernate.WrongClassException: Object [id=3482] was not of the specified subclass [com.acumenllc.domaincore.DbSet] : Discriminator: com.acumenllc.tickets.domain.TicketSet
happening everywhere.
A little more background, I'm working on a closure table to keep track of related objects. The base class recognizes the parent-child bi-directional relationship, as well as the ancestor-descendant extension of it. Different applications then extend this class with belongsTo relationships on objects to be represented as nodes in the resultant graph. We specifically want to be able to more-or-less ignore some of these other classes in other applications that happen to share the same database.
Ideally, it would be possible to import our base domain class into a new application and, rather than extending into a subclass, re-define the set of relationships that the base class recognizes in the scope of the application.
The only practical way I can see of doing this is with .hbm.xml files. The GORM approach of including hasMany/belongsTo in the code and JPA's approach using annotations are both fairly inflexible to support this sort of mapping. But if you separate the configuration from the code, you can define the relationships for different applications however you like. Creating a hibernate.cfg.xml file and the hbm.xml files is described here in the docs.