You are provided with a sample program that demonstrates how to use the Catalog API to create or modify a catalog - TestCatalogAPI.java that is located in <install_root>\help\samples\APICatalog.
Here, TestCatalogAPI.java has been used as an example to explain how the methods work in the Catalog API.
DesignerUserInfo userInfo=new DesignerUserInfo("UID", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
desg = new Designer(path, catName, userInfo);
If the catalog named catName (MyReports.cat) exists, it will be opened. Otherwise it will be created.
CatalogAPI cat = dr.getCatalogAPI();ConnectionInfo info = new ConnectionInfo("sa", "");
String con = cat.insert("", false,"Jinfonet demo", "demo db",
"jdbc:hsqldb:C:\\JReport\\Designer\\Demo\\db\\JRDemo", "org.hsqldb.jdbcDriver", info);tb.addTable("", null, "PUBLIC", "CUSTOMERS", "Customers");
String formulahandles=cat.insert("total",cat.FORMULA);
FormulaInfo formulainfo=new FormulaInfo("total","total formula","@\"Unit Price\" * @Quantity - @Discount");
cat.set(formulahandles,formulainfo);
cat.insert("SQL1","sqlfile.txt"); cat.save(); After running the program, a new catalog file MyReports.cat will be created in C:\JReport\Designer\Demo\MyReports. Be sure to create this empty directory first.
C:\JReport\Designer\help\samples\APICatalog>javac -classpath "C:\JReport\Designer\lib\report.jar;C:\JReport\Designer\lib\sac.jar;C:\JReport\Designer\lib\JREngine.jar;C:\JReport\Designer\lib\log4j-1.2.8.jar;C:\test\classes" TestCatalogAPI.java
C:\JReport\Designer\help\samples\APICatalog>java -classpath "C:\JReport\Designer\lib\jrengine.jar;C:\JReport\Designer\lib\sac.jar;C:\JReport\Designer\lib\report.jar;C:\JReport\Designer\lib\log4j-1.2.8.jar;C:\JReport\Designer\help;C:\test\classes" -Dreporthome=C:\JReport\Designer TestCatalogAPI -path=C:\JReport\Designer\Demo\MyReports -catalog=MyReports.cat -log=C:\JReport\Designer\logs\designer.log