Subversion Repositories SmartDukaan

Rev

Rev 1061 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1061 Rev 1314
Line 1... Line 1...
1
/**
1
/**
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.util;
4
package in.shop2020.util;
5
 
5
 
6
import in.shop2020.metamodel.definitions.FeatureDefinition;
-
 
7
import in.shop2020.metamodel.definitions.RuleDefinition;
6
import in.shop2020.metamodel.definitions.RuleDefinition;
8
import in.shop2020.metamodel.definitions.SlideDefinition;
7
import in.shop2020.metamodel.definitions.SlideDefinition;
9
import in.shop2020.metamodel.util.ExpandedEntity;
-
 
10
import in.shop2020.metamodel.util.ExpandedFacetRuleDefinition;
8
import in.shop2020.metamodel.util.ExpandedFacetSlideDefinition;
11
import in.shop2020.metamodel.util.ExpandedFeature;
-
 
12
import in.shop2020.metamodel.util.ExpandedSlide;
9
import in.shop2020.metamodel.util.ExpandedSlide;
13
 
10
 
14
import java.util.List;
11
import java.util.List;
15
 
12
 
16
import org.python.core.PyList;
13
import org.python.core.PyList;
Line 25... Line 22...
25
public class IRDataJythonWrapper extends JythonWrapper {
22
public class IRDataJythonWrapper extends JythonWrapper {
26
	
23
	
27
	/**
24
	/**
28
	 * Local instance of Facet Rule Definition - Used to pick script to execute
25
	 * Local instance of Facet Rule Definition - Used to pick script to execute
29
	 */
26
	 */
30
	private ExpandedFacetRuleDefinition expandedFacetRuleDefinition = null;
27
	private ExpandedFacetSlideDefinition expandedFacetSlideDefinition = null;
31
	
28
	
32
	/**
29
	/**
33
	 * Resets current PythonInterpreter instance
30
	 * Resets current PythonInterpreter instance
34
	 */
31
	 */
35
	public void reset() {
32
	public void reset() {
36
		super.reset();
33
		super.reset();
37
		this.expandedFacetRuleDefinition = null;
34
		this.expandedFacetSlideDefinition = null;
38
	}
35
	}
39
	
36
	
40
	/**
37
	/**
41
	 * 
38
	 * 
42
	 * @param expandedFacetRuleDefinition
39
	 * @param expandedFacetSlideDefinition
43
	 */
40
	 */
44
	public void setExpandedFacetRuleDefinition(
41
	public void setExpandedFacetSlideDefinition(
45
			ExpandedFacetRuleDefinition expandedFacetRuleDefinition) {
42
			ExpandedFacetSlideDefinition expandedFacetSlideDefinition) {
46
		this.initialize();
43
		this.initialize();
47
		
44
		
48
		this.expandedFacetRuleDefinition = expandedFacetRuleDefinition;
45
		this.expandedFacetSlideDefinition = expandedFacetSlideDefinition;
49
		this.py.set("expFacetRuleDef", expandedFacetRuleDefinition);
46
		this.py.set("expFacetRuleDef", expandedFacetSlideDefinition);
50
	}
47
	}
51
	
48
	
52
	/**
-
 
53
	 * 
-
 
54
	 * @param entity
-
 
55
	 */
-
 
56
	public void setExpandedEntity(ExpandedEntity expEntity) {
-
 
57
		this.initialize();
-
 
58
		
-
 
59
		this.py.set("expEntity", expEntity);
-
 
60
	}
-
 
61
	
-
 
62
	/**
-
 
63
	 * 
-
 
64
	 * @param featureDefinition
-
 
65
	 */
-
 
66
	public void setFeatureDefinition(FeatureDefinition featureDefinition) {
-
 
67
		this.initialize();
-
 
68
		
-
 
69
		this.py.set("featureDef", featureDefinition);
-
 
70
	}
-
 
71
	
49
	
72
	/**
50
	/**
73
	 * 
51
	 * 
74
	 * @param itemPrice
52
	 * @param itemPrice
75
	 */
53
	 */
Line 77... Line 55...
77
		this.initialize();
55
		this.initialize();
78
		
56
		
79
		this.py.set("itemPrice", itemPrice);
57
		this.py.set("itemPrice", itemPrice);
80
	}
58
	}
81
	
59
	
82
	/**
-
 
83
	 * 
-
 
84
	 * @param feature
-
 
85
	 */
-
 
86
	public void setExpandedFeature(ExpandedFeature expandedFeature) {
-
 
87
		this.initialize();
-
 
88
		
60
	
89
		this.py.set("expFeature", expandedFeature);
-
 
90
	}
-
 
91
	
61
	
92
	/**
62
	/**
93
	 * 
63
	 * 
94
	 * @param slideDefinition
64
	 * @param slideDefinition
95
	 */
65
	 */
Line 108... Line 78...
108
		
78
		
109
		this.py.set("expSlide", expSlide);
79
		this.py.set("expSlide", expSlide);
110
	}
80
	}
111
	
81
	
112
	/**
82
	/**
113
	 * Executes IR Data rule from ExpandedFacetDefinition instance
83
	 * Executes IR Data rule from ExpandedFacetSlideDefinition instance
114
	 */
84
	 */
115
	public void executeRule() {
85
	public void executeRule() {
116
		if(this.py == null || this.expandedFacetRuleDefinition == null) {
86
		if(this.py == null || this.expandedFacetSlideDefinition == null) {
117
			throw new IllegalStateException(
87
			throw new IllegalStateException(
118
					"Not initialized properly");
88
					"Not initialized properly");
119
		}
89
		}
120
		
90
		
121
		RuleDefinition irdataRuleDef = 
-
 
122
			this.expandedFacetRuleDefinition.getIRDataRuleDefinition();
91
		RuleDefinition irdataRuleDef = this.expandedFacetSlideDefinition.getIrDataRuleDefinition();
123
		
92
		
124
		String pyScript = irdataRuleDef.getScript();
93
		String pyScript = irdataRuleDef.getScript();
125
		String scriptFullPath = Utils.JYTHON_SRC_PATH + "irdatarules/" + 
94
		String scriptFullPath = Utils.JYTHON_SRC_PATH + "irdatarules/" + 
126
			pyScript;
95
			pyScript;
127
		
96