public void updateOwnedItem(String id, EventCalendar cal) {
   PersistenceManager pm = PMF.get().getPersistenceManager();
   User user = pm.getObjectById(User.class, id);
   Set<EventCalendar> items = user.getOwnedCalendars();
   for (EventCalendar item : items) {
     if (item.getId().equals(cal.getId())) {
       try {
         item.merge(cal);
         item.setDateLastUpdated(new Date());
         pm.makePersistent(item);
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
   pm.close();
 }
 public void removeOwnedItem(String id, String itemId) {
   PersistenceManager pm = PMF.get().getPersistenceManager();
   User user = pm.getObjectById(User.class, id);
   EventCalendar cal = null;
   Set<EventCalendar> items = user.getOwnedCalendars();
   for (EventCalendar item : items) {
     if (item.getId().equals(itemId)) {
       cal = item;
       pm.deletePersistent(cal);
     }
   }
   user.removeOwnedCalendar(cal);
   pm.makePersistent(user);
   pm.close();
 }