| 62 |
naveen |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.util;
|
|
|
5 |
|
| 63 |
naveen |
6 |
import in.shop2020.metamodel.core.Entity;
|
|
|
7 |
import in.shop2020.metamodel.core.Feature;
|
|
|
8 |
import in.shop2020.metamodel.core.Slide;
|
|
|
9 |
import in.shop2020.metamodel.definitions.Catalog;
|
| 64 |
naveen |
10 |
import in.shop2020.metamodel.definitions.Category;
|
| 63 |
naveen |
11 |
import in.shop2020.metamodel.definitions.DefinitionsContainer;
|
|
|
12 |
import in.shop2020.metamodel.definitions.EntityContainer;
|
| 82 |
naveen |
13 |
import in.shop2020.metamodel.definitions.FacetDefinition;
|
| 63 |
naveen |
14 |
import in.shop2020.metamodel.definitions.FeatureDefinition;
|
|
|
15 |
import in.shop2020.metamodel.definitions.SlideDefinition;
|
| 67 |
naveen |
16 |
import in.shop2020.metamodel.util.ExpandedBullet;
|
| 63 |
naveen |
17 |
import in.shop2020.metamodel.util.ExpandedCategoryFacetDefinition;
|
| 64 |
naveen |
18 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
| 82 |
naveen |
19 |
import in.shop2020.metamodel.util.ExpandedFacetDefinition;
|
| 81 |
naveen |
20 |
import in.shop2020.metamodel.util.ExpandedFacetRuleDefinition;
|
| 65 |
naveen |
21 |
import in.shop2020.metamodel.util.ExpandedFeature;
|
|
|
22 |
import in.shop2020.metamodel.util.ExpandedSlide;
|
| 63 |
naveen |
23 |
|
| 81 |
naveen |
24 |
import java.util.ArrayList;
|
|
|
25 |
import java.util.List;
|
| 82 |
naveen |
26 |
import java.util.Map;
|
| 81 |
naveen |
27 |
|
|
|
28 |
import org.apache.commons.lang.ArrayUtils;
|
|
|
29 |
import org.apache.commons.lang.StringEscapeUtils;
|
|
|
30 |
import org.apache.commons.lang.StringUtils;
|
|
|
31 |
|
| 62 |
naveen |
32 |
/**
|
|
|
33 |
* Command line utility to convert IR Definitions into IR Data and IR Meta-data
|
|
|
34 |
*
|
| 81 |
naveen |
35 |
* Usage: IR [irmetadata|irdata] {Category ID}
|
|
|
36 |
*
|
| 62 |
naveen |
37 |
* @author naveen
|
|
|
38 |
*
|
|
|
39 |
*/
|
|
|
40 |
public class IR {
|
| 63 |
naveen |
41 |
|
| 62 |
naveen |
42 |
/**
|
| 64 |
naveen |
43 |
*
|
|
|
44 |
*/
|
| 63 |
naveen |
45 |
private long categoryID;
|
|
|
46 |
|
|
|
47 |
/**
|
| 64 |
naveen |
48 |
* Level - 4, 8, 12, 16
|
|
|
49 |
*/
|
|
|
50 |
private String[] xmlIndentation = {"", " ", " ", " ",
|
|
|
51 |
" "};
|
|
|
52 |
|
|
|
53 |
/**
|
| 62 |
naveen |
54 |
* @param args
|
| 63 |
naveen |
55 |
* @throws Exception
|
| 62 |
naveen |
56 |
*/
|
| 63 |
naveen |
57 |
public static void main(String[] args) throws Exception {
|
| 81 |
naveen |
58 |
String[] commands = new String[] {"irmetadata", "irdata"};
|
| 62 |
naveen |
59 |
|
| 81 |
naveen |
60 |
String usage = "Usage: IR ["+ StringUtils.join(commands, "|") +
|
|
|
61 |
"] {Category ID}\n";
|
|
|
62 |
|
|
|
63 |
if(args.length < 1) {
|
| 63 |
naveen |
64 |
System.out.println(usage);
|
|
|
65 |
System.exit(-1);
|
|
|
66 |
}
|
| 81 |
naveen |
67 |
|
|
|
68 |
String inputCommand = args[0];
|
|
|
69 |
|
|
|
70 |
if(!ArrayUtils.contains(commands, inputCommand)) {
|
|
|
71 |
System.out.println(usage);
|
|
|
72 |
System.exit(-1);
|
|
|
73 |
}
|
| 64 |
naveen |
74 |
|
|
|
75 |
long categoryID = 0L;
|
| 81 |
naveen |
76 |
if(args.length > 1) {
|
| 64 |
naveen |
77 |
try {
|
| 81 |
naveen |
78 |
categoryID = Long.parseLong(args[1]);
|
| 64 |
naveen |
79 |
}
|
|
|
80 |
catch (NumberFormatException nfe) {
|
|
|
81 |
System.out.println(usage);
|
|
|
82 |
System.exit(-1);
|
|
|
83 |
}
|
| 63 |
naveen |
84 |
}
|
|
|
85 |
|
|
|
86 |
IR ir = new IR(categoryID);
|
| 81 |
naveen |
87 |
|
|
|
88 |
if (inputCommand.equals("irdata")) {
|
|
|
89 |
ir.exportIRData();
|
|
|
90 |
|
|
|
91 |
return;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
if (inputCommand.equals("irmetadata")) {
|
|
|
95 |
ir.exportIRMetaData();
|
|
|
96 |
|
|
|
97 |
return;
|
|
|
98 |
}
|
|
|
99 |
|
| 62 |
naveen |
100 |
}
|
| 63 |
naveen |
101 |
|
|
|
102 |
/**
|
|
|
103 |
*
|
|
|
104 |
* @param categoryID
|
|
|
105 |
*/
|
|
|
106 |
public IR(long categoryID) {
|
|
|
107 |
this.categoryID = categoryID;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
/**
|
| 81 |
naveen |
111 |
*
|
|
|
112 |
* @throws Exception
|
|
|
113 |
*/
|
|
|
114 |
public void exportIRMetaData() throws Exception {
|
|
|
115 |
DefinitionsContainer defs =
|
|
|
116 |
Catalog.getInstance().getDefinitionsContainer();
|
| 82 |
naveen |
117 |
|
| 81 |
naveen |
118 |
// <IRMetaData>
|
| 82 |
naveen |
119 |
List<String> xmlSnippets = new ArrayList<String>();
|
|
|
120 |
xmlSnippets.add("<IRMetaData>");
|
| 81 |
naveen |
121 |
|
| 82 |
naveen |
122 |
IRMetaDataJythonWrapper jy = new IRMetaDataJythonWrapper();
|
| 81 |
naveen |
123 |
|
|
|
124 |
// Iterate over all facet definitions
|
| 82 |
naveen |
125 |
Map<Long, FacetDefinition> facetDefs = defs.getFacetDefinitions();
|
|
|
126 |
for(FacetDefinition facetDef : facetDefs.values()) {
|
|
|
127 |
|
|
|
128 |
jy.reset();
|
|
|
129 |
jy.initialize();
|
|
|
130 |
|
|
|
131 |
ExpandedFacetDefinition expFacetDef =
|
|
|
132 |
new ExpandedFacetDefinition(facetDef);
|
|
|
133 |
|
|
|
134 |
jy.setExpandedFacetDefinition(expFacetDef);
|
|
|
135 |
|
|
|
136 |
jy.executeRule();
|
|
|
137 |
|
|
|
138 |
String facetXMLSnip = jy.getXMLSnippet();
|
|
|
139 |
Utils.info("facetXMLSnip=" + facetXMLSnip);
|
|
|
140 |
|
|
|
141 |
xmlSnippets.add(facetXMLSnip);
|
|
|
142 |
}
|
| 81 |
naveen |
143 |
|
|
|
144 |
// Iterate over all feature definitions
|
|
|
145 |
// TODO
|
|
|
146 |
|
|
|
147 |
// </IRMetaData>
|
| 82 |
naveen |
148 |
xmlSnippets.add("</IRMetaData>");
|
| 81 |
naveen |
149 |
|
| 82 |
naveen |
150 |
String irMetaDataXML = StringUtils.join(xmlSnippets, "\n");
|
| 81 |
naveen |
151 |
Utils.info(irMetaDataXML);
|
|
|
152 |
|
|
|
153 |
// Write it to file
|
|
|
154 |
String irMetaDataFilename = Utils.EXPORT_IR_PATH + "irmetadata.xml";
|
|
|
155 |
DBUtils.store(irMetaDataXML, irMetaDataFilename);
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
/**
|
| 63 |
naveen |
159 |
* @throws Exception
|
|
|
160 |
*
|
|
|
161 |
*/
|
|
|
162 |
public void exportIRData() throws Exception {
|
|
|
163 |
DefinitionsContainer defs =
|
|
|
164 |
Catalog.getInstance().getDefinitionsContainer();
|
|
|
165 |
|
|
|
166 |
EntityContainer ents =
|
|
|
167 |
Catalog.getInstance().getEntityContainer();
|
|
|
168 |
|
| 64 |
naveen |
169 |
// <IRData>
|
|
|
170 |
List<String> entityXMLSnippets = new ArrayList<String>();
|
|
|
171 |
entityXMLSnippets.add("<IRData>");
|
| 63 |
naveen |
172 |
|
| 64 |
naveen |
173 |
List<Category> categories = null;
|
|
|
174 |
if(this.categoryID != 0L) {
|
|
|
175 |
categories = new ArrayList<Category>();
|
|
|
176 |
categories.add(defs.getCategory(this.categoryID));
|
|
|
177 |
}
|
|
|
178 |
else {
|
|
|
179 |
|
|
|
180 |
// Get all categories
|
|
|
181 |
categories = defs.getChildrenCategories(10001);
|
|
|
182 |
}
|
| 63 |
naveen |
183 |
|
| 64 |
naveen |
184 |
for(Category cat : categories) {
|
|
|
185 |
long catID = cat.getID();
|
|
|
186 |
|
|
|
187 |
// Get all facets for the category
|
|
|
188 |
ExpandedCategoryFacetDefinition expCategoryFacetDef =
|
|
|
189 |
defs.getExpandedCategoryFacetDefinition(catID);
|
|
|
190 |
|
| 81 |
naveen |
191 |
List<ExpandedFacetRuleDefinition> expFacetRuleDefs =
|
|
|
192 |
expCategoryFacetDef.getExpandedFacetRuleDefinitions();
|
| 64 |
naveen |
193 |
|
|
|
194 |
// Get all entities for the category
|
|
|
195 |
List<Entity> entities = ents.getEntities(catID);
|
|
|
196 |
|
|
|
197 |
if(entities == null) {
|
|
|
198 |
continue;
|
|
|
199 |
}
|
|
|
200 |
|
|
|
201 |
// For each entity
|
| 63 |
naveen |
202 |
for(Entity entity : entities) {
|
| 64 |
naveen |
203 |
ExpandedEntity expEntity =
|
|
|
204 |
ents.getExpandedEntity(entity.getID());
|
| 63 |
naveen |
205 |
|
| 64 |
naveen |
206 |
List<String> facetXMLSnippets = new ArrayList<String>();
|
|
|
207 |
|
| 67 |
naveen |
208 |
// Collect FACETs
|
|
|
209 |
|
|
|
210 |
List<Long> facetFeatureIDs = new ArrayList<Long>();
|
|
|
211 |
|
| 63 |
naveen |
212 |
// For each facet execute Rule
|
| 81 |
naveen |
213 |
for(ExpandedFacetRuleDefinition expFacetRuleDef :
|
|
|
214 |
expFacetRuleDefs) {
|
| 64 |
naveen |
215 |
String facetXMLSnip =
|
| 81 |
naveen |
216 |
this.processFacet(expEntity, expFacetRuleDef);
|
| 63 |
naveen |
217 |
|
| 64 |
naveen |
218 |
if(!facetXMLSnip.isEmpty()) {
|
|
|
219 |
facetXMLSnippets.add(facetXMLSnip);
|
|
|
220 |
Utils.info("facetXMLSnip=" + facetXMLSnip);
|
| 63 |
naveen |
221 |
}
|
| 67 |
naveen |
222 |
|
|
|
223 |
// Collect features already covered as Facet
|
| 81 |
naveen |
224 |
if(expFacetRuleDef.getFeatureDefinition() != null) {
|
| 67 |
naveen |
225 |
facetFeatureIDs.add(
|
| 81 |
naveen |
226 |
new Long(expFacetRuleDef.getFeatureDefinitionID()));
|
| 67 |
naveen |
227 |
}
|
| 63 |
naveen |
228 |
}
|
|
|
229 |
|
| 64 |
naveen |
230 |
String facetXMLSnippetsStr =
|
|
|
231 |
StringUtils.join(facetXMLSnippets, "\n");
|
|
|
232 |
|
|
|
233 |
Utils.info("facetXMLSnippets=" + facetXMLSnippetsStr);
|
|
|
234 |
|
| 67 |
naveen |
235 |
// Collect PROPERTIES
|
|
|
236 |
String propertiesXMLSnippetsStr =
|
|
|
237 |
this.getPropertiesXMLSnippet(expEntity, facetFeatureIDs, 2);
|
| 64 |
naveen |
238 |
|
| 67 |
naveen |
239 |
Utils.info(propertiesXMLSnippetsStr);
|
|
|
240 |
|
|
|
241 |
String entityXMLSnip = this.getEntityXMLSnippet(expEntity,
|
|
|
242 |
facetXMLSnippetsStr, propertiesXMLSnippetsStr, 1);
|
|
|
243 |
|
| 64 |
naveen |
244 |
Utils.info(entityXMLSnip);
|
|
|
245 |
|
|
|
246 |
entityXMLSnippets.add(entityXMLSnip);
|
| 63 |
naveen |
247 |
}
|
|
|
248 |
}
|
| 64 |
naveen |
249 |
|
|
|
250 |
// </IRData>
|
|
|
251 |
entityXMLSnippets.add("</IRData>");
|
|
|
252 |
|
|
|
253 |
String irDataXML = StringUtils.join(entityXMLSnippets, "\n");
|
|
|
254 |
Utils.info(irDataXML);
|
|
|
255 |
|
|
|
256 |
// Write it to file
|
| 70 |
naveen |
257 |
String irDataFilename = Utils.EXPORT_IR_PATH + "irdata.xml";
|
| 64 |
naveen |
258 |
DBUtils.store(irDataXML, irDataFilename);
|
| 63 |
naveen |
259 |
}
|
| 64 |
naveen |
260 |
|
|
|
261 |
/**
|
|
|
262 |
*
|
|
|
263 |
* @param expEntity
|
|
|
264 |
* @param expFacetDef
|
|
|
265 |
* @return
|
|
|
266 |
* @throws Exception
|
|
|
267 |
*/
|
|
|
268 |
@SuppressWarnings("unchecked")
|
|
|
269 |
private String processFacet(ExpandedEntity expEntity,
|
| 81 |
naveen |
270 |
ExpandedFacetRuleDefinition expFacetRuleDef) throws Exception {
|
| 64 |
naveen |
271 |
|
| 81 |
naveen |
272 |
Utils.info("expFacetRuleDef=" + expFacetRuleDef);
|
|
|
273 |
|
| 64 |
naveen |
274 |
EntityContainer ents =
|
|
|
275 |
Catalog.getInstance().getEntityContainer();
|
|
|
276 |
|
| 81 |
naveen |
277 |
IRDataJythonWrapper jw = new IRDataJythonWrapper();
|
| 64 |
naveen |
278 |
|
|
|
279 |
jw.setExpandedEntity(expEntity);
|
| 82 |
naveen |
280 |
jw.setExpandedFacetRuleDefinition(expFacetRuleDef);
|
| 64 |
naveen |
281 |
|
|
|
282 |
// Set FeatureDefinition
|
|
|
283 |
FeatureDefinition featureDef =
|
| 81 |
naveen |
284 |
expFacetRuleDef.getFeatureDefinition();
|
|
|
285 |
|
| 64 |
naveen |
286 |
if(featureDef != null) {
|
|
|
287 |
jw.setFeatureDefinition(featureDef);
|
|
|
288 |
|
|
|
289 |
// Set Feature
|
|
|
290 |
Utils.info("featureDef.getID()=" + featureDef.getID());
|
|
|
291 |
|
| 81 |
naveen |
292 |
|
| 64 |
naveen |
293 |
Feature feature =
|
|
|
294 |
ents.getFeature(expEntity.getID(), featureDef.getID());
|
|
|
295 |
|
| 81 |
naveen |
296 |
// Can happen with un-referred features like Brand
|
|
|
297 |
if(feature != null) {
|
|
|
298 |
ExpandedFeature expFeature = new ExpandedFeature(feature);
|
|
|
299 |
|
|
|
300 |
jw.setExpandedFeature(expFeature);
|
|
|
301 |
}
|
| 64 |
naveen |
302 |
}
|
|
|
303 |
|
|
|
304 |
// Set SlideDefinition
|
| 81 |
naveen |
305 |
SlideDefinition slideDef = expFacetRuleDef.getSlideDefinition();
|
| 64 |
naveen |
306 |
if(slideDef != null) {
|
|
|
307 |
jw.setSlideDefinition(slideDef);
|
|
|
308 |
|
|
|
309 |
// Set Slide
|
|
|
310 |
Utils.info("slideDef.getID()=" + slideDef.getID());
|
|
|
311 |
|
|
|
312 |
Slide slide = ents.getSlide(expEntity.getID(), slideDef.getID());
|
| 65 |
naveen |
313 |
ExpandedSlide expSlide = new ExpandedSlide(slide);
|
| 64 |
naveen |
314 |
|
| 65 |
naveen |
315 |
jw.setExpandedSlide(expSlide);
|
| 64 |
naveen |
316 |
}
|
|
|
317 |
|
| 70 |
naveen |
318 |
// Execute Python script
|
| 82 |
naveen |
319 |
jw.executeRule();
|
| 64 |
naveen |
320 |
|
| 70 |
naveen |
321 |
// Parse returned Python list
|
| 64 |
naveen |
322 |
List<Object> values = (List<Object>)jw.getValues();
|
|
|
323 |
Utils.info("values=" + values);
|
|
|
324 |
|
|
|
325 |
String facetXMLSnip = "";
|
|
|
326 |
if(values != null) {
|
|
|
327 |
|
|
|
328 |
// Get IR Data XML snippet for this entity and facet
|
| 81 |
naveen |
329 |
facetXMLSnip = this.getFacetXMLSnippet(expFacetRuleDef, values, 2);
|
| 64 |
naveen |
330 |
}
|
|
|
331 |
Utils.info(facetXMLSnip);
|
|
|
332 |
|
|
|
333 |
return facetXMLSnip;
|
|
|
334 |
}
|
| 67 |
naveen |
335 |
|
|
|
336 |
/**
|
|
|
337 |
*
|
|
|
338 |
* @param expEntity
|
|
|
339 |
* @param facetFeatureIDs
|
|
|
340 |
* @param indent
|
|
|
341 |
* @return
|
|
|
342 |
*/
|
|
|
343 |
private String getPropertiesXMLSnippet(ExpandedEntity expEntity,
|
|
|
344 |
List<Long> facetFeatureIDs, int indent) {
|
|
|
345 |
|
|
|
346 |
List<String> xmlSnippet = new ArrayList<String>();
|
|
|
347 |
|
|
|
348 |
// Collect all free-form content here
|
|
|
349 |
List<String> ffc = new ArrayList<String>();
|
|
|
350 |
|
|
|
351 |
// Features
|
|
|
352 |
List<ExpandedSlide> expSlides = expEntity.getExpandedSlides();
|
|
|
353 |
|
|
|
354 |
for(ExpandedSlide expSlide : expSlides) {
|
|
|
355 |
List<ExpandedFeature> expFeatures = expSlide.getExpandedFeatures();
|
|
|
356 |
|
|
|
357 |
if(expSlide.getFreeformContent() != null) {
|
|
|
358 |
ffc.add(expSlide.getFreeformContent().getContent());
|
|
|
359 |
}
|
|
|
360 |
|
|
|
361 |
if(expFeatures == null) {
|
|
|
362 |
continue;
|
|
|
363 |
}
|
|
|
364 |
|
|
|
365 |
for(ExpandedFeature expFeature : expFeatures) {
|
|
|
366 |
Long featureDefID =
|
|
|
367 |
new Long(expFeature.getFeatureDefinitionID());
|
|
|
368 |
|
|
|
369 |
// FFC at feature level
|
|
|
370 |
if(expFeature.getFreeformContent() != null) {
|
|
|
371 |
ffc.add(expFeature.getFreeformContent().getContent());
|
|
|
372 |
}
|
|
|
373 |
|
|
|
374 |
// Exclude those who are already covered as facets
|
|
|
375 |
if(facetFeatureIDs.contains(featureDefID)) {
|
|
|
376 |
continue;
|
|
|
377 |
}
|
|
|
378 |
|
|
|
379 |
List<ExpandedBullet> expBullets =
|
|
|
380 |
expFeature.getExpandedBullets();
|
|
|
381 |
|
|
|
382 |
if(expBullets == null) {
|
|
|
383 |
continue;
|
|
|
384 |
}
|
|
|
385 |
|
|
|
386 |
//<Property Label="">
|
|
|
387 |
xmlSnippet.add(this.xmlIndentation[indent] +
|
|
|
388 |
"<Property Label=\"" + StringEscapeUtils.escapeXml(
|
|
|
389 |
expFeature.getFeatureDefinition().getLabel()) +
|
|
|
390 |
"\">");
|
|
|
391 |
|
|
|
392 |
//<Value></Value>
|
|
|
393 |
for(ExpandedBullet bullet : expBullets) {
|
|
|
394 |
|
|
|
395 |
// FFC at bullet level
|
|
|
396 |
if(bullet.getFreeformContent() != null) {
|
|
|
397 |
ffc.add(bullet.getFreeformContent().getContent());
|
|
|
398 |
}
|
|
|
399 |
|
|
|
400 |
xmlSnippet.add(this.xmlIndentation[indent + 1] + "<Value>" +
|
|
|
401 |
StringEscapeUtils.escapeXml(bullet.getValue()) +
|
|
|
402 |
"</Value>");
|
|
|
403 |
}
|
|
|
404 |
|
|
|
405 |
//</Property>
|
|
|
406 |
xmlSnippet.add(this.xmlIndentation[indent] + "</Property>");
|
|
|
407 |
}
|
|
|
408 |
}
|
|
|
409 |
|
|
|
410 |
// FFC as Label="Free-form Content"
|
|
|
411 |
if(!ffc.isEmpty()) {
|
|
|
412 |
xmlSnippet.add(this.xmlIndentation[indent] +
|
|
|
413 |
"<Property Label=\"Free-form Content\">");
|
|
|
414 |
|
|
|
415 |
for(String f : ffc) {
|
|
|
416 |
if(f != null) {
|
|
|
417 |
f = StringEscapeUtils.escapeXml(f);
|
|
|
418 |
|
|
|
419 |
xmlSnippet.add(this.xmlIndentation[indent + 1] + "<Value>" +
|
|
|
420 |
f + "</Value>");
|
|
|
421 |
}
|
|
|
422 |
}
|
|
|
423 |
|
|
|
424 |
xmlSnippet.add(this.xmlIndentation[indent] + "</Property>");
|
|
|
425 |
}
|
|
|
426 |
|
|
|
427 |
// Children slides
|
|
|
428 |
// TODO
|
|
|
429 |
|
|
|
430 |
return StringUtils.join(xmlSnippet, "\n");
|
|
|
431 |
}
|
| 64 |
naveen |
432 |
|
|
|
433 |
/**
|
|
|
434 |
*
|
|
|
435 |
* @param expEntity
|
|
|
436 |
* @param facetXMLSnippets
|
|
|
437 |
* @param indent
|
|
|
438 |
* @return
|
|
|
439 |
*/
|
|
|
440 |
private String getEntityXMLSnippet(ExpandedEntity expEntity,
|
| 67 |
naveen |
441 |
String facetXMLSnippets, String propertiesXMLSnippets, int indent) {
|
| 64 |
naveen |
442 |
|
|
|
443 |
//<Entity ID="40001">
|
|
|
444 |
List<String> xmlSnippet = new ArrayList<String>();
|
|
|
445 |
|
|
|
446 |
String entityID = new Long(expEntity.getID()).toString();
|
|
|
447 |
xmlSnippet.add(this.xmlIndentation[indent] + "<Entity ID=\""+ entityID +
|
|
|
448 |
"\">");
|
|
|
449 |
|
|
|
450 |
//<Category>Business Phones</Category>
|
|
|
451 |
String category = expEntity.getCategory().getLabel();
|
|
|
452 |
xmlSnippet.add(this.xmlIndentation[indent + 1] + "<Category>" +
|
| 67 |
naveen |
453 |
StringEscapeUtils.escapeXml(category) + "</Category>");
|
| 64 |
naveen |
454 |
|
|
|
455 |
//<Title>Nokia E71</Title>
|
| 67 |
naveen |
456 |
String title = StringEscapeUtils.escapeXml(expEntity.getBrand()) + " " +
|
|
|
457 |
StringEscapeUtils.escapeXml(expEntity.getModelName()) +
|
| 64 |
naveen |
458 |
((expEntity.getModelNumber() != null) ?
|
| 67 |
naveen |
459 |
(" " +
|
|
|
460 |
StringEscapeUtils.escapeXml(expEntity.getModelNumber()))
|
| 64 |
naveen |
461 |
: "");
|
|
|
462 |
|
|
|
463 |
xmlSnippet.add(this.xmlIndentation[indent + 1] +
|
| 67 |
naveen |
464 |
"<Title>" + StringEscapeUtils.escapeXml(title) + "</Title>");
|
| 64 |
naveen |
465 |
|
|
|
466 |
xmlSnippet.add(facetXMLSnippets);
|
| 67 |
naveen |
467 |
|
|
|
468 |
xmlSnippet.add(propertiesXMLSnippets);
|
| 64 |
naveen |
469 |
|
|
|
470 |
//</Entity>
|
|
|
471 |
xmlSnippet.add(this.xmlIndentation[indent] + "</Entity>");
|
|
|
472 |
|
|
|
473 |
return StringUtils.join(xmlSnippet, "\n");
|
|
|
474 |
}
|
|
|
475 |
|
|
|
476 |
/**
|
|
|
477 |
*
|
|
|
478 |
* @param expFacetDef
|
|
|
479 |
* @param values
|
|
|
480 |
* @param indent
|
|
|
481 |
* @return String XML Snippet
|
|
|
482 |
*/
|
| 81 |
naveen |
483 |
private String getFacetXMLSnippet(
|
|
|
484 |
ExpandedFacetRuleDefinition expFacetRuleDef,
|
| 64 |
naveen |
485 |
List<Object> values, int indent) {
|
| 81 |
naveen |
486 |
|
| 64 |
naveen |
487 |
// <Facet Label="Form Factor">
|
|
|
488 |
List<String> xmlSnippet = new ArrayList<String>();
|
| 81 |
naveen |
489 |
String target = expFacetRuleDef.getFacetDefinition().getTarget();
|
|
|
490 |
|
| 64 |
naveen |
491 |
xmlSnippet.add(this.xmlIndentation[indent] + "<Facet Label=\"" +
|
|
|
492 |
target + "\">");
|
|
|
493 |
|
|
|
494 |
//<Value>Candybar</Value>
|
|
|
495 |
for(Object value : values) {
|
|
|
496 |
xmlSnippet.add(this.xmlIndentation[indent + 1] + "<Value>" +
|
|
|
497 |
value.toString() + "</Value>");
|
|
|
498 |
}
|
|
|
499 |
|
|
|
500 |
//</Facet>
|
|
|
501 |
xmlSnippet.add(this.xmlIndentation[indent] + "</Facet>");
|
|
|
502 |
|
|
|
503 |
return StringUtils.join(xmlSnippet, "\n");
|
|
|
504 |
}
|
| 62 |
naveen |
505 |
}
|