1 40 package org.dspace.administer; 41 42 import java.io.IOException ; 43 import java.sql.SQLException ; 44 45 import org.apache.log4j.Logger; 46 import org.dspace.authorize.AuthorizeException; 47 import org.dspace.content.MetadataField; 48 import org.dspace.content.MetadataSchema; 49 import org.dspace.content.NonUniqueMetadataException; 50 import org.dspace.core.Context; 51 52 68 public class DCType 69 { 70 71 private static Logger log = Logger.getLogger(DCType.class); 72 73 74 private Context ourContext; 75 76 77 private MetadataField field = new MetadataField(); 78 79 86 public DCType(Context context, MetadataField field) 87 { 88 this.ourContext = context; 89 this.field = field; 90 } 91 92 98 public DCType(Context context) 99 { 100 this.ourContext = context; 101 } 102 103 115 public static String [] quickFind(Context context, int id) 116 throws SQLException 117 { 118 MetadataField field = MetadataField.find(context, id); 119 120 String [] result = new String [2]; 121 122 if (field == null) 123 { 124 return result; 125 } 126 else 127 { 128 result[0] = field.getElement(); 129 result[1] = field.getQualifier(); 130 return result; 131 } 132 } 133 134 145 public static DCType find(Context context, int id) throws SQLException 146 { 147 MetadataField field = MetadataField.find(context, id); 148 return new DCType(context, field); 149 } 150 151 168 public static DCType findByElement(Context context, String element, 169 String qualifier) throws SQLException , AuthorizeException 170 { 171 MetadataField field = MetadataField.findByElement(context, 172 MetadataSchema.DC_SCHEMA_ID, element, qualifier); 173 174 if (field == null) 175 { 176 return null; 177 } 178 else 179 { 180 return new DCType(context, field); 181 } 182 } 183 184 190 public static DCType[] findAll(Context context) throws SQLException 191 { 192 193 MetadataField field[] = MetadataField.findAll(context); 194 DCType[] typeArray = new DCType[field.length]; 195 196 for (int ii = 0; ii < field.length; ii++) 197 { 198 typeArray[ii] = new DCType(context, field[ii]); 199 } 200 201 return typeArray; 203 } 204 205 215 public static DCType create(Context context) throws SQLException , 216 AuthorizeException, IOException , NonUniqueMetadataException 217 { 218 MetadataField field = new MetadataField(); 219 field.setSchemaID(MetadataSchema.DC_SCHEMA_ID); 220 field.create(context); 221 return new DCType(context, field); 222 } 223 224 231 public void delete() throws SQLException , AuthorizeException 232 { 233 field.delete(ourContext); 234 } 235 236 241 public int getID() 242 { 243 return field.getFieldID(); 244 } 245 246 251 public String getElement() 252 { 253 return field.getElement(); 254 } 255 256 262 public void setElement(String s) 263 { 264 field.setElement(s); 265 } 266 267 273 public String getQualifier() 274 { 275 return field.getQualifier(); 276 } 277 278 285 public void setQualifier(String s) 286 { 287 field.setQualifier(s); 288 } 289 290 295 public String getScopeNote() 296 { 297 return field.getScopeNote(); 298 } 299 300 306 public void setScopeNote(String s) 307 { 308 field.setScopeNote(s); 309 } 310 311 318 public void update() throws SQLException , AuthorizeException, 319 NonUniqueMetadataException, IOException 320 { 321 field.update(ourContext); 322 } 323 } 324 | Popular Tags |