| Line 8... |
Line 8... |
| 8 |
import in.shop2020.metamodel.definitions.CMPBucketDefinition;
|
8 |
import in.shop2020.metamodel.definitions.CMPBucketDefinition;
|
| 9 |
import in.shop2020.metamodel.definitions.Catalog;
|
9 |
import in.shop2020.metamodel.definitions.Catalog;
|
| 10 |
import in.shop2020.metamodel.definitions.DefinitionsContainer;
|
10 |
import in.shop2020.metamodel.definitions.DefinitionsContainer;
|
| 11 |
import in.shop2020.metamodel.util.CreationUtils;
|
11 |
import in.shop2020.metamodel.util.CreationUtils;
|
| 12 |
import in.shop2020.metamodel.util.ExpandedCMPSlideRuleDefinition;
|
12 |
import in.shop2020.metamodel.util.ExpandedCMPSlideRuleDefinition;
|
| - |
|
13 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
| 13 |
import in.shop2020.metamodel.util.ExpandedSlide;
|
14 |
import in.shop2020.metamodel.util.ExpandedSlide;
|
| 14 |
|
15 |
|
| 15 |
import java.util.HashMap;
|
16 |
import java.util.HashMap;
|
| 16 |
import java.util.List;
|
17 |
import java.util.List;
|
| 17 |
import java.util.Map;
|
18 |
import java.util.Map;
|
| Line 87... |
Line 88... |
| 87 |
for(Entity entity : entities) {
|
88 |
for(Entity entity : entities) {
|
| 88 |
//Skip categories with value as -1 or categories except mobile phones
|
89 |
//Skip categories with value as -1 or categories except mobile phones
|
| 89 |
if(entity.getCategoryID() == -1 || !(Catalog.getInstance().getDefinitionsContainer().getCategory(entity.getCategoryID()).getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY)){
|
90 |
if(entity.getCategoryID() == -1 || !(Catalog.getInstance().getDefinitionsContainer().getCategory(entity.getCategoryID()).getParentCategory().getID() != Utils.MOBILE_ACCESSORIES_CATEGORY)){
|
| 90 |
continue;
|
91 |
continue;
|
| 91 |
}
|
92 |
}
|
| 92 |
|
- |
|
| - |
|
93 |
ExpandedEntity expEntity = new ExpandedEntity(entity);
|
| 93 |
Map<Long, Double> slideScores = this.getSlideScores(entity);
|
94 |
Map<Long, Double> slideScores = this.getSlideScores(expEntity);
|
| 94 |
|
95 |
|
| 95 |
slideScoresByEntityID.put(entity.getID(), slideScores);
|
96 |
slideScoresByEntityID.put(entity.getID(), slideScores);
|
| 96 |
}
|
97 |
}
|
| 97 |
|
98 |
|
| 98 |
return slideScoresByEntityID;
|
99 |
return slideScoresByEntityID;
|
| Line 102... |
Line 103... |
| 102 |
*
|
103 |
*
|
| 103 |
* @param entity
|
104 |
* @param entity
|
| 104 |
* @return Map<Long, Double>
|
105 |
* @return Map<Long, Double>
|
| 105 |
* @throws Exception
|
106 |
* @throws Exception
|
| 106 |
*/
|
107 |
*/
|
| 107 |
private Map<Long, Double> getSlideScores(Entity entity) throws Exception {
|
108 |
private Map<Long, Double> getSlideScores(ExpandedEntity expEntity) throws Exception {
|
| 108 |
Map<Long, Double> slideScores = new HashMap<Long, Double>();
|
109 |
Map<Long, Double> slideScores = new HashMap<Long, Double>();
|
| 109 |
|
110 |
|
| 110 |
DefinitionsContainer defs =
|
111 |
DefinitionsContainer defs =
|
| 111 |
Catalog.getInstance().getDefinitionsContainer();
|
112 |
Catalog.getInstance().getDefinitionsContainer();
|
| 112 |
|
113 |
|
| 113 |
// Python wrapper for executing rule in python script
|
114 |
// Python wrapper for executing rule in python script
|
| 114 |
CMPJythonWrapper cmpJW = new CMPJythonWrapper();
|
115 |
CMPJythonWrapper cmpJW = new CMPJythonWrapper();
|
| 115 |
|
116 |
|
| 116 |
// Scores are required for parent slides only
|
117 |
// Scores are required for parent slides only
|
| 117 |
List<Slide> slides = entity.getSlides();
|
118 |
List<ExpandedSlide> expSlides = expEntity.getExpandedSlides();
|
| 118 |
if(slides==null){
|
119 |
if(expSlides==null){
|
| 119 |
return slideScores;
|
120 |
return slideScores;
|
| 120 |
}
|
121 |
}
|
| 121 |
for(Slide slide : slides) {
|
- |
|
| 122 |
ExpandedSlide expSlide = new ExpandedSlide(slide);
|
122 |
for(ExpandedSlide expSlide : expSlides) {
|
| 123 |
cmpJW.reset();
|
123 |
cmpJW.reset();
|
| 124 |
cmpJW.initialize();
|
124 |
cmpJW.initialize();
|
| 125 |
|
125 |
|
| 126 |
cmpJW.setExpandedSlide(expSlide);
|
126 |
cmpJW.setExpandedSlide(expSlide);
|
| - |
|
127 |
cmpJW.setCategory(expEntity.getCategory());
|
| 127 |
|
128 |
|
| 128 |
long slideDefinitionID = slide.getSlideDefinitionID();
|
129 |
long slideDefinitionID = expSlide.getSlideDefinitionID();
|
| 129 |
ExpandedCMPSlideRuleDefinition expCMPSlideRuleDef =
|
130 |
ExpandedCMPSlideRuleDefinition expCMPSlideRuleDef =
|
| 130 |
defs.getExpandedComparisonSlideRuleDefinition(
|
131 |
defs.getExpandedComparisonSlideRuleDefinition(
|
| 131 |
slideDefinitionID);
|
132 |
slideDefinitionID);
|
| 132 |
|
133 |
|
| 133 |
if(expCMPSlideRuleDef == null) {
|
134 |
if(expCMPSlideRuleDef == null) {
|