/*
 * Copyright 2015 Red Hat, Inc. and/or its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * 
 *      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.
*/

import org.kie.server.testing.Person;

rule "Set lastname for Darth"
    no-loop true
when
    $person : Person(firstname == "Darth")
then
    modify($person) {
        setSurname("Vader")
    }
end

rule "Mark duplicated Vaders"
   no-loop true
when
    $vader1 : Person(firstname == "Darth", surname == "Vader", duplicated == false)
    $vader2 : Person(firstname == "Darth", surname == "Vader", duplicated == false, this != $vader1)
then
   modify($vader1) {
       setDuplicated(true)
   }
   modify($vader2) {
       setDuplicated(true)
   }
end

rule "Rule with agenda group"
    agenda-group "ag1"
    lock-on-active
when
    $p : Person( firstname == "Bob" )
then
    modify($p){
       setSurname("Sponge")
    }
end

query "get people"()
    person : Person()
end


