/**
   * @param obj : obj
   * @param dao : dao
   * @param sessionDataBean : sessionDataBean
   * @throws BizLogicException : BizLogicException
   */
  @Override
  public synchronized void postInsert(Object obj, DAO dao, SessionDataBean sessionDataBean)
      throws BizLogicException {
    final StorageContainer container = (StorageContainer) obj;
    try {
      final int noOfContainers = container.getNoOfContainers().intValue();
      final Map simMap = container.getSimilarContainerMap();
      final int checkButton = Integer.parseInt((String) simMap.get("checkedButton"));
      for (int i = 1; i <= noOfContainers; i++) {

        final String simContPrefix = "simCont:" + i + "_";
        final String contName = (String) simMap.get(simContPrefix + "name");
        final String identifier = (String) simMap.get(simContPrefix + "Id");
        final StorageContainer cont = new StorageContainer(container);
        // Logger.out.info("contName:" + contName);

        cont.setId(new Long(identifier));
        cont.setName(contName); // by falguni ...Container name is
        // generated via label generator.
        if (checkButton == 2) {
          final String parentId = (String) simMap.get(simContPrefix + "parentContainerId");
          final String posOne = (String) simMap.get(simContPrefix + "positionDimensionOne");
          final String posTwo = (String) simMap.get(simContPrefix + "positionDimensionTwo");
          final String parentContName = (String) simMap.get(simContPrefix + "parentContName");
          final StorageContainer parentContainer = new StorageContainer();
          parentContainer.setId(new Long(parentId));
          parentContainer.setName(parentContName);

          final ContainerPosition cntPos = cont.getLocatedAtPosition();

          cntPos.setPositionDimensionOne(new Integer(posOne));
          cntPos.setPositionDimensionTwo(new Integer(posTwo));
          cntPos.setOccupiedContainer(cont);
          cntPos.setParentContainer(parentContainer);

          // cont.setParent(parentContainer); // <<----

        }
      }

    } catch (final Exception e) {
      this.logger.error(e.getMessage(), e);
      e.printStackTrace();
    }
    super.postInsert(obj, dao, sessionDataBean);
  }
  /**
   * Saves the storageContainer object in the database.
   *
   * @param dao : dao
   * @param obj The storageType object to be saved.
   * @param sessionDataBean The session in which the object is saved.
   * @throws BizLogicException : BizLogicException
   */
  @Override
  protected void insert(Object obj, DAO dao, SessionDataBean sessionDataBean)
      throws BizLogicException {
    final StorageContainer container = (StorageContainer) obj;
    container.setActivityStatus(Status.ACTIVITY_STATUS_ACTIVE.toString());

    final List contList = new ArrayList();
    final int noOfContainers = container.getNoOfContainers().intValue();
    final Map simMap = container.getSimilarContainerMap();
    // --- common values for all similar containers ---
    new StorageTypeBizLogic().loadStorageType(dao, container);
    this.logger.debug(simMap);
    final int checkButton = Integer.parseInt((String) simMap.get("checkedButton"));
    // int checkButton = 1;

    try {
      for (int i = 1; i <= noOfContainers; i++) {
        final String simContPrefix = "simCont:" + i + "_";
        final String IdKey = simContPrefix + "Id";
        final String parentContNameKey = simContPrefix + "parentContName";
        final String contName = (String) simMap.get(simContPrefix + "name");
        String barcode = (String) simMap.get(simContPrefix + "barcode");

        if (barcode != null && barcode.equals("")) // this is done
        // because barcode
        // is empty string
        // set by struts
        { // but barcode in DB is unique but can be null.
          barcode = null;
        }
        final StorageContainer cont = new StorageContainer(container);
        if (checkButton == 1) // site
        {
          final String siteId = (String) simMap.get(simContPrefix + "siteId");
          final String siteName = (String) simMap.get(simContPrefix + "siteName");

          final Site site = new Site();

          /**
           * Start: Change for API Search --- Jitendra 06/10/2006 In Case of Api Search, previoulsy
           * it was failing since there was default class level initialization on domain object. For
           * example in User object, it was initialized as protected String lastName=""; So we
           * removed default class level initialization on domain object and are initializing in
           * method setAllValues() of domain object. But in case of Api Search, default values will
           * not get set since setAllValues() method of domainObject will not get called. To avoid
           * null pointer exception, we are setting the default values same as we were setting in
           * setAllValues() method of domainObject.
           */
          ApiSearchUtil.setSiteDefault(site);
          site.setId(new Long(siteId));
          site.setName(siteName);
          cont.setSite(site);
          new SiteBizLogic().loadSite(dao, cont);

        } else
        // parentContainer
        {
          StorageContainer parentContainer = null;
          final String parentId = (String) simMap.get(simContPrefix + "parentContainerId");
          final String posOne = (String) simMap.get(simContPrefix + "positionDimensionOne");
          final String posTwo = (String) simMap.get(simContPrefix + "positionDimensionTwo");

          final Object object =
              dao.retrieveById(StorageContainer.class.getName(), new Long(parentId));
          if (object != null) {

            parentContainer = (StorageContainer) object;
            cont.setSite(parentContainer.getSite());
          }

          final IFactory factory = AbstractFactoryConfig.getInstance().getBizLogicFactory();
          final StorageContainerBizLogic storageContainerBizLogic =
              (StorageContainerBizLogic) factory.getBizLogic(Constants.STORAGE_CONTAINER_FORM_ID);
          storageContainerBizLogic.checkContainer(
              dao,
              StorageContainerUtil.setparameterList(
                  parentContainer.getId().toString(), posOne, posTwo, false),
              sessionDataBean,
              null);
          ContainerPosition cntPos = cont.getLocatedAtPosition();
          if (cntPos == null) {
            cntPos = new ContainerPosition();
          }

          cntPos.setPositionDimensionOne(new Integer(posOne));
          cntPos.setPositionDimensionTwo(new Integer(posTwo));
          cntPos.setOccupiedContainer(cont);
          cntPos.setParentContainer(parentContainer);
          cont.setLocatedAtPosition(cntPos);
          // Have to set Site object for parentContainer
          SiteBizLogic siteBiz = new SiteBizLogic();
          siteBiz.loadSite(dao, parentContainer);
          siteBiz.loadSiteFromContainerId(dao, parentContainer);

          cntPos.setPositionDimensionOne(new Integer(posOne));
          cntPos.setPositionDimensionTwo(new Integer(posTwo));
          cntPos.setOccupiedContainer(cont);
          cont.setLocatedAtPosition(cntPos);
          cont.setSite(parentContainer.getSite());
          this.logger.debug("^^>> " + parentContainer.getSite());
          simMap.put(parentContNameKey, parentContainer.getName());
        }
        // StorageContainer cont = new StorageContainer();
        cont.setName(contName); // <<----
        cont.setBarcode(barcode); // <<----
        // by falguni
        // Storage container label generator

        // Call Storage container label generator if its specified to
        // use automatic label generator
        if (edu.wustl.catissuecore.util.global.Variables.isStorageContainerLabelGeneratorAvl) {
          LabelGenerator storagecontLblGenerator;
          storagecontLblGenerator =
              LabelGeneratorFactory.getInstance(
                  Constants.STORAGECONTAINER_LABEL_GENERATOR_PROPERTY_NAME);
          try {
            storagecontLblGenerator.setLabel(cont);
          } catch (LabelGenException e) {
            this.logger.error(e.getMessage(), e);
          }
        }

        simMap.put(simContPrefix + "name", cont.getName());

        this.logger.debug(
            "cont.getCollectionProtocol().size() " + cont.getCollectionProtocolCollection().size());
        cont.setActivityStatus("Active");
        dao.insert(cont.getCapacity());
        dao.insert(cont);
        contList.add(cont);
        container.setId(cont.getId());
        simMap.put(IdKey, cont.getId().toString());
      }
    } catch (final DAOException daoExp) {
      this.logger.error(daoExp.getMessage(), daoExp);
      daoExp.printStackTrace();
      throw this.getBizLogicException(daoExp, daoExp.getErrorKeyName(), daoExp.getMsgValues());
    } catch (final NameGeneratorException e) {
      this.logger.error(e.getMessage(), e);
      e.printStackTrace();
      throw this.getBizLogicException(e, "utility.error", "");
    }
  }