Revision 43114 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc2/spi/operations/CreateTableOperation.java
CreateTableOperation.java | ||
---|---|---|
13 | 13 |
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCSQLBuilderBase; |
14 | 14 |
import org.gvsig.fmap.dal.store.jdbc.exception.JDBCSQLException; |
15 | 15 |
import org.gvsig.fmap.dal.store.jdbc2.JDBCUtils; |
16 |
import org.gvsig.fmap.geom.DataTypes; |
|
16 | 17 |
|
17 | 18 |
public class CreateTableOperation extends AbstractConnectionOperation { |
18 | 19 |
|
... | ... | |
65 | 66 |
JDBCSQLBuilderBase sqlbuilder = this.createSQLBuilder(); |
66 | 67 |
sqlbuilder.create_table().table().database(dbName).schema(schemaName).name(tableName); |
67 | 68 |
for (FeatureAttributeDescriptor attr : type) { |
68 |
sqlbuilder.create_table().add_column( |
|
69 |
attr.getName(), |
|
70 |
attr.getType(), |
|
71 |
attr.getSize(), |
|
72 |
attr.getPrecision(), |
|
73 |
attr.isPrimaryKey(), |
|
74 |
attr.allowNull(), |
|
75 |
attr.isAutomatic(), |
|
76 |
attr.getDefaultValue() |
|
77 |
); |
|
69 |
if( attr.getType()==DataTypes.GEOMETRY ) { |
|
70 |
sqlbuilder.create_table().add_geometry_column( |
|
71 |
attr.getName(), |
|
72 |
attr.getGeomType().getType(), |
|
73 |
attr.getGeomType().getSubType(), |
|
74 |
attr.getSRS(), |
|
75 |
attr.allowNull() |
|
76 |
); |
|
77 |
} else { |
|
78 |
sqlbuilder.create_table().add_column( |
|
79 |
attr.getName(), |
|
80 |
attr.getType(), |
|
81 |
attr.getSize(), |
|
82 |
attr.getPrecision(), |
|
83 |
attr.isPrimaryKey(), |
|
84 |
attr.allowNull(), |
|
85 |
attr.isAutomatic(), |
|
86 |
attr.getDefaultValue() |
|
87 |
); |
|
88 |
} |
|
78 | 89 |
} |
79 | 90 |
for (Pair<String, SQLBuilder.Privilege> roleAndPrivilege : rolesAndPrivileges) { |
80 | 91 |
sqlbuilder.grant().role(roleAndPrivilege.getLeft()).privilege(roleAndPrivilege.getRight()); |
Also available in: Unified diff