package org.xcolab.portlets.contestmanagement.beans;

import com.ext.portlet.model.Contest;
import com.ext.portlet.model.ContestType;
import com.ext.portlet.model.DiscussionCategoryGroup;
import com.ext.portlet.service.ContestTypeLocalServiceUtil;
import com.ext.portlet.service.DiscussionCategoryGroupLocalServiceUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import org.xcolab.portlets.contestmanagement.wrappers.ContestScheduleWrapper;
import org.xcolab.portlets.contestmanagement.wrappers.WikiPageWrapper;
import org.xcolab.wrappers.BaseContestWrapper;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;

/**
 * Created by steve on 12/02/16.
 */
public class ContestAdminBean implements Serializable {
    private static final long serialVersionUID = 1L;

    private String emailTemplateUrl;
    private ContestModelSettingsBean contestModelSettings;

    private boolean hideRibbons;

    @NotNull(message = "A contest tier must be selected.")
    private Long contestTier;

    @NotNull(message = "A contest type must be selected.")
    private Long contestType;

    public ContestAdminBean() { }

    public ContestAdminBean(Contest contest) {
        if (contest != null) {
            contestTier = contest.getContestTier();
            contestType = contest.getContestTypeId();
            hideRibbons = contest.getHideRibbons();
            emailTemplateUrl = contest.getEmailTemplateUrl();
            contestModelSettings = new ContestModelSettingsBean(contest);
        }
    }

    public void persist(Contest contest) throws SystemException, UnsupportedEncodingException, PortalException {
        updateContestDescription(contest);
    }

    public String getEmailTemplateUrl() {
        if (emailTemplateUrl != null) {
            return emailTemplateUrl;
        } else {
            return "";
        }
    }

    public void setEmailTemplateUrl(String emailTemplateUrl) {
        this.emailTemplateUrl = emailTemplateUrl;
    }

    public Long getContestTier() {
        return contestTier;
    }

    public void setContestTier(Long contestTier) {
        this.contestTier = contestTier;
    }

    public Long getContestType() { return contestType; }

    public void setContestType(Long contestType) {
        this.contestType = contestType;
    }

    public ContestModelSettingsBean getContestModelSettings() {
        return contestModelSettings;
    }

    public void setContestModelSettings(ContestModelSettingsBean contestModelSettings) {
        this.contestModelSettings = contestModelSettings;
    }

    public boolean isHideRibbons() {
        return hideRibbons;
    }

    public void setHideRibbons(boolean hideRibbons) {
        this.hideRibbons = hideRibbons;
    }

    private void updateContestDescription(Contest contest) throws SystemException, PortalException {
        contest.setEmailTemplateUrl(emailTemplateUrl);
        contest.setContestTier(contestTier);
        contest.setContestTypeId(contestType);
        contest.setHideRibbons(hideRibbons);
        contest.persist();
        contestModelSettings.persist(contest);
    }

}

@@ -100,539 +100,115 @@
 com.
-ext.portlet.model.ContestType;%0Aimport com.ext.portlet.model.DiscussionCategoryGroup;%0Aimport com.ext.portlet.service.ContestTypeLocalServiceUtil;%0Aimport com.ext.portlet.service.DiscussionCategoryGroupLocalServiceUtil;%0Aimport com.liferay.portal.kernel.exception.PortalException;%0Aimport com.liferay.portal.kernel.exception.SystemException;%0Aimport org.xcolab.portlets.contestmanagement.wrappers.ContestScheduleWrapper;%0Aimport org.xcolab.portlets.contestmanagement.wrappers.WikiPageWrapper;%0Aimport org.xcolab.wrappers.BaseContestWrapper
+liferay.portal.kernel.exception.PortalException;%0Aimport com.liferay.portal.kernel.exception.SystemException
 ;%0A%0Ai

Remove unnecessary imports