Search in sources :

Example 21 with Instrument

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

the class EditServiceRecordController method newServiceRecord.

@GetMapping(value = "/new/{instrumentId}")
public ModelAndView newServiceRecord(@PathVariable(value = "instrumentId") Long instrumentId, ModelMap model) throws IOException {
    Instrument instrument = instrumentService.get(instrumentId);
    if (instrument == null) {
        throw new NotFoundException("No instrument found for ID " + instrumentId.toString());
    }
    ServiceRecord record = new ServiceRecord();
    record.setInstrument(instrument);
    return showPage(record, model);
}
Also used : Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) NotFoundException(org.springframework.security.acls.model.NotFoundException) ServiceRecord(uk.ac.bbsrc.tgac.miso.core.data.ServiceRecord) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 22 with Instrument

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

the class InstrumentPageIT method testChangeValues.

@Test
public void testChangeValues() throws Exception {
    // goal: test editing all editable fields on an instrument
    InstrumentPage page = InstrumentPage.get(getDriver(), getBaseUrl(), 100L);
    // check initial values
    Map<Field, String> fields = Maps.newLinkedHashMap();
    fields.put(Field.ID, "100");
    fields.put(Field.COMMISSIONED, "2017-01-01");
    fields.put(Field.INSTRUMENT_MODEL, "Illumina - Illumina HiSeq 2500");
    fields.put(Field.SERIAL_NUMBER, "100");
    fields.put(Field.NAME, "HiSeq_100");
    fields.put(Field.STATUS, "Production");
    fields.put(Field.DEFAULT_PURPOSE, "Production");
    assertFieldValues("loaded", fields, page);
    // make changes
    Map<Field, String> changes = Maps.newLinkedHashMap();
    changes.put(Field.NAME, "HiSeq_changed_100");
    changes.put(Field.SERIAL_NUMBER, "100100");
    changes.put(Field.COMMISSIONED, "2017-01-31");
    changes.put(Field.STATUS, "Retired");
    changes.put(Field.DECOMMISSIONED, "2017-10-31");
    page.setFields(changes);
    // need to make sure this is done after the status change is made
    // copy unchanged
    fields.forEach((key, val) -> {
        if (!changes.containsKey(key))
            changes.put(key, val);
    });
    assertFieldValues("changes pre-save", changes, page);
    InstrumentPage page2 = page.save();
    assertNotNull(page2);
    assertFieldValues("changes post-save", changes, page2);
    Instrument sr = (Instrument) getSession().get(InstrumentImpl.class, 100L);
    assertInstrumentAttributes(changes, sr);
}
Also used : InstrumentPage(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.InstrumentPage) Field(uk.ac.bbsrc.tgac.miso.webapp.integrationtest.page.InstrumentPage.Field) InstrumentImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.InstrumentImpl) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) Test(org.junit.Test)

Example 23 with Instrument

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

the class HibernateArrayRunDaoIT method testSaveNew.

@Test
public void testSaveNew() throws Exception {
    ArrayRun run = new ArrayRun();
    run.setAlias("TestArrayRun");
    Instrument inst = (Instrument) sessionFactory.getCurrentSession().get(InstrumentImpl.class, 3L);
    run.setInstrument(inst);
    run.setHealth(HealthType.Running);
    Date now = new Date();
    run.setStartDate(now);
    User user = (User) sessionFactory.getCurrentSession().get(UserImpl.class, 1L);
    run.setCreator(user);
    run.setCreationTime(now);
    run.setLastModifier(user);
    run.setLastModified(now);
    long savedId = sut.save(run);
    ArrayRun saved = sut.get(savedId);
    assertNotNull(saved);
    assertEquals(run.getAlias(), saved.getAlias());
    assertEquals(run.getInstrument().getId(), saved.getInstrument().getId());
    assertEquals(run.getHealth(), saved.getHealth());
    assertEquals(LimsUtils.formatDate(run.getStartDate()), LimsUtils.formatDate(saved.getStartDate()));
}
Also used : InstrumentImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.InstrumentImpl) User(com.eaglegenomics.simlims.core.User) ArrayRun(uk.ac.bbsrc.tgac.miso.core.data.ArrayRun) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl) Date(java.util.Date) Test(org.junit.Test) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest)

Example 24 with Instrument

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

the class HibernateInstrumentDaoIT method testGet.

@Test
public void testGet() throws Exception {
    Instrument instrument = dao.get(1);
    assertNotNull(instrument);
    assertEquals("instrument name does not match", "SN7001179", instrument.getName());
    assertNull("instrument date commissioned is not null", instrument.getDateCommissioned());
    assertNull("instrument date decommissioned is not null", instrument.getDateDecommissioned());
}
Also used : Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) Test(org.junit.Test) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest)

Example 25 with Instrument

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

the class HibernateInstrumentDaoIT method testGetUsageByRuns.

@Test
public void testGetUsageByRuns() throws Exception {
    Instrument instrument = (Instrument) currentSession().get(InstrumentImpl.class, 1L);
    assertEquals(3L, dao.getUsageByRuns(instrument));
}
Also used : InstrumentImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.InstrumentImpl) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) Test(org.junit.Test) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest)

Aggregations

Instrument (uk.ac.bbsrc.tgac.miso.core.data.Instrument)28 Test (org.junit.Test)14 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)12 InstrumentImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.InstrumentImpl)11 Run (uk.ac.bbsrc.tgac.miso.core.data.Run)5 User (com.eaglegenomics.simlims.core.User)4 GetMapping (org.springframework.web.bind.annotation.GetMapping)4 ServiceRecord (uk.ac.bbsrc.tgac.miso.core.data.ServiceRecord)4 NotFoundException (org.springframework.security.acls.model.NotFoundException)3 InstrumentModel (uk.ac.bbsrc.tgac.miso.core.data.InstrumentModel)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 Date (java.util.Date)2 List (java.util.List)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2