Source code: com/flexstor/common/data/AssetRecordData.java
1 /*
2 * AssetRecordData.java
3 *
4 * Copyright $Date: 2003/08/11 02:22:35 $ FLEXSTOR.net Inc.
5 *
6 * This work is licensed for use and distribution under license terms found at
7 * http://www.flexstor.org/license.html
8 *
9 */
10
11 package com.flexstor.common.data;
12
13 import java.io.File;
14 import java.util.Vector;
15
16 /**
17 * The record data object representing an asset
18 */
19 public class AssetRecordData
20 extends RecordData
21 {
22
23
24 static final long serialVersionUID = 8338091067605342405L;
25
26 private int nStatus = -1;
27
28 /** This field represents the archive status of the asset which corresponds
29 * directly to the archive_status column in the database. These values can
30 * also be found in com.flexstor.common.data.AssetRecordData
31 */
32 private int nArchiveStatus = 99999;
33
34 public void setRoleId( Integer value )
35 {
36 super.setInteger( ROLE_ID, value);
37 }
38
39 public Integer getRoleId()
40 {
41 return super.getInteger( ROLE_ID);
42 }
43
44 public void setServer( String value )
45 {
46 super.setString( SERVER, value );
47 }
48
49 public String getServer()
50 {
51 return getString( SERVER );
52 }
53
54 public void setLocation( String value )
55 {
56 super.setString( LOCATION, value );
57 }
58
59 public String getLocation()
60 {
61 return super.getString( LOCATION );
62 }
63
64 public void setFileName( String value )
65 {
66 super.setString( FILENAME, value );
67 }
68
69 public String getFileName()
70 {
71 return super.getString( FILENAME );
72 }
73
74 public String getFilePath()
75 {
76 String loc = this.getLocation();
77 String fileSep = File.separator;
78 int sepIdx = loc.indexOf(File.separator);
79 if (sepIdx == -1)
80 {//location might use a file separator from a different file system
81 sepIdx = loc.indexOf("/");
82 if(sepIdx != -1)
83 {
84 fileSep = "/";
85 }
86 }
87 if (sepIdx != -1)
88 {// a file separator has been established
89 if (!loc.startsWith(fileSep))
90 {
91 loc = fileSep + loc;
92 }
93 }
94 return loc + this.getFileName();
95 }
96
97 public void setFileSize( Long value )
98 {
99 super.setLong( FILESIZE, value );
100 }
101
102 public Long getFileSize()
103 {
104 return super.getLong( FILESIZE );
105 }
106
107 public void setAppleTalkVendor( Integer value )
108 {
109 super.setInteger( APPLETALK_VENDOR, value );
110 }
111
112 public Integer getAppleTalkVendor()
113 {
114 return super.getInteger( APPLETALK_VENDOR );
115 }
116
117 public void setKeepResourceFork( Boolean value )
118 {
119 super.setBoolean( KEEP_RESOURCEFORK, value );
120 }
121
122 public Boolean isKeepResourceFork()
123 {
124 return super.getBoolean( KEEP_RESOURCEFORK );
125 }
126
127 public void setMacBinaryFormat( Boolean value )
128 {
129 super.setBoolean( MACBINARY_FORMAT, value );
130 }
131
132 public Boolean isMacBinaryFormat()
133 {
134 return super.getBoolean( MACBINARY_FORMAT );
135 }
136
137 public void setDestinationLocation( String value )
138 {
139 super.setString( DESTINATION_LOCATION, value );
140 }
141
142 public String getDestinationLocation()
143 {
144 return super.getString( DESTINATION_LOCATION );
145 }
146
147 public void setDestinationFileName( String value )
148 {
149 super.setString( DESTINATION_FILENAME, value );
150 }
151
152 public String getDestinationFileName()
153 {
154 String sFilename = super.getString( DESTINATION_FILENAME );
155 if( sFilename == null )
156 return getFileName();
157 else
158 return sFilename;
159 }
160
161 public String getDestinationFilePath()
162 {
163 String loc = this.getDestinationLocation();
164 String fileSep = File.separator;
165 int sepIdx = loc.indexOf(File.separator);
166 if(sepIdx == -1)
167 {//location might use a file separator from a different file system
168 sepIdx = loc.indexOf("/");
169 if(sepIdx != -1)
170 {
171 fileSep = "/";
172 }
173 }
174 if(sepIdx != -1)
175 {// a file separator has been established
176 if(!loc.startsWith(fileSep))
177 {
178 loc = fileSep + loc;
179 }
180 }
181 return loc + this.getDestinationFileName();
182 }
183
184 public long getAssetId()
185 {
186 //AssetId is same as RecordId.
187 return getRecordId();
188 }
189
190 public long getElemId()
191 {
192 ///Geting the element id using the Traversal info.
193 Vector traversalInfo = getTraversalPathInfo();
194 TraversalInfo info = (TraversalInfo)traversalInfo.elementAt( 0 );
195 Vector traversalItems = info.getTraversalItems();
196 // Element Id is always last Item
197 TraversalItem item = (TraversalItem)traversalItems.elementAt( traversalItems.size() - 1 );
198 return item.getRecordId();
199 }
200
201 //Default view Asset Id.
202 public Long getDefaultViewAssetId()
203 {
204 return super.getLong( DEFAULT_VIEW_ASSET_ID );
205 }
206
207 public void setDefaultViewAssetId( Long defaultId )
208 {
209 super.setLong( DEFAULT_VIEW_ASSET_ID, defaultId );
210 }
211
212 public void setAsDefaultViewAsset()
213 {
214 super.setBoolean(DEFAULT_VIEW_ASSET, Boolean.TRUE);
215 }
216
217 public void unsetAsDefaultViewAsset()
218 {
219 super.setBoolean(DEFAULT_VIEW_ASSET, Boolean.FALSE);
220 }
221
222 public boolean isDefaultViewAsset()
223 {
224 Boolean b = super.getBoolean(DEFAULT_VIEW_ASSET);
225 return b == null ? false : b.booleanValue();
226 }
227
228 public void setStatus(int status)
229 {
230 nStatus = status;
231 }
232
233 public int getStatus()
234 {
235 return nStatus;
236 }
237
238 public Object clone()
239 {
240 AssetRecordData clone = new AssetRecordData();
241 super.fillCloneInfo( clone );
242 return clone;
243 }
244
245 public boolean equals( Object obj )
246 {
247 if ( !(obj instanceof AssetRecordData) )
248 return false;
249
250 if ( this.getRecordId() > 0 &&
251 ((AssetRecordData)obj).getRecordId() > 0 &&
252 this.getRecordId() == ((AssetRecordData)obj).getRecordId() )
253 return true;
254
255 if ( ((AssetRecordData)obj).getServer() == null || this.getServer() == null )
256 return false;
257
258 if ( ((AssetRecordData)obj).getLocation() == null || this.getLocation() == null )
259 return false;
260
261 if ( ((AssetRecordData)obj).getFileName() == null || this.getFileName() == null )
262 return false;
263
264 if ( ((AssetRecordData)obj).getServer().equals( this.getServer() ) &&
265 ((AssetRecordData)obj).getLocation().equals( this.getLocation() ) &&
266 ((AssetRecordData)obj).getFileName().equals( this.getFileName() ) )
267 return true;
268
269 return false;
270 }
271
272 /**
273 * Returns the nArchiveStatus, the actual archive status of the asset in the database
274 * @return int
275 */
276 public int getArchiveStatus() {
277 return nArchiveStatus;
278 }
279
280 /**
281 * Sets the nArchiveStatus, the actual archive status of the asset in the database
282 * @param nArchiveStatus The nArchiveStatus to set
283 */
284 public void setArchiveStatus(int nArchiveStatus) {
285 this.nArchiveStatus = nArchiveStatus;
286 }
287
288 }