All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.flexicore.sendgrid.model.SendMailRequest Maven / Gradle / Ivy

The newest version!
package com.flexicore.sendgrid.model;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.flexicore.converters.JsonConverter;
import com.flexicore.interfaces.dynamic.FieldInfo;
import com.flexicore.interfaces.dynamic.IdRefFieldInfo;
import com.flexicore.interfaces.dynamic.ListFieldInfo;
import com.flexicore.model.dynamic.ExecutionParametersHolder;

import javax.persistence.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

@Entity
public class SendMailRequest extends ExecutionParametersHolder {

    @Transient
    @JsonIgnore
    private SendGridTemplate sendGridTemplate;

    @Column(columnDefinition = "jsonb")
    @Convert(converter = JsonConverter.class)
    @JsonIgnore
    private Map templateParameters =new HashMap<>();


    @ListFieldInfo(listType = EmailRef.class,mandatory = true)
    @OneToMany(targetEntity = EmailRef.class,mappedBy = "executionParameterHolder")
    private Set emailRefs=new HashSet<>();

    @FieldInfo(displayName = "from",mandatory = true)
    private String emailFrom;
    @IdRefFieldInfo(refType = SendGridTemplate.class,list = false,mandatory = true)
    private String sendGridTemplateId;

    public String getSendGridTemplateId() {
        return sendGridTemplateId;
    }

    public  T setSendGridTemplateId(String externalServerId) {
        this.sendGridTemplateId = externalServerId;
        return (T) this;
    }

    @Transient
    @JsonIgnore
    public SendGridTemplate getSendGridTemplate() {
        return sendGridTemplate;
    }

    public  T setSendGridTemplate(SendGridTemplate sendGridTemplate) {
        this.sendGridTemplate = sendGridTemplate;
        return (T) this;
    }

    @Column(columnDefinition = "jsonb")
    @Convert(converter = JsonConverter.class)
    @JsonIgnore
    public Map getTemplateParameters() {
        return templateParameters;
    }

    public  T setTemplateParameters(Map genericPredicates) {
        this.templateParameters = genericPredicates;
        return (T) this;
    }

    @JsonAnyGetter
    public Map any() {
        return templateParameters;
    }

    @JsonIgnore
    public boolean supportingDynamic() {
        return false;
    }

    @JsonAnySetter
    public void set(final String name, final Object value) {
        templateParameters.put(name, value);
    }

    @OneToMany(targetEntity = EmailRef.class,mappedBy = "executionParameterHolder")
    public Set getEmailRefs() {
        return emailRefs;
    }

    public  T setEmailRefs(Set emailRefs) {
        this.emailRefs = emailRefs;
        return (T) this;
    }

    public String getEmailFrom() {
        return emailFrom;
    }

    public  T setEmailFrom(String emailFrom) {
        this.emailFrom = emailFrom;
        return (T) this;
    }

    @Override
    public void prepareForSave() {
        super.prepareForSave();
        for (EmailRef emailRef : emailRefs) {
            emailRef.prepareForSave(this);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy