// Path: src/main/java/br/fatea/simplebank/model/services/PaymentService.java
// @Service
// public class PaymentService {
// 
// 	@Autowired private PaymentJMSTemplate paymentJMSTemplate;
// 	@Autowired private SystemUserRepository systemUserRepository;
// 	@Autowired private PaymentRepository paymentRepository;
// 	@Autowired private Converter<PaymentRequest, Payment> converter;
// 	
// 	@Transactional
// 	public void updateStatusPayments(PaymentStatus oldStatus, PaymentStatus newStatus, String detail) {
// 		List<Payment> payments = paymentRepository.findAllByStatus(oldStatus);
// 		for(Payment payment : payments) {
// 			payment.setStatus(newStatus);
// 			PaymentMessage message = new PaymentMessage(payment.getOrder(), payment.getStatus(), detail);
// 			paymentJMSTemplate.send(message, payment.getOwner().getIntegrationConfig().getPaymentQueue());
// 		}
// 	}
// 	
// 	@Transactional
// 	public PaymentResponse process(PaymentRequest paymentRequest, String username) {
// 		SystemUser systemUser = systemUserRepository.findOneByUsername(username);
// 		save(paymentRequest, systemUser);
// 		return buildResponse(paymentRequest);
// 	}
// 
// 	private PaymentResponse buildResponse(PaymentRequest paymentRequest) {
// 		PaymentResponse response = new PaymentResponse();
// 		response.setOrder(paymentRequest.getOrder());
// 		response.setStatus(PaymentStatus.OPENED);
// 		response.setProcessDate(DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME));
// 		return response;
// 	}
// 
// 	private void save(PaymentRequest paymentRequest, SystemUser systemUser) {
// 		Payment payment = converter.asDomain(paymentRequest);
// 		payment.setOwner(systemUser);
// 		payment.setStatus(PaymentStatus.OPENED);
// 		paymentRepository.save(payment);
// 	}
// 	
// }
// 
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
// 
//     OPENED,
//     CONFIRMED,
//     REVERSED,
//     CANCELED;
// 
//     public String value() {
//         return name();
//     }
// 
//     public static PaymentStatus fromValue(String v) {
//         return valueOf(v);
//     }
// 
// }


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import br.fatea.simplebank.model.services.PaymentService;
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;
package br.fatea.simplebank.model.schedulers;



@Component
public class PaymentScheduler {
	
// Path: src/main/java/br/fatea/simplebank/model/services/PaymentService.java
// @Service
// public class PaymentService {
// 
// 	@Autowired private PaymentJMSTemplate paymentJMSTemplate;
// 	@Autowired private SystemUserRepository systemUserRepository;
// 	@Autowired private PaymentRepository paymentRepository;
// 	@Autowired private Converter<PaymentRequest, Payment> converter;
// 	
// 	@Transactional
// 	public void updateStatusPayments(PaymentStatus oldStatus, PaymentStatus newStatus, String detail) {
// 		List<Payment> payments = paymentRepository.findAllByStatus(oldStatus);
// 		for(Payment payment : payments) {
// 			payment.setStatus(newStatus);
// 			PaymentMessage message = new PaymentMessage(payment.getOrder(), payment.getStatus(), detail);
// 			paymentJMSTemplate.send(message, payment.getOwner().getIntegrationConfig().getPaymentQueue());
// 		}
// 	}
// 	
// 	@Transactional
// 	public PaymentResponse process(PaymentRequest paymentRequest, String username) {
// 		SystemUser systemUser = systemUserRepository.findOneByUsername(username);
// 		save(paymentRequest, systemUser);
// 		return buildResponse(paymentRequest);
// 	}
// 
// 	private PaymentResponse buildResponse(PaymentRequest paymentRequest) {
// 		PaymentResponse response = new PaymentResponse();
// 		response.setOrder(paymentRequest.getOrder());
// 		response.setStatus(PaymentStatus.OPENED);
// 		response.setProcessDate(DatetimeUtil.now(DatetimeUtil.PATTERN_SOAP_DATETIME));
// 		return response;
// 	}
// 
// 	private void save(PaymentRequest paymentRequest, SystemUser systemUser) {
// 		Payment payment = converter.asDomain(paymentRequest);
// 		payment.setOwner(systemUser);
// 		payment.setStatus(PaymentStatus.OPENED);
// 		paymentRepository.save(payment);
// 	}
// 	
// }
// 
// Path: src/main/java/br/fatea/simplebank/soap/payment/v1/PaymentStatus.java
// @XmlType(name = "paymentStatus")
// @XmlEnum
// public enum PaymentStatus {
// 
//     OPENED,
//     CONFIRMED,
//     REVERSED,
//     CANCELED;
// 
//     public String value() {
//         return name();
//     }
// 
//     public static PaymentStatus fromValue(String v) {
//         return valueOf(v);
//     }
// 
// }


// Path: src/main/java/br/fatea/simplebank/model/schedulers/PaymentScheduler.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import br.fatea.simplebank.model.services.PaymentService;
import br.fatea.simplebank.soap.payment.v1.PaymentStatus;

package br.fatea.simplebank.model.schedulers;



@Component
public class PaymentScheduler {
	
	@Autowired private PaymentService paymentService;