com.plm.model.RecordingQueue.java Source code

Java tutorial

Introduction

Here is the source code for com.plm.model.RecordingQueue.java

Source

/**
 * 
 */
package com.plm.model;

import java.math.BigDecimal;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Set;

import org.apache.commons.lang.StringUtils;

//import com.tandbergtv.tstv.rcs.recqueue.RMScheduleBlocker;
//import com.tandbergtv.tstv.rcs.recqueue.RecRequestQueueConstants;
import com.plm.util.RCSConstants;
//import com.tandbergtv.tstv.rcsrminterface.model.RCSRMInterfaceConstants;

/**
 * This object is used by Recording queue manager.
 * 
 * @author sdhanapal
 * 
 */
public class RecordingQueue extends BaseAuditableModel {
    // Fields
    private Long recordingQueueId;
    private Long recordingId;
    private Long scheduleId;
    private Long poolId;
    private Long rmId;
    private String assetId;
    private String titleAssetId;
    private String movieAssetId;
    private BigDecimal offsetStartTime;
    private BigDecimal offsetEndTime;
    private String recordingMode;
    private Byte priority;
    private String providerQaContact;
    private Boolean catalogEntry;
    private String billingId;
    private String mpaaRating;
    private String tvRating;
    private String providerId;
    private String providerName;
    private String product;
    private String category;
    private String audioType;
    private Integer maxCopies;
    private Integer previewPeriod;
    private Integer redundancyCount;
    private Calendar licenceStartDate;
    private Calendar licenseEndDate;
    private Byte requestType;
    private BigDecimal vodStartTime;
    private BigDecimal vodDuration;
    private String vodRestrictions;
    private BigDecimal rtiStartTime;
    private BigDecimal rtiDuration;
    private String rtiRestrictions;
    private BigDecimal qcStartTime;
    private BigDecimal qcDuration;
    private String qcRestrictions;
    private String programTitle;
    private String programDescription;
    private Byte state;
    private Calendar scheduleStartTime;
    private Calendar scheduleEndTime;
    private Long scheduleDuration;
    private String stationId;
    private String programId;
    private String hdTv;
    private String episodeTitle;
    private String cc;
    private String repeat;
    private String rmName;
    private String rmIpAddress;
    private String yearProgram;
    private Long rmPort;
    private Long stationOffset;
    private long contractId;
    private String headendName;
    private Set<CastCredits> castCreditSet = new HashSet<CastCredits>(0);
    private String advisories;

    //variable used for queue processing. Not persisted in database
    private int returnCode;
    private String returnDescription;
    private String recordingRequestMessage;
    private RMScheduleBlocker blocker;
    private Set<RecordingQueueTrialUseField> trialUseFields = new HashSet<RecordingQueueTrialUseField>(0);
    private Schedule schedule;
    private String timezone;
    private Headend headend;

    private String posterAssetId;
    private String posterImageName;
    private String posterDescription;

    public RecordingQueue() {
    }

    public Headend getHeadend() {
        return headend;
    }

    public void setHeadend(Headend headend) {
        this.headend = headend;
    }

    public Schedule getSchedule() {
        return schedule;
    }

    public void setSchedule(Schedule schedule) {
        this.schedule = schedule;
    }

    public Set<RecordingQueueTrialUseField> getTrialUseFields() {
        return trialUseFields;
    }

    public void setTrialUseFields(Set<RecordingQueueTrialUseField> trialUseFields) {
        this.trialUseFields = trialUseFields;
    }

    public void setRMScheduleBlocker(RMScheduleBlocker blocker) {
        this.blocker = blocker;
    }

    public RMScheduleBlocker getRMScheduleBlocker() {
        return blocker;
    }

    public String getYearProgram() {
        return yearProgram;
    }

    public void setYearProgram(String yearProgram) {
        this.yearProgram = yearProgram;
    }

    public String getTimezone() {
        return timezone;
    }

    public void setTimezone(String timezone) {
        this.timezone = timezone;
    }

    public String getRmName() {
        return rmName;
    }

    public void setRmName(String rmName) {
        this.rmName = rmName;
    }

    public String getRmIpAddress() {
        return rmIpAddress;
    }

    public void setRmIpAddress(String rmIpAddress) {
        this.rmIpAddress = rmIpAddress;
    }

    public Long getRmPort() {
        return rmPort;
    }

    public void setRmPort(Long rmPort) {
        this.rmPort = rmPort;
    }

    public String getRepeat() {
        return repeat;
    }

    public void setRepeat(String repeat) {
        this.repeat = repeat;
    }

    public String getCc() {
        return cc;
    }

    public void setCc(String cc) {
        this.cc = cc;
    }

    public String getEpisodeTitle() {
        return episodeTitle;
    }

    public void setEpisodeTitle(String episodeTitle) {
        this.episodeTitle = episodeTitle;
    }

    public String getHdTv() {
        return hdTv;
    }

    public void setHdTv(String hdTv) {
        this.hdTv = hdTv;
    }

    public Set<CastCredits> getCastCreditSet() {
        return castCreditSet;
    }

    public void setCastCreditSet(Set<CastCredits> castCreditSet) {
        this.castCreditSet = castCreditSet;
    }

    public Byte getState() {
        return state;
    }

    public void setState(Byte state) {
        this.state = state;
    }

    public Long getRecordingQueueId() {
        return this.recordingQueueId;
    }

    public void setRecordingQueueId(Long recordingQueueId) {
        this.recordingQueueId = recordingQueueId;
    }

    public String getHeadendName() {
        return headendName;
    }

    public void setHeadendName(String headendLocation) {
        this.headendName = headendLocation;
    }

    public Long getRecordingId() {
        return this.recordingId;
    }

    public void setRecordingId(Long recordingId) {
        this.recordingId = recordingId;
    }

    public String getTitleAssetId() {
        return titleAssetId;
    }

    public void setTitleAssetId(String titleAssetId) {
        this.titleAssetId = titleAssetId;
    }

    public String getMovieAssetId() {
        return movieAssetId;
    }

    public void setMovieAssetId(String movieAssetId) {
        this.movieAssetId = movieAssetId;
    }

    public Long getScheduleId() {
        return this.scheduleId;
    }

    public void setScheduleId(Long scheduleId) {
        this.scheduleId = scheduleId;
    }

    public Calendar getScheduleStartTime() {
        return (Calendar) scheduleStartTime.clone();
    }

    public void setScheduleStartTime(Calendar scheduleStartTime) {
        this.scheduleStartTime = scheduleStartTime;
    }

    public Calendar getScheduleEndTime() {
        return (Calendar) scheduleEndTime.clone();
    }

    public void setScheduleEndTime(Calendar scheduleEndTime) {
        this.scheduleEndTime = scheduleEndTime;
    }

    public Long getScheduleDuration() {
        return scheduleDuration;
    }

    public void setScheduleDuration(Long scheduleDuration) {
        this.scheduleDuration = scheduleDuration;
    }

    public String getStationId() {
        return stationId;
    }

    public void setStationId(String stationId) {
        this.stationId = stationId;
    }

    public String getProgramId() {
        return programId;
    }

    public void setProgramId(String programId) {
        this.programId = programId;
    }

    public Long getStationOffset() {
        return this.stationOffset;
    }

    public void setStationOffset(Long stationOffset) {
        this.stationOffset = stationOffset;
    }

    public BigDecimal getOffsetStartTime() {
        return this.offsetStartTime;
    }

    public void setOffsetStartTime(BigDecimal offsetStartTime) {
        this.offsetStartTime = offsetStartTime;
    }

    public BigDecimal getOffsetEndTime() {
        return this.offsetEndTime;
    }

    public void setOffsetEndTime(BigDecimal offsetEndTime) {
        this.offsetEndTime = offsetEndTime;
    }

    public String getRecordingMode() {
        return this.recordingMode;
    }

    public void setRecordingMode(String mode) {
        this.recordingMode = mode;
    }

    public Byte getPriority() {
        return this.priority;
    }

    public void setPriority(Byte priority) {
        this.priority = priority;
    }

    public String getProviderQaContact() {
        return this.providerQaContact;
    }

    public void setProviderQaContact(String providerQaContact) {
        this.providerQaContact = providerQaContact;
    }

    public Boolean getCatalogEntry() {
        return this.catalogEntry;
    }

    public void setCatalogEntry(Boolean catalogEntry) {
        this.catalogEntry = catalogEntry;
    }

    public String getBillingId() {
        return this.billingId;
    }

    public void setBillingId(String billingId) {
        this.billingId = billingId;
    }

    public String getMpaaRating() {
        return this.mpaaRating;
    }

    public void setMpaaRating(String mpaaRating) {
        this.mpaaRating = mpaaRating;
    }

    public String getTvRating() {
        return this.tvRating;
    }

    public void setTvRating(String tvRating) {
        this.tvRating = tvRating;
    }

    public String getProviderId() {
        return this.providerId;
    }

    public void setProviderId(String providerId) {
        this.providerId = providerId;
    }

    public String getProviderName() {
        return providerName;
    }

    public void setProviderName(String providerName) {
        this.providerName = providerName;
    }

    public String getProduct() {
        return this.product;
    }

    public void setProduct(String product) {
        this.product = product;
    }

    public String getCategory() {
        return this.category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getAudioType() {
        return this.audioType;
    }

    public void setAudioType(String audioType) {
        this.audioType = audioType;
    }

    public Calendar getLicenceStartDate() {
        return (Calendar) this.licenceStartDate.clone();
    }

    public void setLicenceStartDate(Calendar licenceStartDate) {
        this.licenceStartDate = licenceStartDate;
    }

    public Calendar getLicenseEndDate() {
        return (Calendar) this.licenseEndDate.clone();
    }

    public void setLicenseEndDate(Calendar licenseEndDate) {
        this.licenseEndDate = licenseEndDate;
    }

    public void setReturnCode(int returnCode) {
        this.returnCode = returnCode;
    }

    public int getReturnCode() {
        return returnCode;
    }

    public String getReturnDescription() {
        return returnDescription;
    }

    public void setReturnDescription(String returnDescription) {
        this.returnDescription = returnDescription;
    }

    public void setRecordingRequestMessage(String recordingRequestMessage) {
        this.recordingRequestMessage = recordingRequestMessage;
    }

    public String getRecordingRequestMessage() {
        return recordingRequestMessage;
    }

    public Long getPoolId() {
        return poolId;
    }

    public void setPoolId(Long poolId) {
        this.poolId = poolId;
    }

    public Long getRmId() {
        return rmId;
    }

    public void setRmId(Long rmId) {
        this.rmId = rmId;
    }

    public String getAssetId() {
        return getPackageAssetId();
    }

    public void setAssetId(String assetId) {
        setPackageAssetId(assetId);
    }

    public String getPackageAssetId() {
        return assetId;
    }

    public void setPackageAssetId(String assetId) {
        if (assetId.length() == 16 && StringUtils.isAlpha(Character.toString(assetId.charAt(0)))) {
            /*
             * Added as workaround for auto approve functionality.
             * Should be removed once SQL procedure is fixed.
             */
            this.assetId = RCSConstants.PACKAGE_ASSET_ID_PREFIX + assetId;
        } else {
            this.assetId = assetId;
        }
    }

    public Byte getRequestType() {
        return requestType;
    }

    public void setRequestType(Byte requestType) {
        this.requestType = requestType;
    }

    public String getVodRestrictions() {
        return vodRestrictions;
    }

    public void setVodRestrictions(String vodRestrictions) {
        this.vodRestrictions = vodRestrictions;
    }

    public String getRtiRestrictions() {
        return rtiRestrictions;
    }

    public void setRtiRestrictions(String rtiRestrictions) {
        this.rtiRestrictions = rtiRestrictions;
    }

    public BigDecimal getVodStartTime() {
        return vodStartTime;
    }

    public void setVodStartTime(BigDecimal vodStartTime) {
        this.vodStartTime = vodStartTime;
    }

    public BigDecimal getVodDuration() {
        return vodDuration;
    }

    public void setVodDuration(BigDecimal vodDuration) {
        this.vodDuration = vodDuration;
    }

    public BigDecimal getRtiStartTime() {
        return rtiStartTime;
    }

    public void setRtiStartTime(BigDecimal rtiStartTime) {
        this.rtiStartTime = rtiStartTime;
    }

    public BigDecimal getRtiDuration() {
        return rtiDuration;
    }

    public void setRtiDuration(BigDecimal rtiDuration) {
        this.rtiDuration = rtiDuration;
    }

    public String getProgramTitle() {
        return programTitle;
    }

    public void setProgramTitle(String programTitle) {
        this.programTitle = programTitle;
    }

    public String getProgramDescription() {
        return programDescription;
    }

    public void setProgramDescription(String programDescription) {
        this.programDescription = programDescription;
    }

    public long getDuration() {
        long offsetStart = 0;
        if (offsetStartTime != null)
            offsetStart = offsetStartTime.longValue();

        long offsetEnd = 0;
        if (offsetEndTime != null)
            offsetEnd = offsetEndTime.longValue();

        return scheduleDuration + offsetEnd - offsetStart;
    }

    public void setContractId(long contractId) {
        this.contractId = contractId;
    }

    public long getContractId() {
        return contractId;
    }

    /**
     * This method provides absolute URL for the given relative path.
     * 
     * @param relativePath
     * @return
     */
    //   public String getRmURL()
    //   {
    //      StringBuilder builder = new StringBuilder();
    //      return builder.append(RecRequestQueueConstants.COMMUNICATION_PROTOCOL).
    //            append("://").append(getRmIpAddress()).append(":").append(
    //            getRmPort()).append(RecRequestQueueConstants.RECORDING_REQUEST_RELATIVE_PATH).toString();
    //   }

    public Calendar getOffsetAdjustedStartTime() {
        Calendar cal = (Calendar) scheduleStartTime.clone();
        if (offsetStartTime != null)
            cal.add(Calendar.SECOND, offsetStartTime.intValue());
        if (stationOffset != null)
            cal.add(Calendar.SECOND, stationOffset.intValue());
        return cal;

    }

    public Calendar getOffsetAdjustedEndTime() {
        Calendar cal = (Calendar) scheduleEndTime.clone();
        if (offsetEndTime != null)
            cal.add(Calendar.SECOND, offsetEndTime.intValue());
        if (stationOffset != null && getRequestType() != RCSConstants.RecordingRequestType.STOP_REQUEST)
            cal.add(Calendar.SECOND, stationOffset.intValue());
        return cal;
    }

    public Integer getMaxCopies() {
        return maxCopies;
    }

    public void setMaxCopies(Integer maxCopies) {
        this.maxCopies = maxCopies;
    }

    public Integer getPreviewPeriod() {
        return previewPeriod;
    }

    public void setPreviewPeriod(Integer previewPeriod) {
        this.previewPeriod = previewPeriod;
    }

    public Integer getRedundancyCount() {
        return redundancyCount;
    }

    public void setRedundancyCount(Integer redundancyCount) {
        this.redundancyCount = redundancyCount;
    }

    public String toString() {
        return new StringBuilder().append("Recording Queue[").append("id=").append(recordingQueueId).append(",")
                .append("recording id=").append(recordingId).append(",").append("asset id=").append(assetId)
                .append(",").append("channel id=").append(stationId).append(",").append("program id=")
                .append(programId).append(",").append("rm id=").append(getRmId()).append(",")
                .append("request type=").append(getRequestType()).append("]").toString();
    }

    /**
     * List of time windows and associated restrictions during which the recording can be played back, delimited by comma.
     * The format of a time window is: 
     *       startTime|duration[|restrictions] 
     * Restrictions is a case-insensitive string of alphanumeric characters corresponding to the functions that are disallowed 
     * during the associated time window:
     *       F - fast forward
     *       R - rewind
     *       P - pause
     * 
     * The value format is:
     *       yyyy-mm-ddThh:mm:ss|hh:mm:ss|FRP,...
     * 
     * @return
     */
    //   public String getPlaybackWindows()
    //   {
    //      StringBuilder playbackRestrictionValue = new StringBuilder() ;
    //      boolean restrictionAdded = false ;
    //      if (recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.QC_MODE))
    //      {
    //         if(qcRestrictions != null && qcRestrictions.trim().length() != 0)
    //         {
    //            playbackRestrictionValue.append(RCSConstants.PlaybackRestrictionConstant.QC_MODE).
    //               append(RCSRMInterfaceConstants.Separators.SEPARATOR_COLONS).
    //               append(getPlaybackRestrictionValue(qcStartTime.intValue(), 
    //               qcDuration.intValue(), qcRestrictions)) ;
    //         }
    //      } 
    //      else 
    //      {
    //         if(recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.VOD_MODE) || 
    //               recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.RTI_VOD_MODE))
    //         {
    //            if(vodRestrictions != null && vodRestrictions.trim().length() != 0)
    //            {
    //               playbackRestrictionValue.append(RCSConstants.PlaybackRestrictionConstant.VOD_MODE).
    //                  append(RCSRMInterfaceConstants.Separators.SEPARATOR_COLONS).
    //                  append(getPlaybackRestrictionValue(vodStartTime.intValue(), 
    //                  vodDuration.intValue(), vodRestrictions)) ;
    //               restrictionAdded = true ;            
    //            }
    //         }
    //         if(recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.RTI_MODE) || 
    //               recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.RTI_VOD_MODE))
    //         {
    //            if(rtiRestrictions != null && rtiRestrictions.trim().length() != 0)
    //            {
    //               if(restrictionAdded)
    //                  playbackRestrictionValue.append(",") ;
    //               playbackRestrictionValue.append(RCSConstants.PlaybackRestrictionConstant.RTI_MODE).
    //                  append(RCSRMInterfaceConstants.Separators.SEPARATOR_COLONS).
    //                  append(getPlaybackRestrictionValue(rtiStartTime.intValue(), 
    //                  rtiDuration.intValue(), rtiRestrictions)) ;            
    //            }
    //         }
    //      }
    //      
    //      return playbackRestrictionValue.toString() ;
    //   }

    public Calendar getVODLicenseWindowStartTime() {
        if (recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.VOD_MODE)
                || recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.RTI_VOD_MODE)) {
            Calendar calendar = (Calendar) getOffsetAdjustedStartTime().clone();
            calendar.add(Calendar.SECOND, vodStartTime.intValue());
            return calendar;
        }
        return null;
    }

    public Calendar getVODLicenseWindowEndTime() {
        if (recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.VOD_MODE)
                || recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.RTI_VOD_MODE)) {
            Calendar calendar = (Calendar) getOffsetAdjustedStartTime().clone();
            calendar.add(Calendar.SECOND, vodStartTime.intValue() + vodDuration.intValue());
            return calendar;
        }
        return null;
    }

    public Calendar getRTILicenseWindowStartTime() {
        if (recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.RTI_MODE)
                || recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.RTI_VOD_MODE)) {
            Calendar calendar = (Calendar) getOffsetAdjustedStartTime().clone();
            calendar.add(Calendar.SECOND, rtiStartTime.intValue());
            return calendar;
        }
        return null;
    }

    public Calendar getRTILicenseWindowEndTime() {
        if (recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.RTI_MODE)
                || recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.RTI_VOD_MODE)) {
            Calendar calendar = (Calendar) getOffsetAdjustedStartTime().clone();
            calendar.add(Calendar.SECOND, rtiStartTime.intValue() + rtiDuration.intValue());
            return calendar;
        }
        return null;
    }

    public Calendar getQCLicenseWindowStartTime() {
        if (recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.QC_MODE)) {
            Calendar calendar = (Calendar) getOffsetAdjustedStartTime().clone();
            calendar.add(Calendar.SECOND, qcStartTime.intValue());
            return calendar;
        }
        return null;
    }

    public Calendar getQCLicenseWindowEndTime() {
        if (recordingMode.equals(RCSConstants.PlaybackRestrictionConstant.QC_MODE)) {
            Calendar calendar = (Calendar) getOffsetAdjustedStartTime().clone();
            calendar.add(Calendar.SECOND, qcStartTime.intValue() + qcDuration.intValue());
            return calendar;
        }
        return null;
    }

    //   private String getPlaybackRestrictionValue(int relativeStart, int duration, String restrictionCommaSeparated)
    //   {
    //      StringBuilder playbackRestrictionValue = new StringBuilder() ;
    //      Calendar calendar = (Calendar) getOffsetAdjustedStartTime().clone() ;
    //      calendar.add(Calendar.SECOND, relativeStart) ;
    //      playbackRestrictionValue.append(RecRequestQueueConstants.DATE_TIME_FORMATTER.format(calendar.getTime())) ;
    //      playbackRestrictionValue.append("|") ;
    //      int hours = duration / (60 * 60) ;
    //      int minutes = (duration % (60 * 60)) / 60 ;
    //      int seconds = (duration % (60 * 60)) % 60 ;
    //      playbackRestrictionValue.append(hours).append(":").append(minutes).append(":").append(seconds).append("|") ;
    //      if(restrictionCommaSeparated.contains(RCSConstants.PlaybackRestrictionConstant.ALL_RESTRICTION))
    //      {
    //         playbackRestrictionValue.append("FRP") ;
    //      }
    //      else
    //      {
    //         String[] restrictionArray = restrictionCommaSeparated.split(",") ;
    //         for (int index = 0; index < restrictionArray.length; index++)
    //         {
    //            String restriction = restrictionArray[index];
    //            if(restriction.equals(RCSConstants.PlaybackRestrictionConstant.FAST_FORWARD_RESTRICTION))
    //               playbackRestrictionValue.append("F") ;
    //            else if(restriction.equals(RCSConstants.PlaybackRestrictionConstant.REWIND_RESTRICTION))
    //               playbackRestrictionValue.append("R") ;
    //            else if(restriction.equals(RCSConstants.PlaybackRestrictionConstant.PAUSE_RESTRICTION))
    //               playbackRestrictionValue.append("P") ;
    //         }         
    //      }
    //      
    //      return playbackRestrictionValue.toString() ;
    //   }

    public BigDecimal getQcStartTime() {
        return qcStartTime;
    }

    public void setQcStartTime(BigDecimal qcStartTime) {
        this.qcStartTime = qcStartTime;
    }

    public BigDecimal getQcDuration() {
        return qcDuration;
    }

    public void setQcDuration(BigDecimal qcDuration) {
        this.qcDuration = qcDuration;
    }

    public String getQcRestrictions() {
        return qcRestrictions;
    }

    public void setQcRestrictions(String qcRestrictions) {
        this.qcRestrictions = qcRestrictions;
    }

    public String getAdvisories() {
        return advisories;
    }

    public void setAdvisories(String advisories) {
        this.advisories = advisories;
    }

    public String getPosterAssetId() {
        return posterAssetId;
    }

    public void setPosterAssetId(String posterAssetId) {
        this.posterAssetId = posterAssetId;
    }

    public String getPosterDescription() {
        return posterDescription;
    }

    public void setPosterDescription(String posterDescription) {
        this.posterDescription = posterDescription;
    }

    public String getPosterImageName() {
        return posterImageName;
    }

    public void setPosterImageName(String posterImageName) {
        this.posterImageName = posterImageName;
    }
}