List of usage examples for java.util Date setHours
@Deprecated public void setHours(int hours)
From source file:com.andco.salasucc.bean.nuevaBean.java
public String siguiente() { FacesContext context = FacesContext.getCurrentInstance(); horaInicio.setYear(fecha.getYear()); horaInicio.setMonth(fecha.getMonth()); horaInicio.setDate(fecha.getDate()); horaFin.setYear(fecha.getYear());/* www .j av a 2 s . co m*/ horaFin.setMonth(fecha.getMonth()); horaFin.setDate(fecha.getDate()); if ((horaFin.getTime() - horaInicio.getTime()) < 3600000) { FacesMessage errorMessage = new FacesMessage("Fecha Invalida"); errorMessage.setSeverity(FacesMessage.SEVERITY_ERROR); context.addMessage(null, errorMessage); horaFin = null; return null; } else { SalasJpaController salasCont = new SalasJpaController(); listaSalasDisponibles = new ArrayList<>(); if (!recurrente) { listaSalasDisponibles = salasCont.buscarSalasDisponibles(Integer.parseInt(numEstudiantes), Integer.parseInt(software), horaInicio, horaFin); } else { Date fechaFinSemestre = new Date(); fechaFinSemestre.setHours(23); fechaFinSemestre.setMinutes(59); if (fecha.getMonth() >= 1 && fecha.getMonth() <= 4) { fechaFinSemestre.setMonth(4); fechaFinSemestre.setDate(31); } else { fechaFinSemestre.setMonth(10); fechaFinSemestre.setDate(30); } listaFechasInicio = generaFechasRecurrentes(horaInicio, fechaFinSemestre); listaFechasFin = generaFechasRecurrentes(horaFin, fechaFinSemestre); HashMap<Salas, Integer> map = new HashMap<>(); int tam = listaFechasInicio.size(); for (int i = 0; i < tam; i++) { List<Salas> lSalas = salasCont.buscarSalasDisponibles(Integer.parseInt(numEstudiantes), Integer.parseInt(software), listaFechasInicio.get(i), listaFechasFin.get(i)); for (int j = 0; j < lSalas.size(); j++) { Salas salaActual = lSalas.get(j); Integer previousValue = map.get(salaActual); map.put(salaActual, previousValue == null ? 1 : previousValue + 1); } } for (Salas key : map.keySet()) { if (map.get(key) == tam) { listaSalasDisponibles.add(key); } } } if (listaSalasDisponibles.isEmpty()) { FacesMessage warnMessage = new FacesMessage("No hay salas disponibles"); warnMessage.setSeverity(FacesMessage.SEVERITY_WARN); context.addMessage(null, warnMessage); return null; } else { return "disponibles"; } } }
From source file:com.daphne.es.personal.calendar.web.controller.CalendarController.java
@RequestMapping("/load") @ResponseBody/*from ww w . j a v a 2s. c o m*/ public Collection<Map> ajaxLoad(Searchable searchable, @CurrentUser User loginUser) { searchable.addSearchParam("userId_eq", loginUser.getId()); List<Calendar> calendarList = calendarService.findAllWithNoPageNoSort(searchable); return Lists.<Calendar, Map>transform(calendarList, new Function<Calendar, Map>() { @Override public Map apply(Calendar c) { Map<String, Object> m = Maps.newHashMap(); Date startDate = new Date(c.getStartDate().getTime()); Date endDate = DateUtils.addDays(startDate, c.getLength() - 1); boolean allDays = c.getStartTime() == null && c.getEndTime() == null; if (!allDays) { startDate.setHours(c.getStartTime().getHours()); startDate.setMinutes(c.getStartTime().getMinutes()); startDate.setSeconds(c.getStartTime().getSeconds()); endDate.setHours(c.getEndTime().getHours()); endDate.setMinutes(c.getEndTime().getMinutes()); endDate.setSeconds(c.getEndTime().getSeconds()); } m.put("id", c.getId()); m.put("start", DateFormatUtils.format(startDate, "yyyy-MM-dd HH:mm:ss")); m.put("end", DateFormatUtils.format(endDate, "yyyy-MM-dd HH:mm:ss")); m.put("allDay", allDays); m.put("title", c.getTitle()); m.put("details", c.getDetails()); if (StringUtils.isNotEmpty(c.getBackgroundColor())) { m.put("backgroundColor", c.getBackgroundColor()); m.put("borderColor", c.getBackgroundColor()); } if (StringUtils.isNotEmpty(c.getTextColor())) { m.put("textColor", c.getTextColor()); } return m; } }); }
From source file:com.framework.demo.web.controller.calendar.CalendarController.java
@RequestMapping("/load") @ResponseBody/* w w w .j a v a 2s . c om*/ public Collection<Map> ajaxLoad(Searchable searchable, @CurrentUser SysUser loginUser) { searchable.addSearchParam("userId_eq", loginUser.getId()); List<PersonalCalendar> calendarList = calendarService.findAllWithNoPageNoSort(searchable); return Lists.<PersonalCalendar, Map>transform(calendarList, new Function<PersonalCalendar, Map>() { public Map apply(PersonalCalendar c) { Map<String, Object> m = Maps.newHashMap(); Date startDate = new Date(c.getStartDate().getTime()); Date endDate = DateUtils.addDays(startDate, c.getLength() - 1); boolean allDays = c.getStartTime() == null && c.getEndTime() == null; if (!allDays) { startDate.setHours(c.getStartTime().getHours()); startDate.setMinutes(c.getStartTime().getMinutes()); startDate.setSeconds(c.getStartTime().getSeconds()); endDate.setHours(c.getEndTime().getHours()); endDate.setMinutes(c.getEndTime().getMinutes()); endDate.setSeconds(c.getEndTime().getSeconds()); } m.put("id", c.getId()); m.put("start", DateFormatUtils.format(startDate, "yyyy-MM-dd HH:mm:ss")); m.put("end", DateFormatUtils.format(endDate, "yyyy-MM-dd HH:mm:ss")); m.put("allDay", allDays); m.put("title", c.getTitle()); m.put("details", c.getDetails()); if (StringUtils.isNotEmpty(c.getBackgroundColor())) { m.put("backgroundColor", c.getBackgroundColor()); m.put("borderColor", c.getBackgroundColor()); } if (StringUtils.isNotEmpty(c.getTextColor())) { m.put("textColor", c.getTextColor()); } return m; } }); }
From source file:com.pro.gen.android.MainActivity.java
/** * Return a {@link DataReadRequest} for all step count changes in the past week. *///from w ww . j a v a 2 s . c o m public DataReadRequest queryFitnessData() { // [START build_read_data_request] // Setting a start and end date using a range of 1 week before this moment. Calendar cal = Calendar.getInstance(); Date now = new Date(); now.setHours(0); cal.setTime(now); long endTime = cal.getTimeInMillis(); cal.add(Calendar.DATE, -1); long startTime = cal.getTimeInMillis(); java.text.DateFormat dateFormat = getDateInstance(); Log.i(TAG, "Range Start: " + dateFormat.format(startTime)); Log.i(TAG, "Range End: " + dateFormat.format(endTime)); DataReadRequest readRequest = new DataReadRequest.Builder() // The data request can specify multiple data types to return, effectively // combining multiple data queries into one call. // In this example, it's very unlikely that the request is for several hundred // datapoints each consisting of a few steps and a timestamp. The more likely // scenario is wanting to see how many steps were walked per day, for 7 days. .aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA) // Analogous to a "Group By" in SQL, defines how data should be aggregated. // bucketByTime allows for a time span, whereas bucketBySession would allow // bucketing by "sessions", which would need to be defined in code. .bucketByTime(2, TimeUnit.MINUTES).setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS).build(); // [END build_read_data_request] return readRequest; }
From source file:org.apache.metron.profiler.client.window.WindowProcessorTest.java
@Test public void testManyMoonsAgo() throws ParseException { {//from w ww . j a va 2 s. c o m Window w = WindowProcessor.process("1 hour window every 24 hours starting from 56 days ago"); Date now = new Date(); List<Range<Long>> intervals = w.toIntervals(now.getTime()); Assert.assertEquals(56, intervals.size()); } { Window w = WindowProcessor.process( "1 hour window every 24 hours starting from 56 days ago including this day of the week"); Date now = new Date(); now.setHours(6); //avoid DST impacts if near Midnight List<Range<Long>> intervals = w.toIntervals(now.getTime()); Assert.assertEquals(8, intervals.size()); } }
From source file:org.pentaho.platform.dataaccess.datasource.wizard.service.agile.CsvTransformGeneratorTest.java
public void testGoodTransform() throws Exception { IPentahoSession session = new StandaloneSession("test"); KettleSystemListener.environmentInit(session); ModelInfo info = createModel();// w w w . ja v a 2 s . c o m CsvTransformGenerator gen = new CsvTransformGenerator(info, getDatabaseMeta()); gen.preview(session); DataRow rows[] = info.getData(); assertNotNull(rows); assertEquals(235, rows.length); Date testDate = new Date(); testDate.setDate(1); testDate.setHours(0); testDate.setMinutes(0); testDate.setMonth(0); testDate.setSeconds(0); testDate.setYear(110); // test the first row // test the data types DataRow row = rows[0]; assertNotNull(row); Object cells[] = row.getCells(); assertNotNull(cells); // assertEquals( 8, cells.length ); assertTrue(cells[0] instanceof Long); assertTrue(cells[1] instanceof Double); assertTrue(cells[2] instanceof Long); assertTrue(cells[3] instanceof Date); assertTrue(cells[4] instanceof String); assertTrue(cells[5] instanceof Long); assertTrue(cells[6] instanceof Double); assertTrue(cells[7] instanceof Boolean); // test the values assertEquals((long) 3, cells[0]); assertEquals(25677.96525, cells[1]); assertEquals((long) 1231, cells[2]); assertEquals(testDate.getYear(), ((Date) cells[3]).getYear()); assertEquals(testDate.getMonth(), ((Date) cells[3]).getMonth()); assertEquals(testDate.getDate(), ((Date) cells[3]).getDate()); assertEquals(testDate.getHours(), ((Date) cells[3]).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), ((Date) cells[3]).getSeconds()); // assertEquals( testDate, cells[3] ); assertEquals("Afghanistan", cells[4]); assertEquals((long) 11, cells[5]); assertEquals(111.9090909, cells[6]); assertEquals(false, cells[7]); // test the second row testDate.setDate(2); // test the data types row = rows[1]; assertNotNull(row); cells = row.getCells(); assertNotNull(cells); assertTrue(cells[0] instanceof Long); assertTrue(cells[1] instanceof Double); assertTrue(cells[2] instanceof Long); assertTrue(cells[3] instanceof Date); assertTrue(cells[4] == null); assertTrue(cells[5] instanceof Long); assertTrue(cells[6] instanceof Double); assertTrue(cells[7] instanceof Boolean); // test the values assertEquals((long) 4, cells[0]); assertEquals(24261.81026, cells[1]); assertEquals((long) 1663, cells[2]); assertEquals(testDate.getYear(), ((Date) cells[3]).getYear()); assertEquals(testDate.getMonth(), ((Date) cells[3]).getMonth()); assertEquals(testDate.getDate(), ((Date) cells[3]).getDate()); assertEquals(testDate.getHours(), ((Date) cells[3]).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), ((Date) cells[3]).getSeconds()); // assertEquals( testDate, cells[3] ); assertEquals(null, cells[4]); // IfNull value does not seem to work assertEquals((long) 7, cells[5]); assertEquals(237.5714286, cells[6]); assertEquals(true, cells[7]); }
From source file:at.general.solutions.android.ical.parser.ICalParserThread.java
private Date parseIcalDate(String dateLine) { try {/*from w w w. j av a 2 s . c o m*/ dateLine = StringUtils.replace(dateLine, ";", ""); Date date = null; if (dateLine.contains(ICalTag.DATE_TIMEZONE)) { String[] parts = StringUtils.split(dateLine, ":"); ICAL_DATETIME_FORMAT.setTimeZone(TimeZone .getTimeZone(parts[0].substring(ICalTag.DATE_TIMEZONE.length(), parts[0].length()))); date = ICAL_DATETIME_FORMAT.parse(parts[1]); ICAL_DATETIME_FORMAT.setTimeZone(icalDefaultTimeZone); } else if (dateLine.contains(ICalTag.DATE_VALUE)) { String[] parts = StringUtils.split(dateLine, ":"); date = ICAL_DATE_FORMAT.parse(parts[1]); date.setHours(0); date.setMinutes(0); date.setSeconds(0); } else { dateLine = StringUtils.replace(dateLine, ":", ""); date = ICAL_DATETIME_FORMAT.parse(dateLine); } return date; } catch (ParseException e) { Log.e(LOG_TAG, "Cant't parse date!", e); return null; } }
From source file:org.pentaho.platform.dataaccess.datasource.wizard.service.agile.CsvTransformGeneratorIT.java
public void testLoadTable1() throws Exception { IPentahoSession session = new StandaloneSession("test"); KettleSystemListener.environmentInit(session); ModelInfo info = createModel();//from w w w . j a va 2 s . co m CsvTransformGenerator gen = new CsvTransformGenerator(info, getDatabaseMeta()); // create the model String tableName = info.getStageTableName(); try { gen.execSqlStatement(getDropTableStatement(tableName), getDatabaseMeta(), null); } catch (CsvTransformGeneratorException e) { // table might not be there yet, it is OK } // generate the database table gen.createOrModifyTable(session); // load the table loadTable(gen, info, true, session); // check the results long rowCount = this.getRowCount(tableName); assertEquals((long) 235, rowCount); DatabaseMeta databaseMeta = getDatabaseMeta(); assertNotNull(databaseMeta); Database database = new Database(databaseMeta); assertNotNull(database); database.connect(); Connection connection = null; Statement stmt = null; ResultSet sqlResult = null; try { connection = database.getConnection(); assertNotNull(connection); stmt = database.getConnection().createStatement(); // check the first row Date testDate = new Date(); testDate.setDate(1); testDate.setHours(0); testDate.setMinutes(0); testDate.setMonth(0); testDate.setSeconds(0); testDate.setYear(110); boolean ok = stmt.execute("select * from " + tableName); assertTrue(ok); sqlResult = stmt.getResultSet(); assertNotNull(sqlResult); ok = sqlResult.next(); assertTrue(ok); // test the values assertEquals((long) 3, sqlResult.getLong(1)); assertEquals(25677.96525, sqlResult.getDouble(2)); assertEquals((long) 1231, sqlResult.getLong(3)); assertEquals(testDate.getYear(), sqlResult.getDate(4).getYear()); assertEquals(testDate.getMonth(), sqlResult.getDate(4).getMonth()); assertEquals(testDate.getDate(), sqlResult.getDate(4).getDate()); assertEquals(testDate.getHours(), sqlResult.getTime(4).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), sqlResult.getTime(4).getSeconds()); // assertEquals( testDate, cells[3] ); assertEquals("Afghanistan", sqlResult.getString(5)); assertEquals((long) 11, sqlResult.getLong(6)); assertEquals(111.9090909, sqlResult.getDouble(7)); assertEquals(false, sqlResult.getBoolean(8)); } finally { sqlResult.close(); stmt.close(); connection.close(); } }
From source file:org.pentaho.platform.dataaccess.datasource.wizard.service.agile.CsvTransformGeneratorIT.java
public void testGoodTransform() throws Exception { IPentahoSession session = new StandaloneSession("test"); KettleSystemListener.environmentInit(session); String KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL = System.getProperty("KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL", "N"); ModelInfo info = createModel();/* w w w . ja va 2 s .co m*/ CsvTransformGenerator gen = new CsvTransformGenerator(info, getDatabaseMeta()); gen.preview(session); DataRow rows[] = info.getData(); assertNotNull(rows); assertEquals(235, rows.length); Date testDate = new Date(); testDate.setDate(1); testDate.setHours(0); testDate.setMinutes(0); testDate.setMonth(0); testDate.setSeconds(0); testDate.setYear(110); // test the first row // test the data types DataRow row = rows[0]; assertNotNull(row); Object cells[] = row.getCells(); assertNotNull(cells); // assertEquals( 8, cells.length ); assertTrue(cells[0] instanceof Long); assertTrue(cells[1] instanceof Double); assertTrue(cells[2] instanceof Long); assertTrue(cells[3] instanceof Date); assertTrue(cells[4] instanceof String); assertTrue(cells[5] instanceof Long); assertTrue(cells[6] instanceof Double); assertTrue(cells[7] instanceof Boolean); // test the values assertEquals((long) 3, cells[0]); assertEquals(25677.96525, cells[1]); assertEquals((long) 1231, cells[2]); assertEquals(testDate.getYear(), ((Date) cells[3]).getYear()); assertEquals(testDate.getMonth(), ((Date) cells[3]).getMonth()); assertEquals(testDate.getDate(), ((Date) cells[3]).getDate()); assertEquals(testDate.getHours(), ((Date) cells[3]).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), ((Date) cells[3]).getSeconds()); // assertEquals( testDate, cells[3] ); assertEquals("Afghanistan", cells[4]); assertEquals((long) 11, cells[5]); assertEquals(111.9090909, cells[6]); assertEquals(false, cells[7]); // test the second row testDate.setDate(2); // test the data types row = rows[1]; assertNotNull(row); cells = row.getCells(); assertNotNull(cells); assertTrue(cells[0] instanceof Long); assertTrue(cells[1] instanceof Double); assertTrue(cells[2] instanceof Long); assertTrue(cells[3] instanceof Date); if ("Y".equals(KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL)) { assertTrue("".equals(cells[4])); } else { assertTrue(cells[4] == null); } assertTrue(cells[5] instanceof Long); assertTrue(cells[6] instanceof Double); assertTrue(cells[7] instanceof Boolean); // test the values assertEquals((long) 4, cells[0]); assertEquals(24261.81026, cells[1]); assertEquals((long) 1663, cells[2]); assertEquals(testDate.getYear(), ((Date) cells[3]).getYear()); assertEquals(testDate.getMonth(), ((Date) cells[3]).getMonth()); assertEquals(testDate.getDate(), ((Date) cells[3]).getDate()); assertEquals(testDate.getHours(), ((Date) cells[3]).getHours()); // assertEquals( testDate.getMinutes(), ((Date)cells[3]).getMinutes() ); this fails, a bug in the PDI date parsing? assertEquals(testDate.getSeconds(), ((Date) cells[3]).getSeconds()); // assertEquals( testDate, cells[3] ); if ("Y".equals(KETTLE_EMPTY_STRING_DIFFERS_FROM_NULL)) { assertEquals("", cells[4]); assertEquals(cells[4], ""); } else { assertEquals(null, cells[4]); // IfNull value does not seem to work } assertEquals((long) 7, cells[5]); assertEquals(237.5714286, cells[6]); assertEquals(true, cells[7]); }
From source file:com.pearson.dashboard.util.Util.java
public static void retrieveTestResults(DashboardForm dashboardForm, Configuration configuration, String cutoffDateStr, List<String> testSets) throws IOException, URISyntaxException, ParseException { RallyRestApi restApi = loginRally(configuration); QueryRequest testCaseResultsRequest = new QueryRequest("TestCaseResult"); testCaseResultsRequest.setFetch(//from ww w . java 2 s .c o m new Fetch("Build", "TestCase", "TestSet", "Verdict", "FormattedID", "Date", "TestCaseCount")); if (testSets == null || testSets.isEmpty()) { testSets = new ArrayList<String>(); testSets.add("TS0"); } QueryFilter queryFilter = new QueryFilter("TestSet.FormattedID", "=", testSets.get(0)); int q = 1; while (testSets.size() > q) { queryFilter = queryFilter.or(new QueryFilter("TestSet.FormattedID", "=", testSets.get(q))); q++; } testCaseResultsRequest.setLimit(4000); testCaseResultsRequest.setQueryFilter(queryFilter); boolean dataNotReceived = true; while (dataNotReceived) { try { QueryResponse testCaseResultResponse = restApi.query(testCaseResultsRequest); JsonArray array = testCaseResultResponse.getResults(); int numberTestCaseResults = array.size(); dataNotReceived = false; List<Priority> priorities = new ArrayList<Priority>(); Priority priority0 = new Priority(); priority0.setPriorityName("Pass"); Priority priority1 = new Priority(); priority1.setPriorityName("Blocked"); Priority priority2 = new Priority(); priority2.setPriorityName("Error"); Priority priority3 = new Priority(); priority3.setPriorityName("Fail"); Priority priority4 = new Priority(); priority4.setPriorityName("Inconclusive"); Priority priority5 = new Priority(); priority5.setPriorityName("NotAttempted"); List<TestCase> testCases = new ArrayList<TestCase>(); List<TestResult> testResults = new ArrayList<TestResult>(); if (numberTestCaseResults > 0) { for (int i = 0; i < numberTestCaseResults; i++) { TestResult testResult = new TestResult(); TestCase testCase = new TestCase(); String build = array.get(i).getAsJsonObject().get("Build").getAsString(); String verdict = array.get(i).getAsJsonObject().get("Verdict").getAsString(); DateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd"); String strDate = array.get(i).getAsJsonObject().get("Date").getAsString().substring(0, 10); int hour = Integer.parseInt( array.get(i).getAsJsonObject().get("Date").getAsString().substring(11, 13)); int min = Integer.parseInt( array.get(i).getAsJsonObject().get("Date").getAsString().substring(14, 16)); Date date = (Date) formatter1.parse(strDate); date.setHours(hour); date.setMinutes(min); JsonObject testSetJsonObj = array.get(i).getAsJsonObject().get("TestSet").getAsJsonObject(); JsonObject testCaseJsonObj = array.get(i).getAsJsonObject().get("TestCase") .getAsJsonObject(); String testSet = testSetJsonObj.get("FormattedID").getAsString(); String testCaseId = testCaseJsonObj.get("FormattedID").getAsString(); int resultExists = testResultExists(testSet, testCaseId, date, testResults, testCases); if (resultExists != 0) { testResult.setDate(date); testResult.setStatus(verdict); testResult.setTestCase(testCaseId); testResult.setTestSet(testSet); testResults.add(testResult); testCase.setTestCaseId(testCaseId); testCase.setLastVerdict(verdict); testCase.setName(testSet); testCase.setDescription(""); testCase.setLastRun(strDate); testCase.setLastBuild(build); testCase.setPriority(""); testCases.add(testCase); } } } for (TestResult result : testResults) { String verdict = result.getStatus(); if (verdict.equalsIgnoreCase("error")) { priority2.setPriorityCount(priority2.getPriorityCount() + 1); } else if (verdict.equalsIgnoreCase("pass")) { priority0.setPriorityCount(priority0.getPriorityCount() + 1); } else if (verdict.equalsIgnoreCase("fail")) { priority3.setPriorityCount(priority3.getPriorityCount() + 1); } else if (verdict.equalsIgnoreCase("inconclusive")) { priority4.setPriorityCount(priority4.getPriorityCount() + 1); } else if (verdict.equalsIgnoreCase("blocked")) { priority1.setPriorityCount(priority1.getPriorityCount() + 1); } } dashboardForm.setTestCases(testCases); QueryRequest testCaseCountReq = new QueryRequest("TestSet"); testCaseCountReq.setFetch(new Fetch("FormattedID", "Name", "TestCaseCount")); queryFilter = new QueryFilter("FormattedID", "=", testSets.get(0)); q = 1; while (testSets.size() > q) { queryFilter = queryFilter.or(new QueryFilter("FormattedID", "=", testSets.get(q))); q++; } testCaseCountReq.setQueryFilter(queryFilter); QueryResponse testCaseResponse = restApi.query(testCaseCountReq); int testCaseCount = 0; for (int i = 0; i < testCaseResponse.getResults().size(); i++) { testCaseCount = testCaseCount + testCaseResponse.getResults().get(i).getAsJsonObject() .get("TestCaseCount").getAsInt(); } int unAttempted = testCaseCount - priority0.getPriorityCount() - priority1.getPriorityCount() - priority2.getPriorityCount() - priority3.getPriorityCount() - priority4.getPriorityCount(); priority5.setPriorityCount(unAttempted); List<Integer> arrayList = new ArrayList<Integer>(); arrayList.add(priority0.getPriorityCount()); arrayList.add(priority1.getPriorityCount()); arrayList.add(priority2.getPriorityCount()); arrayList.add(priority3.getPriorityCount()); arrayList.add(priority4.getPriorityCount()); arrayList.add(priority5.getPriorityCount()); Integer maximumCount = Collections.max(arrayList); if (maximumCount <= 0) { priority0.setPxSize("0"); priority1.setPxSize("0"); priority2.setPxSize("0"); priority3.setPxSize("0"); priority4.setPxSize("0"); priority5.setPxSize("0"); } else { priority0.setPxSize(Math.round((100 * priority0.getPriorityCount()) / maximumCount) + ""); priority1.setPxSize(Math.round((100 * priority1.getPriorityCount()) / maximumCount) + ""); priority2.setPxSize(Math.round((100 * priority2.getPriorityCount()) / maximumCount) + ""); priority3.setPxSize(Math.round((100 * priority3.getPriorityCount()) / maximumCount) + ""); priority4.setPxSize(Math.round((100 * priority4.getPriorityCount()) / maximumCount) + ""); priority5.setPxSize(Math.round((100 * priority5.getPriorityCount()) / maximumCount) + ""); } priorities.add(priority0); priorities.add(priority1); priorities.add(priority2); priorities.add(priority3); priorities.add(priority4); priorities.add(priority5); dashboardForm.setTestCasesCount(testCaseCount); dashboardForm.setTestCasesPriorities(priorities); } catch (HttpHostConnectException connectException) { if (restApi != null) { restApi.close(); } try { restApi = loginRally(configuration); } catch (URISyntaxException e) { e.printStackTrace(); } } } }