Esempio n. 1
0
        private void ValidateRelationEntity(Relation_Type entity)
        {
            if (entity.ShouldSerializeid())
            {
                throw new ArgumentException("You must not fill in the Relation_Type.id, use the fluent api to construct a proper relation.", "entity");
            }

            if (entity.ShouldSerializeOriginatingObjectID() || entity.ShouldSerializeOriginatingObjectType())
            {
                throw new ArgumentException("You must not fill in the Relation_Type.OriginatingObjectType, use the fluent api to construct a proper relation.", "entity");
            }

            if (entity.ShouldSerializeRelatedObjectID() || entity.ShouldSerializeRelatedObjectType())
            {
                throw new ArgumentException("You must not fill in the Relation_Type.RelatedObjectType, use the fluent api to construct a proper relation.", "entity");
            }

            if (entity.ShouldSerializeRelationRoleCode())
            {
                throw new ArgumentException("You must not fill in the Relation_Type.RelationRoleCode, use the fluent api to construct a proper relation.", "entity");
            }

            if (entity.ShouldSerializeRelationDescription())
            {
                throw new ArgumentException("You must not fill in the Relation_Type.RelationDescription, use the fluent api to construct a proper relation.", "entity");
            }
        }
Esempio n. 2
0
        private void AddRelationEntity(Relation_Type entity)
        {
            _buildRelationshipsActions.AddLast(n =>
            {
                var originatingObject = n.Items.OfType <IRelation>().Single(m => m.id == entity.OriginatingObjectID);

                OLI_LU_OBJECTTYPE temp = null;
                if (!_typeToOliLuObjectType.TryGetValue(originatingObject.GetType(), out temp))
                {
                    throw new ArgumentException("This argument is not allowed to be related.", "originatingObjectID");
                }

                entity.OriginatingObjectType = temp;

                if (!string.IsNullOrWhiteSpace(entity.RelatedObjectID))
                {
                    var relatedObject = n.Items.OfType <IRelation>().Single(m => m.id == entity.RelatedObjectID);

                    temp = null;
                    if (!_typeToOliLuObjectType.TryGetValue(relatedObject.GetType(), out temp))
                    {
                        throw new ArgumentException("This argument is not allowed to be related.", "originatingObjectID");
                    }

                    entity.RelatedObjectType = temp;
                }

                n.Items.Add(entity);
            });
        }
Esempio n. 3
0
 public override Sans_BeginRelation_OLifEBuilder BeginRelation(string id)
 {
     _buildRelation = new Relation_Type {
         id = id
     };
     return(this);
 }
Esempio n. 4
0
        public override Sans_Properties_OLifEBuilder EndRelation(Relation_Type entity, Relation_Type reciprocalEntity)
        {
            // Relation
            var clonedEntity = entity.Clone();

            ValidateRelationEntity(clonedEntity);

            clonedEntity.id = _buildRelation.id;
            clonedEntity.OriginatingObjectID = _buildRelation.OriginatingObjectID;
            clonedEntity.RelatedObjectID     = _buildRelation.RelatedObjectID;
            clonedEntity.RelationRoleCode    = _buildRelation.RelationRoleCode;
            clonedEntity.RelationDescription = _buildRelation.RelationDescription;

            AddRelationEntity(clonedEntity);
            _buildRelation = null;

            // Reciprocal Relation
            var clonedReciprocalEntity = reciprocalEntity.Clone();

            ValidateRelationEntity(clonedReciprocalEntity);

            clonedReciprocalEntity.id = _buildReciprocalRelation.id;
            clonedReciprocalEntity.OriginatingObjectID = _buildReciprocalRelation.OriginatingObjectID;
            clonedReciprocalEntity.RelatedObjectID     = _buildReciprocalRelation.RelatedObjectID;
            clonedReciprocalEntity.RelationRoleCode    = _buildReciprocalRelation.RelationRoleCode;
            clonedReciprocalEntity.RelationDescription = _buildReciprocalRelation.RelationDescription;

            AddRelationEntity(clonedReciprocalEntity);
            _buildReciprocalRelation = null;

            return(this);
        }
Esempio n. 5
0
        public override Sans_Relation_Where_IsA_Of_AndReciprocal_OLifEBuilder AndReciprocal(string id, OLI_LU_REL relationRoleCode)
        {
            _buildReciprocalRelation = new Relation_Type {
                id = id,
                RelationRoleCode    = relationRoleCode.Clone(),
                RelatedObjectID     = _buildRelation.OriginatingObjectID,
                OriginatingObjectID = _buildRelation.RelatedObjectID,
            };

            return(this);
        }
Esempio n. 6
0
 private void SetAll(Entity first, Entity second, Relation_Type type,
                     Relation_Type mandatory, string name)
 {
     First_Entity  = first;
     Second_Entity = second;
     Relation_type = new Relation_Type[2] {
         type, mandatory
     };
     Attributes = new List <Attribute>();
     rule       = SetRule();
     Name       = name;
 }
Esempio n. 7
0
        public override Sans_Properties_OLifEBuilder EndRelation()
        {
            AddRelationEntity(_buildRelation.Clone());

            if (_buildReciprocalRelation != null)
            {
                AddRelationEntity(_buildReciprocalRelation.Clone());
            }

            _buildRelation           = null;
            _buildReciprocalRelation = null;
            return(this);
        }
Esempio n. 8
0
 internal static IEnumerable<string> Relation(Relation_Type relation, string module)
 {
     List<string> errors = new List<string>();
     if (relation == null) { errors.Add(module + " relation"); }
     else
     {
         if (string.IsNullOrWhiteSpace(relation.id)) { errors.Add (module + " relation id"); }
         if (string.IsNullOrWhiteSpace(relation.OriginatingObjectID)) { errors.Add(module + " relation OriginatingObjectID"); }
         if (LUObjNotValid(relation.OriginatingObjectType)) { errors.Add(module + " relation OriginatingObjectType"); }
         if (string.IsNullOrWhiteSpace(relation.RelatedObjectID)) { errors.Add(module + " relation RelatedObjectID"); }
         if (LUObjNotValid(relation.RelatedObjectType)) { errors.Add(module + " relation RelatedObjectType"); }
         if (LUObjNotValid(relation.RelationRoleCode)) { errors.Add(module + " relation RelationRoleCode"); }
     }
     return errors;
 }
Esempio n. 9
0
 public abstract Sans_Properties_OLifEBuilder EndRelation(Relation_Type entity, Relation_Type reciprocalEntity);
Esempio n. 10
0
 public abstract Sans_Properties_OLifEBuilder AddRelation(Relation_Type entity);
Esempio n. 11
0
 public override Sans_Properties_OLifEBuilder AddRelation(Relation_Type entity)
 {
     AddItem(entity);
     return(this);
 }
Esempio n. 12
0
 public Relation(Entity first, Entity second, Relation_Type type,
                 Relation_Type mandatory, string name, string info)
 {
     SetAll(first, second, type, mandatory, name);
     Additional = info;
 }
Esempio n. 13
0
 public Relation(Entity first, Entity second, Relation_Type type,
                 Relation_Type mandatory, string name)
 {
     SetAll(first, second, type, mandatory, name);
 }