KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > content > ObjectLink


1 package org.jahia.content;
2
3 import java.util.Map JavaDoc;
4
5 import org.jahia.exceptions.JahiaException;
6 import java.util.ArrayList JavaDoc;
7 import java.io.Serializable JavaDoc;
8
9 /**
10  * <p>Title: Represents a link between two objects.</p>
11  * <p>Description: A link between two objects represents a semantic link that
12  * could create any association of sense, ownership, categorization, reference,
13  * and so on between two objects. This is a very general link definition that
14  * allows us to create dynamic links that can then be used to do data integrity
15  * checks, link data analysis, etc..</p>
16  * <p>Copyright: Copyright (c) 2002</p>
17  * <p>Company: </p>
18  * @author Serge Huber
19  * @version 1.0
20  */

21
22 public class ObjectLink implements Serializable JavaDoc {
23     private int ID = -1;
24     private ObjectKey leftObjectKey;
25     private ObjectKey rightObjectKey;
26     private String JavaDoc type;
27     private int status;
28     private java.util.Date JavaDoc creationDate;
29     private String JavaDoc creationUserKey;
30     private java.util.Date JavaDoc lastModificationDate;
31     private String JavaDoc lastModificationUserKey;
32     private java.util.Map JavaDoc leftObjectMetadata;
33     private java.util.Map JavaDoc rightObjectMetadata;
34     private java.util.Map JavaDoc commonMetadata;
35
36     protected ObjectLink (int ID, ObjectKey leftObjectKey,
37                           ObjectKey rightObjectKey,
38                           String JavaDoc type, int status, java.util.Date JavaDoc creationDate,
39                           String JavaDoc creationUserKey,
40                           java.util.Date JavaDoc lastModificationDate,
41                           String JavaDoc lastModificationUserKey,
42                           Map JavaDoc leftObjectMetadata,
43                           Map JavaDoc rightObjectMetadata, Map JavaDoc commonMetadata) {
44         this.ID = ID;
45         this.leftObjectKey = leftObjectKey;
46         this.rightObjectKey = rightObjectKey;
47         this.type = type;
48         this.status = status;
49         this.creationDate = creationDate;
50         this.creationUserKey = creationUserKey;
51         this.lastModificationDate = lastModificationDate;
52         this.lastModificationUserKey = lastModificationUserKey;
53         this.leftObjectMetadata = leftObjectMetadata;
54         this.rightObjectMetadata = rightObjectMetadata;
55         this.commonMetadata = commonMetadata;
56     }
57
58     static public ObjectLink createLink (ObjectKey leftObjectKey,
59                                          ObjectKey rightObjectKey,
60                                          String JavaDoc type, int status,
61                                          java.util.Date JavaDoc creationDate,
62                                          String JavaDoc creationUserKey,
63                                          java.util.Date JavaDoc lastModificationDate,
64                                          String JavaDoc lastModificationUserKey,
65                                          Map JavaDoc leftObjectMetadata,
66                                          Map JavaDoc rightObjectMetadata,
67                                          Map JavaDoc commonMetadata)
68         throws JahiaException {
69         ObjectLink link = new ObjectLink( -1, leftObjectKey, rightObjectKey,
70                                          type, status, creationDate,
71                                          creationUserKey,
72                                          lastModificationDate,
73                                          lastModificationUserKey,
74                                          leftObjectMetadata,
75                                          rightObjectMetadata,
76                                          commonMetadata);
77         ObjectLinkDB.getInstance().createObjectLink(link);
78         return link;
79     }
80
81     static public ObjectLink getLink (int linkID)
82         throws JahiaException {
83         return ObjectLinkDB.getInstance().getObjectLink(linkID);
84     }
85
86     static public ArrayList JavaDoc findByLeftAndRightObjectKeys (ObjectKey leftObjectKey,
87         ObjectKey rightObjectKey)
88         throws JahiaException {
89         return ObjectLinkDB.getInstance().findByLeftAndRightObjectKeys(leftObjectKey, rightObjectKey);
90     }
91
92     static public ArrayList JavaDoc findByLeftObjectKey (ObjectKey leftObjectKey)
93         throws JahiaException {
94         return ObjectLinkDB.getInstance().findByLeftObjectKey(leftObjectKey);
95     }
96
97     static public ArrayList JavaDoc findByRightObjectKey (ObjectKey rightObjectKey)
98         throws JahiaException {
99         return ObjectLinkDB.getInstance().findByRightObjectKey(rightObjectKey);
100     }
101
102     static public ArrayList JavaDoc findByTypeAndLeftAndRightObjectKeys (String JavaDoc type,
103         ObjectKey leftObjectKey,
104         ObjectKey rightObjectKey)
105         throws JahiaException {
106         return ObjectLinkDB.getInstance().findByTypeAndLeftAndRightObjectKeys(type, leftObjectKey, rightObjectKey);
107     }
108
109     static public ArrayList JavaDoc findByTypeAndLeftObjectKey (String JavaDoc type,
110         ObjectKey leftObjectKey)
111         throws JahiaException {
112         return ObjectLinkDB.getInstance().findByTypeAndLeftObjectKey(type, leftObjectKey);
113     }
114
115     static public ArrayList JavaDoc findByTypeAndRightObjectKey (String JavaDoc type,
116         ObjectKey rightObjectKey)
117         throws JahiaException {
118         return ObjectLinkDB.getInstance().findByTypeAndRightObjectKey(type, rightObjectKey);
119     }
120
121     public void save()
122         throws JahiaException {
123         ObjectLinkDB.getInstance().updateObjectLink(this);
124     }
125
126     public void remove()
127         throws JahiaException {
128         ObjectLinkDB.getInstance().removeObjectLink(getID());
129     }
130
131     protected void setID(int ID) {
132         this.ID = ID;
133     }
134
135     public int getID () {
136         return ID;
137     }
138
139     public ObjectKey getLeftObjectKey () {
140         return leftObjectKey;
141     }
142
143     public void setLeftObjectKey (ObjectKey leftObjectKey) {
144         this.leftObjectKey = leftObjectKey;
145     }
146
147     public ObjectKey getRightObjectKey () {
148         return rightObjectKey;
149     }
150
151     public void setRightObjectKey (ObjectKey rightObjectKey) {
152         this.rightObjectKey = rightObjectKey;
153     }
154
155     public String JavaDoc getType () {
156         return type;
157     }
158
159     public void setType (String JavaDoc type) {
160         this.type = type;
161     }
162
163     public int getStatus () {
164         return status;
165     }
166
167     public void setStatus (int status) {
168         this.status = status;
169     }
170
171     public java.util.Date JavaDoc getCreationDate () {
172         return creationDate;
173     }
174
175     public void setCreationDate (java.util.Date JavaDoc creationDate) {
176         this.creationDate = creationDate;
177     }
178
179     public String JavaDoc getCreationUserKey () {
180         return creationUserKey;
181     }
182
183     public void setCreationUserKey (String JavaDoc creationUserKey) {
184         this.creationUserKey = creationUserKey;
185     }
186
187     public java.util.Date JavaDoc getLastModificationDate () {
188         return lastModificationDate;
189     }
190
191     public void setLastModificationDate (java.util.Date JavaDoc lastModificationDate) {
192         this.lastModificationDate = lastModificationDate;
193     }
194
195     public String JavaDoc getLastModificationUserKey () {
196         return lastModificationUserKey;
197     }
198
199     public void setLastModificationUserKey (String JavaDoc lastModificationUserKey) {
200         this.lastModificationUserKey = lastModificationUserKey;
201     }
202
203     public java.util.Map JavaDoc getLeftObjectMetadata () {
204         return leftObjectMetadata;
205     }
206
207     public java.util.Map JavaDoc getRightObjectMetadata () {
208         return rightObjectMetadata;
209     }
210
211     public java.util.Map JavaDoc getCommonMetadata () {
212         return commonMetadata;
213     }
214 }
215
Popular Tags