Source:
protected void commitSubsection(final CitationCollectionOrder citationCollectionOrder) { List<CitationCollectionOrder> citationCollectionOrderList = getNestedCollectionAsList(citationCollectionOrder.getCollectionId()); int subSectionLocation = 1; final List<CitationCollectionOrder> citationCollectionOrderToSave = new ArrayList<CitationCollectionOrder>(); for (CitationCollectionOrder collectionOrder : citationCollectionOrderList) { if (citationCollectionOrder.getLocation() == subSectionLocation){ citationCollectionOrderToSave.add(citationCollectionOrder); } citationCollectionOrderToSave.add(collectionOrder); subSectionLocation++; } if (citationCollectionOrderToSave.size()==citationCollectionOrderList.size()){ citationCollectionOrderToSave.add(citationCollectionOrder); } m_sqlService.transact(new Runnable() { public void run() { String statement = "delete from " + m_collectionOrderTableName + " where COLLECTION_ID = ? and SECTION_TYPE is not null"; Object fields[] = new Object[1]; fields[0] = citationCollectionOrder.getCollectionId(); m_sqlService.dbWrite(statement, fields); int location = 1; for (CitationCollectionOrder citationCollectionOrder1 : citationCollectionOrderToSave) { String orderStatement = "insert into " + m_collectionOrderTableName + " (COLLECTION_ID, CITATION_ID, LOCATION, SECTION_TYPE, VALUE) VALUES(?,?,?,?,?)"; Object[] orderFields = new Object[5]; orderFields [0] = citationCollectionOrder1.getCollectionId(); orderFields [1] = citationCollectionOrder1.getCitationid(); orderFields [2] = location; orderFields [3] = citationCollectionOrder1.getSectiontype(); orderFields [4] = citationCollectionOrder1.getValue(); m_sqlService.dbWrite(orderStatement, orderFields); location++; } } }, "commitSubsection: " + citationCollectionOrder.getCollectionId()); updateCitationCollectionUpdateDate(citationCollectionOrder.getCollectionId()); }

Target:
protected void commitSubsection(final CitationCollectionOrder citationCollectionOrder) { List<CitationCollectionOrder> citationCollectionOrderList = getNestedCollectionAsList(citationCollectionOrder.getCollectionId()); int subSectionLocation = 1; final List<CitationCollectionOrder> citationCollectionOrderToSave = new ArrayList<CitationCollectionOrder>(); for (CitationCollectionOrder collectionOrder : citationCollectionOrderList) { if (citationCollectionOrder.getLocation() == subSectionLocation){ citationCollectionOrderToSave.add(citationCollectionOrder); } citationCollectionOrderToSave.add(collectionOrder); subSectionLocation++; } if (citationCollectionOrderToSave.size()==citationCollectionOrderList.size()){ citationCollectionOrderToSave.add(citationCollectionOrder); } m_sqlService.transact(new Runnable() { public void run() { String statement = "delete from " + m_collectionOrderTableName + " where COLLECTION_ID = ? and SECTION_TYPE is not null"; Object fields[] = new Object[1]; fields[0] = citationCollectionOrder.getCollectionId(); m_sqlService.dbWrite(statement, fields); int location = 1; for (CitationCollectionOrder citationCollectionOrder1 : citationCollectionOrderToSave) { String orderStatement = "insert into " + m_collectionOrderTableName + " (COLLECTION_ID, CITATION_ID, LOCATION, SECTION_TYPE, VALUE) VALUES(?,?,?,?,?)"; Object[] orderFields = new Object[5]; orderFields [0] = citationCollectionOrder1.getCollectionId(); orderFields [1] = citationCollectionOrder1.getCitationid(); orderFields [2] = location; orderFields [3] = citationCollectionOrder1.getSectiontype(); orderFields [4] = citationCollectionOrder1.getValue(); m_sqlService.dbWrite(orderStatement, orderFields); location++; } updateCitationCollectionUpdateDate(citationCollectionOrder.getCollectionId()); } }, "commitSubsection: " + citationCollectionOrder.getCollectionId()); }