Hello I'm desperate trying to find a way in ESPER - CEP to output the events that have the max value. Here's a good example to illustrate my problem:
| value | category | date |
| 12.2 | A | yyyy-MM-dd HH:mm:ss |
| 13.3 | A | yyyy-MM-dd HH:mm:ss |
I want the following output:
| value | category | date |
| 13.3 | A | yyyy-MM-dd HH:mm:ss |
Very basic in SQL : select max(value), category date from tab group by category
Now in Esper, i have tried many things: output every, output last, contexts.. But couldn't find a solution :/ It either outputs nothing or outputs all the lines. With "output first every", it only ouputs the first line, regardless of the max() comparison.
Is there someone who has an idea of how to proceed to obtain the max(value) and group by a parameter from a stream?
Thanks for your help :)
Doc link for controlling time keeping: http://esper.codehaus.org/esper-5.1.0/doc/reference/en-US/html_single/index.html#api-controlling-time
Related
I have following test case where i want pass '00:00:00.0' (date_suffix) for one example and one for not.
however using this approach it also append space in first example with no date_suffix
so it results something like this:
// I need to get rid of last space (after /17) for example 1.
example1. "1996/06/17 "
example2. "1996/06/17 00:00:00.0"
--
Then Some case:
| birthdate |
| 1996/06/17 <date_suffix> |
| 1987-11-08 <date_suffix> |
| 1998-07-20 <date_suffix> |
#example1
Examples:
| date_suffix |
| |
#example2
Examples:
| date_suffix |
| 00:00:00.0 |
What you want to do is not possible in Gherkin.
However it seems like you are testing a date parser or validation tool through some other component.
By adding the time stamp to the date, you're adding incidental details to your scenario. It is not immediately apparent what these test and maybe overlooked in the future.
Consider instead testing the parser/validator separately and directly.
Once you have confidence in the date parser works correctly, use for your current scenario a list of mixed dates, some with and some without suffix.
Use a trim function to eliminate all the spacese.
exemple = urString.trim();
I have a requirement to show leave history and forecast. The data is received weekly in a report which I need to store in a table. I can use any DB supported by Java.
A sample of the data looks like this:
To be able to show past totals by department I need to store the data that comes out in the report each week.
How to store the forecast data, as the data structure of the report keeps changing. In the sample above the last 12 columns are the 12 months following the date the report was run. Next month the first column will be October etc.
I have create a fiddle here
I have considered just storing the last 4 weeks of reports (each report in a separate table) and inserting work group totals into a separate totals table where each row would represent a department and its totals.
If there is a better way - what sort of data structure/schema should I use?
I can think of 3 approaches:
You can add a date and forecast column and then get rid of the columns that are named after month/years. It's like transpose action in Excel. Additionally, since Dept, Leave_Balance, projected_balance_6m will not be in the same grain as the new columns, I'd create a new table. Example rows from the new table would be like:
+------------+-----------+----------+
| EmployeeID | YearMonth | Forecast |
+------------+-----------+----------+
| 456 | 201901 | 0 |
| 456 | 201902 | 5 |
+------------+-----------+----------+
Again in a new table, you can add a year column and make the forecast column names to resemble months. This wouldn't be continuous as your current solution but easier to handle in the BI software.
+------------+------+-----+-----+-----+-----+-----+-----+
| EmployeeID | Year | Jan | Feb | Mar | Apr | May | Jun |
+------------+------+-----+-----+-----+-----+-----+-----+
| 456 | 2019 | 0 | 0 | 0 | 0 | 0 | 0 |
| 456 | 2020 | 0 | 5 | 0 | 6 | 0 | 0 |
| 123 | 2020 | 0 | 0 | 1 | 0 | 0 | 0 |
+------------+------+-----+-----+-----+-----+-----+-----+
Other approach could be to rename columns relative to current date. Here, cur is SEPT19, cur+1 is OCT19 and so on. This solution will have the least impact but, drawback of this approach is, it is not clear when you last updated the table, and what cur value is actually. So, that information should be made available somewhere.
+-----+------+-------+---------------+--------------+-----+-------+-------+
| ID | Name | Dept | Leave_Balance | p_balance_6m | cur | cur+1 | cur+2 |
+-----+------+-------+---------------+--------------+-----+-------+-------+
| 456 | Mary | Sales | 32.3 | 45.6 | 0 | 0 | 0 |
+-----+------+-------+---------------+--------------+-----+-------+-------+
I like the first and second solutions more because they are more self contained. Your choice would depend on how much you want to rely on BI software (Tableau, Qlikview etc).
I've already seen a threads similar to this, but none of them answers my question.
So let's say we have two classes:
Lesson
Break
Both of them are implementing SchoolEntity interface, which has the following methods:
Date getStartDate()
Date getEndDate()
Break class does nothing beside implementing this interface, but Lesson has additional fields and getters, like:
subject
room
teacher, etc.
Now I want to save instance of SchoolEntity using Android's Room Persistence Library.
This is the List I want to be saved:
List<SchoolEntity> timetable:
1. Lesson#13da43:
- Date startDate = Date#ha94j8
- Date endDate = Date#9kf8kf
- String subject = "math"
- String room = "124"
- String teacher = "Joseph Fold"
2. Break#j7gfsd:
- Date startDate = Date#738291
- Date endDate = Date#fj8fjn
And I want it to be saved in SQL Database like this:
+----------------------+---------------------+--------+---------+------+-------------+
| start_date | end_date | type | subject | room | teacher |
+----------------------+---------------------+--------+---------+------+-------------+
| 2019.01.12 08:00:00 | 2019.01.12 08:45:00 | LESSON | math | 124 | Joseph Fold |
| 2019.01.12 08:45:00 | 2019.01.12 08:55:00 | BREAK | NULL | NULL | NULL |
+----------------------+---------------------+--------+---------+------+-------------+
Note: start_date is primary key
And finally I want to be able to retrive saved information as:
LiveData<List<SchoolEntity>> timetable
My question is:
Am I able to do this using Android's Room Persistence Library? If so, how to achieve it? If no what should I use instead?
My language is Java, but Kotlin will also make me.
I am trying to get the full calendar to sort events so that the single day events come to the top of the stack and the multiple day events come to the bottom of the stack where they are still sorted by start time. I am wondering about how to do it?
for example for this data:
[{id: '1',title: '1',color:'*',url:'*',tip: '*',start: new Date(2015,0,6,6,0),end: new Date(2015,0,7,8,55)},
{id: '2',title: '2',color:'*',url:'*',tip: '*',start: new Date(2015,0,6,7,55),end: new Date(2015,0,7,10,50)}]
in this link:
http://stackoverflow.com/questions/8231902/jquery-fullcalendar-event-sorting
it is saying that it is impossible, but i beg to differ because it claims it puts 10x importance to the duration whereas i could not find any code regarding it in the actual fullcalendar.js.
I have tried sql sorting but everytime the script resorts and puts the longer durations at the top from some functions that i cant find.
any help or hint greatly appreciated. thanks in advance.
Something like this?
=> SELECT * FROM calsort ORDER BY id;
id | starts | ends
----+------------------------+------------------------
1 | 2015-01-05 16:47:43+00 | 2015-01-05 17:47:43+00
2 | 2015-01-03 16:48:57+00 | 2015-01-04 16:48:57+00
3 | 2015-01-03 14:48:44+00 | 2015-01-04 15:48:44+00
4 | 2015-01-05 14:48:05+00 | 2015-01-05 16:48:05+00
(4 rows)
=> SELECT * FROM calsort ORDER BY (CASE WHEN date(ends)=date(starts) THEN 1 ELSE 2 END), starts, id;
id | starts | ends
----+------------------------+------------------------
4 | 2015-01-05 14:48:05+00 | 2015-01-05 16:48:05+00
1 | 2015-01-05 16:47:43+00 | 2015-01-05 17:47:43+00
3 | 2015-01-03 14:48:44+00 | 2015-01-04 15:48:44+00
2 | 2015-01-03 16:48:57+00 | 2015-01-04 16:48:57+00
(4 rows)
I have a TIME data type column in my database. According to this, it supports hh[:mm] {AM | PM} format. But when I tried insert this sql :
INSERT INTO POSISI (ID, TUJUAN, PELABUHAN_TERAKHIR, LATLNG, AREA, KECEPATAN, HALUAN, STATUS, KETERANGAN, WAKTU, JAM) VALUES ((SELECT ID FROM KAPAL WHERE UPPER(KAPAL.NAMA)=UPPER('Aura Kasih')), 'Surabaya', 'Karimun', '2.02, 100.2', 'Kiclik', '19 knot', '11°', 'Anchor', 'Aman', '2014-03-16', '01:50 AM')
I got this on my database :
2 | Surabaya | Karimun | 2.02, 100.2 | Kiclik | 19 knot | 11° | Anchor | Aman | 2014-03-16 | 01:50:00
As you can see, I am using 01:50 AM but it stored as 01:50:00.
So, can I tell JavaDB to store TIME as hh:mm a format?
Thank you.
Time will always be stored as hh:mm:ss in the db. The format that you mentioned is for the input. You will need to format the time again when you want to retrieve / display from the db.