List of usage examples for java.util Calendar HOUR
int HOUR
To view the source code for java.util Calendar HOUR.
Click Source Link
get
and set
indicating the hour of the morning or afternoon. From source file:controller.ISLogin.java
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json"); try (PrintWriter out = response.getWriter()) { String email = request.getParameter("email"); String password = request.getParameter("password"); JSONObject object = new JSONObject(); if (email != null && password != null) { String sql = "SELECT * FROM user WHERE email = ? AND password = SHA1(?)"; try (PreparedStatement statement = conn.prepareStatement(sql)) { statement.setString(1, email); statement.setString(2, password); ResultSet result = statement.executeQuery(); if (result.next()) { int u_id = result.getInt("u_id"); String uuid = UUID.randomUUID().toString().replaceAll("-", ""); Calendar time = Calendar.getInstance(); time.setTime(new Date()); time.add(Calendar.HOUR, 2); conn.setAutoCommit(false); String delete = "DELETE from token WHERE u_id = ?"; String insert = "INSERT INTO token (access_token, u_id, expiry_date)" + "VALUES (?, ?, ?)"; try (PreparedStatement deleteStatement = conn.prepareStatement(delete); PreparedStatement insertStatement = conn.prepareStatement(insert);) { deleteStatement.setInt(1, u_id); Timestamp timestamp = new Timestamp(time.getTimeInMillis()); insertStatement.setString(1, uuid); insertStatement.setInt(2, u_id); insertStatement.setTimestamp(3, timestamp); deleteStatement.execute(); insertStatement.execute(); object.put("token", uuid); object.put("expiry_date", timestamp.getTime()); conn.commit();/* w ww.ja v a2s . co m*/ } finally { conn.setAutoCommit(true); } } else { object.put("error", "Invalid email or password"); } } catch (SQLException e) { e.printStackTrace(); } } else { object.put("error", "Empty email or password"); } out.println(object.toString()); } }
From source file:de.otto.mongodb.profiler.web.AbstractController.java
protected static long lowerBoundary(int diffHours) { final Calendar cal = Calendar.getInstance(Locale.ENGLISH); cal.add(Calendar.HOUR, diffHours); return cal.getTimeInMillis(); }
From source file:net.servicefixture.converter.XMLGregorianCalendarConverter.java
private XMLGregorianCalendar calendarToXMLGregorianCalendar(Calendar calendar) { XMLGregorianCalendar xmlCal;//from w ww. ja va 2 s . co m try { xmlCal = DatatypeFactory.newInstance().newXMLGregorianCalendar(); } catch (DatatypeConfigurationException e) { throw new RuntimeException("Failed to create XMLGregorianCalendar", e); } xmlCal.setYear(calendar.get(Calendar.YEAR)); xmlCal.setMonth(calendar.get(Calendar.MONTH) + 1); xmlCal.setDay(calendar.get(Calendar.DAY_OF_MONTH)); xmlCal.setHour(calendar.get(Calendar.HOUR)); xmlCal.setMinute(calendar.get(Calendar.MINUTE)); xmlCal.setSecond(calendar.get(Calendar.SECOND)); xmlCal.setMillisecond(calendar.get(Calendar.MILLISECOND)); return xmlCal; }
From source file:com.redhat.rhn.frontend.graphing.test.GraphGeneratorTest.java
private TimeSeriesData[] getTestTimeSeriesData(String metric, int size) { TimeSeriesData[] tsd = new TimeSeriesData[size]; for (int i = 0; i < tsd.length; i++) { Calendar start = Calendar.getInstance(); start.roll(Calendar.HOUR, -3); start.add(Calendar.MINUTE, (i * 5)); Float rnd = new Float(Math.random() * 10); tsd[i] = new TimeSeriesData("1-2-test", rnd, start.getTime(), metric); }/*from w w w .jav a 2 s .c o m*/ return tsd; }
From source file:org.flowable.rest.service.api.runtime.TaskQueryResourceTest.java
/** * Test querying tasks. GET runtime/tasks *///from w ww . jav a 2 s . com @Deployment public void testQueryTasks() throws Exception { try { Calendar adhocTaskCreate = Calendar.getInstance(); adhocTaskCreate.set(Calendar.MILLISECOND, 0); Calendar processTaskCreate = Calendar.getInstance(); processTaskCreate.add(Calendar.HOUR, 2); processTaskCreate.set(Calendar.MILLISECOND, 0); Calendar inBetweenTaskCreation = Calendar.getInstance(); inBetweenTaskCreation.add(Calendar.HOUR, 1); processEngineConfiguration.getClock().setCurrentTime(adhocTaskCreate.getTime()); Task adhocTask = taskService.newTask(); adhocTask.setAssignee("gonzo"); adhocTask.setOwner("owner"); adhocTask.setDelegationState(DelegationState.PENDING); adhocTask.setDescription("Description one"); adhocTask.setName("Name one"); adhocTask.setDueDate(adhocTaskCreate.getTime()); adhocTask.setPriority(100); adhocTask.setFormKey("myForm.json"); adhocTask.setCategory("some-category"); taskService.saveTask(adhocTask); taskService.addUserIdentityLink(adhocTask.getId(), "misspiggy", IdentityLinkType.PARTICIPANT); processEngineConfiguration.getClock().setCurrentTime(processTaskCreate.getTime()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "myBusinessKey"); Task processTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()) .singleResult(); processTask.setParentTaskId(adhocTask.getId()); processTask.setPriority(50); processTask.setDueDate(processTaskCreate.getTime()); taskService.saveTask(processTask); // Check filter-less to fetch all tasks String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_QUERY); ObjectNode requestNode = objectMapper.createObjectNode(); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId(), adhocTask.getId()); // Name filtering requestNode.removeAll(); requestNode.put("name", "Name one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Name like filtering requestNode.removeAll(); requestNode.put("nameLike", "%one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Description filtering requestNode.removeAll(); requestNode.put("description", "Description one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Description like filtering requestNode.removeAll(); requestNode.put("descriptionLike", "%one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Priority filtering requestNode.removeAll(); requestNode.put("priority", 100); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Mininmum Priority filtering requestNode.removeAll(); requestNode.put("minimumPriority", 70); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Maximum Priority filtering requestNode.removeAll(); requestNode.put("maximumPriority", 70); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Owner filtering requestNode.removeAll(); requestNode.put("owner", "owner"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Assignee filtering requestNode.removeAll(); requestNode.put("assignee", "gonzo"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Owner like filtering requestNode.removeAll(); requestNode.put("ownerLike", "owne%"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Assignee like filtering requestNode.removeAll(); requestNode.put("assigneeLike", "%onzo"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Unassigned filtering requestNode.removeAll(); requestNode.put("unassigned", true); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Delegation state filtering requestNode.removeAll(); requestNode.put("delegationState", "pending"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Candidate user filtering requestNode.removeAll(); requestNode.put("candidateUser", "kermit"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Candidate group filtering requestNode.removeAll(); requestNode.put("candidateGroup", "sales"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Candidate group In filtering requestNode.removeAll(); ArrayNode arrayNode = requestNode.arrayNode(); arrayNode.add("sales"); arrayNode.add("someOtherGroup"); requestNode.set("candidateGroupIn", arrayNode); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Involved user filtering requestNode.removeAll(); requestNode.put("involvedUser", "misspiggy"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Process instance filtering requestNode.removeAll(); requestNode.put("processInstanceId", processInstance.getId()); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Execution filtering requestNode.removeAll(); Execution taskExecution = runtimeService.createExecutionQuery().activityId("processTask") .singleResult(); requestNode.put("executionId", taskExecution.getId()); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process instance businesskey filtering requestNode.removeAll(); requestNode.put("processInstanceBusinessKey", "myBusinessKey"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process instance businesskey like filtering requestNode.removeAll(); requestNode.put("processInstanceBusinessKeyLike", "myBusiness%"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition key requestNode.removeAll(); requestNode.put("processDefinitionKey", "oneTaskProcess"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition key like requestNode.removeAll(); requestNode.put("processDefinitionKeyLike", "%TaskProcess"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition name requestNode.removeAll(); requestNode.put("processDefinitionName", "The One Task Process"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition name like requestNode.removeAll(); requestNode.put("processDefinitionNameLike", "The One %"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // CreatedOn filtering requestNode.removeAll(); requestNode.put("createdOn", getISODateString(adhocTaskCreate.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // CreatedAfter filtering requestNode.removeAll(); requestNode.put("createdAfter", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // CreatedBefore filtering requestNode.removeAll(); requestNode.put("createdBefore", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Subtask exclusion requestNode.removeAll(); requestNode.put("excludeSubTasks", true); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Task definition key filtering requestNode.removeAll(); requestNode.put("taskDefinitionKey", "processTask"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Task definition key like filtering requestNode.removeAll(); requestNode.put("taskDefinitionKeyLike", "process%"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Duedate filtering requestNode.removeAll(); requestNode.put("dueDate", getISODateString(adhocTaskCreate.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Due after filtering requestNode.removeAll(); requestNode.put("dueAfter", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Due before filtering requestNode.removeAll(); requestNode.put("dueBefore", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Suspend process-instance to have a suspended task runtimeService.suspendProcessInstanceById(processInstance.getId()); // Suspended filtering requestNode.removeAll(); requestNode.put("active", false); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Active filtering requestNode.removeAll(); requestNode.put("active", true); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Filtering by category requestNode.removeAll(); requestNode.put("category", "some-category"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Filtering without duedate requestNode.removeAll(); requestNode.put("withoutDueDate", true); // No response should be returned, no tasks without a duedate yet assertResultsPresentInPostDataResponse(url, requestNode); processTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); processTask.setDueDate(null); taskService.saveTask(processTask); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); } finally { // Clean adhoc-tasks even if test fails List<Task> tasks = taskService.createTaskQuery().list(); for (Task task : tasks) { if (task.getExecutionId() == null) { taskService.deleteTask(task.getId(), true); } } } }
From source file:cl.usach.trellosessionbeans.TarjetaTrello.java
@Override public void buscarTarjetasPorLista(Equipo equipo) { Trello trello = new TrelloMake(); trello.setConfigTrello(equipo.getIdCuenta().getKeyCuenta(), equipo.getIdCuenta().getSecretCuenta(), equipo.getIdCuenta().getTokenCuenta()); try {/*from w w w.j ava 2 s. c o m*/ List<CardElement> cardsElement = trello.getCards(equipo.getIdTablero().getIdTableroExt()); List<Tarjeta> tarjetaActual = tarjetaFacade.buscarPorTablero(equipo.getIdTablero()); for (CardElement cardElement : cardsElement) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); Calendar cal = Calendar.getInstance(); Date dateDue = null; if (cardElement.getDue() != null) { cal.setTime(formatter.parse(cardElement.getDue())); cal.add(Calendar.HOUR, -4); dateDue = cal.getTime(); } JSONArray jsona = new JSONArray(cardElement.getIdMembers()); if (tarjetaFacade.existeTarjetaPorIdTarjetaExt(cardElement.getId())) { Tarjeta tarjeta = tarjetaFacade.buscarPorIdTarjetaExt(cardElement.getId()); Lista lista = listaFacade.buscarPorIdExt(cardElement.getIdList()); if (tarjetaActual.contains(tarjeta)) { tarjetaActual.remove(tarjeta); } //Editar Tarjeta tarjeta.setNombreTarjeta(cardElement.getName()); tarjeta.setFechaLimiteTarjeta(dateDue); tarjeta.setIdLista(lista); tarjetaFacade.edit(tarjeta); //Editar Miembros asignados List<DetalleUsuarioTarjeta> detallesActual = detalleUsuarioTarjetaFacade .buscarPorIdTarjeta(tarjeta); if (jsona.length() > 0) { for (int i = 0; i < jsona.length(); i++) { if (miembroFacade.existeMiembroPorIdTableroYIdMiembroExt(equipo.getIdTablero(), jsona.getString(i))) { Miembro miembro = miembroFacade.buscarMiembroPorIdTableroYIdMiembroExt( equipo.getIdTablero(), jsona.getString(i)); if (detalleUsuarioTarjetaFacade.existeDetallePorIdTarjetaYIdMiembro(tarjeta, miembro)) { DetalleUsuarioTarjeta detalleUsuarioTarjeta = detalleUsuarioTarjetaFacade .buscarPorIdTarjetaYIdMiembro(tarjeta, miembro); if (detallesActual.contains(detalleUsuarioTarjeta)) { detallesActual.remove(detalleUsuarioTarjeta); } } else { //Si no existe el usuario asignado para esta tarjeta, se agrega DetalleUsuarioTarjeta dut = new DetalleUsuarioTarjeta(tarjeta, miembro); detalleUsuarioTarjetaFacade.create(dut); } } } } for (DetalleUsuarioTarjeta detalleA : detallesActual) { detalleUsuarioTarjetaFacade.remove(detalleA); } } else { //Agregar Tarjeta Lista lista = listaFacade.buscarPorIdExt(cardElement.getIdList()); EstadoTarjeta estadoTarjeta = estadoTarjetaFacade.buscarPorNombreEstadoTarjeta("Agregada"); Tarjeta tarjeta = new Tarjeta(estadoTarjeta, cardElement.getId(), cardElement.getName(), dateDue, lista, equipo.getIdTablero()); tarjetaFacade.create(tarjeta); //Agregar Miembros asignados a la tarjeta if (jsona.length() > 0) { tarjeta = tarjetaFacade.buscarPorIdTarjetaExt(cardElement.getId()); for (int i = 0; i < jsona.length(); i++) { if (miembroFacade.existeMiembroPorIdTableroYIdMiembroExt(equipo.getIdTablero(), jsona.getString(i))) { Miembro miembro = miembroFacade.buscarMiembroPorIdTableroYIdMiembroExt( equipo.getIdTablero(), jsona.getString(i)); DetalleUsuarioTarjeta dut = new DetalleUsuarioTarjeta(tarjeta, miembro); detalleUsuarioTarjetaFacade.create(dut); } } } } } for (Tarjeta tarjetaA : tarjetaActual) { tarjetaFacade.remove(tarjetaA); } } catch (IOException | ParseException | JSONException ex) { Logger.getLogger(TarjetaTrello.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.activiti.rest.service.api.runtime.TaskQueryResourceTest.java
/** * Test querying tasks. GET runtime/tasks *///w w w .j a v a2 s. c o m @Deployment public void testQueryTasks() throws Exception { try { Calendar adhocTaskCreate = Calendar.getInstance(); adhocTaskCreate.set(Calendar.MILLISECOND, 0); Calendar processTaskCreate = Calendar.getInstance(); processTaskCreate.add(Calendar.HOUR, 2); processTaskCreate.set(Calendar.MILLISECOND, 0); Calendar inBetweenTaskCreation = Calendar.getInstance(); inBetweenTaskCreation.add(Calendar.HOUR, 1); processEngineConfiguration.getClock().setCurrentTime(adhocTaskCreate.getTime()); Task adhocTask = taskService.newTask(); adhocTask.setAssignee("gonzo"); adhocTask.setOwner("owner"); adhocTask.setDelegationState(DelegationState.PENDING); adhocTask.setDescription("Description one"); adhocTask.setName("Name one"); adhocTask.setDueDate(adhocTaskCreate.getTime()); adhocTask.setPriority(100); adhocTask.setFormKey("myForm.json"); adhocTask.setCategory("some-category"); taskService.saveTask(adhocTask); taskService.addUserIdentityLink(adhocTask.getId(), "misspiggy", IdentityLinkType.PARTICIPANT); processEngineConfiguration.getClock().setCurrentTime(processTaskCreate.getTime()); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess", "myBusinessKey"); Task processTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()) .singleResult(); processTask.setParentTaskId(adhocTask.getId()); processTask.setPriority(50); processTask.setDueDate(processTaskCreate.getTime()); taskService.saveTask(processTask); // Check filter-less to fetch all tasks String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_TASK_QUERY); ObjectNode requestNode = objectMapper.createObjectNode(); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId(), adhocTask.getId()); // Name filtering requestNode.removeAll(); requestNode.put("name", "Name one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Name like filtering requestNode.removeAll(); requestNode.put("nameLike", "%one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Description filtering requestNode.removeAll(); requestNode.put("description", "Description one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Description like filtering requestNode.removeAll(); requestNode.put("descriptionLike", "%one"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Priority filtering requestNode.removeAll(); requestNode.put("priority", 100); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Mininmum Priority filtering requestNode.removeAll(); requestNode.put("minimumPriority", 70); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Maximum Priority filtering requestNode.removeAll(); requestNode.put("maximumPriority", 70); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Owner filtering requestNode.removeAll(); requestNode.put("owner", "owner"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Assignee filtering requestNode.removeAll(); requestNode.put("assignee", "gonzo"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Owner like filtering requestNode.removeAll(); requestNode.put("ownerLike", "owne%"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Assignee like filtering requestNode.removeAll(); requestNode.put("assigneeLike", "%onzo"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Unassigned filtering requestNode.removeAll(); requestNode.put("unassigned", true); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Delegation state filtering requestNode.removeAll(); requestNode.put("delegationState", "pending"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Candidate user filtering requestNode.removeAll(); requestNode.put("candidateUser", "kermit"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Candidate group filtering requestNode.removeAll(); requestNode.put("candidateGroup", "sales"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Candidate group In filtering requestNode.removeAll(); ArrayNode arrayNode = requestNode.arrayNode(); arrayNode.add("sales"); arrayNode.add("someOtherGroup"); requestNode.put("candidateGroupIn", arrayNode); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Involved user filtering requestNode.removeAll(); requestNode.put("involvedUser", "misspiggy"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Process instance filtering requestNode.removeAll(); requestNode.put("processInstanceId", processInstance.getId()); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process instance id in filtering requestNode.removeAll(); arrayNode = requestNode.arrayNode(); arrayNode.add(processInstance.getId()); requestNode.put("processInstanceIdIn", arrayNode); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Execution filtering requestNode.removeAll(); Execution taskExecution = runtimeService.createExecutionQuery().activityId("processTask") .singleResult(); requestNode.put("executionId", taskExecution.getId()); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process instance businesskey filtering requestNode.removeAll(); requestNode.put("processInstanceBusinessKey", "myBusinessKey"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process instance businesskey like filtering requestNode.removeAll(); requestNode.put("processInstanceBusinessKeyLike", "myBusiness%"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition key requestNode.removeAll(); requestNode.put("processDefinitionKey", "oneTaskProcess"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition key like requestNode.removeAll(); requestNode.put("processDefinitionKeyLike", "%TaskProcess"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition name requestNode.removeAll(); requestNode.put("processDefinitionName", "The One Task Process"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Process definition name like requestNode.removeAll(); requestNode.put("processDefinitionNameLike", "The One %"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // CeatedOn filtering requestNode.removeAll(); requestNode.put("createdOn", getISODateString(adhocTaskCreate.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // CreatedAfter filtering requestNode.removeAll(); requestNode.put("createdAfter", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // CreatedBefore filtering requestNode.removeAll(); requestNode.put("createdBefore", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Subtask exclusion requestNode.removeAll(); requestNode.put("excludeSubTasks", true); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Task definition key filtering requestNode.removeAll(); requestNode.put("taskDefinitionKey", "processTask"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Task definition key like filtering requestNode.removeAll(); requestNode.put("taskDefinitionKeyLike", "process%"); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Duedate filtering requestNode.removeAll(); requestNode.put("dueDate", getISODateString(adhocTaskCreate.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Due after filtering requestNode.removeAll(); requestNode.put("dueAfter", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Due before filtering requestNode.removeAll(); requestNode.put("dueBefore", getISODateString(inBetweenTaskCreation.getTime())); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Suspend process-instance to have a supended task runtimeService.suspendProcessInstanceById(processInstance.getId()); // Suspended filering requestNode.removeAll(); requestNode.put("active", false); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); // Active filtering requestNode.removeAll(); requestNode.put("active", true); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Filtering by category requestNode.removeAll(); requestNode.put("category", "some-category"); assertResultsPresentInPostDataResponse(url, requestNode, adhocTask.getId()); // Filtering without duedate requestNode.removeAll(); requestNode.put("withoutDueDate", true); // No response should be returned, no tasks without a duedate yet assertResultsPresentInPostDataResponse(url, requestNode); processTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); processTask.setDueDate(null); taskService.saveTask(processTask); assertResultsPresentInPostDataResponse(url, requestNode, processTask.getId()); } finally { // Clean adhoc-tasks even if test fails List<Task> tasks = taskService.createTaskQuery().list(); for (Task task : tasks) { if (task.getExecutionId() == null) { taskService.deleteTask(task.getId(), true); } } } }
From source file:com.haulmont.chile.core.datatypes.impl.DateDatatype.java
protected java.sql.Date normalize(java.util.Date dateTime) { Calendar cal = Calendar.getInstance(); cal.setTime(dateTime);/*ww w . j a v a2 s . c o m*/ cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return new java.sql.Date(cal.getTimeInMillis()); }
From source file:DateUtils.java
public static final String getTimeFromDate(Date dt) { Calendar cal = new GregorianCalendar(); cal.setTime(dt);/*from ww w . ja va 2 s.c om*/ StringBuffer ret = new StringBuffer(); ret.append(cal.get(Calendar.HOUR)); ret.append(":"); ret.append(cal.get(Calendar.MINUTE)); return ret.toString(); }
From source file:com.linuxbox.enkive.teststats.StatsMonthGrainTest.java
@BeforeClass public static void setUp() throws ParseException, GathererException { coll = TestHelper.GetTestCollection(); client = TestHelper.BuildClient();/* ww w .j a v a 2 s . c o m*/ grain = new MonthConsolidator(client); // clean up if week was run... Map<String, Object> queryMap = new HashMap<String, Object>(); queryMap.put(CONSOLIDATION_TYPE, CONSOLIDATION_DAY); StatsQuery statsQuery = new MongoStatsQuery(null, CONSOLIDATION_DAY, null); Set<Object> ids = new HashSet<Object>(); for (Map<String, Object> mapToDelete : client.queryStatistics(statsQuery)) { ids.add(mapToDelete.get("_id")); } if (!ids.isEmpty()) { client.remove(ids); } // TODO List<Map<String, Object>> stats = (new DayConsolidator(client)).consolidateData(); Map<String, Object> timeMap = new HashMap<String, Object>(); Calendar cal = Calendar.getInstance(); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.HOUR, 0); cal.set(Calendar.DAY_OF_MONTH, 1); for (int i = 0; i < 10; i++) { if (i == 5) { cal.add(Calendar.MONTH, -1); } timeMap.put(CONSOLIDATION_MAX, cal.getTime()); timeMap.put(CONSOLIDATION_MIN, cal.getTime()); for (Map<String, Object> data : stats) { data.put(STAT_TIMESTAMP, timeMap); } client.storeData(stats); } dataCount = coll.count(); }