001package com.randomnoun.common.db.to;
002
003import java.util.ArrayList;
004import java.util.LinkedHashMap;
005import java.util.List;
006import java.util.Map;
007
008import com.randomnoun.common.db.enums.ConstraintTypeEnum;
009
010public class ConstraintTO {
011        
012        private String name;
013        private TableTO table;
014        private ConstraintTypeEnum constraintType;
015        private Map<String, ConstraintColumnTO> constraintColumnMap;
016        
017        public ConstraintTO(TableTO table, ConstraintTypeEnum constraintType, String name) {
018                this.table = table;
019                this.constraintType = constraintType;
020                this.name = name;
021                this.constraintColumnMap = new LinkedHashMap<String, ConstraintColumnTO>();
022                // final ConstraintTO constraintRef = this;
023
024                //DatabaseReader.logger.debug("Loading metadata for constraint '" + name + "'");
025                //JdbcTemplate jt = new JdbcTemplate(table.schema.ds);
026                
027        }
028        public TableTO getTable() { return table; }
029        public String getName() { return name; }
030        public ConstraintTypeEnum getConstraintType() { return constraintType; }
031        
032        public List<ConstraintColumnTO> getConstraintColumns() {
033                return new ArrayList<ConstraintColumnTO>(constraintColumnMap.values());
034        }
035        
036        public List<String> getConstraintColumnNames() {
037                return new ArrayList<String>(constraintColumnMap.keySet());
038        }
039        
040        public Map<String, ConstraintColumnTO> getConstraintColumnMap() {
041                return constraintColumnMap;
042        }
043        public void setConstraintColumnMap(Map<String, ConstraintColumnTO> constraintColumnMap) {
044                this.constraintColumnMap = constraintColumnMap;
045        }
046        public void setName(String name) {
047                this.name = name;
048        }
049        public void setTable(TableTO table) {
050                this.table = table;
051        }
052        public void setType(ConstraintTypeEnum type) {
053                this.constraintType = type;
054        }
055}