| 62 |
naveen |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.metamodel.util;
|
|
|
5 |
|
|
|
6 |
import java.util.ArrayList;
|
|
|
7 |
import java.util.List;
|
|
|
8 |
|
|
|
9 |
import in.shop2020.metamodel.definitions.Catalog;
|
|
|
10 |
import in.shop2020.metamodel.definitions.Category;
|
|
|
11 |
import in.shop2020.metamodel.definitions.CategoryFacetDefinition;
|
|
|
12 |
import in.shop2020.metamodel.definitions.DefinitionsContainer;
|
| 63 |
naveen |
13 |
import in.shop2020.util.Utils;
|
| 62 |
naveen |
14 |
|
|
|
15 |
/**
|
|
|
16 |
* Utility class to support CategoryFacetDefintion class. Expands all
|
|
|
17 |
* references into respect detail objects
|
|
|
18 |
*
|
|
|
19 |
* @author naveen
|
|
|
20 |
*
|
|
|
21 |
*/
|
|
|
22 |
public class ExpandedCategoryFacetDefinition extends CategoryFacetDefinition {
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
*
|
|
|
26 |
*/
|
|
|
27 |
private static final long serialVersionUID = 1L;
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* Expanded Category ID
|
|
|
31 |
*/
|
|
|
32 |
private Category category;
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* List of expanded facet definition IDs
|
|
|
36 |
*/
|
|
|
37 |
private List<ExpandedFacetDefinition> expandedFacetDefinitions;
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* Constructs Expanded version from CategoryFacetDefinition instance
|
|
|
41 |
*
|
|
|
42 |
* @param categoryFacetDefinition
|
|
|
43 |
* @throws Exception
|
|
|
44 |
*/
|
|
|
45 |
public ExpandedCategoryFacetDefinition(
|
|
|
46 |
CategoryFacetDefinition categoryFacetDefinition) throws Exception {
|
|
|
47 |
super(categoryFacetDefinition.getCategoryID());
|
|
|
48 |
|
|
|
49 |
// Copy other properties
|
|
|
50 |
this.setFacetDefinitionIDs(
|
|
|
51 |
categoryFacetDefinition.getFacetDefinitionIDs());
|
|
|
52 |
|
|
|
53 |
// Add expanded objects
|
|
|
54 |
DefinitionsContainer defs =
|
|
|
55 |
Catalog.getInstance().getDefinitionsContainer();
|
|
|
56 |
|
|
|
57 |
// Category
|
|
|
58 |
Category category =
|
|
|
59 |
defs.getCategory(categoryFacetDefinition.getCategoryID());
|
|
|
60 |
|
|
|
61 |
this.setCategory(category);
|
|
|
62 |
|
|
|
63 |
// List of ExpandedFacetDefinition objects
|
|
|
64 |
List<Long> facetDefinitionIDs =
|
|
|
65 |
categoryFacetDefinition.getFacetDefinitionIDs();
|
| 63 |
naveen |
66 |
Utils.info("facetDefinitionIDs=" + facetDefinitionIDs);
|
| 62 |
naveen |
67 |
|
|
|
68 |
for(Long facetDefinitionID : facetDefinitionIDs) {
|
| 63 |
naveen |
69 |
Utils.info("facetDefinitionID=" + facetDefinitionID);
|
|
|
70 |
|
| 62 |
naveen |
71 |
ExpandedFacetDefinition expandedFacetDefinition =
|
| 63 |
naveen |
72 |
defs.getExpandedFacetDefinition(facetDefinitionID.longValue());
|
| 62 |
naveen |
73 |
|
|
|
74 |
this.appendExpandedFacetDefinition(expandedFacetDefinition);
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
/**
|
|
|
79 |
* @param category the category to set
|
|
|
80 |
*/
|
|
|
81 |
public void setCategory(Category category) {
|
|
|
82 |
this.category = category;
|
|
|
83 |
}
|
|
|
84 |
|
|
|
85 |
/**
|
|
|
86 |
* @return the category
|
|
|
87 |
*/
|
|
|
88 |
public Category getCategory() {
|
|
|
89 |
return category;
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
/**
|
|
|
93 |
* Utility method to add new elements
|
|
|
94 |
*
|
|
|
95 |
* @param expandedFacetDefinition
|
|
|
96 |
*/
|
|
|
97 |
public void appendExpandedFacetDefinition(
|
|
|
98 |
ExpandedFacetDefinition expandedFacetDefinition) {
|
|
|
99 |
if(this.expandedFacetDefinitions == null) {
|
|
|
100 |
this.expandedFacetDefinitions =
|
|
|
101 |
new ArrayList<ExpandedFacetDefinition>();
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
this.expandedFacetDefinitions.add(expandedFacetDefinition);
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
/**
|
|
|
108 |
* @param expandedFacetDefinitions the expandedFacetDefinitions to set
|
|
|
109 |
*/
|
|
|
110 |
public void setExpandedFacetDefinitions(
|
|
|
111 |
List<ExpandedFacetDefinition> expandedFacetDefinitions) {
|
|
|
112 |
this.expandedFacetDefinitions = expandedFacetDefinitions;
|
|
|
113 |
}
|
|
|
114 |
|
|
|
115 |
/**
|
|
|
116 |
* @return the expandedFacetDefinitions
|
|
|
117 |
*/
|
|
|
118 |
public List<ExpandedFacetDefinition> getExpandedFacetDefinitions() {
|
|
|
119 |
return expandedFacetDefinitions;
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
}
|