Scan Native query in JPA using SonarQube - jpa

I have native queries in java files and i want to scan that queries for using sonarQube server.
Is there any way to do that?

There are a few rules implemented in SonarJava that check the proper use of SQL-related Java objects, specifically
S2695 - "PreparedStatement" and "ResultSet" methods should be called with valid indicies
S2232 - "ResultSet.isLast()" should not be used
S2077 - SQL binding mechanisms should be used
But there are no rules that check the correctness of SQL statements themselves, and I'm not aware of any other plugins that offer such rules for Java.
If you really need this, then you'll have to go down the custom rule implementation route. There's a tutorial to get you started, and if you have specific development questions you can ask them in the SonarQube Google Group, or here, obviously.
Update
The Google Group has been replaced with https://community.sonarsource.com.

Related

Using Sails.js with AWS DynamoDB....not ideal

I started working on a small POC and decided to give Sails.js a try :)
Part of the POC we wanted to use DynamoDB since the project will eventually involve high scalability and we're not looking to hire full-time MongoDB expert at this point.
We used the module: https://github.com/gadelkareem/sails-dynamodb
Problem is there is no documentation and the module does not even work...
It seems the sails ORM is not ideal for DynamoDB and requires writing custom DB services. Does anyone have experience with this?
I was very excited to come across Sails but if it won't let us play nice with DynamoDB then it might very well be out as an option to us....
Anyone have experience with this or maybe something I'm missing?
One of the important plus of vogels is excellent documentation.
Sails-dynamodb adapter based on the vogels, but not all features are implemented in sails-dynamodb adapter. For example, vogels has Expression Filters.
Vogels able to create tables. Adapter can't. An adapter needs duplication table schema in sails files and dynamodb shell.
Vogels has some own types, such as uuid type, StringSet, NumberSet, TimeUUID. (Adapter can use it too, if includes Vogels and Joi lib)
Vogels and adapter have the same query (create, update, delete, find) capabilities.
Adapter allows without changing the code switch to another data base. Adapter encapsulates establishment of connection to database.
Conclusion - for most purposes this adapter is suitable for the work and do not need to work directly with the Vogels
Sails comes loaded with an ORM called "Waterline". There are some official waterline plugins such as mongodb, postgresql, mysql and then there are some unofficial ones created by the community. I'd assume right now that Dynamo is in the latter category since I have not come across it before. However, with that being said I would not take this experience as a reason to ditch Sails.js.
Sails.js is built with the intention that all of its components can be swapped out, this means you are not tied to a specific template engine, authentication libraries etc. and including your ORM choice.
Waterline is still being actively developed but it is sat at v0.12.1 as of writing this response. It isn't fully there yet so there will be the odd issues still around!
My recommendation? Take a look at swapping out waterline for a different ORM. Keep the flexibility Sails gives you and change out the component that doesn't meet your criteria. There are still many benefits to Sails you can utilise.
Vogels might be worth checking out: https://github.com/ryanfitz/vogels
Turning off waterline: Is there a way to disable waterline and use a different ORM in sails.js?

Google Fusion Table REST Api vs Advanced Services Fusion Table Services in app scripts

I am very confused about the correct or recommended mechanism to use for accessing google fusion tables APIs in app scripts. There seem to be two methods with examples but no discussion about which is preferred or why. Is one of these interfaces newer and preferred while the other is dying? Is one obsolete or more restricted in what it can do?
Method 1 is the REST API described here
https://developers.google.com/fusiontables/docs/v2/sql-reference#Select
Method 2 is a set of library functions sort of described here under the Apps Script/Google Advanced Services:
https://developers.google.com/apps-script/advanced/fusion-tables
For example, using the REST api to do a dql query, we end up with something like this:
function runSQL(sql){
var getDataURL = 'https://www.googleapis.com/fusiontables/v1/query?sql='+sql;
var dataResponse = UrlFetchApp.fetch(getDataURL,getUrlFetchOptions()).getContentText();
return dataResponse;
}
And using the advanced API we use something like this:
result = FusionTables.Query.sql(sql, { hdrs: false });
The REST API seems much harder to use, requireing complex oAuth and developer keys to be configured in advance and coded into the application while the Advanced Services API harvests all this behind the scenes and makes for simple API calls like I show here.
I have seen numerous examples using each of the above with no hint as to why one author chose her mechanism instead of the other.
Your help is greatly appreciated.
The service within app-script is a work in progress, so the full functionality of the API might not be fully supported at the moment. As you mentioned though, the big advantage of the service over the REST API is that you do not have to handle the OAuth flow, as you only need to enable it on your script (as stated here).
The Apps Script "advanced service" implementation still lacks some advanced functionality (like alt=media format queries or multipart / resumable uploads) -- if it actually has those features, it lacks extremely basic documentation of them, to the point that the Apps Script editor autocomplete is unaware of them. The tradeoff of these functionality gaps is that you don't need to handle keys, request building, etc.
So, if you're doing simple sql select / importRows work, the Advanced Service should be able to cover almost all your needs. If you need to delete from your FusionTables, you might want to consider setting up the REST API - because deleting is 1 record per query, the better way to delete is to instead "download what you want to keep, then re-upload it back via replaceRows."
(This worked for me for a while, but eventually what I was keeping outgrew the Apps Script service's limitations and I began receiving Empty Response errors from the call to replaceRows. My remedy was to perform my record maintenance tasks via the REST API, where I can specify resumable uploads, timeouts, etc., while more "normal" interactions are done through the Advanced Service.)

connecting to crystal server database

I tried to google this but I failed.
Is there a way (I know it is, found this link but with insufficient details) to connect to crystal server's database?
We are runnig many reports daily which sometimes fail, sometimes don't run at all, we accept this as a part of server imperfection. The issue is, that checking each reports instance through CMC is very inconvenient and time consuming. If I could check it directly in some other way it would be much easier to manage.
The server version is 12.0
While the CMS repository is a plain database, querying it directly (using SQL) is discouraged, unsupported and generally a bad idea.
If you want to query the repository, you have several other options:
Use the built-in Query Builder web application (a web application called AdminTools, normally deployed on your application server). This offers a SQL-like interface for querying the repository, though a lot of SQL features are not available (e.g. table joins). Official documentation is also generally lacking for Query Builder, but if you're interested, there's a very good guide available here.
Use the Java or .NET SDK to query the repository. SDK documentation is available on SAP SCN. This is the most powerful option, but also requires you to do everything yourself. And it will take some time to become familiar with all the different classes and how they relate to the BI Platform.
Use a 3rd-party tool. Different solutions exist, with different feature sets, although it seems that most stopped working when BI4 came out, and the ones that exist usually require a server component as well.
Additional information:
How to browse CMS repository (SAP Wiki)
Query Builder in BO – Browse / Query BO Repository
BusinessObjects Query builder - Basics
Using Query Builder to Explore Your BusinessObjects Repository
You could also more-or-less automate the querying of the repository (although it's very basic) by following the instructions outlined in this blog post.

How to query RTC builds?

We are using RTC for version control and build system.
RTC's web interface allow user to create custom queries for work items - good.
How about creating custom queries to the builds (or other RTC items maybe)?
Let's say I want to know in what builds this particular file was modified or in what builds this particular team member contributed something.
Definitely there is no web interface to do this.
Maybe some other tool? .. Something...
BTW, I didn't find it in scm.exe tool provided with eclipse.
Thanks
While there is no web GUI for building such a query, there is a REST API for querying Build Results:
See "Report REST API" (you need a -- free -- jazz.net account to access it), for com.ibm.team.build.BuildResult, that you can access as in this thread, for instance:
https://<host>:<port>/jazz/resource/itemOid/com.ibm.team.build.BuildResult/_uKcncTTuEeOy2d_WN7u_Bg

JasperReports and custom data sources

I'm looking at embedding JasperReports into an existing web app for reporting. The webapp sits on top of an existing database which is ancient and complex, and really not suitable for report writers to use to write reports against directly.
What I want to look at is writing some kind of wrapper around our existing data access layer (written to make our life easier talking to aforementioned ancient and complex db). Does anyone have any experience of writing custom data sources for JasperResports, or of doing anything like this?
Updated
I guess I probably wasn't clear in my question - which is probably because my requirements aren't clear either. I want to provide some way that the end-users can use something like iReport to author reports against the database, and then to use JasperReportServer for scheduling/viewing of the reports. However, the database is really, really nasty and was never designed for use in this way. We've got a access layer around it that the webapp uses to talk to it. I want to keep my end users away from the DB altogether, and the idea of a custom data source that used the access layer seemed a good option. However, I've found very little documentation on how to do that. Maybe it's just a whole lot easier than I think it is, and I'm just trying to make a dead simple thing too complicated.
Updated
Thanks for the answers. I don't think my problem has been solved, but I think the answers have helped to inform the requirements phase.
Jasper reports allows you to use a "JavaBean" data source. You can load your data into any Java Bean structure and build the reports against that. Works well.
See the "Custom Data Source" section here.
Every JasperReports template can have two different data sources. One is hooking it directly to a database using some jdbc driver or, in your case, providing a collection of java beans (POJO's), usually list.
JasperReports template is similar to a method definition. It has a name, i.e. compiled JR object and parameters (data source and a list of input parameters of some of the most popular Java types).
My suggestion is to use iReport tool. Open some example that comes with the JasperReports bundle, analyze it and tweak it. It's not so complicated.
UPDATE
Letting customers authoring JasperReports templates, compiling and adding to the classpath means that you'll need to open your system too much. Usually clients provide description of a desired report and developer(s) create the data source and design the template. JasperReports can have parameters. If these parameters are exposed through UI users can change the behavior of reports in the runtime.
If you really need to allow more flexibility then use the API provided by JasperReports for authoring templates. I could imagine some simple DLS for advanced users to communicate with your system creating on-fly reports.