yanyuan
2023-11-10 143ef74e2eeee697ac8fda3d9032a790fbb4e146
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
Quintiq file version 2.0
#parent: #root
StaticMethod CanCreate (
  String name,
  ScenarioManager owner,
  Bookmark bookmark,
  String parentname,
  Boolean isFolder,
  output String feedback_o
) declarative remote as Boolean
{
  TextBody:
  [*
    // Precondition to validate if a bookmark can be created
    feedback_o := '';
    
    maxnamelength := GlobalParameters_MP::GetLengthOfNames();
    
    // Check if a name is being provided or whether the length of the name is within the allowed range
    if( name = '' or name.Length() > maxnamelength )
    {
      feedback_o := Translations::ScenarioManager_Bookmark_ValidateInput_IsInvalidName( maxnamelength );
    }
    // Check if the provided name is unique
    else if( exists( owner, Bookmark, b, true , b.Name() = name and guard ( b <> bookmark, true ) ) )
    {
      feedback_o := Translations::ScenarioManager_Bookmark_ValidateInput_IsIDExists();
    }
    //Check if the new name is different from the parent name; this applies to both folders and bookmarks
    else if( parentname = name )
    {
      feedback_o := Translations::ScenarioManager_Bookmark_FolderAndBookmarkNameShouldBeDifferent(); 
    }
    // Check if bookmark folder is being created
    else if( not isFolder  )
    {
      // Check if the length of bookmark folder's name is within the allowed range
       if ( parentname.Length() > maxnamelength )
      {
        feedback_o := Translations::ScenarioManager_Bookmark_ValidateInput_IsInvalidName( maxnamelength );
      }  
    }
    
    return feedback_o = '';
  *]
}