// Path: core/src/main/java/com/github/ehe/simpleorchestrator/Task.java
// public interface Task<P extends Context> {
//     /**
//      * @param context <code>context</code> interface that this Task is working on
//      * @throws OrchestratorException if there is an issue
//      */
//     void execute(P context) throws OrchestratorException;
// }
// 
// Path: core/src/main/java/com/github/ehe/simpleorchestrator/exception/OrchestratorException.java
// public class OrchestratorException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     private int errorCode = 0;
// 
//     public OrchestratorException(String msg, Throwable cause) {
//         super(msg, cause);
//     }
// 
//     public OrchestratorException(String msg, int errorCode) {
//         super(msg);
//         this.errorCode = errorCode;
//     }
// 
//     public OrchestratorException(String msg, int errorCode, Throwable cause) {
//         super(msg, cause);
//         this.errorCode = errorCode;
//     }
// 
//     public int getErrorCode() {
//         return errorCode;
//     }
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/context/DebitCardContext.java
// public interface DebitCardContext extends HistoryContext<String> {
//     CardApplication getApplication();
//     void setCardApproveStatus(boolean isApproved);
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/entity/CardApplication.java
// public class CardApplication {
//     private Person person;
//     private String occupation;
//     private boolean employed;
//     @NotNull
//     private CardType cardType;
// 
//     public CardApplication(Person person, String occupation, boolean employed, CardType cardType) {
//         this.person = person;
//         this.occupation = occupation;
//         this.employed = employed;
//         this.cardType = cardType;
//     }
// 
//     public CardApplication() {
//     }
// 
//     public Person getPerson() {
//         return person;
//     }
// 
//     public void setPerson(Person person) {
//         this.person = person;
//     }
// 
//     public String getOccupation() {
//         return occupation;
//     }
// 
//     public void setOccupation(String occupation) {
//         this.occupation = occupation;
//     }
// 
//     public boolean isEmployed() {
//         return employed;
//     }
// 
//     public void setEmployed(boolean employed) {
//         this.employed = employed;
//     }
// 
//     public CardType getCardType() {
//         return cardType;
//     }
// 
//     public void setCardType(CardType cardType) {
//         this.cardType = cardType;
//     }
// 
//     public enum CardType{
//         Credit, Debit
//     }
// }


import com.github.ehe.simpleorchestrator.Task;
import com.github.ehe.simpleorchestrator.exception.OrchestratorException;
import com.github.ehe.simpleorchestrator.sample.context.DebitCardContext;
import com.github.ehe.simpleorchestrator.sample.entity.CardApplication;
import org.springframework.stereotype.Component;
/*
 *
 *  * Copyright (c) 2017. Eric He (eriche39@gmail.com)
 *  *
 *  * This software is licensed under
 *  *
 *  * MIT license
 *  *
 *
 */

package com.github.ehe.simpleorchestrator.sample.task;


@Component
public class DebitCardTask implements Task<DebitCardContext> {
    @Override
    public void execute(DebitCardContext context) throws OrchestratorException {
        context.logHistory(this.getClass().getName());
        CardApplication app = context.getApplication();
        if(app.getOccupation().length()>0)
// Path: core/src/main/java/com/github/ehe/simpleorchestrator/Task.java
// public interface Task<P extends Context> {
//     /**
//      * @param context <code>context</code> interface that this Task is working on
//      * @throws OrchestratorException if there is an issue
//      */
//     void execute(P context) throws OrchestratorException;
// }
// 
// Path: core/src/main/java/com/github/ehe/simpleorchestrator/exception/OrchestratorException.java
// public class OrchestratorException extends RuntimeException {
// 
//     private static final long serialVersionUID = 1L;
// 
//     private int errorCode = 0;
// 
//     public OrchestratorException(String msg, Throwable cause) {
//         super(msg, cause);
//     }
// 
//     public OrchestratorException(String msg, int errorCode) {
//         super(msg);
//         this.errorCode = errorCode;
//     }
// 
//     public OrchestratorException(String msg, int errorCode, Throwable cause) {
//         super(msg, cause);
//         this.errorCode = errorCode;
//     }
// 
//     public int getErrorCode() {
//         return errorCode;
//     }
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/context/DebitCardContext.java
// public interface DebitCardContext extends HistoryContext<String> {
//     CardApplication getApplication();
//     void setCardApproveStatus(boolean isApproved);
// }
// 
// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/entity/CardApplication.java
// public class CardApplication {
//     private Person person;
//     private String occupation;
//     private boolean employed;
//     @NotNull
//     private CardType cardType;
// 
//     public CardApplication(Person person, String occupation, boolean employed, CardType cardType) {
//         this.person = person;
//         this.occupation = occupation;
//         this.employed = employed;
//         this.cardType = cardType;
//     }
// 
//     public CardApplication() {
//     }
// 
//     public Person getPerson() {
//         return person;
//     }
// 
//     public void setPerson(Person person) {
//         this.person = person;
//     }
// 
//     public String getOccupation() {
//         return occupation;
//     }
// 
//     public void setOccupation(String occupation) {
//         this.occupation = occupation;
//     }
// 
//     public boolean isEmployed() {
//         return employed;
//     }
// 
//     public void setEmployed(boolean employed) {
//         this.employed = employed;
//     }
// 
//     public CardType getCardType() {
//         return cardType;
//     }
// 
//     public void setCardType(CardType cardType) {
//         this.cardType = cardType;
//     }
// 
//     public enum CardType{
//         Credit, Debit
//     }
// }


// Path: samples/src/main/java/com/github/ehe/simpleorchestrator/sample/task/DebitCardTask.java
import com.github.ehe.simpleorchestrator.Task;
import com.github.ehe.simpleorchestrator.exception.OrchestratorException;
import com.github.ehe.simpleorchestrator.sample.context.DebitCardContext;
import com.github.ehe.simpleorchestrator.sample.entity.CardApplication;
import org.springframework.stereotype.Component;

/*
 *
 *  * Copyright (c) 2017. Eric He (eriche39@gmail.com)
 *  *
 *  * This software is licensed under
 *  *
 *  * MIT license
 *  *
 *
 */

package com.github.ehe.simpleorchestrator.sample.task;


@Component
public class DebitCardTask implements Task<DebitCardContext> {
    @Override
    public void execute(DebitCardContext context) throws OrchestratorException {
        context.logHistory(this.getClass().getName());
        CardApplication app = context.getApplication();
        if(app.getOccupation().length()>0)
            context.setCardApproveStatus(true);