Subversion Repositories SmartDukaan

Rev

Rev 10564 | Rev 11230 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10564 Rev 11142
Line 9... Line 9...
9
import in.shop2020.metamodel.core.Slide;
9
import in.shop2020.metamodel.core.Slide;
10
import in.shop2020.metamodel.definitions.Catalog;
10
import in.shop2020.metamodel.definitions.Catalog;
11
import in.shop2020.metamodel.definitions.DefinitionsContainer;
11
import in.shop2020.metamodel.definitions.DefinitionsContainer;
12
import in.shop2020.metamodel.definitions.SlideDefinition;
12
import in.shop2020.metamodel.definitions.SlideDefinition;
13
import in.shop2020.metamodel.util.ContentPojo;
13
import in.shop2020.metamodel.util.ContentPojo;
-
 
14
import in.shop2020.metamodel.util.CreationUtils;
14
import in.shop2020.metamodel.util.ExpandedBullet;
15
import in.shop2020.metamodel.util.ExpandedBullet;
15
import in.shop2020.metamodel.util.ExpandedEntity;
16
import in.shop2020.metamodel.util.ExpandedEntity;
16
import in.shop2020.metamodel.util.ExpandedFeature;
17
import in.shop2020.metamodel.util.ExpandedFeature;
17
import in.shop2020.metamodel.util.ExpertReviewPojo;
18
import in.shop2020.metamodel.util.ExpertReviewPojo;
18
import in.shop2020.metamodel.util.ItemPojo;
19
import in.shop2020.metamodel.util.ItemPojo;
Line 149... Line 150...
149
								}
150
								}
150
							}
151
							}
151
						}
152
						}
152
					}
153
					}
153
				}
154
				}
154
				if(slide.getFeatures()== null){
155
				if(slide.getFeatures()== null || slide.getFeatures().size()==0){
-
 
156
					//Lets collect all the freeform if no features are available
-
 
157
					System.out.println("Lets collect all the freeform if no features are available");
-
 
158
					FreeformContent ffc = slide.getFreeformContent();
-
 
159
					List<String> f = new ArrayList<String>();
-
 
160
					if(ffc != null){
-
 
161
						List<String> freeformTexts = slide.getFreeformContent().getFreeformTexts();
-
 
162
						if(freeformTexts.size()>0){
-
 
163
							f = Arrays.asList(StringUtils.join(freeformTexts, "\r\n").split("\r\n"));
-
 
164
						}
-
 
165
						specs.add(new Specification("", f));
-
 
166
					}
155
					log.info("Got no features for slide: " + slide.getSlideDefinitionID() + " and entity: " + entity.getID());
167
					log.info("Got no features for slide: " + slide.getSlideDefinitionID() + " and entity: " + entity.getID());
156
				}else {
168
				}else {
157
					for(Feature f : slide.getFeatures()) {
169
					for(Feature f : slide.getFeatures()) {
158
						List<String> sb = new ArrayList<String>();
170
						List<String> sb = new ArrayList<String>();
159
						if (f != null){
171
						if (f != null){
Line 165... Line 177...
165
									if(bullet != null) {
177
									if(bullet != null) {
166
										String displayText = bullet.displayText();
178
										String displayText = bullet.displayText();
167
										if(!displayText.equals("") && !displayText.equals("Not available")){
179
										if(!displayText.equals("") && !displayText.equals("Not available")){
168
											sb.add(displayText);
180
											sb.add(displayText);
169
										}
181
										}
-
 
182
									}else {
-
 
183
										if(expFeature.getFeatureDefinition().allowsBlank()){
-
 
184
											sb.add("Yes");
-
 
185
										}
170
									}
186
									}
171
								}
187
								}
172
							}
188
							}
173
							if(sb.size()>0){
189
							if(sb.size()>0){
174
								Specification spec = new Specification(expFeature.getFeatureDefinition().getLabel(), Arrays.asList(StringUtils.join(sb,", ")));
190
								Specification spec = new Specification(expFeature.getFeatureDefinition().getLabel(), Arrays.asList(StringUtils.join(sb,", ")));
175
								specs.add(spec);
191
								specs.add(spec);
176
							}
192
							}
177
						}
193
						}
178
					}
194
					}
179
				}
195
				}
180
				spGroups.add(spGroup);
196
				
181
				if(slideDefinitionId == 130133l){
197
				if(slideDefinitionId == 130133l){
182
					List<Slide> processorChildren = slide.getChildrenSlides();
198
					List<Slide> processorChildren = slide.getChildrenSlides();
183
					if(processorChildren != null) {
199
					if(processorChildren != null) {
184
						Slide processorSlide = processorChildren.get(0);
200
						Slide processorSlide = processorChildren.get(0);
185
						if(processorSlide != null) {
201
						if(processorSlide != null) {
Line 236... Line 252...
236
								}
252
								}
237
							}
253
							}
238
						}
254
						}
239
					}
255
					}
240
				}
256
				}
-
 
257
				if(spGroup!=null && spGroup.getSpecs() != null && spGroup.getSpecs().size()>0) {
-
 
258
					spGroups.add(spGroup);
-
 
259
				}
241
			}
260
			}
242
		}
261
		}
243
		return spGroups;
262
		return spGroups;
244
	}
263
	}
245
 
264
 
Line 248... Line 267...
248
		String fileNamePrefix = EntityUtils.getMediaPrefix(entity);
267
		String fileNamePrefix = EntityUtils.getMediaPrefix(entity);
249
		List<MediaPojo> images = new ArrayList<MediaPojo>();
268
		List<MediaPojo> images = new ArrayList<MediaPojo>();
250
		List<MediaPojo> videos = new ArrayList<MediaPojo>();
269
		List<MediaPojo> videos = new ArrayList<MediaPojo>();
251
		List<Slide> slides = entity.getSlides();
270
		List<Slide> slides = entity.getSlides();
252
		String entityNumber = entity.getID() + "";
271
		String entityNumber = entity.getID() + "";
-
 
272
		Media defaultMedia = null; 
253
		if(slides!=null){
273
		if(slides!=null){
254
			
-
 
255
			for(Slide slide : slides){
274
			for(Slide slide : slides){
256
				if (slide != null){
275
				if (slide != null){
257
					if(slide.getSlideDefinitionID() == 130054l){
276
					if(slide.getSlideDefinitionID() == 130054l){
258
						Media m = slide.getFreeformContent().getMedias().get("default");
277
						defaultMedia = slide.getFreeformContent().getMedias().get("default");
259
						if(m!=null){
278
						if(defaultMedia!=null){
260
							cp.setDefaultImageUrl(MessageFormat.format(IMG_URL_TEMPLATE, entity.getID()%3, entityNumber, NewVUI.computeNewFileName(fileNamePrefix, NewVUI.DEFAULT_JPG, String.valueOf(m.getCreationTime().getTime()))));
279
							cp.setDefaultImageUrl(MessageFormat.format(IMG_URL_TEMPLATE, entity.getID()%3, entityNumber, NewVUI.computeNewFileName(fileNamePrefix, NewVUI.DEFAULT_JPG, String.valueOf(defaultMedia.getCreationTime().getTime()))));
261
							cp.setThumbnailImageUrl(MessageFormat.format(IMG_URL_TEMPLATE, entity.getID()%3, entityNumber, NewVUI.computeNewFileName(fileNamePrefix, NewVUI.THUMBNAIL_JPG, String.valueOf(m.getCreationTime().getTime()))));
280
							cp.setThumbnailImageUrl(MessageFormat.format(IMG_URL_TEMPLATE, entity.getID()%3, entityNumber, NewVUI.computeNewFileName(fileNamePrefix, NewVUI.THUMBNAIL_JPG, String.valueOf(defaultMedia.getCreationTime().getTime()))));
262
							cp.setIconImageUrl(MessageFormat.format(IMG_URL_TEMPLATE, entity.getID()%3, entityNumber, NewVUI.computeNewFileName(fileNamePrefix, NewVUI.ICON_JPG, String.valueOf(m.getCreationTime().getTime()))));
281
							cp.setIconImageUrl(MessageFormat.format(IMG_URL_TEMPLATE, entity.getID()%3, entityNumber, NewVUI.computeNewFileName(fileNamePrefix, NewVUI.ICON_JPG, String.valueOf(defaultMedia.getCreationTime().getTime()))));
263
						}else {
282
						}else {
264
							log.info("Could not find default image for entity:" + entity.getID());
283
							log.info("Could not find default image for entity:" + entity.getID());
265
						}
284
						}
266
					}
285
					}
267
					else if(slide.getFreeformContent() !=null && slide.getFreeformContent().getMedias() !=null){
286
					else if(slide.getFreeformContent() !=null && slide.getFreeformContent().getMedias() !=null){
Line 276... Line 295...
276
							}
295
							}
277
						}
296
						}
278
					}
297
					}
279
				}
298
				}
280
			}
299
			}
-
 
300
			if(images.size()==0){
-
 
301
				images.add(new MediaPojo(defaultMedia.getLabel(), MessageFormat.format(IMG_URL_TEMPLATE, entity.getID()%3, entityNumber, NewVUI.computeNewFileName(fileNamePrefix, defaultMedia.getFileName(), String.valueOf(defaultMedia.getCreationTime().getTime())))));
-
 
302
			}
281
		}
303
		}
282
		cp.setImages(images);
304
		cp.setImages(images);
283
		cp.setVideos(videos);
305
		cp.setVideos(videos);
284
	}
306
	}
285
 
307
 
Line 328... Line 350...
328
		}
350
		}
329
		return packageContents; 
351
		return packageContents; 
330
	}
352
	}
331
 
353
 
332
	public static void main (String [] args) throws Exception{
354
	public static void main (String [] args) throws Exception{
-
 
355
		
333
		PojoCreator creator = new PojoCreator();
356
		PojoCreator creator = new PojoCreator();
334
		//System.out.println(creator.getShortContent(1007425l));
357
		ExpandedEntity exp = new ExpandedEntity(CreationUtils.getEntity(1003970l));
-
 
358
		creator.createAndStoreContentPojo(exp, null, "4 months Warranty");
-
 
359
		creator.updateCatalogInfo(1003970, "This is offer", null);
335
	}
360
	}
336
	
361
	
337
	public void updateCatalogInfo(long entityId, String offerText, List<ItemPojo> items) {
362
	public void updateCatalogInfo(long entityId, String offerText, List<ItemPojo> items) {
338
		ContentPojo cp = new ContentPojo(entityId);
363
		ContentPojo cp = new ContentPojo(entityId);
339
		cp.setOfferText(offerText);
364
		cp.setOfferText(offerText);