Subversion Repositories SmartDukaan

Rev

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

Rev 5358 Rev 5425
Line 4... Line 4...
4
import in.shop2020.metamodel.core.EntityStatus;
4
import in.shop2020.metamodel.core.EntityStatus;
5
import in.shop2020.metamodel.definitions.Category;
5
import in.shop2020.metamodel.definitions.Category;
6
import in.shop2020.metamodel.util.CreationUtils;
6
import in.shop2020.metamodel.util.CreationUtils;
7
import in.shop2020.metamodel.util.ExpandedEntity;
7
import in.shop2020.metamodel.util.ExpandedEntity;
8
 
8
 
-
 
9
import java.util.ArrayList;
-
 
10
import java.util.List;
9
import java.util.Map;
11
import java.util.Map;
10
 
12
 
11
import org.apache.commons.logging.Log;
13
import org.apache.commons.logging.Log;
12
import org.apache.commons.logging.LogFactory;
14
import org.apache.commons.logging.LogFactory;
13
 
15
 
14
public class MostComparedIndexGenerator {
16
public class MostComparedIndexGenerator {
15
	private String[] indentation = {"", "    ", "        ", "            ","                "};
17
	private String[] indentation = {"", "    ", "        ", "            ","                "};
16
    private static Log log = LogFactory.getLog(MostComparedIndexGenerator.class);
18
    private static Log log = LogFactory.getLog(MostComparedIndexGenerator.class);
-
 
19
	private List<Long> validEntityIds;
-
 
20
 
-
 
21
	public MostComparedIndexGenerator(List<Long> valiEntityIds) {
-
 
22
		super();
-
 
23
		this.validEntityIds = valiEntityIds;
17
	
24
	}
-
 
25
 
18
	public void generate()	{
26
	public void generate()	{
19
		StringBuilder sb = new StringBuilder();
27
		StringBuilder sb = new StringBuilder();
20
		
28
		
21
		sb.append(indentation[1] + "<div>\n");
29
		sb.append(indentation[1] + "<div>\n");
22
		sb.append(indentation[2] + "<a href='http://www.saholic.com/compare-mobile-phones?p1=1002160&amp;p2=1000541'>Samsung Galaxy Y S5360 vs Samsung Galaxy Pop S5570</a>\n");
30
		sb.append(indentation[2] + "<a href='http://www.saholic.com/compare-mobile-phones?p1=1002160&amp;p2=1000541'>Samsung Galaxy Y S5360 vs Samsung Galaxy Pop S5570</a>\n");
Line 83... Line 91...
83
			e.printStackTrace();
91
			e.printStackTrace();
84
		}
92
		}
85
	}
93
	}
86
 
94
 
87
	public static void main(String[] args) {
95
	public static void main(String[] args) {
-
 
96
		List<Long> list = new ArrayList<Long>();
88
		MostComparedIndexGenerator g = new MostComparedIndexGenerator();
97
		MostComparedIndexGenerator g = new MostComparedIndexGenerator(list);
89
		g.generate();
98
		g.generate();
90
	}
99
	}
91
	
100
	
92
	private StringBuffer getAutoGeneratedComparisonLinks() throws Exception {
101
	private StringBuffer getAutoGeneratedComparisonLinks() throws Exception {
93
		Map<Long, Map<Long, Long>> comparisonStats = null;
102
		Map<Long, Map<Long, Long>> comparisonStats = null;
Line 99... Line 108...
99
				ExpandedEntity expandedEntity = new ExpandedEntity(CreationUtils.getEntity(entityId));
108
				ExpandedEntity expandedEntity = new ExpandedEntity(CreationUtils.getEntity(entityId));
100
				Category category = expandedEntity.getCategory();
109
				Category category = expandedEntity.getCategory();
101
				if(category == null){
110
				if(category == null){
102
					continue;
111
					continue;
103
				}
112
				}
104
				EntityState es = CreationUtils.getEntityState(entityId);
-
 
105
				if(EntityStatus.READY.equals(es.getStatus()) && category.getParentCategory().getID()==Utils.MOBILE_PHONES_CATAGORY) {
113
				if(this.validEntityIds.contains(entityId) && category.getParentCategory().getID()==Utils.MOBILE_PHONES_CATAGORY) {
106
					String entityName = EntityUtils.getProductName(expandedEntity);
114
					String entityName = EntityUtils.getProductName(expandedEntity);
107
					String hyphendatedName = entityName.replaceAll(" +", "-").replaceAll("/+", "-").replaceAll("-+", "-").toLowerCase();
115
					String hyphendatedName = entityName.replaceAll(" +", "-").replaceAll("/+", "-").replaceAll("-+", "-").toLowerCase();
108
					for (Long anotherEntityId : entry.getValue().keySet()) {
116
					for (Long anotherEntityId : entry.getValue().keySet()) {
109
						EntityState es1 = CreationUtils.getEntityState(anotherEntityId);
-
 
110
						ExpandedEntity anotherExpandedEntity = new ExpandedEntity(CreationUtils.getEntity(anotherEntityId));
117
						ExpandedEntity anotherExpandedEntity = new ExpandedEntity(CreationUtils.getEntity(anotherEntityId));
111
						Category anotherCategory = anotherExpandedEntity.getCategory();
118
						Category anotherCategory = anotherExpandedEntity.getCategory();
112
						if(anotherCategory == null){
119
						if(anotherCategory == null){
113
							continue;
120
							continue;
114
						}
121
						}
115
						if(EntityStatus.READY.equals(es1.getStatus()) && anotherCategory.getParentCategory().getID() == Utils.MOBILE_PHONES_CATAGORY){
122
						if(this.validEntityIds.contains(anotherEntityId) && anotherCategory.getParentCategory().getID() == Utils.MOBILE_PHONES_CATAGORY){
116
							String anotherEntityName = EntityUtils.getProductName(anotherExpandedEntity);
123
							String anotherEntityName = EntityUtils.getProductName(anotherExpandedEntity);
117
							String anotherHyphenatedName = anotherEntityName.replaceAll(" +", "-").replaceAll("/+", "-").replaceAll("-+", "-").toLowerCase();
124
							String anotherHyphenatedName = anotherEntityName.replaceAll(" +", "-").replaceAll("/+", "-").replaceAll("-+", "-").toLowerCase();
118
							sb.append(indentation[1] + "<div>\n");
125
							sb.append(indentation[1] + "<div>\n");
119
							sb.append(indentation[2] + "<a href='http://www.saholic.com/compare-mobile-phones/" + hyphendatedName + "-vs-" + anotherHyphenatedName 
126
							sb.append(indentation[2] + "<a href='http://www.saholic.com/compare-mobile-phones/" + hyphendatedName + "-vs-" + anotherHyphenatedName 
120
										+"?p1=" + entityId +"&p2="+ anotherEntityId+" '>" + entityName + " Vs "+ anotherEntityName + "</a>\n");
127
										+"?p1=" + entityId +"&p2="+ anotherEntityId+" '>" + entityName + " Vs "+ anotherEntityName + "</a>\n");