Jasper Report 6.3 Hyperlink Extension - jasper-reports

I have recently upgraded Jasper Report API from 4.5.1 to 6.3. With 4.5.1, reports are exported to HTML, PDF format. For HTML reports, there is a facility to drill down to child report. In order to customise links to handle request parameters and pre processing of opening child report have created ExtensionRegistryFactory and registered JRHyperlinkProducerMapFactory to handle Hyperlinks.
I've noticed that extension is registered properly but it does not getting used. Checked source code of Jasper Report 6.3 and try to debug why, then observed that method: net.sf.jasperreports.engine.JRAbstractExporter.getHyperlinkProducer(JRPrintHyperlink) does not return JRHyperlinkProducer.
Here is the code of ExtensionsRegistryFactory:
public class HyperlinkExtensionsRegistryFactory implements ExtensionsRegistryFactory
{
#Override
public ExtensionsRegistry createRegistry(String registryId, JRPropertiesMap properties)
{
return new ExtensionsRegistry()
{
#Override
public List getExtensions(Class extensionType)
{
if (extensionType.equals(JRHyperlinkProducerFactory.class))
{
JRHyperlinkProducerMapFactory producerFactory = new JRHyperlinkProducerMapFactory();
producerFactory.addProducer("ReportExecution", new RemoteExecutionHyperlinkProducer());
producerFactory.addProducer("Custom", new ExpandCollapseHyperlinkProducer());
return Arrays.asList(producerFactory);
}
return null;
}
};
}
public static class RemoteExecutionHyperlinkProducer implements JRHyperlinkProducer
{
#Override
public String getHyperlink(JRPrintHyperlink hyperlink)
{
return [custom link generation logic];
}
}
public static class ExpandCollapseHyperlinkProducer implements JRHyperlinkProducer
{
#Override
public String getHyperlink(JRPrintHyperlink hyperlink)
{
return [custom link generation logic];
}
}
}
With this class, have created an entry for jasperreports_extension.properties file. Here is its content:
net.sf.jasperreports.extension.registry.factory.HyperlinkExtensionFactory=<fully_qualified_path_to_HyperlinkExtensionsRegistryFactory>
Am I missing anything? If there is any mistake I am making then kindly help to find out the one.

Thanks Narcis for input.
I've checked source code of Jasper Report 6.3.0 and tried to understand how Hyperlink registry is replaced. Found a work around for this one. Hope it will be helpful to others. Here is code snippet to register Hyperlink extension.
Exporter
AbstractHtmlExporter<HtmlReportConfiguration,HtmlExporterConfiguration> exporter = new HtmlExporter();
SimpleHtmlReportConfiguration htmlReportConfig = new SimpleHtmlReportConfiguration();
htmlReportConfig.setHyperlinkProducerFactory(HyperlinkExtensionsRegistryFactory.hyperlinkProducerFactory());
exporter.setConfiguration(htmlReportConfig);
HyperlinkExtensionsRegistryFactory.hyperlinkProducerFactory()
public JRHyperlinkProducerFactory hyperlinkProducerFactory() {
JRHyperlinkProducerMapFactory producerFactory = new JRHyperlinkProducerMapFactory();
producerFactory.addProducer("ReportExecution", new <Class_implements_JRHyperlinkProducer>());
producerFactory.addProducer("Custom", new <Class_implements_JRHyperlinkProducer>());
return producerFactory;
}

Related

Visual Studio project to call Azure ML Endpoint, namespace how-to

I have a Visual Studio WebForm C# project that loads in a browser. I also have a snippet of code from Azure ML to call my endpoint model. How should the *.aspx.cs file look? Thank you.
screen shot of my visual studio *.aspx.cs file
Here is how I plan to call it from the carprice.aspx file:
<asp:Label ID="lblResults" runat="server" Text="here is where results will go"></asp:Label>
Here is the Namespace template from Visual Studio project, the carprice.aspx.cs file:
namespace web13
{
public partial class carprice : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
And here is the snippet from Azure, a different kind of namespace syntax:
namespace CallRequestResponseService
{
class Program
{
static void Main(string[] args)
{
InvokeRequestResponseService().Wait();
}
static async Task InvokeRequestResponseService()
{
var handler = new HttpClientHandler()
{
ClientCertificateOptions = ClientCertificateOption.Manual,
ServerCertificateCustomValidationCallback =
(httpRequestMessage, cert, cetChain, policyErrors) => { return true; }
};
using (var client = new HttpClient(handler))
{
// Request data goes here
var scoreRequest = new
{
Inputs = new Dictionary<string, List<Dictionary<string, string>>>()
{
{
"input1",
new List<Dictionary<string, string>>()
{
new Dictionary<string, string>()
{
{
"price", "5800"
},
{
"year", "2013"......etc
The next day, I tried calling HTML label control from the Azure snippet of code, but I get an error, "the name lblResults2 does not exist in the current context." I've also tried changing the Azure snippet to Public classes. Here is another screen shot. thank you.
Visual Studio connecting Azure Results to form
Then further along, I'm adding newer screen shots
Visual Studio webform controls
Visual Studio namespace
further days along, this is what gets Visual Studio to compile and load in browser. screen shot is:
working syntax for calling endpoint

Drilling down model objects on Swagger

My application is a restful api and its integrated with Swagger and OpenAPI.
I have generated all Java stubs using OpenAPI YAML file and everything is working fine.
But when i try o drill down model objects on Swagger then it cannot locate some of objects although there are part of project as project compiles fine.
As shown in below screenshot, drilldown fails to locate COnfiguration object.
Any ideas on how to resolve this.
Edit:
I have a restful webservice and i generate all the java stubs [Data transfer objects] from a YAML file using openapi-generator plugin. This plugin automatically generates a class OpenAPIDocumentationConfig and following are the details of the class. After this setup, models are automatically generated in Swagger UI.
Also want to add that I am using OpenAPI 3.0 but i need to split Object definitions into multiple files. So i am referring to them using definitions as i don't believe component schemas can be split into multiple files.
#Configuration
#EnableSwagger2
public class OpenAPIDocumentationConfig {
ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("ABC Service")
.description("ABC Service")
.license("")
.licenseUrl("http://unlicense.org")
.termsOfServiceUrl("")
.version("1.0.0")
.contact(new Contact("","", "xyz#abc.com"))
.build();
}
#Bean
public Docket customImplementation(ServletContext servletContext, #Value("${openapi.studioVALService.base-path:}") String basePath) {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.x.y.z"))
.build()
.pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath))
.directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
.directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class)
.apiInfo(apiInfo());
}
class BasePathAwareRelativePathProvider extends RelativePathProvider {
private String basePath;
public BasePathAwareRelativePathProvider(ServletContext servletContext, String basePath) {
super(servletContext);
this.basePath = basePath;
}
#Override
protected String applicationPath() {
return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(basePath).build().toString());
}
#Override
public String getOperationPath(String operationPath) {
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/");
return Paths.removeAdjacentForwardSlashes(
uriComponentsBuilder.path(operationPath.replaceFirst("^" + basePath, "")).build().toString());
}
}
}
EDIT 2:
I moved all definitions to components and schemas but they are still split in multiple files and are referring to components across files but still i get the same error.
If you are using OpenAPI 3 you should put schemas that you want to reuse inside components. To refeer to it you must use refs like:
$ref: "#/components/schemas/EquityOptionConfigurationDO"

Is it possible to access sonarqube analysis results in a plugin?

As per the sonar logs, I see that sonar first runs the sensors, then the decorators and then stores the analysis results to the database. Is is possible to access analysis results in a sonar plugin?
Thanks
The Sonar web application is available at localhost:9000 (or wherever it's installed).
There is also a plugin for Eclipse to view issues:
http://docs.codehaus.org/display/SONAR/SonarQube+in+Eclipse
I finally found a solution to my problem here.
http://sonarqube.15.x6.nabble.com/sonar-dev-Where-can-I-find-new-issue-information-on-sonar-db-td5021022.html
// this annotation is important to be sure that relevant data on issues are up-to-date.
#DependsUpon(DecoratorBarriers.ISSUES_TRACKED)
public final class MyDecorator implements Decorator {
private final ResourcePerspectives perspectives;
public TechnicalDebtDecorator(ResourcePerspectives perspectives) {
this.perspectives = perspectives;
}
public void decorate(Resource resource, DecoratorContext context) {
Issuable issuable = perspectives.as(Issuable.class, resource);
if (issuable != null) {
List<Issue> issues = issuable.issues();
// Issue has method isNew()
}
}
}

Writing to stdout from an Eclipse plugin

My aim is to extend the eclipse QuickFix component and automate the process of solving syntax errors. Basically, the QuickFix component provides a list of solutions and my task is to select the best possible fix and apply it to the buggy code. But, for now I've been requested to print the resolutions for a marker in the console. I've tried to work out a tutorial and I'm kind of stuck right now. The tutorial I've tried to workout is: http://www.informit.com/articles/article.aspx?p=370625&seqNum=21
I've first added the extension in my plugin.xml file
<extension point="org.eclipse.ui.ide.markerResolution">
<markerResolutionGenerator
markerType="org.eclipse.core.resources.problemmarker"
class="org.eclipse.escript.quickfix.QuickFixer"/>
</extension>
Then i have created the two classes QuickFixer and QuickFix.
package quickfixer;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IMarkerResolutionGenerator;
class QuickFixer implements IMarkerResolutionGenerator {
public IMarkerResolution[] getResolutions(IMarker arg0) {
try {
Object problem = arg0.getAttribute("Whatsup");
return new IMarkerResolution[] {
new QuickFix("Fix #1 for "+problem),
new QuickFix("Fix #2 for "+problem),
};
} catch(CoreException e) {
return new IMarkerResolution[0];
}
}
}
then the class QuickFix:
package quickfixer;
import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IMarkerResolution;
public class QuickFix implements IMarkerResolution {
String label;
QuickFix(String label) {
this.label = label;
}
public String getLabel() {
return label;
}
public void run(IMarker arg0) {
MessageDialog.openInformation(null, "QuickFix Demo",
"This quick-fix is not yet implemented");
System.out.println("Label: " + label);
}
}
I've managed to correct all the errors i encountered and then i have run the plugin.
I have not been able to get the label printed out in the console.Any suggestions???...
Using System.out is not a good idea. Check the relevant FAQ on why
you should avoid using standard output or standard error in your
plug-in
and use proper logging (or the debugger).

iReports won't read my JavaBeans datasource, but it does load the class file

I've been losing my mind over this for the past week. I've tried tons of tutorials and forums, but nothing works.
Here's the overview: I want to display JavaBean objects in a simple table. I've created the JavaBean object, I've set the classpath, but iReport just won't work with it no matter what I try. Here's the entire Java code:
package mypack;
public class Person
{
private String name;
private static Person[] data = {new Person("John"), new Person("Mark")};
public Person() {}
public Person(String newName) { name = newName; }
public String getName() { return name; }
public void setName(String newName) { name = newName; }
public static Person[] getPersons() { return data; }
}
In iReport, I've created a new "JavaBeans set datasource" connection. Here's how it's filled:
However, when I click on "Test", nothing at all happens. No error but no data either. If Ichange the name of the factory class, then I will get the "class not found" exception, so iReport obviously did load my class, but it's still not working.
I really have no idea what I'm doing wrong in the Java file, because iReport seems to load it fine, but can't "talk" with it.
I've created the Java class with Eclipse Juno and I'm using iReport 4.6.0. Any help woud be really appreciated.
Problem solved. I was building Java file against 1.7, which iReports can't seem to read it seems. Building for 1.6 solves the problem and the above code works fine.