Subversion Repositories SmartDukaan

Rev

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

Rev 98 Rev 99
Line 1277... Line 1277...
1277
		
1277
		
1278
		DefinitionsContainer defs = 
1278
		DefinitionsContainer defs = 
1279
			Catalog.getInstance().getDefinitionsContainer();
1279
			Catalog.getInstance().getDefinitionsContainer();
1280
 
1280
 
1281
		// If unit is defined
1281
		// If unit is defined
1282
		Unit unitDef =  null;
1282
		List<Unit> unitDefs =  null;
1283
		if(bulletDef.getUnitID() != 0L) {
1283
		if(bulletDef.getUnitIDs() != null) {
-
 
1284
			unitDefs = new ArrayList<Unit>();
1284
			long unitID = bulletDef.getUnitID();
1285
			List<Long> unitIDs = bulletDef.getUnitIDs();
-
 
1286
			
-
 
1287
			for (Long unitID : unitIDs) {
1285
			unitDef = defs.getUnit(unitID);
1288
				unitDefs.add(defs.getUnit(unitID.longValue()));
-
 
1289
			}
-
 
1290
			
1286
			Utils.info("unitDef=" + unitDef);
1291
			Utils.info("unitDefs=" + unitDefs);
1287
		}
1292
		}
1288
 
1293
 
1289
		long datatypeDefID = bulletDef.getDatatypeDefinitionID();
1294
		long datatypeDefID = bulletDef.getDatatypeDefinitionID();
1290
		DatatypeDefinition datatypeDef = 
1295
		DatatypeDefinition datatypeDef = 
1291
			defs.getDatatypeDefinition(datatypeDefID);
1296
			defs.getDatatypeDefinition(datatypeDefID);
Line 1309... Line 1314...
1309
				" isPrimitive=" + isPrimitive);
1314
				" isPrimitive=" + isPrimitive);
1310
		
1315
		
1311
		// if no unit is defined for this bullet whole is treated as value
1316
		// if no unit is defined for this bullet whole is treated as value
1312
		String bulletValue = bulletText;
1317
		String bulletValue = bulletText;
1313
		Bullet bullet = null;
1318
		Bullet bullet = null;
-
 
1319
		Unit validUnitDef = null;
1314
		
1320
		
1315
		// If unit is defined
1321
		// If unit is defined
1316
		if(bulletDef.getUnitID() != 0L) {
1322
		if(unitDefs != null) {
1317
			
1323
			
1318
			// Validate unit
1324
			// Validate unit
1319
			String[] parts = StringUtils.split(bulletText, " ");
1325
			String[] parts = StringUtils.split(bulletText, " ");
1320
			if(parts.length < 2) {
1326
			if(parts.length < 2) {
1321
				Utils.severe("Unit is missing, \"" + crumb + "\" = " + 
1327
				Utils.severe("Unit is missing, \"" + crumb + "\" = " + 
Line 1333... Line 1339...
1333
			
1339
			
1334
			bulletValue = parts[0];
1340
			bulletValue = parts[0];
1335
			String unitValue = parts[1];
1341
			String unitValue = parts[1];
1336
			Utils.info("unitValue="+unitValue);
1342
			Utils.info("unitValue="+unitValue);
1337
			
1343
			
-
 
1344
			boolean isUnitValid = false;
-
 
1345
			for(Unit unitDef : unitDefs) {
1338
			if(!(unitValue.equalsIgnoreCase(unitDef.getShortForm()) ||
1346
				if(unitValue.equalsIgnoreCase(unitDef.getShortForm()) ||
1339
					unitValue.equalsIgnoreCase(unitDef.getFullForm()))) {
1347
						unitValue.equalsIgnoreCase(unitDef.getFullForm())) {
-
 
1348
					isUnitValid = true;
-
 
1349
					validUnitDef = unitDef;
-
 
1350
					break;
1340
				
1351
				}
-
 
1352
			}
-
 
1353
 
-
 
1354
			if(!isUnitValid) {
1341
				Utils.severe("Invalid unit, \"" + crumb + "\" = " + 
1355
				Utils.severe("Invalid unit, \"" + crumb + "\" = " + 
1342
						bulletText);
1356
						bulletText);
1343
 
1357
	
1344
				return null;
1358
				return null;
1345
			}
1359
			}
1346
		}
1360
		}
1347
		
1361
		
1348
		// Validate bullet value
1362
		// Validate bullet value
Line 1430... Line 1444...
1430
			}
1444
			}
1431
			
1445
			
1432
			bullet = new Bullet(compositeDataObject);
1446
			bullet = new Bullet(compositeDataObject);
1433
		}
1447
		}
1434
		
1448
		
-
 
1449
		// Set valid unit
-
 
1450
		if(bullet != null && validUnitDef != null) {
-
 
1451
			bullet.setUnitID(validUnitDef.getID());
-
 
1452
		}
-
 
1453
		
1435
		// Free-form content at bullet level
1454
		// Free-form content at bullet level
1436
		String key = prefix + "_" + bulletText;
1455
		String key = prefix + "_" + bulletText;
1437
		List<String> bulletFFCs = this.containerFCCs.get(key);
1456
		List<String> bulletFFCs = this.containerFCCs.get(key);
1438
		bullet.setFreeformContent(new FreeformContent(StringUtils.join(
1457
		bullet.setFreeformContent(new FreeformContent(StringUtils.join(
1439
				bulletFFCs, "|")));
1458
				bulletFFCs, "|")));