/** * @param user * @return user @Desc This function populates the "classifiedTimeVector" variable of the * com.post.parser.model.User class. It gives the total number of posts in the specified time * range which has been described in getTimeCategory(int hours) in this class. */ public User setCategorizedHourOfDayToUser(User user) { int[] userTimeVector = user.getClassifiedHourOfDayVector(); for (Posts posts : user.getUserPost()) { Timestamp ts = Timestamp.valueOf( new SimpleDateFormat("yyyy-MM-dd ").format(new Date()).concat(posts.getTime())); int timeCategory = ts.getHours(); userTimeVector[timeCategory] = userTimeVector[timeCategory] + 1; } user.setClassifiedHourOfDayVector(userTimeVector); return user; }
/** * @param user @Desc This function populates the "classifiedTimeVector" variable of the * com.post.parser.model.User class. It gives the total number of posts in the specified time * range which has been described in getTimeCategory(int hours) in this class. * @return List<User> */ public User setCategorizedTimeToUser(User user) { ClusterCommons cc = new ClusterCommons(); int[] userTimeVector = user.getClassifiedTimeVector(); for (Posts posts : user.getUserPost()) { Timestamp ts = Timestamp.valueOf( new SimpleDateFormat("yyyy-MM-dd ").format(new Date()).concat(posts.getTime())); int timeCategory = cc.getTimeCategory(ts.getHours()); if (timeCategory < 6) { userTimeVector[timeCategory] = userTimeVector[timeCategory] + 1; } } user.setClassifiedTimeVector(userTimeVector); return user; }
@Override public void run() { // thread content // TODO Auto-generated method stub if (timerfirst) { // lock by the first thread executing it timerfirst = false; while (true) { while (!computerClock) { // switch between program clock and computer clock try { Thread.currentThread().sleep(1000); // sleep every second } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } // second++; //increase the timer by a second // if (second == 60) //increase the minute and hour and day // { // second = 0; // minute++; // } // if (minute ==60){ // minute = 0; // hour++; // } // if (hour ==24){ // hour = 0; // day++; // weekday = (weekday+1) % weekdays.length; // parent.UpdateCal(); //redraw the view // } // if ((day == 29) && (month == 2)){ //2 means February, check leap year // if (year % 4 != 0 || (year % 100)== 0 && (year % 400) != 0){ // e.g. 1700 is not a // leap year // day = 1; // month++; // } // // // } // if ((day == 30) && (month ==2)){ //handling of leap year // day = 1; // month++; // } // if (((month == 1) || (month == 3)|| (month == 5)|| (month == 7)|| (month == 8) // ||(month == 10) || (month == 12)) && (day== 32)){ //handling of months with 31 days // day = 1; // month++; // } // if (((month == 4) || (month == 6)|| (month == 9)|| (month == 11)) && (day== 31)){ // //handling of months with 30 days // day =1; // month++; // } // if (month==13){ //switch to a new year // month =1; // year++; // } currentTime.setTime(currentTime.getTime() + 1000); year = currentTime.getYear() + 1900; month = currentTime.getMonth() + 1; day = currentTime.getDate(); hour = currentTime.getHours(); minute = currentTime.getMinutes(); second = currentTime.getSeconds(); weekday = currentTime.getDay(); // outputTheCurrentTime(); } while (computerClock) { try { // obtain the computer time every second Thread.currentThread().sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } Calendar cal = Calendar.getInstance(); day = cal.get(Calendar.DATE); month = cal.get(Calendar.MONTH) + 1; year = cal.get(Calendar.YEAR); hour = cal.get(Calendar.HOUR_OF_DAY); minute = cal.get(Calendar.MINUTE); second = cal.get(Calendar.SECOND); weekday = cal.get(Calendar.DAY_OF_WEEK) - 1; } } } else { // Thread 2 is responsible for providing an user interface for accessing the timer int option = -1; while (option != 0) { System.out.println("1) Output the current time"); // System.out.println("2) Modify the time"); System.out.println("2) Switch mode (Program clock <-> Computer Clock)"); System.out.println("0) Quit"); System.out.print("Please choose an option: "); Scanner scanner = new Scanner(System.in); option = Integer.parseInt(scanner.next()); if (option == 1) { outputTheCurrentTime(); } // if (option == 2){ // System.out.println("Please input the year, month(in integer), day, hour, minute // and second separated by a space: "); // year = Integer.parseInt(scanner.next()); // month = Integer.parseInt(scanner.next()); // day = Integer.parseInt(scanner.next()); // hour = Integer.parseInt(scanner.next()); // minute = Integer.parseInt(scanner.next()); // second = Integer.parseInt(scanner.next()); // // // //Sun = 0, Mon = 1, Tue = 2, Wed = 3, Thurs = 4. Fri = 5, Sat = 6 // java.util.GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance(); // //set the weekday of the input date // cal.setTime(new Timestamp(year-1900, month-1, day, hour, minute, second, 0)); // // weekday = cal.get(java.util.Calendar.DAY_OF_WEEK)-1; // // // if (parent != null) // parent.UpdateCal(); //redraw the view // System.out.println(); // } if (option == 3) { // switch between program timer and computer clock if (!computerClock) { computerClock = true; System.out.println("Computer Clock is in effective."); } else { computerClock = false; System.out.println("Program Clock is in effective."); } System.out.println(); } } } }
public void seleccionarMarcaDocente(ActionEvent event) { int paramDocId; int paramSesId; String paramCurNombre; String paramSecNombre; AcDocente acDoc; AcSesionAsistencia sesAsis; AcSesionEfectivaAsisDoc sesEfecAsisDoc; AsistenciaDocenteBean asisDoc; ClSeccion clSec; HSAsistenciaDocenteDAO asisDocDAO; HSDocenteDAO docDAO; Timestamp t1; Timestamp t2; paramDocId = CommonWeb.parseObjToInt(CommonWeb.getParamFromUIParameterUI(event, "w_doc_id")); paramSesId = CommonWeb.parseObjToInt(CommonWeb.getParamFromUIParameterUI(event, "w_ses_id")); paramCurNombre = CommonWeb.getParamFromUIParameterUI(event, "p_cur_nombre"); paramSecNombre = CommonWeb.getParamFromUIParameterUI(event, "p_sec_nombre"); asisDocDAO = CommonDAO.getAsistenciaDocenteDAO(); docDAO = CommonDAO.getAcDocenteDAO(); try { sesEfecAsisDoc = asisDocDAO.listaMarcadoDeAsistencia_x_Docente(paramSesId); asisDoc = new AsistenciaDocenteBean(); if (sesEfecAsisDoc instanceof AcSesionEfectivaAsisDoc) { asisDoc.setDoc_id(sesEfecAsisDoc.getAcDocente().getId()); asisDoc.setDoc_codigo(sesEfecAsisDoc.getAcDocente().getDocCodigo()); asisDoc.setDoc_nombre(sesEfecAsisDoc.getAcDocente().getDocNombre()); asisDoc.setSes_id(sesEfecAsisDoc.getAcSesionAsistencia().getSesId()); clSec = CommonDAO.getClSeccionDAO() .seleccionarSeccion(sesEfecAsisDoc.getAcSesionAsistencia().getAcSeccion().getId()); try { asisDoc.setSec_nombre(clSec.getSecNombre()); } catch (Exception ex) { asisDoc.setSec_nombre("NO DETERMINADO"); ex.printStackTrace(); } try { asisDoc.setCur_nombre(clSec.getClArbolAcademico().getArbAcadPadre().getArbDescripcion()); } catch (Exception ex) { asisDoc.setCur_nombre("NO DETERMINADO"); ex.printStackTrace(); } asisDoc.setEstasis_code(sesEfecAsisDoc.getSesefeasisdocTipo()); asisDoc.setSesefeasisdoc_fecha( sesEfecAsisDoc.getAcSesionAsistencia().getSesFechaRegistro()); asisDoc.setSesefeasisdoc_id(sesEfecAsisDoc.getSesefeasisdocId()); t1 = sesEfecAsisDoc.getSesefeasisdocRegistro(); t2 = sesEfecAsisDoc.getSesefeasisdocSalida(); if (t1 != null) { asisDoc.setReg_hora(t1.getHours()); asisDoc.setReg_min(t1.getMinutes()); } if (t2 != null) { asisDoc.setSal_hora(t2.getHours()); asisDoc.setSal_min(t2.getMinutes()); } sesAsis = asisDocDAO.listarSessionAsistencia_x_sesid(paramSesId); asisDoc.setRegistro(sesAsis.getSesFechaInicio()); asisDoc.setSalida(sesAsis.getSesFechaFin()); asisDoc.setSesefeasisdoc_registro(sesEfecAsisDoc.getSesefeasisdocRegistro()); asisDoc.setSesefeasisdoc_salida(sesEfecAsisDoc.getSesefeasisdocSalida()); asisDoc.setSesefeasisdoc_obs(sesEfecAsisDoc.getSesefeasisdocObs()); } else { // System.out.println("nuevo ingreso!"); acDoc = docDAO.seleccionarDocente(paramDocId); sesAsis = asisDocDAO.listarSessionAsistencia_x_sesid(paramSesId); asisDoc.setRegistro(sesAsis.getSesFechaInicio()); asisDoc.setSalida(sesAsis.getSesFechaFin()); asisDoc.setSesefeasisdoc_fecha(sesAsis.getSesFechaRegistro()); asisDoc.setDoc_id(acDoc.getId()); asisDoc.setDoc_codigo(acDoc.getDocCodigo()); asisDoc.setDoc_nombre(acDoc.getDocNombre()); asisDoc.setSes_id(paramSesId); asisDoc.setSec_nombre(paramSecNombre); asisDoc.setCur_nombre(paramCurNombre); } asisDocente = asisDoc; oncomplete = "Richfaces.showModalPanel('mpAsisDocente')"; } catch (Exception e) { e.printStackTrace(); } }