1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.ActiveRecord
.Tests
.Model
.StrictModel
19 using Iesi
.Collections
;
21 public enum EstratoType
28 [ActiveRecord(DiscriminatorColumn
="type", DiscriminatorType
="Int16", DiscriminatorValue
="0")]
29 public class Estrato
: ActiveRecordValidationBase
32 private EstratoType type
;
33 private QuestionContainer container
;
34 private Estrato parentEstrato
;
35 private ISet subestratos
= new ListSet();
36 private ISet references
= new ListSet();
49 [Property("type", Insert
=false, Update
=false)]
50 public EstratoType EstratoType
56 [BelongsTo("container_id")]
57 public QuestionContainer Container
59 get { return container != null ? container : ParentEstrato.Container; }
60 set { container = value; }
63 [HasAndBelongsToMany( typeof(Estrato
), Table
="EstratoRefEstrato", ColumnRef
="ref_estrato_id", ColumnKey
="estrato_id" )]
64 public ISet ReferencedEstratos
66 get { return references; }
67 set { references = value; }
70 [BelongsTo("parent_id", Type
=typeof(Estrato
))]
71 public Estrato ParentEstrato
73 get { return parentEstrato; }
74 set { parentEstrato = value; }
77 [HasMany( typeof(Estrato
), Inverse
=true, Cascade
=ManyRelationCascadeEnum
.All
)]
78 public ISet SubEstratos
80 get { return subestratos; }
81 set { subestratos = value; }
86 get { return SubEstratos == null || SubEstratos.Count == 0; }