CIB JCoMod technical documentation (EN)
Site: | CIB eLearning |
Course: | CIB JCoMod |
Book: | CIB JCoMod technical documentation (EN) |
Printed by: | Guest user |
Date: | Thursday, 30 January 2025, 6:23 PM |
Table of contents
- 1. Introduction
- 2. JCoMod Wrapper
- 3. Server scenarios in comparison
- 4. Client scenarios
- 5. Quick start
- 5.1. JCoMod Wrapper example for CIB format: Job to evaluate RTF field information via an analysis callback
- 5.2. JCoMod Wrapper example for CIB merge: Job to mix CSV files into RTF documents
- 5.3. JCoMod Wrapper example for CIB format: Job for converting RTF and PDF documents
- 5.4. JCoMod Wrapper example for CIB pdf toolbox: Job for direct printing of a pdf document
- 5.5. JCoMod Wrapper example for CIB view: Job for displaying a RTF document and send it as pDF attachment
- 5.6. JCoMod Wrapper example for CIB view: Job for displaying a RTF document in a modally started Cib View
- 5.7. JCoMod Wrapper example for CIB dialog browser: Job for displaying and editing an HTML page with ruleset and CSV files
- 5.8. JCoMod Wrapper example for CIB dialog browser: Job for displaying an HTML document via CIB dialog and usage of the callback mechanisms of dialog shown with the example OnTextboxPopupCallback/OnTextboxEntryCallback
- 5.9. JCoMod Wrapper example for CIB mail: Job for (Batch) dispatch of a document via CIB mail (only Win32/MAPI)
- 5.10. JCoMod Wrapper example for CIB format/postscript: Job to print a RTF document as postscript
- 5.11. JCoMod Wrapper example for CIB rec: Usage as edit control for java input mask
- 5.12. JCoMod wrapper example for CIB job: JCibjobjob for converting a RTF to a PDF output
- 5.13. JCoMod Wrapper example for CIB runshell: Calling the native CIB runshell from Java using the ini file for CIB PDF conversation
- 5.14. JCoMod Wrapper example for CIB runshell: Calling the native CIB runshell from JAVA for a CIB merge mixing run
- 5.15. JCoMod Wrapper example for CIB runshell: Calling the native CIB runshell synchronously from JAVA for a CIB Postcript job
- 5.16. JCoMod Wrapper example for CIB runshell: Calling the native CIB runshell synchronously from JAVA for a CIB Postcript job with low processing priority
- 6. Scope of delivery
1. Introduction
This guide offers a compact overview of different possibilities to integrate the CIB office modules (JCoMod) from JAVA into your applications. Based on exemplary application architectures, practical use scenarios for the CIB office modules in Java applications are shown. The focus of the described server deployment scenarios is on the JCoMod components without user interface, while the client deployment scenarios demonstrate the integration of the interface-based JCoMod components.
The Java CIB office Module Wrapper (JCoMod) consists of Java classes for controlling the CIB office modules (CIB merge, CIB format incl. output [ascii, html, pcl, pdf, postscript, print, tiff], CIB dialog, CIB view and CIB rec). The package comprises individual job classes, each of which configures and executes a job (merge, format/output, view, dialog or rec) according to the user's requirements.
The JCoMod job classes can be used from JDK version 1.1.6 on.
This documentation gives an overview of the properties and the concept of the JCoMod job classes. Detailed technical interfaces and call parameters of the individual job classes can be found in the technical reference of the product, which is available as electronic online help and Javadoc.
2. JCoMod Wrapper
The JCoMod Wrapper consists of the Java job classes and the corresponding native connection between the CIB office modules.
JCoMod job classes
JCoMod JNI connection
JCoMod job classes
Die JCoMod job classes encapsulate the entire services of the CIB office modules in Java job classes via the Java native interface (JNI). From the Java programmer's point of view, complete "pure Java" interfaces are available for programming the document generation process.
Job |
Description |
JCibCryptJob |
Java class to control CIB crypt |
JCibDialogJob |
Java class for dynamic for dynamic rule-based rest data acquisition with the native CIB dialog HTML browser |
JCibDialogPureJavaJob |
|
JCibDiffJob |
Java class to control CIB diff |
JCibEpdfJob |
Java class to control CIB ePDF |
JCibFormatJob |
Java class for complete RTF for complete RTF output streams via CIB format/output (print & page preview, ASCII, HTML, PDF, PCL, Postscript, TIFF) |
JCibGsJob |
|
JCibJobJob |
Java class to control CIB job |
JCibMailJob |
Java class for email dispatch (currently via MAPI/WIN32) |
JCibMergeJob |
Java class for dynamic RTF variable integration <nd processing with CIB merge |
JCibPadJob |
Java class to control CIB pad |
JCibPdfJoinJob |
Java class to control CIB pdf toolbox |
JCibPdfMergeJob |
Java class to control pdf mixing processes with CIB pdf toolbox |
JCibPdfPrintJob |
Java class to control CIB view silent print functionality |
JCibRecJob |
Java class for RTF editing session with CIB rec |
JCibViewJob |
Java class to control CIB view |
JCibViewPureJavaJob |
|
JCoMod JNI connection
An area invisible to the application programmer is the JNI connection between the JCoMod jobs and the native CIB office modules. This is implemented on the basis of a C++ intermediate layer in the form of a DLL or shared library (Unix systems).
3. Server scenarios in comparison
This chapter gives you a brief overview of possible architectures.
3.1. User scenario ”JCoMod-Wrapper”
Application Servers are currently the heart of modern web-oriented software architectures. The figure below shows a possible application architecture "for generating PDF documents" on an application server.
The JCoMod Wrapper will be used here. This process can be file based or file-less (streaming).
3.2. User scenario ”CIB runshell”
The CIB runshell is a native application that makes the complete functional range of the CIB office modules available via the command line. It is available for Windows, OS/2, Solaris, Linux, HP-UX and AIX.
Since the CIB runshell runs as a separate process, it cannot interfere with the execution of the Java VM. The functions of the CIB office modules can thus be executed synchronously as well as asynchronously. The diagram shows a possible application architecture in connection with the CIB runshell on an Application Server:
An extended feature of the CIB runshell is the definition of the process priority with which it should run itself. All process priorities available on the corresponding system are supported. This allows e.g. a Java VM running with normal priority to start an instance of the CIB runshell running with low priority. This allows parallel running processes - for example, on an application server - to request resources faster, while the CIB runshell does not fully exhaust the processor. Note that low process priority also results in a significantly longer execution time for the CIB runshell process.
3.3. Extension ”CIB job”
The task manager CIB job offers an abstraction of document generation compared to the control of the CIB docgen modules and does not use intermediate files.
This is achieved by the specification of order descriptions in XML format. This means that the customer application describes the sequence of calls to be processed for the various CIB docgen modules with an XML file (order file), which also contains the user data to be used.
More information about CIB job can be found in the documentation "CIB documentServer Overview" and a description of job files can be found in the documentation "CIB documentServer details".
3.4. User scenario ”CIB documentServer”
Weiterführende Anforderungen im Serverumfeld führen zu einer Trennung von Webanwendung und Dokumentgenerierung. Der CIB documentServer ermöglicht durch den Einsatz von Sockets eine Entkoppelung der verschiedenen Betriebssystemprozesse, wodurch eine bessere Stabilität, Verfügbarkeit und Skalierbarkeit erreicht wird. Ausnahmen in der Dokumentgenerierung können zum Beispiel im Fall von Java die VM nicht mehr beeinträchtigen.
Further requirements in the server environment lead to a separation of web application and document generation. By using sockets, the CIB documentServer enables a decoupling of the different operating system processes, which results in better stability, availability and scalability. Exceptions in document generation, for example in the case of Java, can no longer affect the VM.
In addition, the specification of job descriptions in XML format (CIB job) provides an abstraction of the document generation compared to the control of the CIB docgen. A Java framework allows the convenient generation of XML jobs, which contain the instructions and settings for the CIB docgen as well as the user data to be used.
The CIB documentServer is modular in all parts, so that the required components can also be detached and optimally adapted to the individual requirements of your technical solution.
For example, you can also control the XML order processing CIB job directly via a C interface, integrate the Java framework directly into your web application or use your own control of the CIB socket servers. A call from EJB components is possible as well as the integration into MQ-Series.
For more information see the documentation "CIB documentServer Overview".
On the client side, the JCoMod Wrapper is particularly suitable for using the GUI-based CIB office modules like CIB view, CIB dialog and the CIB rec control from Java applications.
4. Client scenarios
The JCoMod Wrapper is particularly suitable on the client side to use the GUI-based CIB office modules such as CIB view, CIB dialog and the CIB rec Control from Java applications.
4.1. Java application uses native CIB view
The figure below shows a possible application architecture for integrating the native CIB view into a Java environment.
Figure to be added.
4.2. Java application uses the native CIB rec control
The figure below shows the integration of a CIB rec control into a Java input mask.
5.1. JCoMod Wrapper example for CIB format: Job to evaluate RTF field information via an analysis callback
The following example uses the CIB format component to parse through an RTF root document including the dependent "included" documents and to provide feedback on the field information contained in the text modules via an analysis callback of the CIB format component.
The analysis callback returns an ID and a corresponding string with content information.
import com.cib.comod.jobs.*;
import com.cib.comod.jobs.event.*;
import de.cib.util.trace.*;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
public class JComodTestCase extends TestCase {
public static final String TESTPATH = "D:\\jcomod\\";
public static void main(String[] args) {
JComodTestCase test = new JComodTestCase();
try {
test.runTest();
} catch (Throwable t) {
t.printStackTrace();
}
}
public static Test suite() {
TestSuite suite = new TestSuite("JComod");
suite.addTest(new JComodTestCase());
return suite;
}
/* (non-Javadoc)
* @see junit.framework.TestCase#runTest()
*/
protected void runTest() throws Throwable {
testFieldAnalyze();
}
public static void testFieldAnalyze() {
ICibFormatCallbackListener listener = new JCibFormatCallbackAdapter() {
public void callbackFormatOnField(FormatOnFieldCallbackEvent e) {
System.out.println(""+e.FieldID+" "+e.FieldData);
switch(e.FieldID) {
case 46: //Begin of REF field
break;
case 1046: //end of REF field
System.out.println("REF fieldname:"+e.FieldData);
break;
case 50: //Begin of MERGEFIELD field
break;
case 1050: //end of MERGEFIELD field
System.out.println("MERGEFIELD fieldname:"+e.FieldData);
break;
case 27: //Begin of INCLUDETEXT field
break;
case 1027: //end of INCLUDETEXT field
System.out.println("INCLUDETEXT fieldname:"+e.FieldData);
break;
}
}
};
//generate Job for CIB format DLL
JCibFormatJob t_Job = new JCibFormatJob();
//loads DLL
if (!t_Job.initialize())
return;
//set callback type
t_Job.executeFunction(ICibFormatJob.FUNCTION_ACTIVATECALLBACK, "FieldCallback");
t_Job.addCibFormatCallbackListener(listener);
//set rtf inputfile which should be analyzed
t_Job.setProperty(ICibFormatJob.PROPERTY_INPUTFILE,"root.rtf");
//activate, that includes should be analyzed as well
t_Job.setProperty(ICibFormatJob.PROPERTY_INCLUDETEXT,"1");
//set workspace, where included rtfs can be found
t_Job.setProperty(ICibFormatJob.PROPERTY_WORKSPACE,TESTPATH+ "./templates");
t_Job.execute();
//Fehlerbehandlung
int t_Error =
((Integer)t_Job.getProperty(ICibFormatJob.PROPERTY_ERROR)).intValue(); if (t_Error != 0) {
// Fehler beim Ausführen des Jobs
String t_Errortext = (String)
t_Job.getProperty(ICibFormatJob.PROPERTY_ERRORTEXT);
System.out.println("Fehler beim Ausführen: "+t_Error+" "+t_Errortext);
}
t_Job.executeFunction(ICibFormatJob.FUNCTION_DEACTIVATECALLBACK, "FieldCallback");
t_Job.removeCibFormatCallbackListener(listener);
t_Job.dispose();
}
}
5.2. JCoMod Wrapper example for CIB merge: Job to mix CSV files into RTF documents
import com.cib.comod.jobs.*; public boolean doMergeJob() { JCibMergeJob t_Job = new JCibMergeJob(); t_Job.initialize(); if (!t_Job.isInitialized()) { System.out.println("Fehler beim Initialisieren des JCibMergeJob"); t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return false; }; t_Job.setProperty(ICibMergeJob.PROPERTY_WORKSPACE, "d:\\test"); t_Job.setProperty(ICibMergeJob.PROPERTY_ERRORFILE, "merge.log"); t_Job.setProperty(ICibMergeJob.PROPERTY_INPUTFILE, "input.rtf"); t_Job.setProperty(ICibMergeJob.PROPERTY_OUTPUTFILE, "output.rtf"); t_Job.setProperty(ICibMergeJob.PROPERTY_DATAFILE, "data.csv"); // wenn die csv eine Multi-csv ist, dann folgende Zeile ausführen //t_Job.setProperty(ICibMergeJob.PROPERTY_MULTICSV, new Boolean(true)); //Job ausführen t_Job.execute(); //Fehlerbehandlung int t_Error = ((Integer)t_Job.getProperty(ICibMergeJob.PROPERTY_ERROR)).intValue(); if (t_Error != 0) { // Fehler beim Ausführen des Jobs String t_Errortext = (String) t_Job.getProperty(ICibMergeJob.PROPERTY_ERRORTEXT); System.out.println("Fehler beim Ausführen: "+t_Error+" "+t_Errortext); t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return false; } t_Job.dispose(); // Resourcen des Jobs freigeben (seit jcomod 2.0) return true; }
5.3. JCoMod Wrapper example for CIB format: Job for converting RTF and PDF documents
import com.cib.comod.jobs.*; public boolean doPdfJob() { JCibFormatJob t_Job = new JCibFormatJob(); t_Job.initialize(); if (!t_Job.isInitialized()) { System.out.println("Fehler beim Initialisieren des JCibFormatJob"); t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return false; } //falls vorhanden Lizenzdaten angeben //t_Job.setProperty(ICibFormatJob.PROPERTY_LICENSEKEY, "..."); //t_Job.setProperty(ICibFormatJob.PROPERTY_LICENSECOMPANY, "..."); //RTF Eingangsdokument t_Job.setProperty(ICibFormatJob.PROPERTY_INPUTFILE, "input.rtf"); //zu erzeugendes PDF Dokument t_Job.setProperty(ICibFormatJob.PROPERTY_OUTPUTFILE, "output.pdf"); //Arbeitsverzeichnis in dem die Dokumente liegen t_Job.setProperty(ICibFormatJob.PROPERTY_WORKSPACE, "d:\\test"); //Gewünschtes Ausgabeformat t_Job.setProperty(ICibFormatJob.PROPERTY_OUTPUTFORMAT, "FormatPdf"); //Job ausführen t_Job.execute(); //Fehlerbehandlung int t_Error = ((Integer)t_Job.getProperty(ICibFormatJob.PROPERTY_ERROR)).intValue(); if (t_Error != 0) { // Fehler beim Ausführen des Jobs String t_Errortext = (String) t_Job.getProperty(ICibFormatJob.PROPERTY_ERRORTEXT); System.out.println("Fehler beim Ausführen: "+t_Error+" "+t_Errortext); t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return false; } t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return true; }
5.4. JCoMod Wrapper example for CIB pdf toolbox: Job for direct printing of a pdf document
import com.cib.comod.jobs.*;
public class DirectPrintPdf { public static void main(String[] args) { JCibPdfJoinJob t_PDFJob = new JCibPdfJoinJob(); t_PDFJob.initialize(); if (!t_PDFJob.isInitialized()) { System.out.println("Fehler beim Initialisieren der Dll"); return; } //PDF-Datei festlegen z.B. ein Test.pdf t_PDFJob.setProperty(ICibPdfJoinJob.PROPERTY_INPUTFILE, "Test.pdf"); //Druckernamen festlegen z.B. HP LaserJet 4100 Series PS t_PDFJob.setProperty("PrinterName", "HP LaserJet 4100 Series PS" ); //Ausgabeformat festlegen t_PDFJob.setProperty(ICibPdfJoinJob.PROPERTY_OUTPUTFORMAT, "FormatPrinter"); //Prozess starten t_PDFJob.execute(); int t_ReturnValue =((Integer)t_PDFJob.getProperty(ICibFormatJob.PROPERTY_ERROR)).intValue(); if (t_ReturnValue != 0) { System.out.println("Fehler! CIB pdf toolbox returns " + t_ReturnValue); } t_PDFJob.dispose(); } }
5.5. JCoMod Wrapper example for CIB view: Job for displaying a RTF document and send it as pDF attachment
import com.cib.comod.jobs.*; public boolean doViewJob() { JCibViewJob t_Job = new JCibViewJob(); t_Job.initialize(); if (!t_Job.isInitialized()) { System.out.println("Fehler beim Initialisieren des JCibViewJob"); t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return false; }; //falls vorhanden Lizenzdaten angeben //t_Job.setProperty(ICibViewJob.PROPERTY_LICENSEKEY, "..."); //t_Job.setProperty(ICibViewJob.PROPERTY_LICENSECOMPANY, "..."); //Für die Verfügbarkeit der Mailanbindung setzen Sie t_Job.setProperty(ICibViewJob.PROPERTY_DISABLEMAIL, new Boolean(false)); // Für die Verfügbarkeit eines separaten Speichern Buttons t_Job.setProperty(ICibViewJob.PROPERTY_DISABLESAVE, new Boolean(false)); //damit hinter dem Speichern Button ein "Speichern unter" Dialog erscheint t_Job.setProperty(ICibViewJob.PROPERTY_SAVEASDIALOG, new Boolean(true)); //Welche Formate beim "Speichern unter" angeboten werden bestimmen Sie mit t_Job.setProperty(ICibViewJob.PROPERTY_SAVEFORMATS, "FormatPdf"); t_Job.setProperty(ICibViewJob.PROPERTY_INPUTFILE, "input.rtf"); //Job ausführen t_Job.execute(); //Fehlerbehandlung int t_Error = ((Integer)t_Job.getProperty(ICibViewJob.PROPERTY_ERROR)).intValue(); if (t_Error != 0) { // Fehler beim Ausführen des Jobs String t_Errortext = (String) t_Job.getProperty(ICibViewJob.PROPERTY_ERRORTEXT); System.out.println("Fehler beim Ausführen: "+t_Error+" "+t_Errortext); t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return false; } t_Job.dispose(); // Resourcen des Jobs freigeben (seit jcomod 2.0) return true; }
5.6. JCoMod Wrapper example for CIB view: Job for displaying a RTF document in a modally started Cib View
import com.cib.comod.jobs.*; import javax.swing.JFrame; public boolean doViewJob(String a_Input) { JCibViewJob t_Job = new JCibViewJob(); t_Job.initialize(); if (!t_Job.isInitialized()) { System.out.println("Fehler beim Initialisieren des JCibViewJob"); t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return false; }; //Definieren der Variable für das WindowHandle Integer t_AncestorWindowHandle = new Integer(0); //OwnerFrame erstellen JFrame t_OwnerFrame = new JFrame(); //Frame Größe setzen t_OwnerFrame.setSize(800, 800); //Frame Titel setzen t_OwnerFrame.setTitle("View"); //Frame auf bestimmte Stelle setzen t_OwnerFrame.setLocation(10, 15); //Frame unsichtbar machen t_OwnerFrame.setVisible(false); //AncestorWindowHandle erfragen t_AncestorWindowHandle = new Integer(new Long(t_Job .getWin32WindowHandle(t_OwnerFrame)).intValue()); //Inputfile setzen t_Job.setProperty(ICibViewJob.PROPERTY_INPUTFILE, a_Input); //ModalWindow wird gesetzt t_Job.setProperty("CVWUseModalWindow", "1"); //OwnerHwnd setzen t_Job.setPropertyImmediate(ICibViewJob.PROPERTY_OWNERHWND, t_AncestorWindowHandle); //Job ausführen t_Job.execute(); //Fehlerbehandlung int t_Error = ((Integer)t_Job.getProperty(ICibViewJob.PROPERTY_ERROR)).intValue(); if (t_Error != 0) { // Fehler beim Ausführen des Jobs String t_Errortext = (String) t_Job.getProperty(ICibViewJob.PROPERTY_ERRORTEXT); System.out.println("Fehler beim Ausführen: "+t_Error+" "+t_Errortext); t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return false; } t_Job.dispose(); // Resourcen des Jobs freigeben (seit jcomod 2.0) return true; }
5.7. JCoMod Wrapper example for CIB dialog browser: Job for displaying and editing an HTML page with ruleset and CSV files
import com.cib.comod.jobs.*; import com.cib.comod.jobs.event.*; public boolean doDialogJob() { JCibDialogJob t_Job = new JCibDialogJob(); t_Job.initialize(); if (!t_Job.isInitialized()) { System.out.println("Fehler beim Initialisieren des JCibDialogJob"); t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return false; } // Properties setzen t_Job.setProperty(ICibDialogJob.PROPERTY_INPUTFILE, "cibdemo.htm"); t_Job.setProperty(ICibDialogJob.PROPERTY_RULFILE, "cibdemo.rul"); t_Job.setProperty(ICibDialogJob.PROPERTY_DATAFILE, "cibdemo.csv"); t_Job.setProperty(ICibDialogJob.PROPERTY_WORKSPACE, "d:\\test"); // Callbacks setzen t_Job.executeFunction (ICibDialogJob.FUNCTION_ACTIVATECALLBACK, "LeaveCallback"); t_Job.executeFunction (ICibDialogJob.FUNCTION_ACTIVATECALLBACK, "EnterCallback"); // Callbackhandler registrieren und Funktionen festlegen t_Job.addCibDialogCallbackListener(new JCibDialogCallbackAdapter() { public void callbackDialogOnLeave() { System.out.println("callbackDialogOnLeave(): Leaving Control "+e.Control+"["+e.Index+"] \""+e.Value +"\", next Control "+e.NextControl+"["+e.NextIndex+"]\n"); } public void callbackDialogOnEnter() { System.out.println("callbackDialogOnEnter(): Entering Control "+e.Control+"["+e.Index+"] \""+e.Value +"\", Direction= "+e.TabDirection+"\n"); } } // Listener ); //new schließen //Job ausführen t_Job.execute(); //Fehlerbehandlung int t_Error = ((Integer)t_Job.getProperty(ICibDialogJob.PROPERTY_ERROR)).intValue(); if (t_Error == 0) { // gedrückten Button ermitteln String t_Button = (String)t_Job.getProperty (ICibDialogJob.PROPERTY_PRESSEDBUTTON); if (t_Button.equals("ANSEHEN")) { //starte einen CIB view JCibViewJob t_ViewJob = new JCibViewJob(); t_ViewJob.initialize(); if (!t_ViewJob.isInitialized()) { System.out.println("Fehler beim Initialisieren des JCibViewJob"); t_ViewJob.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) t_Job.dispose(); return false; } t_ViewJob.setProperty( ICibViewJob.PROPERTY_INPUTFILE, "test.rtf"); t_ViewJob.execute(); String t_Errortext = (String) ViewJob.getProperty(ICibViewJob.PROPERTY_ERRORTEXT); System.out.println("Fehler beim Ausführen: "+t_Error+" "+t_Errortext); ViewJob.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) t_Job.dispose(); return false; } } else { // Fehler beim Ausführen des Jobs String t_Errortext = (String) t_Job.getProperty(ICibDialogJob.PROPERTY_ERRORTEXT); System.out.println("Fehler beim Ausführen: "+t_Error+" "+t_Errortext); t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return false; } t_Job.dispose(); // Resourcen des Jobs freigeben (seit jcomod 2.0) return true; }
5.8. JCoMod Wrapper example for CIB dialog browser: Job for displaying an HTML document via CIB dialog and usage of the callback mechanisms of dialog shown with the example OnTextboxPopupCallback/OnTextboxEntryCallback
import com.cib.comod.jobs.*; import com.cib.comod.jobs.event.*; public class TextboxCBSample { static ICibDialogCallbackListener m_CallbackAdapter; public TextboxCBSample() { m_CallbackAdapter = null; } public static void main(String [] args) { // erzeuge einen JCibDialog-Job JCibDialogJob t_Job = new JCibDialogJob(); // Der Job muß initialisiert werden if (!t_Job.initialize()) { System.out.println("Fehler beim Initialisieren des Dialog-Job"); return; } //hier richtige Dateinamen einfügen t_Job.setProperty(ICibDialogJob.PROPERTY_INPUTFILE, "D:\\XYZ.HTM"); t_Job.setProperty(ICibDialogJob.PROPERTY_RULFILE, "D:\\XYZ.RUL"); // füge dem Job einen Callbacklistener hinzu. // // Der JCibDialogCallbackAdapter implementiert alle Callbackmethoden des // ICibDialogCallbackListener-Interfaces. Callback-Events werden nur // erzeugt, wenn die entsprechenden Callbacks auch per setProperty // gesetzt werden. // // Hier wird gleich eine on-the-fly-Klasse von JcibDialogCallbackListener // abgeleitet und die Callbackmethoden überladen. // // Der CallbackAdapter empfiehlt sich vor allem dann // wenn nicht alle Callbacks gebraucht werden. Außerdem wird der // JcibDialogCallbackAdapter auch neue Callbacks implementieren, // wenn noch weitere hinzukommen. t_Job.addCibDialogCallbackListener (m_CallbackAdapter = new JCibDialogCallbackAdapter() { public void callbackDialogOnTextboxPopup(DialogOnTextboxPopupCallbackEvent e) {callbackOnTextboxPopup(e);} public void callbackDialogOnTextboxEntry(DialogOnTextboxEntryCallbackEvent e) {callbackOnTextboxEntry(e);} } ); // aktiviere die nötigen Callbacks t_Job.executeFunction(ICibDialogJob.FUNCTION_ACTIVATECALLBACK, "TextboxPopupCallback"); t_Job.executeFunction(ICibDialogJob.FUNCTION_ACTIVATECALLBACK, "TextboxEntryCallback"); t_Job.setProperty(ICibDialogJob.PROPERTY_CALLBACKUSERDATA, new Integer(777)); //Dialog anzeigen t_Job.execute(); } public static void callbackOnTextboxPopup(DialogOnTextboxPopupCallbackEvent e) { //zwei Test-Einträge zur Verfügung stellen e.PopupEntries = "Test1a|Test2b"; } public static void callbackOnTextboxEntry(DialogOnTextboxEntryCallbackEvent e) { //Abhängig von der Auswahl einen Textbaustein in den Dialog einfügen //(nur MLE Editfelder) if (e.SelectedPopupEntry.compareTo("Test1a") == 0) { e.SelectedText = "Textbaustein1"; } else if(e.SelectedPopupEntry.compareTo("Test2b") == 0) { e.SelectedText = "Textbaustein2"; } } }
5.9. JCoMod Wrapper example for CIB mail: Job for (Batch) dispatch of a document via CIB mail (only Win32/MAPI)
import com.cib.comod.jobs.ICibMailJob; import com.cib.comod.jobs.JCibMailJob; public boolean doMailJob() { JCibMailJob t_Job = new JCibMailJob(); t_Job.initialize(); if (!t_Job.isInitialized()) { System.out.println("Fehler beim Initialisieren des JCibMailJob"); //t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return false; }; //t_Job.setProperty(ICibFormatJob.PROPERTY_LICENSEKEY, "..."); //t_Job.setProperty(ICibFormatJob.PROPERTY_LICENSECOMPANY, "..."); // Folgende Zustände können abgefragt werden: // MailNone, MailActive, MailDeactivated String t_MailAvailable = (String)t_Job.getProperty(ICibMailJob.PROPERTY_MAILAVAILABLE); // Den Maildialog benutzen, kein Batchbetrieb! t_Job.setProperty(ICibMailJob.PROPERTY_MAILDIALOG, new Boolean(true)); // Mailsystem ist möglicherweise nicht aktiv, es soll aber trotzdem // - wenn möglich - Email genutzt werden t_Job.setProperty(ICibMailJob.PROPERTY_MAILLOGONDIALOG,new Boolean(true)); // Email-Adresse, Betreff und Attachments einstellen t_Job.setProperty(ICibMailJob.PROPERTY_MAILRECIPIENT ,"mustermann@musterserver.de"); t_Job.setProperty(ICibMailJob.PROPERTY_MAILSUBJECT ,"Sehr wichtig!"); t_Job.setProperty(ICibMailJob.PROPERTY_MAILATTACHMENTS ,"c:\temp\wichtig.rtf"); //Job ausführen t_Job.execute(); //Fehlerbehandlung int t_Error = ((Integer)t_Job.getProperty(ICibMailJob.PROPERTY_ERROR)).intValue(); if (t_Error != 0) { // Fehler beim Ausführen des Jobs String t_Errortext = (String) t_Job.getProperty(ICibMailJob.PROPERTY_ERRORTEXT); System.out.println("Fehler beim Ausführen: "+t_Error+" "+t_Errortext); //t_Job.dispose(); // Resourcen d. Jobs freigeben (seit jcomod 2.0) return false; } //t_Job.dispose(); // Resourcen des Jobs freigeben (seit jcomod 2.0) return true; }
5.10. JCoMod Wrapper example for CIB format/postscript: Job to print a RTF document as postscript
import com.cib.comod.jobs.ICibFormatJob; import com.cib.comod.jobs.JCibFormatJob; public boolean doPostscriptJob(String a_Input, String a_Output, String a_Workspace) { JCibFormatJob t_Job = new JCibFormatJob(); t_Job.initialize(); if (!t_Job.isInitialized()) { System.out.println("Fehler beim Initialisieren des JCibFormatJob"); t_Job.dispose(); // Resourcen d. Jobs freigeben return false; } //t_Job.setProperty(ICibFormatJob.PROPERTY_LICENSEKEY, "..."); //t_Job.setProperty(ICibFormatJob.PROPERTY_LICENSECOMPANY, "..."); //RTF Eingangsdokument t_Job.setProperty(ICibFormatJob.PROPERTY_INPUTFILE, "input.rtf"); //zu erzeugendes Postscript Dokument t_Job.setProperty(ICibFormatJob.PROPERTY_OUTPUTFILE, "output.ps"); //PPD Datei mit den Druckerinformationen t_Job.setProperty(ICibFormatJob.PROPERTY_PRINTERNAME, "lp"); //Arbeitsverzeichnis in dem die Dokumente liegen t_Job.setProperty(ICibFormatJob.PROPERTY_WORKSPACE, "/user/test"); //Fontverzeichnis in dem die Fonts liegen t_Job.setProperty(ICibFormatJob.PROPERTY_FONTWORKSPACE, "/user/fonts"); //PPD Datei mit den Druckerinformationen t_Job.setProperty(ICibFormatJob.PROPERTY_PPDFILE, "/user/hp4000.ppd"); //Gewünschtes Ausgabeformat ....//Postscript direkt auf den Drucker t_Job.setProperty(ICibFormatJob.PROPERTY_OUTPUTFORMAT, "FormatPrinterPs"); //Job ausführen t_Job.execute(); //Fehlerbehandlung int t_Error = ((Integer)t_Job.getProperty(ICibFormatJob.PROPERTY_ERROR)).intValue(); if (t_Error != 0) { // Fehler beim Ausführen des Jobs String t_Errortext = (String) t_Job.getProperty(ICibFormatJob.PROPERTY_ERRORTEXT); System.out.println("Fehler beim Ausführen: "+t_Error+" "+t_Errortext); t_Job.dispose(); // Resourcen d. Jobs freigeben return false; } t_Job.dispose(); // Resourcen d. Jobs freigeben return true; }
5.11. JCoMod Wrapper example for CIB rec: Usage as edit control for java input mask
package de.cib.comod.test; import java.awt.BorderLayout; import java.awt.Container; import javax.swing.JFrame; import com.cib.tools.rec.JCibRec; public class RecSampleFrame extends JFrame { JCibRec m_Rec; public RecSampleFrame() { //Frame erstellen makeFrame(); } private void makeFrame() { //nötige Properties setzen setTitle("CIB rec - Testframe"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Frame unbedingt bereits jetzt sichtbar machen setVisible(true); //Rec hinzufügen addComponentsToPane(this.getContentPane()); pack(); //RTF in das Rec setzen (über Filename) m_Rec.setRTF("c:\\temp\\test.rtf"); //RTF in das Rec setzen (über String) //String t_RTF = "{\rtf1..."; //m_Rec.setRTF(t_RTF); m_Rec.update(); } public void addComponentsToPane(Container pane) { //Rec benötigt den Bezug zum Parent-JFrame m_Rec = new JCibRec(this); pane.add(m_Rec,BorderLayout.CENTER); } public static void main(String[] args) { new RecSampleFrame(); } }
5.12. JCoMod wrapper example for CIB job: JCibjobjob for converting a RTF to a PDF output
package example; import java.io.File; import com.cib.comod.jobs.IComodJob; import com.cib.comod.jobs.JCibJobJob; import com.cib.comod.jobs.JComodJob; public class JCoMod { private static final String s_LICENSECOMPANY = "XXX GmbH"; private static final String s_LICENSEKEY = "XXXX-XXXX-XXXXXXXX"; public static void main(String[] args){ JCoMod test = new JCoMod(); JComodJob j_Job = test.loadJob(); test.executeJob(j_Job); } public JComodJob loadJob(){ System.out.println("----------Module - Initialisierung----------"); JComodJob t_Job = new JCibJobJob(); t_Job.initialize(); if (!t_Job.isInitialized()){ System.out.println("Fehler beim Initialisieren des JCibJobJob"); t_Job.dispose(); // Resourcen d. Jobs freigeben } else { System.out.println("JCibJobJob initialisiert"); String version = (String) t_Job.getProperty(JComodJob.PROPERTY_VERSIONSTRING); System.out.println("CIB job version: " + version); } return t_Job; } public void executeJob(JComodJob t_Job){ try{ t_Job.setProperty(JCibJobJob.PROPERTY_LICENSECOMPANY, s_LICENSECOMPANY); t_Job.setProperty(JCibJobJob.PROPERTY_LICENSEKEY, s_LICENSEKEY); if (new File("./input/input.xml").exists()) System.out.println("Input File Exists"); t_Job.setProperty(JCibJobJob.PROPERTY_INPUTFILENAME,"./input/input.xml"); t_Job.setProperty(JCibJobJob.PROPERTY_OUTPUTFILENAME,"./output/output.xml"); t_Job.execute(); //Fehlerbehandlung int t_Error = ((Integer) t_Job.getProperty(IComodJob.PROPERTY_ERROR)).intValue(); if (t_Error != 0){ // Fehler beim Ausführen des Jobs String t_Errortext = (String) t_Job.getProperty(IComodJob.PROPERTY_ERRORTEXT); System.err.println("Fehler beim Ausführen: "+t_Error+" "+t_Errortext); } else { System.out.println("Job-Ausgabe richtig generiert"); } } finally { t_Job.terminate(); } } }
5.13. JCoMod Wrapper example for CIB runshell: Calling the native CIB runshell from Java using the ini file for CIB PDF conversation
package de.cib.sample.comod; import de.cib.comod.RunshellProcess; import java.io.File; boolean doPdfFormatRunshellProcess() { //RunshellProcess mit dem Executable erstellen RunshellProcess t_cibRunShell = new RunshellProcess("cibrsh.exe"); //Eingabefilename String t_inputFileName = new String("Test.rtf"); //Ausgabefilename String t_uniqueID = ""+System.currentTimeMillis(); String t_outputFile = t_uniqueID+".pdf"; //Property für das Arbeitsverzeichnis im CIB-Format //(z.B. für IncludePicture-Anweisungen) setzen String t_Workspace = new String("c:\\test\\"); cibRunShell.addProperty("WorkSpace", t_Workspace); //IniFile mit dem Kommando -i setzen cibRunShell.addCommand("-i", t_Workspace+"cibrsh.ini"); //Kommando -f für die PDF-Konvertierung und Eingabe- sowie //Ausgabefilenamen setzen cibRunShell.addCommand(RunshellProcess.COMMAND_PDF, t_inputFileName, t_outputFile); try { //PDF-Konvertierung ausführen cibRunShell.executeAndWait(new File(t_Workspace)); } catch(Exception ex) { System.out.println("Bei der Konvertierung mit CIB format/pdf "+ "ist eine Exception aufgetreten."); return false; } //Fehlerbehandlung der Runshell int error = cibRunShell.getExitCode(); if (error != 0) { System.out.println("CIB format/pdf-Fehler: " + error + "bei der Ausführung von " + cibRunShell.getCommandLine() + ";"); return false; } return true; }
5.14. JCoMod Wrapper example for CIB runshell: Calling the native CIB runshell from JAVA for a CIB merge mixing run
package de.cib.sample.comod; import de.cib.comod.RunshellProcess; import java.io.File; import java.io.IOException; boolean doMergeRunshellProcess() { // neuen Runshell-Prozess starten String t_Workspace = new String("\home\user\"); // cibrshux ist die CIB runshell unter Linux/Unix RunshellProcess runshell = new RunshellProcess("./bin/cibrshux"); runshell.addArgument(RunshellProcess.COMMAND_MERGE+"a./templates"); runshell.addArgument(RunshellProcess.COMMAND_MERGE+"q./Data"); runshell.addArgument(RunshellProcess.COMMAND_MERGE+"'l!merge.log'"); runshell.addArgument(RunshellProcess.COMMAND_MERGE+"iTest.rtf"); runshell.addArgument(RunshellProcess.COMMAND_MERGE +"'o!output.rtf'"); runshell.addArgument(RunshellProcess.COMMAND_MERGE+"s"); runshell.addArgument(RunshellProcess.COMMAND_MERGE+"-old-compare"); runshell.addArgument(RunshellProcess.COMMAND_MERGE+"dTest.csv"); runshell.addArgument(RunshellProcess.COMMAND_MERGE+"@1"); try { // Pfad zu den Libraries angeben und Prozess starten runshell.executeAndWait(new File(t_Workspace)); } catch(IOException io) { System.out.println("Beim Mischen mit CIB merge "+ "ist eine Exception aufgetreten."); return false; } catch(InterruptedException inter) { System.out.println("Beim Mischen mit CIB merge "+ "ist eine Exception aufgetreten."); return false; } // Fehlerbehandlung der CIB runshell int error = cibRunShell.getExitCode(); if (error != 0) { System.out.println("CIB merge-Fehler: " + error + "bei der Ausführung von " + cibRunShell.getCommandLine() + ";"); return false; } return true; }
5.15. JCoMod Wrapper example for CIB runshell: Calling the native CIB runshell synchronously from JAVA for a CIB Postcript job
package com.cib.comod.test; String cmd = new String("cibrshux FontWorkSpace=./Fonts/ PpdFilename=./ppd/hp4050_6.ppd LicenseCompany=... LicenseKey=... -sp ./InputFile.rtf"); Runtime rt = Runtime.getRuntime(); System.out.println("Executing " + cmd); Process proc = rt.exec(cmd); // any error??? and synchronize! int exitVal = proc.waitFor(); System.out.println("ExitValue: " + exitVal);
5.16. JCoMod Wrapper example for CIB runshell: Calling the native CIB runshell synchronously from JAVA for a CIB Postcript job with low processing priority
package com.cib.comod.test; String cmd = new String("cibrshux FontWorkSpace=./Fonts/ PpdFilename=./ppd/hp4050_6.ppd LicenseCompany=... LicenseKey=... –z-2 -sp ./InputFile.rtf"); Runtime rt = Runtime.getRuntime(); System.out.println("Executing " + cmd); Process proc = rt.exec(cmd); // any error??? and synchronize! int exitVal = proc.waitFor(); System.out.println("ExitValue: " + exitVal);
6. Scope of delivery
The JCoMod wrapper includes the following components:
JCoMod job classes are delivered in the form of a JAR archive.
JNI connection to the CIB office modules that are delivered in form of a DLL or shared library (Unix systems) depending on the platform.
Component |
Software scope |
JCoMod Wrapper |
ComodJobs.jar // jar-Archiv JCoMod Jobs libcibjcomod.so // JCoMod (JNI) shared library für Unix-Systeme libcibjcomod.su // JCoMod (JNI) shared library für HP Unix-Systeme Jcomod.dll // JCoMod (JNI) dynamic link library für Windows, OS/2 |