ResultsRow<?> row = (ResultsRow<?>) i.next(); SavedBag savedBag = (SavedBag) row.get(0); String type = savedBag.getType(); String newType = renamedClasses.get(type); Profile profile = pm.getProfile(savedBag.getUserProfile().getUsername());
ResultsRow<?> row = (ResultsRow<?>) i.next(); SavedBag savedBag = (SavedBag) row.get(0); String type = savedBag.getType(); String newType = renamedClasses.get(type); Profile profile = pm.getProfile(savedBag.getUserProfile().getUsername());
/** * Delete all bags having as a type one of the classes deleted */ public void deleteBags() { Query q = new Query(); QueryClass qc = new QueryClass(SavedBag.class); q.addToSelect(qc); q.addFrom(qc); QueryField typeField = new QueryField(qc, "type"); BagConstraint constraint = new BagConstraint(typeField, ConstraintOp.IN, deletedClasses); q.setConstraint(constraint); Results bagsToDelete = uosw.execute(q, 1000, false, false, true); for (Iterator<?> i = bagsToDelete.iterator(); i.hasNext();) { ResultsRow<?> row = (ResultsRow<?>) i.next(); SavedBag savedBag = (SavedBag) row.get(0); Profile profile = pm.getProfile(savedBag.getUserProfile().getUsername()); try { profile.deleteBag(savedBag.getName()); System .out.println("Deleted the list: " + savedBag.getName() + " having type " + savedBag.getType()); } catch (ObjectStoreException ose) { System .out.println("Problems deleting bag: " + savedBag.getName()); } } }
LOG.warn("The bag '" + bagName + "' for user '" + userProfile.getUsername() + "'" + " with type: " + savedBag.getType() + " is not in the model. It will be saved into invalidBags" , e);
LOG.warn("The bag '" + bagName + "' for user '" + userProfile.getUsername() + "'" + " with type: " + savedBag.getType() + " is not in the model. It will be saved into invalidBags" , e);
/** * Delete all bags having as a type one of the classes deleted */ public void deleteBags() { Query q = new Query(); QueryClass qc = new QueryClass(SavedBag.class); q.addToSelect(qc); q.addFrom(qc); QueryField typeField = new QueryField(qc, "type"); BagConstraint constraint = new BagConstraint(typeField, ConstraintOp.IN, deletedClasses); q.setConstraint(constraint); Results bagsToDelete = uosw.execute(q, 1000, false, false, true); for (Iterator<?> i = bagsToDelete.iterator(); i.hasNext();) { ResultsRow<?> row = (ResultsRow<?>) i.next(); SavedBag savedBag = (SavedBag) row.get(0); Profile profile = pm.getProfile(savedBag.getUserProfile().getUsername()); try { profile.deleteBag(savedBag.getName()); System .out.println("Deleted the list: " + savedBag.getName() + " having type " + savedBag.getType()); } catch (ObjectStoreException ose) { System .out.println("Problems deleting bag: " + savedBag.getName()); } } }
/** * Constructor callable by the ProfileManager. * @param savedBag The saved bag retrieved from the DB. * @param profileId The id of the user profile. * @param os The production object store. * @param userprofileObjectStore The userprofile object store. * @throws ObjectStoreException If there is a problem creating an ObjectStoreBag. */ protected InvalidBag(SavedBag savedBag, Integer profileId, ObjectStore os, ObjectStoreWriter userprofileObjectStore) throws ObjectStoreException { this.type = TypeUtil.unqualifiedName(savedBag.getType()); this.name = savedBag.getName(); this.description = savedBag.getDescription(); this.dateCreated = savedBag.getDateCreated(); checkArguments(os, userprofileObjectStore); this.os = os; this.osb = os.createObjectStoreBag(); this.uosw = userprofileObjectStore; this.profileId = profileId; this.savedBagId = savedBag.getId(); }
/** * Constructor callable by the ProfileManager. * @param savedBag The saved bag retrieved from the DB. * @param profileId The id of the user profile. * @param os The production object store. * @param userprofileObjectStore The userprofile object store. * @throws ObjectStoreException If there is a problem creating an ObjectStoreBag. */ protected InvalidBag(SavedBag savedBag, Integer profileId, ObjectStore os, ObjectStoreWriter userprofileObjectStore) throws ObjectStoreException { this.type = TypeUtil.unqualifiedName(savedBag.getType()); this.name = savedBag.getName(); this.description = savedBag.getDescription(); this.dateCreated = savedBag.getDateCreated(); checkArguments(os, userprofileObjectStore); this.os = os; this.osb = os.createObjectStoreBag(); this.uosw = userprofileObjectStore; this.profileId = profileId; this.savedBagId = savedBag.getId(); }
/** * Loads an InterMineBag from the UserProfile database. * * @param os the production ObjectStore * @param savedBagId the ID of the bag in the userprofile database * @param uosw the ObjectStoreWriter of the userprofile database * @param classDescriptor if true the classDescriptor will be set * @throws UnknownBagTypeException if the type bag is unknown * @throws ObjectStoreException if something goes wrong */ public InterMineBag(ObjectStore os, Integer savedBagId, ObjectStoreWriter uosw, boolean classDescriptor) throws UnknownBagTypeException, ObjectStoreException { this.os = os; this.uosw = uosw; this.savedBagId = savedBagId; ObjectStore uos = uosw.getObjectStore(); SavedBag savedBag = (SavedBag) uos.getObjectById(savedBagId, SavedBag.class); checkAndSetName(savedBag.getName()); this.type = TypeUtil.unqualifiedName(savedBag.getType()); this.description = savedBag.getDescription(); this.dateCreated = savedBag.getDateCreated(); this.profileId = savedBag.proxGetUserProfile().getId(); setState(savedBag.getState()); this.osb = new ObjectStoreBag(savedBag.getOsbId()); if (classDescriptor) { setClassDescriptors(); } }
/** * Loads an InterMineBag from the UserProfile database. * * @param os the production ObjectStore * @param savedBagId the ID of the bag in the userprofile database * @param uosw the ObjectStoreWriter of the userprofile database * @param classDescriptor if true the classDescriptor will be set * @throws UnknownBagTypeException if the type bag is unknown * @throws ObjectStoreException if something goes wrong */ public InterMineBag(ObjectStore os, Integer savedBagId, ObjectStoreWriter uosw, boolean classDescriptor) throws UnknownBagTypeException, ObjectStoreException { this.os = os; this.uosw = uosw; this.savedBagId = savedBagId; ObjectStore uos = uosw.getObjectStore(); SavedBag savedBag = (SavedBag) uos.getObjectById(savedBagId, SavedBag.class); checkAndSetName(savedBag.getName()); this.type = TypeUtil.unqualifiedName(savedBag.getType()); this.description = savedBag.getDescription(); this.dateCreated = savedBag.getDateCreated(); this.profileId = savedBag.proxGetUserProfile().getId(); setState(savedBag.getState()); this.osb = new ObjectStoreBag(savedBag.getOsbId()); if (classDescriptor) { setClassDescriptors(); } }