Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Added two batch job tests in the restaurant sample #442

Closed
wants to merge 17 commits into from

Conversation

sroeger
Copy link

@sroeger sroeger commented Jul 4, 2016

This PR adds:

  • OfferImportJobTest with XML batch configuration. A file offers.csv is read and processed to save valid records to the database. This job utilizes an ItemProcessor in order to import data types "Money" and "OfferState" (enum). In this example this is done via an additional OfferCsv entity (see the example below for an alternative to this). This example also demonstrates error or skip handling with wrongly formatted input lines. An attached SkipListener reports skip occuraces in the log WARN console.
  • StaffImportJobTest with exemplary Java configuration. A bigger file with 2000 entries is read and processed to save valid records to the database. This example utilizes a CustomEditor "RoleEditor" to import the data type "Role" which is an enum value. In Java configuration it is also possible to define skip handling with badly formatted lines. Also it is possible to use variables defined in the application.properties file in the configuration.

@maihacke can you review the changes?

@oasp-ci
Copy link
Collaborator

oasp-ci commented Jul 4, 2016

Can one of the admins verify this patch?

@sroeger sroeger changed the title Added two batch job tests in the restaurant samle Added two batch job tests in the restaurant sample Jul 12, 2016
@maybeec maybeec added this to the oasp:2.2.0 milestone Jul 28, 2016
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.transaction.PlatformTransactionManager;

/**
* This class contains the configuration like jobLauncher,Jobrepository etc.
* @author ssarmoka
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicated javadoc?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please consolidate with class javadoc. This doc is currently connected to an import, which is obviously a mistake.

@maybeec
Copy link
Member

maybeec commented Jul 29, 2016

@maihacke can you have a look at this PR as you have been strongly involved into the batch design?

@sroeger
Copy link
Author

sroeger commented Jul 29, 2016

btw @maybeec is it recommended to merge current changes of oasp4j/develop into PRs when they are outdated? This branch has some conflicts now that I could resolve with a merge. Is there a general best practice?
I could not find any information about this in the wiki.

@maybeec
Copy link
Member

maybeec commented Jul 29, 2016

For updating pull requests, there is basically just one rule:

If you can resolve the merge without guessing what might be the right solution. Go ahead!
But if you are not totally sure about it, get in contact or let it simply be done by someone who has the backgrounds of the changes done on the main repository. :)


Von: Simon Röger [email protected]
Gesendet: 29.07.2016 6:34 nachm.
An: oasp/oasp4j
Cc: Brunnlieb, Malte; Mention
Betreff: Re: [oasp/oasp4j] Added two batch job tests in the restaurant sample (#442)

btw @maybeechttps://github.com/maybeec is it recommended to merge current changes of oasp4j/develop into PRs when they are outdated? This branch has some conflicts now that I could resolve with a merge. Is there a general best practice?
I could not find any information about this in the wiki.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com//pull/442#issuecomment-236174578, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABXHNwm4r3cSuLEYPZi9LTRYRhvdEUPXks5qafowgaJpZM4JEUIV.


Firma: Capgemini Deutschland GmbH
Aufsichtsratsvorsitzender: Antonio Schnieder • Geschäftsführer: Dr. Michael Schulte (Sprecher) • Jost Förster • Dr. Peter Lempp • Dr. Volkmar Varnhagen

Amtsgericht Berlin-Charlottenburg, HRB 98814
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

@maybeec maybeec self-assigned this Aug 1, 2016
/**
* {@inheritDoc}
*/
@Override
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unnecessary @inheritdoc javaDoc comments. They are simply not needed as @OverRide is sufficient for the IDE.

@maybeec maybeec removed their assignment Aug 1, 2016
@sroeger
Copy link
Author

sroeger commented Aug 1, 2016

Thanks for the comments.
It should also be discussed which way is best practice when importing data with custom type fields or enums as they are not automatically converted from strings.
I proposed two ways as mentioned in my first post

  • use a converter in the batch job that goes the way from the import csv string to an OfferCsv to the OfferEto as done in the offer import or
  • use a custom editor that is defined in the job configuration (this means one has to define a class extending PropertyEditorSupport) as done in the staff import.

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

beanFactory.registerScope("step", new StepScope());
Copy link
Member

@maihacke maihacke Aug 9, 2016

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?

Copy link
Member

@maihacke maihacke Aug 9, 2016

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...

Copy link
Author

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?

Copy link
Member

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

@maihacke
Copy link
Member

maihacke commented Aug 9, 2016

Pull requests looks verý good overall. There are some minor issues/questions left. After "fixing" these, PR can be merged...

@maybeec
Copy link
Member

maybeec commented Aug 9, 2016

Please stick to english language :)

@sroeger
Copy link
Author

sroeger commented Aug 29, 2016

The two concerns regarding

are documented in the given issues. Other than these issues the only remaining point for this PR is the registering of the scope step. Imho the only other (maybe more elegant) option is to use Spring Boot's annotation @EnableBatchProcessing but this would change many of our configurations. Maybe someone can think of another solution for CustomBeanFactoryPostProcessor registered in
BeansBatchConfig

@kiran-vadla
Copy link
Contributor

@maihacke , As discussed , assigned it to you for the review . Thanks for your time. Just to keep you posted , this has to be merged onto develop-2.3.0 as this is the branch that is used for oasp4j 2.3.0 release.

Thanks,
Kiran.

Copy link
Member

@maihacke maihacke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Questions were answered. No required changes since last review.

@kiran-vadla kiran-vadla self-assigned this Jan 6, 2017
@kiran-vadla
Copy link
Contributor

@maihacke , Thanks for your time for the review . As discussed , I will take care of the merging.

@kiran-vadla
Copy link
Contributor

Changes submitted as part of this PR are submitted on to a branch under develop-2.3.0 and PR #532 is created . Refer PR #532 . Closing this PR.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants