Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@
import org.egovframe.rte.bat.support.EgovResourceVariable;
import org.egovframe.rte.bat.support.EgovStepVariableListener;
import org.mybatis.spring.batch.MyBatisBatchItemWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.Chunk;
import org.springframework.util.ReflectionUtils;

import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* EgovMyBatisBatchItemWriter 클래스
Expand All @@ -54,8 +39,6 @@
*/
public class EgovMyBatisBatchItemWriter<T> extends MyBatisBatchItemWriter<T> {

private static final Logger LOGGER = LoggerFactory.getLogger(EgovMyBatisBatchItemWriter.class);

/**
* egovframework EgovResourceVariable
*/
Expand Down Expand Up @@ -95,37 +78,4 @@ public void setStepVariable(EgovStepVariableListener stepVariable) {
this.stepVariable = stepVariable;
}

@Override
@SuppressWarnings("unchecked")
public void write(Chunk<? extends T> chunk) {
List<Object> list = new ArrayList<>();
Map<String, Object> map;

try {
for (T item : chunk.getItems()) {
map = new HashMap<>();
BeanInfo beanInfo = Introspector.getBeanInfo(item.getClass());

if (resourceVariable != null)
map.putAll(resourceVariable.getVariableMap());
if (jobVariable != null)
map.putAll(jobVariable.getVariableMap());
if (stepVariable != null)
map.putAll(stepVariable.getVariableMap());

for (PropertyDescriptor pd : beanInfo.getPropertyDescriptors()) {
Method reader = pd.getReadMethod();
if (reader != null)
map.put(pd.getName(), reader.invoke(item));
}

list.add(map);
}
} catch (IntrospectionException | IllegalAccessException | InvocationTargetException e) {
ReflectionUtils.handleReflectionException(e);
}

super.write((Chunk<? extends T>) chunk);
}

}