public void mergeWithProposedItems ( final List < InvoiceItem > proposedItems ) { build ( ) ; for ( SubscriptionItemTree tree : subscriptionItemTree . values ( ) ) { tree . flatten ( true ) ; } for ( InvoiceItem item : proposedItems ) { final UUID subscriptionId = getSubscriptionId ( item , null ) ; SubscriptionItemTree tree = subscriptionItemTree . get ( subscriptionId ) ; if ( tree == null ) { tree = new SubscriptionItemTree ( subscriptionId , targetInvoiceId ) ; subscriptionItemTree . put ( subscriptionId , tree ) ; } tree . mergeProposedItem ( item ) ; } for ( SubscriptionItemTree tree : subscriptionItemTree . values ( ) ) { tree . buildForMerge ( ) ; } }
Rebuild the new tree by merging current on - disk existing view with new proposed list .