yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
StaticMethod Delete (
  LibCal_ExplicitTimeIntervals timeIntervals_i,
  Boolean deleteOfParticipationAllowed_i
)
{
  TextBody:
  [*
    if( timeIntervals_i.Size() > 0 )
    {
      // The intervals always belong to the same participation.
      participation := timeIntervals_i.Element( 0 ).Participation();
    
      traverse( timeIntervals_i, Elements, timeInterval )
      {
        // If the TimeInterval belongs to the initiator of the Event, then the TimeInterval
        // must be deleted for all subscribers to the Event.
        if( participation.IsLeading() )
        {
          traverse( timeInterval, SubscribingETI, subscribingETI )
          {
            subscribingETI.Delete();
          }
        }
    
        timeInterval.Delete();
      }
    
      // If deletion of the Participation is allowed, i.e. when the action is triggered by the user,
      // then delete the Participations that have no TimeIntervals left.
      // Delete _the_ Participation as last.
      if( deleteOfParticipationAllowed_i )
      {
        traverse( participation.Event(), Participation, part, 
                      part <> participation
                  and not part.IsChanged()
                  and not part.HasChangedRecurrencePeriod()
                  and part.ExplicitTimeInterval( relsize ) = 0 )
        {
          part.Delete();
        }
        
        // Delete _the_ Participation as last, because this might trigger the deletion of the whole Event
        // if it is the last Participation of the Event.
        if( participation.ExplicitTimeInterval( relsize ) = 0 )
        {
          participation.Delete();
        }
      }    
    }
  *]
}