* This method returns the latest sitenodeVersion there is for the given siteNode.
*/
public SiteNodeVersion getLatestActiveSiteNodeVersionIfInState(SiteNode siteNode, Integer stateId, Database db) throws SystemException, Exception
{
SiteNodeVersion siteNodeVersion = null;
Collection siteNodeVersions = siteNode.getSiteNodeVersions();
SiteNodeVersion latestSiteNodeVersion = null;
Iterator versionIterator = siteNodeVersions.iterator();
while(versionIterator.hasNext())
{
SiteNodeVersion siteNodeVersionCandidate = (SiteNodeVersion)versionIterator.next();
if(latestSiteNodeVersion == null || (latestSiteNodeVersion.getId().intValue() < siteNodeVersionCandidate.getId().intValue() && siteNodeVersionCandidate.getIsActive().booleanValue()))
latestSiteNodeVersion = siteNodeVersionCandidate;
if(siteNodeVersionCandidate.getIsActive().booleanValue() && siteNodeVersionCandidate.getStateId().intValue() == stateId.intValue())
{
if(siteNodeVersionCandidate.getOwningSiteNode().getSiteNodeId().intValue() == siteNode.getId().intValue())
{
if(siteNodeVersion == null || siteNodeVersion.getSiteNodeVersionId().intValue() < siteNodeVersionCandidate.getId().intValue())
{
siteNodeVersion = siteNodeVersionCandidate;
}
}
}