/*
 * Copyright 2014 Open mHealth
 *
 * 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 org.openmhealth.dsu.configuration;

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;


/**
 * A configuration class that controls the Spring Data MongoDB repositories to scan for.
 *
 * @author Emerson Farrugia
 */
@Configuration
@ConditionalOnExpression("'${dataStore}' == 'mongo'")
@EnableMongoRepositories(basePackages = "org.openmhealth.dsu.repository")
public class MongoPersistenceConfiguration {

}

@@ -645,543 +645,2416 @@
 ort 
-org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.data.mongodb.repository.config.EnableMongoRepositories;%0A%0A%0A/**%0A * A configuration class that controls the Spring Data MongoDB repositories to scan for.%0A *%0A * @author Emerson Farrugia%0A */%0A@Configuration%0A@ConditionalOnExpression(%22'$%7BdataStore%7D' == 'mongo'%22)%0A@EnableMongoRepositories(basePackages = %22org.openmhealth.dsu.repository%22)%0Apublic class MongoPersistenceConfiguration %7B%0A
+com.mongodb.Mongo;%0Aimport com.mongodb.MongoClientOptions;%0Aimport org.openmhealth.dsu.converter.OffsetDateTimeToStringConverter;%0Aimport org.openmhealth.dsu.converter.StringToOffsetDateTimeConverter;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;%0Aimport org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;%0Aimport org.springframework.boot.autoconfigure.mongo.MongoProperties;%0Aimport org.springframework.context.annotation.Bean;%0Aimport org.springframework.context.annotation.Configuration;%0Aimport org.springframework.core.convert.converter.Converter;%0Aimport org.springframework.data.mongodb.config.AbstractMongoConfiguration;%0Aimport org.springframework.data.mongodb.core.convert.CustomConversions;%0Aimport org.springframework.data.mongodb.repository.config.EnableMongoRepositories;%0A%0Aimport javax.annotation.PreDestroy;%0Aimport java.net.UnknownHostException;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A%0A/**%0A * A configuration class for Spring Data MongoDB. It controls the repositories to scan for and sets up converters to%0A * support persistence of Java 8 %7B@link java.time.OffsetDateTime%7D. The remaining boilerplate is mostly a copy of %7B@link%0A * MongoAutoConfiguration%7D.%0A *%0A * @author Emerson Farrugia%0A */%0A@Configuration%0A@ConditionalOnExpression(%22'$%7BdataStore%7D' == 'mongo'%22)%0A@EnableMongoRepositories(basePackages = %22org.openmhealth.dsu.repository%22)%0Apublic class MongoPersistenceConfiguration extends AbstractMongoConfiguration %7B%0A%0A    @Autowired%0A    private MongoProperties mongoProperties;%0A%0A    @Autowired(required = false)%0A    private MongoClientOptions clientOptions;%0A%0A    private Mongo mongo;%0A%0A    @PreDestroy%0A    public void close() %7B%0A        if (mongo != null) %7B%0A            mongo.close();%0A        %7D%0A    %7D%0A%0A    @Bean%0A    public Mongo mongo() throws UnknownHostException %7B%0A        mongo = mongoProperties.createMongoClient(clientOptions);%0A        return mongo;%0A    %7D%0A%0A%0A    @Override%0A    protected String getDatabaseName() %7B%0A        return mongoProperties.getDatabase();%0A    %7D%0A%0A    @Override%0A    public CustomConversions customConversions() %7B%0A%0A        List%3CConverter%3C?, ?%3E%3E converters = new ArrayList%3C%3E();%0A%0A        converters.add(new OffsetDateTimeToStringConverter());%0A        converters.add(new StringToOffsetDateTimeConverter());%0A%0A        return new CustomConversions(converters);%0A    %7D
 %0A%7D%0A

Add Java 8 java.time converters to Mongo configuration.