Question

I used the OWLGrinder to create the assembly and imported the library into my project. That works fine. Now I want to write my own set of classes. Therefore I extended these with the equivalent of the assembly. But it just doesn't work.

The ontology holds a class named ManagementObject.

I created another Class (C#) called RealWorldObject:

public class RealWorldObject : ManagementObject
    {
        public RealWorldObject(string uri) : base(uri) { }
        public RealWorldObject(string uri, RdfDocument rdfdocument) : base(uri, rdfdocument) { }
        public RealWorldObject(RdfDocument rdfdocument) : base(rdfdocument) { }

        public String getClassName()
        {
            return this.OwlClassName;
        }
        public static RdfDocument addRealWorldObjectIndividualt(RdfDocument rdfDocument)
        {
            Vehicle vehicle = new Vehicle("vehicle1", rdfDocument);

            FixedEvent fxE1 = new FixedEvent("autoGekauft", rdfDocument);
            fxE1.agent = new xmlns.com.foaf._01.Person("robert", rdfDocument);

            vehicle.hasFixedEvent = fxE1;

            return rdfDocument;
        }

Which leads to the error:

ObjectManagement.Object.RealWorldObject does declare one (and only one) OwlClassAttribute. This is an implementation bug of the plugin.

How else should I extend the generated classes by the OWLGrinder. Thx it is a long time ago that I used C#, so I'm kind of rusty.

Was it helpful?

Solution

The auto-generated classes produced by OwlGrinder.exe have not been designed for inheritance in mind. I am not saying it is wrong, it is just not designed for that. The auto-generated classes contain plenty of metadata defined as class attributes and inheritance hides all of that. The infrastructure counts on the presence of these attributes and if they are hidden, you get these runtime error messages.

Using Visual Studio Object Browser, take a look of the attributes over the auto-generated classes. OwlClassAttribute, SubClassOfAttribute, LightVersionAttribute are certainly mandatory. You may simply copy/paste the class attributes of ManagementObject on the top of your RealWorldObject class. I assume, it will work. But again, you might bump into additional show stoppers, as you do not follow the default routes ROWLEX has been designed for. This is a bit living on the edge :)

Instead of inheritance, you might consider reverse engineering your auto-generated assembly to C# using Reflector or other tools. Having the source code in your hand, you may modify the generated classes directly. You might make your ManagementObject class partial, and implement your additional methods in a separate file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top