1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.springframework.extensions.surf.types;
20
21 import org.dom4j.Document;
22 import org.springframework.extensions.surf.ModelObject;
23 import org.springframework.extensions.surf.ModelPersisterInfo;
24 import org.springframework.extensions.surf.RequestContext;
25
26
27
28
29
30
31 public class ContentAssociationImpl extends AbstractModelObject implements ContentAssociation
32 {
33
34
35
36
37
38 public ContentAssociationImpl(String id, ModelPersisterInfo key, Document document)
39 {
40 super(id, key, document);
41 }
42
43
44
45
46 public String getTypeId()
47 {
48 return TYPE_ID;
49 }
50
51
52
53
54 public String getSourceId()
55 {
56 return getProperty(PROP_SOURCE_ID);
57 }
58
59
60
61
62 public void setSourceId(String sourceId)
63 {
64 setProperty(PROP_SOURCE_ID, sourceId);
65 }
66
67
68
69
70 public String getDestId()
71 {
72 return getProperty(PROP_DEST_ID);
73 }
74
75
76
77
78 public void setDestId(String destId)
79 {
80 setProperty(PROP_DEST_ID, destId);
81 }
82
83
84
85
86 public String getAssociationType()
87 {
88 return getProperty(PROP_ASSOC_TYPE);
89 }
90
91
92
93
94 public void setSourceType(String sourceType)
95 {
96 setProperty(PROP_SOURCE_TYPE, sourceType);
97 }
98
99
100
101
102 public String getSourceType()
103 {
104 return getProperty(PROP_SOURCE_TYPE);
105 }
106
107
108
109
110 public void setAssociationType(String associationType)
111 {
112 setProperty(PROP_ASSOC_TYPE, associationType);
113 }
114
115
116
117
118 public String getFormatId()
119 {
120 return getProperty(PROP_FORMAT_ID);
121 }
122
123
124
125
126 public void setFormatId(String formatId)
127 {
128 setProperty(PROP_FORMAT_ID, formatId);
129 }
130
131
132
133 public ModelObject getObject(RequestContext context)
134 {
135 ModelObject modelObject = null;
136
137 if (isTemplateAssociation())
138 {
139 modelObject = context.getModel().getTemplate(getDestId());
140 }
141 else if (isPageAssociation())
142 {
143 modelObject = context.getModel().getPage(getDestId());
144 }
145
146 return modelObject;
147 }
148
149 public boolean isTemplateAssociation()
150 {
151 return (getAssociationType() == null || "template".equalsIgnoreCase(getAssociationType()));
152 }
153
154
155
156
157
158
159 public boolean isPageAssociation()
160 {
161 return ("page".equalsIgnoreCase(getAssociationType()));
162 }
163
164 }