Search in sources :

Example 11 with ExpressionExperimentSetValueObject

use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.

the class ExpressionExperimentSetController method create.

public Collection<ExpressionExperimentSetValueObject> create(Collection<ExpressionExperimentSetValueObject> entities) {
    Collection<Long> eeSetIds = new HashSet<>();
    for (ExpressionExperimentSetValueObject ees : entities) {
        if (ees.getExpressionExperimentIds() == null || ees.getExpressionExperimentIds().isEmpty()) {
            throw new IllegalArgumentException("No expression experiment ids provided. Cannot save an empty set.");
        }
        ExpressionExperimentSet newEESet = this.create(ees);
        eeSetIds.add(newEESet.getId());
    }
    return this.expressionExperimentSetService.loadValueObjectsByIds(eeSetIds);
}
Also used : SessionBoundExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.SessionBoundExpressionExperimentSetValueObject) ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) ExpressionExperimentSet(ubic.gemma.model.analysis.expression.ExpressionExperimentSet) HashSet(java.util.HashSet)

Example 12 with ExpressionExperimentSetValueObject

use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.

the class ExpressionExperimentSetController method removeUserAndSessionGroups.

/**
 * AJAX Given valid experiment groups will remove them from the session or the database appropriately.
 */
public Collection<ExpressionExperimentSetValueObject> removeUserAndSessionGroups(Collection<ExpressionExperimentSetValueObject> vos) {
    Collection<ExpressionExperimentSetValueObject> removedSets = new HashSet<>();
    Collection<ExpressionExperimentSetValueObject> databaseCollection = new HashSet<>();
    Collection<SessionBoundExpressionExperimentSetValueObject> sessionCollection = new HashSet<>();
    for (ExpressionExperimentSetValueObject experimentSetValueObject : vos) {
        if (experimentSetValueObject instanceof SessionBoundExpressionExperimentSetValueObject) {
            sessionCollection.add((SessionBoundExpressionExperimentSetValueObject) experimentSetValueObject);
        } else {
            databaseCollection.add(experimentSetValueObject);
        }
    }
    sessionCollection = this.removeSessionGroups(sessionCollection);
    databaseCollection = this.remove(databaseCollection);
    removedSets.addAll(sessionCollection);
    removedSets.addAll(databaseCollection);
    return removedSets;
}
Also used : SessionBoundExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.SessionBoundExpressionExperimentSetValueObject) ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) SessionBoundExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.SessionBoundExpressionExperimentSetValueObject) HashSet(java.util.HashSet)

Example 13 with ExpressionExperimentSetValueObject

use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.

the class ExpressionExperimentSetController method canCurrentUserEditGroup.

/**
 * AJAX returns a JSON string encoding whether the current user owns the group and whether the group is db-backed
 */
public String canCurrentUserEditGroup(ExpressionExperimentSetValueObject eesvo) {
    boolean userCanEditGroup = false;
    boolean groupIsDBBacked = false;
    if (!(eesvo instanceof SessionBoundExpressionExperimentSetValueObject)) {
        groupIsDBBacked = true;
        try {
            ExpressionExperimentSetValueObject set = expressionExperimentSetService.loadValueObject(expressionExperimentSetService.load(eesvo.getId()));
            userCanEditGroup = (set.getUserCanWrite() && set.isModifiable());
        } catch (org.springframework.security.access.AccessDeniedException ade) {
            return "{groupIsDBBacked:" + true + ",userCanEditGroup:" + false + "}";
        }
    }
    return "{groupIsDBBacked:" + groupIsDBBacked + ",userCanEditGroup:" + userCanEditGroup + "}";
}
Also used : SessionBoundExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.SessionBoundExpressionExperimentSetValueObject) ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) SessionBoundExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.SessionBoundExpressionExperimentSetValueObject) AccessDeniedException(org.springframework.security.access.AccessDeniedException)

Example 14 with ExpressionExperimentSetValueObject

use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.

the class ExpressionExperimentSetController method addUserAndSessionGroups.

/**
 * AJAX adds the experiment group to the session
 *
 * @return the new gene groups
 */
public Collection<ExpressionExperimentSetValueObject> addUserAndSessionGroups(Collection<ExpressionExperimentSetValueObject> sets) {
    Collection<ExpressionExperimentSetValueObject> result = new HashSet<>();
    Collection<SessionBoundExpressionExperimentSetValueObject> sessionResult = new HashSet<>();
    for (ExpressionExperimentSetValueObject eesvo : sets) {
        if (eesvo instanceof SessionBoundExpressionExperimentSetValueObject) {
            sessionResult.add((SessionBoundExpressionExperimentSetValueObject) eesvo);
        } else {
            result.add(eesvo);
        }
    }
    result = this.create(result);
    result.addAll(this.addSessionGroups(sessionResult, true));
    return result;
}
Also used : SessionBoundExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.SessionBoundExpressionExperimentSetValueObject) ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) SessionBoundExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.SessionBoundExpressionExperimentSetValueObject) HashSet(java.util.HashSet)

Example 15 with ExpressionExperimentSetValueObject

use of ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject in project Gemma by PavlidisLab.

the class ExpressionExperimentSetIDsEndpoint method invokeInternal.

/**
 * Reads the given <code>requestElement</code>, and sends a the response back.
 *
 * @param requestElement the contents of the SOAP message as DOM elements
 * @param document a DOM document to be used for constructing <code>Node</code>s
 * @return the response element
 */
@Override
protected Element invokeInternal(Element requestElement, Document document) {
    authenticate();
    StopWatch watch = new StopWatch();
    watch.start();
    setLocalName(LOCAL_NAME);
    Collection<ExpressionExperimentSetValueObject> eesCol = expressionExperimentSetService.loadAllExperimentSetValueObjects(false);
    // retain expression experiment sets that have a name assigned (probably not necessary?)
    Collection<ExpressionExperimentSetValueObject> eesColToUse = new HashSet<ExpressionExperimentSetValueObject>();
    for (ExpressionExperimentSetValueObject ees : eesCol) {
        if (ees.getName() != null)
            eesColToUse.add(ees);
    }
    // start building the wrapper
    // build xml manually for mapped result rather than use buildWrapper inherited from AbstractGemmeEndpoint
    Element responseWrapper = document.createElementNS(NAMESPACE_URI, LOCAL_NAME);
    Element responseElement = document.createElementNS(NAMESPACE_URI, LOCAL_NAME + RESPONSE);
    responseWrapper.appendChild(responseElement);
    for (ExpressionExperimentSetValueObject ees : eesColToUse) {
        Element e1 = document.createElement("expression_experiment_set_id");
        e1.appendChild(document.createTextNode(ees.getId().toString()));
        responseElement.appendChild(e1);
        Element e2 = document.createElement("ees_name");
        e2.appendChild(document.createTextNode(ees.getName()));
        responseElement.appendChild(e2);
        Collection<Long> eeIds = ees.getExpressionExperimentIds();
        Element e3 = document.createElement("datasets");
        e3.appendChild(document.createTextNode(encode(eeIds.toArray())));
        responseElement.appendChild(e3);
        Element e4 = document.createElement("taxon");
        assert ees.getTaxonId() != null;
        e4.appendChild(document.createTextNode(ees.getTaxonId().toString()));
        responseElement.appendChild(e4);
    }
    watch.stop();
    Long time = watch.getTime();
    // log.info( "Finished generating result. Sending response to client." );
    if (time > 1000) {
        log.info("XML response for Experiment Set IDs results built in " + time + "ms.");
    }
    return responseWrapper;
}
Also used : ExpressionExperimentSetValueObject(ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject) Element(org.w3c.dom.Element) StopWatch(org.apache.commons.lang3.time.StopWatch) HashSet(java.util.HashSet)

Aggregations

ExpressionExperimentSetValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentSetValueObject)15 SessionBoundExpressionExperimentSetValueObject (ubic.gemma.model.expression.experiment.SessionBoundExpressionExperimentSetValueObject)8 HashSet (java.util.HashSet)5 ExpressionExperimentValueObject (ubic.gemma.model.expression.experiment.ExpressionExperimentValueObject)4 StopWatch (org.apache.commons.lang3.time.StopWatch)3 SearchResultDisplayObject (ubic.gemma.core.search.SearchResultDisplayObject)3 ExpressionExperimentSet (ubic.gemma.model.analysis.expression.ExpressionExperimentSet)3 AccessDeniedException (org.springframework.security.access.AccessDeniedException)2 Taxon (ubic.gemma.model.genome.Taxon)2 ArrayList (java.util.ArrayList)1 Query (org.hibernate.Query)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 Element (org.w3c.dom.Element)1 SessionBoundGeneSetValueObject (ubic.gemma.core.genome.gene.SessionBoundGeneSetValueObject)1 FreeTextExpressionExperimentResultsValueObject (ubic.gemma.model.expression.experiment.FreeTextExpressionExperimentResultsValueObject)1 Gene (ubic.gemma.model.genome.Gene)1 GeneSetValueObject (ubic.gemma.model.genome.gene.GeneSetValueObject)1 GeneValueObject (ubic.gemma.model.genome.gene.GeneValueObject)1