public Object loadPojo(final TypedOid oid) { // REVIEW: does it make sense to get these directly? not sure, so for now have decided to fail // fast. if (oid instanceof AggregatedOid) { throw new UnsupportedOperationException( "Cannot retrieve aggregated objects directly, oid: " + oid.enString(getOidMarshaller())); } final RootOid rootOid = (RootOid) oid; Object result = null; try { final Class<?> cls = clsOf(rootOid); final Object jdoObjectId = JdoObjectIdSerializer.toJdoObjectId(rootOid); final PersistenceManager pm = getPersistenceManager(); FetchPlan fetchPlan = pm.getFetchPlan(); fetchPlan.addGroup(FetchGroup.DEFAULT); result = pm.getObjectById(cls, jdoObjectId); } catch (final RuntimeException e) { throw e; } if (result == null) { throw new ObjectNotFoundException(oid); } return result; }
public List<EventCalendar> getItems(String id, String zoneName) throws Exception { PersistenceManager pm = PMF.get().getPersistenceManager(); FetchPlan fp = pm.getFetchPlan().addGroup("userGroup"); fp.setMaxFetchDepth(1); User user = pm.detachCopy(pm.getObjectById(User.class, id)); pm.close(); EventCalendarDaoImpl eventDao = new EventCalendarDaoImpl(); List<EventCalendar> result = eventDao.getCalendarsById(user.getCalendarKeys(), 0); // addGeoLocatedCals(result, geoLoc, zoneName); return result; }
private List<EventCalendar> getFollowingCals(String userId) throws Exception { PersistenceManager pm = PMF.get().getPersistenceManager(); FetchPlan fp = pm.getFetchPlan().addGroup("userGroup"); fp.setMaxFetchDepth(2); User user = pm.detachCopy(pm.getObjectById(User.class, userId)); pm.close(); log.info("Loading feed"); EventCalendarDaoImpl eventDao = new EventCalendarDaoImpl(); List<EventCalendar> cals = eventDao.getCalendarsById(user.getCalendarKeys(), 1); log.info("Loading feed: following cals count: " + cals.size()); for (EventCalendar cal : cals) cal.setSource("following"); return cals; }