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

net.anotheria.anosite.gen.asresourcedata.data.MailTemplateDocument Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
/**
 ********************************************************************************
 *** MailTemplateDocument.java                                                ***
 *** generated by AnoSiteGenerator (ASG), Version: 3.2.2                      ***
 *** Copyright (C) 2005 - 2023 Anotheria.net, www.anotheria.net               ***
 *** All Rights Reserved.                                                     ***
 ********************************************************************************
 *** Don't edit this code, if you aren't sure                                 ***
 *** that you do exactly know what you are doing!                             ***
 *** It's better to invest time in the generator, as into the generated code. ***
 ********************************************************************************
 */

package net.anotheria.anosite.gen.asresourcedata.data;

import net.anotheria.asg.data.AbstractASGDocument;
import java.util.List;
import net.anotheria.anodoc.data.StringProperty;
import net.anotheria.anodoc.util.context.ContextManager;
import net.anotheria.anodoc.data.NoSuchPropertyException;
import net.anotheria.anodoc.data.BooleanProperty;
import net.anotheria.util.crypt.MD5Util;
import net.anotheria.util.sorter.IComparable;
import net.anotheria.util.BasicComparable;
import net.anotheria.asg.data.MultilingualObject;

public class MailTemplateDocument extends AbstractASGDocument implements MailTemplate, IComparable, MultilingualObject{

	public MailTemplateDocument() {
		super("");
	}

	public MailTemplateDocument(String id){
		super(id);
	}

	public MailTemplateDocument(MailTemplateDocument toClone){
		super(toClone);
	}

	MailTemplateDocument(MailTemplateBuilder builder){
		super("");
		setName(builder.name);
		setSender(builder.sender);
		setSenderName(builder.senderName);
		setSubject(builder.subject);
		setMessage(builder.message);
		setMjml(builder.mjml);
		setPlainMessage(builder.plainMessage);
		setLocalizations(builder.localizations);
	}

	public String getName(){
		return getString(PROP_NAME);
	}

	public void setName(String value){
		setString(PROP_NAME, value);
	}

	public String getSenderEN(){
		return getString(PROP_SENDER_EN);
	}

	public String getSenderDE(){
		return getString(PROP_SENDER_DE);
	}

	public String getSender(){
		return getString("sender_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage()));
	}


	public void setSenderEN(String value){
		setString(PROP_SENDER_EN, value);
	}

	public void setSenderDE(String value){
		setString(PROP_SENDER_DE, value);
	}

	public void setSender(String value){
		setString(("sender_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage())), value);
	}


	public String getSenderNameEN(){
		return getString(PROP_SENDER_NAME_EN);
	}

	public String getSenderNameDE(){
		return getString(PROP_SENDER_NAME_DE);
	}

	public String getSenderName(){
		return getString("senderName_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage()));
	}


	public void setSenderNameEN(String value){
		setString(PROP_SENDER_NAME_EN, value);
	}

	public void setSenderNameDE(String value){
		setString(PROP_SENDER_NAME_DE, value);
	}

	public void setSenderName(String value){
		setString(("senderName_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage())), value);
	}


	public String getSubjectEN(){
		return getString(PROP_SUBJECT_EN);
	}

	public String getSubjectDE(){
		return getString(PROP_SUBJECT_DE);
	}

	public String getSubject(){
		return getString("subject_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage()));
	}


	public void setSubjectEN(String value){
		setString(PROP_SUBJECT_EN, value);
	}

	public void setSubjectDE(String value){
		setString(PROP_SUBJECT_DE, value);
	}

	public void setSubject(String value){
		setString(("subject_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage())), value);
	}


	public String getMessageEN(){
		return getString(PROP_MESSAGE_EN);
	}

	public String getMessageDE(){
		return getString(PROP_MESSAGE_DE);
	}

	public String getMessage(){
		return getString("message_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage()));
	}


	public void setMessageEN(String value){
		setString(PROP_MESSAGE_EN, value);
	}

	public void setMessageDE(String value){
		setString(PROP_MESSAGE_DE, value);
	}

	public void setMessage(String value){
		setString(("message_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage())), value);
	}


	public String getMjmlEN(){
		return getString(PROP_MJML_EN);
	}

	public String getMjmlDE(){
		return getString(PROP_MJML_DE);
	}

	public String getMjml(){
		return getString("mjml_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage()));
	}


	public void setMjmlEN(String value){
		setString(PROP_MJML_EN, value);
	}

	public void setMjmlDE(String value){
		setString(PROP_MJML_DE, value);
	}

	public void setMjml(String value){
		setString(("mjml_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage())), value);
	}


	public String getPlainMessageEN(){
		return getString(PROP_PLAIN_MESSAGE_EN);
	}

	public String getPlainMessageDE(){
		return getString(PROP_PLAIN_MESSAGE_DE);
	}

	public String getPlainMessage(){
		return getString("plainMessage_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage()));
	}


	public void setPlainMessageEN(String value){
		setString(PROP_PLAIN_MESSAGE_EN, value);
	}

	public void setPlainMessageDE(String value){
		setString(PROP_PLAIN_MESSAGE_DE, value);
	}

	public void setPlainMessage(String value){
		setString(("plainMessage_"+(isMultilingualDisabledInstance() ? ContextManager.getCallContext().getDefaultLanguage() : ContextManager.getCallContext().getCurrentLanguage())), value);
	}


	public List getLocalizations(){
		return copyToStringList(getList(PROP_LOCALIZATIONS));
	}

	public void setLocalizations(List value){
		setList(PROP_LOCALIZATIONS, copyFromStringList(value));
	}


	public String toString(){
		String ret = "MailTemplate ";
		ret += "["+getId()+"] ";
		ret += "name: "+getName();
		ret += ", ";
		ret += "sender: "+getSender();
		ret += ", ";
		ret += "senderName: "+getSenderName();
		ret += ", ";
		ret += "subject: "+getSubject();
		ret += ", ";
		ret += "message: "+getMessage();
		ret += ", ";
		ret += "mjml: "+getMjml();
		ret += ", ";
		ret += "plainMessage: "+getPlainMessage();
		ret += ", ";
		ret += "localizations: "+getLocalizations();
		return ret;
	}

	public int getLocalizationsSize(){
		return getList(PROP_LOCALIZATIONS).size();
	}

	public void addLocalizationsElement(String guard){
		getListPropertyAnyCase(PROP_LOCALIZATIONS).add(new StringProperty("" + guard, guard));
	} //method

	public void removeLocalizationsElement(int index){
		getListProperty(PROP_LOCALIZATIONS).remove(index);
	} //method

	public void swapLocalizationsElement(int index1, int index2){
		String tmp1, tmp2;
		tmp1 = ((StringProperty)getList(PROP_LOCALIZATIONS).get(index1)).getString();
		tmp2 = ((StringProperty)getList(PROP_LOCALIZATIONS).get(index2)).getString();
		((StringProperty)getList(PROP_LOCALIZATIONS).get(index1)).setString(tmp2);
		((StringProperty)getList(PROP_LOCALIZATIONS).get(index2)).setString(tmp1);
	} //method

	public String getLocalizationsElement(int index){
		StringProperty p = (StringProperty)getList(PROP_LOCALIZATIONS).get(index);
		return p.getString();
	} //method


	public int compareTo(MailTemplate comparable){
		return compareTo(comparable, MailTemplateSortType.SORT_BY_DEFAULT);
	}

	public int compareTo(IComparable anotherComparable, int method){
		MailTemplateDocument anotherDoc = (MailTemplateDocument) anotherComparable;
		switch(method){
			case MailTemplateSortType.SORT_BY_ID:
				return BasicComparable.compareString(getId(), anotherDoc.getId());
			case MailTemplateSortType.SORT_BY_NAME:
				return BasicComparable.compareString(getName(), anotherDoc.getName());
			case MailTemplateSortType.SORT_BY_SENDER:
				return BasicComparable.compareString(getSender(), anotherDoc.getSender());
			case MailTemplateSortType.SORT_BY_SENDERNAME:
				return BasicComparable.compareString(getSenderName(), anotherDoc.getSenderName());
			case MailTemplateSortType.SORT_BY_SUBJECT:
				return BasicComparable.compareString(getSubject(), anotherDoc.getSubject());
			case MailTemplateSortType.SORT_BY_MESSAGE:
				return BasicComparable.compareString(getMessage(), anotherDoc.getMessage());
			case MailTemplateSortType.SORT_BY_MJML:
				return BasicComparable.compareString(getMjml(), anotherDoc.getMjml());
			case MailTemplateSortType.SORT_BY_PLAINMESSAGE:
				return BasicComparable.compareString(getPlainMessage(), anotherDoc.getPlainMessage());
			default:
				throw new RuntimeException("Sort method "+method+" is not supported.");
		}
	}

	public String getDefinedName(){
		return "MailTemplate";
	}

	public String getDefinedParentName(){
		return "ASResourceData";
	}

	public String getFootprint(){
		StringBuilder footprint = new StringBuilder();
		footprint.append(getName());
		footprint.append(getSenderEN());
		footprint.append(getSenderDE());
		footprint.append(getSenderNameEN());
		footprint.append(getSenderNameDE());
		footprint.append(getSubjectEN());
		footprint.append(getSubjectDE());
		footprint.append(getMessageEN());
		footprint.append(getMessageDE());
		footprint.append(getMjmlEN());
		footprint.append(getMjmlDE());
		footprint.append(getPlainMessageEN());
		footprint.append(getPlainMessageDE());
		footprint.append(getLocalizations());
		return MD5Util.getMD5Hash(footprint);
	}
	public void copyLANG2LANG(String sourceLanguage, String destLanguage){
		if (sourceLanguage.equals("EN") && destLanguage.equals("DE"))
			copyEN2DE();
		if (sourceLanguage.equals("DE") && destLanguage.equals("EN"))
			copyDE2EN();
	}

	/**
	 * Copies all multilingual properties from language EN to language DE
	 */
	public void copyEN2DE(){
		setSenderDE(getSenderEN());
		setSenderNameDE(getSenderNameEN());
		setSubjectDE(getSubjectEN());
		setMessageDE(getMessageEN());
		setMjmlDE(getMjmlEN());
		setPlainMessageDE(getPlainMessageEN());
	}

	/**
	 * Copies all multilingual properties from language DE to language EN
	 */
	public void copyDE2EN(){
		setSenderEN(getSenderDE());
		setSenderNameEN(getSenderNameDE());
		setSubjectEN(getSubjectDE());
		setMessageEN(getMessageDE());
		setMjmlEN(getMjmlDE());
		setPlainMessageEN(getPlainMessageDE());
	}


	public boolean isMultilingualDisabledInstance(){
		try{
			return ((BooleanProperty)getInternalProperty(INT_PROPERTY_MULTILINGUAL_DISABLED)).getboolean();
		}catch(NoSuchPropertyException e){
			return false;
		}
	}

	public void setMultilingualDisabledInstance(boolean value){
		setInternalProperty(new BooleanProperty(INT_PROPERTY_MULTILINGUAL_DISABLED, value));
	}

	public boolean equals(Object o){
		return o == this || ((o instanceof MailTemplateDocument) && ((MailTemplateDocument)o).getId().equals(getId()));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy