Search in sources :

Example 21 with UserImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.

the class DefaultAuthorizationManager method getCurrentUser.

@Override
public User getCurrentUser() throws IOException {
    Authentication auth = securityContextHolderStrategy.getContext().getAuthentication();
    if (auth == null) {
        return null;
    }
    User user = userService.getByLoginName(auth.getName());
    if (user == null && auth.isAuthenticated()) {
        user = new UserImpl();
        user.setAdmin(true);
        user.setActive(true);
    }
    return user;
}
Also used : User(com.eaglegenomics.simlims.core.User) Authentication(org.springframework.security.core.Authentication) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl)

Example 22 with UserImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.

the class HibernateSampleDaoIT method testCreate.

@Test
public void testCreate() throws Exception {
    Sample sample = new SampleImpl();
    String sampleName = "latestSample32";
    sample.setName(sampleName);
    sample.setAlias("alias32LK");
    sample.setProject(dao.get(1L).getProject());
    sample.setSampleType("GENOMIC");
    ScientificName scientificName = (ScientificName) currentSession().get(ScientificName.class, 1L);
    sample.setScientificName(scientificName);
    User user = new UserImpl();
    user.setId(1L);
    Date now = new Date();
    sample.setCreator(user);
    sample.setCreationTime(now);
    sample.setLastModifier(user);
    sample.setLastModified(now);
    int sizeBefore = dao.list().size();
    long id = dao.create(sample);
    clearSession();
    Sample retrieved = dao.get(id);
    assertEquals("did not insert sample", sizeBefore + 1, dao.list().size());
    assertEquals("sample name does not match", sampleName, retrieved.getName());
}
Also used : User(com.eaglegenomics.simlims.core.User) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl) ScientificName(uk.ac.bbsrc.tgac.miso.core.data.ScientificName) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Example 23 with UserImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.

the class HibernateSampleNumberPerProjectDaoIT method testNextNumberPaddingDecreasesTest.

@Test
public void testNextNumberPaddingDecreasesTest() throws Exception {
    Project project = new ProjectImpl();
    project.setId(1L);
    User user = new UserImpl();
    user.setId(1L);
    String s1 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0002", s1);
    String s2 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0003", s2);
    String s3 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0004", s3);
    String s4 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0005", s4);
    String s5 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0006", s5);
    String s6 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0007", s6);
    String s7 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0008", s7);
    String s8 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0009", s8);
    String s9 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0010", s9);
    String s10 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0011", s10);
    String s11 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0012", s11);
}
Also used : Project(uk.ac.bbsrc.tgac.miso.core.data.Project) User(com.eaglegenomics.simlims.core.User) ProjectImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.ProjectImpl) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Example 24 with UserImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.

the class HibernateSampleNumberPerProjectDaoIT method testExceedPadding.

@Test
public void testExceedPadding() throws Exception {
    Project project = new ProjectImpl();
    project.setId(3L);
    User user = new UserImpl();
    user.setId(1L);
    String s = sampleNumberPerProjectDao.nextNumber(project, user, PRO3_PARTIAL_ALIAS);
    assertEquals("10000", s);
    String s2 = sampleNumberPerProjectDao.nextNumber(project, user, PRO3_PARTIAL_ALIAS);
    assertEquals("10001", s2);
}
Also used : Project(uk.ac.bbsrc.tgac.miso.core.data.Project) User(com.eaglegenomics.simlims.core.User) ProjectImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.ProjectImpl) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Example 25 with UserImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.

the class HibernateSampleNumberPerProjectDaoIT method testNextNumberMultipleIncrements.

@Test
public void testNextNumberMultipleIncrements() throws Exception {
    Project project = new ProjectImpl();
    project.setId(1L);
    User user = new UserImpl();
    user.setId(1L);
    String s1 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0002", s1);
    String s2 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0003", s2);
    String s3 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
    assertEquals("0004", s3);
}
Also used : Project(uk.ac.bbsrc.tgac.miso.core.data.Project) User(com.eaglegenomics.simlims.core.User) ProjectImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.ProjectImpl) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Aggregations

UserImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl)29 User (com.eaglegenomics.simlims.core.User)25 Test (org.junit.Test)17 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)16 Project (uk.ac.bbsrc.tgac.miso.core.data.Project)10 ProjectImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.ProjectImpl)10 Date (java.util.Date)7 Sample (uk.ac.bbsrc.tgac.miso.core.data.Sample)5 DetailedSample (uk.ac.bbsrc.tgac.miso.core.data.DetailedSample)4 SampleImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl)4 BigDecimal (java.math.BigDecimal)3 Group (com.eaglegenomics.simlims.core.Group)2 Note (com.eaglegenomics.simlims.core.Note)2 Box (uk.ac.bbsrc.tgac.miso.core.data.Box)2 BoxSize (uk.ac.bbsrc.tgac.miso.core.data.BoxSize)2 BoxUse (uk.ac.bbsrc.tgac.miso.core.data.BoxUse)2 Library (uk.ac.bbsrc.tgac.miso.core.data.Library)2 BoxImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.BoxImpl)2 LibraryImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryImpl)2 PoolImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.PoolImpl)2