| Line 1... |
Line 1... |
| 1 |
package in.shop2020.metamodel.util;
|
1 |
package in.shop2020.metamodel.util;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.metamodel.core.SpecialPage;
|
- |
|
| 4 |
import in.shop2020.metamodel.core.Entity;
|
3 |
import in.shop2020.metamodel.core.Entity;
|
| 5 |
import in.shop2020.metamodel.core.EntityState;
|
4 |
import in.shop2020.metamodel.core.EntityState;
|
| - |
|
5 |
import in.shop2020.metamodel.core.ExpertReview;
|
| - |
|
6 |
import in.shop2020.metamodel.core.ExpertReviewSource;
|
| 6 |
import in.shop2020.metamodel.core.Feature;
|
7 |
import in.shop2020.metamodel.core.Feature;
|
| 7 |
import in.shop2020.metamodel.core.Helpdoc;
|
8 |
import in.shop2020.metamodel.core.Helpdoc;
|
| 8 |
import in.shop2020.metamodel.core.Slide;
|
9 |
import in.shop2020.metamodel.core.Slide;
|
| - |
|
10 |
import in.shop2020.metamodel.core.SpecialPage;
|
| 9 |
import in.shop2020.metamodel.definitions.Catalog;
|
11 |
import in.shop2020.metamodel.definitions.Catalog;
|
| 10 |
import in.shop2020.metamodel.definitions.Category;
|
12 |
import in.shop2020.metamodel.definitions.Category;
|
| 11 |
import in.shop2020.metamodel.definitions.CategorySlideDefinition;
|
13 |
import in.shop2020.metamodel.definitions.CategorySlideDefinition;
|
| 12 |
import in.shop2020.metamodel.util.CN;
|
- |
|
| 13 |
import in.shop2020.storage.bdb.StorageManager;
|
14 |
import in.shop2020.storage.bdb.StorageManager;
|
| 14 |
import in.shop2020.util.Utils;
|
15 |
import in.shop2020.util.Utils;
|
| 15 |
|
16 |
|
| 16 |
import java.io.File;
|
17 |
import java.io.File;
|
| 17 |
import java.io.PrintWriter;
|
18 |
import java.io.PrintWriter;
|
| 18 |
import java.io.StringWriter;
|
19 |
import java.io.StringWriter;
|
| 19 |
import java.io.Writer;
|
20 |
import java.io.Writer;
|
| 20 |
import java.util.ArrayList;
|
21 |
import java.util.ArrayList;
|
| 21 |
import java.util.Collection;
|
22 |
import java.util.Collection;
|
| - |
|
23 |
import java.util.Date;
|
| - |
|
24 |
import java.util.HashMap;
|
| - |
|
25 |
import java.util.HashSet;
|
| 22 |
import java.util.List;
|
26 |
import java.util.List;
|
| 23 |
import java.util.Map;
|
27 |
import java.util.Map;
|
| - |
|
28 |
import java.util.Set;
|
| 24 |
|
29 |
|
| 25 |
/**
|
30 |
/**
|
| 26 |
* All storage and retrival utility methods
|
31 |
* All storage and retrival utility methods
|
| 27 |
* @author rajveer
|
32 |
* @author rajveer
|
| 28 |
*
|
33 |
*
|
| Line 38... |
Line 43... |
| 38 |
private static final String HELPDOC_ENTITYIDS = "HELPDOC_ENTITYIDS";
|
43 |
private static final String HELPDOC_ENTITYIDS = "HELPDOC_ENTITYIDS";
|
| 39 |
private static final String RELATED_ACCESSORIES = "RELATED_ACCESSORIES";
|
44 |
private static final String RELATED_ACCESSORIES = "RELATED_ACCESSORIES";
|
| 40 |
private static final String COMPARISON_STATS = "COMPARISON_STATS";
|
45 |
private static final String COMPARISON_STATS = "COMPARISON_STATS";
|
| 41 |
private static final String SEARCH_STATS = "SEARCH_STATS";
|
46 |
private static final String SEARCH_STATS = "SEARCH_STATS";
|
| 42 |
private static final String SYNONYMS = "SYNONYMS";
|
47 |
private static final String SYNONYMS = "SYNONYMS";
|
| - |
|
48 |
private static final String EXPERT_REVIEWS = "EXPERT_REVIEWS";
|
| - |
|
49 |
private static final String EXPERT_REVIEW_SOURCES = "EXPERT_REVIEW_SOURCES";
|
| 43 |
private static long helpDocId;
|
50 |
private static long helpDocId;
|
| 44 |
private static long specialPageId;
|
51 |
private static long specialPageId;
|
| 45 |
|
52 |
|
| 46 |
/**
|
53 |
/**
|
| 47 |
*
|
54 |
*
|
| Line 139... |
Line 146... |
| 139 |
*/
|
146 |
*/
|
| 140 |
public static void storeSynonyms(Map<String, Map<String, String>> synonyms) throws Exception {
|
147 |
public static void storeSynonyms(Map<String, Map<String, String>> synonyms) throws Exception {
|
| 141 |
StorageManager.getStorageManager().storeDataObject(CreationUtils.SYNONYMS, synonyms);
|
148 |
StorageManager.getStorageManager().storeDataObject(CreationUtils.SYNONYMS, synonyms);
|
| 142 |
}
|
149 |
}
|
| 143 |
|
150 |
|
| - |
|
151 |
|
| - |
|
152 |
/**
|
| - |
|
153 |
*
|
| - |
|
154 |
* @param Synonym that contains map of brand/category name as keys and their synonyms as values.
|
| - |
|
155 |
* @throws Exception
|
| - |
|
156 |
*/
|
| - |
|
157 |
@SuppressWarnings("unchecked")
|
| - |
|
158 |
public static Map<Long, List<ExpertReview>> getExpertReviews() throws Exception {
|
| - |
|
159 |
return (Map<Long, List<ExpertReview>>)StorageManager.getStorageManager().getDataObject(CreationUtils.EXPERT_REVIEWS);
|
| - |
|
160 |
}
|
| - |
|
161 |
|
| - |
|
162 |
/**
|
| - |
|
163 |
*
|
| - |
|
164 |
* @param Synonym that contains map of brand/category name as keys and their synonyms as values.
|
| - |
|
165 |
* @throws Exception
|
| - |
|
166 |
*/
|
| - |
|
167 |
@SuppressWarnings("unchecked")
|
| - |
|
168 |
public static List<ExpertReview> getExpertReviewByEntity(long entityId) throws Exception {
|
| - |
|
169 |
return ((Map<Long, List<ExpertReview>>)StorageManager.getStorageManager().getDataObject(CreationUtils.EXPERT_REVIEWS)).get(entityId);
|
| - |
|
170 |
}
|
| - |
|
171 |
|
| - |
|
172 |
public static Set<ExpertReviewSource> getExpertReviewSources() throws Exception {
|
| - |
|
173 |
return (Set<ExpertReviewSource>)StorageManager.getStorageManager().getDataObject(CreationUtils.EXPERT_REVIEW_SOURCES);
|
| - |
|
174 |
}
|
| - |
|
175 |
|
| - |
|
176 |
public static void addExpertReviewSource(ExpertReviewSource expertReviewSource) throws Exception {
|
| - |
|
177 |
Set<ExpertReviewSource> expertReviewSources = (Set<ExpertReviewSource>)StorageManager.getStorageManager().getDataObject(CreationUtils.EXPERT_REVIEW_SOURCES);
|
| - |
|
178 |
if(expertReviewSources == null){
|
| - |
|
179 |
expertReviewSources = new HashSet<ExpertReviewSource>();
|
| - |
|
180 |
}
|
| - |
|
181 |
expertReviewSources.add(expertReviewSource);
|
| - |
|
182 |
StorageManager.getStorageManager().storeDataObject(CreationUtils.EXPERT_REVIEW_SOURCES, expertReviewSources);
|
| - |
|
183 |
|
| - |
|
184 |
}
|
| - |
|
185 |
|
| - |
|
186 |
public static void deleteExpertReviewSource(ExpertReviewSource expertReviewSource) throws Exception {
|
| - |
|
187 |
Set<ExpertReviewSource> expertReviewSources = (Set<ExpertReviewSource>)StorageManager.getStorageManager().getDataObject(CreationUtils.EXPERT_REVIEW_SOURCES);
|
| - |
|
188 |
expertReviewSources.remove(expertReviewSource);
|
| - |
|
189 |
StorageManager.getStorageManager().storeDataObject(CreationUtils.EXPERT_REVIEW_SOURCES, expertReviewSources);
|
| - |
|
190 |
|
| - |
|
191 |
}
|
| - |
|
192 |
|
| - |
|
193 |
/**
|
| - |
|
194 |
*
|
| - |
|
195 |
* @param Synonym that contains map of brand/category name as keys and their synonyms as values.
|
| - |
|
196 |
* @throws Exception
|
| - |
|
197 |
*/
|
| - |
|
198 |
public static void storeExpertReview(long entityId, ExpertReview expertReview) throws Exception {
|
| - |
|
199 |
Map<Long, List<ExpertReview>> expertReviewMap = (Map<Long, List<ExpertReview>>)StorageManager.getStorageManager().getDataObject(CreationUtils.EXPERT_REVIEWS);
|
| - |
|
200 |
if(expertReviewMap == null){
|
| - |
|
201 |
expertReviewMap = new HashMap<Long, List<ExpertReview>>();
|
| - |
|
202 |
}
|
| - |
|
203 |
EntityState es = CreationUtils.getEntityState(entityId);
|
| - |
|
204 |
es.setMerkedReadyOn(new Date());
|
| - |
|
205 |
CreationUtils.updateEntityState(es);
|
| - |
|
206 |
List<ExpertReview> er = expertReviewMap.get(entityId);
|
| - |
|
207 |
if(er == null) {
|
| - |
|
208 |
er = new ArrayList<ExpertReview>();
|
| - |
|
209 |
expertReviewMap.put(entityId, er);
|
| - |
|
210 |
}
|
| - |
|
211 |
er.add(expertReview);
|
| - |
|
212 |
|
| - |
|
213 |
StorageManager.getStorageManager().storeDataObject(CreationUtils.EXPERT_REVIEWS, expertReviewMap);
|
| - |
|
214 |
}
|
| - |
|
215 |
|
| - |
|
216 |
public static void storeExpertReview(long entityId, List<ExpertReview> expertReviews) throws Exception {
|
| - |
|
217 |
Map<Long, List<ExpertReview>> expertReviewMap = (Map<Long, List<ExpertReview>>)StorageManager.getStorageManager().getDataObject(CreationUtils.EXPERT_REVIEWS);
|
| - |
|
218 |
expertReviewMap.put(entityId, expertReviews);
|
| - |
|
219 |
StorageManager.getStorageManager().storeDataObject(CreationUtils.EXPERT_REVIEWS, expertReviewMap);
|
| - |
|
220 |
}
|
| - |
|
221 |
|
| - |
|
222 |
public static void deleteExpertReview(long entityId, int index) throws Exception {
|
| - |
|
223 |
Map<Long, List<ExpertReview>> expertReviewMap = (Map<Long, List<ExpertReview>>)StorageManager.getStorageManager().getDataObject(CreationUtils.EXPERT_REVIEWS);
|
| - |
|
224 |
List<ExpertReview> er = expertReviewMap.get(entityId);
|
| - |
|
225 |
er.remove(index);
|
| - |
|
226 |
EntityState es = CreationUtils.getEntityState(entityId);
|
| - |
|
227 |
es.setMerkedReadyOn(new Date());
|
| - |
|
228 |
CreationUtils.updateEntityState(es);
|
| - |
|
229 |
|
| - |
|
230 |
StorageManager.getStorageManager().storeDataObject(CreationUtils.EXPERT_REVIEWS, expertReviewMap);
|
| - |
|
231 |
}
|
| - |
|
232 |
|
| - |
|
233 |
/**
|
| - |
|
234 |
*
|
| - |
|
235 |
* @param Synonym that contains map of brand/category name as keys and their synonyms as values.
|
| - |
|
236 |
* @throws Exception
|
| - |
|
237 |
*/
|
| - |
|
238 |
public static void deleteExpertReviews(long entityId) throws Exception {
|
| - |
|
239 |
Map<Long, List<ExpertReview>> expertReviewMap = (Map<Long, List<ExpertReview>>)StorageManager.getStorageManager().getDataObject(CreationUtils.EXPERT_REVIEWS);
|
| - |
|
240 |
expertReviewMap.remove(entityId);
|
| - |
|
241 |
EntityState es = CreationUtils.getEntityState(entityId);
|
| - |
|
242 |
es.setMerkedReadyOn(new Date());
|
| - |
|
243 |
CreationUtils.updateEntityState(es);
|
| - |
|
244 |
StorageManager.getStorageManager().storeDataObject(CreationUtils.EXPERT_REVIEWS, expertReviewMap);
|
| - |
|
245 |
}
|
| - |
|
246 |
|
| 144 |
|
247 |
|
| 145 |
/**
|
248 |
/**
|
| 146 |
*
|
249 |
*
|
| 147 |
* @return
|
250 |
* @return
|
| 148 |
* @throws Exception
|
251 |
* @throws Exception
|
| Line 782... |
Line 885... |
| 782 |
* delete the special pages from database.
|
885 |
* delete the special pages from database.
|
| 783 |
*/
|
886 |
*/
|
| 784 |
public static void deleteSpecialPage(long specialPageId) {
|
887 |
public static void deleteSpecialPage(long specialPageId) {
|
| 785 |
StorageManager.getStorageManager().deleteSpecialPage(specialPageId);
|
888 |
StorageManager.getStorageManager().deleteSpecialPage(specialPageId);
|
| 786 |
}
|
889 |
}
|
| 787 |
|
- |
|
| 788 |
|
- |
|
| 789 |
}
|
890 |
}
|