KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > entities > publishing > PublicationVO


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.entities.publishing;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.Date JavaDoc;
28 import java.util.List JavaDoc;
29
30 import org.infoglue.cms.entities.kernel.BaseEntityVO;
31 import org.infoglue.cms.entities.kernel.ValidatableEntityVO;
32 import org.infoglue.cms.entities.publishing.impl.simple.PublicationImpl;
33 import org.infoglue.cms.util.validators.ConstraintRule;
34 import org.infoglue.cms.util.validators.Range;
35
36 /**
37  * This class represents a published edition. The individual entries in the edition
38  * are contained in the publicationDetails List.
39  */

40 public class PublicationVO extends ValidatableEntityVO implements BaseEntityVO
41 {
42     private Integer JavaDoc publicationId;
43     private Integer JavaDoc repositoryId;
44     private String JavaDoc name;
45     private String JavaDoc description = "No description";;
46     private Date JavaDoc publicationDateTime;
47     private String JavaDoc publisher = null;
48     private List JavaDoc publicationDetails = new ArrayList JavaDoc();
49
50     public Integer JavaDoc getId()
51     {
52         return getPublicationId();
53     }
54
55     public Integer JavaDoc getPublicationId()
56     {
57         return this.publicationId;
58     }
59
60     public void setPublicationId(Integer JavaDoc publicationId)
61     {
62         this.publicationId = publicationId;
63     }
64
65     public Integer JavaDoc getRepositoryId()
66     {
67         return repositoryId;
68     }
69
70     public void setRepositoryId(Integer JavaDoc repositoryId)
71     {
72         this.repositoryId = repositoryId;
73     }
74
75     public String JavaDoc getName()
76     {
77         return this.name;
78     }
79
80     public void setName(String JavaDoc name)
81     {
82         this.name = name;
83     }
84
85     public String JavaDoc getDescription()
86     {
87         return this.description;
88     }
89
90     public void setDescription(String JavaDoc description)
91     {
92         if(description != null && !description.equals(""))
93             this.description = description;
94     }
95
96     public Date JavaDoc getPublicationDateTime()
97     {
98         return this.publicationDateTime;
99     }
100
101     public void setPublicationDateTime(Date JavaDoc publicationDateTime)
102     {
103         this.publicationDateTime = publicationDateTime;
104     }
105
106     public String JavaDoc getPublisher()
107     {
108         return this.publisher;
109     }
110
111     public void setPublisher(String JavaDoc publisher)
112     {
113         this.publisher = publisher;
114     }
115
116     public List JavaDoc getPublicationDetails()
117     {
118         return publicationDetails;
119     }
120
121     public void setPublicationDetails(List JavaDoc c)
122     {
123         publicationDetails = (c != null)? c : new ArrayList JavaDoc();
124     }
125
126     public void PrepareValidation()
127     {
128         // Define the constraint rules for this valueobject
129
// maybe this belongs in the setters of this object?.
130
// then this method would be obsolete, and the validation
131
// should be initiated through a controller from the
132
// action class??.
133
// -----------------------------------------
134

135         // On the rulelist set the class that holds this vo, the class
136
// that is known to castor. This is for unique validation and
137
// if possible should not be set in the valueobject, but preferably
138
// in the actual castor-entity class. (Im not to satisfied with this
139
// construction).
140
rules.setEntityClass(PublicationImpl.class);
141
142         // Create a new constraintrule, supply constraint type, and field that this rule
143
// applies to.
144
ConstraintRule cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.STRING, "Publication.name");
145
146         // Set the constraints
147
cr.setValidRange(new Range(2, 50) );
148         cr.unique=true; // public variabel will be changed to setter later
149
cr.required=true; // public variabel will be changed to setter later
150
cr.setValue(name);
151
152         // Add this rule to the rulelist
153
rules.addRule(cr);
154
155         // Create a new constraintrule, supply constraint type, and field that this rule
156
// applies to.
157
cr = new ConstraintRule(org.infoglue.cms.util.validators.Constants.STRING, "Publication.description");
158
159         // Set the constraints
160
cr.setValidRange(new Range(2, 50) );
161         cr.unique=false; // public variabel will be changed to setter later
162
cr.required=true; // public variabel will be changed to setter later
163
cr.setValue(description);
164
165         // Add this rule to the rulelist
166
rules.addRule(cr);
167     }
168 }
169
170
Popular Tags