コード例 #1
0
  /*
   * 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;
  }
コード例 #2
0
  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.");
        }
      }
    }
  }