/** * The method retrieves campaigns based on customer id * * @return struts return value * @throws Exception */ @Override public String execute() throws Exception { // initializing http session object objRequest = ServletActionContext.getRequest(); // initializing http session object objSession = objRequest.getSession(); // checking for 'customerID' attribute in session if (objSession.getAttribute("customerID") != null) { if (objSession.getAttribute("activationPeriod").toString().equals("0")) { return "renewal"; } // reading the 'customerID' from session and type casting it to integer String sCustomerID = objSession.getAttribute("customerID").toString(); Integer customerID = Integer.parseInt(sCustomerID); // invoking the getData() method of CampaignsServiceImpl Object[] dataObject = objCampaignsService.getSerpData(customerID); // retrieving theb list of keywords data from dataObject lstKeywordData = (List<Integer>) dataObject[0]; // now retrieving the active keyword count and allowed keyword count activeKeywordsCount = lstKeywordData.get(0); allowedKeywordsCount = lstKeywordData.get(1); // retrieving the list of campaigns lstCampaigns = (List<Campaigns>) dataObject[1]; lstCampaignsSearch = (List<Campaigns>) dataObject[1]; lstKeywords = objCampaignsService.getRankData(customerID); try { int count5 = 0; int count10 = 0; int count20 = 0; int count30 = 0; int count100 = 0; int keywordcount = lstKeywords.size(); int keyrank; rankComparision = new RankComparision(); if (!lstKeywords.isEmpty()) { Iterator itr = lstKeywords.iterator(); while (itr.hasNext()) { Serpkeywords keys = (Serpkeywords) itr.next(); keyrank = keys.getRankGoogle(); if (keyrank <= 5 & keyrank != 0) { count5++; } if (keyrank <= 10 & keyrank != 0) { count10++; } if (keyrank <= 20 & keyrank != 0) { count20++; } if (keyrank <= 30 & keyrank != 0) { count30++; } if (keyrank <= 100 & keyrank != 0) { count100++; } } rankComparision.setKeywordsRankBelow5(count5); rankComparision.setKeywordsRankBelow10(count10); rankComparision.setKeywordsRankBelow20(count20); rankComparision.setKeywordsRankBelow30(count30); rankComparision.setKeywordsRankBelow100(count100); rankComparision.setTotalkeywords(keywordcount); } objRequest.setAttribute("highlight", "CAMPAIGN"); if (objSession.getAttribute("message") != null) { addActionMessage(objSession.getAttribute("message").toString()); objSession.removeAttribute("message"); } } catch (Exception e) { e.printStackTrace(); } return SUCCESS; } else { // if session attribute 'customerID' is null then return result parameter as 'LOGIN' // this result parameter is mapped in 'struts.xml' return LOGIN; } }
/** * The method retrieves tempKeywords based on campaign id * * @return struts return value * @throws Exception */ @Override public String execute() throws Exception { setkeywordslastupdate = new HashSet<>(); // initializing http request object objRequest = ServletActionContext.getRequest(); List lst = null; // initializing http session object objSession = objRequest.getSession(); String alerts = (String) objSession.getAttribute("alerts"); if ("on".equals(alerts)) { lstkeywords = (List<Serpkeywords>) objSession.getAttribute("lstkeywords"); objSession.removeAttribute("lstkeywords"); objSession.removeAttribute("alerts"); return SUCCESS; } try { // checking for 'customerID' attribute in session if (objSession.getAttribute("customerID") != null) { if (objRequest.getParameter("campaignId") != null) { campaignId = Integer.valueOf(objRequest.getParameter("campaignId")); } else { // reading the 'campaignID' from session and type casting it to integer campaignId = Integer.valueOf(objSession.getAttribute("campaignId").toString()); } objSession.setAttribute("campaignId", campaignId); customerId = Integer.parseInt(objSession.getAttribute("customerID").toString()); // retrieving the list of keywords object from getData method of KeywordsServiceImpl for // <campaignId> Object[] dataObject = objKeywordsService.getSerpData(campaignId, customerId); lstUpdatedKeywords = (List<Serpkeywords>) dataObject[0]; lstsocialsignalupdate = (List<KeywordsLastUpdatedForm>) dataObject[1]; lstSeoDetails = (List<Seokeyworddetails>) dataObject[3]; int count5 = 0; int count10 = 0; int count20 = 0; int count30 = 0; int count100 = 0; int keywordcount = lstUpdatedKeywords.size(); int keyrank; rankComparision = new RankComparision(); if (!lstUpdatedKeywords.isEmpty()) { Iterator itr = lstUpdatedKeywords.iterator(); while (itr.hasNext()) { Serpkeywords keys = (Serpkeywords) itr.next(); keyrank = keys.getRankGoogle(); if (keyrank <= 5 & keyrank != 0) { count5++; } if (keyrank <= 10 & keyrank != 0) { count10++; } if (keyrank <= 20 & keyrank != 0) { count20++; } if (keyrank <= 30 & keyrank != 0) { count30++; } if (keyrank <= 100 & keyrank != 0) { count100++; } } rankComparision.setKeywordsRankBelow5(count5); rankComparision.setKeywordsRankBelow10(count10); rankComparision.setKeywordsRankBelow20(count20); rankComparision.setKeywordsRankBelow30(count30); rankComparision.setKeywordsRankBelow100(count100); rankComparision.setTotalkeywords(keywordcount); } campaignName = dataObject[2].toString(); if (objSession.getAttribute("message") != null) { addActionMessage(objSession.getAttribute("message").toString()); objSession.removeAttribute("message"); } lstDisplaysettings = objKeywordsService.getCustomerSettings(customerId); // if the lstDisplaysettings object will become null the below code add one Displaysettings // object to the lstDisplaysettings object if (lstDisplaysettings.isEmpty()) { lstDisplaysettings = new ArrayList<>(); Displaysettings d = new Displaysettings(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); // making all tab active lstDisplaysettings.add(d); // adding to array list } objRequest.setAttribute("highlight", "CAMPAIGNS"); return SUCCESS; } } catch (Exception e) { e.printStackTrace(); return LOGIN; } return LOGIN; }
/** * The method retrieves campaigns based on given search key * * @return struts return value */ public String searchSerpsCampaign() { // initializing http request object objRequest = ServletActionContext.getRequest(); // initializing http session object objSession = objRequest.getSession(); // checking for 'customerID' attribute in session if (objSession.getAttribute("customerID") != null) { // reading the 'customerID' from session and type casting it to integer Integer customerID = (Integer) objSession.getAttribute("customerID"); String campaign = objRequest.getParameter("searchSerpsCampaign"); System.out.println(campaign); if (campaign.equals("Search Campaign")) { message = "Campaign name is Required"; addActionError(message); return INPUT; } // now invoking the searchCampaign() method of CampaignsServiceImpl lstCampaigns = objCampaignsService.searchCampaign(campaign, customerID); Object[] dataObject = objCampaignsService.getSerpData(customerID); lstCampaignsSearch = (List<Campaigns>) dataObject[1]; // retrieving the list of keywords lstKeywordData = (List<Integer>) dataObject[0]; // retrieving active keyword count and allowed keyword count activeKeywordsCount = lstKeywordData.get(0); allowedKeywordsCount = lstKeywordData.get(1); lstKeywords = objCampaignsService.getRankData(customerID); int count5 = 0; int count10 = 0; int count20 = 0; int count30 = 0; int count100 = 0; int keywordcount = lstKeywords.size(); int keyrank; rankComparision = new RankComparision(); if (!lstKeywords.isEmpty()) { Iterator itr = lstKeywords.iterator(); while (itr.hasNext()) { Serpkeywords keys = (Serpkeywords) itr.next(); keyrank = keys.getRankGoogle(); if (keyrank <= 5 & keyrank != 0) { count5++; } if (keyrank <= 10 & keyrank != 0) { count10++; } if (keyrank <= 20 & keyrank != 0) { count20++; } if (keyrank <= 30 & keyrank != 0) { count30++; } if (keyrank <= 100 & keyrank != 0) { count100++; } } rankComparision.setKeywordsRankBelow5(count5); rankComparision.setKeywordsRankBelow10(count10); rankComparision.setKeywordsRankBelow20(count20); rankComparision.setKeywordsRankBelow30(count30); rankComparision.setKeywordsRankBelow100(count100); rankComparision.setTotalkeywords(keywordcount); } if (lstCampaigns.isEmpty()) { message = "Sorry! Your Search Campaign not found!"; addActionMessage(message); // setMessage(message); // seacrhCampaign = campaign; // setSeacrhCampaign(seacrhCampaign); // objRequest.setAttribute("notfound", campaign); } return SUCCESS; } else { // if session attribute 'customerID' is null then return result parameter as 'LOGIN' // this result parameter is mapped in 'struts.xml' return LOGIN; } }