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; }
public Product setProduct(Product product) { Product _product = null; // Retreive product if (product.getIdProduct() != 0) { _product = this.getProduct(product.getIdProduct()); } else { _product = this.getProduct( product.getProductConf(), product.getSerialNumber(), product.getDatecode()); } // Update product components List<Product> _productComponents = this.updateProductComponents(this.getProductComponents(product)); // Update product softwares List<Software> _productSoftwares = this.updateProductSoftwares(product.getProductSoftwares()); // Save product _product = this.setProduct( _product, product.getProductConf(), product.getSerialNumber(), product.getDatecode(), _productComponents, _productSoftwares); return _product; }
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."); } } } }
/* * Création de la liste des composants du produit à partir d'une liste de * composants. * * @param productComponents Liste des composants. */ private List<Product> updateProductComponents(List<Product> productComponents) { List<Product> _productComponents = new ArrayList<Product>(); if (null != productComponents) { ProductConf _productConf = null; String _datecode; String _serialNumber; String _provider; for (Product _productComponent : productComponents) { _productConf = _productComponent.getProductConf(); _serialNumber = _productComponent.getSerialNumber(); _datecode = _productComponent.getDatecode(); _provider = _productComponent.getProviderCode(); // Retreive component _productComponent = this.getProduct(_productConf, _serialNumber, _datecode); if (null == _productComponent) { // New component _productComponent = this.addProduct(_productConf, _serialNumber, _datecode, _provider); } else { // Exiting component _productComponent.setDatecode(_datecode); _productComponent.setSerialNumber(_serialNumber); _productComponent.setProviderCode(_provider); this.updateProduct(_productComponent); } _productComponents.add(_productComponent); } } return _productComponents; }
public void displayProduct() { this.productBeanList = new ArrayList<ProductBean>(); String modele = null; java.util.Date uDate = new java.util.Date( System .currentTimeMillis()); // Relever l'heure avant le debut du progamme (en // milliseconde) System.out.println("Debut de la recherche de la liste des produits"); List<Product> _productList = this.globalService.getProductsRecordables(modele); System.out.println("Fin de la recherche de la liste des produits"); Date dateFin = new Date( System.currentTimeMillis()); // Relever l'heure a la fin du progamme (en milliseconde) Date duree = new Date(System.currentTimeMillis()); // Pour calculer la différence duree.setTime(dateFin.getTime() - uDate.getTime()); // Calcul de la différence long secondes = duree.getTime() / 1000; long min = secondes / 60; long heures = min / 60; long mili = duree.getTime() % 1000; secondes %= 60; System.out.println( "Temps passé durant le traitement : \nHeures : " + heures + "\nMinutes : " + min + "\nSecondes : " + secondes + "\nMilisecondes : " + mili + "\n"); for (Product p : _productList) { ProductBean _productBean = new ProductBean(); _productBean.setIdProduct(p.getIdProduct()); // JB : cette ligne ne semble pas servir _productBean.setSerialNumber(p.getSerialNumber()); _productBean.setProductConf(p.getFEDDProductConf()); _productBean.setDatecode(p.getDatecode()); // _productBean.getProductConf().setReference(p.getProductConf().getReference()); en // commentaire par RMO this.productBeanList.add(_productBean); } System.out.println("Fin de la recuperation des informations produits"); this.result = true; }
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; }