CPD Results

The following document contains the results of PMD's CPD 3.9.

Duplications

FileLine
fr/hyphonem/conges/data/EmployeeData.java83
fr/hyphonem/conges/forms/ModifyUserForm.java259
	}

	/**
	 * @return pays
	 */
	public String getPays() {
		return pays;
	}

	/**
	 * @param string
	 */
	public void setPays(String string) {
		pays = string;
	}

	/**
	 * @return team
	 */
	public String getTeam() {
		return team;
	}

	/**
	 * @param string
	 */
	public void setTeam(String string) {
		team = string;
	}

	/**
	 * @return Returns the entryDate.
	 */
	public String getEntryDate() {
		return entryDate;
	}

	/**
	 * @param entryDate
	 *            The entryDate to set.
	 */
	public void setEntryDate(String entryDate) {
		this.entryDate = entryDate;
	}

	public boolean isDayoff1() {
		return dayoff1;
	}

	public void setDayoff1(boolean dayoff1) {
		this.dayoff1 = dayoff1;
	}

	public boolean isDayoff2() {
		return dayoff2;
	}

	public void setDayoff2(boolean dayoff2) {
		this.dayoff2 = dayoff2;
	}

	public boolean isDayoff3() {
		return dayoff3;
	}

	public void setDayoff3(boolean dayoff3) {
		this.dayoff3 = dayoff3;
	}

	public boolean isDayoff4() {
		return dayoff4;
	}

	public void setDayoff4(boolean dayoff4) {
		this.dayoff4 = dayoff4;
	}

	public boolean isDayoff5() {
		return dayoff5;
	}

	public void setDayoff5(boolean dayoff5) {
		this.dayoff5 = dayoff5;
	}

	public boolean isDayoff6() {
		return dayoff6;
	}

	public void setDayoff6(boolean dayoff6) {
		this.dayoff6 = dayoff6;
	}

	public boolean isDayoff7() {
		return dayoff7;
	}

	public void setDayoff7(boolean dayoff7) {
		this.dayoff7 = dayoff7;
	}
}

FileLine
fr/hyphonem/conges/AccessDataXMLImpl.java1839
fr/hyphonem/conges/AccessDataXMLImpl.java2044
				Iterator iterPendingEvents = listOfPendingEvents.iterator();
				while (iterPendingEvents.hasNext()) {
					Element event = (Element) iterPendingEvents.next();
					PendingEventData ped = new PendingEventData();
					context = JXPathContext.newContext(event);
					ped.setId((String) context.getValue("/id"));
					ped.setIdcal((String) context.getValue("/idcal"));
					ped.setDatedeb((String) context.getValue("/datedeb"));
					ped.setDatefin((String) context.getValue("/datefin"));
					ped.setRaison((String) context.getValue("/raison"));
					ped.setNom((String) context.getValue("/nom"));
					ped.setPrenom((String) context.getValue("/prenom"));
					ped.setNbjours((String) context.getValue("/nbjours"));
					ped.setType((String) context.getValue("/cause"));
					ped.setCbmatin(Boolean.parseBoolean((String) context
							.getValue("/matin")));
					ped.setCbaprem(Boolean.parseBoolean((String) context
							.getValue("/aprem")));

FileLine
fr/hyphonem/conges/actions/ValidateEvtAction.java88
fr/hyphonem/conges/actions/ValidateModifEvtAction.java67
		String datedeb = absForm.getDatedeb();
		String datefin = absForm.getDatefin();

		// on verifie si les dates d'absence ne sont pas avant la date d'entrÔø?e
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");

		String entrydate = "";
		Date datedeb_d = sdf.parse(datedeb);
		Date datefin_d = sdf.parse(datefin);
		Date entryDate_d = null;
		if (employee.getEntryDate() != null
				&& !employee.getEntryDate().equals("")) {
			entryDate_d = sdf.parse(employee.getEntryDate());
			entrydate = employee.getEntryDate();
		}

		if (entryDate_d != null) {
			if (datedeb_d.before(entryDate_d) && datefin_d.before(entryDate_d)) {
				errors.add("error.abs.before.entry.date", new ActionError(
						"error.abs.before.entry.date"));
			} else if (datedeb_d.before(entryDate_d)
					&& datefin_d.after(entryDate_d)) {
				datedeb = entrydate;
			}
		}

		if (!errors.isEmpty()) {
			saveErrors(request, errors);
			return mapping.getInputForward();
		}
		String id = absForm.getId();

FileLine
fr/hyphonem/conges/CommonCal.java730
fr/hyphonem/conges/CommonCal.java815
					String datefin = param.getDateFin();

					// format attendu jj/mm
					int idx = datedeb.indexOf("/");
					if (idx > -1 && idx < datedeb.length()) {
						String jjdeb = datedeb.substring(0, idx);
						String mmdeb = datedeb.substring(idx + 1);
						String jjfin = datefin.substring(0, idx);
						String mmfin = datefin.substring(idx + 1);

						int debMonth = new Integer(mmdeb).intValue();
						int finMonth = new Integer(mmfin).intValue();
						int debDay = new Integer(jjdeb).intValue();
						int finDay = new Integer(jjfin).intValue();

						Calendar cal = Calendar.getInstance();

						int currentMonth = cal.get(Calendar.MONTH) + 1;
						if (currentMonth >= debMonth) {
							// on est dans la meme annee
							int year = cal.get(Calendar.YEAR);
							cal.set(year, debMonth - 1, debDay);

FileLine
fr/hyphonem/conges/AccessDataXMLImpl.java533
fr/hyphonem/conges/AccessDataXMLImpl.java1257
			String xpath = "/users/user[login=\"" + login + "\"]";
			Element user = (Element) context.selectSingleNode(xpath);
			context = JXPathContext.newContext(user);
			ud = new UserData();
			ud.setLogin((String) context.getValue("login"));
			ud.setPassword((String) context.getValue("password"));
			ud.setEmail((String) context.getValue("email"));
			ud.setEmployee(Boolean.parseBoolean((String) context
					.getValue("employee")));
			ud.setModif(Boolean
					.parseBoolean((String) context.getValue("modif")));
			ud.setNom((String) context.getValue("nom"));
			ud.setPrenom((String) context.getValue("prenom"));
			ud.setTeam((String) context.getValue("team"));
			// FIN JXPATH
		} else {
			ud = null;
		// System.out.println("fin AccessDataXMLImpl readUsers");
		}

		return ud;
	}

	/**
	 * write a new employee
	 * 
	 * @param employee -
	 *            EmployeeData
	 * @param modif -
	 *            boolean
	 * @param delete -
	 *            boolean
	 * @throws Exception
	 */
	public void writeEmployee(EmployeeData employee, boolean modif,

FileLine
fr/hyphonem/conges/AccessDataXMLImpl.java1688
fr/hyphonem/conges/AccessDataXMLImpl.java2303
		String pathFileName = dataDirPath + File.separator + fileName;
		File pendingEventsDataFile = new File(pathFileName);

		if (pendingEventsDataFile.exists()) {
			doc = constructeur.parse(pendingEventsDataFile);
			root = doc.getFirstChild();
		} else {
			doc = constructeur.newDocument();
			root = doc.createElement("events");
			doc.appendChild(root);
		}

		// creation du noeud
		Element nodePrincipal = doc.createElement("event");

		// creation du noeud nom
		String nom = employee.getNom();
		Element nodenom = doc.createElement("nom");
		nodenom.appendChild(doc.createTextNode(nom));

		String prenom = employee.getPrenom();
		Element nodeprenom = doc.createElement("prenom");
		nodeprenom.appendChild(doc.createTextNode(prenom));

		String equipe = employee.getTeam();
		Element nodeequipe = doc.createElement("equipe");
		nodeequipe.appendChild(doc.createTextNode(equipe));

FileLine
fr/hyphonem/conges/actions/CreateEvtAction.java40
fr/hyphonem/conges/actions/ModifEvtAction.java41
	public ModifEvtAction() {
		super();
	}

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws java.io.IOException, ServletException {
		HttpSession session = request.getSession();
		if (session.getAttribute("user") == null) {
			return mapping.findForward("invalidsession");
		}

		String date = request.getParameter("date");
		if (date == null) {
			// on met la date du jour
			Calendar today = Calendar.getInstance();
			int day = today.get(Calendar.DAY_OF_MONTH);
			int month = today.get(Calendar.MONTH) + 1;
			int year = today.get(Calendar.YEAR);
			date = day + "/" + month + "/" + year;
		}
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
		Date dateDeb;
		try {
			dateDeb = sdf.parse(date);
			AbsForm absenceForm = new AbsForm();

FileLine
fr/hyphonem/conges/actions/ValidNationalDaysAction.java60
fr/hyphonem/conges/actions/ValidNationalDaysAction.java149
	public ActionForward delete(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		HttpSession session = request.getSession();
		if (session.getAttribute("user") == null) {
			return mapping.findForward("invalidsession");
		}

		UserData userd = (UserData) session.getAttribute("user");
		// admin only
		if (userd.isModif() || userd.isEmployee()) {
			return mapping.findForward("invalidaction");
		}
		ActionErrors errors = new ActionErrors();

		String dataDirPath = (String) session.getAttribute("dataDirPath");
		AccessData ad = new AccessDataMng().getInstance(dataDirPath);
		NationalDaysForm ndf = (NationalDaysForm) form;

		String annee = ndf.getAnnee();
		session.setAttribute("year", annee);
		String pays = ndf.getPays();
		session.setAttribute("pays", pays);

		String[] checks = ndf.getCheckboxes();

FileLine
fr/hyphonem/conges/AccessDataXMLImpl.java1745
fr/hyphonem/conges/AccessDataXMLImpl.java2368
			} else if (originalEvent.isCbaprem() || originalEvent.isCbmatin()) {
				jourAjout = 0.5;
			}

			nombreJours += jourAjout;
		}

		Date datedebcal = sdf.parse(datedeb);
		Date datefincal = sdf.parse(datefin);

		if (datedebcal.before(datedebwd)) {
			datedeb = sdf.format(datedebwd);
		}
		if (datefincal.after(datefinwd)) {
			datefin = sdf.format(datefinwd);
		}

		Element nodedatedeb = doc.createElement("datedeb");
		nodedatedeb.appendChild(doc.createTextNode(datedeb));

		Element nodedatefin = doc.createElement("datefin");
		nodedatefin.appendChild(doc.createTextNode(datefin));

		Element nodenbjours = doc.createElement("nbjours");
		nodenbjours.appendChild(doc.createTextNode("" + nombreJours));

		String raison = originalEvent.getRaison();

FileLine
fr/hyphonem/conges/AccessDataXMLImpl.java1724
fr/hyphonem/conges/AccessDataXMLImpl.java2347
		Hashtable hjf = jf.getNationalDays(datedeb, datefin, codePays, dirWeb);
		Vector lstOfworkingDaysInCalData = common.getDiscretCalData(lstCal,
				employee, hjf);
		Iterator iter = lstOfworkingDaysInCalData.iterator();
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
		Date datedebwd = sdf.parse("01/01/2050");
		Date datefinwd = sdf.parse("10/12/1973");
		while (iter.hasNext()) {
			CalendarData caldata = (CalendarData) iter.next();
			Date datedeb_d = sdf.parse(caldata.getDatedeb());
			Date datefin_d = sdf.parse(caldata.getDatefin());
			if (datedeb_d.before(datedebwd)) {
				datedebwd = datedeb_d;
			}
			if (datefin_d.after(datefinwd)) {
				datefinwd = datefin_d;
			}

			double jourAjout = 0.0;
			if (originalEvent.isCbaprem() && originalEvent.isCbmatin()) {

FileLine
fr/hyphonem/conges/forms/CreateUserForm.java132
fr/hyphonem/conges/forms/ModifyUserForm.java78
		if (password == null || password.equals("")) {
			errors.add("password.required",
					new ActionError("password.required"));
		}
		if (nom == null || nom.equals("")) {
			errors.add("nom.required", new ActionError("nom.required"));
		}
		if (prenom == null || prenom.equals("")) {
			errors.add("prenom.required", new ActionError("prenom.required"));
		}
		if (email == null || email.equals("")) {
			errors.add("email.required", new ActionError("email.required"));
		}
		if (entryDate == null || entryDate.equals("")) {
			errors.add("entryDate.required", new ActionError(
					"entryDate.required"));
		}

FileLine
fr/hyphonem/conges/data/CalendarData.java52
fr/hyphonem/conges/forms/AbsForm.java178
	}

	/**
	 * Returns the datedeb.
	 * 
	 * @return datedeb
	 */
	public String getDatedeb() {
		return datedeb;
	}

	/**
	 * Returns the datefin.
	 * 
	 * @return datefin
	 */
	public String getDatefin() {
		return datefin;
	}

	/**
	 * Returns the raison.
	 * 
	 * @return raison
	 */
	public String getRaison() {
		return raison;
	}

	/**
	 * Sets the datedeb.
	 * 
	 * @param datedeb
	 *            The datedeb to set
	 */
	public void setDatedeb(String datedeb) {
		this.datedeb = datedeb;
	}

	/**
	 * Sets the datefin.
	 * 
	 * @param datefin
	 *            The datefin to set
	 */
	public void setDatefin(String datefin) {
		this.datefin = datefin;
	}

	/**
	 * Sets the raison.
	 * 
	 * @param raison
	 *            The raison to set
	 */
	public void setRaison(String raison) {
		this.raison = raison;
	}

	/**
	 * Returns the cbaprem.
	 * 
	 * @return boolean
	 */
	public boolean isCbaprem() {
		return cbaprem;
	}

	/**
	 * Returns the cbmatin.
	 * 
	 * @return boolean
	 */
	public boolean isCbmatin() {
		return cbmatin;
	}

	/**
	 * Sets the cbaprem.
	 * 
	 * @param cbaprem
	 *            The cbaprem to set
	 */
	public void setCbaprem(boolean cbaprem) {
		this.cbaprem = cbaprem;
	}

	/**
	 * Sets the cbmatin.
	 * 
	 * @param cbmatin
	 *            The cbmatin to set
	 */
	public void setCbmatin(boolean cbmatin) {
		this.cbmatin = cbmatin;
	}

	/**
	 * @return boolean
	 */
	public boolean isDelete() {

FileLine
fr/hyphonem/conges/actions/ValidValidatingAction.java65
fr/hyphonem/conges/actions/ValidValidatingAction.java220
	public ActionForward refuse(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		HttpSession session = request.getSession();

		if (session.getAttribute("user") == null) {
			return mapping.findForward("invalidsession");
		}

		UserData userd = (UserData) session.getAttribute("user");
		if (!userd.isModif() && userd.isEmployee()) {
			return mapping.findForward("invalidaction");
		}

		ActionErrors errors = new ActionErrors();
		ActionForward forward = new ActionForward();

		ValidatingForm vform = (ValidatingForm) form;
		String[] checks = vform.getCheckboxes();

FileLine
fr/hyphonem/conges/CommonCal.java359
fr/hyphonem/conges/CommonCal.java382
				String raison = cd.getRaison();
				String db = cd.getDatedeb();
				String df = cd.getDatefin();
				Date ddb = new SimpleDateFormat("dd/MM/yyyy").parse(db);
				Date ddf = new SimpleDateFormat("dd/MM/yyyy").parse(df);

				Calendar cal = Calendar.getInstance();
				cal.setTime(ddf);
				cal.add(Calendar.DATE, 1);
				ddf = cal.getTime();

				if (ddb.compareTo(firstDate) < 0) {
					firstDate = ddb;
				}
				if (ddf.compareTo(lastDate) > 0) {
					lastDate = ddf;
				}

FileLine
fr/hyphonem/conges/actions/ValidNationalDaysAction.java121
fr/hyphonem/conges/actions/ValidNationalDaysAction.java200
			hjf.remove(annee);
			hjf.put(annee, vDays);
		}

		try {
			ad.writeNationalHolidays(pays, annee, hjf);
		} catch (IOException e) {
			errors.add("error.concurrent.access", new ActionError(
					"error.concurrent.access"));
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}

		if (!errors.isEmpty()) {
			saveErrors(request, errors);
			return mapping.getInputForward();
		}
		session.setAttribute("listeDeJoursFeries", hjf);
		return mapping.findForward("success");
	}

FileLine
fr/hyphonem/conges/actions/GenerateFranceNationalDaysAction.java38
fr/hyphonem/conges/actions/NationalDaysAction.java34
public class NationalDaysAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		HttpSession session = request.getSession();
		if (session.getAttribute("user") == null) {
			return mapping.findForward("invalidsession");
		}

		UserData userd = (UserData) session.getAttribute("user");
		// admin only
		if (userd.isModif() || userd.isEmployee()) {
			return mapping.findForward("invalidaction");
		}

		ActionErrors errors = new ActionErrors();
		ActionForward forward = new ActionForward();

		// pays en cours
		String pays = (String) session.getServletContext().getAttribute(