Exposing CQL Result in NDepend - ndepend

I have some custom CQLs in NDepend Project and I want generate the results of these CQLs using NDepend.Console.exe. When I generate the report, I don't see any result of my custom CQLs in the report. I can export from Visual NDepend but I want to use NDepend.Console.exe from script.
Ant.

Several different ways can be used to show code queries and code rules results in a report:
You can first transform your code query to a violated code rules like for example, transforming
from m in Methods select new {m, m.CyclomaticComplexity}
into warnif count > 0 from m in Methods select new {m, m.CyclomaticComplexity}
...and then you need to set the following code query flag: Display list of items selected in report
You can also Reports groups of Code Queries in the report as explained here.
You can use the NDepend.API to programatically compile and execute Code Queries or Rules and browse programatically the result. See the source code of the Power Tool Query Code with CQLinq for more details about this. The source code of Power Tools can be found in $NDependInstallPath$\NDepend.PowerTools.SourceCode\NDepend.PowerTools.sln

Related

SQL Developer - automatically refresh a query

Is there a way to automatically refresh my own query in Oracle SQL Developer?
Something like Tools/Monitor Sessions.../Refresh but for any provided query.
Yes, turn your query into a user defined report.
You can right-click on your query result grid in the worksheet -
Then if you want a new one, i'd just keep the one and edit the report properties for your new query.
Doesn't have to be a grid either - you can have a report of type script. Or use charts. Or a lot more.

How to make my subreport access a different database than the main one?

I am evaluating JasperReports and Jaspersoft Studio for using in the company I work for and I am trying to build a report that contains information from 2 different databases.
I have 2 data adapters configured.
I've my research and found out that the only way to do so is to have either a list, table or subreport in a main report, but I still can't make it work.
I took the subreport approach, I have two reports that work separately, the main one executes this query in the sample DB
select 1 from ORDERS limit 10
The subreport runs this one in a Vertica database I own:
select 1 from my_schema.my_table limit 10
Both of them, as said, run separately.
So I go to the mainreport and add a SubReport element to the ColumnHeader band, then the wizard opens:
In the step 1 I select the subreport from the project
Second step is connection. I have these options:
Same JDBC conection
Use another connection
Use an empty data source
Use a JRDatasourceExpression
Don't use any connection.
The first and third ones are not what I want.
I tried to set the second one, but I could not find a way to select the data adapter that I have configured.
The last one doesn't work ( I get a message saying that my_schema doesn't exists, so I think that it is still trying to access the MainReport database).
Is there anyway I can make a subreport run a query in a different database/datasource from the main report?
I can summarize what I did if anyone has the same issue:
I made a proof of concept (therefore I do not have the code anymore), but I created a JRDataSource class using this tutorial and there I manually access the database and returned the rows. Then I use this as the datasource of my subreport/table.
Not as nice as I wanted, but it is possible
I guess this iReport article is also applicable to reports designed in jaspersoft studio; you just need to define the subreport connection parameter with the given expression.
Perhaps, you can ask for help from two parameters which defined in the master report by yourself. Such as:
$P{MySubreport} with type net.sf.jasperreport.engine.JasperReport;
$P{MyDatasource} with type net.sf.jasperreport.engine.JRDataSource;
Associate these two parameters to your subreport element respectively in attributes 'Expression' and 'Data Source Expression';
Please write your DataSource class that implements interface JRDataSource.
Then, in your servlet class, put your real parameter values(JasperReport for your subreport .jasper file, and your DataSource object) into a parameters Map object, and call JasperFillManager.fillReport().

Jasper Report run different query based on different dynamic values

I have three different queries and want to run them as per value get in jasper report.Queries are written in Jrxml file itself.How I can run different queries based on different dynamic values.
Like (It is just a sudo code)
If($(a) == "Germany")
run query 1
If($(a) == "India")
run query 2
Any help would be highly appreciated.
Define parameter $P{a} in mainReport.jrxml
Make subreports subreport1.jrxml (query1), subreport2.jrxml (query2)
Put subreport1 and subreport2 into Title band of mainReport.jrxml
Use PrintWhenExpression in mainReport for properties of subreports (Window->Properties)
Set PrintWhenExpression in mainReport for subreport1: $P{a}.equals("Germany")
Set PrintWhenExpression in mainReport for subreport2: $P{a}.equals("India")
Pass $P{a} into mainReport from your application
You can try using DynamicReports. This is a library based on JasperReports, and let's you construct your report directly from you java code.
Here is an axample Dynamic Reports
There is a .setDataSource() method which can take a string + a connection objects. Based on some little logic you can set the query there.
.setDataSource() is overloaded, and it can even take a ResultSet object. So you can even use a Statement/PreparedStatement object passing different queries and values, and then passing their result as a source for the report.
Hope it helps!
P.S: The example uses maven dependencies, but you can also download the .jar and add it to your classpath to make it work

Two SQL query inside single JasperReport and populating Data

We are using reports in our web application.
The report is generated using JasperReports.
The problem I am facing is:
My SQL query fetches data based on a where clause:
SELECT * FROM table WHERE level='c'
I can easily show this information inside the iReport.
But I need to fire another query where level='d' and the information for the same needs to be appended to the report with that of level='c'.
I tried grouping both the outputs. But problem is how do I fire two different query while generating the report because I can write only one query in QueryBuilder inside the iReport.
Is there anyway of achieving the same.
In essence:
The report should look like:
Level=C
Name Age Phone number
Level=D
Name Age Phone number
Level D should appear only after level c is completed.
Can anyone please guide.
I finally managed to achieve the same..Grouping the data using level_id..
Initially I was trying to group in a different manner and hence the value was not getting shown..
The same is explained pretty nicely in ireport Ultimate guide-3 document.

Selection Formula Pass-through not working with SQL Command Object

I'm using Crystal Reports XI. We use Crystal Reports embedded into a share point site written in C#/ASP.net. Our web developers instatiate a report in code and pass the selection criteria by appending to the Select Formula object.
The problem I'm running in to is that when I use a SQL Command Object, the selection formula is not being passed to the sql server as a where clause. This causes the entire result set to be queried and then limited on the server. For very large tables, this is causing a significant performance hit.
Here's an example:
SELECT foo.id, foo.code, foo.name
FROM foo foo
Select criteria is shown as:
{Command.name} like "someName"
If I then run the report the entire foo table is queried and then crystal reports limits from the entire set.
If instead I do it based on the table without a command object, the WHERE clause is appended to the sql query and all the limiting is done at the db level.
I'm assuming this occurs because a SQL command could potentially be very complex and adding a WHERE clause to the bottom isn't always possible. My question then, is there any good way to force some sort of pass through. Should I be talking to the C# devs and asking them to rework the way we pass parameters?
Thanks for any help and discussions.
A record-selection formula is never added to the Command-object's query.
I'm not certain if the CR SDK supports Command object modification (I know it supports read-only access, however).
The Command object does support parameters (in 2008, they can be multi-valued parameters) which can be accessed programmatically (they are converted to Parameter Fields in the report).
I'm assuming that you are using a Command object because of the query's complexity. If you can push the complexity to a SQL view, then use the 'visual linking' expert to create your query, you'll have more flexibility.