package com.brilliance.isc.swift.objmtconvert.model.mt1xx;

import com.brilliance.isc.swift.objmtconvert.annotation.FieldDescription;
import com.brilliance.isc.swift.objmtconvert.annotation.Status;
import com.brilliance.isc.swift.objmtconvert.annotation.TagName;
import com.brilliance.isc.swift.objmtconvert.annotation.TagRegex;
import com.brilliance.isc.swift.objmtconvert.model.AbsMTCreator;
import com.brilliance.isc.swift.objmtconvert.model.AbsTagCreate;
import com.brilliance.isc.swift.objmtconvert.model.mt1xx.tag.tag105.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

import java.util.ArrayList;
import java.util.List;

public class MT105Creator extends AbsMTCreator {
    @Status("M")
    @TagName("27")
    @FieldDescription("Sequence of Total")
    @TagRegex("1!n/1!n")
    //27
    private String sequenceofTotal;
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    //20
    private String transactionReferenceNumber;
    @Status("M")
    @TagName("21")
    @FieldDescription("Related Reference")
    @TagRegex("16x")
    //21
    private String relatedReference;
    @Status("M")
    @TagName("12")
    @FieldDescription("Sub-Message Type")
    @TagRegex("3!n")
    //12
    private String subMessageType;
    @Status("M")
    @TagName("77F")
    @FieldDescription("EDIFACT Message")
    @TagRegex("1800y")
    //77F
    private String edifactMessage;

    public String getSequenceofTotal() {
        return sequenceofTotal;
    }

    public void setSequenceofTotal(String sequenceofTotal) {
        this.sequenceofTotal = sequenceofTotal;
    }

    public String getTransactionReferenceNumber() {
        return transactionReferenceNumber;
    }

    public void setTransactionReferenceNumber(String transactionReferenceNumber) {
        this.transactionReferenceNumber = transactionReferenceNumber;
    }

    public String getRelatedReference() {
        return relatedReference;
    }

    public void setRelatedReference(String relatedReference) {
        this.relatedReference = relatedReference;
    }

    public String getSubMessageType() {
        return subMessageType;
    }

    public void setSubMessageType(String subMessageType) {
        this.subMessageType = subMessageType;
    }

    public String getEdifactMessage() {
        return edifactMessage;
    }

    public void setEdifactMessage(String edifactMessage) {
        this.edifactMessage = edifactMessage;
    }

    //    public MT105Creator(String jsonData) throws Exception {
//        super(jsonData);
//    }
    public MT105Creator(String msgType)  {
    super(msgType);
}

    @Override
    public void pack() {
       // MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try {
            tagCreateList.add(new Tag12Creator(this));
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag27Creator(this));
            tagCreateList.add(new Tag77FCreator(this));

            dealTags(tagCreateList);

            mtResult.setMessage(abstractMT.message());
        } catch (Exception e) {
            e.printStackTrace();
            mtResult.setSuccess(false);
            mtResult.addDescription(e.getLocalizedMessage());
        }

       // return mtResult;

    }

    public MtResult unpack() {
        return null;
    }
}
