public void executeAction() {
    
        if(getSelectedStudent()==null){            
             JOptionPane.showMessageDialog(null,"Please select a student to generate the report","No Student Found", JOptionPane.ERROR_MESSAGE);
              return;
        }
        CourseDAO courseDAO=new CourseDAO();
        List <StudentRegisteredCourse> registeredCourses=dao.getFollowedCourses(getSelectedStudent().getId());
        ReportModule mod=null;
        report.clear();
        InstanceInvoker in=new InstanceInvoker();
        MarkCalculator calculator=new MarkCalculator();
        CourseDAO courseType=new CourseDAO();
        double sumOf_C_G=0;
        double sumOfCredits=0;
        for (StudentRegisteredCourse studentRegisteredCourse : registeredCourses) {
            
            Course c=courseDAO.getCourseByPrimaryID(studentRegisteredCourse.getCourseID());
            
            MarkAdapter adapter=new MarkAdapter();
             
            in.initTargetObj(studentRegisteredCourse, adapter);
            int totalMarks=0;
            System.out.println("c.getType(). : "+c.getType());
            System.out.println("c.getType().equals(courseType.OPTIONAL_COURSE_WITH_PRACTICAL) ? : "+ (c.getType().equals(courseType.OPTIONAL_COURSE_WITH_PRACTICAL)));
            
            if(c.getType().equals(courseType.CORE_COURSE)){            
                totalMarks= calculator.getTotalMarksForCourse(adapter, CoreCourse.class);                
            
            }else if(c.getType().equals(courseType.CORE_COURSE_WITH_PRACTICAL)){                
               totalMarks= calculator.getTotalMarksForCourse(adapter, CoreCourseWithPractical.class);                
            
            }else if(c.getType().equals(courseType.OPTIONAL_COURSE)){                
               totalMarks= calculator.getTotalMarksForCourse(adapter, OptionalCourse.class);                
            
            }else if(c.getType().equals(courseType.OPTIONAL_COURSE_WITH_PRACTICAL)){                
               totalMarks= calculator.getTotalMarksForCourse(adapter, OptionalCourseWithPractical.class);                
            
            }else if(c.getType().equals(courseType.PROJECT)){                
               totalMarks= calculator.getTotalMarksForCourse(adapter, Project.class);                
            
            }
            
            
            System.out.println("course name folowed : "+c.getName()+"  totalMarks : "+totalMarks);
            String grade=calculator.getGPARates(totalMarks)[0];
            String grdP_S=calculator.getGPARates(totalMarks)[1];
            System.out.println(" g p : "+grdP_S+"  grade : "+grade);
            double gradePoint=Double.parseDouble(grdP_S);
            
            sumOf_C_G +=(c.getCredits() * gradePoint);
            sumOfCredits +=c.getCredits();
            mod=new ReportModule(c.getCode(),c.getName(),(totalMarks+""), (c.getCredits()+""),grade );
              /*
               * (String courseCode, String courseName, String marks, String grade, String credits)
               */     
                
            report.add(mod);
        }
        
        double GPA=sumOf_C_G/sumOfCredits;
        System.out.println("GPA is : "+GPA);
        
        double dd=(GPA*100);
        System.out.println("d :"+dd);
        dd=Math.round(dd);
        System.out.println("d: "+dd);
        dd=dd/100;
        System.out.println("f d :"+dd);
        setGPA(dd+"");
        
        
        try {
            InputStream inn = getClass().getResourceAsStream("/edu/ugms/action/report1.jasper");//("/Reports/invoice.jasper");
            Map<String, Object> params = new HashMap<String, Object>();
            params.put("discount", String.valueOf(2));
           // System.out.println("\n\n---------total value is: " + totalValue);
          //  params.put("ttl", D.d(totalValue));
           
            String s =("/edu/ugms/report/"); // ("/Reports/"); 
            s="/edu/ugms/action";
            String reportsDirPath = this.getClass().getResource(s).getPath();//s.getClass().getResource(s).getFile();
            
            File reportsDir = new File(reportsDirPath); 
                System.out.println("Report path is: "+reportsDirPath); 
           // params.put(JRParameter.REPORT_FILE_RESOLVER, new SimpleFileResolver(reportsDir));
           params.put("path", reportsDir.getAbsolutePath())     ;

            JRBeanCollectionDataSource datasource = new JRBeanCollectionDataSource(report);
            JasperPrint jasperPrint = JasperFillManager.fillReport(inn, params, datasource);

          
                //JasperViewer.viewReport(jasperPrint, false);
                new Shows().showJasper(jasperPrint, "TRANSCRIPT:" + getSelectedStudent().getFirstName() +" "+getSelectedStudent().getLastName());
          

             //final JRPrintServiceExporter exporter = new JRPrintServiceExporter();
           // exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
//            exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
           // exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
                     //  exporter.setParameter(JRPrintServiceExporterParameter., Boolean.TRUE);
            
            //JasperPrintManager.printReport(jasperPrint, false);



        } catch (Exception e) {
            e.printStackTrace();
        }
        
    }