private void updateProductComponents(Product _product, String[][] productComponents) { _product.setProductComponents(new ArrayList<Product>()); if (null != productComponents) { Product _productComponent; int _nbRow = productComponents[0].length; int _idProductConf = 0; String _productConfReference; String _productConfMajorIndex; String _productConfMinorIndex; String _datecode; String _serialNumber; String _provider; for (int _componentRow = 0; _componentRow < _nbRow; _componentRow++) { if (productComponents[0][_componentRow].equals("")) { _idProductConf = Integer.parseInt(productComponents[0][_componentRow]); } _productConfReference = productComponents[1][_componentRow]; _productConfMajorIndex = productComponents[2][_componentRow]; _productConfMinorIndex = productComponents[3][_componentRow]; _datecode = productComponents[5][_componentRow]; _serialNumber = productComponents[6][_componentRow]; _provider = productComponents[7][_componentRow]; // ServiceInterface _serviceInterface = new ServiceInterface(); // Retreive productConf ProductConf _productConf = null; if (0 == _idProductConf) { _productConf = _productConfModule.getProductConf( _productConfReference, _productConfMajorIndex, _productConfMinorIndex); } else { _productConf = _productConfModule.getProductConf(_idProductConf); } if (null != _productConf) { // Retreive component _productComponent = getProduct(_productConf, _serialNumber, _datecode); if (null == _productComponent) { // New component _productComponent = addProduct(_productConf, _serialNumber, _datecode, _provider); } else { // Exiting component } _product.getProductComponents().add(_productComponent); } else { throw new IllegalStateException("Configuration produit inconnue."); } } } }
public Product setProduct( int idProduct, String productConfReference, String productConfMajorIndex, String productConfMinorIndex, String serialNumber, String datecode, String[][] productComponents, String[][] productSoftwares) { Product _product = null; ProductConf _productConf = _productConfModule.getProductConf( productConfReference, productConfMajorIndex, productConfMinorIndex); if (null != _productConf) { String _serialNumber = ToolsProduct.deleteAhead("0", serialNumber); // Retreive product _product = this.getProduct(idProduct); if (null != _product) { // Update product object _product.setProductConf(_productConf); _product.setDatecode(datecode); _product.setSerialNumber(_serialNumber); } else { _product = new Product(_productConf, datecode, _serialNumber, ""); } updateProductComponents(_product, productComponents); // Update product softwares updateProductSoftwares(_product, productSoftwares); // Save product _product = this.setProduct(_product); } else { // throw new JProductBaseException("Configuration produit inconnue."); } return _product; }
public Product retreiveProduct( String productConfReference, String serialNumber, String datecode) { Product _product = null; // Retreive productConf List<ProductConf> _productConfs = _productConfModule.getActiveProductConfs(productConfReference); Product _selectedProduct = null; for (ProductConf _productConf : _productConfs) { String _serialNumber = ToolsProduct.deleteAhead("0", serialNumber); // Retreive product _selectedProduct = this.getProduct(_productConf, _serialNumber, datecode); if (null != _selectedProduct) { _product = _selectedProduct; } } return _product; }