Beispiel #1
0
 public WOActionResults delete() {
   EOEditingContext ec = (EOEditingContext) valueForBinding("ec");
   ec.lock();
   try {
     NSArray usage =
         EOUtilities.objectsMatchingKeyAndValue(ec, "ItogTypeList", "itogType", currType);
     if (usage != null && usage.count() > 0) {
       Enumeration enu = usage.objectEnumerator();
       while (enu.hasMoreElements()) {
         EOEnterpriseObject itl = (EOEnterpriseObject) enu.nextElement();
         ec.deleteObject(itl);
       }
     }
     ec.deleteObject(currType);
     ec.saveChanges();
     currType = null;
     setValueForBinding(currType, "currType");
   } catch (Exception e) {
     SetupItogs.logger.log(WOLogLevel.WARNING, "Error saving changes in list ", e);
     session().takeValueForKey(e.getMessage(), "message");
     ec.revert();
   } finally {
     ec.unlock();
   }
   return (WOActionResults) valueForBinding("actionResult");
 }
Beispiel #2
0
 public WOActionResults saveType() {
   EOEditingContext ec = (EOEditingContext) valueForBinding("ec");
   ec.lock();
   try {
     boolean newType = (currType == null);
     if (newType) {
       currType = (ItogType) EOUtilities.createAndInsertInstance(ec, ItogType.ENTITY_NAME);
       Number maxSort = (Number) valueForBinding("maxSort");
       if (maxSort != null) {
         currType.setSort(new Integer(maxSort.intValue() + 1));
       } else {
         currType.setSort(new Integer(1));
       }
     }
     currType.setName(itogName);
     currType.setTitle(itogTitle);
     currType.setInYearCount((itogCount == null) ? new Integer(0) : itogCount);
     ec.saveChanges();
     //			if(newType) {
     //				allTypes = allTypes.arrayByAddingObject(currType);
     //				itogsList = NSArray.EmptyArray;
     //			}
     setValueForBinding(currType, "currType");
   } catch (Exception e) {
     SetupItogs.logger.log(WOLogLevel.WARNING, "Error saving changes in list ", e);
     session().takeValueForKey(e.getMessage(), "message");
     ec.revert();
   } finally {
     ec.unlock();
   }
   return (WOActionResults) valueForBinding("actionResult");
 }
 public WOComponent selectStudent() {
   EOEditingContext context = session().defaultEditingContext();
   context.revert();
   student = selectedStudent;
   homeAddress = (HomeAddress) student.address();
   return null;
 }
 /** Go back to administration page */
 public AdministrationPage administrationPage() {
   AdministrationPage nextPage = (AdministrationPage) pageWithName("AdministrationPage");
   EOEditingContext context = session().defaultEditingContext();
   // throw away any unsaved changes
   context.revert();
   return nextPage;
 }
Beispiel #5
0
 public void cancel() {
   ec.revert();
   // NSDictionary snapshot = ec.committedSnapshotForObject(onEdit);
   if (ec.insertedObjects().contains(item)) {
     NSMutableArray fullList = (NSMutableArray) session().valueForKey("personList");
     fullList.removeObject(item);
   }
   //		onEdit = null;
 }
  public WOComponent afficherLeDossier() {

    if (unPreEtudiant() != null) {
      EOEditingContext edc = component.session().defaultEditingContext();

      EORne rne = unPreEtudiant().rne();
      if (rne == null) {
        component
            .session()
            .addSimpleErrorMessage(
                "Erreur", "Impossible de déterminer l'établissement du pré-étudiant !");
        return null;
      }

      IEtudiant etudiant = null;
      try {
        edc.revert();
        edc.invalidateAllObjects();
        EOPreEtudiant preEtudiant =
            EOPreEtudiant.fetchByKeyValue(
                edc, EOPreEtudiant.ETUD_NUMERO_KEY, unPreEtudiant().etudNumero());
        Method m =
            component
                .session()
                .finder(rne.cRne())
                .getDeclaredMethod(
                    "getEtudiantPreEtudiant",
                    new Class[] {
                      EOEditingContext.class,
                      EOPreEtudiant.class,
                      String.class,
                      component.session().interfaceEtudiant(rne.cRne())
                    });
        etudiant = (IEtudiant) m.invoke(null, new Object[] {edc, preEtudiant, rne.cRne(), null});
      } catch (SecurityException e1) {
        e1.printStackTrace();
      } catch (NoSuchMethodException e2) {
        e2.printStackTrace();
      } catch (IllegalArgumentException e3) {
        e3.printStackTrace();
      } catch (IllegalAccessException e4) {
        e4.printStackTrace();
      } catch (EtudiantException e6) {
        e6.printStackTrace();
      } catch (InvocationTargetException e5) {
        if (e5.getCause().getClass().equals(EtudiantException.class)) {
          EtudiantException exception = (EtudiantException) e5.getCause();
          component.session().addSimpleErrorMessage("Erreur", exception.getMessage());
          return null;
        }
      }

      if (etudiant != null) {
        EOHistorique historique = etudiant.historiquePlusRecent(new Integer(3000));
        etudiant.setAnneeInscriptionEnCours(historique.histAnneeScol());
        etudiant.setEtudType(EOEtudiant.ETUD_TYPE_INSCRIPTION);
        etudiant.setRne(rne);

        setLeEtudiant(etudiant);
        setLeDossier(historique);

        NSArray<EtudiantException> userInfos = etudiant.userInfos();
        if (userInfos != null && userInfos.count() > 0) {
          String messages = "";
          Enumeration<EtudiantException> enumUserInfos = userInfos.objectEnumerator();
          while (enumUserInfos.hasMoreElements()) {
            EtudiantException exception = enumUserInfos.nextElement();
            messages += exception.getMessageJS() + "\\n";
          }
          component.session().addSimpleErrorMessage("Erreur", messages);
        }
      }
    }

    return null;
  }
 /** Go back to main page */
 public Main mainPage() {
   Main nextPage = (Main) pageWithName("Main");
   EOEditingContext context = session().defaultEditingContext();
   context.revert();
   return nextPage;
 }