use of ubic.gemma.model.genome.gene.DatabaseBackedGeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetController method removeUserAndSessionGroups.
/**
* AJAX Given valid gene groups will remove them from the session or the database appropriately.
*
* @param vos vos
* @return gene set vos
*/
public Collection<GeneSetValueObject> removeUserAndSessionGroups(Collection<GeneSetValueObject> vos) {
Collection<GeneSetValueObject> removedSets = new HashSet<>();
Collection<DatabaseBackedGeneSetValueObject> databaseCollection = new HashSet<>();
Collection<SessionBoundGeneSetValueObject> sessionCollection = new HashSet<>();
for (GeneSetValueObject geneSetValueObject : vos) {
if (geneSetValueObject instanceof SessionBoundGeneSetValueObject) {
sessionCollection.add((SessionBoundGeneSetValueObject) geneSetValueObject);
} else if (geneSetValueObject instanceof DatabaseBackedGeneSetValueObject) {
databaseCollection.add((DatabaseBackedGeneSetValueObject) geneSetValueObject);
}
}
sessionCollection = this.removeSessionGroups(sessionCollection);
databaseCollection = this.remove(databaseCollection);
removedSets.addAll(sessionCollection);
removedSets.addAll(databaseCollection);
return removedSets;
}
use of ubic.gemma.model.genome.gene.DatabaseBackedGeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetController method updateUserAndSessionGroups.
/**
* AJAX Updates the session group and user database groups.
*
* @param vos vos
* @return gene set vos
*/
public Collection<GeneSetValueObject> updateUserAndSessionGroups(Collection<GeneSetValueObject> vos) {
Collection<GeneSetValueObject> updatedSets = new HashSet<>();
Collection<DatabaseBackedGeneSetValueObject> databaseCollection = new HashSet<>();
Collection<SessionBoundGeneSetValueObject> sessionCollection = new HashSet<>();
for (GeneSetValueObject geneSetValueObject : vos) {
if (geneSetValueObject instanceof SessionBoundGeneSetValueObject) {
sessionCollection.add((SessionBoundGeneSetValueObject) geneSetValueObject);
} else if (geneSetValueObject instanceof DatabaseBackedGeneSetValueObject) {
databaseCollection.add((DatabaseBackedGeneSetValueObject) geneSetValueObject);
}
}
sessionCollection = this.updateSessionGroups(sessionCollection);
databaseCollection = this.update(databaseCollection);
updatedSets.addAll(sessionCollection);
updatedSets.addAll(databaseCollection);
return updatedSets;
}
use of ubic.gemma.model.genome.gene.DatabaseBackedGeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetDaoImpl method loadValueObjects.
@Override
public Collection<DatabaseBackedGeneSetValueObject> loadValueObjects(Collection<Long> ids) {
Collection<DatabaseBackedGeneSetValueObject> result = this.loadValueObjectsLite(ids);
for (GeneSetValueObject res : result) {
res.setGeneIds(new HashSet<Long>());
// noinspection unchecked
res.getGeneIds().addAll(this.getSessionFactory().getCurrentSession().createQuery("select genes.id from GeneSet g join g.members m join m.gene genes where g.id = :id").setParameter("id", res.getId()).list());
}
return result;
}
use of ubic.gemma.model.genome.gene.DatabaseBackedGeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetDaoImpl method loadValueObjectsLite.
@Override
public Collection<DatabaseBackedGeneSetValueObject> loadValueObjectsLite(Collection<Long> ids) {
Collection<DatabaseBackedGeneSetValueObject> result = new HashSet<>();
if (ids.isEmpty())
return result;
// Left join: includes one that have no members. Caller has to filter them out if they need to.
// noinspection unchecked
List<Object[]> list = this.getSessionFactory().getCurrentSession().createQuery("select g.id, g.description, count(m), g.name from GeneSet g" + " left join g.members m where g.id in (:ids) group by g.id").setParameterList("ids", ids).list();
Map<Long, Taxon> taxa = this.getTaxa(ids);
for (Object[] oa : list) {
DatabaseBackedGeneSetValueObject dvo = new DatabaseBackedGeneSetValueObject();
dvo.setDescription((String) oa[1]);
dvo.setId((Long) oa[0]);
dvo.setSize(((Long) oa[2]).intValue());
dvo.setName((String) oa[3]);
Taxon t = taxa.get(dvo.getId());
dvo.setTaxonId(t.getId());
dvo.setTaxonName(t.getCommonName());
result.add(dvo);
}
return result;
}
use of ubic.gemma.model.genome.gene.DatabaseBackedGeneSetValueObject in project Gemma by PavlidisLab.
the class GeneSetValueObjectHelperImpl method convertToValueObject.
@Override
public DatabaseBackedGeneSetValueObject convertToValueObject(GeneSet gs) {
if (gs == null)
return null;
DatabaseBackedGeneSetValueObject dbgsvo = convertToLightValueObject(gs);
Collection<Long> ids = EntityUtils.getIds(this.geneSetService.getGenesInGroup(new GeneSetValueObject(gs.getId())));
dbgsvo.getGeneIds().addAll(ids);
dbgsvo.setSize(ids.size());
return dbgsvo;
}
Aggregations