Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5638 amit.gupta 1
package in.shop2020.util;
2
 
3
import in.shop2020.metamodel.core.Entity;
4
import in.shop2020.metamodel.util.CreationUtils;
5
import in.shop2020.metamodel.util.ExpandedEntity;
6
 
7
import java.util.Arrays;
8
import java.util.List;
9
 
10
public class ProductDocumentsGenerator {
11
	private String[] indentation = {"", "    ", "        ", "            ","                "};
12
	private List<Entity> entities;
13
 
14
 
15
	public ProductDocumentsGenerator(List<Entity> allValidEntities) {
16
		this.entities = allValidEntities;
17
	}
18
 
19
	public void generate() throws Exception {
20
		StringBuffer sb = new StringBuffer();
21
		for ( Entity entity : entities) {
22
			ExpandedEntity ex = new ExpandedEntity(entity);
23
			if(ex.getCategory().getParentCategory().isComparable()) {
24
	 			String productName = EntityUtils.getProductName(ex);
25
				String productUrl = productName.toLowerCase().replace(' ', '-');
26
				productUrl = productUrl.replaceAll("/", "-").replaceAll("-+", "-");
27
				productUrl = "/product-documents/" + productUrl + "-user-manual-software-updates-how-to-" + entity.getID();
28
				sb.append("<div>\n");
29
				sb.append(indentation[1] + "<a href='" + productUrl + "'>");
30
				sb.append(productName + " User manual, Software updates and how to");
31
				sb.append("</div>\n");
32
				sb.append("</a>\n");
33
			}
34
		}
35
		String indexFilename = Utils.EXPORT_PARTNERS_CONTENT_PATH + "product-documents.html";
36
 
37
		try	{
38
			DBUtils.store(sb.toString(), indexFilename);
39
 
40
		} catch (Exception e) {
41
			e.printStackTrace();
42
		}
43
	}
44
 
45
	public static void main (String [] args) throws Exception {
46
		ProductDocumentsGenerator asg = new ProductDocumentsGenerator(Arrays.asList(CreationUtils.getEntity(1001715l), CreationUtils.getEntity(1001715l), CreationUtils.getEntity(1003884l)));
47
		asg.generate();
48
	}
49
}