View | Details | Raw Unified | Return to bug 248031
Collapse All | Expand All

(-)src/org/eclipse/jpt/db/Column.java (+36 lines)
Lines 9-14 Link Here
9
 ******************************************************************************/
9
 ******************************************************************************/
10
package org.eclipse.jpt.db;
10
package org.eclipse.jpt.db;
11
11
12
import org.eclipse.datatools.modelbase.sql.datatypes.CharacterStringDataType;
13
import org.eclipse.datatools.modelbase.sql.datatypes.NumericalDataType;
12
import org.eclipse.jpt.utility.JavaType;
14
import org.eclipse.jpt.utility.JavaType;
13
15
14
/**
16
/**
Lines 80-83 Link Here
80
	 */
82
	 */
81
	JavaType getPrimaryKeyJavaType();
83
	JavaType getPrimaryKeyJavaType();
82
84
85
	/**
86
	 * Return whether the column is part of it's table's unique constraint.
87
	 */	
88
	public boolean isPartOfUniqueConstraint();
89
	
90
	/**
91
	 * Return whether the column is nullable.
92
	 */	
93
	public boolean isNullable();
94
	
95
	/**
96
	 * Return whether the column is of numeric type.
97
	 */	
98
	public boolean isNumeric() ;	
99
100
	/**
101
	 * Return precision of the column if it is NumericalDataType
102
	 * otherwise, return -1
103
	 */	
104
	public int getPrecision();	
105
106
	/**
107
	 * Return scale of the column if it is ExactNumericDataType
108
	 * otherwise, return -1
109
	 */	
110
	public int getScale();	
111
112
	/**
113
	 * Return size of the column:
114
	 * - if the column is CharacterStringDataType, return the length
115
	 * - otherwise, return -1
116
	 */	
117
	public int getLength() ;
118
	
83
}
119
}
(-)src/org/eclipse/jpt/db/internal/DTPColumnWrapper.java (-1 / +49 lines)
Lines 12-18 Link Here
12
import java.text.Collator;
12
import java.text.Collator;
13
13
14
import org.eclipse.datatools.modelbase.dbdefinition.PredefinedDataTypeDefinition;
14
import org.eclipse.datatools.modelbase.dbdefinition.PredefinedDataTypeDefinition;
15
import org.eclipse.datatools.modelbase.sql.datatypes.CharacterStringDataType;
15
import org.eclipse.datatools.modelbase.sql.datatypes.DataType;
16
import org.eclipse.datatools.modelbase.sql.datatypes.DataType;
17
import org.eclipse.datatools.modelbase.sql.datatypes.ExactNumericDataType;
18
import org.eclipse.datatools.modelbase.sql.datatypes.NumericalDataType;
16
import org.eclipse.datatools.modelbase.sql.datatypes.PredefinedDataType;
19
import org.eclipse.datatools.modelbase.sql.datatypes.PredefinedDataType;
17
import org.eclipse.datatools.modelbase.sql.datatypes.PrimitiveType;
20
import org.eclipse.datatools.modelbase.sql.datatypes.PrimitiveType;
18
import org.eclipse.jpt.db.Column;
21
import org.eclipse.jpt.db.Column;
Lines 47-55 Link Here
47
		this.getConnectionProfile().columnChanged(this);
50
		this.getConnectionProfile().columnChanged(this);
48
	}
51
	}
49
52
53
	// ********** return the wrapped DTP Column **********
50
54
51
	// ********** Column implementation **********
55
	public org.eclipse.datatools.modelbase.sql.tables.Column getDtpColumn(){
56
		return this.dtpColumn;
57
	}
52
58
59
	// ********** Column implementation **********
53
	public String getName() {
60
	public String getName() {
54
		return this.dtpColumn.getName();
61
		return this.dtpColumn.getName();
55
	}
62
	}
Lines 66-71 Link Here
66
		return this.getTable().foreignKeyBaseColumnsContains(this);
73
		return this.getTable().foreignKeyBaseColumnsContains(this);
67
	}
74
	}
68
75
76
	public boolean isPartOfUniqueConstraint() {
77
		return this.dtpColumn.isPartOfUniqueConstraint() ;
78
	}
79
80
	public boolean isNullable() {
81
		return this.dtpColumn.isNullable();
82
	}
83
	
84
	public int getPrecision(){
85
		DataType dataType = this.dtpColumn.getDataType();
86
		if( dataType instanceof NumericalDataType){
87
			NumericalDataType type = (NumericalDataType)dataType;
88
			return type.getPrecision();
89
		}
90
		return -1;
91
	}
92
93
	public int getScale(){
94
		DataType dataType = this.dtpColumn.getDataType();
95
		if( dataType instanceof ExactNumericDataType){
96
			ExactNumericDataType type = (ExactNumericDataType)dataType;
97
			return type.getScale();
98
		}
99
		return -1;
100
	}		
101
102
	public int getLength() {
103
		DataType dataType = this.dtpColumn.getDataType();
104
		if(dataType instanceof CharacterStringDataType){
105
			CharacterStringDataType type = (CharacterStringDataType)dataType ;
106
			return type.getLength();
107
		}
108
		return -1;
109
	}
110
111
	public boolean isNumeric() {
112
		DataType dataType = this.dtpColumn.getDataType();
113
		boolean ret = dataType instanceof NumericalDataType;
114
		return ret;
115
	}	
116
	
69
	public String getDataTypeName() {
117
	public String getDataTypeName() {
70
		DataType dataType = this.dtpColumn.getDataType();
118
		DataType dataType = this.dtpColumn.getDataType();
71
		return (dataType == null) ? null : dataType.getName();
119
		return (dataType == null) ? null : dataType.getName();

Return to bug 248031