/* * * Create both Master and Work Repositories * * * * */ import groovy.swing.SwingBuilder import java.awt.FlowLayout as FL import javax.swing.DefaultComboBoxModel import javax.swing.BoxLayout as BXL import groovy.beans.Bindable; import oracle.odi.domain.topology.finder.IOdiTechnologyFinder; import oracle.odi.domain.topology.finder.IOdiContextFinder; import oracle.odi.domain.project.finder.IOdiRKMFinder; import oracle.odi.domain.project.OdiRKM; import oracle.odi.core.persistence.transaction.support.DefaultTransactionDefinition; import oracle.odi.domain.topology.OdiTechnology; import oracle.odi.domain.topology.OdiContext; import oracle.odi.domain.util.ObfuscatedString; import oracle.odi.domain.model.OdiModel; import oracle.odi.domain.topology.OdiLogicalSchema; import oracle.odi.domain.topology.OdiPhysicalSchema; import oracle.odi.domain.topology.OdiDataServer; import oracle.odi.domain.topology.OdiContextualSchemaMapping; import oracle.odi.domain.topology.AbstractOdiDataServer; import oracle.odi.setup.AuthenticationConfiguration; import oracle.odi.setup.IMasterRepositorySetup; import oracle.odi.setup.IWorkRepositorySetup; import oracle.odi.setup.RepositorySetupException; import oracle.odi.setup.TechnologyName; import oracle.odi.setup.support.MasterRepositorySetupImpl; import oracle.odi.setup.support.WorkRepositorySetupImpl; import oracle.odi.core.OdiInstance; import oracle.odi.core.config.OdiInstanceConfig; import oracle.odi.core.config.MasterRepositoryDbInfo; import oracle.odi.core.config.PoolingAttributes; import oracle.odi.core.security.Authentication; class Model{ @Bindable DefaultComboBoxModel toItems } def captureInput(defaultSup, defaultTech, defaultUrl, defaultDriver, defaultUser) { technos = [] technos.add("ORACLE") Model t=new Model() d = new java.awt.Dimension(205,20) t.toItems = new DefaultComboBoxModel(technos as Object[]) def s = new SwingBuilder() s.setVariable('myDialog-properties',[:]) def vars = s.variables def dial = s.dialog(title:'Create ODI Repository',id:'myDialog',modal:true) { panel() { boxLayout(axis:BXL.Y_AXIS) panel(alignmentX:0f) { flowLayout(alignment:FL.RIGHT) label('Technology:') comboBox(id:'techcode', 'model': bind {t.toItems}, selectedItem:defaultTech, preferredSize:d) } panel(alignmentX:0f) { flowLayout(alignment:FL.LEFT) label('ODI Supervisor:') } panel(alignmentX:0f) { flowLayout(alignment:FL.RIGHT) label('User:') textField(id:'odi_user',columns:25, text:defaultSup) } panel(alignmentX:0f) { flowLayout(alignment:FL.RIGHT) label('Password:') passwordField(id:'odi_password',columns:25) } panel(alignmentX:0f) { flowLayout(alignment:FL.LEFT) label('Master Repository Details:') } panel(alignmentX:0f) { flowLayout(alignment:FL.RIGHT) label('Schema:') textField(id:'schema',columns:25, text:defaultUser) } panel(alignmentX:0f) { flowLayout(alignment:FL.RIGHT) label('Password:') passwordField(id:'password',columns:25) } panel(alignmentX:0f) { flowLayout(alignment:FL.RIGHT) label('Driver:') textField(id:'driver',columns:25, text:defaultDriver) } panel(alignmentX:0f) { flowLayout(alignment:FL.RIGHT) label('URL:') textField(id:'url',columns:25, text:defaultUrl) } panel(alignmentX:0f) { flowLayout(alignment:FL.LEFT) label('Work Repository Details:') } panel(alignmentX:0f) { flowLayout(alignment:FL.RIGHT) label('Schema:') textField(id:'wschema',columns:25, text:defaultUser) } panel(alignmentX:0f) { flowLayout(alignment:FL.RIGHT) label('Password:') passwordField(id:'wpassword',columns:25) } panel(alignmentX:0f) { flowLayout(alignment:FL.RIGHT) label('Driver:') textField(id:'wdriver',columns:25, text:defaultDriver) } panel(alignmentX:0f) { flowLayout(alignment:FL.RIGHT) label('URL:') textField(id:'wurl',columns:25, text:defaultUrl) } panel(alignmentX:0f) { flowLayout(alignment:FL.LEFT) button('Create Repository',preferredSize:[160,24], actionPerformed:{ vars.dialogResult = 'Create Repository' dispose() }) button('Cancel',preferredSize:[80,24], actionPerformed:{ vars.dialogResult = 'cancel' dispose() }) } } } dial.setLocationRelativeTo(null) dial.pack() dial.show() return vars } vars= captureInput('SUPERVISOR', 'ORACLE', 'jdbc:oracle:thin:@localhost:1521:ora112', 'oracle.jdbc.OracleDriver', 'ODI_TEST_REPOS') if (vars.dialogResult == 'Create Repository') { String odiSupervisorUser = vars.odi_user.text String odiSupervisorPassword = vars.odi_password.text String masterRepositoryJdbcUrl = vars.url.text String masterRepositoryJdbcDriver = vars.driver.text String masterRepositoryJdbcUser = vars.schema.text String masterRepositoryJdbcPassword = vars.password.text TechnologyName masterRepositoryTechnology = TechnologyName.ORACLE; int masterRepositoryId = 0; String workRepositoryJdbcUrl = vars.wurl.text String workRepositoryJdbcDriver = vars.wdriver.text String workRepositoryJdbcUsername = vars.wschema.text String workRepositoryJdbcPassword = vars.wpassword.text String workRepositoryName = "WORKREP" int workRepositoryId = 1; try { println "======================================================" println "Repository Creation Started...." println "======================================================" println "Master Repository Creation Started...." IMasterRepositorySetup masterRepositorySetup = new MasterRepositorySetupImpl(); AuthenticationConfiguration authConf = AuthenticationConfiguration.createStandaloneAuthenticationConfiguration(odiSupervisorPassword.toCharArray()); masterRepositorySetup.createMasterRepository(masterRepositoryJdbcUrl, masterRepositoryJdbcDriver, masterRepositoryJdbcUser, masterRepositoryJdbcPassword, masterRepositoryId, masterRepositoryTechnology, true, authConf, null, null); println "Master Repository Creation Completed." MasterRepositoryDbInfo masterInfo = new MasterRepositoryDbInfo(masterRepositoryJdbcUrl, masterRepositoryJdbcDriver, masterRepositoryJdbcUser, masterRepositoryJdbcPassword.toCharArray(), new PoolingAttributes()); OdiInstance odiInstance = OdiInstance.createInstance(new OdiInstanceConfig(masterInfo, null)); Authentication auth = odiInstance.getSecurityManager().createAuthentication(odiSupervisorUser, odiSupervisorPassword.toCharArray()); odiInstance.getSecurityManager().setCurrentThreadAuthentication(auth); println "Work Repository Creation Started." AuthenticationConfiguration authConf2 = AuthenticationConfiguration.createStandaloneAuthenticationConfiguration(odiSupervisorPassword.toCharArray()); IWorkRepositorySetup workRepositorySetup = new WorkRepositorySetupImpl(odiInstance); workRepositorySetup.createWorkDevRepository(workRepositoryJdbcUrl, workRepositoryJdbcDriver, workRepositoryJdbcUsername, workRepositoryJdbcPassword, workRepositoryId, workRepositoryName, masterRepositoryTechnology, true); println "Work Repository Creation Completed." println "======================================================" println "Repository Creation Completed Successfully" println "======================================================" } catch (Exception e) { println "======================================================" println "Repository Creation Complete in Error" println "======================================================" println e println "======================================================" e.printStackTrace(); } } else { println "Repsoitory Creation Cancelled" }