Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

whitespace, STS warnings, etc.

  • Loading branch information...
commit 94733fb62817abba5bfd73412c4c299e55f17828 1 parent 41d6978
@burtbeckwith burtbeckwith authored
Showing with 1,259 additions and 1,340 deletions.
  1. +10 −11 grails-bootstrap/src/main/groovy/grails/build/logging/GrailsConsole.java
  2. +1 −1  grails-bootstrap/src/main/groovy/grails/build/logging/GrailsEclipseConsole.java
  3. +1 −10 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/parsing/CommandLine.java
  4. +6 −6 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/parsing/CommandLineParser.java
  5. +2 −2 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/parsing/ParseException.java
  6. +36 −42 grails-bootstrap/src/test/groovy/org/codehaus/groovy/grails/cli/parsing/CommandLineParserSpec.groovy
  7. +7 −8 grails-core/src/main/groovy/grails/validation/ValidationErrors.groovy
  8. +17 −6 grails-core/src/main/groovy/grails/web/CamelCaseUrlConverter.java
  9. +9 −9 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsControllerClass.java
  10. +5 −9 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsDomainClassProperty.java
  11. +3 −5 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/DomainClassArtefactHandler.java
  12. +14 −15 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/GrailsDomainConfigurationUtil.java
  13. +1 −1  grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/GrailsProjectWatcher.java
  14. +1 −1  grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/GrailsASTUtils.java
  15. +1 −1  grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/DefaultGrailsPluginManager.java
  16. +8 −4 grails-core/src/main/groovy/org/codehaus/groovy/grails/support/SoftThreadLocalMap.java
  17. +3 −4 grails-core/src/test/groovy/grails/web/CamelCaseUrlConverterSpec.groovy
  18. +3 −4 grails-core/src/test/groovy/grails/web/HyphenatedUrlConverterSpec.groovy
  19. +1 −1  grails-core/src/test/groovy/org/codehaus/groovy/grails/compiler/injection/GrailsArtefactTransformerSpec.groovy
  20. +3 −3 grails-crud/src/main/groovy/org/codehaus/groovy/grails/scaffolding/view/ScaffoldedGroovyPageView.java
  21. +2 −2 grails-docs/src/main/groovy/grails/doc/DocPublisher.groovy
  22. +1 −1  grails-docs/src/main/groovy/grails/doc/internal/LegacyTocStrategy.groovy
  23. +1 −1  grails-docs/src/test/groovy/grails/doc/internal/YamlTocStrategySpec.groovy
  24. +35 −9 grails-hibernate/src/main/groovy/grails/orm/HibernateCriteriaBuilder.java
  25. +1 −7 ...hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/ConfigurableLocalSessionFactoryBean.java
  26. +10 −9 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/HibernateDatastore.java
  27. +61 −57 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/HibernateGormEnhancer.groovy
  28. +98 −98 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/cfg/GrailsDomainBinder.java
  29. +1 −1  ...-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/cfg/HibernateNamedQueriesBuilder.groovy
  30. +1 −1  ...ate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/AbstractDynamicPersistentMethod.java
  31. +17 −10 ...ernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/AbstractSavePersistentMethod.java
  32. +2 −2 ...ernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/ExecuteQueryPersistentMethod.java
  33. +2 −5 ...s-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/FindAllPersistentMethod.java
  34. +1 −1  grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/FindPersistentMethod.java
  35. +2 −2 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/SavePersistentMethod.java
  36. +37 −44 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/query/HibernateQuery.java
  37. +84 −72 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/support/ClosureEventListener.java
  38. +12 −13 ...ate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/support/ClosureEventTriggeringInterceptor.java
  39. +2 −6 grails-hibernate/src/test/groovy/org/codehaus/groovy/grails/compiler/gorm/GormTransformerSpec.groovy
  40. +2 −0  grails-plugin-controllers/src/main/groovy/org/codehaus/groovy/grails/plugins/web/api/ControllersApi.java
  41. +4 −4 grails-plugin-controllers/src/main/groovy/org/codehaus/groovy/grails/web/metaclass/RenderDynamicMethod.java
  42. +2 −2 grails-plugin-controllers/src/main/groovy/org/codehaus/groovy/grails/web/plugins/support/WebMetaUtils.groovy
  43. +1 −1  ...src/test/groovy/org/codehaus/groovy/grails/compiler/web/ControllerActionTransformerCommandObjectSpec.groovy
  44. +1 −1  ...-controllers/src/test/groovy/org/codehaus/groovy/grails/compiler/web/ControllerDomainTransformerSpec.groovy
  45. +7 −14 ...plugin-controllers/src/test/groovy/org/codehaus/groovy/grails/compiler/web/ControllerTransformerSpec.groovy
  46. +0 −2  ...src/main/groovy/org/codehaus/groovy/grails/web/converters/marshaller/xml/InstanceMethodBasedMarshaller.java
  47. +13 −21 ...s/src/test/groovy/org/codehaus/groovy/grails/compiler/web/converters/ConvertersDomainTransformerSpec.groovy
  48. +1 −0  ...-plugin-domain-class/src/main/groovy/org/codehaus/groovy/grails/domain/GrailsDomainClassMappingContext.java
  49. +1 −1  grails-plugin-gsp/src/ast/groovy/org/codehaus/groovy/grails/compiler/web/taglib/TagLibraryTransformer.java
  50. +2 −2 grails-plugin-gsp/src/ast/groovy/org/codehaus/groovy/grails/plugins/web/api/TagLibraryApi.java
  51. +1 −1  grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/FormTagLib.groovy
  52. +9 −9 grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/SitemeshTagLib.groovy
  53. +1 −1  grails-plugin-gsp/src/main/groovy/org/codehaus/groovy/grails/plugins/web/taglib/ValidationTagLib.groovy
  54. +1 −1  grails-plugin-logging/src/main/groovy/org/slf4j/impl/GrailsLog4jLoggerAdapter.java
  55. +3 −3 grails-plugin-testing/src/main/groovy/grails/test/AbstractCliTestCase.groovy
  56. +1 −1  grails-plugin-testing/src/main/groovy/grails/test/mixin/support/GrailsUnitTestMixin.groovy
  57. +1 −1  grails-plugin-testing/src/main/groovy/grails/test/mixin/web/ControllerUnitTestMixin.groovy
  58. +3 −3 grails-plugin-tomcat/src/main/groovy/org/grails/plugins/tomcat/TomcatServer.groovy
  59. +1 −2  ...-url-mappings/src/main/groovy/org/codehaus/groovy/grails/plugins/web/mapping/UrlMappingsGrailsPlugin.groovy
  60. +1 −1  ...ls-plugin-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/filter/UrlMappingsFilter.java
  61. +1 −1  grails-plugin-validation/src/main/groovy/grails/validation/DefaultASTValidateableHelper.java
  62. +2 −2 grails-plugin-validation/src/main/groovy/org/codehaus/groovy/grails/validation/Validateable.groovy
  63. +2 −2 grails-plugin-validation/src/test/groovy/grails/validation/DefaultASTValidateableHelperSpec.groovy
  64. +2 −2 ...dation/src/test/groovy/org/codehaus/groovy/grails/compiler/validation/ValidateableTransformationSpec.groovy
  65. +1 −1  grails-plugin-validation/src/test/groovy/org/codehaus/groovy/grails/plugins/ValidationGrailsPluginTests.groovy
  66. +9 −9 grails-resources/src/grails/home/dsl-support/dsld/grails.dsld
  67. +2 −3 ...-suite-base/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/AbstractGrailsControllerTests.groovy
  68. +1 −1  grails-test-suite-base/src/main/groovy/org/codehaus/groovy/grails/web/taglib/AbstractGrailsTagTests.groovy
  69. +2 −3 ...-suite-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/CharSequenceAndGormTests.groovy
  70. +1 −10 ...te-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/CustomTypeMappingForMapTests.groovy
  71. +1 −10 ...suite-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/DomainEventsFlushingTests.groovy
  72. +6 −19 ...-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/EmbeddedGlobalConstraintsTests.groovy
  73. +4 −4 ...e-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/HibernateCriteriaBuilderTests.groovy
  74. +2 −2 ...s-test-suite-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/NamedCriteriaTests.groovy
  75. +4 −4 ...st-suite-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/PersistenceMethodTests.groovy
  76. +0 −11 ...suite-persistence/src/test/groovy/org/codehaus/groovy/grails/orm/hibernate/UserTypeGlobalConfigTests.groovy
  77. +3 −11 grails-test-suite-uber/src/test/groovy/grails/test/mixin/ControllerAndFilterMixinInteractionTests.groovy
  78. +1 −7 ...est-suite-uber/src/test/groovy/grails/test/mixin/DomainClassWithDefaultConstraintsUnitTestMixinTests.groovy
  79. +2 −2 grails-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/commons/CodecArtefactHandlerTests.java
  80. +5 −7 ...-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsControllerClass2Tests.java
  81. +3 −3 ...test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsControllerClassTests.groovy
  82. +4 −5 grails-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsDomainClassTests.groovy
  83. +1 −1  ...s-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/web/errors/GrailsExceptionResolverTests.groovy
  84. +0 −2  ...ls-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/web/servlet/GrailsDispatcherServletTests.java
  85. +10 −10 ...-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/web/servlet/mvc/RenderDynamicMethodTests.groovy
  86. +7 −4 ...test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/web/servlet/mvc/SimpleGrailsControllerTests.java
  87. +17 −17 grails-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/web/sitemesh/GSPSitemeshPageTests.groovy
  88. +2 −3 grails-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/web/util/StreamCharBufferTests.java
  89. +10 −25 grails-test-suite-web/build.gradle
  90. +10 −10 grails-test-suite-web/src/test/groovy/grails/gsp/PageRendererSpec.groovy
  91. +1 −1  grails-test-suite-web/src/test/groovy/grails/test/GrailsUrlMappingsTestCaseTests.groovy
  92. +0 −8 ...ls-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/binding/BindXmlWithAssociationTests.groovy
  93. +3 −3 ...-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/mapping/filter/UrlMappingsFilterTests.groovy
  94. +13 −13 grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageRenderingTests.groovy
  95. +22 −26 ...s-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/pages/GroovyPagesTemplateEngineTests.groovy
  96. +4 −4 grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/ApplicationTagLibTests.groovy
  97. +4 −3 grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/FormTagLib2Tests.groovy
  98. +1 −1  grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/FormTagLib3Tests.groovy
  99. +1 −0  grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/GroovyCollectTagTests.java
  100. +78 −78 grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/RenderTagLibTests.groovy
  101. +50 −50 grails-test-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/taglib/ReturnValueTagLibTests.groovy
  102. +1 −1  grails-web/src/main/groovy/grails/gsp/PageRenderer.groovy
  103. +5 −6 grails-web/src/main/groovy/grails/util/GrailsWebUtil.java
  104. +1 −1  grails-web/src/main/groovy/org/codehaus/groovy/grails/plugins/web/api/CommonWebApi.java
  105. +12 −6 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/binding/GrailsDataBinder.java
  106. +2 −2 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultLinkGenerator.groovy
  107. +6 −4 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPage.java
  108. +15 −16 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageBinding.java
  109. +47 −49 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageParser.java
  110. +5 −5 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageRequestBinding.java
  111. +28 −28 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageScanner.java
  112. +6 −6 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageTemplate.java
  113. +19 −19 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPageWritable.java
  114. +2 −2 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPagesServlet.java
  115. +26 −22 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/GrailsParameterMap.java
  116. +4 −4 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/view/GroovyPageView.java
  117. +2 −2 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/sitemesh/GrailsContentBufferingResponse.java
  118. +3 −1 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/GroovyPageAttributes.java
  119. +4 −5 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/GroovySyntaxTag.java
  120. +1 −1  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/jsp/JspFormRemoteTag.java
  121. +1 −1  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/jsp/JspFormTag.java
  122. +1 −1  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/jsp/JspLinkTag.java
  123. +1 −1  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/jsp/JspRemoteFunctionTag.java
  124. +1 −1  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/jsp/JspRemoteLinkTag.java
  125. +1 −1  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/jsp/JspSubmitToRemoteTag.java
  126. +89 −86 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/util/AbstractTypeConvertingMap.java
  127. +3 −3 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/util/GrailsPrintWriter.java
  128. +36 −37 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/util/StreamCharBuffer.java
  129. +61 −64 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/util/TypeConvertingMap.groovy
  130. +9 −11 scripts/RefreshDependencies.groovy
  131. +2 −2 scripts/Upgrade.groovy
  132. +5 −9 scripts/_GrailsPluginDev.groovy
  133. +9 −9 scripts/_GrailsRun.groovy
  134. +1 −1  scripts/_GrailsWar.groovy
View
21 grails-bootstrap/src/main/groovy/grails/build/logging/GrailsConsole.java
@@ -142,7 +142,7 @@ protected ConsoleReader createConsoleReader() throws IOException {
* is controlled by the jline.terminal system property.
*/
protected Terminal createTerminal() {
- Terminal terminal;
+ @SuppressWarnings("hiding") Terminal terminal;
if (isWindows()) {
terminal = new WindowsTerminal() {
@Override
@@ -170,12 +170,12 @@ public boolean isANSISupported() {
* like they do not understand ansi, even if we were to implement support in Eclipse to'
* handle it and the wrapped stream will not pass the ansi chars on to Eclipse).
*/
- protected OutputStream ansiWrap(OutputStream out) {
+ protected OutputStream ansiWrap(@SuppressWarnings("hiding") OutputStream out) {
return AnsiConsole.wrapOutputStream(out);
}
// hack to workaround JLine bug - see https://issues.apache.org/jira/browse/GERONIMO-3978 for source of fix
- private void fixCtrlC() throws IOException {
+ private void fixCtrlC() {
try {
Field f = ConsoleReader.class.getDeclaredField("keybindings");
f.setAccessible(true);
@@ -592,14 +592,13 @@ public String userInput(String msg) {
* @return The user input prompt
*/
private String showPrompt(String prompt) {
- cursorMove = 0;
- if(!userInputActive) {
- return readLine(prompt);
- }
- else {
- out.print(prompt);
- return null;
- }
+ cursorMove = 0;
+ if (!userInputActive) {
+ return readLine(prompt);
+ }
+
+ out.print(prompt);
+ return null;
}
private String readLine(String prompt) {
View
2  grails-bootstrap/src/main/groovy/grails/build/logging/GrailsEclipseConsole.java
@@ -50,7 +50,7 @@ protected GrailsEclipseConsole() throws IOException {
}
@Override
- protected OutputStream ansiWrap(OutputStream out) {
+ protected OutputStream ansiWrap(@SuppressWarnings("hiding") OutputStream out) {
if (DEBUG) {
try {
out.write(("<<<"+ECLIPSE_SUPPORTS_ANSI_PROP+":"+eclipseSupportsAnsi()+">>>\n").getBytes());
View
11 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/parsing/CommandLine.java
@@ -15,9 +15,6 @@
*/
package org.codehaus.groovy.grails.cli.parsing;
-import groovy.lang.Closure;
-import org.codehaus.groovy.grails.cli.GrailsScriptRunner;
-
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -40,7 +37,6 @@
String NON_INTERACTIVE_ARGUMENT = "non-interactive";
/**
- *
* @return The environment specified
*/
String getEnvironment();
@@ -51,19 +47,16 @@
boolean isEnvironmentSet();
/**
- *
* @return The command name specified
*/
String getCommandName();
/**
- *
* @return The remaining arguments after the command name
*/
List<String> getRemainingArgs();
/**
- *
* @return The remaining arguments as an array
*/
String[] getRemainingArgsArray();
@@ -74,11 +67,10 @@
Properties getSystemProperties();
/**
- *
* @param name The name of the option
* @return Whether the given option is specified
*/
- public boolean hasOption(String name);
+ boolean hasOption(String name);
/**
* The value of an option
@@ -97,6 +89,5 @@
*/
String getRemainingArgsLineSeparated();
-
Map<String, Object> getUndeclaredOptions();
}
View
12 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/parsing/CommandLineParser.java
@@ -74,12 +74,12 @@ public void addOption(String name, String description) {
*/
public CommandLine parseString(String string) {
// Steal ants implementation for argument splitting. Handles quoted arguments with " or '.
- // Doesn't handle escape sequences with \
- try {
- return parse(Commandline.translateCommandline(string));
- } catch (BuildException e) {
- throw new ParseException(e); //Rethrow as an error that clients can expect.
- }
+ // Doesn't handle escape sequences with \
+ try {
+ return parse(Commandline.translateCommandline(string));
+ } catch (BuildException e) {
+ throw new ParseException(e); //Rethrow as an error that clients can expect.
+ }
}
/**
View
4 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/parsing/ParseException.java
@@ -28,8 +28,8 @@
public ParseException(String message) {
super(message);
}
-
+
public ParseException(Throwable cause) {
- super(cause);
+ super(cause);
}
}
View
78 grails-bootstrap/src/test/groovy/org/codehaus/groovy/grails/cli/parsing/CommandLineParserSpec.groovy
@@ -5,7 +5,7 @@ import spock.lang.Specification
/**
* Tests for {@link CommandLineParser}
*/
-class CommandLineParserSpec extends Specification{
+class CommandLineParserSpec extends Specification {
void "Test parse basic command"() {
when:
@@ -66,11 +66,10 @@ class CommandLineParserSpec extends Specification{
then:
thrown ParseException
-
}
void "Test parse command with environment, sys props, arguments and undeclared options"() {
- when:
+ when:
def parser = new CommandLineParser()
def cl = parser.parse("prod", "run-app", "-DmyProp=value", "foo", "bar", "--dev-mode")
@@ -83,7 +82,6 @@ class CommandLineParserSpec extends Specification{
cl.remainingArgs == ['foo', 'bar']
cl.hasOption('dev-mode')
cl.optionValue('dev-mode') == true
-
}
void "Test parse command with environment, sys props, arguments and undeclared options with values"() {
@@ -100,7 +98,6 @@ class CommandLineParserSpec extends Specification{
cl.remainingArgs == ['foo', 'bar']
cl.hasOption('host')
cl.optionValue('host') == "localhost"
-
}
void "Test help message with declared options"() {
@@ -112,9 +109,7 @@ class CommandLineParserSpec extends Specification{
then:
String ls = System.getProperty("line.separator");
parser.helpMessage == "usage: grails [options] [command]${ls} -interactive-mode Enabled interactive mode${ls} -version Shows the vesrion${ls}"
- }
-
-
+ }
// STRING tests
@@ -186,7 +181,6 @@ class CommandLineParserSpec extends Specification{
cl.remainingArgs == ['foo', 'bar']
cl.hasOption('dev-mode')
cl.optionValue('dev-mode') == true
-
}
void "Test parse string command with environment, sys props, arguments and undeclared options with values"() {
@@ -205,8 +199,8 @@ class CommandLineParserSpec extends Specification{
cl.optionValue('host') == "localhost"
}
-
- void "Test that parseString handles quoted arguments with double quotes"() {
+
+ void "Test that parseString handles quoted arguments with double quotes"() {
when:
def parser = new CommandLineParser()
def cl = parser.parseString('refresh-dependencies --include-sources "file with spaces.xml"')
@@ -216,37 +210,37 @@ class CommandLineParserSpec extends Specification{
cl.systemProperties.size() == 0
cl.remainingArgs.size() == 1
cl.remainingArgs == ['file with spaces.xml']
- }
-
- void "Test that parseString handles quoted arguments with single quotes"() {
- when:
- def parser = new CommandLineParser()
- def cl = parser.parseString("refresh-dependencies --include-sources 'file with spaces.xml'")
-
- then:
- cl.commandName == 'refresh-dependencies'
- cl.systemProperties.size() == 0
- cl.remainingArgs.size() == 1
- cl.remainingArgs == ['file with spaces.xml']
- cl.hasOption('include-sources')
- cl.optionValue('include-sources') == true
- }
-
- void "Test that parseString with unbalanced double quotes throws ParseException"() {
- when:
- def parser = new CommandLineParser()
- def cl = parser.parseString("refresh-dependencies --include-sources 'file with spaces.xml")
-
- then:
+ }
+
+ void "Test that parseString handles quoted arguments with single quotes"() {
+ when:
+ def parser = new CommandLineParser()
+ def cl = parser.parseString("refresh-dependencies --include-sources 'file with spaces.xml'")
+
+ then:
+ cl.commandName == 'refresh-dependencies'
+ cl.systemProperties.size() == 0
+ cl.remainingArgs.size() == 1
+ cl.remainingArgs == ['file with spaces.xml']
+ cl.hasOption('include-sources')
+ cl.optionValue('include-sources') == true
+ }
+
+ void "Test that parseString with unbalanced double quotes throws ParseException"() {
+ when:
+ def parser = new CommandLineParser()
+ def cl = parser.parseString("refresh-dependencies --include-sources 'file with spaces.xml")
+
+ then:
thrown ParseException
- }
-
- void "Test that parseString with unbalanced single quotes throws ParseException"() {
- when:
- def parser = new CommandLineParser()
- def cl = parser.parseString('refresh-dependencies --include-sources "file with spaces.xml')
-
- then:
+ }
+
+ void "Test that parseString with unbalanced single quotes throws ParseException"() {
+ when:
+ def parser = new CommandLineParser()
+ def cl = parser.parseString('refresh-dependencies --include-sources "file with spaces.xml')
+
+ then:
thrown ParseException
- }
+ }
}
View
15 grails-core/src/main/groovy/grails/validation/ValidationErrors.groovy
@@ -13,24 +13,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package grails.validation;
+package grails.validation
-import org.springframework.validation.BeanPropertyBindingResult;
+import org.springframework.validation.BeanPropertyBindingResult
/**
- *
- * Models validation errors in a Grails application
- *
+ * Models validation errors in a Grails application.
+ *
* @author Graeme Rocher
* @since 2.0
*/
-public class ValidationErrors extends BeanPropertyBindingResult {
+class ValidationErrors extends BeanPropertyBindingResult {
- public ValidationErrors(Object target) {
+ ValidationErrors(Object target) {
super(target, target.getClass().name)
}
- public ValidationErrors(Object target, String objectName) {
+ ValidationErrors(Object target, String objectName) {
super(target, objectName)
}
View
23 grails-core/src/main/groovy/grails/web/CamelCaseUrlConverter.java
@@ -1,15 +1,28 @@
+/*
+ * Copyright 2011 SpringSource.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package grails.web;
import java.util.Locale;
import org.apache.commons.lang.StringUtils;
-import grails.util.GrailsNameUtils;
-
public class CamelCaseUrlConverter implements UrlConverter {
public String toUrlElement(String propertyOrClassName) {
- if(StringUtils.isBlank(propertyOrClassName)) {
+ if (StringUtils.isBlank(propertyOrClassName)) {
return propertyOrClassName;
}
if (propertyOrClassName.length() > 1 && Character.isUpperCase(propertyOrClassName.charAt(0)) &&
@@ -17,8 +30,6 @@ public String toUrlElement(String propertyOrClassName) {
return propertyOrClassName;
}
- String uriElement = propertyOrClassName.substring(0,1).toLowerCase(Locale.ENGLISH) + propertyOrClassName.substring(1);
- return uriElement;
+ return propertyOrClassName.substring(0,1).toLowerCase(Locale.ENGLISH) + propertyOrClassName.substring(1);
}
-
}
View
18 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsControllerClass.java
@@ -175,7 +175,7 @@ private void configureMappingForMethodAction(String closureName) {
String tmpUri = controllerPath + urlConverter.toUrlElement(closureName);
uri2methodMap.put(tmpUri, closureName);
uri2methodMap.put(tmpUri + SLASH + "**", closureName);
-
+
String viewPath = SLASH + GrailsNameUtils.getPropertyNameRepresentation(getName()) + SLASH + closureName;
uri2viewMap.put(tmpUri, viewPath);
viewNames.put(closureName, viewPath);
@@ -299,19 +299,19 @@ public Closure getAfterInterceptor(GroovyObject controller) {
private Closure getInterceptor(GroovyObject controller, Object ip) {
Closure interceptor=null;
- if (ip instanceof Map) {
+ if (ip instanceof Map) {
Map ipMap = (Map) ip;
if (ipMap.containsKey(ACTION)) {
- interceptor=(Closure) ipMap.get(ACTION);
+ interceptor=(Closure) ipMap.get(ACTION);
}
} else if (ip instanceof Closure) {
- interceptor=(Closure) ip;
+ interceptor=(Closure) ip;
+ }
+ if(interceptor != null && interceptor.getDelegate() != controller) {
+ interceptor = (Closure)interceptor.clone();
+ interceptor.setDelegate(controller);
+ interceptor.setResolveStrategy(Closure.DELEGATE_FIRST);
}
- if(interceptor != null && interceptor.getDelegate() != controller) {
- interceptor = (Closure)interceptor.clone();
- interceptor.setDelegate(controller);
- interceptor.setResolveStrategy(Closure.DELEGATE_FIRST);
- }
return interceptor;
}
View
14 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/DefaultGrailsDomainClassProperty.java
@@ -73,7 +73,6 @@
* @param domainClass
* @param descriptor
*/
- @SuppressWarnings("rawtypes")
public DefaultGrailsDomainClassProperty(GrailsDomainClass domainClass, PropertyDescriptor descriptor) {
this(domainClass, descriptor, null);
}
@@ -169,13 +168,13 @@ private List getTransients() {
allTransientProps.addAll(transientList);
}
}
-
+
return allTransientProps;
}
-
+
private List<Class<?>> getAllDomainClassesInHierarchy() {
List<Class<?>> classesInHierarchy = new ArrayList<Class<?>>();
-
+
Class<?> currentClass = domainClass.getClazz();
while(currentClass != null) {
classesInHierarchy.add(currentClass);
@@ -568,13 +567,10 @@ public ComponentDomainClass(Class<?> type) {
}
private ConstraintsEvaluator getConstraintsEvaluator() {
- GrailsDomainClass domainClass = DefaultGrailsDomainClassProperty.this.domainClass;
- if(domainClass instanceof DefaultGrailsDomainClass) {
+ if (domainClass instanceof DefaultGrailsDomainClass) {
return ((DefaultGrailsDomainClass) domainClass).getConstraintsEvaluator();
}
- else {
- return new DefaultConstraintEvaluator();
- }
+ return new DefaultConstraintEvaluator();
}
private GrailsDomainClassProperty[] createDomainClassProperties(PropertyDescriptor[] descriptors) {
View
8 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/DomainClassArtefactHandler.java
@@ -29,20 +29,18 @@
* @author Graeme Rocher
* @author Marc Palmer (marc@anyware.co.uk)
*/
-public class DomainClassArtefactHandler extends ArtefactHandlerAdapter implements GrailsApplicationAware{
+public class DomainClassArtefactHandler extends ArtefactHandlerAdapter implements GrailsApplicationAware {
public static final String TYPE = "Domain";
- private GrailsApplication grailsApplication;
private Map<String, Object> defaultConstraints;
public DomainClassArtefactHandler() {
super(TYPE, GrailsDomainClass.class, DefaultGrailsDomainClass.class, null, true);
}
public void setGrailsApplication(GrailsApplication grailsApplication) {
- this.grailsApplication = grailsApplication;
- if(grailsApplication != null) {
- this.defaultConstraints = ConstraintEvalUtils.getDefaultConstraints(grailsApplication.getConfig());
+ if (grailsApplication != null) {
+ defaultConstraints = ConstraintEvalUtils.getDefaultConstraints(grailsApplication.getConfig());
}
}
View
29 grails-core/src/main/groovy/org/codehaus/groovy/grails/commons/GrailsDomainConfigurationUtil.java
@@ -303,23 +303,22 @@ public static boolean isNotConfigurational(PropertyDescriptor descriptor) {
Method readMethod = descriptor.getReadMethod();
Method writeMethod = descriptor.getWriteMethod();
- if((readMethod != null && Modifier.isStatic(readMethod.getModifiers()) || (writeMethod != null && Modifier.isStatic(writeMethod.getModifiers())))) {
+ if ((readMethod != null && Modifier.isStatic(readMethod.getModifiers()) ||
+ (writeMethod != null && Modifier.isStatic(writeMethod.getModifiers())))) {
return false;
}
- else {
-
- return !Errors.class.isAssignableFrom(descriptor.getPropertyType()) &&
- !name.equals(GrailsDomainClassProperty.META_CLASS) &&
- !name.equals(GrailsDomainClassProperty.CLASS) &&
- !name.equals(GrailsDomainClassProperty.TRANSIENT) &&
- !name.equals(GrailsDomainClassProperty.RELATES_TO_MANY) &&
- !name.equals(GrailsDomainClassProperty.HAS_MANY) &&
- !name.equals(GrailsDomainClassProperty.EVANESCENT) &&
- !name.equals(GrailsDomainClassProperty.CONSTRAINTS) &&
- !name.equals(GrailsDomainClassProperty.MAPPING_STRATEGY) &&
- !name.equals(GrailsDomainClassProperty.MAPPED_BY) &&
- !name.equals(GrailsDomainClassProperty.BELONGS_TO);
- }
+
+ return !Errors.class.isAssignableFrom(descriptor.getPropertyType()) &&
+ !name.equals(GrailsDomainClassProperty.META_CLASS) &&
+ !name.equals(GrailsDomainClassProperty.CLASS) &&
+ !name.equals(GrailsDomainClassProperty.TRANSIENT) &&
+ !name.equals(GrailsDomainClassProperty.RELATES_TO_MANY) &&
+ !name.equals(GrailsDomainClassProperty.HAS_MANY) &&
+ !name.equals(GrailsDomainClassProperty.EVANESCENT) &&
+ !name.equals(GrailsDomainClassProperty.CONSTRAINTS) &&
+ !name.equals(GrailsDomainClassProperty.MAPPING_STRATEGY) &&
+ !name.equals(GrailsDomainClassProperty.MAPPED_BY) &&
+ !name.equals(GrailsDomainClassProperty.BELONGS_TO);
}
/**
View
2  grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/GrailsProjectWatcher.java
@@ -128,7 +128,7 @@ public void onChange(File file) {
public void onNew(File file) {
LOG.info("File [" + file + "] added. Applying changes to application.");
if (!file.getName().toLowerCase().endsWith(".properties")) {
- // only sleep for source files, not i18n files
+ // only sleep for source files, not i18n files
sleep(5000);
}
compileIfSource(file);
View
2  grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/GrailsASTUtils.java
@@ -188,7 +188,7 @@ public static MethodNode addDelegateInstanceMethod(ClassNode classNode, Expressi
if(propertyName != null && parameterTypes.length == 1 && classNode.hasProperty(propertyName)) {
return null;
}
-
+
BlockStatement methodBody = new BlockStatement();
ArgumentListExpression arguments = createArgumentListFromParameters(parameterTypes, thisAsFirstArgument);
View
2  grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/DefaultGrailsPluginManager.java
@@ -89,7 +89,7 @@
* @author Graeme Rocher
* @since 0.4
*/
-public class DefaultGrailsPluginManager extends AbstractGrailsPluginManager implements GrailsPluginManager {
+public class DefaultGrailsPluginManager extends AbstractGrailsPluginManager {
private static final Log LOG = LogFactory.getLog(DefaultGrailsPluginManager.class);
protected static final Class<?>[] COMMON_CLASSES = {
View
12 grails-core/src/main/groovy/org/codehaus/groovy/grails/support/SoftThreadLocalMap.java
@@ -15,6 +15,9 @@
*/
package org.codehaus.groovy.grails.support;
+import java.util.Collections;
+import java.util.Map;
+
import org.apache.commons.collections.map.ReferenceMap;
/**
@@ -23,13 +26,14 @@
* @author Graeme Rocher
* @since 0.6
*/
-public class SoftThreadLocalMap extends InheritableThreadLocal<ReferenceMap> {
+@SuppressWarnings({ "unchecked", "rawtypes" })
+public class SoftThreadLocalMap extends InheritableThreadLocal<Map> {
/**
- * Creates an initial value of a Map
+ * Creates an initial value of a Map.
*/
@Override
- protected ReferenceMap initialValue() {
- return new ReferenceMap(ReferenceMap.SOFT, ReferenceMap.SOFT);
+ protected Map initialValue() {
+ return Collections.synchronizedMap(new ReferenceMap(ReferenceMap.SOFT, ReferenceMap.SOFT));
}
}
View
7 grails-core/src/test/groovy/grails/web/CamelCaseUrlConverterSpec.groovy
@@ -4,17 +4,16 @@ import grails.web.CamelCaseUrlConverter;
import spock.lang.Specification
import spock.lang.Unroll
-
class CamelCaseUrlConverterSpec extends Specification {
-
+
@Unroll({"converting $classOrActionName to url element $expectedUrlElement"})
def 'Test converting class and action names to url elements'() {
given:
def converter = new CamelCaseUrlConverter()
-
+
expect:
converter.toUrlElement(classOrActionName) == expectedUrlElement
-
+
where:
classOrActionName | expectedUrlElement
'Widget' | 'widget'
View
7 grails-core/src/test/groovy/grails/web/HyphenatedUrlConverterSpec.groovy
@@ -4,17 +4,16 @@ import grails.web.HyphenatedUrlConverter;
import spock.lang.Specification
import spock.lang.Unroll
-
class HyphenatedUrlConverterSpec extends Specification {
-
+
@Unroll({"converting $classOrActionName to url element $expectedUrlElement"})
def 'Test converting class and action names to url elements'() {
given:
def converter = new HyphenatedUrlConverter()
-
+
expect:
converter.toUrlElement(classOrActionName) == expectedUrlElement
-
+
where:
classOrActionName | expectedUrlElement
'Widget' | 'widget'
View
2  ...-core/src/test/groovy/org/codehaus/groovy/grails/compiler/injection/GrailsArtefactTransformerSpec.groovy
@@ -92,7 +92,7 @@ class TestTransformer extends AbstractGrailsArtefactTransformer {
boolean shouldInject(URL arg0) {
true
- }
+ }
}
class TestInstanceApi {
View
6 grails-crud/src/main/groovy/org/codehaus/groovy/grails/scaffolding/view/ScaffoldedGroovyPageView.java
@@ -80,9 +80,9 @@ protected void renderWithTemplateEngine(GroovyPagesTemplateEngine templateEngine
}
Template t = templateEngine.createTemplate(contents, getUrl());
- if(t instanceof GroovyPageTemplate) {
- ((GroovyPageTemplate)t).setAllowSettingContentType(true);
- }
+ if (t instanceof GroovyPageTemplate) {
+ ((GroovyPageTemplate)t).setAllowSettingContentType(true);
+ }
Writable w = t.make(model);
Writer out = null;
try {
View
4 grails-docs/src/main/groovy/grails/doc/DocPublisher.groovy
@@ -260,7 +260,7 @@ class DocPublisher {
sponsorLogo: injectPath(sponsorLogo, pathToRoot),
single: false,
path: pathToRoot,
- resourcesPath: calculatePathToResources(pathToRoot),
+ resourcesPath: calculatePathToResources(pathToRoot),
prev: null,
next: null,
legacyLinks: legacyLinks
@@ -553,7 +553,7 @@ class DocPublisher {
}
private String calculatePathToResources(String pathToRoot) {
- return language ? '../' + pathToRoot : pathToRoot
+ return language ? '../' + pathToRoot : pathToRoot
}
private initContext(context, path) {
View
2  grails-docs/src/main/groovy/grails/doc/internal/LegacyTocStrategy.groovy
@@ -3,7 +3,7 @@ package grails.doc.internal
class LegacyTocStrategy {
def generateToc(files) {
// Compares two gdoc filenames based on the section number in the
- // form x.y.z...
+ // form x.y.z...
def sectionNumberComparator = [
compare: {o1, o2 ->
def idx1 = o1.name[0..o1.name.indexOf(' ') - 1]
View
2  grails-docs/src/test/groovy/grails/doc/internal/YamlTocStrategySpec.groovy
@@ -17,7 +17,7 @@ class YamlTocStrategySpec extends Specification {
"gettingStarted.gdoc",
"downloading.gdoc",
"upgrading.gdoc",
- "creatingApp.gdoc"]))
+ "creatingApp.gdoc"]))
when: "A test YAML document is loaded"
def toc = loader.load("""\
View
44 grails-hibernate/src/main/groovy/grails/orm/HibernateCriteriaBuilder.java
@@ -15,14 +15,43 @@
*/
package grails.orm;
-import groovy.lang.*;
-import org.codehaus.groovy.grails.commons.*;
+import groovy.lang.Closure;
+import groovy.lang.GroovyObjectSupport;
+import groovy.lang.GroovySystem;
+import groovy.lang.MetaClass;
+import groovy.lang.MetaMethod;
+import groovy.lang.MissingMethodException;
+
+import java.beans.PropertyDescriptor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.codehaus.groovy.grails.commons.GrailsApplication;
+import org.codehaus.groovy.grails.commons.GrailsClassUtils;
import org.codehaus.groovy.grails.orm.hibernate.cfg.GrailsHibernateUtil;
-import org.grails.datastore.mapping.query.api.*;
-import org.hibernate.*;
import org.hibernate.Criteria;
-import org.hibernate.criterion.*;
+import org.hibernate.EntityMode;
+import org.hibernate.FetchMode;
+import org.hibernate.LockMode;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.criterion.AggregateProjection;
+import org.hibernate.criterion.CountProjection;
+import org.hibernate.criterion.CriteriaSpecification;
+import org.hibernate.criterion.Criterion;
+import org.hibernate.criterion.IdentifierProjection;
+import org.hibernate.criterion.Junction;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Projection;
+import org.hibernate.criterion.ProjectionList;
import org.hibernate.criterion.Projections;
+import org.hibernate.criterion.PropertyProjection;
+import org.hibernate.criterion.Restrictions;
+import org.hibernate.criterion.SimpleExpression;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.transform.ResultTransformer;
@@ -32,9 +61,6 @@
import org.springframework.orm.hibernate3.SessionHolder;
import org.springframework.transaction.support.TransactionSynchronizationManager;
-import java.beans.PropertyDescriptor;
-import java.util.*;
-
/**
* <p>Wraps the Hibernate Criteria API in a builder. The builder can be retrieved through the "createCriteria()" dynamic static
* method of Grails domain classes (Example in Groovy):
@@ -1246,7 +1272,7 @@ else if (paginationEnabledList) {
addOrder(criteria, aliasMap.get(associationForOrdering) + "." + sort.substring(lastPropertyPos + 1),
order, ignoreCase);
// remove sort from arguments map to exclude from default processing.
- Map argMap2 = new HashMap(argMap);
+ @SuppressWarnings("unchecked") Map argMap2 = new HashMap(argMap);
argMap2.remove(GrailsHibernateUtil.ARGUMENT_SORT);
argMap = argMap2;
}
View
8 ...ernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/ConfigurableLocalSessionFactoryBean.java
@@ -130,8 +130,6 @@ protected Configuration newConfiguration() {
return (Configuration)config;
}
-
-
@Override
public SessionFactoryBuilder setClassLoader(ClassLoader beanClassLoader) {
this.classLoader = beanClassLoader;
@@ -153,7 +151,7 @@ public void afterPropertiesSet() throws Exception {
@Override
protected SessionFactory newSessionFactory() throws HibernateException {
try {
- SessionFactory sf = super.newSessionFactory();
+ SessionFactory sf = super.newSessionFactory();
if (!grails.util.Environment.getCurrent().isReloadEnabled() || !proxyIfReloadEnabled) {
return sf;
@@ -182,10 +180,8 @@ protected SessionFactory newSessionFactory() throws HibernateException {
}
throw e;
}
-
}
-
private String getCauseMessage(HibernateException e) {
Throwable cause = e.getCause();
if (cause instanceof InvocationTargetException) {
@@ -291,10 +287,8 @@ protected void postProcessConfiguration() throws HibernateException {
listeners.getPostCollectionRemoveEventListeners(), listenerMap);
addNewListenerToConfiguration(config, "post-collection-update", PostCollectionUpdateEventListener.class,
listeners.getPostCollectionUpdateEventListeners(), listenerMap);
-
}
-
@SuppressWarnings("unchecked")
private <T> void addNewListenerToConfiguration(final Configuration config, final String listenerType,
final Class<? extends T> klass, final T[] currentListeners, final Map<String,Object> newlistenerMap) {
View
19 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/HibernateDatastore.java
@@ -14,29 +14,30 @@
*/
package org.codehaus.groovy.grails.orm.hibernate;
+import java.util.Map;
+
+import org.grails.datastore.gorm.events.DomainEventListener;
+import org.grails.datastore.mapping.core.AbstractDatastore;
+import org.grails.datastore.mapping.core.Session;
+import org.grails.datastore.mapping.model.MappingContext;
import org.hibernate.SessionFactory;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
-import org.grails.datastore.mapping.core.AbstractDatastore;
-import org.grails.datastore.mapping.core.Session;
-import org.grails.datastore.mapping.model.MappingContext;
import org.springframework.util.Assert;
-import java.util.Map;
-
/**
- * Datastore implementation that uses a Hibernate SessionFactory underneath
+ * Datastore implementation that uses a Hibernate SessionFactory underneath.
*
* @author Graeme Rocher
- * @since 1.0
+ * @since 2.0
*/
public class HibernateDatastore extends AbstractDatastore {
private SessionFactory sessionFactory;
- public HibernateDatastore(MappingContext mappingContext,
- SessionFactory sessionFactory, ApplicationContext applicationContext) {
+ public HibernateDatastore(MappingContext mappingContext, SessionFactory sessionFactory,
+ ApplicationContext applicationContext) {
super(mappingContext);
this.sessionFactory = sessionFactory;
super.initializeConverters(mappingContext);
View
118 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/HibernateGormEnhancer.groovy
@@ -68,7 +68,7 @@ class HibernateGormEnhancer extends GormEnhancer {
HibernateGormEnhancer(HibernateDatastore datastore,
PlatformTransactionManager transactionManager,
GrailsApplication grailsApplication) {
- super(datastore, transactionManager);
+ super(datastore, transactionManager)
this.grailsApplication = grailsApplication
classLoader = grailsApplication.classLoader
finders = createPersistentMethods(grailsApplication, classLoader, datastore)
@@ -105,13 +105,13 @@ class HibernateGormEnhancer extends GormEnhancer {
}
@Override
- protected void registerNamedQueries(PersistentEntity entity, Object namedQueries) {
+ protected void registerNamedQueries(PersistentEntity entity, namedQueries) {
if (grailsApplication == null) {
return
}
def domainClass = grailsApplication.getArtefact(DomainClassArtefactHandler.TYPE, entity.name)
- if (domainClass != null) {
+ if (domainClass) {
new HibernateNamedQueriesBuilder(domainClass, finders).evaluate((Closure)namedQueries)
}
}
@@ -137,7 +137,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
private ExecuteUpdatePersistentMethod executeUpdateMethod
private MergePersistentMethod mergeMethod
private ClassLoader classLoader
- private GrailsApplication grailsApplication;
+ private GrailsApplication grailsApplication
HibernateGormStaticApi(Class persistentClass, HibernateDatastore datastore, List<FinderMethod> finders,
ClassLoader classLoader, PlatformTransactionManager transactionManager) {
@@ -173,7 +173,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
D get(Serializable id) {
if (id || (id instanceof Number)) {
id = convertIdentifier(id)
- final Object result = hibernateTemplate.get(persistentClass, id)
+ final result = hibernateTemplate.get(persistentClass, id)
return GrailsHibernateUtil.unwrapIfProxy(result)
}
}
@@ -186,8 +186,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
id = id.toLong()
}
else {
- SimpleTypeConverter typeConverter = new SimpleTypeConverter()
- id = typeConverter.convertIfNecessary(id, idType)
+ id = new SimpleTypeConverter().convertIfNecessary(id, idType)
}
} catch (e) {
// ignore
@@ -273,7 +272,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
}
@Override
- D merge(Object o) {
+ D merge(o) {
mergeMethod.invoke(o, "merge", [] as Object[])
}
@@ -309,12 +308,12 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
}
@Override
- List<D> findAll(Object example, Map args) {
+ List<D> findAll(example, Map args) {
findAllMethod.invoke(persistentClass, "findAll", [example, args] as Object[])
}
@Override
- D find(Object example, Map args) {
+ D find(example, Map args) {
findMethod.invoke(persistentClass, "find", [example, args] as Object[])
}
@@ -326,9 +325,9 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
* @param max The maximum to return
* @return A single result or null
*
- *
* @deprecated Use Book.find('..', [foo:'bar], [max:10]) instead
*/
+ @Deprecated
D find(String query, Map args, Integer max) {
findMethod.invoke(persistentClass, "find", [query, args, max] as Object[])
}
@@ -342,9 +341,9 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
* @param offset The offset
* @return A single result or null
*
- *
* @deprecated Use Book.find('..', [foo:'bar], [max:10, offset:5]) instead
*/
+ @Deprecated
D find(String query, Map args, Integer max, Integer offset) {
findMethod.invoke(persistentClass, "find", [query, args, max, offset] as Object[])
}
@@ -356,9 +355,9 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
* @param max The maximum to return
* @return A single result or null
*
- *
* @deprecated Use Book.find('..', [max:10]) instead
*/
+ @Deprecated
D find(String query, Integer max) {
findMethod.invoke(persistentClass, "find", [query, max] as Object[])
}
@@ -373,6 +372,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
*
* @deprecated Use Book.find('..', [max:10, offset:5]) instead
*/
+ @Deprecated
D find(String query, Integer max, Integer offset) {
findMethod.invoke(persistentClass, "find", [query, max, offset] as Object[])
}
@@ -387,6 +387,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
*
* @deprecated Use findAll('..', [foo:'bar], [max:10]) instead
*/
+ @Deprecated
List<D> findAll(String query, Map args, Integer max) {
findAllMethod.invoke(persistentClass, "findAll", [query, args, max] as Object[])
}
@@ -403,6 +404,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
*
* @deprecated Use findAll('..', [foo:'bar], [max:10, offset:5]) instead
*/
+ @Deprecated
List<D> findAll(String query, Map args, Integer max, Integer offset) {
findAllMethod.invoke(persistentClass, "findAll", [query, args, max, offset] as Object[])
}
@@ -416,6 +418,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
*
* @deprecated Use findAll('..', [max:10]) instead
*/
+ @Deprecated
List<D> findAll(String query, Integer max) {
findAllMethod.invoke(persistentClass, "findAll", [query, max] as Object[])
}
@@ -429,6 +432,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
*
* @deprecated Use findAll('..', [max:10, offset:5]) instead
*/
+ @Deprecated
List<D> findAll(String query, Integer max, Integer offset) {
findAllMethod.invoke(persistentClass, "findAll", [query, max, offset] as Object[])
}
@@ -490,7 +494,6 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
nullNames
}
-
@Override
Object withSession(Closure callable) {
new HibernateTemplate(sessionFactory).execute({ session ->
@@ -529,7 +532,7 @@ class HibernateGormStaticApi<D> extends GormStaticApi<D> {
executeQueryMethod.invoke(persistentClass, "executeQuery", [query] as Object[])
}
- List<D> executeQuery(String query, Object arg) {
+ List<D> executeQuery(String query, arg) {
executeQueryMethod.invoke(persistentClass, "executeQuery", [query, arg] as Object[])
}
@@ -645,7 +648,7 @@ class HibernateGormValidationApi extends GormValidationApi {
ValidatePersistentMethod validateMethod
HibernateGormValidationApi(Class persistentClass, HibernateDatastore datastore, ClassLoader classLoader) {
- super(persistentClass, datastore);
+ super(persistentClass, datastore)
this.classLoader = classLoader
@@ -655,42 +658,43 @@ class HibernateGormValidationApi extends GormValidationApi {
if (mappingContext instanceof GrailsDomainClassMappingContext) {
GrailsDomainClassMappingContext domainClassMappingContext = mappingContext
def grailsApplication = domainClassMappingContext.getGrailsApplication()
- def validator = mappingContext.getEntityValidator(mappingContext.getPersistentEntity(persistentClass.name))
- this.validateMethod = new ValidatePersistentMethod(sessionFactory,
+ def validator = mappingContext.getEntityValidator(
+ mappingContext.getPersistentEntity(persistentClass.name))
+ validateMethod = new ValidatePersistentMethod(sessionFactory,
classLoader, grailsApplication, validator)
}
}
@Override
- boolean validate(Object instance) {
- if (validateMethod != null) {
+ boolean validate(instance) {
+ if (validateMethod) {
return validateMethod.invoke(instance, "validate", [] as Object[])
}
- return super.validate(instance);
+ return super.validate(instance)
}
@Override
- boolean validate(Object instance, boolean evict) {
- if (validateMethod != null) {
+ boolean validate(instance, boolean evict) {
+ if (validateMethod) {
return validateMethod.invoke(instance, "validate", [evict] as Object[])
}
- return super.validate(instance, evict);
+ return super.validate(instance, evict)
}
@Override
- boolean validate(Object instance, Map arguments) {
- if (validateMethod != null) {
+ boolean validate(instance, Map arguments) {
+ if (validateMethod) {
return validateMethod.invoke(instance, "validate", [arguments] as Object[])
}
- return super.validate(instance, arguments);
+ return super.validate(instance, arguments)
}
@Override
- boolean validate(Object instance, List fields) {
- if (validateMethod != null) {
+ boolean validate(instance, List fields) {
+ if (validateMethod) {
return validateMethod.invoke(instance, "validate", [fields] as Object[])
}
- return super.validate(instance, arguments);
+ return super.validate(instance, arguments)
}
}
@@ -737,7 +741,7 @@ class HibernateGormInstanceApi extends GormInstanceApi {
*
* @return True if the field is dirty
*/
- boolean isDirty(Object instance, String fieldName) {
+ boolean isDirty(instance, String fieldName) {
def session = sessionFactory.currentSession
def entry = findEntityEntry(instance, session)
if (!entry) {
@@ -756,7 +760,7 @@ class HibernateGormInstanceApi extends GormInstanceApi {
* @param instance The instance
* @return True if it is dirty
*/
- boolean isDirty(Object instance) {
+ boolean isDirty(instance) {
def session = sessionFactory.currentSession
def entry = findEntityEntry(instance, session)
if (!entry) {
@@ -774,7 +778,7 @@ class HibernateGormInstanceApi extends GormInstanceApi {
* @param instance The instance
* @return A list of property names that are dirty
*/
- List getDirtyPropertyNames(Object instance) {
+ List getDirtyPropertyNames(instance) {
def session = sessionFactory.currentSession
def entry = findEntityEntry(instance, session)
if (!entry) {
@@ -796,7 +800,7 @@ class HibernateGormInstanceApi extends GormInstanceApi {
* @param fieldName The field name
* @return The original persisted value
*/
- Object getPersistentValue(Object instance, String fieldName) {
+ Object getPersistentValue(instance, String fieldName) {
def session = sessionFactory.currentSession
def entry = findEntityEntry(instance, session, false)
if (!entry) {
@@ -808,72 +812,72 @@ class HibernateGormInstanceApi extends GormInstanceApi {
}
@Override
- Object lock(Object instance) {
+ Object lock(instance) {
hibernateTemplate.lock(instance, LockMode.UPGRADE)
}
@Override
- Object refresh(Object instance) {
+ Object refresh(instance) {
hibernateTemplate.refresh(instance)
return instance
}
@Override
- Object save(Object instance) {
- if (saveMethod != null) {
+ Object save(instance) {
+ if (saveMethod) {
return saveMethod.invoke(instance, "save", EMPTY_ARRAY)
}
- return super.save(instance);
+ return super.save(instance)
}
- Object save(Object instance, boolean validate) {
- if (saveMethod != null) {
+ Object save(instance, boolean validate) {
+ if (saveMethod) {
return saveMethod.invoke(instance, "save", [validate] as Object[])
}
- return super.save(instance);
+ return super.save(instance, validate)
}
@Override
- Object merge(Object instance) {
- if (mergeMethod != null) {
+ Object merge(instance) {
+ if (mergeMethod) {
mergeMethod.invoke(instance, "merge", EMPTY_ARRAY)
}
else {
- return super.merge(instance);
+ return super.merge(instance)
}
}
@Override
- Object merge(Object instance, Map params) {
- if (mergeMethod != null) {
+ Object merge(instance, Map params) {
+ if (mergeMethod) {
mergeMethod.invoke(instance, "merge", [params] as Object[])
}
else {
- return super.merge(instance, params);
+ return super.merge(instance, params)
}
}
@Override
- Object save(Object instance, Map params) {
- if (saveMethod != null) {
+ Object save(instance, Map params) {
+ if (saveMethod) {
return saveMethod.invoke(instance, "save", [params] as Object[])
}
- return super.save(instance, params);
+ return super.save(instance, params)
}
@Override
- Object attach(Object instance) {
+ Object attach(instance) {
hibernateTemplate.lock(instance, LockMode.NONE)
return instance
}
@Override
- void discard(Object instance) {
+ void discard(instance) {
hibernateTemplate.evict instance
}
@Override
- void delete(Object instance) {
+ void delete(instance) {
def obj = instance
try {
hibernateTemplate.execute({Session session ->
@@ -889,7 +893,7 @@ class HibernateGormInstanceApi extends GormInstanceApi {
}
@Override
- void delete(Object instance, Map params) {
+ void delete(instance, Map params) {
def obj = instance
hibernateTemplate.delete obj
if (shouldFlush(params)) {
@@ -903,7 +907,7 @@ class HibernateGormInstanceApi extends GormInstanceApi {
}
@Override
- boolean instanceOf(Object instance, Class cls) {
+ boolean instanceOf(instance, Class cls) {
if (instance instanceof HibernateProxy) {
def o = GrailsHibernateUtil.unwrapProxy(instance)
return cls.isInstance(o)
@@ -912,7 +916,7 @@ class HibernateGormInstanceApi extends GormInstanceApi {
}
@Override
- boolean isAttached(Object instance) {
+ boolean isAttached(instance) {
hibernateTemplate.contains instance
}
View
196 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/cfg/GrailsDomainBinder.java
@@ -557,105 +557,105 @@ private static void bindCollectionSecondPass(GrailsDomainClassProperty property,
}
}
- private static String buildOrderByClause(String hqlOrderBy, PersistentClass associatedClass, String role, String defaultOrder) {
- String orderByString = null;
- if ( hqlOrderBy != null ) {
- List<String> properties = new ArrayList<String>();
- List<String> ordering = new ArrayList<String>();
- StringBuilder orderByBuffer = new StringBuilder();
- if ( hqlOrderBy.length() == 0 ) {
- //order by id
- Iterator it = associatedClass.getIdentifier().getColumnIterator();
- while ( it.hasNext() ) {
- Selectable col = (Selectable) it.next();
- orderByBuffer.append( col.getText() ).append( " asc" ).append( ", " );
- }
- }
- else {
- StringTokenizer st = new StringTokenizer( hqlOrderBy, " ,", false );
- String currentOrdering = defaultOrder;
- //FIXME make this code decent
- while ( st.hasMoreTokens() ) {
- String token = st.nextToken();
- if ( isNonPropertyToken( token ) ) {
- if ( currentOrdering != null ) {
- throw new GrailsDomainException(
- "Error while parsing sort clause: " + hqlOrderBy
- + " (" + role + ")"
- );
- }
- currentOrdering = token;
- }
- else {
- //Add ordering of the previous
- if ( currentOrdering == null ) {
- //default ordering
- ordering.add( "asc" );
- }
- else {
- ordering.add( currentOrdering );
- currentOrdering = null;
- }
- properties.add( token );
- }
- }
- ordering.remove( 0 ); //first one is the algorithm starter
- // add last one ordering
- if ( currentOrdering == null ) {
- //default ordering
- ordering.add(defaultOrder );
- }
- else {
- ordering.add( currentOrdering );
- currentOrdering = null;
- }
- int index = 0;
-
- for (String property : properties) {
- Property p = BinderHelper.findPropertyByName(associatedClass, property);
- if ( p == null ) {
- throw new GrailsDomainException(
- "property from sort clause not found: "
- + associatedClass.getEntityName() + "." + property
- );
- }
- PersistentClass pc = p.getPersistentClass();
- String table;
- if ( pc == null ) {
- table = "";
- }
-
- else if (pc == associatedClass
- || (associatedClass instanceof SingleTableSubclass && pc
- .getMappedClass().isAssignableFrom(
- associatedClass.getMappedClass()))) {
- table = "";
- } else {
- table = pc.getTable().getQuotedName() + ".";
- }
-
- Iterator propertyColumns = p.getColumnIterator();
- while ( propertyColumns.hasNext() ) {
- Selectable column = (Selectable) propertyColumns.next();
- orderByBuffer.append( table )
- .append( column.getText() )
- .append( " " )
- .append( ordering.get( index ) )
- .append( ", " );
- }
- index++;
- }
- }
- orderByString = orderByBuffer.substring( 0, orderByBuffer.length() - 2 );
- }
- return orderByString;
- }
+ @SuppressWarnings("unchecked")
+ private static String buildOrderByClause(String hqlOrderBy, PersistentClass associatedClass, String role, String defaultOrder) {
+ String orderByString = null;
+ if (hqlOrderBy != null) {
+ List<String> properties = new ArrayList<String>();
+ List<String> ordering = new ArrayList<String>();
+ StringBuilder orderByBuffer = new StringBuilder();
+ if (hqlOrderBy.length() == 0) {
+ //order by id
+ Iterator<?> it = associatedClass.getIdentifier().getColumnIterator();
+ while (it.hasNext()) {
+ Selectable col = (Selectable) it.next();
+ orderByBuffer.append(col.getText()).append(" asc").append(", ");
+ }
+ }
+ else {
+ StringTokenizer st = new StringTokenizer(hqlOrderBy, " ,", false);
+ String currentOrdering = defaultOrder;
+ //FIXME make this code decent
+ while (st.hasMoreTokens()) {
+ String token = st.nextToken();
+ if (isNonPropertyToken(token)) {
+ if (currentOrdering != null) {
+ throw new GrailsDomainException(
+ "Error while parsing sort clause: " + hqlOrderBy
+ + " (" + role + ")"
+ );
+ }
+ currentOrdering = token;
+ }
+ else {
+ //Add ordering of the previous
+ if (currentOrdering == null) {
+ //default ordering
+ ordering.add("asc");
+ }
+ else {
+ ordering.add(currentOrdering);
+ currentOrdering = null;
+ }
+ properties.add(token);
+ }
+ }
+ ordering.remove(0); //first one is the algorithm starter
+ // add last one ordering
+ if (currentOrdering == null) {
+ //default ordering
+ ordering.add(defaultOrder);
+ }
+ else {
+ ordering.add(currentOrdering);
+ currentOrdering = null;
+ }
+ int index = 0;
+
+ for (String property : properties) {
+ Property p = BinderHelper.findPropertyByName(associatedClass, property);
+ if (p == null) {
+ throw new GrailsDomainException(
+ "property from sort clause not found: "
+ + associatedClass.getEntityName() + "." + property
+ );
+ }
+ PersistentClass pc = p.getPersistentClass();
+ String table;
+ if (pc == null) {
+ table = "";
+ }
+
+ else if (pc == associatedClass
+ || (associatedClass instanceof SingleTableSubclass &&
+ pc.getMappedClass().isAssignableFrom(associatedClass.getMappedClass()))) {
+ table = "";
+ } else {
+ table = pc.getTable().getQuotedName() + ".";
+ }
+
+ Iterator<?> propertyColumns = p.getColumnIterator();
+ while (propertyColumns.hasNext()) {
+ Selectable column = (Selectable) propertyColumns.next();
+ orderByBuffer.append(table)
+ .append(column.getText())
+ .append(" ")
+ .append(ordering.get(index))
+ .append(", ");
+ }
+ index++;
+ }
+ }
+ orderByString = orderByBuffer.substring(0, orderByBuffer.length() - 2);
+ }
+ return orderByString;
+ }
private static boolean isNonPropertyToken(String token) {
- if ( " ".equals( token ) ) return true;
- if ( ",".equals( token ) ) return true;
- if ( token.equalsIgnoreCase( "desc" ) ) return true;
- if ( token.equalsIgnoreCase( "asc" ) ) return true;
+ if (" ".equals(token)) return true;
+ if (",".equals(token)) return true;
+ if (token.equalsIgnoreCase("desc")) return true;
+ if (token.equalsIgnoreCase("asc")) return true;
return false;
}
@@ -1708,7 +1708,7 @@ protected static void createClassProperties(GrailsDomainClass domainClass, Persi
if (collectionType != null) {
- String typeName = getTypeName(currentGrailsProp, getPropertyConfig(currentGrailsProp),gormMapping );
+ String typeName = getTypeName(currentGrailsProp, getPropertyConfig(currentGrailsProp),gormMapping);
if(typeName != null && "serializable".equals(typeName)) {
value = new SimpleValue(mappings,table);
bindSimpleValue(typeName, (SimpleValue) value, currentGrailsProp.isOptional(), getColumnNameForPropertyAndPath(currentGrailsProp, EMPTY_PATH, null, sessionFactoryBeanName), mappings);
View
2  ...bernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/cfg/HibernateNamedQueriesBuilder.groovy
@@ -105,7 +105,7 @@ class NamedCriteriaProxy {
resultTransformer = CriteriaSpecification.DISTINCT_ROOT_ENTITY
}
}
-
+
def paramsMap
if (params && params[-1] instanceof Map) {
paramsMap = params[-1]
View
2  .../src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/AbstractDynamicPersistentMethod.java
@@ -36,7 +36,7 @@
public static final String ERRORS_PROPERTY = "errors";
- private ClassLoader classLoader = null;
+ private ClassLoader classLoader;
private HibernateTemplate hibernateTemplate;
public AbstractDynamicPersistentMethod(Pattern pattern, SessionFactory sessionFactory, ClassLoader classLoader) {
View
27 ...ate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/AbstractSavePersistentMethod.java
@@ -20,7 +20,19 @@
import groovy.lang.GroovyObject;
import groovy.lang.GroovySystem;
import groovy.lang.MetaClass;
-import org.codehaus.groovy.grails.commons.*;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import org.codehaus.groovy.grails.commons.DomainClassArtefactHandler;
+import org.codehaus.groovy.grails.commons.GrailsApplication;
+import org.codehaus.groovy.grails.commons.GrailsClassUtils;
+import org.codehaus.groovy.grails.commons.GrailsDomainClass;
+import org.codehaus.groovy.grails.commons.GrailsDomainClassProperty;
import org.codehaus.groovy.grails.lifecycle.ShutdownOperations;
import org.codehaus.groovy.grails.validation.CascadingValidator;
import org.hibernate.SessionFactory;
@@ -32,10 +44,6 @@
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
-import java.io.Serializable;
-import java.util.*;
-import java.util.regex.Pattern;
-
/**
* Abstract class for different implementations that perform saving to implement.
*
@@ -85,7 +93,6 @@ public static void clearDisabledValidations(Object obj) {
disableAutoValidationFor.get().remove(System.identityHashCode(obj));
}
-
public static void clearDisabledValidations() {
disableAutoValidationFor.get().clear();
}
@@ -99,6 +106,10 @@ public AbstractSavePersistentMethod(Pattern pattern, SessionFactory sessionFacto
this.application = application;
}
+ public AbstractSavePersistentMethod(Pattern pattern, SessionFactory sessionFactory, ClassLoader classLoader, GrailsApplication application) {
+ this(pattern, sessionFactory, classLoader, application, null);
+ }
+
@SuppressWarnings("rawtypes")
private boolean shouldFail(GrailsApplication grailsApplication, GrailsDomainClass domainClass) {
boolean shouldFail = false;
@@ -119,10 +130,6 @@ else if (configProperty instanceof List) {
return shouldFail;
}
- public AbstractSavePersistentMethod(Pattern pattern, SessionFactory sessionFactory, ClassLoader classLoader, GrailsApplication application) {
- this(pattern, sessionFactory, classLoader, application,null);
- }
-
/* (non-Javadoc)
* @see org.codehaus.groovy.grails.orm.hibernate.metaclass.AbstractDynamicPersistentMethod#doInvokeInternal(java.lang.Object, java.lang.Object[])
*/
View
4 ...ate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/ExecuteQueryPersistentMethod.java
@@ -51,7 +51,7 @@
public class ExecuteQueryPersistentMethod extends AbstractStaticPersistentMethod {
private static final String METHOD_SIGNATURE = "executeQuery";
private static final Pattern METHOD_PATTERN = Pattern.compile("^executeQuery$");
-
+
@SuppressWarnings("serial")
private static final List<String> QUERY_META_PARAMS = Collections.unmodifiableList(
new ArrayList<String>() {{
@@ -114,7 +114,7 @@ public Object doInHibernate(Session session) throws HibernateException, SQLExcep
for (Object parameter : positionalParams) {
q.setParameter(index++, parameter instanceof CharSequence ? parameter.toString() : parameter);
}
-
+
// process named HQL params
for (Object o : namedParams.entrySet()) {
Map.Entry entry = (Map.Entry) o;
View
7 ...ibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/FindAllPersistentMethod.java
@@ -224,17 +224,14 @@ else if (isIntegerOrLong(arguments[1]) && isIntegerOrLong(arguments[2])) {
private boolean retrieveBoolean(Object param, String key) {
boolean value = false;
if (isMapWithValue(param, key)) {
- SimpleTypeConverter converter = new SimpleTypeConverter();
- value = converter.convertIfNecessary(((Map)param).get(key), Boolean.class);
+ value = new SimpleTypeConverter().convertIfNecessary(((Map)param).get(key), Boolean.class);
}
return value;
}
private int retrieveInt(Object param, String key) {
if (isMapWithValue(param, key)) {
- SimpleTypeConverter converter = new SimpleTypeConverter();
- Integer convertedParam = converter.convertIfNecessary(((Map) param).get(key),Integer.class);
- return convertedParam;
+ return new SimpleTypeConverter().convertIfNecessary(((Map) param).get(key),Integer.class);
}
if (isIntegerOrLong(param)) {
return ((Number)param).intValue();
View
2  ...s-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/FindPersistentMethod.java
@@ -163,7 +163,7 @@ private boolean useCache(Object[] args) {
String key = GrailsHibernateUtil.ARGUMENT_CACHE;
boolean value = false;
if ((param instanceof Map) && ((Map)param).containsKey(key)) {
- SimpleTypeConverter converter = new SimpleTypeConverter();
+ SimpleTypeConverter converter = new SimpleTypeConverter();
value = converter.convertIfNecessary(((Map)param).get(key), Boolean.class);
}
useCache = value;
View
4 ...s-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/SavePersistentMethod.java
@@ -41,11 +41,11 @@
public static final Pattern METHOD_PATTERN = Pattern.compile('^'+METHOD_SIGNATURE+'$');
public SavePersistentMethod(SessionFactory sessionFactory, ClassLoader classLoader, GrailsApplication application) {
- super(METHOD_PATTERN,sessionFactory, classLoader, application);
+ super(METHOD_PATTERN, sessionFactory, classLoader, application);
}
public SavePersistentMethod(SessionFactory sessionFactory, ClassLoader classLoader, GrailsApplication application, GrailsDomainClass domainClass) {
- super(METHOD_PATTERN,sessionFactory, classLoader, application, domainClass);
+ super(METHOD_PATTERN, sessionFactory, classLoader, application, domainClass);
}
@Override
View
81 grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/query/HibernateQuery.java
@@ -44,153 +44,148 @@
static {
criterionAdaptors.put(IdEquals.class, new CriterionAdaptor() {
- public org.hibernate.criterion.Criterion toHibernateCriterion(
- Criterion criterion) {
+ @Override
+ public org.hibernate.criterion.Criterion toHibernateCriterion(Criterion criterion) {
IdEquals eq = (IdEquals) criterion;
return Restrictions.idEq(eq.getValue());
}
});
criterionAdaptors.put(IsNull.class, new CriterionAdaptor() {
- public org.hibernate.criterion.Criterion toHibernateCriterion(
- Criterion criterion) {
+ @Override
+ public org.hibernate.criterion.Criterion toHibernateCriterion(Criterion criterion) {
IsNull eq = (IsNull) criterion;
return Restrictions.isNull(eq.getProperty());
}
});
criterionAdaptors.put(IsNotNull.class, new CriterionAdaptor() {
- public org.hibernate.criterion.Criterion toHibernateCriterion(
- Criterion criterion) {
+ @Override
+ public org.hibernate.criterion.Criterion toHibernateCriterion(Criterion criterion) {
IsNotNull eq = (IsNotNull) criterion;
return Restrictions.isNotNull(eq.getProperty());
}
});
criterionAdaptors.put(IsEmpty.class, new CriterionAdaptor() {
- public org.hibernate.criterion.Criterion toHibernateCriterion(
- Criterion criterion) {
+ @Override
+ public org.hibernate.criterion.Criterion toHibernateCriterion(Criterion criterion) {
IsEmpty eq = (IsEmpty) criterion;
return Restrictions.isEmpty(eq.getProperty());
}
});
criterionAdaptors.put(IsNotEmpty.class, new CriterionAdaptor() {
- public org.hibernate.criterion.Criterion toHibernateCriterion(
- Criterion criterion) {
+ @Override
+ public org.hibernate.criterion.Criterion toHibernateCriterion(Criterion criterion) {
IsNotEmpty eq = (IsNotEmpty) criterion;
return Restrictions.isNotEmpty(eq.getProperty());
}
});
criterionAdaptors.put(Equals.class, new CriterionAdaptor() {
- public org.hibernate.criterion.Criterion toHibernateCriterion(
- Criterion criterion) {
+ @Override
+ public org.hibernate.criterion.Criterion toHibernateCriterion(Criterion criterion) {
Equals eq = (Equals) criterion;
return Restrictions.eq(eq.getProperty(), convertStringValue(eq.getValue()));
}
});
criterionAdaptors.put(Like.class, new CriterionAdaptor() {
- public org.hibernate.criterion.Criterion toHibernateCriterion(
- Criterion criterion) {
+ @Override
+ public org.hibernate.criterion.Criterion toHibernateCriterion(Criterion criterion) {
Like eq = (Like) criterion;
return Restrictions.like(eq.getProperty(), convertStringValue(eq.getValue()));
}
});
criterionAdaptors.put(ILike.class, new CriterionAdaptor() {
- public org.hibernate.criterion.Criterion toHibernateCriterion(
- Criterion criterion) {
+ @Override
+ public org.hibernate.criterion.Criterion toHibernateCriterion(Criterion criterion) {
ILike eq = (ILike) criterion;
return Restrictions.ilike(eq.getProperty(), convertStringValue(eq.getValue()));
}
});