From: <rv...@us...> - 2010-03-16 17:00:56
|
Revision: 609 http://treebase.svn.sourceforge.net/treebase/?rev=609&view=rev Author: rvos Date: 2010-03-16 17:00:50 +0000 (Tue, 16 Mar 2010) Log Message: ----------- Implemented getContext, which returns the containing study. Wrapped annotation generation inside a try {} block (I was getting some lazy initialization exceptions), changed the fetch mode to join, to prevent lazy initialization exceptions. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/PhyloTree.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/PhyloTree.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/PhyloTree.java 2010-03-16 16:58:15 UTC (rev 608) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/tree/PhyloTree.java 2010-03-16 17:00:50 UTC (rev 609) @@ -37,6 +37,8 @@ import org.hibernate.annotations.BatchSize; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; +import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.NamedNativeQuery; /** @@ -284,6 +286,7 @@ */ @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY) @JoinColumn(name = "TREEQUALITY_ID") + @Fetch(FetchMode.JOIN) public TreeQuality getTreeQuality() { return mTreeQuality; } @@ -320,6 +323,7 @@ */ @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "TREEKIND_ID") + @Fetch(FetchMode.JOIN) public TreeKind getTreeKind() { return mTreeKind; } @@ -338,6 +342,7 @@ */ @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY) @JoinColumn(name = "TREETYPE_ID") + @Fetch(FetchMode.JOIN) public TreeType getTreeType() { return mTreeType; } @@ -786,22 +791,29 @@ @Transient public List<Annotation> getAnnotations() { List<Annotation> annotations = super.getAnnotations(); - if ( null != getId() ) { - annotations.add(new Annotation(Constants.TBTermsURI, "tb:identifier.tree", getId())); + try { + if ( null != getKindDescription() ) { + annotations.add(new Annotation(Constants.TBTermsURI, "tb:kind.tree", getKindDescription())); + } + if ( null != getTypeDescription() ) { + annotations.add(new Annotation(Constants.TBTermsURI, "tb:type.tree", getTypeDescription())); + } + if ( null != getQualityDescription() ) { + annotations.add(new Annotation(Constants.TBTermsURI, "tb:quality.tree", getQualityDescription())); + } + if ( null != getnTax() ) { + annotations.add(new Annotation(Constants.TBTermsURI, "tb:ntax.tree", getnTax())); + } + } catch ( Exception e ) { + e.printStackTrace(); } - if ( null != getKindDescription() ) { - annotations.add(new Annotation(Constants.TBTermsURI, "tb:kind.tree", getKindDescription())); - } - if ( null != getTypeDescription() ) { - annotations.add(new Annotation(Constants.TBTermsURI, "tb:type.tree", getTypeDescription())); - } - if ( null != getQualityDescription() ) { - annotations.add(new Annotation(Constants.TBTermsURI, "tb:quality.tree", getQualityDescription())); - } - if ( null != getnTax() ) { - annotations.add(new Annotation(Constants.TBTermsURI, "tb:ntax.tree", getnTax())); - } return annotations; } + + @Override + @Transient + public Study getContext() { + return getStudy(); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |