service.@date -> service.getLocalDate because direct field accessor isn't working properly anymore.
This commit is contained in:
		@@ -16,7 +16,7 @@ public class Service implements Serializable {
 | 
			
		||||
        Service that = (Service) thatObj
 | 
			
		||||
 | 
			
		||||
        return (this.id == that.id &&
 | 
			
		||||
                this.date == (that.rawDate) &&
 | 
			
		||||
                this.date == (that.locaDate) &&
 | 
			
		||||
                this.serviceType == that.serviceType) }
 | 
			
		||||
 | 
			
		||||
    public void setDate(Date date) { this.date = LocalDate.fromDateFields(date) }
 | 
			
		||||
@@ -29,5 +29,5 @@ public class Service implements Serializable {
 | 
			
		||||
 | 
			
		||||
    // Needed only because the @directFieldAccesor syntax stopped working in
 | 
			
		||||
    // Groovy 2.4.7
 | 
			
		||||
    private LocalDate getRawDate() { return this.date }
 | 
			
		||||
    private LocalDate getLocalDate() { return this.date }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ public class NLSongsContext {
 | 
			
		||||
    public static String mediaBaseUrl
 | 
			
		||||
 | 
			
		||||
    public static String makeUrl(Service service, Song song) {
 | 
			
		||||
        return mediaBaseUrl + '/' + service.@date.toString('yyyy-MM-dd') + '_' +
 | 
			
		||||
        return mediaBaseUrl + '/' + service.localDate.toString('yyyy-MM-dd') + '_' +
 | 
			
		||||
            service.serviceType.name().toLowerCase() + '_' +
 | 
			
		||||
            song.name.replaceAll(/[\s'"\\\/\?!]/, '') + '.mp3' }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,23 +21,28 @@ public final class NLSongsContextListener implements ServletContextListener {
 | 
			
		||||
 | 
			
		||||
        Properties props = new Properties()
 | 
			
		||||
 | 
			
		||||
        // Load database details from the context configuration.
 | 
			
		||||
        String contextConfigFile = context.getInitParameter('context.config.file')
 | 
			
		||||
        if (contextConfigFile) {
 | 
			
		||||
          NLSongsContextListener.getResourceAsStream(contextConfigFile)
 | 
			
		||||
            .withStream { is -> props.load(is) } }
 | 
			
		||||
        // Load configuration details from the context configuration.
 | 
			
		||||
        NLSongsContextListener.getResourceAsStream(
 | 
			
		||||
            context.getInitParameter('context.config.file'))
 | 
			
		||||
          .withStream { is -> props.load(is) }
 | 
			
		||||
 | 
			
		||||
        // Load database configuration
 | 
			
		||||
        Properties dataSourceProps = new Properties()
 | 
			
		||||
        String dbConfigFile = context.getInitParameter('datasource.config.file')
 | 
			
		||||
 | 
			
		||||
        if (dbConfigFile) {
 | 
			
		||||
          NLSongsContextListener.getResourceAsStream(dbConfigFile)
 | 
			
		||||
            .withStream { is -> dataSourceProps.load(is) } }
 | 
			
		||||
 | 
			
		||||
        // Load database configuration from environment variables (may
 | 
			
		||||
        // override settings in file).
 | 
			
		||||
        def env = System.getenv()
 | 
			
		||||
        env.keySet().findAll { it.startsWith('DB_') }.each { key ->
 | 
			
		||||
          props[key.substring(3)] = env[key] }
 | 
			
		||||
        System.properties.keySet().findAll { it.startsWith('DB_') }.each { key ->
 | 
			
		||||
          dataSourceProps["dataSource.${key.substring(3)}"] = System.properties[key] }
 | 
			
		||||
 | 
			
		||||
        log.debug("Database configuration: {}", props)
 | 
			
		||||
        log.debug("Database configuration: {}", dataSourceProps)
 | 
			
		||||
 | 
			
		||||
        // Create the pooled data source
 | 
			
		||||
        HikariConfig hcfg = new HikariConfig(
 | 
			
		||||
            context.getInitParameter('datasource.config.file'))
 | 
			
		||||
        HikariConfig hcfg = new HikariConfig(dataSourceProps)
 | 
			
		||||
 | 
			
		||||
        HikariDataSource hds = new HikariDataSource(hcfg)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@ if (!service) { response.sendError(response.SC_NOT_FOUND); return }
 | 
			
		||||
        <meta name="referrer" content="origin">
 | 
			
		||||
        <link rel="shortcut icon" href="../images/favicon.ico">
 | 
			
		||||
 | 
			
		||||
        <title><%= service.@date.toString("yyyy-MM-dd")
 | 
			
		||||
        <title><%= service.localDate.toString("yyyy-MM-dd")
 | 
			
		||||
           %> (<%= service.serviceType.displayName %>) - New Life Songs Database</title>
 | 
			
		||||
        <script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
 | 
			
		||||
        <!--<script type="application/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"></script>-->
 | 
			
		||||
@@ -38,7 +38,7 @@ if (!service) { response.sendError(response.SC_NOT_FOUND); return }
 | 
			
		||||
    <body>
 | 
			
		||||
        <header>
 | 
			
		||||
            <h1><a href="../">New Life Songs</a></h1>
 | 
			
		||||
            <h2 class=service-desc><%= service.@date.toString("yyyy-MM-dd") %>: (<%=
 | 
			
		||||
            <h2 class=service-desc><%= service.localDate.toString("yyyy-MM-dd") %>: (<%=
 | 
			
		||||
                    service.description ?: service.serviceType.displayName %>)</h2>
 | 
			
		||||
 | 
			
		||||
            <nav><ul>
 | 
			
		||||
 
 | 
			
		||||
@@ -44,7 +44,7 @@ songsDB = NLSongsContext.songsDB
 | 
			
		||||
                <tbody>
 | 
			
		||||
                <% songsDB.findAllServices().sort { it.date }.reverse().each { service -> %>
 | 
			
		||||
                    <tr><td class=date><a href="../service/<%= service.id %>"><%=
 | 
			
		||||
                            service.@date.toString("yyyy-MM-dd") %></a></td>
 | 
			
		||||
                            service.localDate.toString("yyyy-MM-dd") %></a></td>
 | 
			
		||||
                        <td class=service-type><%= service.description ?:
 | 
			
		||||
                            service.serviceType.displayName %></td></tr><% } %>
 | 
			
		||||
                </tbody>
 | 
			
		||||
 
 | 
			
		||||
@@ -67,7 +67,7 @@ if (!song) { response.sendError(response.SC_NOT_FOUND); return }
 | 
			
		||||
                    sort { it.svc.date }.each { row -> %>
 | 
			
		||||
                    <tr><td class=actions><a href='<%= NLSongsContext.makeUrl(row.svc, song) %>'><i class="fa fa-download"></i></a></td>
 | 
			
		||||
                        <td class=performance-date><a href='../service/<%= row.svc.id %>'><%= 
 | 
			
		||||
                                row.svc.@date.toString("yyyy-MM-dd") %></a></td>
 | 
			
		||||
                                row.svc.localDate.toString("yyyy-MM-dd") %></a></td>
 | 
			
		||||
                        <td class=service-type><%= row.svc.serviceType.displayName %></td>
 | 
			
		||||
                        <td class=not-small><%= row.perf.leader ?: "" %></td>
 | 
			
		||||
                        <td class=not-small><%= row.perf.pianist ?: "" %></td>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user