Subversion Repositories SmartDukaan

Rev

Rev 4706 | Rev 4964 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4706 Rev 4818
Line 36... Line 36...
36
import java.util.List;
36
import java.util.List;
37
import java.util.Map;
37
import java.util.Map;
38
import java.util.Set;
38
import java.util.Set;
39
import java.util.TreeMap;
39
import java.util.TreeMap;
40
 
40
 
-
 
41
import org.apache.commons.lang.ArrayUtils;
-
 
42
import org.apache.commons.lang.StringUtils;
-
 
43
 
41
/*
44
/*
42
 * @author rajveer 
45
 * @author rajveer 
43
 * 
46
 * 
44
 *
47
 *
45
 */
48
 */
Line 59... Line 62...
59
//			destinationDbPath = args[1];
62
//			destinationDbPath = args[1];
60
//			dryRun = args[2];
63
//			dryRun = args[2];
61
//		}
64
//		}
62
//		
65
//		
63
		ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath, destinationDbPath);
66
		ContentMigrator contentmigrator = new ContentMigrator(sourceDbPath, destinationDbPath);
64
		contentmigrator.migrateOS();
67
		contentmigrator.migrateNetwork();
65
//		contentmigrator.migrateWarrantyType();
68
//		contentmigrator.migrateWarrantyType();
66
//    	CreationUtils.storeComparisonStats(null);
69
//    	CreationUtils.storeComparisonStats(null);
67
//		contentmigrator.migrateMedia();
70
//		contentmigrator.migrateMedia();
68
		
71
		
69
		
72
		
Line 114... Line 117...
114
		
117
		
115
		
118
		
116
	}
119
	}
117
 
120
 
118
 
121
 
-
 
122
	private void migrateNetwork() throws Exception {
-
 
123
		Map<Long, Entity> map = CreationUtils.getEntities();
-
 
124
	    for (Long entityId : map.keySet()) {
-
 
125
            Entity entity = map.get(entityId);
-
 
126
            if (entity == null || entity.getSlides() == null) {
-
 
127
                continue;
-
 
128
            }
-
 
129
            
-
 
130
            for (Slide slide : entity.getSlides()) {
-
 
131
                if (slide.getSlideDefinitionID() == 130005) {
-
 
132
                	List<Feature> features = slide.getFeatures();
-
 
133
                	for(Feature f: features){
-
 
134
                		if(f.getFeatureDefinitionID()==120012){
-
 
135
                			List<Bullet> bs = f.getBullets();
-
 
136
                			for(Bullet b : bs){
-
 
137
                			String value = ((PrimitiveDataObject)b.getDataObject()).getValue();
-
 
138
                			if(value.trim().equals("")){
-
 
139
                				continue;
-
 
140
                			}
-
 
141
                			//System.out.println(value);
-
 
142
                			long enumValueID= getEnumValueForNetwork(value, entityId);
-
 
143
                			/*if(enumValueID == 110371L){
-
 
144
                				Logger.log("Set entity:" + entityId + " as proprietary software", entity);
-
 
145
                			}*/
-
 
146
                			if(enumValueID!=0){
-
 
147
                				b.setDataObject(new EnumDataObject(enumValueID));
-
 
148
                			}
-
 
149
                		}
-
 
150
                		}
-
 
151
                	}
-
 
152
                }
-
 
153
                
-
 
154
            }
-
 
155
 
-
 
156
           CreationUtils.updateEntity(entity);
-
 
157
	    }
-
 
158
	}
-
 
159
 
-
 
160
 
-
 
161
	private long getEnumValueForNetwork(String value, Long entityLong) {
-
 
162
		value = value.toLowerCase().replaceAll(" ", "");
-
 
163
		Map<String, Long> map = new HashMap<String, Long>();
-
 
164
		map.put("quadband(gsm850/900/1800/1900)",	110382L);
-
 
165
		map.put("quadband(gsm850/900/1800/1900)-sim1", 110383l);
-
 
166
		map.put("quadband(gsm850/900/1800/1900)-sim2", 110384l);
-
 
167
		map.put("triband(gsm900/1800/1900)", 110385l);
-
 
168
		map.put("triband(gsm900/1800/1900)-sim1", 110386l);
-
 
169
		map.put("triband(gsm900/1800/1900)-sim2", 110387l);
-
 
170
		map.put("dualband(gsm900/1800)", 110388l);
-
 
171
		map.put("dualband(gsm900/1800)-sim1", 110389l);
-
 
172
		map.put("dualband(gsm900/1800)-sim2", 110390l);
-
 
173
		map.put("cdma800", 110391l); //CDMA 800
-
 
174
		map.put("cdma800-sim2", 110392l); //CDMA 800-SIM 2
-
 
175
		map.put("cdma800-sim3", 110393l); //CDMA 800-SIM 3
-
 
176
		
-
 
177
		if(!StringUtils.contains(value, "sim") && StringUtils.contains(value, "850/900/1800/1900")){
-
 
178
			return map.get("quadband(gsm850/900/1800/1900)");
-
 
179
		}
-
 
180
		if(StringUtils.contains(value, "sim1") && StringUtils.contains(value, "850/900/1800/1900")){
-
 
181
			return map.get("quadband(gsm850/900/1800/1900)-sim1");
-
 
182
		}
-
 
183
		if(StringUtils.contains(value, "sim2") && StringUtils.contains(value, "850/900/1800/1900")){
-
 
184
			return map.get("quadband(gsm850/900/1800/1900)-sim2");
-
 
185
		}
-
 
186
		if(!StringUtils.contains(value, "sim") && StringUtils.contains(value, "900/1800/1900")){
-
 
187
			return map.get("triband(gsm900/1800/1900)");
-
 
188
		}
-
 
189
		if(StringUtils.contains(value, "sim1") && StringUtils.contains(value, "900/1800/1900")){
-
 
190
			return map.get("triband(gsm900/1800/1900)-sim1");
-
 
191
		}
-
 
192
		if(StringUtils.contains(value, "sim2") && StringUtils.contains(value, "900/1800/1900")){
-
 
193
			return map.get("triband(gsm900/1800/1900)-sim2");
-
 
194
		}
-
 
195
		if(!StringUtils.contains(value, "sim") && StringUtils.contains(value, "900/1800")){
-
 
196
			return map.get("dualband(gsm900/1800)");
-
 
197
		}
-
 
198
		if(StringUtils.contains(value, "sim1") && StringUtils.contains(value, "900/1800")){
-
 
199
			return map.get("dualband(gsm900/1800)-sim1");
-
 
200
		}
-
 
201
		if(StringUtils.contains(value, "sim2") && StringUtils.contains(value, "900/1800")){
-
 
202
			return map.get("dualband(gsm900/1800)-sim2");
-
 
203
		}
-
 
204
		if(StringUtils.contains(value, "cdma")){
-
 
205
			if(StringUtils.contains(value, "sim2")){
-
 
206
				return map.get("cdma800-sim2");
-
 
207
			}
-
 
208
			if(StringUtils.contains(value, "sim3")){
-
 
209
				return map.get("cdma800-sim3");
-
 
210
			}
-
 
211
			return map.get("cdma800");
-
 
212
		}
-
 
213
		else {
-
 
214
			System.out.println("Unknown networks: " + value + " : " + entityLong);
-
 
215
			return 0;
-
 
216
		}
-
 
217
	}
-
 
218
 
-
 
219
 
119
	public ContentMigrator(String sourceDbPath, String destinationDbPath) {
220
	public ContentMigrator(String sourceDbPath, String destinationDbPath) {
120
		this.sourceDbPath      = sourceDbPath;
221
		this.sourceDbPath      = sourceDbPath;
121
		this.destinationDbPath = destinationDbPath;
222
		this.destinationDbPath = destinationDbPath;
122
	}
223
	}
123
 
224