| Line 24... |
Line 24... |
| 24 |
import in.shop2020.metamodel.definitions.SlideFeatureDefinition;
|
24 |
import in.shop2020.metamodel.definitions.SlideFeatureDefinition;
|
| 25 |
import in.shop2020.metamodel.util.CreationUtils;
|
25 |
import in.shop2020.metamodel.util.CreationUtils;
|
| 26 |
import in.shop2020.metamodel.util.CreationUtils1;
|
26 |
import in.shop2020.metamodel.util.CreationUtils1;
|
| 27 |
import in.shop2020.metamodel.util.ExpandedBullet;
|
27 |
import in.shop2020.metamodel.util.ExpandedBullet;
|
| 28 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
28 |
import in.shop2020.metamodel.util.ExpandedEntity;
|
| - |
|
29 |
import in.shop2020.metamodel.util.ExpandedFeature;
|
| - |
|
30 |
import in.shop2020.metamodel.util.ExpandedSlide;
|
| 29 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
31 |
import in.shop2020.model.v1.catalog.CatalogService.Client;
|
| 30 |
import in.shop2020.model.v1.catalog.Item;
|
32 |
import in.shop2020.model.v1.catalog.Item;
|
| 31 |
import in.shop2020.model.v1.catalog.status;
|
33 |
import in.shop2020.model.v1.catalog.status;
|
| 32 |
import in.shop2020.thrift.clients.CatalogClient;
|
34 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 33 |
import in.shop2020.utils.Logger;
|
35 |
import in.shop2020.utils.Logger;
|
| Line 76... |
Line 78... |
| 76 |
*
|
78 |
*
|
| 77 |
*
|
79 |
*
|
| 78 |
*/
|
80 |
*/
|
| 79 |
|
81 |
|
| 80 |
public class ContentMigrator {
|
82 |
public class ContentMigrator {
|
| - |
|
83 |
private static final String HYPHON = "-";
|
| - |
|
84 |
private static final String SPACE = " ";
|
| 81 |
private String sourceDbPath;
|
85 |
private String sourceDbPath;
|
| 82 |
private String destinationDbPath;
|
86 |
private String destinationDbPath;
|
| 83 |
|
87 |
|
| 84 |
public static void main(String[] args) throws Exception {
|
88 |
public static void main(String[] args) throws Exception {
|
| 85 |
String usage = "Usage: ContentMigrator {source db path}{destination db path}";
|
89 |
String usage = "Usage: ContentMigrator {source db path}{destination db path}";
|
| Line 122... |
Line 126... |
| 122 |
contentmigrator.touchEntityState(1006864l);*/
|
126 |
contentmigrator.touchEntityState(1006864l);*/
|
| 123 |
//contentmigrator.clearEmptyPrimitiveBullets();
|
127 |
//contentmigrator.clearEmptyPrimitiveBullets();
|
| 124 |
//contentmigrator.migrateSoftCategories();
|
128 |
//contentmigrator.migrateSoftCategories();
|
| 125 |
//contentmigrator.updateSummaryMediaLabel();
|
129 |
//contentmigrator.updateSummaryMediaLabel();
|
| 126 |
//contentmigrator.migrateReviews();
|
130 |
//contentmigrator.migrateReviews();
|
| 127 |
contentmigrator.test();
|
131 |
contentmigrator.test1();
|
| 128 |
|
132 |
|
| 129 |
}
|
133 |
}
|
| 130 |
|
134 |
|
| - |
|
135 |
//Full run for monge Mobile content
|
| - |
|
136 |
|
| - |
|
137 |
private void test1() throws Exception{
|
| - |
|
138 |
Map<Long,Entity> entities = CreationUtils.getEntities();
|
| - |
|
139 |
System.out.println("Expert reviews:" + entities.size());
|
| - |
|
140 |
PojoCreator pc = new PojoCreator();
|
| - |
|
141 |
for(Map.Entry<Long, Entity> entry : entities.entrySet()) {
|
| - |
|
142 |
if(CreationUtils.getEntityState(entry.getKey()).getStatus().equals(EntityStatus.READY)) {
|
| - |
|
143 |
System.out.println("Updated entity:" + entry.getKey());
|
| - |
|
144 |
ExpandedEntity expEntity = new ExpandedEntity(entry.getValue());
|
| - |
|
145 |
Map<String, String > entityParams = getEntityParameters(expEntity);
|
| - |
|
146 |
List<ExpertReview> expertReviews = getExpertReviews(entry.getKey());
|
| - |
|
147 |
//context.put("expertReviews", expertReviews);
|
| - |
|
148 |
pc.createAndStoreContentPojo(expEntity, expertReviews,entityParams.get("WARRANTY"));
|
| - |
|
149 |
}
|
| - |
|
150 |
}
|
| - |
|
151 |
}
|
| - |
|
152 |
|
| 131 |
private void test() throws Exception{
|
153 |
private void test() throws Exception{
|
| 132 |
/*PojoCreator pc = new PojoCreator();
|
154 |
/*PojoCreator pc = new PojoCreator();
|
| 133 |
List<ExpertReview> expertReviews = getExpertReviews(1007379);*/
|
155 |
List<ExpertReview> expertReviews = getExpertReviews(1007379);*/
|
| 134 |
Map<Long, Entity> ee = CreationUtils.getEntities();
|
156 |
Map<Long, Entity> ee = CreationUtils.getEntities();
|
| 135 |
Map<Long, EntityState> bb = CreationUtils.getEntitiesState();
|
157 |
Map<Long, EntityState> bb = CreationUtils.getEntitiesState();
|
| Line 2929... |
Line 2951... |
| 2929 |
}
|
2951 |
}
|
| 2930 |
|
2952 |
|
| 2931 |
}
|
2953 |
}
|
| 2932 |
return expertReviews;
|
2954 |
return expertReviews;
|
| 2933 |
}
|
2955 |
}
|
| - |
|
2956 |
|
| - |
|
2957 |
private Map<String, String> getEntityParameters(ExpandedEntity expEntity)
|
| - |
|
2958 |
throws Exception {
|
| - |
|
2959 |
Map<String, String> params = new HashMap<String, String>();
|
| - |
|
2960 |
String warranty = "";
|
| - |
|
2961 |
|
| - |
|
2962 |
// Creating warranty string!
|
| - |
|
2963 |
for (Slide slide : expEntity.getSlide(130054).getChildrenSlides()) {
|
| - |
|
2964 |
if (slide.getSlideDefinitionID() == 130105) {
|
| - |
|
2965 |
ExpandedSlide expSlide = new ExpandedSlide(slide);
|
| - |
|
2966 |
Feature warrantyDurationFeature = expSlide.getExpandedFeature(120125);
|
| - |
|
2967 |
if (warrantyDurationFeature != null) {
|
| - |
|
2968 |
ExpandedFeature expFeature = new ExpandedFeature(warrantyDurationFeature);
|
| - |
|
2969 |
ExpandedBullet expBullet = expFeature.getExpandedBullets().get(0);
|
| - |
|
2970 |
if (expBullet != null) {
|
| - |
|
2971 |
String shortForm = expBullet.getUnit().getShortForm();
|
| - |
|
2972 |
|
| - |
|
2973 |
// Append 's' to month and year
|
| - |
|
2974 |
if (!expBullet.getValue().trim().equals("1")) {
|
| - |
|
2975 |
shortForm += "s";
|
| - |
|
2976 |
}
|
| - |
|
2977 |
warranty += expBullet.getValue() + SPACE + shortForm;
|
| - |
|
2978 |
}
|
| - |
|
2979 |
}
|
| - |
|
2980 |
|
| - |
|
2981 |
Feature warrantyTypeFeature = expSlide.getExpandedFeature(120219);
|
| - |
|
2982 |
if (warrantyTypeFeature != null) {
|
| - |
|
2983 |
ExpandedFeature expFeature = new ExpandedFeature(warrantyTypeFeature);
|
| - |
|
2984 |
ExpandedBullet expBullet = expFeature.getExpandedBullets().get(0);
|
| - |
|
2985 |
if (expBullet != null) {
|
| - |
|
2986 |
warranty += SPACE + expBullet.getExpandedEnumDataObject()
|
| - |
|
2987 |
.getEnumValue().getValue();
|
| - |
|
2988 |
}
|
| - |
|
2989 |
}
|
| - |
|
2990 |
|
| - |
|
2991 |
Feature warrantyCoverageFeature = expSlide.getExpandedFeature(120220);
|
| - |
|
2992 |
if (warrantyCoverageFeature != null) {
|
| - |
|
2993 |
ExpandedFeature expFeature = new ExpandedFeature(warrantyCoverageFeature);
|
| - |
|
2994 |
ExpandedBullet expBullet = expFeature.getExpandedBullets().get(0);
|
| - |
|
2995 |
if (expBullet != null) {
|
| - |
|
2996 |
warranty += SPACE + HYPHON + SPACE + expBullet.getExpandedEnumDataObject().getEnumValue().getValue();
|
| - |
|
2997 |
}
|
| - |
|
2998 |
}
|
| - |
|
2999 |
}
|
| - |
|
3000 |
}
|
| - |
|
3001 |
return params;
|
| - |
|
3002 |
}
|
| 2934 |
|
3003 |
|
| 2935 |
}
|
3004 |
}
|
| 2936 |
|
3005 |
|