lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Quintiq file version 2.0
#parent: #root
Method SetBookmarkElement (
  const Units units,
  const StockingPoint_MPs stocking_points,
  const Product_MPs products,
  const SalesSegment_MPs sales_segments,
  const structured_Object periodObjects
)
{
  TextBody:
  [*
    // Set the elements to be bookmarked in a Bookmark
    oldBookmarks := selectset( this, AllBookmarkElement, e, true );
    newBookmarks := construct( BookmarkElementBases );
    
    // Find/Create bookmark elements according to the units passed in and assign it to newBookmarks
    traverse( units, Elements, e )
    {
      newBookmarks.Add( BookmarkUnitElement::FindCreate( this, e ) );
    }
    
    // Find/Create bookmark elements according to the stocking points passed in and assign it to newBookmarks
    traverse( stocking_points, Elements, e )
    {
      newBookmarks.Add( BookmarkStockingPointElement::FindCreate( this, e ) );
    }
    
    // Find/Create bookmark elements according to the products passed in and assign it to newBookmarks
    traverse( products, Elements, e )
    {
      newBookmarks.Add( BookmarkProductElement::FindCreate( this, e ) );
    }
    
    // Find/Create bookmark elements according to the sales segment passed in and assign it to newBookmarks
    traverse( sales_segments, Elements, e )
    {
      newBookmarks.Add( BookmarkSalesSegmentElement::FindCreate( this, e ) );
    }
    
    // Find/Create bookmark elements according to the periodObjects consist of PeriodSpecification passed in and assign it to newBookmarks
    traverse( periodObjects, Elements.astype( PeriodSpecification_MP ), e )
    {
      newBookmarks.Add( BookmarkPeriodSpecificationElement::FindCreate( this, e ) );
    }
    
    // Find/Create bookmark elements according to the periodObjects consist of PeriodSpecificationPeriod passed in and assign it to newBookmarks
    traverse( periodObjects, Elements.astype( PeriodSpecificationPeriod ), e )
    {
      newBookmarks.Add( BookmarkPeriodSpecificationPeriodElement::FindCreate( this, e ) );
    }
    
    // Get old bookmark elements that is not in the updated set of bookmark elements
    oldBookmarks := oldBookmarks.Difference( newBookmarks );
    
    // Delete all old bookmark elements
    BookmarkElementBase::Delete( oldBookmarks );
  *]
}