-
Notifications
You must be signed in to change notification settings - Fork 303
Added two batch job tests in the restaurant sample #442
Changes from all commits
49312b6
298c35b
fb1a606
324327a
b05527e
867a1ad
f7bb804
2f15a9a
f10ecf2
f77126b
74833e8
1c004c5
c70bd00
728e92b
b6ebc17
0ccb804
599b845
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.oasp.gastronomy.restaurant.batch.common; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.batch.core.SkipListener; | ||
import org.springframework.batch.core.listener.SkipListenerSupport; | ||
|
||
/** | ||
* Implementation of a {@link SkipListener} for logging skipped items in batch processes. | ||
* | ||
* @author sroeger | ||
* | ||
*/ | ||
public class CustomSkipListener<T, S> extends SkipListenerSupport<T, S> { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(CustomSkipListener.class); | ||
|
||
@Override | ||
public void onSkipInRead(Throwable t) { | ||
|
||
LOG.warn("skipped item: {}", t.toString()); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.oasp.gastronomy.restaurant.general.configuration; | ||
|
||
import org.springframework.batch.core.scope.StepScope; | ||
import org.springframework.beans.BeansException; | ||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; | ||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; | ||
|
||
/** | ||
* Registers bean of type 'step' to be used in batch processing. E.g to be able to access jobParameter within a reader. | ||
* Note that the annotation {@code @StepScope} has to be used on an implementation not an interface to function properly | ||
* | ||
* @author sroeger | ||
* | ||
*/ | ||
public class CustomBeanFactoryPostProcessor implements BeanFactoryPostProcessor { | ||
|
||
@Override | ||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { | ||
|
||
beanFactory.registerScope("step", new StepScope()); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,5 @@ | ||
package io.oasp.gastronomy.restaurant.general.logic.base; | ||
|
||
|
||
import io.oasp.gastronomy.restaurant.general.common.base.AbstractBeanMapperSupport; | ||
import io.oasp.module.jpa.common.api.to.PaginatedListTo; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
|
@@ -15,6 +11,9 @@ | |
import net.sf.mmm.util.transferobject.api.AbstractTransferObject; | ||
import net.sf.mmm.util.transferobject.api.TransferObject; | ||
|
||
import io.oasp.gastronomy.restaurant.general.common.base.AbstractBeanMapperSupport; | ||
import io.oasp.module.jpa.common.api.to.PaginatedListTo; | ||
|
||
/** | ||
* Abstract base class for any management implementation class in this application. | ||
*/ | ||
|
@@ -55,8 +54,8 @@ protected <T extends TransferObject, E extends PersistenceEntity<?>> PaginatedLi | |
|
||
/** | ||
* Creates a {@link Map} with all {@link GenericEntity entities} from the given {@link Collection} using their | ||
* {@link GenericEntity#getId() ID} as key. All {@link GenericEntity entities} without an | ||
* {@link GenericEntity#getId() ID} ({@code null}) will be ignored. | ||
* {@link GenericEntity#getId() ID} as key. All {@link GenericEntity entities} without an {@link GenericEntity#getId() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generell gibt es in deinem PR relativ viele "Code-style"-Änderungen. Ich möchte vermeiden, dass wir häufige Changes wegen unterschiedlicher Code-Style-Configs haben. Ist in deinem Eclipse alles "richtig" konfiguriert, nutzt du ggf. eine andere Version, als bisher? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Das ist auffällig, das stimmt. Ich geh durch meine Config durch und schaue, was da nicht passt. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also selbst auf einer frischen Umgebung werden die Änderungen so durchgeführt. In der |
||
* ID} ({@code null}) will be ignored. | ||
* | ||
* @param <ID> is the generic type of the {@link GenericEntity#getId() ID}. | ||
* @param <E> is the generic type of the {@link GenericEntity entity}. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package io.oasp.gastronomy.restaurant.offermanagement.batch.impl.offerimport.writer; | ||
|
||
import io.oasp.gastronomy.restaurant.salesmanagement.logic.api.to.OrderEto; | ||
|
||
/** | ||
* Helper entity in order to convert imported data into a {@link OrderEto} as this contains an enum value and a custom | ||
* type. An other solution is to use CustomEditors as done in staffImport. | ||
* | ||
* @author sroeger | ||
*/ | ||
public class OfferCsv { | ||
|
||
private String name; | ||
|
||
private String description; | ||
|
||
private String state; | ||
|
||
private String mealId; | ||
|
||
private String sideDishId; | ||
|
||
private String drinkId; | ||
|
||
private String price; | ||
|
||
/** | ||
* @return name | ||
*/ | ||
public String getName() { | ||
|
||
return this.name; | ||
} | ||
|
||
/** | ||
* @param name new value of name. | ||
*/ | ||
public void setName(String name) { | ||
|
||
this.name = name; | ||
} | ||
|
||
/** | ||
* @return description | ||
*/ | ||
public String getDescription() { | ||
|
||
return this.description; | ||
} | ||
|
||
/** | ||
* @param description new value of description. | ||
*/ | ||
public void setDescription(String description) { | ||
|
||
this.description = description; | ||
} | ||
|
||
/** | ||
* @return state | ||
*/ | ||
public String getState() { | ||
|
||
return this.state; | ||
} | ||
|
||
/** | ||
* @param state new value of state. | ||
*/ | ||
public void setState(String state) { | ||
|
||
this.state = state; | ||
} | ||
|
||
/** | ||
* @return mealId | ||
*/ | ||
public String getMealId() { | ||
|
||
return this.mealId; | ||
} | ||
|
||
/** | ||
* @param mealId new value of mealId. | ||
*/ | ||
public void setMealId(String mealId) { | ||
|
||
this.mealId = mealId; | ||
} | ||
|
||
/** | ||
* @return sideDishId | ||
*/ | ||
public String getSideDishId() { | ||
|
||
return this.sideDishId; | ||
} | ||
|
||
/** | ||
* @param sideDishId new value of sideDishId. | ||
*/ | ||
public void setSideDishId(String sideDishId) { | ||
|
||
this.sideDishId = sideDishId; | ||
} | ||
|
||
/** | ||
* @return drinkId | ||
*/ | ||
public String getDrinkId() { | ||
|
||
return this.drinkId; | ||
} | ||
|
||
/** | ||
* @param drinkId new value of drinkId. | ||
*/ | ||
public void setDrinkId(String drinkId) { | ||
|
||
this.drinkId = drinkId; | ||
} | ||
|
||
/** | ||
* @return price | ||
*/ | ||
public String getPrice() { | ||
|
||
return this.price; | ||
} | ||
|
||
/** | ||
* @param price new value of price. | ||
*/ | ||
public void setPrice(String price) { | ||
|
||
this.price = price; | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
muss dieser Scope wirklich so manuell registriert werden? Gibt es da keinen eleganteren Weg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the two ways of ENUM-Mapping. I think both ways are eligible. It's more or less a matter of taste and I don't think we need standardize this in OASP. Just leave it as it is...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prinzipiell nein, man könnte den ganzen Stack an Einstellungen und Konfigurationen über @EnableBatchProcessing beziehen. Ich hab angenommen, wir machen das absichtlich alles manuell, um mehr Kontrolle zu haben. Oder wäre es im Zuge der Umstellung auf Spring Boot auch besser, alles über die Annotation zu laden?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for remark. Ticket for migration to java config created by @sroeger #472