DXLExporter is not exporting the design element sin Xpage? - lotus-notes

**I am using the following code,**
var db=session.getCurrentDatabase()
var nc:NotesNoteCollection=db.createNoteCollection(true);
nc.selectAllDesignElements(true);
nc.buildCollection()
var filename = "d:\\dxl\\xpDXL.dxl";
var stream:NotesStream=session.createStream()
if (stream.open(filename)) {
stream.truncate(); // Any existing file is erased
var exporter:NotesDxlExporter = session.createDxlExporter();
stream.writeText(exporter.exportDxl(db))
}
** It is not exporting the designelements. But in DXL, It has the documentcollections.**

You are creating a NotesNoteCollection called nc but you end up exporting db. So change stream.writeText(exporter.exportDxl(db)) to:
stream.writeText(exporter.exportDxl(nc))

The XPages design elements in DXL are a headache to use. You are better off using the import/export plug-in from OpenNTF. It uses the Eclipse VFS to go after data in native format. So images are images, forms are DXL and XPages are their source. The plug-in contains the source code, so you can see how it is done.
The other option is to link a NSF to an onDisk project (the step necessary for version control) and just look inside the directory.
XPages design elements are a little problematic if you want to deal with them outside of designer: if you inject the source somewhere else you lack the compiled Java. If you are looking at documentation or variation management Designer and VFS (Virtual File System, Java Interface IResource) is our best bet

Maybe this is an security issue: You need at least designer access to your database to get design elements in a DXL export via XPage.
Even public access elements are not exported.
Hope this helps
Sven

Related

How to convert a QuickReport .QRP files into XML, HTML or Text?

I need to create a service to convert a series of QuickReport _(.QRP)_ files into something more parsable such as Text or HTML.
What is the best way of doing that?
qrp files are definition files for the Delphi/Quick Reports engine.
It is not immediately clear from the question whether you want to completely do away with the delphi/quickreports engine or just get the results in a browser.
If it is the former, then you may have a complete rewrite on your hands. But if it is the latter then you probably need to adapt a delphi app to export pdf files, say.
The Delphi app approach is likely only viable if you have full control of the security of your web-server.
Re-reading the question, you specifically want to parse the reports (presumably for data extraction).
As quick reports uses a relational db as a source, the only reason I can think of doing this is because you don't have access to the Delphi source or the database.
This may imply a one-off data migration away from an ex-supplier. So maybe just print to a pdf-print driver, then convert the pdfs to text and parse away.
I hope this helps.
I would recommend you to check Gnostice eDocEngine which will allow you to export .QPR to many formats including Excel.
https://www.gnostice.com/nl_article.asp?id=248&t=Export_From_Quickreport_To_PDF_And_Other_Formats
eDocEngine VCL has several interesting components:
TQRPQuickrep, TgtQRExportInterface and for export to Excel TgtExcelEngine. QPR-to-Excel rendering is performed with 4 lines of code (assuming the components are initialized) :
gtPDFEngine1.FileName := 'eDoc_QuickReport_Demo.pdf';
gtPDFEngine1.Preferences.ShowSetupDialog := false;
gtQRExportInterface1.Engine := gtPDFEngine1;
gtQRExportInterface1.RenderDocument('eDoc_QuickReport.QRP');
It is fairly priced and is provided with the source code. The only limitation is that it is Delphi and C++ Builder complaint, but if you feel comfortable with any of these languages you can easily create CLI utility or service and call it from your code.

Can I write to a text file from a button in xPages?

I have an xPages application that needs to write a text file to a folder on my network. I'm not sure if it's even possible from an xPages application?
If it is, can someone give me an idea how to go about this?
POI4XPages can write views etc to CSV files https://poi4xpages.openntf.org/. I've previously used OpenCSV, and Apache-licensed Java library to import from a CSV file, but it also allows exporting. I use it regularly to preload data for session databases like for my session at Connect 2016. CommonsCSV has subsequently been released, which would replace OpenCSV.
Yes you can. The easiest way is to create a Java class that does what you need (and test it from the command line). In a button, which is server side JavaScript, you can instantiate that class and write out.
You might need to handle security setting (e.g. deploying your class in a jar file into [DominoAppDir]/jvm/lib/ext) to be allowed to have network access. If you rather keep the class in the nsf, you might need harder measures.
Let us know how it goes
I just created a simple class that created the file and wrote to it. Worked like a champ
Thanks all!

how to extract the entire database/application script in lotusscript?

I want to know some way to extract the entire script from all design elements, forms, agents, views etc. I know that in MS .NET we use reflection to get the entire code, classes, functions, properties, everything. I wonder if this is also possible using lotus script or any third party tool. In fact, my basic requirements is to search for anything in the entire script in the Lotus Designer using Ctrl+F but that doesn't help, whereas in Visual Studio.NET one can easily search the project or even the entire solution for the specific keyword.
Thanks,
baburman
You can search for every string in database's code in Domino Designer at menu entry
Search / File...
If you still need to export all LotusScript code of a database,
execute menu File / Application / Design Synopsis... or
export database design as DXL

XPages: Is there a way to copy/rename custom controls

In Lotuscript you can manipulate design elements - create them, change them, rename them, etc.
Are you able to do the same thing for Xpages and custom controls design elements?
====================================================================
My question should have been clearer. What I want to accomplish is to copy an existing cc and give it a new name, programatically. The app will then close and reopen (or refresh or get rebuilt) so that the app can "see" the new cc. If I copy the cc it will only have one field on it. I will add custom code later. I could just create a new cc with no code in it, that would work too.
I am not familiar with the DXL exporter but I can research it. Using that can I just export the design of the cc to an XML file in a temp directory, use the transform to change the name, and then import the control?
I think the XPage or Custom Control design elements are probably under MISC_CODE or MISC_FORMAT design elements in a NoteCollection.
However, accessing that design element is the easy part. Doing a create / rename / change etc is a much bigger task.
Remember that the XPage or Custom Control XML file is only a starting point:
XPages and Custom Controls also have a .xsp.metadata file, as you'll see with source control.
Custom Controls will also have (and need) a .xsp-config file.
There are corresponding .java files for every XPage and Custom Control in the Local source folder. They're created by a builder based on parsing the XML. I don't think you'll be able to create those programmatically. I'm not sure of the impact of renaming them.
For Custom Controls, even if you can rename the .java file, it's referenced in the .java files of relevant XPages. Updating those is goiong to be a significant task.
The XPages runtime doesn't even use those .java files. Instead it uses the .class files in WebContent\WEB-INF (you need to use Project Explorer view and modify the filter to see those files). This is compiled byte code, so you won't be able to update the .class files for XPages containing renamed Custom Controls, as far as I know.
Even if you can rename the .class files, the XPages runtime almost certainly won't use them until either a Clean (which will overwrite anything you've done) or an HTTP restart. As far as I can tell they're cached.
Depending on your use cases, it's possible not all these points will be an issue, e.g. if you're modifying the XML files and building with headless designer.
I suspect this is why nothing was added to the NoteCollection object or a specific NotesXPage / NotesCustomControl API class added.
In Lotuscript you can manipulate design elements - create them, change them, rename them, etc.
This is only partially true. There is a LS API to create/alter views and outlines. Good luck with other design elements - although they're standard "notes", so you can access their items, in most cases you won't compile them and there will be some problems with signatures (real experience with TeamStudio CIAO).
Your question has two points of view - do you want to alter design elements in design process or alter running application?
To help a designer you can go the way of Eclipse extensions and enrich tools in IBM Designer to help developer. Something like TeamStudio Designer. In this case you need to look for source design elements, mentioned by Paul.
To enrich application you don't need to alter source design elements. IBM Designer transforms XML in source code to a Java code (JSF framework) - so you can generate your Java code from anything you wish. Take a look inside Local\xsp folder of NSF in Package explorer. You will find Java sources made from your XPages and Custom Controls. So if you don't need to work with design elements, go for Java components - they can be built on the fly.
And of course, there is always the option of DXL framework - so you can clone/alter design of the application through XML transformations. Good starting point: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/ls-design-programming.htm

How to directly export a collection of DTOs to CSV, Excel or PDF?

I have a List<MyDto> which I want to export with PrimeFaces. I tried with <p:dataExporter>, but it seems that it only uses UI <p:dataTable> content.
How can I directly export a list of DTOs to CSV, Excel or PDF?
You need a library to handle this. Primefaces doesn't inherently know how to display your data (it analyzes the columns and then exports based on that) so you need to give it some hints. The short answer is that you can easily create a table either programatically via reflection on the DTO and binding it to the page or by creating a simple data-table and set it to a style of "display:none" and then using the exporter.
Alternatively you can look at a reporting suite like JasperReports that handles "printing" to the above formats, but again, you will need to do something to interpret it. If you don't care about performance JSON-Lib has a very nice "toXML" method that will rip down a DTO to xml which could then be easily exported to any of the formats you choose.
Basically, you're looking at ~ 1 hour of work if it is a complex set of DTOs or 10 minutes if it isn't--as long as bandwidth isn't an issue this should be completely painless.

Resources