From: <hs...@us...> - 2011-04-14 21:10:00
|
Revision: 784 http://treebase.svn.sourceforge.net/treebase/?rev=784&view=rev Author: hshyket Date: 2011-04-14 21:09:54 +0000 (Thu, 14 Apr 2011) Log Message: ----------- Setting limit for the number of trees allowed in a block. This is set in the treebase.properties file. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/service/study/SubmissionServiceImpl.java trunk/treebase-core/src/main/resources/applicationContext-service.xml trunk/treebase-core/src/main/resources/treebase.properties Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/service/study/SubmissionServiceImpl.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/service/study/SubmissionServiceImpl.java 2011-04-12 20:16:48 UTC (rev 783) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/service/study/SubmissionServiceImpl.java 2011-04-14 21:09:54 UTC (rev 784) @@ -7,7 +7,10 @@ import java.util.Collection; import java.util.Date; import java.util.HashSet; +import java.util.Iterator; +import java.util.List; + import org.apache.log4j.Logger; import org.cipres.treebase.dao.jdbc.MatrixJDBC; import org.cipres.treebase.dao.jdbc.NexusDataSetJDBC; @@ -65,6 +68,8 @@ private CitationService mCitationService; private StudyService mStudyService; private NexusService mNexusService; + + private int mMaxTreeCount; /** * Constructor. @@ -297,8 +302,25 @@ return sub; } + + /** + * Return the MaxTreeCount field. + * + * @return MatrixDataTypeHome mMatrixDataTypeHome + */ + private int getMaxTreeCount() { + return mMaxTreeCount; + } /** + * Set the MaxTreeCount field. + */ + public void setMaxTreeCount(int maxTreeCount) { + mMaxTreeCount = maxTreeCount; + } + + + /** * * @see org.cipres.treebase.domain.study.SubmissionService#createSubmission(org.cipres.treebase.domain.admin.User, * org.cipres.treebase.domain.study.Study) @@ -680,8 +702,30 @@ // alltrees.addAll(block.getTreeList()); // } // getPhyloTreeHome().storeAll(alltrees); + + + //If there are more than the number of trees in getMaxTreeCount trees in a TreeBlock we need to remove them + for (TreeBlock treeblock : data.getTreeBlocks()) { + if (treeblock.getTreeCount() > getMaxTreeCount()) { + Iterator tree = treeblock.getTreeListIterator(); + int treecount = 1; + + while(tree.hasNext()) { + if (treecount > getMaxTreeCount()) { + tree.remove(); + } + tree.next(); + treecount++; + } + } + } + getPhyloTreeHome().storeAll(data.getTreeBlocks()); sub.addPhyloTreeBlocks(data.getTreeBlocks()); + + + + getPhyloTreeHome().flush(); update(sub); Modified: trunk/treebase-core/src/main/resources/applicationContext-service.xml =================================================================== --- trunk/treebase-core/src/main/resources/applicationContext-service.xml 2011-04-12 20:16:48 UTC (rev 783) +++ trunk/treebase-core/src/main/resources/applicationContext-service.xml 2011-04-14 21:09:54 UTC (rev 784) @@ -243,6 +243,7 @@ <property name="taxonHome" ref="taxonHome"/> <property name="taxonLabelHome" ref="taxonLabelHome"/> <property name="userHome" ref="userHome"/> + <property name="maxTreeCount" value="${treeblock.trees.max_count}"/> </bean> </property> </bean> Modified: trunk/treebase-core/src/main/resources/treebase.properties =================================================================== --- trunk/treebase-core/src/main/resources/treebase.properties 2011-04-12 20:16:48 UTC (rev 783) +++ trunk/treebase-core/src/main/resources/treebase.properties 2011-04-14 21:09:54 UTC (rev 784) @@ -1,6 +1,9 @@ #options are: NexusServiceMesquite | NexusServiceNCL nexus.parser.impl=NexusServiceMesquite +#The number of trees allowed in a treeblock +treeblock.trees.max_count=30 + ######################################################################## ### Prior to 2010-04-29, these were in jdbc.properties, ### which now contains only properties not used by the web app @@ -18,6 +21,8 @@ hibernate.format_sql=true hibernate.generate_statistics=false + + # options are: validate | update | create | create-drop hibernate.hbm2ddl.auto= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |