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

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.mt4xx.tag.tag495.*;
import com.brilliance.isc.swift.objmtconvert.result.MtResult;

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

public class MT495Creator extends AbsMTCreator {
    @Status("M")
    @TagName("20")
    @FieldDescription("Transaction Reference Number")
    @TagRegex("16x")
    private String transactionReferenceNumber;
    @Status("M")
    @TagName("21")
    @FieldDescription("Related Reference")
    @TagRegex("16x")
    private String relatedReference;
    @Status("O")
    @TagName("75")
    @FieldDescription("Queries")
    @TagRegex("6*35x")
    private String queries;
    @Status("O")
    @TagName("77A")
    @FieldDescription("Narrative")
    @TagRegex("20*35x")
    //77A
    private String narrative;
    @Status("M")
    @TagName("11S")
    @FieldDescription("MT and Date of the Original Message")
    @TagRegex("3!n<crlf>6!n<crlf>[4!n6!n]")
    //11a
    private String mtandDate;
    //11r
    @Status("O")
    @TagName("11R")
    @FieldDescription("MT and Date of the Original Message")
    @TagRegex("3!n<crlf>6!n<crlf>[4!n6!n]")
    private String mtAndDateoftheOriginalMessage;
    @Status("O")
    @TagName("79")
    @FieldDescription("Narrative Description of the Original Message")
    @TagRegex("35*50x")
    //79
    private String narrativeDescriptionofQueryRelates;
    @Status("O")
    @TagName("")
    @FieldDescription("Copy of at least the Mandatory Fields of the Original Message")
    @TagRegex("Copy of fields")
    private String copyoffields;

    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 getQueries() {
        return queries;
    }

    public void setQueries(String queries) {
        this.queries = queries;
    }

    public String getNarrative() {
        return narrative;
    }

    public void setNarrative(String narrative) {
        this.narrative = narrative;
    }

    public String getMtandDate() {
        return mtandDate;
    }

    public void setMtandDate(String mtandDate) {
        this.mtandDate = mtandDate;
    }

    public String getMtAndDateoftheOriginalMessage() {
        return mtAndDateoftheOriginalMessage;
    }

    public void setMtAndDateoftheOriginalMessage(String mtAndDateoftheOriginalMessage) {
        this.mtAndDateoftheOriginalMessage = mtAndDateoftheOriginalMessage;
    }

    public String getNarrativeDescriptionofQueryRelates() {
        return narrativeDescriptionofQueryRelates;
    }

    public void setNarrativeDescriptionofQueryRelates(String narrativeDescriptionofQueryRelates) {
        this.narrativeDescriptionofQueryRelates = narrativeDescriptionofQueryRelates;
    }

    public String getCopyoffields() {
        return copyoffields;
    }

    public void setCopyoffields(String copyoffields) {
        this.copyoffields = copyoffields;
    }

    public MT495Creator(String msgType) {
        super(msgType);
    }

    public MT495Creator() {
        super("495");
    }

    @Override
    public void pack() {
       // MtResult mtResult = new MtResult();
        List<AbsTagCreate> tagCreateList=new ArrayList<>();
        try{
            tagCreateList.add(new Tag20Creator(this));
            tagCreateList.add(new Tag21Creator(this));
            tagCreateList.add(new Tag75Creator(this));
            tagCreateList.add(new Tag77ACreator(this));
            tagCreateList.add(new Tag11sCreator(this));
            tagCreateList.add(new Tag11rCreator(this));
            tagCreateList.add(new Tag79Creator(this));
            tagCreateList.add(new TagCreator(this));
            dealTags(tagCreateList);
            mtResult.setMessage(abstractMT.message());
        }catch (Exception e) {
            e.printStackTrace();
            mtResult.setSuccess(false);
            mtResult.addDescription(e.getLocalizedMessage());
        }

        //return mtResult;

    }
}
