/*********************************************************************/ /* */ /* AgentService Framework */ /* www.agentservice.it */ /* */ /* Copyright (C) 2007 l.i.d.o. - DIST, University of Genoa, Italy */ /* GNU Lesser General Public License */ /* */ /* This library is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU Lesser General Public */ /* License as published by the Free Software Foundation, */ /* version 2.1 of the License. */ /* */ /* This library is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ /* Lesser General Public License for more details. */ /* */ /* You should have received a copy of the GNU Lesser General Public */ /* License along with this library; if not, write to the */ /* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */ /* Boston, MA 02111-1307, USA. */ /* */ /*********************************************************************/ using System; using System.Collections; using AgentService.Ontology.Schema; using System.IO; namespace AgentService.Ontology { /// /// This class provides a detailed description of a given ontology. /// public class OntologyDescriptor { private Ontology onto; private ArrayList concepts = new ArrayList(); private ArrayList agentActions = new ArrayList(); private ArrayList aggregates = new ArrayList(); private ArrayList ires = new ArrayList(); private ArrayList predicates = new ArrayList(); private ArrayList primitives = new ArrayList(); private ArrayList terms = new ArrayList(); private ArrayList variables = new ArrayList(); private ArrayList contents = new ArrayList(); private string ontologyPath = null; private string ontologyName = null; private ArrayList bases = new ArrayList(); private string version=null; private ArrayList domain = new ArrayList(); private ArrayList sourceLanguages = new ArrayList(); /// /// Constructs an ontology descriptor. /// public OntologyDescriptor() { this.onto=null; } /// /// Constructs an ontology descriptor. /// /// The ontology that must be described. public OntologyDescriptor(Ontology onto) { this.onto=onto; this.ClassifyEntities(this.onto); this.ontologyName = onto.GetName(); foreach(Ontology o in onto.BaseOntologies) { this.bases.Add(o); this.ClassifyEntities(o); } } /// /// Constructs an ontology descriptor. /// /// The ontology that must be described. /// The full path of the .dll containing the ontology. public OntologyDescriptor(Ontology onto, string path): this(onto) { this.ontologyPath=Path.GetFullPath(path); } /// /// Constructs an ontology descriptor. /// /// The ontology that must be described. /// The full path of the .dll containing the ontology. /// The version of the ontology. public OntologyDescriptor(Ontology onto, string path, string version): this(onto, path) { this.version=version; } /// /// Constructs an ontology descriptor. /// /// The ontology that must be described. /// The full path of the .dll containing the ontology. /// The version of the ontology. /// A list of application domains in which the ontology is applicable. public OntologyDescriptor(Ontology onto, string path, string version, ArrayList domain): this(onto,path,version) { this.domain=domain; } /// /// Constructs an ontology descriptor. /// /// The ontology that must be described. /// The full path of the .dll containing the ontology. /// The version of the ontology. /// A list of application domains in which the ontology is applicable. /// A list of languages in which the ontology is represented. public OntologyDescriptor(Ontology onto, string path, string version, ArrayList domain, ArrayList languages): this(onto,path,version,domain) { this.sourceLanguages=languages; } /// /// The described ontology. /// public Ontology Ontology { /*set { this.onto=value; }*/ get { return this.onto; } } /// /// Searches and classifies all entities of the current ontology. /// /// The ontology to describe. private void ClassifyEntities(Ontology onto) { foreach(ObjectSchema o in onto.Elements.Values) { string typeName = o.GetTypeName().ToLower(); if(o is ConceptSchema) { this.concepts.Add(new EntityDescriptor(typeName, onto.Classes[typeName].GetType(), o)); } if(o is AgentActionSchema) { this.agentActions.Add(new EntityDescriptor(typeName, onto.Classes[typeName].GetType(), o)); } if(o is AggregateSchema) { this.aggregates.Add(new EntityDescriptor(typeName, onto.Classes[typeName].GetType(), o)); } if(o is IRESchema) { this.ires.Add(new EntityDescriptor(typeName, onto.Classes[typeName].GetType(), o)); } if(o is PredicateSchema) { this.predicates.Add(new EntityDescriptor(typeName, onto.Classes[typeName].GetType(), o)); } if(o is PrimitiveSchema) { this.primitives.Add(new EntityDescriptor(typeName, onto.Classes[typeName].GetType(), o)); } if(o is TermSchema) { this.terms.Add(new EntityDescriptor(typeName, onto.Classes[typeName].GetType(), o)); } if(o is VariableSchema) { this.variables.Add(new EntityDescriptor(typeName, onto.Classes[typeName].GetType(), o)); } if(o is ContentElementSchema || o is AgentActionSchema || o is IRESchema) { this.contents.Add(new EntityDescriptor(typeName, onto.Classes[typeName].GetType(), o)); } } } /// /// A list of the concepts of the ontology. /// public ArrayList Concepts { get { return this.concepts; } /*set { this.concepts = value; }*/ } /// /// A list of the agent actions of the ontology. /// public ArrayList AgentActions { get { return this.agentActions; } /*set { this.agentActions = value; }*/ } /// /// A list of the aggregates of the ontology. /// public ArrayList Aggregates { get { return this.aggregates; } /*set { this.aggregates = value; }*/ } /// /// A list of the IREs of the ontology. /// public ArrayList IREs { get { return this.ires; } /*set { this.ires = value; }*/ } /// /// A list of the predicates of the ontology. /// public ArrayList Predicates { get { return this.predicates; } /*set { this.predicates = value; }*/ } /// /// A list of the primitives of the ontology. /// public ArrayList Primitives { get { return this.primitives; } /*set { this.primitives = value; }*/ } /// /// A list of the terms of the ontology. /// public ArrayList Terms { get { return this.terms; } /*set { this.terms = value; }*/ } /// /// A list of the variables of the ontology. /// public ArrayList Variables { get { return this.variables; } /*set { this.variables = value; }*/ } /// /// A list of the content elements of the ontology. /// public ArrayList Contents { get { return this.contents; } /*set { this.contents = value; }*/ } /// /// The path of the dll containing the ontology. /// public string OntologyPath { set { this.ontologyPath=Path.GetFullPath(value); } /*get { return this.ontologyPath; }*/ } /// /// The name of the ontology. /// public string OntologyName { get { return this.ontologyName; } /*set { this.ontologyName = value; }*/ } /// /// A list of base ontologies. /// public ArrayList BaseOntologies { get { return this.bases; } /*set { this.BaseOntologies = value; }*/ } /// /// The version of the ontology. /// public string Version { get { return this.version; } } /// /// A list of application domains in which the ontology is applicable. /// public ArrayList Domain { get { return this.domain; } } /// /// A list of languages in which the ontology is represented. /// public ArrayList SourceLanguages { get { return this.sourceLanguages; } } } }