コード例 #1
0
 public void saveGeneralInfo() {
   try {
     controller.saveCompetitionGeneralInfo(competition);
     JsfUtils.addSuccessMessage(
         ResourceBundleUtil.getResourceBundleProperty("dataSaved"), " ", "manageCompetitionForm");
   } catch (ApplicationException e) {
     System.out.println("APPExcpetion ManageCmopBB#saveGeneralInfo " + e.getMessage());
     JsfUtils.addErrorMessage(e, "manageCompetitionForm");
     controller.storeCompetition(competition);
   } catch (Exception e) {
     System.out.println(
         "ManageCompetitionBackingBean#saveGeneralInfo excpetion " + e.getLocalizedMessage());
     e.printStackTrace();
     JsfUtils.addErrorMessage("ERROR", null, "manageCompetitionForm");
   }
 }
コード例 #2
0
  public void saveScore(CompetitorMatch cmg, DashboardPanel dp) {
    System.out.println("Wykonal sie save z inpalce " + cmg.getCompetitorMatchScore());
    //
    //        Panel testPanel = new Panel();
    //        testPanel.setId("someId");
    //
    ////        try {
    ////            new ObjectOutputStream(new ByteArrayOutputStream()).writeObject(testPanel);
    ////        } catch (IOException ex) {
    ////            System.out.println("POELCIAAL exxxx");
    ////            Logger.getLogger(ManageCompetitionBackingBean.class.getName()).log(Level.SEVERE,
    // null, ex);
    ////        }
    //        System.out.println("Serializable test passed");
    //        for (DashboardPanel dp1 : bracketCreator.getPanelList()) {
    //            if (dp1.getMatch() != null && dp1.getMatch().getIdMatch() != null) {
    //                if (dp1.getMatch().getIdMatch().equals(cmg.getIdMatch().getIdMatch())) {
    //                    System.out.println("Sa rowne, zamien " + dp1.getPanel() + " id " +
    // dp1.getPanel().getId());
    //                    System.out.println("param " + dp.getPanel() + " id " +
    // dp.getPanel().getId());
    ////                    Panel p = new Panel();
    ////                    p.setId(dp1.getPanel().getId());
    ////                    dp1.setPanel(p);
    //                    dp = dp1;
    //                    break;
    //                }
    //            }
    //        }
    //        bracketCreator.disableMatch(dp);

    System.out.println("Zawodnika " + cmg.getIdCompetitor());

    try {
      Map<String, CompetitorMatch> savedMap = controller.saveCompetitorScore(cmg);
      CompetitorMatch savedCompetitorMatch = savedMap.get("saved");

      System.out.println("CKP111111111");
      bracketCreator.updateScores(savedCompetitorMatch);

      //            CompetitorMatch advancedCompetitorMatchVersioned =
      // savedMap.get("advancedVersioned");
      //
      //            if (advancedCompetitorMatchVersioned != null) {
      //                bracketCreator.addAdvancedCompetitor(advancedCompetitorMatchVersioned);
      //            }
      CompetitorMatch advancedCompetitorMatch = savedMap.get("advanced");

      //            System.out.println("id match " +
      // advancedCompetitorMatch.getIdMatch().getIdMatch());
      if (advancedCompetitorMatch != null) {
        System.out.println("CKP222222222");
        //        cmgList.add(advancedCompetitorMatch);
        bracketCreator.addAdvancedCompetitor(advancedCompetitorMatch);

        System.out.println("CKP3333333");
        //                BracketUtil.makeSerializablePanel(dp);
        bracketCreator.disableMatch(dp);

        JsfUtils.addSuccessMessage(
            ResourceBundleUtil.getResourceBundleProperty("competitorAdvanced"),
            advancedCompetitorMatch.getIdCompetitor().getIdPersonalInfo().getFirstName()
                + " "
                + advancedCompetitorMatch.getIdCompetitor().getIdPersonalInfo().getLastName(),
            "manageCompetitionForm");
      } else if (BracketUtil.getMatchWinner(savedCompetitorMatch.getIdMatch())
          != null) { // finished final
        for (MatchMatchType mmt : savedCompetitorMatch.getIdMatch().getMatchMatchTypeList()) {
          if (mmt.getIdMatchType().getMatchTypeName().equals("final")) {
            bracketCreator.disableMatch(dp);

            JsfUtils.addSuccessMessage(
                ResourceBundleUtil.getResourceBundleProperty("competitorWonCompetition"),
                BracketUtil.getMatchWinner(savedCompetitorMatch.getIdMatch())
                        .getIdCompetitor()
                        .getIdPersonalInfo()
                        .getFirstName()
                    + " "
                    + BracketUtil.getMatchWinner(savedCompetitorMatch.getIdMatch())
                        .getIdCompetitor()
                        .getIdPersonalInfo()
                        .getLastName(),
                "manageCompetitionForm");

            break;
          }
        }
      }

      System.out.println("Przeszlo all, advanced id = " + advancedCompetitorMatch);
      RequestContext.getCurrentInstance().update(":manageCompetitionForm:dashboard");
      System.out.println("Po odswiezeniu");

      JsfUtils.addSuccessMessage(
          ResourceBundleUtil.getResourceBundleProperty("dataSaved"), "", "manageCompetitionForm");
      return;

    } catch (InvalidScoreException ise) {
      JsfUtils.addErrorMessage(ise, "manageCompetitionForm");
    } catch (MatchOptimisticLockException e) {
      System.out.println("MatchoptimiscitExcpetion#saveScoere " + e.getLocalizedMessage());
      JsfUtils.addErrorMessage(e, "manageCompetitionForm");
    } catch (ApplicationException ae) {
      JsfUtils.addErrorMessage(ae, "manageCompetitionForm");
      System.out.println("ManageCompetitonBackingBean#saceScore exception" + ae.getMessage());
      ae.printStackTrace();
    }

    cmg.setCompetitorMatchScore(competitorOldScore);
    bracketCreator.updateScores(cmg);
    //       init();
    //    refreshPage();
  }