use of com.revolsys.jdbc.field.JdbcFieldAdder in project com.revolsys.open by revolsys.
the class AbstractJdbcRecordStore method addFieldAdder.
protected void addFieldAdder(final String sqlTypeName, final DataType dataType) {
final JdbcFieldAdder adder = new JdbcFieldAdder(dataType);
this.fieldDefinitionAdders.put(sqlTypeName, adder);
}
use of com.revolsys.jdbc.field.JdbcFieldAdder in project com.revolsys.open by revolsys.
the class OracleRecordStore method initializeDo.
@Override
@PostConstruct
public void initializeDo() {
super.initializeDo();
final JdbcFieldAdder attributeAdder = new JdbcFieldAdder();
addFieldAdder("NUMBER", attributeAdder);
addFieldAdder("CHAR", attributeAdder);
addFieldAdder("NCHAR", attributeAdder);
addFieldAdder("VARCHAR", attributeAdder);
addFieldAdder("VARCHAR2", attributeAdder);
addFieldAdder("NVARCHAR2", new JdbcFieldAdder(DataTypes.STRING));
addFieldAdder("LONG", attributeAdder);
addFieldAdder("CLOB", attributeAdder);
addFieldAdder("NCLOB", attributeAdder);
addFieldAdder("DATE", attributeAdder);
addFieldAdder("TIMESTAMP", attributeAdder);
final OracleSdoGeometryFieldAdder sdoGeometryAttributeAdder = new OracleSdoGeometryFieldAdder(this);
addFieldAdder("SDO_GEOMETRY", sdoGeometryAttributeAdder);
addFieldAdder("MDSYS.SDO_GEOMETRY", sdoGeometryAttributeAdder);
final OracleBlobFieldAdder blobAdder = new OracleBlobFieldAdder();
addFieldAdder("BLOB", blobAdder);
final OracleClobFieldAdder clobAdder = new OracleClobFieldAdder();
addFieldAdder("CLOB", clobAdder);
setPrimaryKeySql("SELECT distinct cols.table_name, cols.column_name FROM all_constraints cons, all_cons_columns cols WHERE cons.constraint_type = 'P' AND cons.constraint_name = cols.constraint_name AND cons.owner = cols.owner AND cons.owner =?");
setPrimaryKeyTableCondition(" AND cols.table_name = ?");
setSchemaPermissionsSql("select distinct p.owner \"SCHEMA_NAME\" " + "from ALL_TAB_PRIVS_RECD P " + "where p.privilege in ('SELECT', 'INSERT', 'UPDATE', 'DELETE') union all select USER \"SCHEMA_NAME\" from DUAL");
setSchemaTablePermissionsSql("select distinct p.owner \"SCHEMA_NAME\", p.table_name, p.privilege, comments \"REMARKS\", c.table_type \"TABLE_TYPE\" " + " from ALL_TAB_PRIVS_RECD P " + " join all_tab_comments C on (p.owner = c.owner and p.table_name = c.table_name) " + "where p.owner = ? and c.table_type in ('TABLE', 'VIEW') and p.privilege in ('SELECT', 'INSERT', 'UPDATE', 'DELETE') " + " union all " + "select user \"SCHEMA_NAME\", t.table_name, 'ALL', comments, c.table_type \"TABLE_TYPE\" " + "from user_tables t join user_tab_comments c on (t.table_name = c.table_name) and c.table_type in ('TABLE', 'VIEW')");
addRecordStoreExtension(new ArcSdeStGeometryRecordStoreExtension());
}
use of com.revolsys.jdbc.field.JdbcFieldAdder in project com.revolsys.open by revolsys.
the class PostgreSQLRecordStore method initializeDo.
@Override
public void initializeDo() {
super.initializeDo();
final JdbcFieldAdder numberFieldAdder = new JdbcFieldAdder(DataTypes.DECIMAL);
addFieldAdder("numeric", numberFieldAdder);
final JdbcFieldAdder stringFieldAdder = new JdbcFieldAdder(DataTypes.STRING);
addFieldAdder("varchar", stringFieldAdder);
addFieldAdder("text", stringFieldAdder);
addFieldAdder("name", stringFieldAdder);
addFieldAdder("bpchar", stringFieldAdder);
final JdbcFieldAdder longFieldAdder = new JdbcFieldAdder(DataTypes.LONG);
addFieldAdder("int8", longFieldAdder);
addFieldAdder("bigint", longFieldAdder);
addFieldAdder("bigserial", longFieldAdder);
addFieldAdder("serial8", longFieldAdder);
final JdbcFieldAdder intFieldAdder = new JdbcFieldAdder(DataTypes.INT);
addFieldAdder("int4", intFieldAdder);
addFieldAdder("integer", intFieldAdder);
addFieldAdder("serial", intFieldAdder);
addFieldAdder("serial4", intFieldAdder);
final JdbcFieldAdder shortFieldAdder = new JdbcFieldAdder(DataTypes.SHORT);
addFieldAdder("int2", shortFieldAdder);
addFieldAdder("smallint", shortFieldAdder);
final JdbcFieldAdder floatFieldAdder = new JdbcFieldAdder(DataTypes.FLOAT);
addFieldAdder("float4", floatFieldAdder);
final JdbcFieldAdder doubleFieldAdder = new JdbcFieldAdder(DataTypes.DOUBLE);
addFieldAdder("float8", doubleFieldAdder);
addFieldAdder("double precision", doubleFieldAdder);
addFieldAdder("date", new JdbcFieldAdder(DataTypes.DATE_TIME));
addFieldAdder("timestamp", new JdbcFieldAdder(DataTypes.TIMESTAMP));
addFieldAdder("bool", new JdbcFieldAdder(DataTypes.BOOLEAN));
addFieldAdder("oid", PostgreSQLJdbcBlobFieldDefinition::new);
final JdbcFieldAdder geometryFieldAdder = new PostgreSQLGeometryFieldAdder(this);
addFieldAdder("geometry", geometryFieldAdder);
setPrimaryKeySql(//
"SELECT t.relname \"TABLE_NAME\", c.attname \"COLUMN_NAME\"" + //
" FROM pg_namespace s" + //
" join pg_class t on t.relnamespace = s.oid" + //
" join pg_index i on i.indrelid = t.oid " + //
" join pg_attribute c on c.attrelid = t.oid" + " WHERE s.nspname = ? AND c.attnum = any(i.indkey) AND i.indisprimary");
setPrimaryKeyTableCondition(" AND r.relname = ?");
setSchemaPermissionsSql("select distinct t.table_schema as \"SCHEMA_NAME\" " + "from information_schema.role_table_grants t " + "where (t.grantee in (current_user, 'PUBLIC') or " + "t.grantee in (select role_name from information_schema.applicable_roles r where r.grantee = current_user)) and " + "privilege_type IN ('SELECT', 'INSERT','UPDATE','DELETE') ");
setSchemaTablePermissionsSql("select distinct t.table_schema as \"SCHEMA_NAME\", t.table_name, t.privilege_type as \"PRIVILEGE\", d.description as \"REMARKS\", " + " CASE WHEN relkind = 'r' THEN 'TABLE' WHEN relkind = 'v' THEN 'VIEW' ELSE relkind || '' END \"TABLE_TYPE\" " + //
"from" + //
" information_schema.role_table_grants t" + //
" join pg_namespace n on t.table_schema = n.nspname" + //
" join pg_class c on (n.oid = c.relnamespace AND t.table_name = c.relname)" + //
" left join pg_description d on d.objoid = c.oid " + //
"where" + //
" t.table_schema = ? and " + " (t.grantee in (current_user, 'PUBLIC') or t.grantee in (select role_name from information_schema.applicable_roles r where r.grantee = current_user)) AND " + " privilege_type IN ('SELECT', 'INSERT','UPDATE','DELETE') " + " order by t.table_schema, t.table_name, t.privilege_type");
}
use of com.revolsys.jdbc.field.JdbcFieldAdder in project com.revolsys.open by revolsys.
the class PostgreSQLRecordStore method addField.
@Override
protected JdbcFieldDefinition addField(final JdbcRecordDefinition recordDefinition, final String dbColumnName, final String name, final String dbDataType, final int sqlType, final int length, final int scale, final boolean required, final String description) {
final JdbcFieldDefinition field;
if (dbDataType.charAt(0) == '_') {
final String elementDbDataType = dbDataType.substring(1);
final JdbcFieldAdder fieldAdder = getFieldAdder(elementDbDataType);
final JdbcFieldDefinition elementField = fieldAdder.newField(this, recordDefinition, dbColumnName, name, elementDbDataType, sqlType, length, scale, required, description);
final DataType elementDataType = elementField.getDataType();
final CollectionDataType listDataType = new CollectionDataType("List" + elementDataType.getName(), List.class, elementDataType);
field = new PostgreSQLArrayFieldDefinition(dbColumnName, name, listDataType, sqlType, length, scale, required, description, elementField, getProperties());
recordDefinition.addField(field);
} else {
field = super.addField(recordDefinition, dbColumnName, name, dbDataType, sqlType, length, scale, required, description);
}
if (!dbColumnName.matches("[a-z_]+")) {
field.setQuoteName(true);
}
return field;
}
use of com.revolsys.jdbc.field.JdbcFieldAdder in project com.revolsys.open by revolsys.
the class ArcSdeStGeometryRecordStoreExtension method initialize.
@Override
public void initialize(final RecordStore recordStore, final Map<String, Object> connectionProperties) {
final OracleRecordStore oracleRecordStore = (OracleRecordStore) recordStore;
final JdbcFieldAdder stGeometryAttributeAdder = new ArcSdeStGeometryFieldAdder(oracleRecordStore);
oracleRecordStore.addFieldAdder("ST_GEOMETRY", stGeometryAttributeAdder);
oracleRecordStore.addFieldAdder("SDE.ST_GEOMETRY", stGeometryAttributeAdder);
}
Aggregations