| Line 1... |
Line 1... |
| 1 |
package in.shop2020.util;
|
1 |
package in.shop2020.util;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.metamodel.core.Entity;
|
3 |
import in.shop2020.metamodel.core.Entity;
|
| 4 |
import in.shop2020.metamodel.core.Slide;
|
4 |
import in.shop2020.metamodel.core.Slide;
|
| - |
|
5 |
import in.shop2020.metamodel.definitions.Catalog;
|
| - |
|
6 |
import in.shop2020.metamodel.definitions.Category;
|
| - |
|
7 |
import in.shop2020.metamodel.definitions.DefinitionsContainer;
|
| 5 |
import in.shop2020.metamodel.util.CreationUtils;
|
8 |
import in.shop2020.metamodel.util.CreationUtils;
|
| 6 |
import in.shop2020.metamodel.util.ExpandedBullet;
|
9 |
import in.shop2020.metamodel.util.ExpandedBullet;
|
| 7 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
10 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
| 8 |
import in.shop2020.metamodel.util.ExpandedFeature;
|
11 |
import in.shop2020.metamodel.util.ExpandedFeature;
|
| 9 |
import in.shop2020.metamodel.util.ExpandedSlide;
|
12 |
import in.shop2020.metamodel.util.ExpandedSlide;
|
| 10 |
import in.shop2020.utils.CategoryManager;
|
- |
|
| 11 |
|
13 |
|
| 12 |
import java.util.ArrayList;
|
14 |
import java.util.ArrayList;
|
| 13 |
import java.util.Arrays;
|
15 |
import java.util.Arrays;
|
| 14 |
import java.util.Collection;
|
16 |
import java.util.Collection;
|
| 15 |
import java.util.HashMap;
|
17 |
import java.util.HashMap;
|
| Line 20... |
Line 22... |
| 20 |
|
22 |
|
| 21 |
import org.apache.commons.lang.StringUtils;
|
23 |
import org.apache.commons.lang.StringUtils;
|
| 22 |
|
24 |
|
| 23 |
|
25 |
|
| 24 |
public class AccessoriesFinder {
|
26 |
public class AccessoriesFinder {
|
| 25 |
CategoryManager catm = CategoryManager.getCategoryManager();
|
27 |
DefinitionsContainer defContainer = Catalog.getInstance().getDefinitionsContainer();
|
| 26 |
Set<Long> entityIds;
|
28 |
Set<Long> entityIds;
|
| 27 |
|
29 |
|
| 28 |
public static void main(String[] args) throws Exception {
|
30 |
public static void main(String[] args) throws Exception {
|
| 29 |
// AccessoriesFinder af = new AccessoriesFinder();
|
31 |
// AccessoriesFinder af = new AccessoriesFinder();
|
| 30 |
// Map<Long, Map<Long, List<Long>>> relatedAccessories = af.findAccessories();
|
32 |
// Map<Long, Map<Long, List<Long>>> relatedAccessories = af.findAccessories();
|
| Line 51... |
Line 53... |
| 51 |
|
53 |
|
| 52 |
|
54 |
|
| 53 |
for(Long entityID: entityIds){
|
55 |
for(Long entityID: entityIds){
|
| 54 |
Entity entity = CreationUtils.getEntity(entityID);
|
56 |
Entity entity = CreationUtils.getEntity(entityID);
|
| 55 |
Map<Long, Object> entityCategoryParameters = getEntityCategoryParameters(entity);
|
57 |
Map<Long, Object> entityCategoryParameters = getEntityCategoryParameters(entity);
|
| 56 |
if(catm.getCategory(entity.getCategoryID()).getParent_category_id() != Utils.MOBILE_ACCESSORIES_CATEGORY && catm.getCategory(entity.getCategoryID()).getId() != Utils.LAPTOPS_CATEGORY){
|
58 |
Category cat = defContainer.getCategory(entity.getCategoryID()).getParentCategory();
|
| - |
|
59 |
if(cat.isHasAccessories()){
|
| 57 |
entityAccessories.put(entity.getID(), getRelatedAccessories(entityCategoryParameters, categoryParameterMap));
|
60 |
entityAccessories.put(entity.getID(), getRelatedAccessories(entityCategoryParameters, categoryParameterMap));
|
| 58 |
}
|
61 |
}
|
| 59 |
}
|
62 |
}
|
| 60 |
return entityAccessories;
|
63 |
return entityAccessories;
|
| 61 |
}
|
64 |
}
|
| 62 |
|
65 |
|
| 63 |
private Map<Long, Object> getEntityCategoryParameters(Entity entity) throws Exception {
|
66 |
private Map<Long, Object> getEntityCategoryParameters(Entity entity) throws Exception {
|
| 64 |
Map<Long, Object> entityCategoryParameters = new HashMap<Long, Object>();
|
67 |
Map<Long, Object> entityCategoryParameters = new HashMap<Long, Object>();
|
| 65 |
List<Long> categoryIDs = catm.getCategory(Utils.MOBILE_ACCESSORIES_CATEGORY).getChildren_category_ids();
|
68 |
List<Category> categories = defContainer.getCategory(Utils.MOBILE_ACCESSORIES_CATEGORY).getChildrenCategory();
|
| 66 |
for(Long categoryID: categoryIDs){
|
69 |
for(Category category : categories){
|
| 67 |
Object obj = populateEntityParameters(categoryID, entity);
|
70 |
Object obj = populateEntityParameters(category.getID(), entity);
|
| 68 |
if(obj != null){
|
71 |
if(obj != null){
|
| 69 |
entityCategoryParameters.put(categoryID, obj);
|
72 |
entityCategoryParameters.put(category.getID(), obj);
|
| 70 |
}
|
73 |
}
|
| 71 |
}
|
74 |
}
|
| 72 |
return entityCategoryParameters;
|
75 |
return entityCategoryParameters;
|
| 73 |
}
|
76 |
}
|
| 74 |
|
77 |
|