Search in sources :

Example 1 with EntityDelegator

use of ubic.gemma.web.remote.EntityDelegator in project Gemma by PavlidisLab.

the class ExperimentalDesignControllerTest method testGetExperimentalFactors.

@Test
public void testGetExperimentalFactors() throws Exception {
    // readonly.
    ExpressionExperiment ee = this.getTestPersistentCompleteExpressionExperiment(true);
    Collection<ExperimentalFactorValueObject> experimentalFactors = experimentalDesignController.getExperimentalFactors(new EntityDelegator(ee.getExperimentalDesign()));
    assertTrue(!experimentalFactors.isEmpty());
}
Also used : EntityDelegator(ubic.gemma.web.remote.EntityDelegator) Test(org.junit.Test) BaseSpringWebTest(ubic.gemma.web.util.BaseSpringWebTest)

Example 2 with EntityDelegator

use of ubic.gemma.web.remote.EntityDelegator in project Gemma by PavlidisLab.

the class ExperimentalDesignControllerTest method testGetExperimentalFactorValues.

@Test
public void testGetExperimentalFactorValues() throws Exception {
    ExpressionExperiment ee = this.getTestPersistentCompleteExpressionExperiment(false);
    ee = this.eeService.thawLite(ee);
    Collection<FactorValueValueObject> fvs = experimentalDesignController.getFactorValuesWithCharacteristics(new EntityDelegator(ee.getExperimentalDesign().getExperimentalFactors().iterator().next()));
    assertTrue(!fvs.isEmpty());
}
Also used : EntityDelegator(ubic.gemma.web.remote.EntityDelegator) Test(org.junit.Test) BaseSpringWebTest(ubic.gemma.web.util.BaseSpringWebTest)

Example 3 with EntityDelegator

use of ubic.gemma.web.remote.EntityDelegator in project Gemma by PavlidisLab.

the class SecurityControllerTest method setup.

@Before
public void setup() {
    this.ee = super.getTestPersistentBasicExpressionExperiment();
    securityService.makePublic(ee);
    this.eeId = ee.getId();
    this.userName = this.randomName();
    this.makeUser(userName);
    ed = new EntityDelegator();
    ed.setClassDelegatingFor(ee.getClass().getName());
    ed.setId(this.eeId);
    securityService.makeOwnedByUser(ee, userName);
}
Also used : EntityDelegator(ubic.gemma.web.remote.EntityDelegator) Before(org.junit.Before)

Example 4 with EntityDelegator

use of ubic.gemma.web.remote.EntityDelegator in project Gemma by PavlidisLab.

the class PhenotypeController method makeDifferentialExpressionEvidencesFromDiffExpressionMetaAnalysis.

public ValidateEvidenceValueObject makeDifferentialExpressionEvidencesFromDiffExpressionMetaAnalysis(Long geneDifferentialExpressionMetaAnalysisId, SortedSet<CharacteristicValueObject> phenotypes, Double selectionThreshold) {
    ValidateEvidenceValueObject validateEvidenceValueObject;
    try {
        validateEvidenceValueObject = this.phenotypeAssociationManagerService.makeDifferentialExpressionEvidencesFromDiffExpressionMetaAnalysis(geneDifferentialExpressionMetaAnalysisId, phenotypes, selectionThreshold);
        // get the permission of the metaAnalysis
        EntityDelegator ed = new EntityDelegator();
        ed.setId(geneDifferentialExpressionMetaAnalysisId);
        ed.setClassDelegatingFor(GeneDifferentialExpressionMetaAnalysis.class.getName());
        // update the permission of the meta analysis,(this will update all evidence linked to it)
        this.securityController.updatePermission(this.securityController.getSecurityInfo(ed));
    } catch (Throwable throwable) {
        validateEvidenceValueObject = this.generateValidateEvidenceValueObject(throwable);
    }
    return validateEvidenceValueObject;
}
Also used : GeneDifferentialExpressionMetaAnalysis(ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysis) EntityDelegator(ubic.gemma.web.remote.EntityDelegator)

Example 5 with EntityDelegator

use of ubic.gemma.web.remote.EntityDelegator in project Gemma by PavlidisLab.

the class SecurityControllerImpl method updatePermission.

@Override
public SecurityInfoValueObject updatePermission(SecurityInfoValueObject settings) {
    EntityDelegator sd = new EntityDelegator();
    sd.setId(settings.getEntityId());
    sd.setClassDelegatingFor(settings.getEntityClazz());
    Securable s = this.getSecurable(sd);
    if (settings.isPubliclyReadable()) {
        securityService.makePublic(s);
    } else {
        securityService.makePrivate(s);
    }
    try {
        if (settings.getOwner().isPrincipal()) {
            securityService.makeOwnedByUser(s, settings.getOwner().getAuthority());
        } else {
            // this warning is not even worth issuing if we are not an administrator.
            if (SecurityUtil.isUserAdmin())
                SecurityControllerImpl.log.warn("Can't make groupauthority " + settings.getOwner().getAuthority() + " owner, not implemented");
        }
    } catch (AccessDeniedException e) {
        SecurityControllerImpl.log.warn("Non-administrators cannot change the owner of an entity");
    // okay, only works if you are administrator.
    }
    /*
         * This works in one of two ways. If settings.currentGroup is non-null, we just update the permissions for that
         * group - this may leave them unchanged. Otherwise, we update them all based on
         * groupsThatCanRead/groupsThatCanWrite
         */
    String currentGroupName = settings.getCurrentGroup();
    if (StringUtils.isNotBlank(currentGroupName) && !(currentGroupName.equals(AuthorityConstants.ADMIN_GROUP_NAME) || currentGroupName.equals(AuthorityConstants.AGENT_GROUP_NAME))) {
        // this test only makes sense for changing the group's name, not for changing the permissions
        // of potentially shared entities
        // if ( !getGroupsUserCanEdit().contains( currentGroupName ) ) {
        // throw new AccessDeniedException( "Access denied to permissions for group=" + currentGroupName );
        // }
        Boolean readable = settings.isCurrentGroupCanRead();
        Boolean writeable = settings.isCurrentGroupCanWrite();
        if (readable) {
            securityService.makeReadableByGroup(s, currentGroupName);
        } else {
            securityService.makeUnreadableByGroup(s, currentGroupName);
        }
        if (writeable) {
            // if writable should be readable
            securityService.makeReadableByGroup(s, currentGroupName);
            securityService.makeWriteableByGroup(s, currentGroupName);
        } else {
            securityService.makeUnwriteableByGroup(s, currentGroupName);
        }
    } else {
        /*
             * Remove all group permissions - we'll set them back to what was requested. Exception: we don't allow
             * changes to admin or agent permissions by this route.
             */
        for (String groupName : this.getGroupsUserCanEdit()) {
            if (groupName.equals(AuthorityConstants.ADMIN_GROUP_NAME) || groupName.equals(AuthorityConstants.AGENT_GROUP_NAME)) {
                // never changes this.
                continue;
            }
            securityService.makeUnreadableByGroup(s, groupName);
            securityService.makeUnwriteableByGroup(s, groupName);
        }
        /*
             * Add selected ones back
             */
        for (String reader : settings.getGroupsThatCanRead()) {
            if (reader.equals(AuthorityConstants.ADMIN_GROUP_NAME) || reader.equals(AuthorityConstants.AGENT_GROUP_NAME)) {
                // never changes this.
                continue;
            }
            securityService.makeReadableByGroup(s, reader);
        }
        for (String writer : settings.getGroupsThatCanWrite()) {
            if (writer.equals(AuthorityConstants.ADMIN_GROUP_NAME) || writer.equals(AuthorityConstants.AGENT_GROUP_NAME)) {
                // never changes this.
                continue;
            }
            // when it is writable it should be readable
            securityService.makeReadableByGroup(s, writer);
            securityService.makeWriteableByGroup(s, writer);
        }
    }
    // special case for Phenocarta, changing the meta analysis, changes the permissions of all evidence linked
    if (s instanceof GeneDifferentialExpressionMetaAnalysis) {
        Collection<DifferentialExpressionEvidence> differentialExpressionEvidence = this.phenotypeAssociationService.loadEvidenceWithGeneDifferentialExpressionMetaAnalysis(s.getId(), -1);
        for (DifferentialExpressionEvidence d : differentialExpressionEvidence) {
            settings.setEntityId(d.getId());
            settings.setEntityClazz(d.getClass().getName());
            this.updatePermission(settings);
        }
    }
    SecurityControllerImpl.log.info("Updated permissions on " + s);
    return this.securable2VO(s);
}
Also used : DifferentialExpressionEvidence(ubic.gemma.model.association.phenotype.DifferentialExpressionEvidence) Securable(gemma.gsec.model.Securable) AccessDeniedException(org.springframework.security.access.AccessDeniedException) GeneDifferentialExpressionMetaAnalysis(ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysis) EntityDelegator(ubic.gemma.web.remote.EntityDelegator)

Aggregations

EntityDelegator (ubic.gemma.web.remote.EntityDelegator)7 Test (org.junit.Test)4 BaseSpringWebTest (ubic.gemma.web.util.BaseSpringWebTest)4 GeneDifferentialExpressionMetaAnalysis (ubic.gemma.model.analysis.expression.diff.GeneDifferentialExpressionMetaAnalysis)2 Securable (gemma.gsec.model.Securable)1 Before (org.junit.Before)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1 DifferentialExpressionEvidence (ubic.gemma.model.association.phenotype.DifferentialExpressionEvidence)1 VocabCharacteristic (ubic.gemma.model.common.description.VocabCharacteristic)1