コード例 #1
0
 @Override
 public boolean createCampaign(BatchCampaignAssociationModel batchCampaignAssociationModel) {
   final String campaignId = batchCampaignAssociationModel.getCampaignId();
   LOGGER.info(
       "Saving newly created campaign "
           + campaignId
           + " started at : "
           + System.currentTimeMillis());
   boolean transactionStatus = true;
   Session session = sessionFactory.openSession();
   Transaction tx = null;
   try {
     tx = session.beginTransaction();
     session.save(batchCampaignAssociationModel);
     tx.commit();
   } catch (HibernateException e) {
     tx.rollback();
     transactionStatus = false;
     LOGGER.error(
         "HibernateException while saving newly created campaign with id ("
             + campaignId
             + "), "
             + e.getMessage());
   } finally {
     session.close();
   }
   LOGGER.info(
       "Newly created campaign ("
           + campaignId
           + ") saved successfully"
           + System.currentTimeMillis());
   return transactionStatus;
 }
コード例 #2
0
  public BatchCampaignAssociationModel getFilterAsInstance(HttpServletRequest request)
      throws Exception {

    BatchCampaignAssociationModel filterModel = null;
    filterModel = new BatchCampaignAssociationModel();

    if (null != request.getParameter("cid") && !"".equals(request.getParameter("cid")))
      filterModel.setCampaignId(request.getParameter("cid"));

    if (null != request.getParameter("dsc") && !"".equals(request.getParameter("dsc")))
      filterModel.setCampaignDescription(request.getParameter("dsc"));

    if (null != request.getParameter("csd") && !"".equals(request.getParameter("csd")))
      filterModel.setCampaignStartDate(
          DateUtil.convertStringToSqlDate(DATE_FORMAT, request.getParameter("csd")));

    if (null != request.getParameter("ced") && !"".equals(request.getParameter("ced")))
      filterModel.setCampaignEndDate(
          DateUtil.convertStringToSqlDate(DATE_FORMAT, request.getParameter("ced")));

    if (null != request.getParameter("rsd") && !"".equals(request.getParameter("rsd")))
      filterModel.setRegistrationStartDate(
          DateUtil.convertStringToSqlDate(DATE_FORMAT, request.getParameter("rsd")));

    if (null != request.getParameter("red") && !"".equals(request.getParameter("red")))
      filterModel.setRegistrationEndDate(
          DateUtil.convertStringToSqlDate(DATE_FORMAT, request.getParameter("red")));

    return filterModel;
  }
コード例 #3
0
  @SuppressWarnings("unchecked")
  private boolean checkForCampaignIDExist(
      final Session session, final BatchCampaignAssociationModel batchCampaignAssociationModel)
      throws HibernateException {
    // Session session = null;
    List<BatchCampaignAssociationModel> list = Collections.emptyList();
    boolean campIdExist = true;
    final String campId = batchCampaignAssociationModel.getCampaignId();
    try {
      // session = sessionFactory.openSession();
      final String hql =
          "from BatchCampaignAssociationModel where campaignId =:cmpid and campaignType =:cmpType";
      // QC-1257 (change from Prelink to Targeted)
      list = session.createQuery(hql).setString("cmpid", campId).setString("cmpType", "T").list();

      if (list.size() > 0) {
        campIdExist = false;
        // session = null;
        // session = sessionFactory.openSession();
        final String uhql =
            "update BatchCampaignAssociationModel set campaignId = :cid, batchFileNo = :bfN, campaignStartDate = :csD, "
                + "campaignEndDate = :ceD, registrationStartDate = :rsD, registrationEndDate = :reD, "
                + "registrationRequired = :rReq, campaignType = :cT, commentsRequired = :cR, campaignDescription = :cD where id = :d";
        for (BatchCampaignAssociationModel b : list) {

          Query query = session.createQuery(uhql);
          query.setString("cid", batchCampaignAssociationModel.getCampaignId());
          query.setString("bfN", batchCampaignAssociationModel.getBatchFileNo());
          query.setDate("csD", batchCampaignAssociationModel.getCampaignStartDate());
          query.setDate("ceD", batchCampaignAssociationModel.getCampaignEndDate());
          query.setDate("rsD", batchCampaignAssociationModel.getRegistrationStartDate());
          query.setDate("reD", batchCampaignAssociationModel.getRegistrationEndDate());
          query.setParameter("rReq", batchCampaignAssociationModel.getRegistrationRequired());
          query.setString("cT", batchCampaignAssociationModel.getCampaignType());
          query.setParameter("cR", batchCampaignAssociationModel.getCommentsRequired());
          query.setString("cD", batchCampaignAssociationModel.getCampaignDescription());
          query.setInteger("d", b.getId());

          int rowCount = query.executeUpdate();
          LOGGER.info(
              rowCount > 0
                  ? "Update BatchCampaignAssociation table is successful with campaignid : "
                      + campId
                  : "Failed to update BatchCampaignAssociation table with campaignid : " + campId);
        }
      }
    } catch (HibernateException e) {
      LOGGER.error("Error in checking and updating campaign details with id : " + campId);
      throw e;
    } finally {
      // session.close();
      // batchCampaignAssociationModel = null;
    }
    return campIdExist;
  }