Package org.kapott.hbci.GV

Examples of org.kapott.hbci.GV.HBCIJob


        try {
          if (getSupportedLowlevelJobs().getProperty("SEPAInfo")!=null) {
            HBCIUtils.log("trying to fetch SEPA information from institute", HBCIUtils.LOG_INFO);
           
            // HKSPA wird unterstuetzt
            HBCIJob sepainfo=newJob("SEPAInfo");
            sepainfo.addToQueue();
            HBCIExecStatus status=execute();
            if (status.isOK()) {
              HBCIUtils.log("successfully fetched information about SEPA accounts from institute", HBCIUtils.LOG_INFO);
             
              passport.getUPD().setProperty("_fetchedSEPA","1");
View Full Code Here


                String line;
               
                try {
                    int       state=STATE_NEED_JOBNAME;
                    boolean   lljob=false;           // low- oder high-level-job?
                    HBCIJob   job=null;              // job-objekt
                    String    jobid=null;            // job-bezeichner
                    String    customerId=null;       // customer-id f�r job
                    Hashtable<String, Object> jobs=new Hashtable<String, Object>()// liste aller jobs
                       
                    // batch-datei zeilenweise einlesen und auswerten
                    while ((line=reader.readLine())!=null) {
                        line=line.trim();
                        // kommentare ignorieren
                        if (line.startsWith("#")) {
                            continue;
                        }
                       
                        if (state==STATE_NEED_JOBNAME && line.length()!=0) {
                            // es wird der beginn einer job-definition erwartet
                           
                            StringTokenizer tok=new StringTokenizer(line,":");
                            // jobnamen extrahieren
                            String          jobname=tok.nextToken().trim();
                           
                            if (jobname.equals("--")) {
                                // wenn jobname="--", dann neue hbci-message erzeugen
                                customerId=(tok.hasMoreTokens()?tok.nextToken().trim():null);
                                handler.newMsg(customerId);
                            } else {
                                // ansonsten handelt es sich um einen "richtigen" job
                                String resultMode;
                               
                                if (jobname.startsWith("_")) {
                                    // wenn jobname mit "_" beginnt, handelt es
                                    // sich um einen low-level-jobnamen
                                   
                                    job=handler.newLowlevelJob(jobname.substring(1));
                                    lljob=true;
                                   
                                    // zu einem low-level-job m�ssen zus�tzlich noch
                                    // eine ID (zum sp�teren wiederfinden des jobs)
                                    // und optional eine kunden-id festgelegt werden
                                    jobid=tok.nextToken().trim();
                                    resultMode="toString";
                                    customerId=(tok.hasMoreTokens()?tok.nextToken().trim():null);
                                } else {
                                    // wenn jobname nicht mit "_" beginnt, ist es
                                    // ein high-level-job
                                   
                                    job=handler.newJob(jobname);
                                    lljob=false;
                                   
                                    // zu einem high-level-job m�ssen zus�tzlich noch
                                    // eine ID (zum sp�teren wiederfinden des jobs),
                                    // ein modus f�r die ausgabe der ergebisdaten
                                    // und optional eine kunden-id festgelegt werden
                                    jobid=tok.nextToken().trim();
                                    resultMode=tok.nextToken().trim();
                                    customerId=(tok.hasMoreTokens()?tok.nextToken().trim():null);
                                }
                               
                                // job in menge der jobs speichern
                                jobs.put(jobid,job);
                                // ... und ausgabemodus f�r diesen job merken
                                jobs.put(jobid+"_resultMode",resultMode);
                                state=STATE_NEED_JOBPARAMS;
                            }
                        } else if (state==STATE_NEED_JOBPARAMS) {
                            // bis zur n�chsten leerzeile oder dem dateienende
                            // werden jetzt alle zeilen als job-parameter
                            // interpretiert
                           
                            if (line.length()!=0) {
                                StringTokenizer tok=new StringTokenizer(line,"=");
                               
                                // parameternamen und -wert holen
                                String paramName=tok.nextToken().trim();
                                if (!tok.hasMoreTokens()) {
                                    continue;
                                }
                                String paramValue=tok.nextToken().trim();
                               
                                // f�r low-level-jobs m�ssen die parameter mit
                                // einem "_" beginnen, bei high-level-jobs
                                // d�rfen sie *nicht* mit einem "_" beginnen
                                if (paramName.startsWith("_")!=lljob) {
                                    if (lljob) {
                                        throw new HBCI_Exception("*** "+jobid+" is a lowlevel job, so parameter names have to start with '_'");
                                    }
                                    throw new HBCI_Exception("*** "+jobid+" is a highlevel job, so parameter names must not start with '_'");
                                }
                               
                                // wenn es sich um einen low-level-job, den
                                // f�hrenden "_" beim parameter-namen entfernen
                                if (lljob) {
                                    paramName=paramName.substring(1);
                                }
                               
                                // wenn der parameter-wert mit einem "<" beginnt,
                                // so soll der wert des parameter aus der datei
                                // gelesen werden, die nach dem "<" spezifiziert
                                // ist
                                if (paramValue.startsWith("<")) {
                                    // �ffnen der datei
                                    String          filename=paramValue.substring(1);
                                    FileInputStream fin=new FileInputStream(filename);
                                   
                                    // puffer f�r einlesen der datei
                                    byte[]       buffer=new byte[2048];
                                    int          len;
                                    StringBuffer content=new StringBuffer();
                                   
                                    // datei in stringbuffer einlesen
                                    while ((len=fin.read(buffer))>0) {
                                        content.append(new String(buffer,0,len,"ISO-8859-1"));
                                    }
                                   
                                    // datei schlie�en
                                    fin.close();
                                    // parameterwert ist inhalt des stringbuffers
                                    paramValue=content.toString();
                                }
                               
                                // parameter f�r aktuellen job setzen
                                job.setParam(paramName,paramValue);
                            } else {
                                // leerzeile gefunden - damit ist die parameter-
                                // spez. f�r den aktuellen job beendet
                               
                                // aktuellen job zur job-queue hinzuf�gen
                                job.addToQueue(customerId);
                                state=STATE_NEED_JOBNAME;
                            }
                        }
                    }
                   
                    // wenn noch ein job "in bearbeitung" ist, der noch nicht
                    // zur job-queue hinzugef�gt wurde, dann das jetzt nachholen
                    if (state==STATE_NEED_JOBPARAMS) {
                        job.addToQueue(customerId);
                    }
                   
                    // alle batch-jobs ausf�hren
                    handler.execute();
                   
                    // ergebnis-writer f�r ok-jobs und f�r fehlerhafte jobs
                    // erzeugen
                    PrintWriter writer=new PrintWriter(new FileWriter(args[3]));
                    PrintWriter errWriter=new PrintWriter(new FileWriter(args[3]+".err"));
                   
                    try {
                        // alle bekannten job-bezeichner (IDs) durchlaufen
                        for (Enumeration<String> jobIds=jobs.keys();jobIds.hasMoreElements();) {
                            jobid=jobIds.nextElement();
                            if (jobid.endsWith("_resultMode")) {
                                continue;
                            }
                            // den dazugeh�rigen job holen
                            job=(HBCIJob)jobs.get(jobid);
                           
                            if (job.getJobResult().isOK()) {
                                // wenn der job erfolgreich gelaufen ist
                               
                                // ausgabe von jobid
                                writer.println("jobid:"+jobid);
                                // ausgabe der hbci-status-meldungen zu diesem job
                                writer.println("job status:");
                                writer.println(job.getJobResult().getJobStatus());
                               
                                // ausgabe der job-ergebnisse
                                writer.println("job result:");
                               
                                String resultMode=(String)jobs.get(jobid+"_resultMode");
                                if (resultMode.equals("props")) {
                                    // ausgabemodus="props": alle ergebnisdaten
                                    // als lowlevel-properties ausgeben
                                   
                                    Properties result=job.getJobResult().getResultData();
                                    if (result!=null) {
                                        // array mit result-properties holen und
                                        // sortieren
                                        String[] keys=(String[])new ArrayList(result.keySet()).toArray(new String[0]);
                                        Arrays.sort(keys);
                                       
                                        // ausgabe aller result-properties
                                        for (int i=0;i<keys.length;i++) {
                                            String name=keys[i];
                                            String value=result.getProperty(name);
                                            writer.println(name+"="+value);
                                        }
                                    }
                                } else {
                                    // ausgabemodus="toString": job-spezifische
                                    // toString()-methode f�r formatierung der
                                    // ergebnisdaten aufrufen
                                    writer.println(job.getJobResult());
                                }
                               
                                // leerzeile einf�gen
                                writer.println();
                            } else {
                                // wenn ein job fehler erzeugt hatte, die fehlermeldungen
                                // an die err-datei anh�ngen
                               
                                errWriter.println("jobid:"+jobid);
                                errWriter.println("global status:");
                                errWriter.println(job.getJobResult().getGlobStatus().getErrorString());
                                errWriter.println("job status:");
                                errWriter.println(job.getJobResult().getJobStatus().getErrorString());
                                errWriter.println();
                            }
                        }
                    } finally {
                        writer.close();
View Full Code Here

        // wenn der obige Aufruf nicht funktioniert, muss die abzufragende
        // Kontoverbindung manuell gesetzt werden:
        // Konto myaccount=new Konto("DE","86055592","1234567890");

        // Job zur Abholung der Kontoausz�ge erzeugen
        HBCIJob auszug=hbciHandle.newJob("KUmsAll");
        auszug.setParam("my",myaccount);
        // evtl. Datum setzen, ab welchem die Ausz�ge geholt werden sollen
        // job.setParam("startdate","21.5.2003");
        auszug.addToQueue();

        // alle Jobs in der Job-Warteschlange ausf�hren
        HBCIExecStatus ret=hbciHandle.execute();

        GVRKUms result=(GVRKUms)auszug.getJobResult();
        // wenn der Job "Kontoausz�ge abholen" erfolgreich ausgef�hrt wurde
        if (result.isOK()) {
            // kompletten kontoauszug als string ausgeben:
            System.out.println("##############################");
            System.out.println("#####    Umsatzliste   #######");
View Full Code Here

   
    private static void analyzeDepot(HBCIPassport hbciPassport, HBCIHandler hbciHandle, Konto myaccount) {
        myaccount.curr = null;

        // Job zur Abholung des Depotbestands erzeugen
        HBCIJob auszug=hbciHandle.newJob("WPDepotList");
        auszug.setParam("my",myaccount);
        auszug.addToQueue();

        // alle Jobs in der Job-Warteschlange ausf�hren
        HBCIExecStatus ret=hbciHandle.execute();

        GVRWPDepotList result=(GVRWPDepotList)auszug.getJobResult();
        // wenn der Job "Depotbestand abholen" erfolgreich ausgef�hrt wurde
        if (result.isOK()) {
            // kompletten Depotbestand als string ausgeben:
            System.out.println("##############################");
            System.out.println("#####    Depotliste    #######");
            System.out.println("##############################");
            System.out.println(result.toString());


        } else {
            // Fehlermeldungen ausgeben
            System.out.println("Job-Error");
            System.out.println(result.getJobStatus().getErrorString());
            System.out.println("Global Error");
            System.out.println(ret.getErrorString());
        }
       
        // Pr�fen, ob Depotumsatzabruf unterst�tzt wird
        if (!hbciHandle.getSupportedLowlevelJobs().containsKey("WPDepotUms")) {
            System.out.println("Abruf der Depotums�tze nicht unterst�tzt!");
        } else {
            // Job zur Abholung der Depotums�tze erzeugen
            HBCIJob ums=hbciHandle.newJob("WPDepotUms");
            ums.setParam("my",myaccount);
            // evtl. Datum setzen, ab welchem die Ums�tze geholt werden sollen
            // job.setParam("startdate","21.5.2003");
            ums.addToQueue();

            // alle Jobs in der Job-Warteschlange ausf�hren
            ret=hbciHandle.execute();

            GVRWPDepotUms umsRes =(GVRWPDepotUms)ums.getJobResult();
            // wenn der Job "Depotums�tze abholen" erfolgreich ausgef�hrt wurde
            if (umsRes.isOK()) {
                // komplette Depotums�tze als string ausgeben:
                System.out.println("################################");
                System.out.println("#####    Depotums�tze    #######");
View Full Code Here

        // wenn der obige Aufruf nicht funktioniert, muss die abzufragende
        // Kontoverbindung manuell gesetzt werden:
        // Konto myaccount=new Konto("DE","86055592","1234567890");

        // Job zur Abholung der Kontoausz�ge erzeugen
        HBCIJob auszug=hbciHandle.newJob("KUmsAll");
        auszug.setParam("my",myaccount);
        // evtl. Datum setzen, ab welchem die Ausz�ge geholt werden sollen
        // job.setParam("startdate","21.5.2003");
        auszug.addToQueue();

        // alle Jobs in der Job-Warteschlange ausf�hren
        HBCIExecStatus ret=hbciHandle.execute();

        GVRKUms result=(GVRKUms)auszug.getJobResult();
        // wenn der Job "Kontoausz�ge abholen" erfolgreich ausgef�hrt wurde
        if (result.isOK()) {
            // kompletten kontoauszug als string ausgeben:
            System.out.println(result.toString());
View Full Code Here

            this.checkInterrupted();

            monitor.setStatusText(i18n.tr("Aktiviere HBCI-Job: \"{0}\"",job.getName()));
            Logger.info("adding job " + hbciJob.getIdentifier() + " to queue");

            HBCIJob j = handler.newJob(hbciJob.getIdentifier());
            this.dumpJob(j);
            hbciJob.setJob(j);
            j.addToQueue();
            this.hbciJobs.add(hbciJob);
            if (hbciJob.isExclusive())
            {
              Logger.info("job will be executed in seperate hbci message");
              handler.newMsg();
View Full Code Here

   
   
    @Test
    public void test() {
        System.out.println("---------Erstelle Job");
        HBCIJob job =  handler.newJob("DauerSEPAEdit");
       
        Konto acc = new Konto();
        acc.blz = params.getProperty("target_blz");
        acc.number = params.getProperty("target_number");
        acc.name = "Kurt Mustermann";
        acc.bic = params.getProperty("target_bic");
        acc.iban = params.getProperty("target_iban");
       
       
        int source_acc_idx = Integer.parseInt(params.getProperty("source_account_idx"));
        job.setParam("src",passport.getAccounts()[source_acc_idx]);
        job.setParam("dst",acc);
        String value = params.getProperty("value");
        if(value == null) value = "100";
        job.setParam("btg",new Value(Integer.parseInt(value),"EUR"));
        job.setParam("usage","SEPA Dauerauftrag");
        job.setParam("firstdate", params.getProperty("firstdate"));
        job.setParam("timeunit", "M");
        job.setParam("turnus", "1");
        job.setParam("execday", "1");
        job.setParam("orderid", params.getProperty("orderid"));
       
        System.out.println("---------F�r Job zur Queue");
        job.addToQueue();

       
        HBCIExecStatus ret = handler.execute();
        HBCIJobResult res = job.getJobResult();
        System.out.println("----------Result: "+res.toString());
       
        Assert.assertEquals("Job Result ist nicht OK!", true, res.isOK());
    }
View Full Code Here

public class TestGVLastSEPA2 extends AbstractTestGV {

    @Test
    public void test() {
        System.out.println("---------Erstelle Job");
        HBCIJob job =  handler.newJob("LastSEPA");
       
        Konto acc = new Konto();
        acc.blz = params.getProperty("target_blz");
        acc.number = params.getProperty("target_number");
        acc.name = "Kurt Mustermann";
        acc.bic = params.getProperty("target_bic");
        acc.iban = params.getProperty("target_iban");
       
        int source_acc_idx = Integer.parseInt(params.getProperty("source_account_idx"));
        job.setParam("src",passport.getAccounts()[source_acc_idx]);
        job.setParam("dst",acc);
       
        String value = params.getProperty("value");
        if(value == null) value = "100";
        job.setParam("btg",new Value(Integer.parseInt(value),"EUR"));
        job.setParam("usage",params.getProperty("usage"));
        job.setParam("targetdate", params.getProperty("date"));
        job.setParam("creditorid", params.getProperty("creditorid"));
        job.setParam("mandateid", params.getProperty("mandateid"));
        job.setParam("manddateofsig", params.getProperty("date_of_sig"));
       
        System.out.println("---------F�r Job zur Queue");
        job.addToQueue();

       
        HBCIExecStatus ret = handler.execute();
        HBCIJobResult res = job.getJobResult();
        System.out.println("----------Result: "+res.toString());
       
        Assert.assertEquals("Job Result ist nicht OK!", true, res.isOK() && ret.isOK());
    }
View Full Code Here

   
   
    @Test
    public void test() {
        System.out.println("---------Erstelle Job");
        HBCIJob job =  handler.newJob("DauerSEPAList");
       
        int source_acc_idx = Integer.parseInt(params.getProperty("source_account_idx"));
        job.setParam("src",passport.getAccounts()[source_acc_idx]);
       
        System.out.println("---------F�r Job zur Queue");
        job.addToQueue();

       
        HBCIExecStatus ret = handler.execute();
        HBCIJobResult res = job.getJobResult();
        System.out.println("----------Result: "+res.toString());
       
        Assert.assertEquals("Job Result ist nicht OK!", true, res.isOK());
    }
View Full Code Here

   
   
    @Test
    public void test() {
        System.out.println("---------Erstelle Job");
        HBCIJob job =  handler.newJob("DauerSEPANew");
       
        Konto acc = new Konto();
        acc.blz = params.getProperty("target_blz");
        acc.number = params.getProperty("target_number");
        acc.name = "Kurt Mustermann";
        acc.bic = params.getProperty("target_bic");
        acc.iban = params.getProperty("target_iban");
       
        int source_acc_idx = Integer.parseInt(params.getProperty("source_account_idx"));
        job.setParam("src",passport.getAccounts()[source_acc_idx]);
        job.setParam("dst",acc);
       
        String value = params.getProperty("value");
        if(value == null) value = "100";
        job.setParam("btg",new Value(Integer.parseInt(value),"EUR"));

        job.setParam("usage","SEPA Dauerauftrag");
       
        job.setParam("firstdate", params.getProperty("firstdate"));
        job.setParam("timeunit", "M");
        job.setParam("turnus", "1");
        job.setParam("execday", "1");
       
        System.out.println("---------F�r Job zur Queue");
        job.addToQueue();

       
        HBCIExecStatus ret = handler.execute();
        HBCIJobResult res = job.getJobResult();
        System.out.println("----------Result: "+res.toString());
       
        Assert.assertEquals("Job Result ist nicht OK!", true, res.isOK());
    }
View Full Code Here

TOP

Related Classes of org.kapott.hbci.GV.HBCIJob

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.