// Copyright 2023 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

###Mapping
Mapping test::simpleModelMapping
(
   test::Types : Pure
            {
              ~src test::_S_Types
              string: $src.string,
              float: $src.float,
              int: $src.int,
              bool: $src.bool,
              decimal: $src.decimal,
              date: $src.date,
              dateTime: $src.dateTime
            }
)

###Pure
import meta::pure::graphFetch::execution::*;
import meta::pure::mapping::*;
import meta::pure::mapping::modelToModel::*;
import meta::external::store::model::*;
import meta::core::runtime::*;
import meta::pure::runtime::*;
import meta::pure::executionPlan::*;

Class test::_S_Types
{
   string: String[1];
   float: Float[1];
   int: Integer[1];
   bool: Boolean[1];
   decimal: Decimal[1];
   date: StrictDate[1];
   dateTime: DateTime[1];
}

Class test::Types
{
   string: String[1];
   float: Float[1];
   int: Integer[1];
   bool: Boolean[1];
   decimal: Decimal[1];
   date: StrictDate[1];
   dateTime: DateTime[1];

   sum(nums: Integer[*]){
    $nums->plus() + $this.int;
   }:Integer[1];

   mult(num: Decimal[1]){
    $num * $this.decimal;
   }:Decimal[1];

   mult(num: Integer[1]){
    $num * $this.int;
   }:Integer[1];

   mult(num: Float[1]){
    $num * $this.float;
   }:Float[1];

   and(other: Boolean[1]){
    $other && $this.bool;
   }:Boolean[1];

   string(prefix: String[1], suffix: String[1]){
    $prefix + $this.string + $suffix;
   }:String[1];

   years(asOf: StrictDate[1]){
      dateDiff($this.date, $asOf, DurationUnit.YEARS);
   }:Integer[1];

   seconds(asOf: DateTime[1]){
     dateDiff($this.dateTime, $asOf, DurationUnit.SECONDS);
   }:Integer[1];
}
