Subversion Repositories SmartDukaan

Rev

Rev 323 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 323 Rev 341
Line 26... Line 26...
26
import in.shop2020.metamodel.util.ExpandedFacetRuleDefinition;
26
import in.shop2020.metamodel.util.ExpandedFacetRuleDefinition;
27
import in.shop2020.metamodel.util.ExpandedFeature;
27
import in.shop2020.metamodel.util.ExpandedFeature;
28
import in.shop2020.metamodel.util.ExpandedFeatureDefinition;
28
import in.shop2020.metamodel.util.ExpandedFeatureDefinition;
29
import in.shop2020.metamodel.util.ExpandedSlide;
29
import in.shop2020.metamodel.util.ExpandedSlide;
30
 
30
 
-
 
31
import java.io.File;
-
 
32
import java.io.FileOutputStream;
31
import java.util.ArrayList;
33
import java.util.ArrayList;
32
import java.util.HashMap;
34
import java.util.HashMap;
33
import java.util.List;
35
import java.util.List;
34
import java.util.Map;
36
import java.util.Map;
35
 
37
 
-
 
38
import javax.xml.transform.TransformerConfigurationException;
-
 
39
import javax.xml.transform.TransformerFactory;
-
 
40
import javax.xml.transform.Transformer;
-
 
41
import javax.xml.transform.stream.StreamResult;
-
 
42
import javax.xml.transform.stream.StreamSource;
-
 
43
 
36
import org.apache.commons.lang.ArrayUtils;
44
import org.apache.commons.lang.ArrayUtils;
37
import org.apache.commons.lang.StringEscapeUtils;
45
import org.apache.commons.lang.StringEscapeUtils;
38
import org.apache.commons.lang.StringUtils;
46
import org.apache.commons.lang.StringUtils;
39
 
47
 
-
 
48
 
40
/**
49
/**
41
 * Command line utility to convert IR Definitions into IR Data and IR Meta-data
50
 * Command line utility to convert IR Definitions into IR Data and IR Meta-data
42
 * 
51
 * 
43
 * Usage: IR [irmetadata|irdata] {Category ID}
52
 * Usage: IR [irmetadata|irdata] {Category ID}
44
 * 
53
 * 
Line 99... Line 108...
99
		
108
		
100
		IR ir = new IR(categoryID);
109
		IR ir = new IR(categoryID);
101
		
110
		
102
		if (inputCommand.equals("irdata")) {
111
		if (inputCommand.equals("irdata")) {
103
			ir.exportIRData();
112
			ir.exportIRData();
104
			
113
			ir.transformIrDataXMLtoSolrXML();
105
			return;
114
			return;
106
		}
115
		}
107
		
116
		
108
		if (inputCommand.equals("irmetadata")) {
117
		if (inputCommand.equals("irmetadata")) {
109
			ir.exportIRMetaData();
118
			ir.exportIRMetaData();
110
			
-
 
-
 
119
			ir.transformIrMetaDataXMLSolrSchemaXML();
111
			return;
120
			return;
112
		}
121
		}
113
		
122
		
114
	}
123
	}
115
	
124
	
Line 119... Line 128...
119
	 */
128
	 */
120
	public IR(long categoryID) {
129
	public IR(long categoryID) {
121
		this.categoryID = categoryID;
130
		this.categoryID = categoryID;
122
	}
131
	}
123
	
132
	
-
 
133
	
-
 
134
	/**
-
 
135
	 * 
-
 
136
	 * @param inXMLFilename
-
 
137
	 * @param xslFilename
-
 
138
	 * @param outXMLFilename
-
 
139
	 * @throws Exception 
-
 
140
	 */
-
 
141
	
-
 
142
	public void xsltTransformation(String inXMLFilename, String xslFilename, String outXMLFilename) throws Exception{
-
 
143
		// Use the static TransformerFactory.newInstance() method to instantiate 
-
 
144
		  // a TransformerFactory. The javax.xml.transform.TransformerFactory 
-
 
145
		  // system property setting determines the actual class to instantiate --
-
 
146
		  // org.apache.xalan.transformer.TransformerImpl.
-
 
147
		TransformerFactory tFactory = TransformerFactory.newInstance();
-
 
148
			
-
 
149
			// Use the TransformerFactory to instantiate a Transformer that will work with  
-
 
150
			// the stylesheet you specify. This method call also processes the stylesheet
-
 
151
		  // into a compiled Templates object.
-
 
152
		Transformer transformer = tFactory.newTransformer(new StreamSource(xslFilename));
-
 
153
 
-
 
154
			// Use the Transformer to apply the associated Templates object to an XML document
-
 
155
			// (foo.xml) and write the output to a file (foo.out).
-
 
156
		transformer.transform(new StreamSource(inXMLFilename), new StreamResult(new FileOutputStream(outXMLFilename)));
-
 
157
		
-
 
158
	}
-
 
159
	
-
 
160
	/**
-
 
161
	 * 
-
 
162
	 * @throws Exception
-
 
163
	 */
-
 
164
	public void transformIrDataXMLtoSolrXML() throws Exception {
-
 
165
		String irDataFilename = Utils.EXPORT_IR_PATH + "irdata.xml";
-
 
166
		String irSolrDataFilename = Utils.EXPORT_SOLR_PATH + "irdata_solr.xml";
-
 
167
		String irXslFilename = "src/xsl/irdata_solrdata.xsl";
-
 
168
		System.out.println(irSolrDataFilename);
-
 
169
		File solrFile = new File(irSolrDataFilename);
-
 
170
		if(!solrFile.exists()){
-
 
171
			solrFile.createNewFile();
-
 
172
		}
-
 
173
		xsltTransformation(irDataFilename, irXslFilename, irSolrDataFilename);
-
 
174
	}
-
 
175
	
-
 
176
 
-
 
177
	/**
-
 
178
	 * 
-
 
179
	 * @throws Exception
-
 
180
	 */
-
 
181
	public void transformIrMetaDataXMLSolrSchemaXML() throws Exception {
-
 
182
		String irDataFilename = Utils.EXPORT_IR_PATH + "irmetadata.xml";
-
 
183
		String irSolrDataFilename = Utils.EXPORT_SOLR_PATH + "irmetadata_solrschema.xml";
-
 
184
		String irXslFilename = "src/xsl/irmetadata_solrschema.xsl";
-
 
185
		System.out.println(irSolrDataFilename);
-
 
186
		File solrFile = new File(irSolrDataFilename);
-
 
187
		if(!solrFile.exists()){
-
 
188
			solrFile.createNewFile();
-
 
189
		}
-
 
190
		xsltTransformation(irDataFilename, irXslFilename, irSolrDataFilename);
-
 
191
	}
-
 
192
	
-
 
193
	
-
 
194
 
124
	/**
195
	/**
125
	 * 
196
	 * 
126
	 * @throws Exception
197
	 * @throws Exception
127
	 */
198
	 */
128
	public void exportIRMetaData() throws Exception {
199
	public void exportIRMetaData() throws Exception {