private PropertyValueModel buildRelationalPlatformHolderImp() { PreferencePropertyValueModel adapter = new PreferencePropertyValueModel( preferences(), SCPlugin.DATABASE_PLATFORM_PREFERENCE, DatabasePlatformRepository.getDefault() .platformNamed(SCPlugin.DATABASE_PLATFORM_PREFERENCE_DEFAULT)); adapter.setConverter( new BidiStringConverter() { public Object convertToObject(String value) { if (value == null) return null; return DatabasePlatformRepository.getDefault().platformNamed(value); } public String convertToString(Object value) { if (value == null) return null; DatabasePlatform platform = (DatabasePlatform) value; return platform.getName(); } }); return adapter; }
protected void setUp() throws Exception { super.setUp(); this.databasePlatform = DatabasePlatformRepository.getDefault().platformNamed("MySQL"); String projectName = ClassTools.shortClassNameForObject(this); this.project = new MWRelationalProject( projectName, MappingsModelTestTools.buildSPIManager(), this.databasePlatform); this.database = this.project.getDatabase(); this.loginSpec = TestDatabases.mySQLLoginSpec(this.database); this.catalogName = null; this.schemaName = null; // EMP this.table_EMP = this.database.addTable(this.catalogName, this.schemaName, "emp"); this.field_EMP_ID = this.table_EMP.addColumn("emp_id"); this.field_EMP_ID.setDatabaseType(this.databasePlatform.databaseTypeNamed("integer")); this.field_EMP_ID.setSize(0); this.field_EMP_ID.setPrimaryKey(true); this.field_ADDR_ID1_FK = this.table_EMP.addColumn("addr_id1"); this.field_ADDR_ID1_FK.setDatabaseType(this.databasePlatform.databaseTypeNamed("integer")); this.field_ADDR_ID1_FK.setSize(0); this.field_ADDR_ID2_FK = this.table_EMP.addColumn("addr_id2"); this.field_ADDR_ID2_FK.setDatabaseType(this.databasePlatform.databaseTypeNamed("integer")); this.field_ADDR_ID2_FK.setSize(0); this.field_PHONE = this.table_EMP.addColumn("phone"); this.field_PHONE.setDatabaseType(this.databasePlatform.databaseTypeNamed("varchar")); this.field_PHONE.setSize(20); this.field_BOSS_ID_FK = this.table_EMP.addColumn("boss_id"); this.field_BOSS_ID_FK.setDatabaseType(this.databasePlatform.databaseTypeNamed("integer")); this.field_BOSS_ID_FK.setSize(0); // ADDR this.table_ADDR = this.database.addTable(this.catalogName, this.schemaName, "addr"); this.field_ADDR_ID1 = this.table_ADDR.addColumn("addr_id1"); this.field_ADDR_ID1.setDatabaseType(this.databasePlatform.databaseTypeNamed("integer")); this.field_ADDR_ID1.setSize(0); this.field_ADDR_ID1.setPrimaryKey(true); this.field_ADDR_ID2 = this.table_ADDR.addColumn("addr_id2"); this.field_ADDR_ID2.setDatabaseType(this.databasePlatform.databaseTypeNamed("integer")); this.field_ADDR_ID2.setSize(0); this.field_ADDR_ID2.setPrimaryKey(true); this.field_STREET = this.table_ADDR.addColumn("street"); this.field_STREET.setSize(20); this.field_CITY = this.table_ADDR.addColumn("city"); this.field_CITY.setSize(20); this.field_STATE_ID1_FK = this.table_ADDR.addColumn("state_id1"); this.field_STATE_ID1_FK.setDatabaseType(this.databasePlatform.databaseTypeNamed("integer")); this.field_STATE_ID1_FK.setSize(0); this.field_STATE_ID2_FK = this.table_ADDR.addColumn("state_id2"); this.field_STATE_ID2_FK.setDatabaseType(this.databasePlatform.databaseTypeNamed("integer")); this.field_STATE_ID2_FK.setSize(0); this.field_ZIP = this.table_ADDR.addColumn("zip"); this.field_ZIP.setDatabaseType(this.databasePlatform.databaseTypeNamed("varchar")); this.field_ZIP.setSize(9); // STATE this.table_STATE = this.database.addTable(this.catalogName, this.schemaName, "state"); this.field_STATE_ID1 = this.table_STATE.addColumn("state_id1"); this.field_STATE_ID1.setDatabaseType(this.databasePlatform.databaseTypeNamed("integer")); this.field_STATE_ID1.setSize(0); this.field_STATE_ID1.setPrimaryKey(true); this.field_STATE_ID2 = this.table_STATE.addColumn("state_id2"); this.field_STATE_ID2.setDatabaseType(this.databasePlatform.databaseTypeNamed("integer")); this.field_STATE_ID2.setSize(0); this.field_STATE_ID2.setPrimaryKey(true); this.field_STATE_CODE = this.table_STATE.addColumn("code"); this.field_STATE_CODE.setDatabaseType(this.databasePlatform.databaseTypeNamed("varchar")); this.field_STATE_CODE.setSize(2); this.field_STATE_NAME = this.table_STATE.addColumn("name"); this.field_STATE_NAME.setDatabaseType(this.databasePlatform.databaseTypeNamed("varchar")); this.field_STATE_NAME.setSize(20); // constraints this.reference_EMP_ADDR = this.table_EMP.addReference("emp_addr", this.table_ADDR); this.reference_EMP_ADDR.setOnDatabase(true); this.reference_EMP_ADDR.addColumnPair(this.field_ADDR_ID1_FK, this.field_ADDR_ID1); this.reference_EMP_ADDR.addColumnPair(this.field_ADDR_ID2_FK, this.field_ADDR_ID2); this.reference_EMP_BOSS = this.table_EMP.addReference("emp_boss", this.table_EMP); this.reference_EMP_BOSS.setOnDatabase(true); this.reference_EMP_BOSS.addColumnPair(this.field_BOSS_ID_FK, this.field_EMP_ID); this.reference_ADDR_STATE = this.table_ADDR.addReference("addr_state", this.table_STATE); this.reference_ADDR_STATE.setOnDatabase(true); this.reference_ADDR_STATE.addColumnPair(this.field_STATE_ID1_FK, this.field_STATE_ID1); this.reference_ADDR_STATE.addColumnPair(this.field_STATE_ID2_FK, this.field_STATE_ID2); }