View Javadoc
1   /******************************************************************************
2    * LibrarySection.java - domain object
3    * 
4    * BuckoVidLib - The BuckoSoft Video Library
5    * Copyright(c) 2014 - Dick Balaska
6    * 
7    */
8   package com.buckosoft.BuckoVidLib.domain;
9   
10  import java.util.ArrayList;
11  import java.util.List;
12  
13  
14  /** LibrarySection domain object. Describe one section of the library.
15   * Note: This is a fuller object that does not get RESTed.
16   * 
17   * @author dick
18   * @since 2014-10-06
19   */
20  
21  public class LibrarySection {
22  	private	int		key;
23  	private	String	name;
24  	private	String	type;
25  	private	boolean	restricted = false;
26  	private	List<VideoBase>	videos = new ArrayList<VideoBase>();
27  
28  	public enum	Type {
29  		Movie,
30  		TVShow,
31  	}
32  	
33  	public LibrarySection() {}
34  	
35  	/** Clone another LibrarySection
36  	 * @param other The LibrarySection to make a copy of.
37  	 */
38  	public LibrarySection(LibrarySection other) {
39  		this.key = other.key;
40  		this.name = other.name;
41  		this.type = other.type;
42  		this.restricted = other.restricted;
43  		for (VideoBase vb : other.videos)
44  			videos.add(vb);
45  	}
46  	/**
47  	 * @return the key
48  	 */
49  	public int getKey() {
50  		return key;
51  	}
52  	/**
53  	 * @param key the key to set
54  	 */
55  	public void setKey(int key) {
56  		this.key = key;
57  	}
58  	/**
59  	 * @return the name
60  	 */
61  	public String getName() {
62  		return name;
63  	}
64  	/**
65  	 * @param name the name to set
66  	 */
67  	public void setName(String name) {
68  		this.name = name;
69  	}
70  	/**
71  	 * @return the videoCount
72  	 */
73  	public int getVideoCount() {
74  		return(this.videos.size());
75  	}
76  
77  	/**
78  	 * @return the videos
79  	 */
80  	public List<VideoBase> getVideos() {
81  		return videos;
82  	}
83  	/**
84  	 * @param videos the videos to set
85  	 */
86  	public void setVideos(List<VideoBase> videos) {
87  		this.videos = videos;
88  	}
89  	
90  	public void addVideo(VideoBase v) {
91  		this.videos.add(v);
92  	}
93  	/**
94  	 * @return the type
95  	 */
96  	public Type getType() {
97  		return(type.equals("M") ? Type.Movie : Type.TVShow);
98  	}
99  	/**
100 	 * @param type the type to set
101 	 */
102 	public void setType(Type type) {
103 		this.type =  type == Type.Movie ? "M" : "T";
104 	}
105 
106 	public void setType(String type) {
107 		if (type.equals("movie"))
108 			this.type = "M";
109 		if (type.equals("show"))
110 			this.type = "T";
111 	}
112 	
113 	/** Hibernate gets access to the primitive type
114 	 * @param type
115 	 */
116 	public void setCtype(String type) {
117 		this.type = type;
118 	}
119 	public String getCtype() {
120 		return(this.type);
121 	}
122 	
123 	/**
124 	 * @return the restricted
125 	 */
126 	public boolean isRestricted() {
127 		return restricted;
128 	}
129 	/**
130 	 * @param restricted the restricted to set
131 	 */
132 	public void setRestricted(boolean restricted) {
133 		this.restricted = restricted;
134 	}
135 	
136 }