Lien indirect entre 2 objets métier

Suite à notre entretien téléphonique, voici la correction “au plus propre” (vs le “plus pédagogique” que nous avons réalisé ensemble)

package com.simplicite.objects.SECCo;

import java.util.*;

import com.simplicite.util.*;
import com.simplicite.util.exceptions.*;
import com.simplicite.util.tools.*;

/**
 * Business object SeccoEntree
 */
public class SeccoEntree extends ObjectDB {
	private static final long serialVersionUID = 1L;
	
	@Override
	public String postUpdate() {
		// pour chacune des SeccoEntreeProd de ce SeccoEntree (rechercher au préalable)
			// charger le SeccoStockReferent correspondant à 1) l'entrepot de l'entrée, 2) au produit 
			// augmenter la quantité d'autant qu'indiqué dans SeccoEntreeProd
			// sauvegarder
		
		if(this.getOldStatus().equals("EN_COURS") && this.getStatus().equals("VALIDEE")){
			ObjectDB entreePrd = getGrant().getTmpObject("SeccoEntreeProd");
			ObjectDB stockRef = getGrant().getTmpObject("SeccoStockReferent");
			
			synchronized(entreePrd.getLock()){
				for(String[] row : entreePrd.getTool().search(Map.of("seccoEntreeprodEntreeId", getRowId()))){
					entreePrd.setValues(row);
					synchronized(stockRef.getLock()){
						try{
							stockRef.getTool().get(Map.of(
								"seccoStockrefEntrefId", this.getFieldValue("seccoEntreeEntrefId"),
								"seccoStockrefProdId", entreePrd.getFieldValue("seccoEntreeprodProdId")
							));
							stockRef.setFieldValue("seccoStockRefQuantite", 
								stockRef.getField("seccoStockRefQuantite").getInt(0)
								+
								entreePrd.getField("seccoEntreeprodQuantite").getInt(0)
							);
							stockRef.getTool().validateAndSave();
						}
						catch(Exception e){
							AppLog.error("error updating stock", e, getGrant());
						}
					}
				}
			}
		}
		return null;
	}
}