Subversion Repositories SmartDukaan

Rev

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

Rev 250 Rev 310
Line 2... Line 2...
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.creation.util;
4
package in.shop2020.creation.util;
5
 
5
 
6
import in.shop2020.metamodel.core.Entity;
6
import in.shop2020.metamodel.core.Entity;
-
 
7
import in.shop2020.metamodel.core.Slide;
-
 
8
import in.shop2020.metamodel.definitions.Catalog;
-
 
9
import in.shop2020.metamodel.definitions.CategorySlideDefinition;
-
 
10
import in.shop2020.metamodel.definitions.DefinitionsContainer;
-
 
11
import in.shop2020.metamodel.definitions.SlideDefinition;
7
import in.shop2020.util.DBUtils;
12
import in.shop2020.util.DBUtils;
8
import in.shop2020.util.Utils;
13
import in.shop2020.util.Utils;
9
 
14
 
10
import java.io.File;
15
import java.io.File;
11
import java.io.PrintWriter;
16
import java.io.PrintWriter;
12
import java.io.StringWriter;
17
import java.io.StringWriter;
13
import java.io.Writer;
18
import java.io.Writer;
14
import java.util.ArrayList;
19
import java.util.ArrayList;
-
 
20
import java.util.HashMap;
15
import java.util.List;
21
import java.util.List;
16
import java.util.Map;
22
import java.util.Map;
17
 
23
 
18
import org.apache.juli.logging.Log;
24
import org.apache.juli.logging.Log;
19
import org.apache.juli.logging.LogFactory;
25
import org.apache.juli.logging.LogFactory;
Line 160... Line 166...
160
		return getSlideSequence(catSlides);
166
		return getSlideSequence(catSlides);
161
	}
167
	}
162
	
168
	
163
	/**
169
	/**
164
	 * 
170
	 * 
-
 
171
	 * @param entityID
-
 
172
	 * @return
-
 
173
	 */
-
 
174
	public static List<Long> getSlideSequence(long entityID, long categoryID) throws Exception {
-
 
175
		Map<Long, List<Long>> catSlides = getRawSlideSequence(entityID);
-
 
176
		
-
 
177
		return getOrderedSlideSequence(catSlides, categoryID);
-
 
178
	}
-
 
179
	
-
 
180
	/**
-
 
181
	 * 
165
	 * @param catSlides
182
	 * @param catSlides
166
	 * @return
183
	 * @return
167
	 * @throws Exception
184
	 * @throws Exception
168
	 */
185
	 */
169
	public static List<Long> getSlideSequence(Map<Long, List<Long>> catSlides) 
186
	public static List<Long> getSlideSequence(Map<Long, List<Long>> catSlides) 
170
		throws Exception {
187
		throws Exception {
171
		if(catSlides == null) {
188
		if(catSlides == null) {
172
			return null;
189
			return null;
173
		}
190
		}
174
		
-
 
-
 
191
		log.info(" IN GetSlideSequence" );
175
		List<Long> slideDefIDs = new ArrayList<Long>();
192
		List<Long> slideDefIDs = new ArrayList<Long>();
176
		
193
		
177
		for(Long catID : catSlides.keySet()) {
194
		for(Long catID : catSlides.keySet()) {
178
			slideDefIDs.addAll(catSlides.get(catID));
195
			slideDefIDs.addAll(catSlides.get(catID));
179
		}
196
		}
Line 181... Line 198...
181
		return slideDefIDs;
198
		return slideDefIDs;
182
	}
199
	}
183
	
200
	
184
	/**
201
	/**
185
	 * 
202
	 * 
-
 
203
	 * @param catSlides
-
 
204
	 * @param categoryID
-
 
205
	 * @return
-
 
206
	 * @throws Exception
-
 
207
	 */
-
 
208
	public static List<Long> getOrderedSlideSequence(Map<Long, List<Long>> catSlides, Long categoryID) 
-
 
209
		throws Exception {
-
 
210
		if(catSlides == null) {
-
 
211
			return null;
-
 
212
		}
-
 
213
		
-
 
214
		List<Long> slideDefIDs = new ArrayList<Long>();
-
 
215
		List<Long> orderedSlideDefIDs = new ArrayList<Long>();
-
 
216
		
-
 
217
		DefinitionsContainer defs = Catalog.getInstance().getDefinitionsContainer();
-
 
218
		List<Long> categorySlideSequence = defs.getCategorySlideSequence(categoryID);
-
 
219
		
-
 
220
		
-
 
221
		for(Long catID : catSlides.keySet()) {
-
 
222
			slideDefIDs.addAll(catSlides.get(catID));
-
 
223
		}
-
 
224
		log.info("slideDefIDs:" + slideDefIDs);
-
 
225
		
-
 
226
		Map<String,Long> labelIDMap = new HashMap<String, Long>();
-
 
227
		for(long slideDefID : slideDefIDs){
-
 
228
			labelIDMap.put(defs.getSlideDefinition(slideDefID).getLabel(), slideDefID);
-
 
229
		}
-
 
230
		log.info("labelIDMap:" + labelIDMap);
-
 
231
		
-
 
232
		for(Long slideID : categorySlideSequence){
-
 
233
			String currentSlideLabel = defs.getSlideDefinition(slideID).getLabel();
-
 
234
			if(labelIDMap.containsKey(currentSlideLabel)){
-
 
235
				orderedSlideDefIDs.add(labelIDMap.get(currentSlideLabel));
-
 
236
				labelIDMap.remove(currentSlideLabel);
-
 
237
			}
-
 
238
		}
-
 
239
		log.info("orderedSlideDefIDs:" + orderedSlideDefIDs);
-
 
240
		
-
 
241
		for(String label : labelIDMap.keySet()){
-
 
242
			orderedSlideDefIDs.add(labelIDMap.get(label));
-
 
243
			labelIDMap.remove(label);
-
 
244
		}
-
 
245
		log.info(" orderedSlideDefIDs:" + orderedSlideDefIDs);
-
 
246
		return orderedSlideDefIDs;
-
 
247
	}
-
 
248
	
-
 
249
	/**
-
 
250
	 * 
186
	 * @param entities
251
	 * @param entities
187
	 * @param entitiesByCategory
252
	 * @param entitiesByCategory
188
	 * @throws Exception
253
	 * @throws Exception
189
	 */
254
	 */
190
	public static void rewriteRepository(Map<Long, Entity> entities, 
255
	public static void rewriteRepository(Map<Long, Entity> entities,