OWL/RDF to UML Converter - uml

I'm new to the concept of OWL/RDF ontologies and thinking it would useful to be able to convert them to UML so I could then generate class skeletons using my IDE. Assuming this is a reasonable thing to do, can you please recommend an approach?
I'm aware that there are OWL/RDF parsers like this one, but I can't find any that will convert to UML.
EDIT:
Based on the comments let me modify the question:
When starting a new project based on an existing ontology is there a way to easily create skeleton classes as a starting point? I do not need to synchronize changes between the ontology and the classes - it is a one time setup that I expect will take a significant amount of copy and paste which strikes me as the wrong approach.
If I'm not using ontologies correctly, can you please explain what their purpose is (if any) in designing class hierarchies?
Here's an example of what I want to implement (except this is only 1 sensor and I need to implement several):
http://www.w3.org/2005/Incubator/ssn/XGR-ssn-20110628/#Smart_product_example

To implement https://github.com/WolfgangFahl/pysotsog/issues/21 I created some conversion code see https://github.com/WolfgangFahl/pysotsog/blob/main/skg/dblp.py. It is currently for the dblp schema at:
https://dblp.org/rdf/schema and a conversion example is at:
plantum online dblp schema
/'
Wolfgang Fahl 2022-11-19
updated 2022-11-19
dblp schema https://dblp.org/rdf/schema
converted from owl to plantuml
'/
title dblp schema https://dblp.org/rdf/schema converted from owl to plantuml updated 2022-11-19
hide circle
package foaf {
class Document {
}
}
package dblp {
note top of AmbiguousCreator
Ambiguous Creator
Not an actual creator, but an ambiguous proxy for an unknown number of unrelated actual creators. Associated publications do not have their true creators determined yet.
end note
class AmbiguousCreator{
}
AmbiguousCreator--Creator:possibleActualCreator
Creator <|-- AmbiguousCreator
note top of Informal
Informal
An informal or other publication.
end note
class Informal{
}
Publication <|-- Informal
note top of Creator
Creator
A creator of a publication.
end note
class Creator{
primaryCreatorName:string
homepage:Document
creatorNote:string
orcid:anyUri
creatorName:string
affiliation:string
awardWebpage:Document
primaryAffiliation:string
primaryHomepage:Document
}
Creator--Publication:editorOf
Creator--AmbiguousCreator:proxyAmbiguousCreator
Creator--Creator:coCreatorWith
Creator--Creator:homonymousCreator
Creator--Publication:authorOf
Creator--Creator:coEditorWith
Creator--Publication:creatorOf
Creator--Creator:coAuthorWith
Entity <|-- Creator
note top of Publication
Publication
A publication.
end note
class Publication{
primarydocumentPage:Document
listedOnTocPage:Document
yearOfEvent:gYear
publishedBy:string
isbn:anyUri
publishersAddress:string
publicationNote:string
title:string
bibtexType:Entry
publishedInBookChapter:string
doi:anyUri
documentPage:Document
numberOfCreators:integer
publishedInSeries:string
publishedInSeriesVolume:string
publishedIn:string
pagination:string
yearOfPublication:gYear
monthOfPublication:string
publishedInJournalVolumeIssue:string
publishedInJournal:string
thesisAcceptedBySchool:string
publishedInJournalVolume:string
publishedInBook:string
}
Publication--Creator:createdBy
Publication--Creator:authoredBy
Publication--Creator:editedBy
Publication--Signature:hasSignature
Publication--Publication:publishedAsPartOf
Entity <|-- Publication
note top of Data
Data
Research data or artifacts.
end note
class Data{
}
Publication <|-- Data
note top of Person
Person
An actual person, who is a creator of a publication.
end note
class Person{
}
Creator <|-- Person
note top of AuthorSignature
Author Signaure
The information that links a publication to an author.
end note
class AuthorSignature{
}
Signature <|-- AuthorSignature
note top of Inproceedings
Inproceedings
A conference or workshop paper.
end note
class Inproceedings{
}
Publication <|-- Inproceedings
note top of Withdrawn
Withdrawn
A withdrawn publication item.
end note
class Withdrawn{
}
Publication <|-- Withdrawn
note top of EditorSignature
Editor Signaure
The information that links a publication to an editor.
end note
class EditorSignature{
}
Signature <|-- EditorSignature
note top of Editorship
Editorship
An edited publication.
end note
class Editorship{
}
Publication <|-- Editorship
note top of Incollection
Incollection
A part/chapter in a book or a collection.
end note
class Incollection{
}
Publication <|-- Incollection
note top of Reference
Reference
A reference work entry.
end note
class Reference{
}
Publication <|-- Reference
note top of Group
Group
A creator alias used by a group or consortium of persons.
end note
class Group{
}
Creator <|-- Group
note top of Signature
Signature
The information that links a publication to a creator.
end note
class Signature{
signatureOrcid:anyUri
signatureDblpName:string
signatureOrdinal:integer
}
Signature--Creator:signatureCreator
Signature--Publication:signaturePublication
note top of Book
Book
A book or a thesis.
end note
class Book{
}
Publication <|-- Book
note top of Entity
Entity
A general, identifiable entity in dblp.
end note
class Entity{
identifier:anyUri
wikipedia:Document
archivedWebpage:Document
wikidata:anyUri
webpage:Document
}
Thing <|-- Entity
note top of Article
Article
A journal article.
end note
class Article{
}
Publication <|-- Article
}
Just create an issue following the links in http://sotsog.bitplan.com if you'd like to get an online version.
https://github.com/WolfgangFahl/pysotsog/blob/main/skg/owl.py
https://github.com/WolfgangFahl/pysotsog/blob/main/skg/schema.py
have a more generic version as of 2023-01-08

Check for UML to OWL converter. It converts UML to RDF/OWL, so it does job in opposite direction, but it can be used as a template for your task. The converter is based on MDA approach, so requires knowledge of it (MOF, ODM, Eclipse EMF, ATL), which is worth to have.

My understanding is that the concept of the "semantic web" is still largely in the visionary stage and will not impact developers for some time. The initial applications seem to be centered around knowledge sharing between humans not machines. Hopefully it moves toward machine-to-machine sharing as there doesn't appear to be any interest in that at this time.

Related

UML - How to show a class instantiated by its static main method

It is a Sequence Diagram HowTo question, not a HowTo code.
I am using Visio 2010 and developing >> reverse engineering from Microsoft Dynamics AX 2012 / X++. Yes people its all about how to map static on UML.
My class is instantiated from FORM using at its void static main(). This calls another static method, say construct() which returns an instance of the same class.
I want to show the class (in static methods) and the resulting object separately some like the meta class runs (self msgs) and finally produces the class object which finally takes over. But how will a self msg call return a value ? How do I connect it with the resulting object of the class ? I hope I make enough sense to make you guys understand.
Note, the class is not a static class, but it has a static constructor.
If you want to depict a call to constructor (i.e. static operation that is responsible for creating an object and (usually) returning it as a reply) then you have to use a createMessage construct i.e. a dashed line with an open arrow and the word create on it. While this is not directly stated in specification, usually in such case the arrow points on the lifeline box (rectangle) rather than a line itself (however I've seen information that both notations are correct).
Note that in this case the logic of constructor is hidden (encapsulated) which is a good idea in general.
You can find more details in UML specification in section 17.4, especially 17.4.4.1 and an example in section 17.6.5 on Figure 17.14.
If you want to use a static operation other than constructor and call it without a use of class instance you have to model class as object (after all class is an object itself at least on analytical level). Note that the type of message can be either synchronous or asynchronous depending on your needs.
With this approach you can provide details on how the class handles this function (i.e. what other calls does it make).
For more details see "Applied UML and Patterns" by Craig Larman, section 15.4, Figure 15.20. Note however that Larman suggest a use of <<metaclass>> stereotype. Yet the called object is a class (metaclass is a class whose instance is class so this is not our case) so the stereotype should be <<class>>.

Do I Need To Make A Class Diagram For All Object Instances and Microsoft Methods That I Use?

I have the following classes made in C# in a program called MyGrades:
Menu.cs
Grade.cs
Student.cs
I have the following instances in my Student class:
private Grade test = new Grade(300);
private Grade hwQz = new Grade(700);
In Menu.cs I use the following Microsoft methods and Microsoft Class respectively:
Console.Clear()
Console.WriteLine()
Console.Write()
Console.ReadKey()
ConsoleKeyInfo key = Console.ReadKey();
In Grade.cs I use the following Microsoft methods:
Console.Clear()
Console.WriteLine()
Console.Write()
Console.ReadKey
Do I need to make class diagrams for Console as well as for all my class instances?
The programming language doesn't require you to draw a class diagram.
If your course instructor requires you to draw diagrams, you'll need to ask them exactly what they want.
Generally you should include other classes when they are relevant to understanding the diagram. It is not useful to have everything point to, say, the Logging class. If something especially interacts with the Console that might be relevant.

DDD - Invalidating expirable

Currently diving into DDD and i've read most of the big blue book of Eric Evans. Quite interesting so far :)
I've been modeling some aggregates where they hold a collection of entities which expire. I've come up with a generic approach of expressing that:
public class Expirable<T>
{
public T Value { get; protected set; }
public DateTime ValidTill { get; protected set; }
public Expirable(T value, DateTime validTill)
{
Value = value;
ValidTill = validTill;
}
}
I am curious what the best way is to invalidate an Expirable (nullify or omit it when working in a set). So far I've been thinking to do that in the Repository constructor since that's the place where you access the aggregates from and acts as a 'collection'.
I am curious if someone has come up with a solution to tackle this and I would be glad to hear it :) Other approaches are also very welcome.
UPDATE 10-1-2013:
This is not DDD with the CQRS/ES approach from Greg Young. But the approach Evans had, since I just started with the book and the first app. Like Greg Young said, if you have to make good tables, you have to make a few first ;)
There are probably multiple ways to approach this, but I, personally, would solve this using the Specification pattern. Assuming object expiration is a business rule that belongs in the domain, I would have a specification in addition to the class you have written. Here is an example:
public class NotExpiredSpecification
{
public bool IsSatisfiedBy(Expirable<T> expirableValue)
{
//Return true if not expired; otherwise, false.
}
}
Then, when your repositories are returning a list of aggregates or when performing any business actions on a set, this can be utilized to restrict the set to un-expired values which will make your code expressive and keep the business logic within the domain.
To learn more about the Specification pattern, see this paper.
I've added a method to my abstract repository InvalidateExpirable. An example would be the UserRepository where I remove in active user sessions like this: InvalidateExpirable(x => x.Sessions, (user, expiredSession) => user.RemoveSession(expiredSession));.
The signature of InvalidateExpirable looks like this: protected void InvalidateExpirable<TExpirableValue>(Expression<Func<T, IEnumerable<Expirable<TExpirableValue>>>> selector, Action<T, Expirable<TExpirableValue>> remover). The method itself uses reflection to extract the selected property from the selector parameter. That property name is glued in a generic HQL query which will traverse over the set calling the remove lambda. user.RemoveSession will remove the session from the aggregate. This way the I keep the aggregate responsible for it's own data. Also in RemoveSession an domain event is raised for future cases.
See: https://gist.github.com/4484261 for an example
Works quite well sofar, I have to see how it works further down in the application though.
Have been reading up on DDD with CQRS/ES (Greg Young approach) and found a great example on the MSDN site about CQRS/ES: http://msdn.microsoft.com/en-us/library/jj554200.aspx
In this example they use the command message queue to queue a Expire message in the future, which will call the Aggregate at the specified time removing/deactivate the expirable construct from the aggregate.

DDD Using Specification pattern for Validation

I am thinking of using Specification pattern for validation purposes. The hard thing is how to tell the user why some Specification was not satisfied. What if the Specification.IsSatisfiedBy() will not only return a bool value, but also the reason of failure. It would look something like this:
interface ISpecification<T>
{
CheckResult IsSatisfiedBy(T candidate);
}
where CheckResult is:
class CheckResult
{
public bool IsSatisfied { get; }
public string FailureReason { get; }
}
In Fowler & Evans work there is a concept of Partially Satisfied Specification whose purpose is to provide explanation what exactly was not satisfied. However in that document, it is implemented as additional method remainderUnsatisfiedBy which returns the Specification which was not accomplished by the Candidate.
So the question is: When using Specification for validation purposes, how to provide feedback to user that a given Specification was not satisfied? Is the solution I've presented above good?
Although you may use your Specifications classes for validation, I would suggest you keep them as separate concepts within your domain. You may find that you need to re-use the same underlying specifications but need to return different "Failure Reasons" depending on purpose and context. See this article for more details.
The author of the post referenced above has also kindly shared code to github and posted the code as NCommon. Review these areas in particular:
Specifications: https://github.com/riteshrao/ncommon/tree/v1.2/NCommon/src/Specifications
Validations: https://github.com/riteshrao/ncommon/tree/v1.2/NCommon/src/Rules (especially the classes for ValidationResult and ValidationError)
I had the same problem. I create Validation decorator for Specification (code is JAVA).
interface Validator<T>{
Respond validate(T t)
}
class abstract ValidationSpecificationDecorator<T> implements Validator<T> {
Specification<T> spec;
ValidationSpecificationDecorator(Specification<T> spec){
this.spec = spec;
}
public Respond validate(T t) {
Respond respond = new Respond();
if(!spec.IsSatisfiedBy(t){
respond.add(error(t));
}
return respond;
)
public abstract Error error(T t);
}
Not sure about your language, but in Scala there is a concept (structure): Either[A,B]
And in calculations you either return right side (B) - for successful validation (object satisfy business rule) or left side (A) to express reason of failed validation for a given business object.
For the Specification purpose, you could return (for A type) e.g. String (as an error message) or some objects/enums (or anything which is appropriate in your language) representing business reason of why specified object didn't satisfy the specification.
It's similar to your solution but more functional and robust.

Difference between association and dependency?

In a UML class diagram, what is the difference between an association relationship and a dependency relationship?
From what I know, an association is a stronger relationship than a dependency, but I'm not sure how it is stronger.
Any example would be more than welcome :)
An association almost always implies that one object has the other object as a field/property/attribute (terminology differs).
A dependency typically (but not always) implies that an object accepts another object as a method parameter, instantiates, or uses another object. A dependency is very much implied by an association.
In OOP terms:
Association --> A has-a C object (as a member variable)
Dependency --> A references B (as a method parameter or return type)
public class A {
private C c;
public void myMethod(B b) {
b.callMethod();
}
}
There is also a more detailed answer.
What is the difference between dependency and association?:
In general, you use an association to represent something like a field
in a class. The link is always there, in that you can always ask an
order for its customer. It need not actually be a field, if you are
modeling from a more interface perspective, it can just indicate the
presence of a method that will return the order's customer.
To quote from the 3rd edition of UML Distilled (now just out) "a
dependency exists between two elements if changes to the definition of
one element (the supplier) may cause changes to the other (the
client)". This is a very vague and general relationship, which is why
the UML has a host of stereotypes for different forms of dependency.
In code terms, such things as naming a parameter type and creating an
object in a temporary variable imply a dependency.
...
Dependency is like when you define a method that takes a String(in Java, C#, as string is a object in them) as a parameter, then your class is dependent on String class.
Association is like when you declare a string as an attribute in your class.
then your code is associated with the string class.
String name = null //: is a association.
Dependency - A change in a class affects the change in it's dependent class. Example- Circle is dependent on Shape (an interface). If you change Shape , it affects Circle too. So, Circle has a dependency on Shape.
Association- means there is a certain relationship between 2 objects
(one-one, one-many,many-many)
Association is of 2 types-
Composition
Aggregation
1) Composition- stronger Association or relationship between 2 objects. You are creating an object of a class B inside another class A
public class A {
B b;
public void setB(){
this.b= new B();
}
}
If we delete class A , B won't exist( B object is created inside A only).
Another example -Body & Liver .Liver can't exist outside Body.
2) Aggregation - weaker type of Association between 2 objects.
public class A {
B b;
public void setB(B b_ref){
this.b= b_ref;
/* object B is passed as an argument of a method */
}
}
Even if you delete class A, B will exist outside(B is created outside and passed to Class A)
Another example of this- Man & Car . Man has a Car but Man & Car exist independently.
Here: "Association vs. Dependency vs. Aggregation vs. Composition", you have a great vade mecum with uml class diagrams and code snippets.
The author gives us a list of relationships: Association, Dependency, Aggregation, Composition in one place.
A dependency is very general and lowering complexity is about diminishing dependencies as much as possible.
An association is a strong (static) dependency. Aggregation and Composition are even stronger.
I was always checking this answer as it didn't stick in my mind. I found this one more helpful after reading the accepted answer
Association is when one object just has a link to another and don't use relational object methods. For ruby for example
class User
has_one :profile
end
user = User.first
profile = user.profile
profile.sign_out
It means you can get a profile object from user but user don't use profile's methods inside himself(has no dependency on a Profile's interface).
Dependency means that User has link to another object and call that object's methods inside himself
class User
has_one :profile
def personal_info
profile.info
end
end
Here if Profile's info method will be changed or renamed our Dependent User class also need to be changed.

Resources