Subversion Repositories SmartDukaan

Rev

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

Rev 24410 Rev 24413
Line 34... Line 34...
34
import org.springframework.web.bind.annotation.RequestBody;
34
import org.springframework.web.bind.annotation.RequestBody;
35
import org.springframework.web.bind.annotation.RequestMapping;
35
import org.springframework.web.bind.annotation.RequestMapping;
36
import org.springframework.web.bind.annotation.RequestMethod;
36
import org.springframework.web.bind.annotation.RequestMethod;
37
import org.springframework.web.bind.annotation.RequestParam;
37
import org.springframework.web.bind.annotation.RequestParam;
38
 
38
 
-
 
39
import com.mongodb.TaggableReadPreference;
39
import com.spice.profitmandi.common.enumuration.CounterSize;
40
import com.spice.profitmandi.common.enumuration.CounterSize;
40
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
41
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
41
import com.spice.profitmandi.common.model.BrandPerformance;
42
import com.spice.profitmandi.common.model.BrandPerformance;
42
import com.spice.profitmandi.common.model.CatalogListingModel;
43
import com.spice.profitmandi.common.model.CatalogListingModel;
43
import com.spice.profitmandi.common.model.CustomRetailer;
44
import com.spice.profitmandi.common.model.CustomRetailer;
Line 285... Line 286...
285
	{
286
	{
286
		if (catalogId == 0) {
287
		if (catalogId == 0) {
287
			catalogId = itemRepository.selectById(itemId).getCatalogItemId();
288
			catalogId = itemRepository.selectById(itemId).getCatalogItemId();
288
		}
289
		}
289
		List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
290
		List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
290
		Map<Integer, String> itemsColorMap = items.stream().collect(Collectors.toMap(Item::getId, Item::getColor));
291
		Map<Integer, String> itemsColorMap = items.stream().filter(x->x.getColor().startsWith("f_")).collect(Collectors.toMap(Item::getId, Item::getColor));
291
		List<TagListing> tags = tagListingRepository
292
		Map<Integer, TagListing> tagsMap = tagListingRepository
292
				.selectByItemIdsAndTagIds(items.stream().map(x -> x.getId()).collect(Collectors.toSet()), defaultTags);
293
				.selectByItemIdsAndTagIds(items.stream().map(x -> x.getId()).collect(Collectors.toSet()), defaultTags)
-
 
294
				.stream().collect(Collectors.toMap(TagListing::getItemId, x->x));
293
		JSONArray response = new JSONArray();
295
		JSONArray response = new JSONArray();
294
		tags.stream().forEach(x -> {
296
		itemsColorMap.keySet().stream().forEach(x -> {
-
 
297
			response.put(
-
 
298
				new JSONObject()
295
			response.put(new JSONObject().put("color", itemsColorMap.get(x.getItemId())).put("id", x.getItemId())
299
					.put("color", itemsColorMap.get(x))
296
					.put("active", x.isActive()));
300
					.put("id", x)
-
 
301
					.put("active", tagsMap.get(x)==null ? false : tagsMap.get(x).isActive()));
297
		});
302
		});
298
		model.addAttribute("response", response.toString());
303
		model.addAttribute("response", response.toString());
299
		return "response";
304
		return "response";
300
 
305
 
301
	}
306
	}