/*********************************************************************/ /* */ /* 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 AgentService.Ontology; using AgentService.Ontology.Schema.Abstract; using System; using AgentService.Ontology.Validation; namespace AgentService.Ontology.Schema { /// /// AggregateSchema is the schema of aggregate entities in an ontology. /// public class AggregateSchema : TermSchema { public static readonly new string base_name = "Aggregate"; private static new AggregateSchema baseSchema = new AggregateSchema(); /// /// Constructs a schema that vinculates an entity to be a generic aggregate. /// private AggregateSchema():base(base_name) { } /// /// Constructs a schema with a given typeName that vinculates an entity to be a generic aggregate. /// /// It is the name of the aggregate public AggregateSchema(string typeName):base(typeName) { } /// /// Retrieves the generic AggregateSchema for all aggregates. /// /// Returns a ObjectSchema that represent the generic AggregateSchema public static new ObjectSchema GetBaseSchema() { return baseSchema; } /// /// Returns true if ///- s is the base schema for the XXXSchema class and this schema is /// an instance of (e.g. s is ConceptSchema.GetBaseSchema() and this /// schema is an instance of ConceptSchema) /// - s is the base schema for a super-class of the XXXSchema class and /// this schema is an instance of (e.g. s is TermSchema.GetBaseSchema() /// and this schema is an instance of ConceptSchema. /// /// The possible base schema /// Returns true if s is a base schema for this schema public override bool DescendsFrom(ObjectSchema s) { try { if (s != null) { if (s.Equals(GetBaseSchema())) { return true; } return base.DescendsFrom(s); } else { return false; } } catch(Exception ex) { throw new OntologyException(ex.ToString()); } } /// /// Returns an abstract object that represents this aggregate. /// /// public override AbsObject NewInstance() { return new AbsAggregate(GetTypeName()); } /// /// Validates a given abstract object, using a given ontology. /// /// The abstract object to Validate. /// The ontology to use. public override void Validate(AbsObject abs, Ontology onto) { try { if (!(abs is AbsAggregate)) { throw new ValidationException(abs.ToString()+" is not an AbsAggregate"); } AbsAggregate agg = (AbsAggregate) abs; for(int i=0; i /// /// /// /// public new bool IsEqualTo(object o) { try { if (o != null) { return (o is AggregateSchema); } else { return false; } } catch(Exception ex) { throw new OntologyException(ex.ToString()); } } } }