Subversion Repositories SmartDukaan

Rev

Rev 1061 | Rev 2657 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1061 Rev 1918
Line 5... Line 5...
5
 
5
 
6
import in.shop2020.metamodel.definitions.CMPRuleDefinition;
6
import in.shop2020.metamodel.definitions.CMPRuleDefinition;
7
import in.shop2020.metamodel.util.ExpandedCMPSlideRuleDefinition;
7
import in.shop2020.metamodel.util.ExpandedCMPSlideRuleDefinition;
8
import in.shop2020.metamodel.util.ExpandedSlide;
8
import in.shop2020.metamodel.util.ExpandedSlide;
9
 
9
 
-
 
10
import org.python.core.PyFloat;
10
import org.python.core.PyInteger;
11
import org.python.core.PyInteger;
11
 
12
 
12
/**
13
/**
13
 * Wrapper around Jython for Comparison Python scripts
14
 * Wrapper around Jython for Comparison Python scripts
14
 * 
15
 * 
Line 78... Line 79...
78
	/**
79
	/**
79
	 * Return integer score value
80
	 * Return integer score value
80
	 * 
81
	 * 
81
	 * @return int score
82
	 * @return int score
82
	 */
83
	 */
83
	public int getScore() {
84
	public double getScore() {
84
		if(this.py == null) {
85
		if(this.py == null) {
85
			throw new IllegalStateException("Exec is not called yet");
86
			throw new IllegalStateException("Exec is not called yet");
86
		}
87
		}
87
		
88
		
-
 
89
		
88
		PyInteger score = (PyInteger)this.py.get("score");
90
		PyFloat score = (PyFloat)this.py.get("score");
89
		
91
		
90
		if(score == null) {
92
		if(score == null) {
91
			CMPRuleDefinition cmpRuleDef = 
93
			CMPRuleDefinition cmpRuleDef = 
92
				this.expandedCMPSlideRuleDefinition.getCMPRuleDefinition();
94
				this.expandedCMPSlideRuleDefinition.getCMPRuleDefinition();
93
			
95
			
94
			String pyScript = cmpRuleDef.getScript();
96
			String pyScript = cmpRuleDef.getScript();
95
			Utils.severe("No score returned from script " + pyScript);
97
			Utils.severe("No score returned from script " + pyScript);
96
			return -1;
98
			return -1;
97
		}
99
		}
98
		
100
		
99
		return score.asInt();
101
		return score.asDouble();
100
	}
102
	}
101
}
103
}