Example #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");
 }
Example #2
0
 public void appendToResponse(WOResponse aResponse, WOContext aContext) {
   ItogType type = (ItogType) valueForBinding("currType");
   currType = type;
   NamedFlags access = (NamedFlags) valueForBinding("access");
   if (access == null)
     access = (NamedFlags) session().valueForKeyPath("readAccess.FLAGS.ItogType");
   if (type == null) {
     itogName = null;
     itogTitle = null;
     itogCount = null;
     canDelete = false;
     cantEdit = (Boolean) access.valueForKey("_create");
     // session().valueForKeyPath("readAccess._create.ItogType");
   } else {
     itogName = currType.name();
     itogTitle = currType.title();
     itogCount = currType.inYearCount();
     if (itogCount.intValue() == 0) itogCount = null;
     EOEditingContext ec = (EOEditingContext) valueForBinding("ec");
     NSArray itogs =
         EOUtilities.objectsMatchingKeyAndValue(
             ec, ItogContainer.ENTITY_NAME, ItogContainer.ITOG_TYPE_KEY, type);
     canDelete = (itogs == null || itogs.count() == 0);
     cantEdit = (Boolean) access.valueForKey("_edit");
     // session().valueForKeyPath("readAccess._edit.currType");
   }
   super.appendToResponse(aResponse, aContext);
 }
Example #3
0
 @Override
 protected void handleUnsuccessfullQueryForKey(Object key) {
   EOEditingContext ec = ERXEC.newEditingContext();
   EOGlobalID gid = NO_GID_MARKER;
   ec.lock();
   try {
     EOEnterpriseObject eo =
         (EOEnterpriseObject)
             EOUtilities.objectsMatchingKeyAndValue(ec, ENTITY, Key.KEY, key).lastObject();
     if (eo != null) {
       gid = ec.globalIDForObject(eo);
     }
   } finally {
     ec.unlock();
   }
   cache().setObjectForKey(createRecord(gid, null), key);
 }