/* 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.util.Date; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import org.clothocore.api.data.Factoid; import org.clothocore.api.data.Factoid.FactoidDatum; import org.clothocore.api.data.ObjBase; import org.clothocore.api.data.ObjBase.ObjBaseDatum; import org.clothocore.api.data.ObjType; import org.clothocore.api.data.Reference; import org.clothocad.hibernate.hibernateDatum; /** * FactoidTable generated by hbm2java */ public class FactoidTable implements java.io.Serializable, hibernateDatum { public static ObjType getType( Enum field ) { if ( field.getDeclaringClass() != Factoid.Fields.class ) { return null; } Factoid.Fields f = (Factoid.Fields) field; switch ( f ) { case AUTHOR: return ObjType.PERSON; case WIKITEXT: return ObjType.WIKITEXT; case NOTES: return ObjType.NOTE; default: return null; } } public FactoidTable( Factoid f ) { this.idFactoid = f.getUUID(); this.name = f.getName(); this.dateCreated = f.getDateCreated(); this.lastModified = f.getLastModified(); if ( f.getReference() != null ) { this.reference = f.getReference().getID(); } String wikiID = f.getWikiText().getUUID(); if ( wikiID != null ) { this.wikitextTable = new WikitextTable( wikiID ); } if ( f.getAuthor() != null ) { this.personTable = new PersonTable( f.getAuthor().getUUID() ); } } @Override public void runSecondaryProcessing(ObjBase obj) { } @Override public boolean needsSecondaryProcessing() { return false; } @Override public ObjBase getObject() { FactoidDatum d = (FactoidDatum) getObjBaseDatum(); Factoid f = new Factoid(d); return f; } @Override public ObjBaseDatum getObjBaseDatum() { String authorUUID = null; if ( personTable != null ) { authorUUID = personTable.getUUID(); } //find all the Factoid links HashSet<String> notelist = new HashSet<String>(); Iterator<hibernateDatum> objs = this.noteFactoidXrefs.iterator(); while ( objs.hasNext() ) { NoteFactoidXref cx = (NoteFactoidXref) objs.next(); String uuid = cx.getId().getNoteId(); notelist.add( uuid ); } Factoid.FactoidDatum d = new Factoid.FactoidDatum(); d.uuid = idFactoid; d.name = name; d.dateCreated = dateCreated; d.lastModified = lastModified; d._reference = Reference.generate(this.reference); d._wikiUUID = wikitextTable.getIdWikitext(); d._authorUUID = authorUUID; d._noteLinks = notelist; return d; } @Override public String getUUID() { return idFactoid; } public static String translate( Enum field ) { if ( field.getDeclaringClass() != Factoid.Fields.class ) { return null; } Factoid.Fields f = (Factoid.Fields) field; switch ( f ) { case NAME: return "name"; case DATE_CREATED: return "dateCreated"; case LAST_MODIFIED: return "lastModified"; case REFERENCE: return "reference"; case AUTHOR: return "personTable"; case WIKITEXT: return "wikitextTable"; case NOTES: return "noteFactoidXrefs"; default: return null; } } /***** AUTO-GENERATED CODE *****/ private String idFactoid; private PersonTable personTable; private WikitextTable wikitextTable; private String name; private String reference; private Date dateCreated; private Date lastModified; private Set noteFactoidXrefs = new HashSet( 0 ); public FactoidTable() { } public FactoidTable( String idFactoid ) { this.idFactoid = idFactoid; } public FactoidTable( String idFactoid, PersonTable personTable, WikitextTable wikitextTable, String name, String reference, Date dateCreated, Date lastModified, Set noteFactoidXrefs ) { this.idFactoid = idFactoid; this.personTable = personTable; this.wikitextTable = wikitextTable; this.name = name; this.reference = reference; this.dateCreated = dateCreated; this.lastModified = lastModified; this.noteFactoidXrefs = noteFactoidXrefs; } public String getIdFactoid() { return this.idFactoid; } public void setIdFactoid( String idFactoid ) { this.idFactoid = idFactoid; } public PersonTable getPersonTable() { return this.personTable; } public void setPersonTable( PersonTable personTable ) { this.personTable = personTable; } public WikitextTable getWikitextTable() { return this.wikitextTable; } public void setWikitextTable( WikitextTable wikitextTable ) { this.wikitextTable = wikitextTable; } public String getName() { return this.name; } public void setName( String name ) { this.name = name; } public String getReference() { return this.reference; } public void setReference( String reference ) { this.reference = reference; } 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 getNoteFactoidXrefs() { return this.noteFactoidXrefs; } public void setNoteFactoidXrefs( Set noteFactoidXrefs ) { this.noteFactoidXrefs = noteFactoidXrefs; } }