private void updateProductSoftwares(Product _product, String[][] productSoftwares) { _product.setProductSoftwares(new ArrayList<Software>()); if (null != productSoftwares) { Software _software; int _nbRow = productSoftwares[0].length; String _name; String _version; for (int _softwareRow = 0; _softwareRow < _nbRow; _softwareRow++) { _name = productSoftwares[1][_softwareRow]; _version = productSoftwares[2][_softwareRow]; // ServiceInterface _serviceInterface = new ServiceInterface(); // Retreive software _software = _softwareModule.getSoftware(_name, _version); if (null == _software) { // New software _software = _softwareModule.addSoftware(_name, _version); } else { // Exiting component } _product.getProductSoftwares().add(_software); } } }
/* * Sauvegarde un produit. * * @param product Produit ` enregistré. * * @param productConf Configuration du produit. * * @param serialNumber Numéro de série du produit. * * @param datecode Datecode du produit. * * @param productComponents Composants du produit. * * @param productSoftwares Logiciels du produit. * * @return Produit sauvegardé. * * @throws Exception */ private Product setProduct( Product product, ProductConf productConf, String serialNumber, String datecode, List<Product> productComponents, List<Software> productSoftwares) { Product _product = product; if (null == product) { // New product _product = this.addProduct(productConf, serialNumber, datecode); } else { // Existing product product.setProductConf(productConf); product.setSerialNumber(serialNumber); product.setDatecode(datecode); product.setProductComponents(productComponents); product.setProductSoftwares(productSoftwares); this.updateProduct(product); } // Update link between product and components this.updateProductComponents(_product, productComponents); // Update link between product and softwares this.updateProductSoftwares(_product, productSoftwares); return _product; }