I created one birt report.It contains one report parameter with name "FromDate".User will insert it in a fromat like "dd/MM/yyyy". I want to get year(if date is 11/01/2013.i want to extract 2013 from this varaible) from this input parameter and want to pass this value to one stored procedure(ie data set).How can i do that.Can anyone pls share sample code
You could define a variable 'selectedYear' like this:
var selectedValue = params["FromDate"].value;
var selectedValueArray = selectedValue.split("/");
selectedValueArray[2]
This code creates an array by "cutting up" the parameter value on the /'s, and then selecting the year (the second value in the array, which is the third block since we count from zero).
You can then use vars["selectedYear"] on your data set.
Alternatively, if your data set contains a list of years, you can create a data set
select distinct YEAR
from [dataSource]
and have your parameter select from that list instead. This will also guarantee that the selected year is in range.
You can map dataset parameters to report parameter-derived values in the Parameters section of the Edit Dataset dialog:
Select the stored procedure year input parameter from the list of dataset parameters and click Edit... .
Click on the fx button next to the Default Value and select Javascript Syntax .
Enter the formula BirtDateTime.year(params["FromDate"].value) .
Click on OK to confirm these changes in each dialog. (The Linked To Report Parameter option needs to be left as None for that dataset parameter, since you don't want to set the procedure input parameter value to be exactly the same as any of the Report Parameters.)
I had a similar problem in the past, however i looked at from a different angle in driving the date selection from the dates stored in the datasource as a dynamic parameter. Normally then a date from the dataset is in a format which can be formatted/extracted by functions to give the year month day etc.
i tried this one..in corresponding stored procedure i will do a substring on input paramaeter(ie FromDate)..it is working
In sql query(Data Set), Use this
"split_part(?,'/',3)" , We will have date parameter in place of '?' . As, you must be aware of that, Split_part will divide the string using the delimiter '/' .
Related
I am getting list of information along with the user details from an API. Based on a particular parameter i need to get last modified user who has acted upon it by comparing date.
For ex:
parameter Last updated user Date
param1 John 26-Sep-16
param1 Jane 12-Nov-17
Param1 James 12-April-18
The size of the data increases for the same param1 in the list. So how to accomplish this.
Thanks in advance
I am not sure I understand your question properly, but if what you need is to get the object with the latest modified date from the list of user information entries, then (if you use Java 8+) you may try using Java stream for that as following:
list.stream().max(Comparator.comparing(UserInformation::getLastModifiedDate));
I am assuming here you have a list of UserInfromation objects called list , and UserInfromation has a getter method with the signature Date getLastModifiedDate()
I can't find a way to append multiple values to multiple rows, like I do with .update method with the same range value.
service.spreadsheets().values()
.append(
spreadsheetId,
"sheet!A2:B300",
new ValueRange().setValues(Arrays.asList(Arrays.asList("1", "2")))
)
.setValueInputOption("USER_ENTERED").execute();
The message I get is:
"Requested writing within range [sheet!A2], but tried writing to column [B]"
If I use all the same arguments with the .update method instead of .append, everything works nicely.
Also, .append will work if the inner list has only 1 item
-
Thanks
EDIT: I was using HH:mm string as a part of sheet name. It was causing the range error. The same worked on .update method so I didn't consider it important at first
Remove the colon from the name of your worksheet, and this apparent bug in the append feature of the Spreadsheet API will go away.
Append works by finding a table within the requested range and then appending data to the end of that table. The table it found appears to only have one column (in 'A'), and append is having trouble adding the new column. You can resolve this by adding a column header in B, most likely.
Admittedly, this isn't super intuitive, so we'll take a look at changing the behavior.
I am using google spreadsheet API v4 for java.
My Spreadsheet looks something like this -
User Message Time
--------------------------------
User1 My Message 10:30
User2 User2 msg 3:40
User3 User3 msg 1:30
User2 User2 msg
User4 User4 msg 4:00
I want to find row index with User 'User2' and Time bank (empty value).
After that, I would like to use this row index to add time value in that row.
Is it possible to search row by cell values without knowing range or index?
In above example, it should return me only second last row index as it matches to the criteria (User='User2' and Time='').
or even better, is there any find and replace API, which will find row criteria (User='User2' and Time='') and replace Time value from '' to '3:30'?
I went through google docs, but could not find one according to my need.
Thanks.
Edit:
I found a formula to find cell address which needs to be updated.
=ADDRESS(MATCH("User2",A1:A4000),3)
For example used in this question, this formula will return '$C$4' address, which is expected. I tested this by evaluating this formula in spreadsheet manually. Is there any way using Google spreadsheet API V4 to evaluate this formula using Java code?
I think you'd want to use a combination of lookup functions:
https://support.google.com/docs/topic/3105472?hl=en&ref_topic=3046366
In particular, MATCH lets you get a position offset of the value you want in a range, so you could get the offset of the cells in column1 containing values 'User2', and OFFSET could let you check the value in the cell 2 columns to the right of the found cell, which would give you the value in the Time column to compare with. Since then you'd also have the cell coordiates of the thing checked, you could then assign a new value. These lookup functions allow you to find the range or index that you need for the rest.
This just gives you a handy way to have certain values precomputed for your other functions so that your script can get direct access to values output by the sheets builtin functions. It saves having to have your sheets script sort through a range for a value, but the logic is the same.
1) Get range for Column1
2) Search range of Column1 for value 'User2'
3) If matched, check offset(0,2) to get the cell reference 2 spaces to the right and ask for its cell reference.
4) If that reference is empty, assign it a timestamp.
If you want the code for this, it'll take me a bit longer to put together.
I want to print 4 different values from my database table in 4 different Java Textfields when u click in the corresponding row.
You can use String.valueOf(arg) to convert to string your values. Also if the values coming from your database are numeric, you might want to call getDouble or getFloat on your ResultSet object too. Don't forget to remove the casts in the query as you will tranform the values in the Java code instead, like this:
textFieldEröffnungspreis.setText(String.valueOf(rs.getDouble("Eröffnungspreis")));
I've been thinking it over, and I'm starting to wonder if this is even possible.
User Perspective:
There's a table of data, and one column contains a date. The user can type in a search term like dec and get all rows that occurred during December.
Backend: A jqGrid is used for displaying the table. It sends the entered search terms to the server. The server uses the code
Criteria cr = session.createCriteria( DetailedLogEntry.class );
Disjunction disjunction = Restrictions.disjunction();
MatchMode matchMode = MatchMode.ANYWHERE;
disjunction.add( Restrictions.ilike( searchKey.getField(), searchKey.getData(), matchMode ) );
cr.add( disjunction );
to apply the search terms, and where DetailedLogEntry contains a Date variable to represent the database's TIMESTAMPfield.
Because searchKey.getData() returns a string, comparing it against a date object results in an empty set.
So I guess the question is...is it possible, preferbly through Hibernate, to apply a restriction against a Date object as if it were a String?
That's not possible. You'd need to use Restrictions.between() and give it an upper and lower date values. You could use SimpleDateFormat to convert from your String values to Date values and then perform the search?
If the user searched for Dec, would you expect all the log entries from December of every year to show up? Can they type in :"1, Dec" and expect to see all the logs from the 1st December for every year? If it is string matching on dates you are looking for, it might be easier to load all the data into your jqGrid and use javascript to filter the table based on the string formatted date values.