Search in sources :

Example 91 with Sample

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

the class HibernateSampleDao method listByIdList.

@Override
public List<Sample> listByIdList(Collection<Long> idList) throws IOException {
    if (idList.isEmpty()) {
        return Collections.emptyList();
    }
    Criteria criteria = currentSession().createCriteria(SampleImpl.class);
    criteria.add(Restrictions.in("sampleId", idList));
    @SuppressWarnings("unchecked") List<Sample> records = criteria.list();
    return records;
}
Also used : Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) Criteria(org.hibernate.Criteria) DetachedCriteria(org.hibernate.criterion.DetachedCriteria)

Example 92 with Sample

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

the class HibernateSampleNumberPerProjectDao method nextNumber.

@SuppressWarnings("unchecked")
@Override
public synchronized String nextNumber(Project project, User user, String partialAlias) {
    SampleNumberPerProject sampleNumberPerProject = getByProject(project);
    if (sampleNumberPerProject == null) {
        sampleNumberPerProject = createSampleNumberPerProject(project, user);
    }
    Integer highestSampleNumber = sampleNumberPerProject.getHighestSampleNumber();
    String num = null;
    List<Sample> existing = null;
    do {
        highestSampleNumber++;
        num = padInteger(sampleNumberPerProject.getPadding(), highestSampleNumber);
        Criteria criteria = currentSession().createCriteria(SampleImpl.class);
        criteria.add(Restrictions.eq("alias", partialAlias + num));
        existing = criteria.list();
    } while (existing != null && !existing.isEmpty());
    sampleNumberPerProject.setHighestSampleNumber(highestSampleNumber);
    sampleNumberPerProject.setUpdatedBy(user);
    update(sampleNumberPerProject);
    return num;
}
Also used : Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) Criteria(org.hibernate.Criteria) SampleNumberPerProject(uk.ac.bbsrc.tgac.miso.core.data.SampleNumberPerProject)

Example 93 with Sample

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

the class HibernateAttachableDaoIT method testGetManagedAttachable.

@Test
public void testGetManagedAttachable() throws Exception {
    Sample sample = (Sample) currentSession().get(SampleImpl.class, 1L);
    Attachable attachable = sut.getManaged(sample);
    assertTrue(attachable instanceof Sample);
    assertEquals(sample.getId(), attachable.getId());
}
Also used : Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) Attachable(uk.ac.bbsrc.tgac.miso.core.data.Attachable) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl) Test(org.junit.Test) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest)

Example 94 with Sample

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

the class HibernateProgressDaoIT method makeSampleProgressStep.

private SampleProgressStep makeSampleProgressStep(long sampleId, int stepNumber) {
    SampleProgressStep step = new SampleProgressStep();
    Sample sample = new SampleImpl();
    sample.setId(sampleId);
    step.setInput(sample);
    step.setStepNumber(stepNumber);
    return step;
}
Also used : SampleProgressStep(uk.ac.bbsrc.tgac.miso.core.data.workflow.impl.SampleProgressStep) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl)

Example 95 with Sample

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

the class RequisitionController method edit.

@GetMapping("/{id}")
public ModelAndView edit(@PathVariable long id, ModelMap model) throws IOException {
    Requisition requisition = requisitionService.get(id);
    if (requisition == null) {
        throw new NotFoundException("No requisition found for ID: " + id);
    }
    model.put("title", "Requisition " + id);
    List<Sample> samples = sampleService.list(0, 0, false, "id", PaginationFilter.requisitionId(id));
    List<Sample> extractions = sampleService.getChildren(samples.stream().map(Sample::getId).collect(Collectors.toSet()), SampleStock.CATEGORY_NAME);
    List<SampleDto> extractionDtos = extractions.stream().map(sam -> Dtos.asDto(sam, false)).collect(Collectors.toList());
    model.put("extractions", extractionDtos);
    List<Long> libraryIds = libraryService.listIdsByRequisitionId(id);
    List<Run> runs = runService.listByLibraryIdList(libraryIds);
    List<RunDto> runDtos = runs.stream().map(Dtos::asDto).collect(Collectors.toList());
    model.put("runs", runDtos);
    return setupForm(requisition, PageMode.EDIT, model);
}
Also used : PageMode(uk.ac.bbsrc.tgac.miso.webapp.util.PageMode) PathVariable(org.springframework.web.bind.annotation.PathVariable) AuthorizationManager(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager) PaginationFilter(uk.ac.bbsrc.tgac.miso.core.util.PaginationFilter) RequisitionService(uk.ac.bbsrc.tgac.miso.core.service.RequisitionService) NotFoundException(org.springframework.security.acls.model.NotFoundException) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Controller(org.springframework.stereotype.Controller) Dtos(uk.ac.bbsrc.tgac.miso.dto.Dtos) ModelMap(org.springframework.ui.ModelMap) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) SampleDto(uk.ac.bbsrc.tgac.miso.dto.SampleDto) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) GetMapping(org.springframework.web.bind.annotation.GetMapping) Requisition(uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition) RequisitionDto(uk.ac.bbsrc.tgac.miso.dto.RequisitionDto) ListItemsPage(uk.ac.bbsrc.tgac.miso.webapp.util.ListItemsPage) RunPartitionAliquotService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionAliquotService) SampleService(uk.ac.bbsrc.tgac.miso.core.service.SampleService) LibraryService(uk.ac.bbsrc.tgac.miso.core.service.LibraryService) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Collectors(java.util.stream.Collectors) ModelAndView(org.springframework.web.servlet.ModelAndView) List(java.util.List) SampleStock(uk.ac.bbsrc.tgac.miso.core.data.SampleStock) RunService(uk.ac.bbsrc.tgac.miso.core.service.RunService) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) NotFoundException(org.springframework.security.acls.model.NotFoundException) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) SampleDto(uk.ac.bbsrc.tgac.miso.dto.SampleDto) Requisition(uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

Sample (uk.ac.bbsrc.tgac.miso.core.data.Sample)97 DetailedSample (uk.ac.bbsrc.tgac.miso.core.data.DetailedSample)60 Test (org.junit.Test)55 SampleImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl)37 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)24 TransferSample (uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferSample)19 SampleIdentity (uk.ac.bbsrc.tgac.miso.core.data.SampleIdentity)11 User (com.eaglegenomics.simlims.core.User)9 ArrayList (java.util.ArrayList)9 Project (uk.ac.bbsrc.tgac.miso.core.data.Project)9 SampleTissue (uk.ac.bbsrc.tgac.miso.core.data.SampleTissue)8 IOException (java.io.IOException)7 PostMapping (org.springframework.web.bind.annotation.PostMapping)7 Library (uk.ac.bbsrc.tgac.miso.core.data.Library)7 SampleStock (uk.ac.bbsrc.tgac.miso.core.data.SampleStock)7 Requisition (uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition)7 WorksetSample (uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetSample)7 Date (java.util.Date)6 Criteria (org.hibernate.Criteria)6 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)6