package org.ihtsdo.buildcloud.service.precondition;

import org.ihtsdo.buildcloud.entity.Execution;
import org.ihtsdo.buildcloud.entity.Package;
import org.ihtsdo.buildcloud.entity.PreConditionCheckReport;
import org.ihtsdo.buildcloud.entity.PreConditionCheckReport.State;

public abstract class PreconditionCheck {
	
    private State state = State.NOT_RUN;

    private String responseMessage = "";

    public abstract void runCheck(Package pkg, Execution execution);

    public PreConditionCheckReport getReport() {
	PreConditionCheckReport report = new PreConditionCheckReport();
	report.setPreConditionCheckName(getTestName());
	report.setResult(state);
	report.setMessage(getResponseMessage());
	return report;
    }

    protected void pass() {
	this.state = State.PASS;
	//need to update this
	this.responseMessage="";
    }

    protected void fail(String msg) {
	this.state = State.FAIL;
	this.responseMessage = msg;
    }
    protected void fatalError(String error){
	state = State.FATAL;
	responseMessage = error;
    }

    public State getState() {
	return state;
    }

    protected void setState(State state) {
	this.state = state;
    }

    public String getResponseMessage() {
	return responseMessage;
    }

    protected void setResponseMessage(String responseMessage) {
	this.responseMessage = responseMessage;
    }

    //Default behaviour is to return the class name
    public String getTestName() {
	return this.getClass().getSimpleName();
    }
}

@@ -313,14 +313,10 @@
 k %7B%0A
+%0A
 %09
-%0A    
 priv
@@ -349,20 +349,17 @@
 T_RUN;%0A%0A
-    
+%09
 private 
@@ -388,20 +388,17 @@
  = %22%22;%0A%0A
-    
+%09
 public a
@@ -455,20 +455,17 @@
 tion);%0A%0A
-    
+%09
 public P
@@ -501,16 +501,17 @@
 ort() %7B%0A
+%09
 %09PreCond
@@ -567,16 +567,17 @@
 port();%0A
+%09
 %09report.
@@ -617,16 +617,17 @@
 ame());%0A
+%09
 %09report.
@@ -644,16 +644,17 @@
 state);%0A
+%09
 %09report.
@@ -687,16 +687,17 @@
 age());%0A
+%09
 %09return 
@@ -704,27 +704,21 @@
 report;%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 protecte
@@ -729,24 +729,25 @@
 id pass() %7B%0A
+%09
 %09this.state 
@@ -760,16 +760,17 @@
 e.PASS;%0A
+%09
 %09//need 
@@ -784,16 +784,17 @@
 te this%0A
+%09
 %09this.re
@@ -810,24 +810,20 @@
 sage
-=
+ = 
 %22%22;%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 prot
@@ -848,24 +848,25 @@
 ring msg) %7B%0A
+%09
 %09this.state 
@@ -879,16 +879,17 @@
 e.FAIL;%0A
+%09
 %09this.re
@@ -913,18 +913,13 @@
 sg;%0A
-    %7D%0A    
+%09%7D%0A%0A%09
 prot
@@ -953,18 +953,20 @@
 g error)
+ 
 %7B%0A
+%09
 %09state =
@@ -979,16 +979,17 @@
 .FATAL;%0A
+%09
 %09respons
@@ -1006,27 +1006,21 @@
  error;%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 public S
@@ -1033,24 +1033,25 @@
 etState() %7B%0A
+%09
 %09return stat
@@ -1053,27 +1053,21 @@
  state;%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 protecte
@@ -1093,24 +1093,25 @@
 te state) %7B%0A
+%09
 %09this.state 
@@ -1119,27 +1119,21 @@
  state;%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 public S
@@ -1157,24 +1157,25 @@
 Message() %7B%0A
+%09
 %09return resp
@@ -1187,27 +1187,21 @@
 essage;%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 protecte
@@ -1252,16 +1252,17 @@
 sage) %7B%0A
+%09
 %09this.re
@@ -1298,19 +1298,13 @@
 ge;%0A
-    %7D%0A%0A    
+%09%7D%0A%0A%09
 //De
@@ -1347,20 +1347,17 @@
 ss name%0A
-    
+%09
 public S
@@ -1378,16 +1378,17 @@
 ame() %7B%0A
+%09
 %09return 
@@ -1424,12 +1424,9 @@
 ();%0A
-    
+%09
 %7D%0A%7D%0A

Correct code format.