package com.rthoni.intellij.codefromds.dbo.template;

import java.util.List;
import java.util.Vector;

/**
 * Created by robin on 11/18/16.
 */
public class ForeignKeyDbo {

    private TableDataSourceDbo _sourceTable;

    private List<ColumnDataSourceDbo> _sourceColumns = new Vector<>();

    private TableDataSourceDbo _targetTable;

    private List<ColumnDataSourceDbo> _targetColumns = new Vector<>();

    private String _sourceForeignKeyName;

    private String _targetForeignKeyName;

    private String _name;
//
//    private ForeignKeyDbo _other;
//
//    private boolean _isOneToOne;
//
//    private boolean _isOneToMany;
//
//    private boolean _isManyToMany;

    public TableDataSourceDbo getSourceTable() {
        return _sourceTable;
    }

    public boolean isSelected()
    {
        return _sourceColumns.stream().allMatch(ColumnDataSourceDbo::isSelected) &&
                _targetColumns.stream().allMatch(ColumnDataSourceDbo::isSelected);
    }

    public void setSourceTable(TableDataSourceDbo sourceTable) {
        _sourceTable = sourceTable;
    }

    public List<ColumnDataSourceDbo> getSourceColumns() {
        return _sourceColumns;
    }

    public void addSourceColumn(ColumnDataSourceDbo sourceColumns) {
        _sourceColumns.add(sourceColumns);
    }

    public TableDataSourceDbo getTargetTable() {
        return _targetTable;
    }

    public void setTargetTable(TableDataSourceDbo targetTable) {
        _targetTable = targetTable;
    }

    public List<ColumnDataSourceDbo> getTargetColumns() {
        return _targetColumns;
    }

    public void addTargetColumn(ColumnDataSourceDbo targetColumns) {
        _targetColumns.add(targetColumns);
    }

    public String getSourceForeignKeyName() {
        return _sourceForeignKeyName;
    }

    public void setSourceForeignKeyName(String sourceForeignKeyName) {
        _sourceForeignKeyName = sourceForeignKeyName;
    }

    public String getTargetForeignKeyName() {
        return _targetForeignKeyName;
    }

    public void setTargetForeignKeyName(String targetForeignKeyName) {
        _targetForeignKeyName = targetForeignKeyName;
    }

    public String getName() {
        return _name;
    }

    public void setName(String name) {
        _name = name;
    }

//    public boolean isOneToOne() {
//        return _isOneToOne;
//    }
//
//    public void setOneToOne(boolean oneToOne) {
//        _isOneToOne = oneToOne;
//        if (_isOneToOne) {
//            _isOneToMany = true;
//            _isManyToMany = false;
//        }
//    }
//
//    public boolean isOneToMany() {
//        return _isOneToMany;
//    }
//
//    public void setOneToMany(boolean oneToMany) {
//        _isOneToMany = oneToMany;
//        if (_isOneToMany) {
//            _isOneToOne = true;
//            _isManyToMany = false;
//        }
//    }
//
//    public boolean isManyToMany() {
//        return _isManyToMany;
//    }
//
//    public void setManyToMany(boolean manyToMany) {
//        _isManyToMany = manyToMany;
//        if (_isManyToMany) {
//            _isOneToOne = true;
//            _isOneToMany = false;
//        }
//    }
//
//    public ForeignKeyDbo getOther() {
//        return _other;
//    }
//
//    public void setOther(ForeignKeyDbo other) {
//        _other = other;
//    }
}
