Package com.dtrules.xmlparser

Examples of com.dtrules.xmlparser.XMLPrinter


    /**
     * Set the output streams for debug and trace.
     */
    public void setOutput(PrintStream debugtrace, PrintStream error) {
        outPs = debugtrace;
        out = new XMLPrinter(outPs);
        err = error;
    }
View Full Code Here


     * @param session      The Rules Engine session
     * @param _out        The PrintStream we will write the XML stream to.
     * @throws RulesException
     */
    public static void printReport(IRSession session, PrintStream _out) throws RulesException {
        XMLPrinter xout = new XMLPrinter(_out);    // Get an instance of the XML Formatter.
       
        DTState state   = session.getState();    // Get all the state information from our
                                //   Session.
       
        IREntity job     = state.findEntity("job"); // Get the Job Entity from the Entity Stack
       
        RArray   results = job.get("job.results").rArrayValue(); // Get the Rules Engine list
                              //   of result Entities
                             
        for(IRObject r :results){          // For each result entity
            IREntity result = r.rEntityValue();    //   (which we will alias to an IREntity
                                //    pointer to cut down on type casting).

            xout.opentag("Client","id",result.get("client_id").stringValue()); // Output the
                                // client tag and the client ID
              prt(xout,result,"totalGroupIncome");// Print the totalGroupIncome
              prt(xout,result,"client_fpl");    // Print the fpl percentage
             
              if(result.get("eligible").booleanValue()){  // Test their eligiblity result
                  xout.printdata("eligibility", "Approved")// If approved, print the details of their     
                  prt(xout,result,"program");    //   approval. 
                  prt(xout,result,"programLevel");
                
              }else{
                xout.printdata("eligibility", "Not Approved"); // If not approved, print the
                  prt(xout,result,"program");    //   details of their rejection.       
              }
              RArray notes = result.get("notes").rArrayValue();
              xout.opentag("Notes");        // Print out any notes attached to the result.
                  for(IRObject n : notes){
                     xout.printdata("note",n.stringValue());
                  }
              xout.closetag();          // Close tags
            xout.closetag();
        }
        xout.close();                // Closes any remaining open tags.
    }
View Full Code Here

          t.runTests();
      }
    @Override
    public void printReport(int runNumber, IRSession session,
        PrintStream out) throws Exception {
      XMLPrinter xout = new XMLPrinter(out);
      session.printEntityReport(
          xout,
          true,
          false,
          session.getState(),
View Full Code Here

     * @param session      The Rules Engine session
     * @param _out        The PrintStream we will write the XML stream to.
     * @throws RulesException
     */
    public static void printReport(IRSession session, PrintStream _out) throws RulesException {
        XMLPrinter xout = new XMLPrinter(_out);    // Get an instance of the XML Formatter.
       
        DTState state   = session.getState();    // Get all the state information from our
                                //   Session.
       
        IREntity job     = state.findEntity("job"); // Get the Job Entity from the Entity Stack
       
        RArray   results = job.get("job.results").rArrayValue(); // Get the Rules Engine list
                              //   of result Entities
                             
        for(IRObject r :results){          // For each result entity
            IREntity result = r.rEntityValue();    //   (which we will alias to an IREntity
                                //    pointer to cut down on type casting).

            xout.opentag("Client","id",result.get("client_id").stringValue()); // Output the
                                // client tag and the client ID
              prt(xout,result,"totalGroupIncome");// Print the totalGroupIncome
              prt(xout,result,"client_fpl");    // Print the fpl percentage
             
              if(result.get("eligible").booleanValue()){  // Test their eligiblity result
                  xout.printdata("eligibility", "Approved")// If approved, print the details of their     
                  prt(xout,result,"program");    //   approval. 
                  prt(xout,result,"programLevel");
                
              }else{
                xout.printdata("eligibility", "Not Approved"); // If not approved, print the
                  prt(xout,result,"program");    //   details of their rejection.       
              }
              RArray notes = result.get("notes").rArrayValue();
              xout.opentag("Notes");        // Print out any notes attached to the result.
                  for(IRObject n : notes){
                     xout.printdata("note",n.stringValue());
                  }
              xout.closetag();          // Close tags
            xout.closetag();
        }
        xout.close();                // Closes any remaining open tags.
    }
View Full Code Here

     * @param destinationFile
     * @return
     * @throws Exception
     */   
  public void convertDecisionTables(String directory,String destinationFile) throws Exception{
      XMLPrinter out = new XMLPrinter("decision_tables",new FileOutputStream(destinationFile));
      StringBuffer conversion = convertFiles(new File(directory),out,0);
      if(conversion != null){
          System.out.print(conversion);
      }else{
          System.out.println("No Decision Tables Found");
      }
      out.close();
    }
View Full Code Here

                }
            }
        }else{
            convertEDD(ef,rs,excelName);
        }
        XMLPrinter   xptr  = new XMLPrinter(new FileOutputStream(outputXMLName));
        xptr.opentag("entity_data_dictionary","version","2","xmlns:xs","http://www.w3.org/2001/XMLSchema");
        ef.writeAttributes(xptr);
        xptr.close();
    }
View Full Code Here

        HSSFWorkbook wb = new HSSFWorkbook(input);
        HSSFSheet sheet = wb.getSheetAt(0);

        // Open the EDD.xml output file
        String     tmpEDDfilename = rs.getWorkingdirectory()+tmpEDD;
        XMLPrinter xout = new XMLPrinter(new FileOutputStream(tmpEDDfilename));
       
        // Write out a header in the EDD xml file.
        xout.opentag("edd_header");
           xout.printdata("edd_create_stamp",
                new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z").format(new Date())
           );
           xout.printdata("Excel_File_Name",excelFileName);
        xout.closetag();
        xout.opentag("edd");

       
        // Get the indexes of the columns we need to write out the XML for this EDD.
        int rows = sheet.getLastRowNum();
        int entityIndex    = findvalue("entity",sheet,0);
        int attributeIndex = findvalue("attribute",sheet,0);
        int typeIndex      = findvalue("type",sheet,0);
        int subtypeIndex   = findvalue("subtype",sheet,0);
        int defaultIndex   = findvalue("defaultvalue",sheet,0);
        int inputIndex     = findvalue("input",sheet,0);
        int accessIndex    = findvalue("access",sheet,0);
        int commentIndex   = findvalue("comment",sheet,0);      // optional
        int sourceIndex    = findvalue("source",sheet,0);       // optional
       
        // Some columns we just have to have.  Make sure we have them here.
        if(entityIndex <0 || attributeIndex < 0 || typeIndex < 0 || defaultIndex < 0 || accessIndex < 0 || inputIndex <0 ){
            String err = " Couldn't find the following column header(s): "+
              (entityIndex<0?" entity":"")+
              (attributeIndex<0?" attribute":"")+
              (typeIndex<0?" type":"")+
              (defaultIndex<0?" default value":"")+
              (accessIndex<0?" access":"")+
              (inputIndex<0?" input":"");
            throw new Exception("This EDD may not be valid, as we didn't find the proper column headers\n"+err);
        }
       
        // Go through each row, writing out each entry to the XML.
        for(int row = 1; row <=rows; row++){
            String entityname = getCellValue(sheet,row,entityIndex);    // Skip all the rows that have no Entity
            if(entityname.length()>0){
                String src     = sourceIndex>=0 ? getCellValue(sheet,row,sourceIndex):"";
                String comment = commentIndex>=0 ? getCellValue(sheet,row,commentIndex):"";
                xout.opentag("entry");
                xout.opentag("entity",
                        "entityname"        , entityname,
                        "attribute"         , getCellValue(sheet,row,attributeIndex),
                        "type"              , getCellValue(sheet,row,typeIndex),
                        "subtype"           , getCellValue(sheet,row,subtypeIndex),
                        "default"           , getCellValue(sheet,row,defaultIndex),
                        "access"            , getCellValue(sheet,row,accessIndex),
                        "input"             , getCellValue(sheet,row,inputIndex),
                        "comment"           , getCellValue(sheet,row,commentIndex)
                );
                xout.closetag();
                if(comment.length()>0)xout.printdata("comment",getCellValue(sheet,row,commentIndex));
                if(src    .length()>0 )xout.printdata("source", getCellValue(sheet,row,sourceIndex));
                xout.closetag();               
            }
        }
        xout.closetag();
        xout.close();
        convertEDD(ef,rs, tmpEDDfilename);
    }
View Full Code Here

    /**
     * Prints the current state of the AutoDataMap as a single configuration file.
     * @param fstream
     */
    public void printMappingConfigurationXML(FileOutputStream fstream) {
        XMLPrinter xout = new XMLPrinter("config",fstream);
        printMappingConfigurationXML(xout);
    }
View Full Code Here

        return true;
    }
   
    public void generateMapping(String mapping, String inputfile, String outputfile) throws Exception {
        FileInputStream input = new FileInputStream(inputfile);
        XMLPrinter      out   = new XMLPrinter(new FileOutputStream(outputfile));
        generateMapping(mapping,input,out);
    }
View Full Code Here

    /* (non-Javadoc)
     * @see com.dtrules.mapping.IMapGenerator#generateMapping(java.lang.String, java.lang.String, java.lang.String)
     */
    public void generateMapping(String mapping, String inputfile, String outputfile) throws Exception {
        FileInputStream input = new FileInputStream(inputfile);
        XMLPrinter      out   = new XMLPrinter(new FileOutputStream(outputfile));
        generateMapping(mapping,input,out);
    }
View Full Code Here

TOP

Related Classes of com.dtrules.xmlparser.XMLPrinter

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.