Iterator iterator = qualifyers.iterator();
int i = 0;
while(iterator.hasNext())
{
QualifyerVO qualifyer = (QualifyerVO)iterator.next();
logger.info("Found qualifyer " + qualifyer.getValue() + ":" + qualifyer.getSortOrder());
if(qualifyer.getSortOrder().equals(oldSortOrder) && direction.intValue() == 0) //down
{
logger.info("About to move it down...");
if(iterator.hasNext())
{
QualifyerVO nextQualifyer = (QualifyerVO)iterator.next();
logger.info("nextQualifyer " + nextQualifyer.getValue() + ":" + nextQualifyer.getSortOrder());
nextQualifyer.setSortOrder(qualifyer.getSortOrder());
logger.info("Set the nextQualifyer sortOrder to " + qualifyer.getSortOrder());
qualifyer.setSortOrder(new Integer(qualifyer.getSortOrder().intValue() + 1));
logger.info("Set the qualifyer sortOrder to " + qualifyer.getSortOrder());
newQualifyers.add(nextQualifyer);
newQualifyers.add(qualifyer);
}
else
newQualifyers.add(qualifyer);
}
else if(qualifyer.getSortOrder().equals(oldSortOrder) && direction.intValue() == 1) //up
{
logger.info("About to move it up...");
if(i > 0)
{
QualifyerVO previousQualifyer = (QualifyerVO)newQualifyers.get(i-1);
logger.info("Previous qualifyer " + previousQualifyer.getValue() + ":" + previousQualifyer.getSortOrder());
previousQualifyer.setSortOrder(qualifyer.getSortOrder());
logger.info("Set the previous qualifyer sortOrder to " + qualifyer.getSortOrder());
qualifyer.setSortOrder(new Integer(qualifyer.getSortOrder().intValue() - 1));
logger.info("Set the qualifyer sortOrder to " + qualifyer.getSortOrder());
newQualifyers.remove(qualifyer);
newQualifyers.add(i-1, qualifyer);