# -----------------------------------
# schema: test class
# -----------------------------------

# builtin
# app, site, sitegroup, customer
# sirene_category, sirene_template, sirene_public

# schema
# test1 : all field types
# test2 : > test1 
# test3 : > test2 > test1
# test4 : > test3 > test2 > test1

# dataviews 
# test1_default
# test1_welcome
# test1_default
# test1_enumerate
# test1_enumerate_inject
# test4_external

# pipelines
# test1_pipeline
# test1_pipeline_regexp
# test1_pipeline_keep
# test1_pipeline_timestamp
# test1_pipeline_uuid


# -----------------------------------
# pipeline
# -----------------------------------

- classname: _pipeline
  keyname: test1_pipeline
  displayname: test_pipeline
  description: unittest pipeline
  content: |
      csv_delimiter: '|'
      classname: test1
      keyfield: keyname
      tasks: 
        - field_noop: ['']

- classname: _pipeline
  keyname: test1_pipeline_regexp
  displayname: test1_pipeline REGEXP
  description: Apply a REGEXP on mystring field
  content: |
      csv_delimiter: '|'
      classname: test1
      keyfield: keyname
      tasks: 
        - field_regexp_sub: ["", "mystring", "test", "TESTREGEXP-"]


- classname: _pipeline
  keyname: test1_pipeline_keep
  displayname: test1_pipeline Keep
  description: Keep some fields
  content: |
      csv_delimiter: '|'
      classname: test1
      keyfield: keyname
      tasks: 
        - field_keep: ["", "mystring", "myint"]

- classname: _pipeline
  keyname: test1_pipeline_timestamp
  displayname: test1_pipeline Timestamp 
  is_enabled: true
  description: Add timestamp
  content: |
      csv_delimiter: '|'
      classname: test1
      keyfield: keyname
      tasks: 
        - field_date_now: ["", date_auto_pipeline]
        - field_time_now: ["", time_auto_pipeline]
        - field_datetime_now: ["", datetime_auto_pipeline]


- classname: _pipeline
  keyname: test1_pipeline_uuid
  displayname: test1_pipeline UUID
  is_enabled: true
  description: Add a UUID field
  content: |
      csv_delimiter: '|'
      classname: test1
      keyfield: keyname
      tasks: 
        - field_uuid: ["", uuid_auto]

- classname: _pipeline
  keyname: test1_pipeline_utf8
  displayname: test1_pipeline UTF8
  is_enabled: true
  description: Use utf-8 encoding
  content: |
      csv_delimiter: '|'
      classname: test1
      encoding: utf-8

- classname: _pipeline
  keyname: test1_pipeline_iso8859_1
  displayname: test1_pipeline ISO-8859-1
  is_enabled: true
  description: Use ISO-8859-1 encoding
  content: |
      csv_delimiter: '|'
      classname: test1
      encoding: 'ISO-8859-1'


- classname: _pipeline
  keyname: test1_pipeline_toint
  displayname: test1_pipeline to_int
  is_enabled: true
  description: Convert to int
  content: |
      csv_delimiter: '|'
      classname: test1
      tasks: 
        - field_toint: ['',myint]

- classname: _pipeline
  keyname: test1_pipeline_tofloat
  displayname: test1_pipeline to_float
  is_enabled: true
  description: Convert to float
  content: |
      csv_delimiter: '|'
      classname: test1
      tasks: 
        - field_tofloat: ['',myfloat]

- classname: _pipeline
  keyname: test1_pipeline_nospace
  displayname: test1_pipeline_nospace
  is_enabled: true
  description: Remove all whitespaces
  content: |
      csv_delimiter: '|'
      classname: test1
      tasks: 
        - field_nospace: ['', myint, myfloat]


# -----------------------------------
# dataview
# -----------------------------------

# test0
- classname: _dataview
  keyname: test0_default
  target_class: test0
  displayname: Test0 Default View
  is_enabled: true
  content: |
    columns:
      - keyname
      - displayname
      - mystring


# test1
- classname: _dataview
  target_class: test1
  keyname: test1_default
  displayname: Test1 Default DataView
  content: |
    columns:
      - keyname
      - displayname
      
- classname: _dataview
  target_class: test1
  keyname: test1_fields
  displayname: Test1 Field DataView
  content: |
    columns:
      - keyname
      - displayname
      - mystring
      - myint
      - myfloat
      - myboolean
      - my_enumerate_abcde
      - my_enumerate_abcde_multi
      - my_schema_test0
      - my_schema_test0_multi


- classname: _dataview
  target_class: test1
  keyname: test1_welcome
  displayname: Test1 Welcome DataView
  content: |
    columns:
      - keyname
      - displayname
      - mystring
      - mystring_renamed:
          from: mystring
      - my_enumerate_abcde
      - newcol
      - invalid:
          from: non_existent_column
          add: 5

- classname: _dataview
  target_class: test1
  keyname: test1_enumerate
  displayname: test1 enumerate
  description: Test Enumerate UI subfields
  content: |
    columns:
    - keyname
    - displayname
    - abcde:
        from: my_enumerate_abcde
    - abcde_multi:
        from: my_enumerate_abcde_multi



- classname: _dataview
  target_class: test1
  keyname: test1_enumerate_inject
  displayname: Test1 Enumerate Inject Subfields
  content: |
    columns:
      - keyname
      - displayname
      - Enum:
          from: my_enumerate_subfields
      - Widget:
          from: my_enumerate_subfields__widget
      - String:
          from: my_enumerate_subfields__enumstring
      - Boolean:
          from: my_enumerate_subfields__enumboolean
      - Int:
          from: my_enumerate_subfields__enumint
      - Float:
          from: my_enumerate_subfields__enumfloat


# test2
- classname: _dataview
  keyname: test2_default
  target_class: test2
  displayname: Test2 Default Dataview
  is_enabled: true
  content: |
    columns:
      - keyname
      - displayname
      - test1
      - test1__mystring
      - test1__myint
      - test1__myfloat
      - test1__myboolean


# test3
- classname: _dataview
  keyname: test3_default
  target_class: test3
  displayname: Test3 Default Dataview
  is_enabled: true
  content: |
    columns:
      - keyname
      - displayname
      - test2
      - test1
      - test1__mystring
      - test1__myint
      - test1__myfloat
      - test1__myboolean


# test4
- classname: _dataview
  keyname: test4_external
  _action: delete

- classname: _dataview
  keyname: test4_default
  target_class: test4
  displayname: Test4 Defautt View with External
  is_enabled: true
  content: |
    columns:
      - keyname
      - displayname
      - test3
      - test1
      - test1__mystring
      - test1__myint
      - test1__myfloat
      - test1__myboolean

# --------------------------------
# enumerate
# --------------------------------


- classname: _enumerate
  keyname: enumerate_test
  displayname: "Enumerate Test ABCDE"
  description: "Enumerate Test ABCDE"
  content: |
    - value: "A"
      long: "A - OK"
      #is_enabled: True
      widget: "green_circle"
      num: 1
      description: "Use if perfect"
      enumstring: string AAA
      enumint: int 111
      enumfloat: float 111.1
      enumboolean: boolean no

    - value: "B"
      long: "B - Good"
      widget: "yellow_circle"
      num: 2
      enumstring: string BBB
      enumint: int 222
      enumfloat: float 222.2
      enumboolean: boolean no

    - value: "C"
      long: "C - Medium"
      widget: "orange_circle"
      num: 3
      enumstring: string CCC
      enumint: int 333
      enumfloat: float 333.3
      enumboolean: boolean no

    - value: "D"
      long: "D - Bad"
      widget: "red_circle"
      num: 4

    - value: "E"
      long: "E - Alert"
      widget: "black_circle"
      num: 5

    - value: "n/a"
      long: "n/a"
      widget: "white_circle"
      enumstring: string ZZZ
      enumint: int 999
      enumfloat: float 99.99
      enumboolean: boolean yes

    - value: "?"
      long: "? - check"
      description: "Unknown/Check"
      widget: "blue_circle"
      enumboolean: boolean yes

    - value: "complex"
      widget: 'html <span class="badge bg-dark">Widget</span> &nbsp;'
      enumstring: string test_enum_string
      enumint: int 123
      enumfloat: float 99.95
      enumboolean: boolean no



# --------------------------------------------
# test4 > test3 > test2 > test1 (full) > test0
# --------------------------------------------

# test0  - minimal - no class level permission
- classname: _schema
  keyname: test0
  handle_method: keyname
  displayname: "TestClass #0"
  is_enabled: yes
  order: 900
  page: Test        
  icon: fa-diamond
  mystring:
        displayname: MyString
        dataformat: string
        description: A string 

# test1

- classname: _permission
  keyname: p_test1_admin
  description: "Built-in test1 admin permission"
  displayname: "p_test1_admin"

- classname: _permission
  keyname: p_test1_create
  description: "Built-in test1 create permission"
  displayname: p_test1_create

- classname: _permission
  keyname: p_test1_read
  description: "Built-in test1 read permission"
  displayname: p_test1_read

- classname: _permission
  keyname: p_test1_update
  description: "Built-in test1 update permission"
  displayname: p_test1_update
      
- classname: _permission
  keyname: p_test1_delete
  description: "Built-in test1 delete permission"
  displayname: p_test1_delete

- classname: _permission
  keyname: p_test1_import
  description: "Built-in test1 import permission"
  displayname: p_test1_import

- classname: _permission
  keyname: p_test1_export
  description: "Built-in test1 export permission"
  displayname: p_test1_export
      


- classname: _schema
  keyname: test1
  handle_method: keyname
  displayname: "TestClass #1"
  is_enabled: yes
  order: 910
  page: Test        
  icon: fa-diamond
  p_admin: p_test1_admin
  p_create: p_test1_create
  p_read: p_test1_read
  p_update: p_test1_update
  p_delete: p_test1_delete
  p_import: p_test1_import
  p_export: p_test1_export
  options:
     keyname_mode: edit
     "strange$€": "verystrange$€é''\""



  mystring:
        displayname: MyString
        dataformat: string
        description: A string           

  mystring_default:
        displayname: MyString Default
        dataformat: string
        description: A string with default value
        default: hello

  myint:
        displayname: MyInt
        dataformat: int

  myint_multi:
        displayname: MyIntMulti
        dataformat: int
        description: separate values with blank
        cardinal_max: 0
        cardinal_max: 0

  myint_default:
        displayname: MyInt default
        dataformat: int
        description: single int with default value
        default: 11

  myint_default_multi:
        displayname: MyInt default multi
        description: separate values with blank
        dataformat: int
        default: 11 22
        cardinal_max: 0

  myfloat:
        displayname: MyFloat
        dataformat: float
        description: float ; use dot as decimal separator

  myfloat_multi:
        displayname: MyFloatMulti
        dataformat: float
        description: use dot for decimal - separate values with blank
        cardinal_max: 0
        cardinal_max: 0

  myfloat_default:
        displayname: MyFloat default
        dataformat: float
        description: float ; use dot as decimal separator
        default: 11.11

  myfloat_default_multi:
        displayname: MyFloat default multi
        dataformat: float
        description: float ; use dot as decimal separator ; separate values with blank
        default: 11.11 22.22
        cardinal_max: 0

  myboolean:
        displayname: MyBoolean
        dataformat: boolean

# ---
  mydate:
        displayname: MyDate
        description: format YYYY-MM-DD
        dataformat: date

  date_auto_pipeline:
        displayname: DateAutoPipeline
        description: YYYY-MM-DD
        dataformat: date
  
  time_auto_pipeline:
        displayname: TimeAutoPipeline
        description: HH:MM:SS
        dataformat: time
  
  datetime_auto_pipeline:
        displayname: DateTimeAutoPipeline
        description: YYYY-MM-DD HH:MM:SS
        dataformat: datetime

# ---

  myipv4:
        displayname: MyIPV4
        dataformat: ipv4
        description: A.B.C.D or A.B.C.D/mask

  uuid_auto:
        displayname: UUID auto
        dataformat: string
        description: UUID from pipeline

# ---


  my_user:      
        displayname: My Sirene User
        dataformat: user
        description: Choose a user
        cardinal_min: 0
        cardinal_max: 1

  my_user_multi:
        displayname: My Sirene User Multi
        dataformat: user
        description: Choose one or more users
        cardinal_min: 0
        cardinal_max: 0

  my_notify_group:
        displayname: MysireneGroup
        dataformat: group
        description: Choose a usergroup
        cardinal_max: 0
        cardinal_max: 1

  my_notify_group_multi:
        displayname: MysireneGroupMulti
        dataformat: group
        description: Choose one or more usergroups
        cardinal_max: 0
        cardinal_max: 0

# ---

  my_schema_test0:
        displayname: Schema Test0
        dataformat: schema
        dataformat_ext: test0
        description: Schema Test0 loop free
        cardinal_min: 0
        cardinal_max: 1

  my_schema_test0_multi:      
        displayname: Schema Test0 Multi
        dataformat: schema
        dataformat_ext: test0
        description: Choose one or more Test0 object
        cardinal_min: 0
        cardinal_max: 0

  my_schema_self:      
        displayname: Schema self Single
        dataformat: schema
        dataformat_ext: test1
        description: Choose a TEST (self)
        cardinal_min: 0
        cardinal_max: 1


# --- Enumerate


  my_enumerate_abcde:      
        displayname: Enumerate ABCDE
        dataformat: enumerate
        dataformat_ext: enumerate_test
        description: Choose a value
        cardinal_min: 0
        cardinal_max: 1

  my_enumerate_abcde_multi:      
        displayname: Enumerate Multi ABCDE
        dataformat: enumerate
        dataformat_ext: enumerate_test
        description: Choose one or more values
        cardinal_min: 0
        cardinal_max: 0

  my_enumerate_default:
        displayname: Enumerate with default
        dataformat: enumerate
        dataformat_ext: enumerate_test
        default: B

  my_enumerate_subfields:
        displayname: Enumerate with subfields
        dataformat: enumerate
        dataformat_ext: enumerate_test

# -- File

  my_file:
      displayname: My File
      description: Select a single test file
      dataformat: file

  # my_file_multi:
  #     displayname: My File Multi
  #     dataformat: file
  #     cardinal_max: 0


# ------------------------
# test 2 (> test1)
# -------------------------

- classname: _permission
  keyname: p_test2_admin
  description: "Built-in test2 admin permission"
  displayname: "p_test2_admin"

- classname: _permission
  keyname: p_test2_create
  description: "Built-in test2 create permission"
  displayname: p_test2_create

- classname: _permission
  keyname: p_test2_read
  description: "Built-in test2 read permission"
  displayname: p_test2_read

- classname: _permission
  keyname: p_test2_update
  description: "Built-in test2 update permission"
  displayname: p_test2_update
      
- classname: _permission
  keyname: p_test2_delete
  description: "Built-in test2 delete permission"
  displayname: p_test2_delete

- classname: _permission
  keyname: p_test2_import
  description: "Built-in test2 import permission"
  displayname: p_test2_import

- classname: _permission
  keyname: p_test2_export
  description: "Built-in test2 export permission"
  displayname: p_test2_export
      


- classname: _schema
  keyname: test2
  handle_method: keyname
  displayname: "TestClass #2"
  is_enabled: yes
  order: 920
  page: Test
  icon: fa-diamond
  p_admin: p_test2_admin
  p_create: p_test2_create
  p_read: p_test2_read
  p_update: p_test2_update
  p_delete: p_test2_delete
  p_import: p_test2_import
  p_export: p_test2_export

  test1:      
        displayname: Test1 Object
        dataformat: schema
        dataformat_ext: test1 mystring myint myfloat myboolean
        description: Test1 Object with injected subfields


# ------------------------
# test3 (> test2)
# -------------------------
- classname: _permission
  keyname: p_test3_admin
  description: "Built-in test3 admin permission"
  displayname: "p_test3_admin"

- classname: _permission
  keyname: p_test3_create
  description: "Built-in test3 create permission"
  displayname: p_test3_create

- classname: _permission
  keyname: p_test3_read
  description: "Built-in test3 read permission"
  displayname: p_test3_read

- classname: _permission
  keyname: p_test3_update
  description: "Built-in test3 update permission"
  displayname: p_test3_update
      
- classname: _permission
  keyname: p_test3_delete
  description: "Built-in test3 delete permission"
  displayname: p_test3_delete

- classname: _permission
  keyname: p_test3_import
  description: "Built-in test3 import permission"
  displayname: p_test3_import

- classname: _permission
  keyname: p_test3_export
  description: "Built-in test3 export permission"
  displayname: p_test3_export
      



- classname: _schema
  keyname: test3
  handle_method: keyname
  displayname: "TestClass #3"
  is_enabled: yes
  order: 930
  page: Test
  icon: fa-diamond
  p_admin: p_test3_admin
  p_create: p_test3_create
  p_read: p_test3_read
  p_update: p_test3_update
  p_delete: p_test3_delete
  p_import: p_test3_import
  p_export: p_test3_export

  test2:
        displayname: Test2 Object (schema)
        dataformat: schema
        dataformat_ext: test2


  _test1:
        displayname: Test1 Object (external)
        dataformat: external
        dataformat_ext: test2 test1 mystring myint myfloat myboolean


# ------------------------
# test4 (> test3)
# -------------------------

- classname: _permission
  keyname: p_test4_admin
  description: "Built-in test4 admin permission"
  displayname: "p_test4_admin"

- classname: _permission
  keyname: p_test4_create
  description: "Built-in test4 create permission"
  displayname: p_test4_create

- classname: _permission
  keyname: p_test4_read
  description: "Built-in test4 read permission"
  displayname: p_test4_read

- classname: _permission
  keyname: p_test4_update
  description: "Built-in test4 update permission"
  displayname: p_test4_update
      
- classname: _permission
  keyname: p_test4_delete
  description: "Built-in test4 delete permission"
  displayname: p_test4_delete

- classname: _permission
  keyname: p_test4_import
  description: "Built-in test4 import permission"
  displayname: p_test4_import

- classname: _permission
  keyname: p_test4_export
  description: "Built-in test4 export permission"
  displayname: p_test4_export
      


- classname: _schema
  keyname: test4
  handle_method: keyname
  displayname: "TestClass #4"
  is_enabled: yes
  order: 940
  page: Test
  icon: fa-diamond
  p_admin: p_test4_admin
  p_create: p_test4_create
  p_read: p_test4_read
  p_update: p_test4_update
  p_delete: p_test4_delete
  p_import: p_test4_import
  p_export: p_test4_export


  test3:      
        displayname: Test3 Object
        dataformat: schema
        dataformat_ext: test3


  _test1:
        displayname: Test1 (external)
        dataformat: external
        dataformat_ext: test3 test1 displayname is_enabled mystring myint myfloat myboolean
