/* Copyright (c) 2009 The Regents of the University of California. All rights reserved. Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that the above copyright notice and the following two paragraphs appear in all copies of this software. IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.. */ package org.clothocad.hibernate.data; // Generated Jun 1, 2010 8:47:54 PM by Hibernate Tools 3.2.1.GA import java.io.File; import java.util.Date; import java.util.HashSet; import java.util.Set; import org.clothocore.api.data.Attachment; import org.clothocore.api.data.Attachment.AttachmentDatum; import org.clothocore.api.data.Attachment.AttachmentType; import org.clothocore.api.data.ObjBase; import org.clothocore.api.data.ObjBase.ObjBaseDatum; import org.clothocore.api.data.ObjType; import org.clothocad.hibernate.hibernateDatum; /** * AttachmentTable generated by hbm2java */ public class AttachmentTable implements java.io.Serializable, hibernateDatum { public static ObjType getType( Enum field ) { if ( field.getDeclaringClass() != Attachment.Fields.class ) { return null; } Attachment.Fields f = (Attachment.Fields) field; switch ( f ) { case WIKITEXT: return ObjType.WIKITEXT; default: return null; } } public AttachmentTable( Attachment a ) { this.idAttachment = a.getUUID(); this.fileName = a.getName(); this.attachmentType = a.getAttachmentTypeAsString(); this.dateCreated = a.getDateCreated(); this.lastModified = a.getLastModified(); if ( a.getWiki() != null ) { this.wikitextTable = new WikitextTable( a.getWiki().getUUID() ); } this.fileBlob = a.getBytes(); } @Override public void runSecondaryProcessing(ObjBase obj) { } @Override public boolean needsSecondaryProcessing() { return false; } @Override public ObjBase getObject() { Attachment.AttachmentDatum d = (AttachmentDatum) getObjBaseDatum(); Attachment att = new Attachment( d ); Attachment.convertToFile(d._myFile, this.fileBlob); return att; } @Override public ObjBaseDatum getObjBaseDatum() { Attachment.AttachmentDatum d = new Attachment.AttachmentDatum(); d.uuid = idAttachment; d.name = fileName; d.dateCreated = dateCreated; d.lastModified = lastModified; if(wikitextTable!=null) { d._wikiUUID = wikitextTable.getIdWikitext(); } try { d._attType = AttachmentType.valueOf(this.attachmentType); } catch(Exception e) { e.printStackTrace(); } d._myFile = new File(Attachment.cacheDir.getAbsolutePath() + "/" + fileName); return d; } public static String translate( Enum field ) { if ( field.getDeclaringClass() != Attachment.Fields.class ) { return null; } Attachment.Fields f = (Attachment.Fields) field; switch ( f ) { case NAME: return "fileName"; case DATE_CREATED: return "dateCreated"; case LAST_MODIFIED: return "lastModified"; case ATTACHMENT_TYPE: return "attachmentType"; case FILE: return "fileBlob"; case WIKITEXT: return "wikitextTable"; default: return null; } } @Override public String getName() { return fileName; } @Override public String getUUID() { return idAttachment; } /***** AUTO-GENERATED CODE *****/ private String idAttachment; private WikitextTable wikitextTable; private String fileName; private String attachmentType; private byte[] fileBlob; private Date dateCreated; private Date lastModified; private Set plateTypeTables = new HashSet( 0 ); private Set strainTables = new HashSet( 0 ); private Set sampleDataTables = new HashSet( 0 ); public AttachmentTable() { } public AttachmentTable( String idAttachment ) { this.idAttachment = idAttachment; } public AttachmentTable( String idAttachment, WikitextTable wikitextTable, String fileName, String attachmentType, byte[] fileBlob, Date dateCreated, Date lastModified, Set plateTypeTables, Set strainTables, Set sampleDataTables ) { this.idAttachment = idAttachment; this.wikitextTable = wikitextTable; this.fileName = fileName; this.attachmentType = attachmentType; this.fileBlob = fileBlob; this.dateCreated = dateCreated; this.lastModified = lastModified; this.plateTypeTables = plateTypeTables; this.strainTables = strainTables; this.sampleDataTables = sampleDataTables; } public String getIdAttachment() { return this.idAttachment; } public void setIdAttachment( String idAttachment ) { this.idAttachment = idAttachment; } public WikitextTable getWikitextTable() { return this.wikitextTable; } public void setWikitextTable( WikitextTable wikitextTable ) { this.wikitextTable = wikitextTable; } public String getFileName() { return this.fileName; } public void setFileName( String fileName ) { this.fileName = fileName; } public String getAttachmentType() { return this.attachmentType; } public void setAttachmentType( String attachmentType ) { this.attachmentType = attachmentType; } public byte[] getFileBlob() { return this.fileBlob; } public void setFileBlob( byte[] fileBlob ) { this.fileBlob = fileBlob; } public Date getDateCreated() { return this.dateCreated; } public void setDateCreated( Date dateCreated ) { this.dateCreated = dateCreated; } public Date getLastModified() { return this.lastModified; } public void setLastModified( Date lastModified ) { this.lastModified = lastModified; } public Set getPlateTypeTables() { return this.plateTypeTables; } public void setPlateTypeTables( Set plateTypeTables ) { this.plateTypeTables = plateTypeTables; } public Set getStrainTables() { return this.strainTables; } public void setStrainTables( Set strainTables ) { this.strainTables = strainTables; } public Set getSampleDataTables() { return this.sampleDataTables; } public void setSampleDataTables( Set sampleDataTables ) { this.sampleDataTables = sampleDataTables; } }