/** * Perform a query to retrieve a bag's backing SavedBag * @param bagName the bagName * @param dateCreated the date when the bag has been created * @return the relevant SavedBag */ public SavedBag getSavedBag(String bagName, String dateCreated) { SavedBag bag = new SavedBag(); bag.setName(bagName); bag.setDateCreated(new Date(Long.parseLong(dateCreated))); Set<String> fieldNames = new HashSet<String>(); fieldNames.add("name"); fieldNames.add("dateCreated"); try { bag = uosw.getObjectByExample(bag, fieldNames); } catch (ObjectStoreException e) { throw new RuntimeException("Unable to load user profile", e); } return bag; }
/** * Perform a query to retrieve a bag's backing SavedBag * @param bagName the bagName * @param dateCreated the date when the bag has been created * @return the relevant SavedBag */ public SavedBag getSavedBag(String bagName, String dateCreated) { SavedBag bag = new SavedBag(); bag.setName(bagName); bag.setDateCreated(new Date(Long.parseLong(dateCreated))); Set<String> fieldNames = new HashSet<String>(); fieldNames.add("name"); fieldNames.add("dateCreated"); try { bag = uosw.getObjectByExample(bag, fieldNames); } catch (ObjectStoreException e) { throw new RuntimeException("Unable to load user profile", e); } return bag; }
/** * Perform the actual insertion of data into the userprofile database. * @return The object that represents the database record for this bag. * @throws ObjectStoreException If we cannot store the bag. */ protected SavedBag storeSavedBag() throws ObjectStoreException { SavedBag savedBag = new SavedBag(); savedBag.setId(getSavedBagId()); if (profileId != null) { savedBag.setName(getName()); savedBag.setType(getType()); savedBag.setDescription(getDescription()); savedBag.setDateCreated(getDateCreated()); savedBag.proxyUserProfile(new ProxyReference(null, profileId, UserProfile.class)); savedBag.setOsbId(getOsb().getBagId()); savedBag.setState(getState()); getUserProfileWriter().store(savedBag); } else if (savedBag.getId() == null) { // Even if the list is not saved because we're using an anonymous profile, still // give it an ID so that calling code can manipulate all lists by ID savedBag.setId(getUserProfileWriter().getSerial()); } return savedBag; }
/** * Perform the actual insertion of data into the userprofile database. * @return The object that represents the database record for this bag. * @throws ObjectStoreException If we cannot store the bag. */ protected SavedBag storeSavedBag() throws ObjectStoreException { SavedBag savedBag = new SavedBag(); savedBag.setId(getSavedBagId()); if (profileId != null) { savedBag.setName(getName()); savedBag.setType(getType()); savedBag.setDescription(getDescription()); savedBag.setDateCreated(getDateCreated()); savedBag.proxyUserProfile(new ProxyReference(null, profileId, UserProfile.class)); savedBag.setOsbId(getOsb().getBagId()); savedBag.setState(getState()); getUserProfileWriter().store(savedBag); } else if (savedBag.getId() == null) { // Even if the list is not saved because we're using an anonymous profile, still // give it an ID so that calling code can manipulate all lists by ID savedBag.setId(getUserProfileWriter().getSerial()); } return savedBag; }