陈清红
2025-04-14 880f3c0257eeb8c37761d484258fdd102a369a19
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
Quintiq file version 2.0
#parent: #root
Method RemoveDeclarative (const Type type, NamedValueTree nvt, NamedValue nv)
{
  Description:
  [*
    Exporting a type to NamedValueTree also exports values that cannot be set: KPIs, Constraints and declarative attributes.
    This method will remove these attributes.
  *]
  TextBody:
  [*
    traverse( nv.Children(), Elements, child )
    {
      // Find if it is a relation node
      rel := constnull( MdlModeledRelSideElement );
      if( child.GetValue().istype( Key ) )
      {
        rel := select( LibOpt_Utility::GetTypeAncestors( type ), Elements.MdlRelSideElements.astype( MdlModeledRelSideElement ), r, r.Name() = child.Name() );
      }
      
      if( isnull( rel ) )
      {
        // This needs to be an attribute
        att := select( LibOpt_Utility::GetTypeAncestors( type ), Elements.MdlAttrElements.astype( MdlModeledAttrElement ), att, att.Name() = child.Name() );
        
        if( isnull( att ) or att.IsDerived() )
        {
          child.Delete( true );
        }
      }
      else
      {
        this.RemoveDeclarative( rel.OtherSide().Type(), nvt, child );
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}