nva commented on code in PR #294:
URL: https://github.com/apache/ignite-extensions/pull/294#discussion_r1856254703


##########
modules/spring-data-ext/spring-data/src/main/java/org/apache/ignite/springdata/repository/query/IgniteCustomConversions.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springdata.repository.query;
+
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.data.mapping.model.SimpleTypeHolder;
+
+/**
+ * Custom conversions implementation.
+ * An application can define its own converter by defining the following bean:
+ * <pre>
+ * {@code
+ *     @Bean
+ *     public CustomConversions customConversions() {
+ *         return new IgniteCustomConversions(Arrays.asList(new 
LocalDateTimeWriteConverter()));
+ *     }
+ * }
+ * </pre>
+ */
+public class IgniteCustomConversions extends 
org.springframework.data.convert.CustomConversions {
+
+    private static final List<Object> STORE_CONVERTERS;
+
+    private static final StoreConversions STORE_CONVERSIONS;
+
+    static {
+        List<Object> converters = new ArrayList<>();
+        converters.add(new LocalDateTimeWriteConverter());
+        converters.add(new DateWriteConverter());
+
+        STORE_CONVERTERS = Collections.unmodifiableList(converters);
+        STORE_CONVERSIONS = StoreConversions.of(SimpleTypeHolder.DEFAULT, 
STORE_CONVERTERS);
+    }
+
+    public IgniteCustomConversions() {
+        this(Collections.emptyList());
+    }
+
+    public IgniteCustomConversions(List<?> converters) {
+        super(STORE_CONVERSIONS, converters);
+    }
+
+    static class LocalDateTimeWriteConverter implements Converter<Timestamp, 
LocalDateTime> {
+

Review Comment:
   ```suggestion
       @WritingConverter
       static class TimestampToLocalDateTimeConverter implements 
Converter<Timestamp, LocalDateTime> {
   ```



##########
modules/spring-data-ext/spring-data/src/main/java/org/apache/ignite/springdata/repository/query/IgniteCustomConversions.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springdata.repository.query;
+
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.data.mapping.model.SimpleTypeHolder;
+
+/**
+ * Custom conversions implementation.
+ * An application can define its own converter by defining the following bean:
+ * <pre>
+ * {@code
+ *     @Bean
+ *     public CustomConversions customConversions() {
+ *         return new IgniteCustomConversions(Arrays.asList(new 
LocalDateTimeWriteConverter()));
+ *     }
+ * }
+ * </pre>
+ */
+public class IgniteCustomConversions extends 
org.springframework.data.convert.CustomConversions {
+
+    private static final List<Object> STORE_CONVERTERS;
+
+    private static final StoreConversions STORE_CONVERSIONS;
+
+    static {
+        List<Object> converters = new ArrayList<>();
+        converters.add(new LocalDateTimeWriteConverter());
+        converters.add(new DateWriteConverter());
+
+        STORE_CONVERTERS = Collections.unmodifiableList(converters);
+        STORE_CONVERSIONS = StoreConversions.of(SimpleTypeHolder.DEFAULT, 
STORE_CONVERTERS);
+    }
+
+    public IgniteCustomConversions() {
+        this(Collections.emptyList());
+    }
+
+    public IgniteCustomConversions(List<?> converters) {
+        super(STORE_CONVERSIONS, converters);
+    }
+
+    static class LocalDateTimeWriteConverter implements Converter<Timestamp, 
LocalDateTime> {
+
+        @Override public LocalDateTime convert(Timestamp source) {
+            LocalDateTime localDateTime = source.toInstant()
+                .atZone(ZoneId.systemDefault())
+                .toLocalDateTime();
+            return localDateTime;
+        }
+    }
+
+    static class DateWriteConverter implements Converter<Timestamp, Date> {
+

Review Comment:
   ```suggestion
       @WritingConverter
       static class TimestampToDateConverter implements Converter<Timestamp, 
Date> {
   ```



##########
modules/spring-data-ext/spring-data/src/main/java/org/apache/ignite/springdata/repository/query/IgniteCustomConversions.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springdata.repository.query;
+
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.data.mapping.model.SimpleTypeHolder;
+
+/**
+ * Custom conversions implementation.
+ * An application can define its own converter by defining the following bean:
+ * <pre>
+ * {@code
+ *     @Bean
+ *     public CustomConversions customConversions() {
+ *         return new IgniteCustomConversions(Arrays.asList(new 
LocalDateTimeWriteConverter()));
+ *     }
+ * }
+ * </pre>
+ */
+public class IgniteCustomConversions extends 
org.springframework.data.convert.CustomConversions {
+
+    private static final List<Object> STORE_CONVERTERS;
+

Review Comment:
   Can we replace this field with a local variable?



##########
modules/spring-data-ext/spring-data/src/test/java/org/apache/ignite/springdata/misc/CustomConvertersApplicationConfiguration.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springdata.misc;
+
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.util.Arrays;
+import org.apache.ignite.springdata.repository.query.IgniteCustomConversions;
+import org.springframework.context.annotation.Bean;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.data.convert.CustomConversions;
+
+/**
+ *  Test configuration that overrides default converter for LocalDateTime type.
+ */
+public class CustomConvertersApplicationConfiguration extends 
ApplicationConfiguration {
+
+    @Bean
+    public CustomConversions customConversions() {
+        return new IgniteCustomConversions(Arrays.asList(new 
LocalDateTimeWriteConverter()));
+    }
+
+    static class LocalDateTimeWriteConverter implements Converter<Timestamp, 
LocalDateTime> {
+

Review Comment:
   ```suggestion
       @Bean
       public CustomConversions customConversions() {
           return new IgniteCustomConversions(Arrays.asList(new 
LocalDateTimeWriteConverter()));
       }
   
       static class LocalDateTimeWriteConverter implements Converter<Timestamp, 
LocalDateTime> {
   ```



##########
modules/spring-data-ext/spring-data/src/test/java/org/apache/ignite/springdata/IgniteSpringDataConversionsTest.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springdata;
+
+import java.time.LocalDateTime;
+import org.apache.ignite.springdata.misc.ApplicationConfiguration;
+import 
org.apache.ignite.springdata.misc.CustomConvertersApplicationConfiguration;
+import org.apache.ignite.springdata.misc.Person;
+import org.apache.ignite.springdata.misc.PersonRepository;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+import 
org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+public class IgniteSpringDataConversionsTest extends GridCommonAbstractTest {
+

Review Comment:
   ```suggestion
   ```



##########
modules/spring-data-ext/spring-data/src/main/java/org/apache/ignite/springdata/repository/query/IgniteCustomConversions.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.springdata.repository.query;
+
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.data.mapping.model.SimpleTypeHolder;
+
+/**
+ * Custom conversions implementation.
+ * An application can define its own converter by defining the following bean:
+ * <pre>
+ * {@code
+ *     @Bean
+ *     public CustomConversions customConversions() {
+ *         return new IgniteCustomConversions(Arrays.asList(new 
LocalDateTimeWriteConverter()));
+ *     }
+ * }
+ * </pre>
+ */
+public class IgniteCustomConversions extends 
org.springframework.data.convert.CustomConversions {

Review Comment:
   ```suggestion
   public class IgniteCustomConversions extends CustomConversions {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to