Author: vyemialyanchyk
Date: 2010-10-06 13:31:54 -0400 (Wed, 06 Oct 2010)
New Revision: 25528
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/sample/AntCodeGenPropsInternal.hibernate.properties
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/sample/AntCodeGenInternalProps_test1.xml
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/sample/AntCodeGenInternalProps_test2.xml
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java
Log:
https://jira.jboss.org/browse/JBIDE-7274 - fixed
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java 2010-10-06
17:09:03 UTC (rev 25527)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java 2010-10-06
17:31:54 UTC (rev 25528)
@@ -178,55 +178,46 @@
String pass =
cpProperties.getProperty("org.eclipse.datatools.connectivity.db.password");
//$NON-NLS-1$
//
String dialectName = consoleConfigPrefs.getDialectName();
+ //
+ Set<String> specialProps = new TreeSet<String>();
+ specialProps.add(Environment.DRIVER);
+ specialProps.add(Environment.URL);
+ specialProps.add(Environment.USER);
+ specialProps.add(Environment.PASS);
+ specialProps.add(Environment.DIALECT);
+ //
+ Properties propsTmp = null;
if (consoleConfigPrefs.getPropertyFile() != null) {
- props = consoleConfigPrefs.getProperties();
- props.setProperty(Environment.DRIVER, driverClass);
- props.setProperty(Environment.URL, url);
- props.setProperty(Environment.USER, user);
- props.setProperty(Environment.PASS, pass);
- if (StringHelper.isNotEmpty(dialectName)) {
- props.setProperty(Environment.DIALECT, dialectName);
- }
- // output keys in sort order
- Object[] keys = props.keySet().toArray();
- Arrays.sort(keys);
+ propsTmp = consoleConfigPrefs.getProperties();
+ }
+ if (propsTmp == null) {
+ propsTmp = new Properties();
+ }
+ propsTmp.setProperty(Environment.DRIVER, driverClass);
+ propsTmp.setProperty(Environment.URL, url);
+ propsTmp.setProperty(Environment.USER, user);
+ propsTmp.setProperty(Environment.PASS, pass);
+ if (StringHelper.isNotEmpty(dialectName)) {
+ propsTmp.setProperty(Environment.DIALECT, dialectName);
+ }
+ // output keys in sort order
+ Object[] keys = propsTmp.keySet().toArray();
+ Arrays.sort(keys);
+ //
+ if (externalPropFile) {
for (Object obj : keys) {
- addIntoPropFileContent(propFileContent, obj.toString(),
props.getProperty(obj.toString()));
+ addIntoPropFileContent(propFileContent, obj.toString(),
propsTmp.getProperty(obj.toString()));
}
} else {
- //
- /** /
- String driverURL = getConnectionProfileDriverURL(connProfileName);
- el = root.addElement(CodeGenerationStrings.PROPERTY);
- el.addAttribute(CodeGenerationStrings.NAME, "jdbc.driver"); //$NON-NLS-1$
- el.addAttribute(CodeGenerationStrings.LOCATION, driverURL);
- /**/
- //
- el = root.addElement(CodeGenerationStrings.PROPERTY);
- el.addAttribute(CodeGenerationStrings.NAME, Environment.DRIVER);
- el.addAttribute(CodeGenerationStrings.VALUE, driverClass);
- addIntoPropFileContent(propFileContent, Environment.DRIVER);
- //
- el = root.addElement(CodeGenerationStrings.PROPERTY);
- el.addAttribute(CodeGenerationStrings.NAME, Environment.URL);
- el.addAttribute(CodeGenerationStrings.VALUE, url);
- addIntoPropFileContent(propFileContent, Environment.URL);
- //
- el = root.addElement(CodeGenerationStrings.PROPERTY);
- el.addAttribute(CodeGenerationStrings.NAME, Environment.USER);
- el.addAttribute(CodeGenerationStrings.VALUE, user);
- addIntoPropFileContent(propFileContent, Environment.USER);
- //
- el = root.addElement(CodeGenerationStrings.PROPERTY);
- el.addAttribute(CodeGenerationStrings.NAME, Environment.PASS);
- el.addAttribute(CodeGenerationStrings.VALUE, pass);
- addIntoPropFileContent(propFileContent, Environment.PASS);
- //
- if (StringHelper.isNotEmpty(dialectName)) {
- el = root.addElement(CodeGenerationStrings.PROPERTY);
- el.addAttribute(CodeGenerationStrings.NAME, Environment.DIALECT);
- el.addAttribute(CodeGenerationStrings.VALUE, dialectName);
- addIntoPropFileContent(propFileContent, Environment.DIALECT);
+ for (Object obj : keys) {
+ if (specialProps.contains(obj)) {
+ el = root.addElement(CodeGenerationStrings.PROPERTY);
+ el.addAttribute(CodeGenerationStrings.NAME, obj.toString());
+ el.addAttribute(CodeGenerationStrings.VALUE,
propsTmp.getProperty(obj.toString()));
+ addIntoPropFileContent(propFileContent, obj.toString());
+ } else {
+ addIntoPropFileContent(propFileContent, obj.toString(),
propsTmp.getProperty(obj.toString()));
+ }
}
}
if (externalPropFile) {
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/sample/AntCodeGenInternalProps_test1.xml
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/sample/AntCodeGenInternalProps_test1.xml 2010-10-06
17:09:03 UTC (rev 25527)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/sample/AntCodeGenInternalProps_test1.xml 2010-10-06
17:31:54 UTC (rev 25528)
@@ -1,13 +1,18 @@
<project name="CodeGen" default="hibernateAntCodeGeneration">
<property name="build.dir" location="reslocation/test"/>
- <property name="hibernatePropFile"
value="${java.io.tmpdir}${ant.project.name}-hibernate.properties"/>
- <target name="generateHibernatePropeties">
- <echo
file="${hibernatePropFile}">hibernate.connection.driver_class=driverClass
-hibernate.connection.password=passw
-hibernate.connection.url=url
-hibernate.connection.username=username
-hibernate.dialect=testDialect</echo>
- </target>
+ <property name="hibernate.connection.driver_class"
value="driverClass"/>
+ <property name="hibernate.connection.password"
value="passw"/>
+ <property name="hibernate.connection.url" value="url"/>
+ <property name="hibernate.connection.username"
value="username"/>
+ <property name="hibernate.dialect" value="testDialect"/>
+ <property name="hibernatePropFile"
value="${java.io.tmpdir}${ant.project.name}-hibernate.properties"/>
+ <target name="generateHibernatePropeties">
+ <echo
file="${hibernatePropFile}">hibernate.connection.driver_class=${hibernate.connection.driver_class}
+hibernate.connection.password=${hibernate.connection.password}
+hibernate.connection.url=${hibernate.connection.url}
+hibernate.connection.username=${hibernate.connection.username}
+hibernate.dialect=${hibernate.dialect}</echo>
+ </target>
<path id="toolslib"/>
<target name="hibernateAntCodeGeneration"
depends="generateHibernatePropeties">
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib"/>
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/sample/AntCodeGenInternalProps_test2.xml
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/sample/AntCodeGenInternalProps_test2.xml 2010-10-06
17:09:03 UTC (rev 25527)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/sample/AntCodeGenInternalProps_test2.xml 2010-10-06
17:31:54 UTC (rev 25528)
@@ -1,13 +1,18 @@
<project name="CodeGen" default="hibernateAntCodeGeneration">
<property name="build.dir" location="reslocation/test"/>
- <property name="hibernatePropFile"
value="${java.io.tmpdir}${ant.project.name}-hibernate.properties"/>
- <target name="generateHibernatePropeties">
- <echo
file="${hibernatePropFile}">hibernate.connection.driver_class=driverClass
-hibernate.connection.password=passw
-hibernate.connection.url=url
-hibernate.connection.username=username
-hibernate.dialect=testDialect</echo>
- </target>
+ <property name="hibernate.connection.driver_class"
value="driverClass"/>
+ <property name="hibernate.connection.password"
value="passw"/>
+ <property name="hibernate.connection.url" value="url"/>
+ <property name="hibernate.connection.username"
value="username"/>
+ <property name="hibernate.dialect" value="testDialect"/>
+ <property name="hibernatePropFile"
value="${java.io.tmpdir}${ant.project.name}-hibernate.properties"/>
+ <target name="generateHibernatePropeties">
+ <echo
file="${hibernatePropFile}">hibernate.connection.driver_class=${hibernate.connection.driver_class}
+hibernate.connection.password=${hibernate.connection.password}
+hibernate.connection.url=${hibernate.connection.url}
+hibernate.connection.username=${hibernate.connection.username}
+hibernate.dialect=${hibernate.dialect}</echo>
+ </target>
<path id="toolslib"/>
<target name="hibernateAntCodeGeneration"
depends="generateHibernatePropeties">
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib"/>
Added:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/sample/AntCodeGenPropsInternal.hibernate.properties
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/sample/AntCodeGenPropsInternal.hibernate.properties
(rev 0)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/res/sample/AntCodeGenPropsInternal.hibernate.properties 2010-10-06
17:31:54 UTC (rev 25528)
@@ -0,0 +1,5 @@
+hibernate.connection.driver_class=${hibernate.connection.driver_class}
+hibernate.connection.password=${hibernate.connection.password}
+hibernate.connection.url=${hibernate.connection.url}
+hibernate.connection.username=${hibernate.connection.username}
+hibernate.dialect=${hibernate.dialect}
\ No newline at end of file
Modified:
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java
===================================================================
---
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java 2010-10-06
17:09:03 UTC (rev 25527)
+++
trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/CodeGenXMLFactoryTest.java 2010-10-06
17:31:54 UTC (rev 25528)
@@ -390,7 +390,7 @@
String codeGenProperties = codeGenFactory.getPropFileContentPreSave();
codeGen = updatePaths(codeGen);
String sample = getSample("AntCodeGenInternalProps_test1.xml");
//$NON-NLS-1$
- String sampleProperties = getSample("AntCodeGenProps.hibernate.properties");
//$NON-NLS-1$
+ String sampleProperties =
getSample("AntCodeGenPropsInternal.hibernate.properties"); //$NON-NLS-1$
assertEquals(sample, codeGen);
assertEquals(sampleProperties.trim(), codeGenProperties);
}
@@ -403,7 +403,7 @@
String codeGenProperties = codeGenFactory.getPropFileContentPreSave();
codeGen = updatePaths(codeGen);
String sample = getSample("AntCodeGenInternalProps_test2.xml");
//$NON-NLS-1$
- String sampleProperties = getSample("AntCodeGenProps.hibernate.properties");
//$NON-NLS-1$
+ String sampleProperties =
getSample("AntCodeGenPropsInternal.hibernate.properties"); //$NON-NLS-1$
assertEquals(sample, codeGen);
assertEquals(sampleProperties.trim(), codeGenProperties);
}