galovics commented on code in PR #2481:
URL: https://github.com/apache/fineract/pull/2481#discussion_r937723756


##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/FineractPartitionJobConfigValidationCondition.java:
##########
@@ -0,0 +1,49 @@
+/**
+ * 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.fineract.infrastructure.core.config;
+
+import java.util.List;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+@Slf4j
+public class FineractPartitionJobConfigValidationCondition implements 
Condition {
+
+    @Override
+    public boolean matches(ConditionContext context, AnnotatedTypeMetadata 
metadata) {
+        FineractProperties.FineractPartitionedJobProperties 
partitionedJobProperties = Binder.get(context.getEnvironment())
+                .bind("fineract.partitioned-job", 
FineractProperties.FineractPartitionedJobProperties.class).orElse(null);
+        List<FineractProperties.JobProperty> invalidConfigs = 
partitionedJobProperties.getJobProperties().stream()

Review Comment:
   null-check for `partitionedJobProperties` is required based on the 
`orElse(null)` call



##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/FineractPartitionJobConfigValidationCondition.java:
##########
@@ -0,0 +1,49 @@
+/**
+ * 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.fineract.infrastructure.core.config;
+
+import java.util.List;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+@Slf4j
+public class FineractPartitionJobConfigValidationCondition implements 
Condition {
+
+    @Override
+    public boolean matches(ConditionContext context, AnnotatedTypeMetadata 
metadata) {

Review Comment:
   Please add a test case to verify the logic. Thanks.



##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/FineractPartitionJobConfigValidationCondition.java:
##########
@@ -0,0 +1,49 @@
+/**
+ * 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.fineract.infrastructure.core.config;
+
+import java.util.List;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+@Slf4j
+public class FineractPartitionJobConfigValidationCondition implements 
Condition {
+
+    @Override
+    public boolean matches(ConditionContext context, AnnotatedTypeMetadata 
metadata) {
+        FineractProperties.FineractPartitionedJobProperties 
partitionedJobProperties = Binder.get(context.getEnvironment())
+                .bind("fineract.partitioned-job", 
FineractProperties.FineractPartitionedJobProperties.class).orElse(null);
+        List<FineractProperties.JobProperty> invalidConfigs = 
partitionedJobProperties.getJobProperties().stream()
+                .filter(jobProperty -> !(jobProperty.getPartitionSize() > 0 && 
jobProperty.getChunkSize() > 0

Review Comment:
   Can we extract the filter condition to a method so it's more easier to read? 
thanks.



##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/config/FineractPartitionJobConfigValidationCondition.java:
##########
@@ -0,0 +1,49 @@
+/**
+ * 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.fineract.infrastructure.core.config;
+
+import java.util.List;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.context.properties.bind.Binder;
+import org.springframework.context.annotation.Condition;
+import org.springframework.context.annotation.ConditionContext;
+import org.springframework.core.type.AnnotatedTypeMetadata;
+
+@Slf4j
+public class FineractPartitionJobConfigValidationCondition implements 
Condition {
+
+    @Override
+    public boolean matches(ConditionContext context, AnnotatedTypeMetadata 
metadata) {
+        FineractProperties.FineractPartitionedJobProperties 
partitionedJobProperties = Binder.get(context.getEnvironment())
+                .bind("fineract.partitioned-job", 
FineractProperties.FineractPartitionedJobProperties.class).orElse(null);
+        List<FineractProperties.JobProperty> invalidConfigs = 
partitionedJobProperties.getJobProperties().stream()
+                .filter(jobProperty -> !(jobProperty.getPartitionSize() > 0 && 
jobProperty.getChunkSize() > 0
+                        && jobProperty.getThreadCount() > 0
+                        && jobProperty.getPartitionSize() >= 
jobProperty.getThreadCount() * jobProperty.getChunkSize()))

Review Comment:
   Actually 2 filter methods would be cool. One for the greater than 0 check 
and one for the actual logic.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to