// Generated by Qleany v1.7.0 from entity_dtos.tera

pub use common::entities::Cardinality;
pub use common::entities::Direction;
pub use common::entities::Order;
use common::entities::Relationship;
pub use common::entities::RelationshipType;
pub use common::entities::Strength;
use common::types::EntityId;
use serde::{Deserialize, Serialize};
use std::convert::From;

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct RelationshipDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub left_entity: Option<EntityId>,
    pub right_entity: Option<EntityId>,
    pub field_name: String,
    pub relationship_type: RelationshipType,
    pub strength: Strength,
    pub direction: Direction,
    pub cardinality: Cardinality,
    pub order: Option<Order>,
}

impl From<RelationshipDto> for Relationship {
    fn from(dto: RelationshipDto) -> Self {
        Relationship {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            left_entity: dto.left_entity,
            right_entity: dto.right_entity,
            field_name: dto.field_name,
            relationship_type: dto.relationship_type,
            strength: dto.strength,
            direction: dto.direction,
            cardinality: dto.cardinality,
            order: dto.order,
        }
    }
}

impl From<&RelationshipDto> for Relationship {
    fn from(dto: &RelationshipDto) -> Self {
        Relationship {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            left_entity: dto.left_entity,
            right_entity: dto.right_entity,
            field_name: dto.field_name.clone(),
            relationship_type: dto.relationship_type.clone(),
            strength: dto.strength.clone(),
            direction: dto.direction.clone(),
            cardinality: dto.cardinality.clone(),
            order: dto.order.clone(),
        }
    }
}

impl From<Relationship> for RelationshipDto {
    fn from(entity: Relationship) -> Self {
        RelationshipDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            left_entity: entity.left_entity,
            right_entity: entity.right_entity,
            field_name: entity.field_name,
            relationship_type: entity.relationship_type,
            strength: entity.strength,
            direction: entity.direction,
            cardinality: entity.cardinality,
            order: entity.order,
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct CreateRelationshipDto {
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub left_entity: Option<EntityId>,
    pub right_entity: Option<EntityId>,
    pub field_name: String,
    pub relationship_type: RelationshipType,
    pub strength: Strength,
    pub direction: Direction,
    pub cardinality: Cardinality,
    pub order: Option<Order>,
}

impl From<CreateRelationshipDto> for Relationship {
    fn from(dto: CreateRelationshipDto) -> Self {
        Relationship {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            left_entity: dto.left_entity,
            right_entity: dto.right_entity,
            field_name: dto.field_name,
            relationship_type: dto.relationship_type,
            strength: dto.strength,
            direction: dto.direction,
            cardinality: dto.cardinality,
            order: dto.order,
        }
    }
}

impl From<&CreateRelationshipDto> for Relationship {
    fn from(dto: &CreateRelationshipDto) -> Self {
        Relationship {
            id: 0,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            left_entity: dto.left_entity,
            right_entity: dto.right_entity,
            field_name: dto.field_name.clone(),
            relationship_type: dto.relationship_type.clone(),
            strength: dto.strength.clone(),
            direction: dto.direction.clone(),
            cardinality: dto.cardinality.clone(),
            order: dto.order.clone(),
        }
    }
}

impl From<Relationship> for CreateRelationshipDto {
    fn from(entity: Relationship) -> Self {
        CreateRelationshipDto {
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            left_entity: entity.left_entity,
            right_entity: entity.right_entity,
            field_name: entity.field_name,
            relationship_type: entity.relationship_type,
            strength: entity.strength,
            direction: entity.direction,
            cardinality: entity.cardinality,
            order: entity.order,
        }
    }
}
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct UpdateRelationshipDto {
    pub id: EntityId,
    pub created_at: chrono::DateTime<chrono::Utc>,
    pub updated_at: chrono::DateTime<chrono::Utc>,
    pub field_name: String,
    pub relationship_type: RelationshipType,
    pub strength: Strength,
    pub direction: Direction,
    pub cardinality: Cardinality,
    pub order: Option<Order>,
}

impl From<UpdateRelationshipDto> for Relationship {
    fn from(dto: UpdateRelationshipDto) -> Self {
        Relationship {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            field_name: dto.field_name,
            relationship_type: dto.relationship_type,
            strength: dto.strength,
            direction: dto.direction,
            cardinality: dto.cardinality,
            order: dto.order,
            left_entity: Default::default(),
            right_entity: Default::default(),
        }
    }
}

impl From<&UpdateRelationshipDto> for Relationship {
    fn from(dto: &UpdateRelationshipDto) -> Self {
        Relationship {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            field_name: dto.field_name.clone(),
            relationship_type: dto.relationship_type.clone(),
            strength: dto.strength.clone(),
            direction: dto.direction.clone(),
            cardinality: dto.cardinality.clone(),
            order: dto.order.clone(),
            left_entity: Default::default(),
            right_entity: Default::default(),
        }
    }
}

impl From<Relationship> for UpdateRelationshipDto {
    fn from(entity: Relationship) -> Self {
        UpdateRelationshipDto {
            id: entity.id,
            created_at: entity.created_at,
            updated_at: entity.updated_at,
            field_name: entity.field_name,
            relationship_type: entity.relationship_type,
            strength: entity.strength,
            direction: entity.direction,
            cardinality: entity.cardinality,
            order: entity.order,
        }
    }
}

impl From<RelationshipDto> for UpdateRelationshipDto {
    fn from(dto: RelationshipDto) -> Self {
        UpdateRelationshipDto {
            id: dto.id,
            created_at: dto.created_at,
            updated_at: dto.updated_at,
            field_name: dto.field_name,
            relationship_type: dto.relationship_type,
            strength: dto.strength,
            direction: dto.direction,
            cardinality: dto.cardinality,
            order: dto.order,
        }
    }
}
pub use common::direct_access::relationship::RelationshipRelationshipField;

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct RelationshipRelationshipDto {
    pub id: EntityId,
    pub field: RelationshipRelationshipField,
    pub right_ids: Vec<EntityId>,
}
