use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class OrmLabelProvider method updateColumnSqlType.
/**
* For correct label creation should update column sql type.
* @param column
* @return
*/
public boolean updateColumnSqlType(final IColumn column) {
String sqlType = column.getSqlType();
if (sqlType != null) {
return false;
}
final IConfiguration config = getConfig();
if (config != null) {
final ConsoleConfiguration consoleConfig = getConsoleConfig();
try {
sqlType = (String) consoleConfig.execute(new ExecutionContext.Command() {
public Object execute() {
return column.getSqlType(config);
}
});
} catch (Exception e) {
// do not ignore it - print in Error Log
// $NON-NLS-1$
HibernateConsolePlugin.getDefault().logErrorMessage("Exception: ", e);
}
}
if (sqlType != null) {
column.setSqlType(sqlType);
return true;
}
return false;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class OrmLabelProvider method getConsoleConfig.
protected ConsoleConfiguration getConsoleConfig() {
final KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
ConsoleConfiguration consoleConfig = knownConfigurations.find(consoleConfigName);
return consoleConfig;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class WripperException method testHbmExportExceptionTest.
public void testHbmExportExceptionTest() throws Exception {
try {
Object[] persClassesInit = getPersistenceClasses(false);
final ConsoleConfiguration consCFG = getConsoleConfig();
IConfiguration config = consCFG.getConfiguration();
// delete old hbm files
assertNotNull(testPackage);
int nDeleted = 0;
if (testPackage.getNonJavaResources().length > 0) {
Object[] ress = testPackage.getNonJavaResources();
for (int i = 0; i < ress.length; i++) {
if (ress[i] instanceof IFile) {
IFile res = (IFile) ress[i];
if (res.getName().endsWith(".hbm.xml")) {
// $NON-NLS-1$
res.delete(true, false, null);
nDeleted++;
}
}
}
}
IHibernateMappingExporter hce = service.newHibernateMappingExporter(config, getSrcFolder());
try {
hce.start();
IArtifactCollector collector = service.newArtifactCollector();
collector.formatFiles();
try {
// build generated configuration
testPackage.getResource().refreshLocal(IResource.DEPTH_INFINITE, null);
testPackage.getJavaProject().getProject().build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
ConsoleConfigUtils.customizeCfgXmlForPack(testPackage);
assertNotNull(consCFG);
consCFG.reset();
consCFG.build();
assertTrue(consCFG.hasConfiguration());
consCFG.getConfiguration().buildMappings();
config = consCFG.getConfiguration();
} catch (CoreException e) {
String out = NLS.bind(ConsoleTestMessages.UpdateConfigurationTest_error_customising_file_for_package, new Object[] { ConsoleConfigUtils.CFG_FILE_NAME, testPackage.getPath(), e.getMessage() });
fail(out);
}
} catch (Exception e) {
throw (Exception) e.getCause();
}
//
Object[] persClassesReInit = getPersistenceClasses(false);
//
int nCreated = 0;
if (testPackage.getNonJavaResources().length > 0) {
Object[] ress = testPackage.getNonJavaResources();
for (int i = 0; i < ress.length; i++) {
if (ress[i] instanceof IFile) {
IFile res = (IFile) ress[i];
if (res.getName().endsWith(".hbm.xml")) {
// $NON-NLS-1$
nCreated++;
}
}
}
}
//
assertTrue(persClassesInit.length == persClassesReInit.length);
assertTrue(nCreated > 0);
assertTrue(nDeleted >= 0 && persClassesInit.length > 0);
assertTrue(nCreated <= persClassesInit.length);
} catch (Exception e) {
// $NON-NLS-1$ //$NON-NLS-2$
String newMessage = "\nPackage " + testPackage.getElementName() + ":";
throw new WripperException(newMessage, e);
}
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class BaseTestSetCase method getPersistenceClasses.
public Object[] getPersistenceClasses(boolean resetCC) {
final ConsoleConfiguration consCFG = getConsoleConfig();
if (resetCC) {
consCFG.reset();
consCFG.build();
}
assertTrue(consCFG.hasConfiguration());
if (resetCC) {
consCFG.buildMappings();
}
Object[] configs = null;
Object[] persClasses = null;
try {
configs = ccWorkbenchAdapter.getChildren(consCFG);
assertNotNull(configs);
assertEquals(3, configs.length);
assertTrue(configs[0] instanceof IConfiguration);
persClasses = configWorkbenchAdapter.getChildren(configs[0]);
} catch (Exception ex) {
String out = NLS.bind(ConsoleTestMessages.OpenMappingDiagramTest_mapping_diagrams_for_package_cannot_be_opened, new Object[] { testPackage.getElementName(), ex.getMessage() });
fail(out);
}
return persClasses;
}
use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.
the class BaseTestSetCase method getConsoleConfig.
public ConsoleConfiguration getConsoleConfig() {
KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
final ConsoleConfiguration consCFG = knownConfigurations.find(consoleConfigName);
assertNotNull(consCFG);
return consCFG;
}
Aggregations