org.shoulder.batch.model.convert.BatchModelConvertImpl Maven / Gradle / Ivy
package org.shoulder.batch.model.convert;
import javax.annotation.processing.Generated;
import org.shoulder.batch.dto.result.BatchProcessResult;
import org.shoulder.batch.dto.result.BatchRecordDetailResult;
import org.shoulder.batch.dto.result.BatchRecordResult;
import org.shoulder.batch.model.BatchProgress;
import org.shoulder.batch.model.BatchRecord;
import org.shoulder.batch.model.BatchRecordDetail;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2021-05-21T02:15:31+0800",
comments = "version: 1.4.2.Final, compiler: javac, environment: Java 11 (Oracle Corporation)"
)
public class BatchModelConvertImpl implements BatchModelConvert {
@Override
public BatchProcessResult toDTO(BatchProgress model) {
if ( model == null ) {
return null;
}
BatchProcessResult batchProcessResult = new BatchProcessResult();
batchProcessResult.setProcessed( model.getProcessed() );
batchProcessResult.setSuccessNum( model.getSuccessNum() );
batchProcessResult.setFailNum( model.getFailNum() );
batchProcessResult.setStatus( model.getStatus() );
batchProcessResult.setTimeConsumed( (int) model.calculateProcessedTime() );
batchProcessResult.setTimeLeft( (int) model.calculateTimeLeft() );
batchProcessResult.setFinish( model.hasFinish() );
return batchProcessResult;
}
@Override
public BatchRecordResult toDTO(BatchRecord record) {
if ( record == null ) {
return null;
}
BatchRecordResult batchRecordResult = new BatchRecordResult();
batchRecordResult.setOperator( record.getCreator() );
batchRecordResult.setExecutedTime( record.getCreateTime() );
batchRecordResult.setTotalNum( record.getTotalNum() );
batchRecordResult.setSuccessNum( record.getSuccessNum() );
batchRecordResult.setFailNum( record.getFailNum() );
batchRecordResult.setDataType( record.getDataType() );
batchRecordResult.setOperation( record.getOperation() );
batchRecordResult.setDetailList( org.apache.commons.collections4.CollectionUtils.emptyIfNull(record.getDetailList()).stream().map(org.shoulder.batch.model.convert.BatchModelConvert.CONVERT::toDTO).collect(java.util.stream.Collectors.toList()) );
return batchRecordResult;
}
@Override
public BatchRecordDetailResult toDTO(BatchRecordDetail model) {
if ( model == null ) {
return null;
}
BatchRecordDetailResult batchRecordDetailResult = new BatchRecordDetailResult();
batchRecordDetailResult.setIndex( model.getIndex() );
batchRecordDetailResult.setStatus( model.getStatus() );
batchRecordDetailResult.setSource( model.getSource() );
return batchRecordDetailResult;
}
}