Ejemplo n.º 1
0
  @Test
  public void testDataReadable() {
    // Init Number Serices
    Services.initNumberFormats();

    XMLImport myImport = new XMLImport("src/org/bh/companydata/periods.xml");
    try {
      DTOBusinessData myDTO = (DTOBusinessData) myImport.startImport();

      List<DTOBranch> branches = myDTO.getChildren();

      File f = new File("BROKEN_DATA.data");
      System.out.println(f.getAbsolutePath());

      PrintWriter outputStream = new PrintWriter(f);

      for (DTOBranch branch : branches) {

        for (DTOCompany company : branch.getChildren()) {

          DTOScenario scenario = new DTOScenario();
          scenario.put(DTOScenario.Key.BTAX, new DoubleValue(10.0));
          scenario.put(DTOScenario.Key.REK, new DoubleValue(10.0));
          scenario.put(DTOScenario.Key.RFK, new DoubleValue(10.0));
          scenario.put(DTOScenario.Key.CTAX, new DoubleValue(10.0));

          company.updateReferences(scenario);

          int i = 0;

          for (DTOPeriod period : company.getChildren()) {
            try {
              if (i != 0) {
                period.get(DTOPeriod.Key.FCF);
              }

              period.get(DTOPeriod.Key.LIABILITIES);

            } catch (DTOAccessException ae) {
              ae.printStackTrace(outputStream);
              outputStream.println(branch + " " + company + " " + period);
            }

            i++;
          }
        }
      }
      outputStream.close();

    } catch (Exception e) {
      e.printStackTrace();
      fail();
    }
  }
Ejemplo n.º 2
0
  public void testImport() {

    // Init Number Serices
    Services.initNumberFormats();

    XMLImport myImport = new XMLImport("src/org/bh/companydata/periods.xml");
    try {
      DTOBusinessData myDTO = (DTOBusinessData) myImport.startImport();

      //
      // just play with the BusinessData DTO! :-)
      // Like...
      //

      int counter = 0;

      List<DTOBranch> branchList = myDTO.getChildren();

      // Iterate all Company DTOs
      Iterator<DTOBranch> itr = branchList.iterator();
      while (itr.hasNext()) {
        DTOBranch currBranch = itr.next();

        // echos the branch keys
        System.out.print(currBranch.get(DTOBranch.Key.BRANCH_KEY_MAIN_CATEGORY));
        System.out.print(currBranch.get(DTOBranch.Key.BRANCH_KEY_MID_CATEGORY));
        System.out.println(currBranch.get(DTOBranch.Key.BRANCH_KEY_SUB_CATEGORY));

        //
        // Do the Branch has Companies?
        List<DTOCompany> companyList = currBranch.getChildren();
        Iterator<DTOCompany> CompanyItr = companyList.iterator();
        while (CompanyItr.hasNext()) {
          DTOCompany currCompany = CompanyItr.next();

          // echo them
          System.out.println("----" + currCompany.get(DTOCompany.Key.NAME));

          //
          // Do the Company has any Periods?
          List<DTOPeriod> periodList = currCompany.getChildren();
          Iterator<DTOPeriod> PeriodItr = periodList.iterator();
          while (PeriodItr.hasNext()) {
            DTOPeriod currPeriod = PeriodItr.next();

            // echo the name of the Period
            System.out.println("---------" + currPeriod.get(DTOPeriod.Key.NAME));
            counter++;

            //
            //	NEW ENHANCEMENT 04.01.2012
            //

            // get the Balance Sheet
            DTOGCCBalanceSheet myCurrBalanceSheet = (DTOGCCBalanceSheet) currPeriod.getChild(0);

            //
            // TotalCosts or CostOfSales Method?

            // get the ProfitLossStatements
            IPeriodicalValuesDTO myProfitStatement = currPeriod.getChild(1);
            // TotalCost Method
            if (myProfitStatement.getUniqueId()
                == DTOGCCProfitLossStatementTotalCost.getUniqueIdStatic()) {

              DTOGCCProfitLossStatementTotalCost myProfitStatementCasted =
                  (DTOGCCProfitLossStatementTotalCost) myProfitStatement;
            }

            // CostOfSales Method
            if (myProfitStatement.getUniqueId()
                == DTOGCCProfitLossStatementCostOfSales.getUniqueIdStatic()) {

              DTOGCCProfitLossStatementCostOfSales myProfitStatementCasted =
                  (DTOGCCProfitLossStatementCostOfSales) myProfitStatement;
            }
          }
        }
      }

      System.out.println(counter);

    } catch (XMLNotValidException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }