	/**
	 * A konstruktora l�trehozza az ablakot
	 */
	public WinFrame()
	{
		this.setSize(200,200);
        this.setLocationRelativeTo(null);
		ImageIcon winp= new ImageIcon("./Pictures/WinFrame.png");
		this.setTitle("You won!");
		l.setIcon(winp);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		ok.setBounds(80, 90, 40, 40);
		ok.addActionListener(e -> System.exit(0));
		JPanel panel = new JPanel();
		panel.add(ok, BorderLayout.CENTER);
		this.add(panel, BorderLayout.SOUTH);
		JPanel panelCenter = new JPanel();
		panelCenter.add(l, BorderLayout.SOUTH);
		this.add(panelCenter, BorderLayout.CENTER);
		this.setVisible(true);
	}

	/**
	 * A konstruktora l�trehozza az ablakot
	 */
	public WinFrame()
	{
		this.setSize(200,200);
        this.setLocationRelativeTo(null);
		ImageIcon winp= new ImageIcon("./Pictures/WinFrame.png");
		this.setTitle("You won!");
		l.setIcon(winp);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		ok.setBounds(80, 90, 40, 40);
		ok.addActionListener( new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}

		});
		JPanel panel = new JPanel();
		panel.add(ok, BorderLayout.CENTER);
		this.add(panel, BorderLayout.SOUTH);
		JPanel panelCenter = new JPanel();
		panelCenter.add(l, BorderLayout.SOUTH);
		this.add(panelCenter, BorderLayout.CENTER);
		this.setVisible(true);
	}

Replace Anonymous With Lambda .WinFrame.WinFrame.addActionListener.new ActionListener with e -> System.exit(0) in method public WinFrame() from class WinFrame


    public static <T> DefaultSubscriber<T> of() {
        return new DefaultSubscriber<>();
    }

    public static <T> DefaultSubscriber<T> of() {
        return new DefaultSubscriber<T>();
    }

Replace Generic With Diamond DefaultSubscriber<T> with DefaultSubscriber<> in method public of() : DefaultSubscriber<T> from class net.benfro.lab.reactor.common.DefaultSubscriber


    public static <T> DefaultSubscriber<T> of(String name) {
        return new DefaultSubscriber<>(name);
    }

    public static <T> DefaultSubscriber<T> of(String name) {
        return new DefaultSubscriber<T>(name);
    }

Replace Generic With Diamond DefaultSubscriber<T> with DefaultSubscriber<> in method public of(name String) : DefaultSubscriber<T> from class net.benfro.lab.reactor.common.DefaultSubscriber


    public List<Message> consume(Topic topic, String city, int offset) throws BadPartitionException, NoPartitionFound {
        if (topic != Topic.RIDER_REQUESTS_RIDE) {
            throw new BadPartitionException(String.format("%s partitions by id not city", topic.toString()));
        }
        List<Message> messages = new ArrayList<>();

        Partition p = findPartition(topic, city);
        System.out.println(p);
        Message m = p.readMessage(offset);
        System.out.println(m);
        while (m != null) {
            System.out.printf("consuming: " + m.content);
            messages.add(m);
            offset += 1;
            m = p.readMessage(offset);
        }

        return messages;
    }

    public List<Message> consume(Topic topic, String city, int offset) throws BadPartitionException, NoPartitionFound {
        if (topic != Topic.RIDER_REQUESTS_RIDE) {
            throw new BadPartitionException(String.format("%s partitions by id not city", topic.toString()));
        }
        List<Message> messages = new ArrayList<Message>();

        Partition p = findPartition(topic, city);
        System.out.println(p);
        Message m = p.readMessage(offset);
        System.out.println(m);
        while (m != null) {
            System.out.printf("consuming: " + m.content);
            messages.add(m);
            offset += 1;
            m = p.readMessage(offset);
        }

        return messages;
    }

Replace Generic With Diamond ArrayList<Message> with ArrayList<> in method public consume(topic Topic, city String, offset int) : List<Message> from class brokers.DefaultBroker


    public void addShutdownThreat() {
        Runtime.getRuntime().addShutdownHook(new Thread(() -> {
            try {
                Thread.sleep(200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("Shutting Down Brass Brewery Bot");
            //on shutdown
            jda.shutdown();
        }));
    }

    public void addShutdownThreat() {
        Runtime.getRuntime().addShutdownHook(new Thread() {
            public void run() {
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("Shutting Down Brass Brewery Bot");
                //on shutdown
                jda.shutdown();
            }
        });
    }

Replace Anonymous With Lambda sanford.BrassBreweryBot.addShutdownThreat.addShutdownHook.new Thread with () -> {tryThread.sleep(200); in method public addShutdownThreat() : void from class sanford.BrassBreweryBot


    private Catalog createCatalog(Book... books) {
        Catalog catalog = new Catalog();
        if (catalog.getBooks() == null) {
            catalog.setBooks(new ArrayList<>());
        }
        for (Book book: books) {
            catalog.getBooks().add(book);
        }
        return catalog;
    }

    private Catalog createCatalog(Book... books) {
        Catalog catalog = new Catalog();
        if (catalog.getBooks() == null) {
            catalog.setBooks(new ArrayList<Book>());
        }
        for (Book book: books) {
            catalog.getBooks().add(book);
        }
        return catalog;
    }

Replace Generic With Diamond ArrayList<Book> with ArrayList<> in method private createCatalog(books Book...) : Catalog from class beans.BeansTest


    private Catalog createCatalog(Book... books) {
        Catalog catalog = new Catalog();
        if (catalog.getBooks() == null) {
            catalog.setBooks(new ArrayList<>());
        }
        for (Book book: books) {
            catalog.getBooks().add(book);
            book.setCatalog(catalog);
        }
        return catalog;
    }

    private Catalog createCatalog(Book... books) {
        Catalog catalog = new Catalog();
        if (catalog.getBooks() == null) {
            catalog.setBooks(new ArrayList<Book>());
        }
        for (Book book: books) {
            catalog.getBooks().add(book);
            book.setCatalog(catalog);
        }
        return catalog;
    }

Replace Generic With Diamond ArrayList<Book> with ArrayList<> in method private createCatalog(books Book...) : Catalog from class jaxbcycle.JaxbCycleTest


    private Catalog createCatalog(Item... items) {
        Catalog catalog = new Catalog();
        if (catalog.getItems() == null) {
            catalog.setItems(new ArrayList<>());
        }
        for (Item item: items) {
            catalog.getItems().add(item);
        }
        return catalog;
    }

    private Catalog createCatalog(Item... items) {
        Catalog catalog = new Catalog();
        if (catalog.getItems() == null) {
            catalog.setItems(new ArrayList<Item>());
        }
        for (Item item: items) {
            catalog.getItems().add(item);
        }
        return catalog;
    }

Replace Generic With Diamond ArrayList<Item> with ArrayList<> in method private createCatalog(items Item...) : Catalog from class jaxbinherit.JaxbInheritTest


    private void printCsvTrainingSet(String trainingName, int i) throws IOException {
        try (FileWriter trainingWriter = new FileWriter(trainingName)) {
            trainingWriter.append("LOC,LOC_touched,NR,NFix,NAuth,LOC_added,MAX_LOC_added,Churn,MAX_Churn,AVG_Churn,AVG_Holiday,Buggy")
                    .append("\n");
            for (int j = 0; j < i; j++) {
                for (Class javaClass : releases.get(j).getAllClasses().values()) {
                    trainingWriter.append(String.valueOf(javaClass.getLoc())).append(",")
                            .append(String.valueOf(javaClass.getLocTouched())).append(",")
                            .append(String.valueOf(javaClass.getNr())).append(",")
                            .append(String.valueOf(javaClass.getNumFix())).append(",")
                            .append(String.valueOf(javaClass.getNumAuth())).append(",")
                            .append(String.valueOf(javaClass.getLocAdded())).append(",")
                            .append(String.valueOf(javaClass.getMaxLocAdded())).append(",")
                            .append(String.valueOf(javaClass.getChurn())).append(",")
                            .append(String.valueOf(javaClass.getMaxChurn())).append(",")
                            .append(String.valueOf(javaClass.getAverageChurn())).append(",")
                            .append(String.valueOf(javaClass.getAverageHolydays())).append(",")
                            .append(javaClass.isBuggy() ? "YES" : "NO")
                            .append("\n");
                }
            }
        }
    }

    private void printCsvTrainingSet(String trainingName, int i) throws IOException {
        FileWriter trainingWriter = null;
        try {
            trainingWriter = new FileWriter(trainingName);
            trainingWriter.append("LOC,LOC_touched,NR,NFix,NAuth,LOC_added,MAX_LOC_added,Churn,MAX_Churn,AVG_Churn,AVG_Holiday,Buggy");
            trainingWriter.append("\n");
            for (int j = 0; j < i; j++) {
                for (Class javaClass : releases.get(j).getAllClasses().values()) {
                    trainingWriter.append(String.valueOf(javaClass.getLoc()));
                    trainingWriter.append(",");
                    trainingWriter.append(String.valueOf(javaClass.getLocTouched()));
                    trainingWriter.append(",");
                    trainingWriter.append(String.valueOf(javaClass.getNr()));
                    trainingWriter.append(",");
                    trainingWriter.append(String.valueOf(javaClass.getNumFix()));
                    trainingWriter.append(",");
                    trainingWriter.append(String.valueOf(javaClass.getNumAuth()));
                    trainingWriter.append(",");
                    trainingWriter.append(String.valueOf(javaClass.getLocAdded()));
                    trainingWriter.append(",");
                    trainingWriter.append(String.valueOf(javaClass.getMaxLocAdded()));
                    trainingWriter.append(",");
                    trainingWriter.append(String.valueOf(javaClass.getChurn()));
                    trainingWriter.append(",");
                    trainingWriter.append(String.valueOf(javaClass.getMaxChurn()));
                    trainingWriter.append(",");
                    trainingWriter.append(String.valueOf(javaClass.getAverageChurn()));
                    trainingWriter.append(",");
                    trainingWriter.append(String.valueOf(javaClass.getAverageHolydays()));
                    trainingWriter.append(",");
                    if (javaClass.isBuggy()) trainingWriter.append("YES");
                    else trainingWriter.append("NO");
                    trainingWriter.append("\n");
                }
            }
        } finally {
            if (trainingWriter != null) trainingWriter.close();
        }
    }

Try With Resources try(FileWriter trainingWriter=new FileWriter(trainingName)) in method private printCsvTrainingSet(trainingName String, i int) : void from class com.isw2data.controller.GitController


    public void printDataset(String projName) throws IOException, GitAPIException {
        setBuggyClasses();
        String outname = projName + "//dataset_" + projName + ".csv";
        try (FileWriter fileWriter = new FileWriter(outname)) {
            fileWriter.append("Index,Class,LOC,LOC_touched,NR,NFix,NAuth,LOC_added,MAX_LOC_added,Churn,MAX_Churn,AVG_Churn,AVG_Holiday,Buggy")
                    .append("\n");
            for (Release release : releases) {
                if (release.getAllClasses() != null) {
                    for (Class javaClass : release.getAllClasses().values()) {
                        fileWriter.append(String.valueOf(javaClass.getVersion())).append(",")
                                .append(javaClass.getPath()).append(",")
                                .append(String.valueOf(javaClass.getLoc())).append(",")
                                .append(String.valueOf(javaClass.getLocTouched())).append(",")
                                .append(String.valueOf(javaClass.getNr())).append(",")
                                .append(String.valueOf(javaClass.getNumFix())).append(",")
                                .append(String.valueOf(javaClass.getNumAuth())).append(",")
                                .append(String.valueOf(javaClass.getLocAdded())).append(",")
                                .append(String.valueOf(javaClass.getMaxLocAdded())).append(",")
                                .append(String.valueOf(javaClass.getChurn())).append(",")
                                .append(String.valueOf(javaClass.getMaxChurn())).append(",")
                                .append(String.valueOf(javaClass.getAverageChurn())).append(",")
                                .append(String.valueOf(javaClass.getAverageHolydays())).append(",")
                                .append(javaClass.isBuggy() ? "YES" : "NO")
                                .append("\n");
                    }
                }
            }
        }
    }

    public void printDataset(String projName) throws IOException, GitAPIException {
        FileWriter fileWriter = null;
        setBuggyClasses();
        //Name of CSV for output
        String outname = projName + "//dataset_" + projName + ".csv";
        try {
            fileWriter = new FileWriter(outname);
            fileWriter.append("Index,Class,LOC,LOC_touched,NR,NFix,NAuth,LOC_added,MAX_LOC_added,Churn,MAX_Churn,AVG_Churn,AVG_Holiday,Buggy");
            fileWriter.append("\n");
            for (Release release : releases) {
                if (release.getAllClasses() != null) {
                    for (Class javaClass : release.getAllClasses().values()) {
                        fileWriter.append(String.valueOf(javaClass.getVersion()));
                        fileWriter.append(",");
                        fileWriter.append(javaClass.getPath());
                        fileWriter.append(",");
                        fileWriter.append(String.valueOf(javaClass.getLoc()));
                        fileWriter.append(",");
                        fileWriter.append(String.valueOf(javaClass.getLocTouched()));
                        fileWriter.append(",");
                        fileWriter.append(String.valueOf(javaClass.getNr()));
                        fileWriter.append(",");
                        fileWriter.append(String.valueOf(javaClass.getNumFix()));
                        fileWriter.append(",");
                        fileWriter.append(String.valueOf(javaClass.getNumAuth()));
                        fileWriter.append(",");
                        fileWriter.append(String.valueOf(javaClass.getLocAdded()));
                        fileWriter.append(",");
                        fileWriter.append(String.valueOf(javaClass.getMaxLocAdded()));
                        fileWriter.append(",");
                        fileWriter.append(String.valueOf(javaClass.getChurn()));
                        fileWriter.append(",");
                        fileWriter.append(String.valueOf(javaClass.getMaxChurn()));
                        fileWriter.append(",");
                        fileWriter.append(String.valueOf(javaClass.getAverageChurn()));
                        fileWriter.append(",");
                        fileWriter.append(String.valueOf(javaClass.getAverageHolydays()));
                        fileWriter.append(",");
                        if (javaClass.isBuggy()) fileWriter.append("YES");
                        else fileWriter.append("NO");
                        fileWriter.append("\n");
                    }
                }
            }
            fileWriter.flush();
        } finally {
            if (fileWriter != null) fileWriter.close();
        }
    }

Try With Resources try(FileWriter fileWriter=new FileWriter(outname)) in method public printDataset(projName String) : void from class com.isw2data.controller.GitController


    private void writeArffTesting(String filename, int i) throws IOException {
        String[] parts = filename.split("\\.");
        try (FileWriter fileWriter = new FileWriter(filename)) {
            fileWriter.append("@relation " + parts[0]).append("\n\n")
                    .append("@attribute LOC numeric").append("\n")
                    .append("@attribute LOC_touched numeric").append("\n")
                    .append("@attribute NR numeric").append("\n")
                    .append("@attribute NFix numeric").append("\n")
                    .append("@attribute NAuth numeric").append("\n")
                    .append("@attribute LOC_added numeric").append("\n")
                    .append("@attribute MAX_LOC_added numeric").append("\n")
                    .append("@attribute Churn numeric").append("\n")
                    .append("@attribute MAX_Churn numeric").append("\n")
                    .append("@attribute AVG_Churn numeric").append("\n")
                    .append("@attribute AVG_Holiday numeric").append("\n")
                    .append("@attribute Buggy {'YES', 'NO'}").append("\n\n")
                    .append("@data").append("\n");
            for (Class javaClass : releases.get(i).getAllClasses().values()) {
                fileWriter.append(String.valueOf(javaClass.getLoc())).append(",")
                        .append(String.valueOf(javaClass.getLocTouched())).append(",")
                        .append(String.valueOf(javaClass.getNr())).append(",")
                        .append(String.valueOf(javaClass.getNumFix())).append(",")
                        .append(String.valueOf(javaClass.getNumAuth())).append(",")
                        .append(String.valueOf(javaClass.getLocAdded())).append(",")
                        .append(String.valueOf(javaClass.getMaxLocAdded())).append(",")
                        .append(String.valueOf(javaClass.getChurn())).append(",")
                        .append(String.valueOf(javaClass.getMaxChurn())).append(",")
                        .append(String.valueOf(javaClass.getAverageChurn())).append(",")
                        .append(String.valueOf(javaClass.getAverageHolydays())).append(",")
                        .append(javaClass.isBuggy() ? "YES" : "NO")
                        .append("\n");
            }
        }
    }

    private void writeArffTesting(String filename, int i) throws IOException{
        String[] parts = filename.split("\\.");
        FileWriter fileWriter = null;
        //Name of CSV for output
        try {
            fileWriter = new FileWriter(filename);
            fileWriter.append("@relation " + parts[0]).append("\n\n")
                    .append("@attribute LOC numeric").append("\n")
                    .append("@attribute LOC_touched numeric").append("\n")
                    .append("@attribute NR numeric").append("\n")
                    .append("@attribute NFix numeric").append("\n")
                    .append("@attribute NAuth numeric").append("\n")
                    .append("@attribute LOC_added numeric").append("\n")
                    .append("@attribute MAX_LOC_added numeric").append("\n")
                    .append("@attribute Churn numeric").append("\n")
                    .append("@attribute MAX_Churn numeric").append("\n")
                    .append("@attribute AVG_Churn numeric").append("\n")
                    .append("@attribute AVG_Holiday numeric").append("\n")
                    .append("@attribute Buggy {'YES', 'NO'}").append("\n\n")
                    .append("@data").append("\n");
            for (Class javaClass : releases.get(i).getAllClasses().values()) {
                fileWriter.append(String.valueOf(javaClass.getLoc()));
                fileWriter.append(",");
                fileWriter.append(String.valueOf(javaClass.getLocTouched()));
                fileWriter.append(",");
                fileWriter.append(String.valueOf(javaClass.getNr()));
                fileWriter.append(",");
                fileWriter.append(String.valueOf(javaClass.getNumFix()));
                fileWriter.append(",");
                fileWriter.append(String.valueOf(javaClass.getNumAuth()));
                fileWriter.append(",");
                fileWriter.append(String.valueOf(javaClass.getLocAdded()));
                fileWriter.append(",");
                fileWriter.append(String.valueOf(javaClass.getMaxLocAdded()));
                fileWriter.append(",");
                fileWriter.append(String.valueOf(javaClass.getChurn()));
                fileWriter.append(",");
                fileWriter.append(String.valueOf(javaClass.getMaxChurn()));
                fileWriter.append(",");
                fileWriter.append(String.valueOf(javaClass.getAverageChurn()));
                fileWriter.append(",");
                fileWriter.append(String.valueOf(javaClass.getAverageHolydays()));
                fileWriter.append(",");
                if (javaClass.isBuggy()) fileWriter.append("YES");
                else fileWriter.append("NO");
                fileWriter.append("\n");

            }
            fileWriter.flush();
        } finally {
            if (fileWriter != null) fileWriter.close();
        }
    }

Try With Resources try(FileWriter fileWriter=new FileWriter(filename)) in method private writeArffTesting(filename String, i int) : void from class com.isw2data.controller.GitController


    private void writeArffTraining(String filename, int i) throws IOException {
        String[] parts = filename.split("\\.");
        try (FileWriter fileWriter = new FileWriter(filename)) {
            fileWriter.append("@relation " + parts[0]).append("\n\n")
                    .append("@attribute LOC numeric").append("\n")
                    .append("@attribute LOC_touched numeric").append("\n")
                    .append("@attribute NR numeric").append("\n")
                    .append("@attribute NFix numeric").append("\n")
                    .append("@attribute NAuth numeric").append("\n")
                    .append("@attribute LOC_added numeric").append("\n")
                    .append("@attribute MAX_LOC_added numeric").append("\n")
                    .append("@attribute Churn numeric").append("\n")
                    .append("@attribute MAX_Churn numeric").append("\n")
                    .append("@attribute AVG_Churn numeric").append("\n")
                    .append("@attribute AVG_Holiday numeric").append("\n")
                    .append("@attribute Buggy {'YES', 'NO'}").append("\n\n")
                    .append("@data").append("\n");
            for (int j = 0; j < i; j++) {
                for (Class javaClass : releases.get(j).getAllClasses().values()) {
                    fileWriter.append(String.valueOf(javaClass.getLoc())).append(",")
                            .append(String.valueOf(javaClass.getLocTouched())).append(",")
                            .append(String.valueOf(javaClass.getNr())).append(",")
                            .append(String.valueOf(javaClass.getNumFix())).append(",")
                            .append(String.valueOf(javaClass.getNumAuth())).append(",")
                            .append(String.valueOf(javaClass.getLocAdded())).append(",")
                            .append(String.valueOf(javaClass.getMaxLocAdded())).append(",")
                            .append(String.valueOf(javaClass.getChurn())).append(",")
                            .append(String.valueOf(javaClass.getMaxChurn())).append(",")
                            .append(String.valueOf(javaClass.getAverageChurn())).append(",")
                            .append(String.valueOf(javaClass.getAverageHolydays())).append(",")
                            .append(javaClass.isBuggy() ? "YES" : "NO")
                            .append("\n");
                }
            }
        }
    }

    private void writeArffTraining(String filename, int i) throws IOException{
        String[] parts = filename.split("\\.");
        FileWriter fileWriter = null;
        //Name of CSV for output
        try {
            fileWriter = new FileWriter(filename);

            fileWriter.append("@relation " + parts[0]).append("\n\n")
                    .append("@attribute LOC numeric").append("\n")
                    .append("@attribute LOC_touched numeric").append("\n")
                    .append("@attribute NR numeric").append("\n")
                    .append("@attribute NFix numeric").append("\n")
                    .append("@attribute NAuth numeric").append("\n")
                    .append("@attribute LOC_added numeric").append("\n")
                    .append("@attribute MAX_LOC_added numeric").append("\n")
                    .append("@attribute Churn numeric").append("\n")
                    .append("@attribute MAX_Churn numeric").append("\n")
                    .append("@attribute AVG_Churn numeric").append("\n")
                    .append("@attribute AVG_Holiday numeric").append("\n")
                    .append("@attribute Buggy {'YES', 'NO'}").append("\n\n")
                    .append("@data").append("\n");

            for (int j = 0; j < i; j++) {
                for (Class javaClass : releases.get(j).getAllClasses().values()) {
                    fileWriter.append(String.valueOf(javaClass.getLoc()));
                    fileWriter.append(",");
                    fileWriter.append(String.valueOf(javaClass.getLocTouched()));
                    fileWriter.append(",");
                    fileWriter.append(String.valueOf(javaClass.getNr()));
                    fileWriter.append(",");
                    fileWriter.append(String.valueOf(javaClass.getNumFix()));
                    fileWriter.append(",");
                    fileWriter.append(String.valueOf(javaClass.getNumAuth()));
                    fileWriter.append(",");
                    fileWriter.append(String.valueOf(javaClass.getLocAdded()));
                    fileWriter.append(",");
                    fileWriter.append(String.valueOf(javaClass.getMaxLocAdded()));
                    fileWriter.append(",");
                    fileWriter.append(String.valueOf(javaClass.getChurn()));
                    fileWriter.append(",");
                    fileWriter.append(String.valueOf(javaClass.getMaxChurn()));
                    fileWriter.append(",");
                    fileWriter.append(String.valueOf(javaClass.getAverageChurn()));
                    fileWriter.append(",");
                    fileWriter.append(String.valueOf(javaClass.getAverageHolydays()));
                    fileWriter.append(",");
                    if (javaClass.isBuggy()) fileWriter.append("YES");
                    else fileWriter.append("NO");
                    fileWriter.append("\n");
                }
            }
            fileWriter.flush();
        } finally {
            if (fileWriter != null) fileWriter.close();
        }
    }

Try With Resources try(FileWriter fileWriter=new FileWriter(filename)) in method private writeArffTraining(filename String, i int) : void from class com.isw2data.controller.GitController


  public void get(long key, LongConsumer consumer) {
    var node = get(root, key);
    if (node != null) {
      node.list.forEach(consumer::accept);
    }
  }

  public void get(long key, LongConsumer consumer) {
    var node = get(root, key);
    if (node != null) {
      for (var item = node.value; item != null; item = item.prev) {
        consumer.accept(item.value);
      }
    }
  }

Replace Loop With Pipeline for(var item=node.value; item != null; item=item.prev) with node.list.forEach(consumer::accept); in method public get(key long, consumer LongConsumer) : void from class org.dauch.piola.collections.map.LongLongAVLMemoryMap


    public static void main(String[] args) {
        Properties config = loadConfig();
        try {
            try (Connection cn = DriverManager.getConnection(
                    config.getProperty("rabbit.url"),
                    config.getProperty("rabbit.username"),
                    config.getProperty("rabbit.password"))) {
                Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
                scheduler.start();
                JobDataMap data = new JobDataMap();
                data.put("conn", cn);
                JobDetail job = newJob(Rabbit.class)
                        .usingJobData(data)
                        .build();
                SimpleScheduleBuilder times = simpleSchedule()
                        .withIntervalInSeconds(Integer.parseInt(config.getProperty("rabbit.interval")))
                        .repeatForever();
                Trigger trigger = newTrigger()
                        .startNow()
                        .withSchedule(times)
                        .build();
                scheduler.scheduleJob(job, trigger);
                Thread.sleep(10000);
                scheduler.shutdown();
            } catch (SQLException throwable) {
                throwable.printStackTrace();
            }
        } catch (SchedulerException | InterruptedException se) {
            se.printStackTrace();
        }
    }

    public static void main(String[] args) {
        try {
            Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
            scheduler.start();
            Properties config = loadConfig();
            Connection cn = getConnection(config);
            JobDataMap data = new JobDataMap();
            data.put("conn", cn);
            JobDetail job = newJob(Rabbit.class)
                    .usingJobData(data)
                    .build();
            SimpleScheduleBuilder times = simpleSchedule()
                    .withIntervalInSeconds(Integer.parseInt(config.getProperty("rabbit.interval")))
                    .repeatForever();
            Trigger trigger = newTrigger()
                    .startNow()
                    .withSchedule(times)
                    .build();
            scheduler.scheduleJob(job, trigger);
            Thread.sleep(10000);
            scheduler.shutdown();
        } catch (SchedulerException | InterruptedException se) {
            se.printStackTrace();
        }
    }

Try With Resources try(Connection cn=DriverManager.getConnection(config.getProperty("rabbit.url"),config.getProperty("rabbit.username"),config.getProperty("rabbit.password"))) in method public main(args String[]) : void from class ru.job4j.quartz.AlertRabbit


    /**
     * Search for the show using the show name
     *
     * @param showName
     * @return list of matching shows
     * @throws com.omertron.tvrageapi.TVRageException
     */
    public List<ShowInfo> searchShow(String showName) throws TVRageException {
        if (!isValidString(showName)) {
            return new ArrayList<>();
        }

        String tvrageURL = buildURL(API_SEARCH, showName).toString();
        return TVRageParser.getSearchShow(tvrageURL);
    }

    /**
     * Search for the show using the show name
     *
     * @param showName
     * @return list of matching shows
     * @throws com.omertron.tvrageapi.TVRageException
     */
    public List<ShowInfo> searchShow(String showName) throws TVRageException {
        if (!isValidString(showName)) {
            return new ArrayList<ShowInfo>();
        }

        String tvrageURL = buildURL(API_SEARCH, showName).toString();
        return TVRageParser.getSearchShow(tvrageURL);
    }

Replace Generic With Diamond ArrayList<ShowInfo> with ArrayList<> in method public searchShow(showName String) : List<ShowInfo> from class com.omertron.tvrageapi.TVRageApi


    public EpisodeList() {
        showName = TVRageApi.UNKNOWN;
        totalSeasons = 0;
        episodes = new TreeMap<>();
    }

    public EpisodeList() {
        showName = TVRageApi.UNKNOWN;
        totalSeasons = 0;
        episodes = new TreeMap<EpisodeNumber, Episode>();
    }

Replace Generic With Diamond TreeMap<EpisodeNumber,Episode> with TreeMap<> in method public EpisodeList() from class com.omertron.tvrageapi.model.EpisodeList


    /**
     * Get a DOM document from the supplied URL
     *
     * @param url
     * @return
     * @throws com.omertron.tvrageapi.TVRageException
     */
    public static Document getEventDocFromUrl(String url) throws TVRageException {
        Document doc;
        InputStream in = null;

        try {
            in = new ByteArrayInputStream(requestWebContent(url));

            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(in);
            doc.getDocumentElement().normalize();
            return doc;
        } catch (ParserConfigurationException | SAXException | IOException ex) {
            throw new TVRageException(ApiExceptionType.MAPPING_FAILED, UNABLE_TO_PARSE, url, ex);
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (IOException ex) {
                // Input Stream was already closed or null
                LOG.trace("Stream already closed for getEventDocFromUrl", ex);
            }
        }
    }

    /**
     * Get a DOM document from the supplied URL
     *
     * @param url
     * @return
     * @throws com.omertron.tvrageapi.TVRageException
     */
    public static Document getEventDocFromUrl(String url) throws TVRageException {
        Document doc;
        InputStream in = null;

        try {
            in = new ByteArrayInputStream(requestWebContent(url));

            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(in);
            doc.getDocumentElement().normalize();
            return doc;
        } catch (ParserConfigurationException ex) {
            throw new TVRageException(ApiExceptionType.MAPPING_FAILED, UNABLE_TO_PARSE, url, ex);
        } catch (SAXException ex) {
            throw new TVRageException(ApiExceptionType.MAPPING_FAILED, UNABLE_TO_PARSE, url, ex);
        } catch (IOException ex) {
            throw new TVRageException(ApiExceptionType.MAPPING_FAILED, UNABLE_TO_PARSE, url, ex);
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (IOException ex) {
                // Input Stream was already closed or null
                LOG.trace("Stream already closed for getEventDocFromUrl", ex);
            }
        }
    }

Merge Catch [catch(ParserConfigurationException ex), catch(SAXException ex), catch(IOException ex)] to catch(ParserConfigurationException|SAXException|IOException ex) in method public getEventDocFromUrl(url String) : Document from class com.omertron.tvrageapi.tools.DOMHelper


    /**
     * Get a list of the ShowInfo from the specified tag
     *
     * @param searchUrl
     * @param tagName
     * @return
     */
    private static List<ShowInfo> processShowInfo(String searchUrl, String tagName) throws TVRageException {
        List<ShowInfo> showList = new ArrayList<>();
        ShowInfo showInfo;

        Document doc = getDocFromUrl(searchUrl);
        NodeList nlShowInfo = doc.getElementsByTagName(tagName);

        if (nlShowInfo == null || nlShowInfo.getLength() == 0) {
            return showList;
        }

        for (int loop = 0; loop < nlShowInfo.getLength(); loop++) {
            Node nShowInfo = nlShowInfo.item(loop);
            if (nShowInfo.getNodeType() == Node.ELEMENT_NODE) {
                Element eShowInfo = (Element) nShowInfo;
                showInfo = parseNextShowInfo(eShowInfo);
                showList.add(showInfo);
            }
        }

        return showList;
    }

    /**
     * Get a list of the ShowInfo from the specified tag
     *
     * @param searchUrl
     * @param tagName
     * @return
     */
    private static List<ShowInfo> processShowInfo(String searchUrl, String tagName) throws TVRageException {
        List<ShowInfo> showList = new ArrayList<ShowInfo>();
        ShowInfo showInfo;

        Document doc = getDocFromUrl(searchUrl);
        NodeList nlShowInfo = doc.getElementsByTagName(tagName);

        if (nlShowInfo == null || nlShowInfo.getLength() == 0) {
            return showList;
        }

        for (int loop = 0; loop < nlShowInfo.getLength(); loop++) {
            Node nShowInfo = nlShowInfo.item(loop);
            if (nShowInfo.getNodeType() == Node.ELEMENT_NODE) {
                Element eShowInfo = (Element) nShowInfo;
                showInfo = parseNextShowInfo(eShowInfo);
                showList.add(showInfo);
            }
        }

        return showList;
    }

Replace Generic With Diamond ArrayList<ShowInfo> with ArrayList<> in method private processShowInfo(searchUrl String, tagName String) : List<ShowInfo> from class com.omertron.tvrageapi.tools.TVRageParser


	/**
	 * Note that the signature produced will be different each time
	 * due to the fact we are using ECDSA (select a K at random)
	 */
	public void signEmployee() {
		try {
			this.employeeSignature = this.employee.sign(this.getSignedPortion());
		} catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchProviderException
				| SignatureException e) {
			e.printStackTrace();
			throw new RuntimeException("Fatal Error - can't sign");
		};
	}

	/**
	 * Note that the signature produced will be different each time
	 * due to the fact we are using ECDSA (select a K at random)
	 */
	public void signEmployee() {
		try {
			this.employeeSignature = this.employee.sign(this.getSignedPortion());
		} catch (InvalidKeyException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchProviderException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SignatureException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

Merge Catch [catch(InvalidKeyException e), catch(NoSuchAlgorithmException e), catch(NoSuchProviderException e), catch(SignatureException e)] to catch(InvalidKeyException|NoSuchAlgorithmException|NoSuchProviderException|SignatureException e) in method public signEmployee() : void from class org.bverify.records.Change


	/**
	 * Note that the signature produced will be different each time
	 * due to the fact we are using ECDSA (select a K at random)
	 */
	public void signRecipient() {
		try {
			this.recepientSignature = this.recepient.sign(this.getSignedPortion());
		} catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchProviderException
				| SignatureException e) {
			e.printStackTrace();
			throw new RuntimeException("Fatal Error - can't sign");
		};
	}

	/**
	 * Note that the signature produced will be different each time
	 * due to the fact we are using ECDSA (select a K at random)
	 */
	public void signRecipient() {
		try {
			this.recepientSignature = this.recepient.sign(this.getSignedPortion());
		} catch (InvalidKeyException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchProviderException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SignatureException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

Merge Catch [catch(InvalidKeyException e), catch(NoSuchAlgorithmException e), catch(NoSuchProviderException e), catch(SignatureException e)] to catch(InvalidKeyException|NoSuchAlgorithmException|NoSuchProviderException|SignatureException e) in method public signRecipient() : void from class org.bverify.records.Change


	@Override
	public boolean isSigned() {
		if(this.recepientSignature != null && this.employeeSignature != null) {
			byte[] message = this.getSignedPortion();
			try {
				return this.employee.checkSignature(message, this.employeeSignature)
						&& this.recepient.checkSignature(message, recepientSignature);
			} catch (InvalidKeyException | SignatureException e) {
				e.printStackTrace();
				return false;
			}
		}
		else {
			return false;
		}
	}

	@Override
	public boolean isSigned() {
		if(this.recepientSignature != null && this.employeeSignature != null) {
			byte[] message = this.getSignedPortion();
			try {
				return this.employee.checkSignature(message, this.employeeSignature)
						&& this.recepient.checkSignature(message, recepientSignature);
			} catch (InvalidKeyException e) {
				e.printStackTrace();
				return false;
			} catch (SignatureException e) {
				e.printStackTrace();
				return false;
			}
		}
		else {
			return false;
		}
	}

Merge Catch [catch(InvalidKeyException e), catch(SignatureException e)] to catch(InvalidKeyException|SignatureException e) in method public isSigned() : boolean from class org.bverify.records.Change


	public void signSender() {
		try {
			this.senderSignature = this.sender.sign(this.getSignedPortion());
		} catch (InvalidKeyException | NoSuchProviderException
				| NoSuchAlgorithmException | SignatureException e) {
			e.printStackTrace();
		}
	}

	public void signSender() {
		try {
			this.senderSignature = this.sender.sign(this.getSignedPortion());
		} catch (InvalidKeyException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchProviderException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SignatureException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

Merge Catch [catch(InvalidKeyException e), catch(NoSuchAlgorithmException e), catch(NoSuchProviderException e), catch(SignatureException e)] to catch(InvalidKeyException|NoSuchProviderException|NoSuchAlgorithmException|SignatureException e) in method public signSender() : void from class org.bverify.records.Transfer


	public void signRecipient() {
		try {
			this.recepientSignature = this.recepient.sign(this.getSignedPortion());
		} catch (InvalidKeyException | NoSuchProviderException
				| NoSuchAlgorithmException | SignatureException e) {
			e.printStackTrace();
		}
	}

	public void signRecipient() {
		try {
			this.recepientSignature = this.recepient.sign(this.getSignedPortion());
		} catch (InvalidKeyException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchProviderException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SignatureException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

Merge Catch [catch(InvalidKeyException e), catch(NoSuchAlgorithmException e), catch(NoSuchProviderException e), catch(SignatureException e)] to catch(InvalidKeyException|NoSuchProviderException|NoSuchAlgorithmException|SignatureException e) in method public signRecipient() : void from class org.bverify.records.Transfer


    /**
     * Subscribe a listener to a type.
     *
     * @param type EventType that is to be subscribed to. It may be a subclass.
     * @param listener EventListener implementation, that should process a notification for the event.
     */
    public void subscribe(EventType type, EventListener listener) {
        // If the type does not exist in the listernes map, add a new set
        if (!this.listeners.containsKey(type)) {
            this.listeners.put(type, new LinkedHashSet<>());
        }

        // Get the listener set from the type supplied
        Set<EventListener> listeners = this.listeners.get(type);

        // Add the new listeener to the set
        listeners.add(listener);
    }

    /**
     * Subscribe a listener to a type.
     *
     * @param type EventType that is to be subscribed to. It may be a subclass.
     * @param listener EventListener implementation, that should process a notification for the event.
     */
    public void subscribe(EventType type, EventListener listener) {
        // If the type does not exist in the listernes map, add a new set
        if (!this.listeners.containsKey(type)) {
            this.listeners.put(type, new LinkedHashSet<EventListener>());
        }

        // Get the listener set from the type supplied
        Set<EventListener> listeners = this.listeners.get(type);

        // Add the new listeener to the set
        listeners.add(listener);
    }

Replace Generic With Diamond LinkedHashSet<EventListener> with LinkedHashSet<> in method public subscribe(type EventType, listener EventListener) : void from class dk.sdu.sesem4.common.event.EventManager


    public void addDepartment(Department department) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
            transaction = session.beginTransaction();
            int id = (Integer) session.save(department);
            transaction.commit();
        } catch (HibernateException e) {
            if(transaction != null) {
                transaction.rollback();
            }
            logger.error("Error while adding department");
           throw new EmployeeException("Error while adding department" + department.getName(), e);
        }
     }

    public void addDepartment(Department department) throws DatabaseException {
        Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
        try {
            transaction = session.beginTransaction();
            int id = (Integer) session.save(department);
            transaction.commit();
        } catch (HibernateException e) {
           throw new DatabaseException("Error while adding department" + e);
        } finally {
            session.close();
        }
     }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public addDepartment(department Department) : void from class com.ideas2it.department.dao.DepartmentRepositoryImpl


    public void updateDepartment(Department department) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
            transaction = session.beginTransaction();
            Department existingDepartment = session.get(Department.class, department.getId());
            if (existingDepartment != null) {
                existingDepartment .setName(department.getName());
                session.update(existingDepartment );
                transaction.commit();
            }
        } catch (HibernateException e) {
            if(transaction != null) {
                transaction.rollback();
            }
            logger.error("Can't able to update the department ");
            throw new EmployeeException("Error while updating department : " + department.getId(), e);
        }
    }

    public void updateDepartment(Department department) throws DatabaseException {
        Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
        try {
            transaction = session.beginTransaction();
            Department existingDepartment = session.get(Department.class, department.getId());
            if (existingDepartment != null) {
                existingDepartment .setName(department.getName());
                session.update(existingDepartment );
                transaction.commit();
            }
        } catch (HibernateException e) {
            if(transaction != null) {
                transaction.rollback();
            }
            throw new DatabaseException("Error while updating department  " + department.getId() + "  " + e);
        } finally {
            session.close();
        }
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public updateDepartment(department Department) : void from class com.ideas2it.department.dao.DepartmentRepositoryImpl


     public void deleteDepartment(int id) throws EmployeeException {
         Transaction transaction = null;
         try (Session session = HibernateConnection.getFactory().openSession()) {
             transaction = session.beginTransaction();
             Department department = session.get (Department.class, id);
             if (department != null) {
                 session.delete(department);
                 transaction.commit();
             }
             else {
                 throw new EmployeeException("Department not found : " + id);
             }
         } catch (HibernateException e) {
             if(transaction != null) {
                transaction.rollback();
            }
             logger.error("No Department found with this ID");
             throw new EmployeeException("Error while deleting department : " + id, e);
         }
     }

     public void deleteDepartment(int id) throws DatabaseException {
         Session session = HibernateConnection.getFactory().openSession();
         Transaction transaction = null;
         try {
             transaction = session.beginTransaction();
             Department department = session.get (Department.class, id);
             if (department != null) {
                 session.delete(department);
                 transaction.commit();
             }
             else {
                 throw new DatabaseException("Department not found!!!  " + id);
             }
         } catch (HibernateException e) {
             if(transaction != null) {
                transaction.rollback();
            }
             throw new DatabaseException("Error while deleting department  " + id + "  " + e);

         } finally {
             session.close();
        }
     }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public deleteDepartment(id int) : void from class com.ideas2it.department.dao.DepartmentRepositoryImpl


    public Department findDepartmentById(int id) throws EmployeeException {
        Department department = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
			department = session.get(Department.class, id);
			if (department == null) {
			    throw new EmployeeException("No Department found in this ID : " + id);
			}
        } catch (HibernateException e) {
            logger.error("No department found in this ID");
            throw new EmployeeException("Department not found" + id, e);
        }
        return department;
    }

    public Department findDepartmentById(int id) throws DatabaseException {
        Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
        Department department = null;
        try {
			transaction = session.beginTransaction();
			department = session.get(Department.class, id);
			if (department == null) {
			    throw new DatabaseException("No Department found in this ID : " + id);
			}
			transaction.commit();
        } catch (HibernateException e) {
            throw new DatabaseException("Department not found" + id);
        } finally {
            session.close();
        }
        return department;
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public findDepartmentById(id int) : Department from class com.ideas2it.department.dao.DepartmentRepositoryImpl


    public List<Employee> getEmployeesByDepartmentId(int departmentId) throws EmployeeException {
        List<Employee> employees = new ArrayList<>();
		try (Session session = HibernateConnection.getFactory().openSession()) {
			String hqlQuery = "from Employee e left join fetch e.department d "
										   + "where d.id = :departmentId";
			Query<Employee> query = session.createQuery(hqlQuery, Employee.class);
			query.setParameter("departmentId", departmentId);
			employees = query.getResultList();
        } catch (HibernateException e) {
            logger.error("There is no employee to display");
            throw new EmployeeException("No Employees to display in this DepartmentID : " + departmentId, e);
        }
        return employees;
    }

    public List<Employee> getEmployeesByDepartmentId(int departmentId) throws DatabaseException {
        List<Employee> employees = new ArrayList<>();
		Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
		try {
			transaction = session.beginTransaction();
			String hqlQuery = "from Employee e left join fetch e.department d "
										   + "where d.id = :departmentId";
			Query<Employee> query = session.createQuery(hqlQuery, Employee.class);
			query.setParameter("departmentId", departmentId);
			employees = query.getResultList();
			transaction.commit();
        } catch (HibernateException e) {
			if (transaction != null) {
			    transaction.rollback();
			}
            throw new DatabaseException("No Employees to display" + e);
        } finally {
            session.close();
        }
        return employees;
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public getEmployeesByDepartmentId(departmentId int) : List<Employee> from class com.ideas2it.department.dao.DepartmentRepositoryImpl


    public void addEmployee(Employee employee) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
            transaction = session.beginTransaction();
            session.save(employee);
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            logger.error("Error by adding employee");
            throw new EmployeeException("Error while adding to Database : " + employee, e);
        }
    }

    public void addEmployee(Employee employee) throws DatabaseException {
        Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
        try {
            transaction = session.beginTransaction();
			session.save(employee);
			transaction.commit();
        } catch (HibernateException e) {
			if (transaction != null) {
			    transaction.rollback();
			}
            throw new DatabaseException("Error while adding to Database  :  " + e);

        } finally {
            session.close();
        }
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public addEmployee(employee Employee) : void from class com.ideas2it.employee.dao.EmployeeRepositoryImpl


    public void deleteEmployee(int id) throws EmployeeException {

        Transaction transaction = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
            transaction = session.beginTransaction();
            Employee employee = session.get(Employee.class, id);
            employee.setIsActive(false);
            session.update(employee);
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            logger.error("Error by deleting the employee");
            throw new EmployeeException("Not able to delete employee : " + id, e);
        }
    }

    public void deleteEmployee(int id) throws DatabaseException {
        Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
        try {
            transaction = session.beginTransaction();
			Employee employee = session.get(Employee.class, id);
			if (employee != null) {
			    employee.setIsActive(false);
				session.update(employee);
				transaction.commit();
			}
			else {
			    throw new DatabaseException("No Employee found in ID : " + id);
			}
        } catch (HibernateException e) {
            throw new DatabaseException("Not able to delete  "+ e + "  " + id);
        } finally {
             session.close();
        }
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public deleteEmployee(id int) : void from class com.ideas2it.employee.dao.EmployeeRepositoryImpl


    public List<Employee> getAllEmployees() throws EmployeeException {
        List<Employee> employees = new ArrayList<>();
        try (Session session = HibernateConnection.getFactory().openSession()) {
            String hql = "from Employee where isActive = true";
            Query<Employee> query = session.createQuery(hql, Employee.class);
            employees = query.list();
        } catch (HibernateException e) {
            logger.error("Unable to display all the employees");
            throw new EmployeeException("Error while getting ", e);
        }
        return employees;
    }

    public List<Employee> getAllEmployees() throws DatabaseException {
        List<Employee> employees = new ArrayList<>();
        Session session = HibernateConnection.getFactory().openSession();
		Transaction transaction = null;
        try {
			transaction = session.beginTransaction();
			String hql = "from Employee where isActive = true";
			Query<Employee> query = session.createQuery(hql, Employee.class);
			employees = query.list();
			transaction.commit();
        } catch (HibernateException e) {
			if(transaction != null) {
                transaction.rollback();
		  System.out.println(e.getMessage());
            }
            throw new DatabaseException("Error while getting " + e.getMessage());
        } finally {
             session.close();
        }
		return employees;
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public getAllEmployees() : List<Employee> from class com.ideas2it.employee.dao.EmployeeRepositoryImpl


    public Employee findEmployeeById(int id) throws EmployeeException {
        Employee employee = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
            Query<Employee> query = session.createQuery("From Employee e "
                    + "left join fetch e.department where e.id = :id "
                    + "and e.isActive = true", Employee.class);
            query.setParameter("id", id);
            employee = query.uniqueResult();
        } catch (HibernateException e) {
            logger.error("Unable to display that particular employee");
            throw new EmployeeException("Error while finding Employee with ID : " + id, e);
        }
        return employee;
    }

    public Employee findEmployeeById(int id) throws DatabaseException {
		Session session = HibernateConnection.getFactory().openSession();
		Transaction transaction = null;
        Employee employee = null;
        try {
			transaction = session.beginTransaction();
            Query<Employee> query = session.createQuery( "From Employee e "
			                        + "left join fetch e.department where e.id = :id "
									+ "and e.isActive = true", Employee.class);
			query.setParameter("id", id);
			employee = query.uniqueResult();
			transaction.commit();

         } catch (HibernateException e) {
             throw new DatabaseException("Error while finding Employee with ID : " + id);
         } finally {
             session.close();
         }
		 return employee;
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public findEmployeeById(id int) : Employee from class com.ideas2it.employee.dao.EmployeeRepositoryImpl


    public void updateEmployee(Employee employee) throws EmployeeException {

        Transaction transaction = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
            transaction = session.beginTransaction();
            session.update(employee);
            transaction.commit();

        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            logger.error("Error by updating the employee details");
            throw new EmployeeException("Error while updating employee with ID" + employee.getId(), e);
        }
    }

    public void updateEmployee(Employee employee) throws DatabaseException {
        Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
        try {
            transaction = session.beginTransaction();
			session.update(employee);
			transaction.commit();

        } catch (HibernateException e) {
			if (transaction != null) {
			    transaction.rollback();
			}
            throw new DatabaseException("Error while updating employee with ID" + employee.getId());
        } finally {
             session.close();
        }
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public updateEmployee(employee Employee) : void from class com.ideas2it.employee.dao.EmployeeRepositoryImpl


    public void addProjectToEmployee(int employeeId, int projectId)
            throws EmployeeException {

        Transaction transaction = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
            transaction = session.beginTransaction();
            Employee employee = session.get(Employee.class, employeeId);
            Project project = session.get(Project.class, projectId);
            if (employee == null || project == null) {
                throw new EmployeeException("Employee or Project not found with given ID");
            }
            employee.getProjects().add(project);
            project.getEmployees().add(employee);
            session.update(employee);
            session.update(project);
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            logger.error("Error while assigning project to employee", employeeId);
            throw new EmployeeException("Error while adding project : " + e.getMessage(), e);
        }
    }

    public void addProjectToEmployee(int employeeId, int projectId)
                                           throws DatabaseException {
        Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
        try {
            transaction = session.beginTransaction();
			Employee employee = session.get(Employee.class, employeeId);
			Project project = session.get(Project.class, projectId);

			if (employee == null || project == null) {
			    throw new DatabaseException("Employee or Project not found with given ID");
			}
			employee.getProjects().add(project);
			project.getEmployees().add(employee);
			session.update(employee);
			session.update(project);
			transaction.commit();
        } catch (HibernateException e) {
			if (transaction != null) {
				transaction.rollback();
			}
            throw new DatabaseException("Error while adding project : " + e.getMessage() + "  " + e);
        } finally {
             session.close();
        }
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public addProjectToEmployee(employeeId int, projectId int) : void from class com.ideas2it.employee.dao.EmployeeRepositoryImpl


    public void removeProjectFromEmployee(int employeeId, int projectId)
            throws EmployeeException {

        Transaction transaction = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
            transaction = session.beginTransaction();
            Employee employee = session.get(Employee.class, employeeId);
            Project project = session.get(Project.class, projectId);
            if (employee == null || project == null) {
                throw new EmployeeException("Employee or Project not found with given ID");
            }
            if (employee.getProjects().contains(project)) {
                employee.getProjects().remove(project);
                session.update(employee);
            } else {
                throw new EmployeeException("This project is not associated with the employee" + employeeId);
            }
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            logger.error("Error while removing project from employee", employeeId);
            throw new EmployeeException("Error while removing project from employee : " + employeeId, e);
        }
    }

    public void removeProjectFromEmployee(int employeeId, int projectId)
                                           throws DatabaseException {
        Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
        try {
            transaction = session.beginTransaction();
			Employee employee = session.get(Employee.class, employeeId);
			Project project = session.get(Project.class, projectId);

			if (employee == null || project == null) {
			    throw new DatabaseException("Employee or Project not found with given ID");
			}
			if (employee.getProjects().contains(project)){
				employee.getProjects().remove(project);
				session.update(employee);
			} else {
				throw new DatabaseException("This project is not associated with the employee");
			}
			transaction.commit();
        } catch (HibernateException e) {
			if (transaction != null) {
				transaction.rollback();
			}
            throw new DatabaseException("Error while removing project from employee : " + e.getMessage() + "  " + e);
        } finally {
             session.close();
        }
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public removeProjectFromEmployee(employeeId int, projectId int) : void from class com.ideas2it.employee.dao.EmployeeRepositoryImpl


    public void addProject(Project project) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
            transaction = session.beginTransaction();
            session.save(project);
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            logger.error("Error while adding the project");
            throw new EmployeeException("Error while adding project: " + project.getName(), e);
        }
    }

    public void addProject(Project project) throws DatabaseException {
        Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
        try {
			transaction = session.beginTransaction();
			session.save(project);
			transaction.commit();

        } catch (HibernateException e) {
			if(transaction != null) {
                transaction.rollback();
            }
            throw new DatabaseException ("Error while adding project" + project.getName());
        } finally {
            session.close();
        }
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public addProject(project Project) : void from class com.ideas2it.project.dao.ProjectRepositoryImpl


    public void updateProject(Project project) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
            transaction = session.beginTransaction();
            Project existingProject = session.get(Project.class, project.getId());
            existingProject.setName(project.getName());
            session.update(existingProject);
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            logger.error("Error while updating the project");
            throw new EmployeeException("Error while updating project : " + project.getId(), e);
        }
    }

    public void updateProject(Project project) throws DatabaseException {
        Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
        try {
			transaction = session.beginTransaction();
			Project existingProject = session.get(Project.class, project.getId());
			if (existingProject != null) {
			    existingProject.setName(project.getName());
				session.update(existingProject);
				transaction.commit();
			}
			else {
				throw new DatabaseException("No project found with ID : " + project.getId());
			}
        } catch (HibernateException e) {
            throw new DatabaseException ("Error while updating project : " + project.getId());
        } finally {
            session.close();
        }
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public updateProject(project Project) : void from class com.ideas2it.project.dao.ProjectRepositoryImpl


    public void deleteProject(int id) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
            transaction = session.beginTransaction();
            Project project = session.get(Project.class, id);
            session.delete(project);
            transaction.commit();
        } catch (HibernateException e) {
            if (transaction != null) {
                transaction.rollback();
            }
            logger.error("Error while deleting the project.");
            throw new EmployeeException("No project found  " + id, e);
        }
    }

    public void deleteProject(int id) throws DatabaseException {
        Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
        try {
			transaction = session.beginTransaction();
			 Project project = session.get (Project.class, id);
             if (project != null) {
                 session.delete(project);
                 transaction.commit();
             }
             else {
                 throw new DatabaseException("Project not found!!!  " + id);
             }

        } catch (HibernateException e) {
             throw new DatabaseException ("No project found  " + id);
        }  finally {
            session.close();
        }
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public deleteProject(id int) : void from class com.ideas2it.project.dao.ProjectRepositoryImpl


    public Project findProjectById(int id) throws EmployeeException {
        try (Session session = HibernateConnection.getFactory().openSession()) {
            Project project = session.get(Project.class, id);
            if (project != null) {
                return project;
            } else {
                throw new EmployeeException("Project not found in this ID : " + id);
            }
        } catch (HibernateException e) {
            throw new EmployeeException("No project found : " + id, e);
        }
    }

    public Project findProjectById(int id) throws DatabaseException {
        Session session = HibernateConnection.getFactory().openSession();
        try {
            Project project = session.get(Project.class, id);
			if (project != null) {
			    return project;
			}
			else {
			    throw new DatabaseException("Project not found in this ID : " + id);
			}

        } catch (HibernateException e) {
            throw new DatabaseException ("No project found  " + id);
        } finally {
            session.close();
        }
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public findProjectById(id int) : Project from class com.ideas2it.project.dao.ProjectRepositoryImpl


    public Project mapRowToProject(int id, String name) throws EmployeeException {
        Project project = null;
        try (Session session = HibernateConnection.getFactory().openSession()) {
            Transaction transaction = session.beginTransaction();
            project = session.get(Project.class, id);
            project.setName(name);
            transaction.commit();
        } catch (HibernateException e) {
            logger.error("No project found error");
            throw new EmployeeException("No project found : " + id, e);
        }
        return project;
    }

    public Project mapRowToProject(int id, String name) throws DatabaseException {
		Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;
		Project project = null;
        try {
			transaction = session.beginTransaction();
			project = session.get(Project.class, id);
			if (project == null) {
			    throw new DatabaseException("No project found with ID : " + id);
			}

			project.setName(name);
        } catch (HibernateException e) {
			if (transaction != null) {
			    transaction.rollback();
			}
            throw new DatabaseException ("No project found  " + id);
        } finally {
			session.close();
		}
		return project;
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public mapRowToProject(id int, name String) : Project from class com.ideas2it.project.dao.ProjectRepositoryImpl


    public List<Employee> getEmployeesByProjectId(int projectId) throws EmployeeException {
        List<Employee> employees = new ArrayList<>();
        try (Session session = HibernateConnection.getFactory().openSession()) {
            String hqlQuery = "select e from Employee e join e.projects p where p.id = :projectId and e.isActive = true";
            Query<Employee> query = session.createQuery(hqlQuery, Employee.class);
            query.setParameter("projectId", projectId);
            employees = query.list();
        } catch (HibernateException e) {
            logger.error("No employee found");
            throw new EmployeeException("No employee found in this project with ID : " + projectId);
        }
        return employees;
    }

    public List<Employee> getEmployeesByProjectId(int projectId) throws DatabaseException {
        List<Employee> employees = new ArrayList<>();
        Session session = HibernateConnection.getFactory().openSession();
        Transaction transaction = null;

        try {
			transaction = session.beginTransaction();
			String hqlQuery = "select e from Employee e join e.projects p where p.id = :projectId and e.isActive = true";
			Query<Employee> query = session.createQuery(hqlQuery, Employee.class);
			query.setParameter("projectId", projectId);
			employees = query.list();
			transaction.commit();
         } catch (HibernateException e) {
			 if (transaction != null) {
			     transaction.rollback();
			 }
             throw new DatabaseException ("No employee found in this project with ID : " + projectId);
         } finally {
             session.close();
         }
        return employees;
    }

Try With Resources try(Session session=HibernateConnection.getFactory().openSession()) in method public getEmployeesByProjectId(projectId int) : List<Employee> from class com.ideas2it.project.dao.ProjectRepositoryImpl


    @Override
    public void addCourse(String courseName) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            transaction = session.beginTransaction();
            Course course = new Course(courseName);
            session.save(course);
            transaction.commit();
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error in adding the Course: " + courseName, e);
        }
    }

    @Override
    public void addCourse(String courseName) throws EmployeeException {
        Session session = null;
        Transaction transaction = null;
        try {
            session = SessionProvider.getSessionFactory().openSession();
            transaction = session.beginTransaction();
            Course course = new Course(courseName);
            session.save(course);
            transaction.commit();
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error in adding the Course: " + courseName, e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public addCourse(courseName String) : void from class com.i2i.employeemanagement.course.dao.CourseDaoImpl


    @Override
    public void updateCourse(Course course) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            transaction = session.beginTransaction();
            session.update(course);
            transaction.commit();
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error updating the course " + course.getCourseName(), e);
        }
    }

    @Override
    public void updateCourse(Course course) throws EmployeeException {
        Session session = null;
        Transaction transaction = null;
        try {
            session = SessionProvider.getSessionFactory().openSession();
            transaction = session.beginTransaction();
            session.update(course);
            transaction.commit();
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error updating the course " + course.getCourseName(), e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public updateCourse(course Course) : void from class com.i2i.employeemanagement.course.dao.CourseDaoImpl


    @Override
    public boolean deleteCourse(int courseId) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            transaction = session.beginTransaction();
            Course course = session.get(Course.class, courseId);
            if (course != null) {
                course.setIsDeleted(true);
                session.update(course);
                transaction.commit();
                return true;
            }
            return false;
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error in deleting the Course with Id " + courseId, e);
        }
    }

    @Override
    public boolean deleteCourse(int courseId) throws EmployeeException {
        Session session = null;
        Transaction transaction = null;
        try {
            session = SessionProvider.getSessionFactory().openSession();
            transaction = session.beginTransaction();
            Course course = session.get(Course.class, courseId);
            if (course != null) {
                course.setIsDeleted(true);
                session.update(course);
                transaction.commit();
                return true;
            }
            return false;
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error in deleting the Course with Id " + courseId, e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public deleteCourse(courseId int) : boolean from class com.i2i.employeemanagement.course.dao.CourseDaoImpl


    @Override
    public Course getCourseById(int courseId) throws EmployeeException {
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            return session.get(Course.class, courseId);
        } catch (Exception e) {
            throw new EmployeeException("Error in retrieving all Courses. Cause: " + e.getMessage(), e);
        }
    }

    @Override
    public Course getCourseById(int courseId) throws EmployeeException {
        Session session = null;
        try {
            session = SessionProvider.getSessionFactory().openSession();
            Course course = session.get(Course.class, courseId);
            return course;
        } catch (Exception e) {
            throw new EmployeeException("Error in retrieving all Courses. Cause: " + e.getMessage(), e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public getCourseById(courseId int) : Course from class com.i2i.employeemanagement.course.dao.CourseDaoImpl


    @Override
    public Map<Integer, Employee> getEmployeesByCourse(int courseId) throws EmployeeException {
        Map<Integer, Employee> employees = new HashMap<>();
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            Course course = session.get(Course.class, courseId);
            if (course.getEmployees() != null) {
                for (Employee employee : course.getEmployees()) {
                    if (!employee.getIsDeleted()) {
                        employees.put(employee.getId(), employee);
                    }
                }
            }
        } catch (Exception e) {
            throw new EmployeeException("Error in retrieving Employees by Course Id" + courseId , e);
        }
        return employees;
    }

    @Override
    public Map<Integer, Employee> getEmployeesByCourse(int courseId) throws EmployeeException {
        Session session = null;
        Map<Integer, Employee> employees = new HashMap<>();
        try {
            session = SessionProvider.getSessionFactory().openSession();
            Course course = session.get(Course.class, courseId);
            if (course.getEmployees() != null) {
                for (Employee employee : course.getEmployees()) {
                    employees.put(employee.getId(), employee);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new EmployeeException("Error in retrieving Employees by Course Id" + courseId , e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
        return employees;
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public getEmployeesByCourse(courseId int) : Map<Integer,Employee> from class com.i2i.employeemanagement.course.dao.CourseDaoImpl


    @Override
    public void addDepartment(String departmentName) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            transaction = session.beginTransaction();
            Department department = new Department(departmentName);
            session.save(department);
            transaction.commit();
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error in adding the Department Name: " + departmentName, e);
        }
    }

    @Override
    public void addDepartment(String departmentName) throws EmployeeException {
        Session session = null;
        Transaction transaction = null;
        try {
            session = SessionProvider.getSessionFactory().openSession();
            transaction = session.beginTransaction();
            Department department = new Department(departmentName);
            session.save(department);
            transaction.commit();
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error in adding the Department Name: " + departmentName, e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public addDepartment(departmentName String) : void from class com.i2i.employeemanagement.department.dao.DepartmentDaoImpl


    @Override
    public Department getDepartmentById(int departmentId) throws EmployeeException{
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            return session.get(Department.class, departmentId);
        } catch (Exception e) {
            throw new EmployeeException("Error retrieving all departments:", e);
        }
    }

    @Override
    public Department getDepartmentById(int departmentId) throws EmployeeException{
        Session session = null;
        try {
            session = SessionProvider.getSessionFactory().openSession();
            Department department = session.get(Department.class, departmentId);
            return department;
        } catch (Exception e) {
            throw new EmployeeException("Error retrieving all departments:", e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public getDepartmentById(departmentId int) : Department from class com.i2i.employeemanagement.department.dao.DepartmentDaoImpl


    @Override
    public void updateDepartment(int departmentId, Department department) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            transaction = session.beginTransaction();
            session.update(department);
            transaction.commit();
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error updating the departmentId: " + departmentId, e);
        }
    }

    @Override
    public void updateDepartment(int departmentId, Department department) throws EmployeeException {
        Session session = null;
        Transaction transaction = null;
        try {
            session = SessionProvider.getSessionFactory().openSession();
            transaction = session.beginTransaction();
            session.update(department);
            transaction.commit();
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error updating the departmentId: " + departmentId, e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public updateDepartment(departmentId int, department Department) : void from class com.i2i.employeemanagement.department.dao.DepartmentDaoImpl


    @Override
    public boolean deleteDepartment(int departmentId) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            transaction = session.beginTransaction();
            Department department = session.get(Department.class, departmentId);
            if (department != null) {
                department.setIsDeleted(true);
                session.update(department);
                transaction.commit();
            }
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error deleting DepartmentId:" + departmentId, e);
        }
        return true;
    }

    @Override
    public boolean deleteDepartment(int departmentId) throws EmployeeException {
        Session session = null;
        Transaction transaction = null;
        try {
            session = SessionProvider.getSessionFactory().openSession();
            transaction = session.beginTransaction();
            Department department = session.get(Department.class, departmentId);
            if (department != null) {
                department.setIsDeleted(true);
                session.update(department);
                transaction.commit();
                return true;
            }
            return false;
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error deleting DepartmentId:" + departmentId, e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public deleteDepartment(departmentId int) : boolean from class com.i2i.employeemanagement.department.dao.DepartmentDaoImpl


    @Override
    public Map<Integer, Employee> getEmployeeByDepartment(int departmentId) throws EmployeeException {
        Map<Integer, Employee> employeeDetails = new HashMap<>();
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            Department department = session.get(Department.class, departmentId);
            if (department != null && department.getEmployees() != null) {
                for (Employee employee : department.getEmployees()) {
                    if(!employee.getIsDeleted()) {
                        employeeDetails.put(employee.getId(), employee);
                    }
                }
            }
        } catch (Exception e) {
            throw new EmployeeException("Error in retrieving employees by department " + departmentId, e);
        }
        return employeeDetails;
    }

    @Override
    public Map<Integer, Employee> getEmployeeByDepartment(int departmentId) throws EmployeeException {
        Session session = null;
        Map<Integer, Employee> employeeDetails = new HashMap<>();
        try {
            session = SessionProvider.getSessionFactory().openSession();
            Department department = session.get(Department.class, departmentId);
            if (department != null && department.getEmployees() != null) {
                for (Employee employee : department.getEmployees()) {
                    employeeDetails.put(employee.getId(), employee);
                }
            }
        } catch (Exception e) {
            throw new EmployeeException("Error in retrieving employees by department " + departmentId, e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
        return employeeDetails;
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public getEmployeeByDepartment(departmentId int) : Map<Integer,Employee> from class com.i2i.employeemanagement.department.dao.DepartmentDaoImpl


    @Override
    public int addEmployee(String name, String dob, int experience, String place, Laptop laptop, Department department) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            transaction = session.beginTransaction();
            Employee employee = new Employee(name, dob, experience, place, laptop, department);
            session.save(employee);
            transaction.commit();
            return employee.getId();
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error while adding employee: " + name, e);
        }
    }

    @Override
    public int addEmployee(String name, String dob, int experience, String place, Laptop laptop, Department department) throws EmployeeException {
        Session session = null;
        Transaction transaction = null;
        try {
            session = SessionProvider.getSessionFactory().openSession();
            transaction = session.beginTransaction();
            Employee employee = new Employee(name, dob, experience, place,laptop, department);
            session.save(employee);
            transaction.commit();
            return employee.getId();
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error while adding employee: " + name, e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public addEmployee(name String, dob String, experience int, place String, laptop Laptop, department Department) : int from class com.i2i.employeemanagement.employee.dao.EmployeeDaoImpl


    @Override
    public Map<Integer, Employee> getAllEmployees() throws EmployeeException {
        Map<Integer, Employee> employees = new HashMap<>();

        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            String hql = "From Employee WHERE isDeleted = false";
            Query<Employee> query = session.createQuery(hql, Employee.class);
            for (Employee employee : query.list()) {
                employees.put(employee.getId(), employee);
            }
        } catch (Exception e) {
            throw new EmployeeException("Error retrieving employees", e);
        }
        return employees;

    }

    @Override
    public Map<Integer, Employee> getAllEmployees() throws EmployeeException {
        Session session = null;
        Map<Integer, Employee> employees = new HashMap<>();
        try {
            session = SessionProvider.getSessionFactory().openSession();
            String hql = "From Employee WHERE isDeleted = false";
            Query<Employee> query = session.createQuery(hql, Employee.class);
            for (Employee employee : query.list()) {
                employees.put(employee.getId(), employee);
            }

        } catch (Exception e) {
            throw new EmployeeException("Error retrieving employees", e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
        return employees;
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public getAllEmployees() : Map<Integer,Employee> from class com.i2i.employeemanagement.employee.dao.EmployeeDaoImpl


    @Override
    public Employee getEmployeeById(int id) throws EmployeeException {
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            return session.get(Employee.class, id);
        } catch (Exception e) {
            throw new EmployeeException("Error retrieving employees", e);
        }
    }

    @Override
    public Employee getEmployeeById(int id) throws EmployeeException {
        Session session = null;
        try {
            session = SessionProvider.getSessionFactory().openSession();
            Employee employee = session.get(Employee.class, id);
            return employee;
        } catch (Exception e) {
            throw new EmployeeException("Error retrieving employees", e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public getEmployeeById(id int) : Employee from class com.i2i.employeemanagement.employee.dao.EmployeeDaoImpl


    @Override
    public boolean deleteEmployee(int deleteId) throws EmployeeException {
        Transaction transaction = null;
        try (Session session = SessionProvider.getSessionFactory().openSession()) {
            transaction = session.beginTransaction();
            Employee employee = session.get(Employee.class, deleteId);
            if (employee != null) {
                employee.setIsDeleted(true);
                session.update(employee);
                transaction.commit();
                return true;
            }
            return false;
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error deleting employee with Id: " + deleteId, e);
        }
    }

    @Override
    public boolean deleteEmployee(int deleteId) throws EmployeeException {
        Session session = null;
        Transaction transaction = null;
        try {
            session = SessionProvider.getSessionFactory().openSession();
            transaction = session.beginTransaction();
            Employee employee = session.get(Employee.class, deleteId);
            if (employee != null) {
                employee.setIsDeleted(true);
                session.update(employee);
                transaction.commit();
                return true;
            }
            return false;
        } catch (Exception e) {
            if (transaction != null) {
                transaction.rollback();
            }
            throw new EmployeeException("Error deleting employee with Id: " + deleteId, e);
        } finally {
            if (session != null) {
                session.close();
            }
        }
    }

Try With Resources try(Session session=SessionProvider.getSessionFactory().openSession()) in method public deleteEmployee(deleteId int) : boolean from class com.i2i.employeemanagement.employee.dao.EmployeeDaoImpl