package au.gov.amsa.detection.behaviour;

import au.gov.amsa.detection.ArbitraryId;
import au.gov.amsa.detection.model.Craft;
import au.gov.amsa.detection.model.Detection;
import au.gov.amsa.detection.model.DetectionRule;
import au.gov.amsa.detection.model.DetectionRuleCraft;
import au.gov.amsa.detection.model.DetectionRuleCraft.Behaviour;
import au.gov.amsa.detection.model.DetectionRuleCraft.Events.Create;

public class DetectionRuleCraftBehaviour implements Behaviour {

    private final DetectionRuleCraft self;

    public DetectionRuleCraftBehaviour(DetectionRuleCraft self) {
        this.self = self;
    }

    @Override
    public void onEntryCreated(Create event) {
        self.setId(ArbitraryId.next());
        self.setCraft_R18(Craft.find(event.getCraftID()).get());
        self.setDetectionRule_R17(DetectionRule.find(event.getDetectionRuleID()).get());
        self.relateAcrossR12(Detection.find(event.getDetectionID()).get());
    }

}

@@ -39,188 +39,8 @@
 r;%0A%0A
-import au.gov.amsa.detection.ArbitraryId;%0Aimport au.gov.amsa.detection.model.Craft;%0Aimport au.gov.amsa.detection.model.Detection;%0Aimport au.gov.amsa.detection.model.DetectionRule;%0A
 impo
@@ -90,16 +90,16 @@
 eCraft;%0A
+
 import a
@@ -506,267 +506,57 @@
     
-self.setId(ArbitraryId.next());%0A        self.setCraft_R18(Craft.find(event.getCraftID()).get());%0A        self.setDetectionRule_R17(DetectionRule.find(event.getDetectionRuleID()).get());%0A        self.relateAcrossR12(Detection.find(event.getDetectionID()).get()
+throw new RuntimeException(%22should not be called%22
 );%0A 

replace creation method with throw in DetectionRuleCraft