beginTransaction(db);
try
{
RepositoryLanguage originalRepositoryLanguage = this.getRepositoryLanguageWithId(repositoryLanguageVO.getRepositoryLanguageId(), db);
List repositoryLanguages = this.getRepositoryLanguageListWithRepositoryId(originalRepositoryLanguage.getRepository().getId(), db);
for(int i=0; i<repositoryLanguages.size(); i++)
{
RepositoryLanguage repositoryLanguage = (RepositoryLanguage)repositoryLanguages.get(i);
if(repositoryLanguage.getRepositoryLanguageId().intValue() == repositoryLanguageVO.getRepositoryLanguageId().intValue())
{
if(down && i != repositoryLanguages.size() - 1)
{
RepositoryLanguage nextRepositoryLanguage = (RepositoryLanguage)repositoryLanguages.get(i+1);
Integer currentSortOrder = repositoryLanguage.getSortOrder();
repositoryLanguage.setSortOrder(nextRepositoryLanguage.getSortOrder());
nextRepositoryLanguage.setSortOrder(currentSortOrder);
}
else if(!down && i != 0)
{
RepositoryLanguage previousRepositoryLanguage = (RepositoryLanguage)repositoryLanguages.get(i-1);
Integer currentSortOrder = repositoryLanguage.getSortOrder();
repositoryLanguage.setSortOrder(previousRepositoryLanguage.getSortOrder());
previousRepositoryLanguage.setSortOrder(currentSortOrder);
}
}
}
commitTransaction(db);