Search in sources :

Example 1 with InstrumentPosition

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

the class DefaultRunService method updateContainerFromNotification.

private boolean updateContainerFromNotification(final Run target, User user, SequencingContainerModel containerModel, String containerSerialNumber, final GetLaneContents getLaneContents, String positionName) throws IOException {
    if (LimsUtils.isStringBlankOrNull(containerSerialNumber)) {
        return false;
    }
    final Collection<SequencerPartitionContainer> containers = containerService.listByBarcode(containerSerialNumber);
    int laneCount = containerModel.getPartitionCount();
    InstrumentPosition position = null;
    if (!isStringEmptyOrNull(positionName)) {
        position = target.getSequencer().getInstrumentModel().getPositions().stream().filter(pos -> positionName.equals(pos.getAlias())).findFirst().orElseThrow(() -> new IllegalArgumentException(String.format("Unknown position '%s' for platform '%s'", positionName, target.getSequencer().getInstrumentModel().getAlias())));
    }
    switch(containers.size()) {
        case 0:
            SequencerPartitionContainer newContainer = containerModel.getPlatformType().createContainer();
            newContainer.setModel(containerModel);
            newContainer.setCreator(user);
            newContainer.setIdentificationBarcode(containerSerialNumber);
            newContainer.setPartitionLimit(laneCount);
            newContainer.setPartitions(IntStream.range(0, laneCount).mapToObj(i -> new PartitionImpl(newContainer, i + 1)).collect(Collectors.toList()));
            updatePartitionContents(getLaneContents, newContainer);
            RunPosition newRunPos = new RunPosition();
            newRunPos.setRun(target);
            newRunPos.setContainer(newContainer);
            newRunPos.setPosition(position);
            target.getRunPositions().clear();
            target.getRunPositions().add(newRunPos);
            return true;
        case 1:
            SequencerPartitionContainer container = containers.iterator().next();
            boolean isMutated = false;
            if (container.getPartitions().size() != laneCount) {
                throw new IllegalArgumentException(String.format("The container %s has %d partitions, but %d were detected by the scanner.", containerSerialNumber, container.getPartitions().size(), laneCount));
            }
            // only update container model from fallback to non-fallback
            if (container.getModel().isFallback() && !containerModel.isFallback() && container.getModel().getId() != containerModel.getId()) {
                container.setModel(containerModel);
                isMutated = true;
            }
            if (target.getSequencerPartitionContainers().stream().noneMatch(c -> c.getId() == container.getId())) {
                target.addSequencerPartitionContainer(container, position);
                updatePartitionContents(getLaneContents, container);
                isMutated = true;
            }
            return isMutated;
        default:
            throw new IllegalArgumentException("Multiple containers with same identifier: " + containerSerialNumber);
    }
}
Also used : SequencingContainerModel(uk.ac.bbsrc.tgac.miso.core.data.impl.SequencingContainerModel) PaginationFilter(uk.ac.bbsrc.tgac.miso.core.util.PaginationFilter) LoggerFactory(org.slf4j.LoggerFactory) KitDescriptorService(uk.ac.bbsrc.tgac.miso.core.service.KitDescriptorService) Autowired(org.springframework.beans.factory.annotation.Autowired) MisoNamingException(uk.ac.bbsrc.tgac.miso.core.exception.MisoNamingException) RunPartition(uk.ac.bbsrc.tgac.miso.core.data.RunPartition) KitType(uk.ac.bbsrc.tgac.miso.core.data.type.KitType) NotImplementedException(org.apache.commons.lang.NotImplementedException) SequencerPartitionContainer(uk.ac.bbsrc.tgac.miso.core.data.SequencerPartitionContainer) NamingScheme(uk.ac.bbsrc.tgac.miso.core.service.naming.NamingScheme) Note(com.eaglegenomics.simlims.core.Note) JsonNode(com.fasterxml.jackson.databind.JsonNode) RunPartitionAliquotService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionAliquotService) KitDescriptor(uk.ac.bbsrc.tgac.miso.core.data.impl.kit.KitDescriptor) ValidationException(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationException) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) Predicate(java.util.function.Predicate) DeletionStore(uk.ac.bbsrc.tgac.miso.core.store.DeletionStore) Partition(uk.ac.bbsrc.tgac.miso.core.data.Partition) Collectors(java.util.stream.Collectors) PartitionImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) SequencingParametersService(uk.ac.bbsrc.tgac.miso.core.service.SequencingParametersService) InstrumentService(uk.ac.bbsrc.tgac.miso.core.service.InstrumentService) PoolService(uk.ac.bbsrc.tgac.miso.core.service.PoolService) ChangeLogService(uk.ac.bbsrc.tgac.miso.core.service.ChangeLogService) RunService(uk.ac.bbsrc.tgac.miso.core.service.RunService) OxfordNanoporeRun(uk.ac.bbsrc.tgac.miso.core.data.OxfordNanoporeRun) InstrumentModel(uk.ac.bbsrc.tgac.miso.core.data.InstrumentModel) Barcodable(uk.ac.bbsrc.tgac.miso.core.data.Barcodable) IntStream(java.util.stream.IntStream) User(com.eaglegenomics.simlims.core.User) java.util(java.util) AuthorizationManager(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager) RunStore(uk.ac.bbsrc.tgac.miso.persistence.RunStore) SequencerPartitionContainerChangeLog(uk.ac.bbsrc.tgac.miso.core.data.impl.changelog.SequencerPartitionContainerChangeLog) HealthType(uk.ac.bbsrc.tgac.miso.core.data.type.HealthType) InstrumentDataManglingPolicy(uk.ac.bbsrc.tgac.miso.core.data.InstrumentDataManglingPolicy) SequencingContainerModelService(uk.ac.bbsrc.tgac.miso.core.service.SequencingContainerModelService) IlluminaRun(uk.ac.bbsrc.tgac.miso.core.data.IlluminaRun) UserService(uk.ac.bbsrc.tgac.miso.core.service.UserService) SolidRun(uk.ac.bbsrc.tgac.miso.core.data.SolidRun) Run(uk.ac.bbsrc.tgac.miso.core.data.Run) Service(org.springframework.stereotype.Service) GetLaneContents(uk.ac.bbsrc.tgac.miso.core.data.GetLaneContents) LimsUtils(uk.ac.bbsrc.tgac.miso.core.util.LimsUtils) RunChangeLog(uk.ac.bbsrc.tgac.miso.core.data.impl.changelog.RunChangeLog) ContainerService(uk.ac.bbsrc.tgac.miso.core.service.ContainerService) NamingSchemeHolder(uk.ac.bbsrc.tgac.miso.core.service.naming.NamingSchemeHolder) RunPartitionService(uk.ac.bbsrc.tgac.miso.core.service.RunPartitionService) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) Logger(org.slf4j.Logger) InstrumentPosition(uk.ac.bbsrc.tgac.miso.core.data.InstrumentPosition) LS454Run(uk.ac.bbsrc.tgac.miso.core.data.LS454Run) WhineyFunction(uk.ac.bbsrc.tgac.miso.core.util.WhineyFunction) ExceptionUtils(org.apache.commons.lang.exception.ExceptionUtils) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) SequencingParameters(uk.ac.bbsrc.tgac.miso.core.data.SequencingParameters) AuthorizationException(uk.ac.bbsrc.tgac.miso.core.security.AuthorizationException) Consumer(java.util.function.Consumer) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition) FileAttachmentService(uk.ac.bbsrc.tgac.miso.core.service.FileAttachmentService) ValidationUtils(uk.ac.bbsrc.tgac.miso.service.impl.ValidationUtils) PaginatedDataSource(uk.ac.bbsrc.tgac.miso.core.util.PaginatedDataSource) Instrument(uk.ac.bbsrc.tgac.miso.core.data.Instrument) Transactional(org.springframework.transaction.annotation.Transactional) SopService(uk.ac.bbsrc.tgac.miso.core.service.SopService) SequencerPartitionContainer(uk.ac.bbsrc.tgac.miso.core.data.SequencerPartitionContainer) RunPosition(uk.ac.bbsrc.tgac.miso.core.data.impl.RunPosition) PartitionImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.PartitionImpl) InstrumentPosition(uk.ac.bbsrc.tgac.miso.core.data.InstrumentPosition)

Example 2 with InstrumentPosition

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

the class Dtos method to.

public static InstrumentPosition to(@Nonnull InstrumentPositionDto from) {
    InstrumentPosition to = new InstrumentPosition();
    setLong(to::setId, from.getId(), false);
    setString(to::setAlias, from.getAlias());
    return to;
}
Also used : InstrumentPosition(uk.ac.bbsrc.tgac.miso.core.data.InstrumentPosition) IonTorrentRunDto(uk.ac.bbsrc.tgac.miso.dto.run.IonTorrentRunDto) QcHierarchyNodeDto(uk.ac.bbsrc.tgac.miso.dto.dashi.QcHierarchyNodeDto) RunPositionDto(uk.ac.bbsrc.tgac.miso.dto.run.RunPositionDto) PacBioRunDto(uk.ac.bbsrc.tgac.miso.dto.run.PacBioRunDto) Ls454RunDto(uk.ac.bbsrc.tgac.miso.dto.run.Ls454RunDto) IlluminaNotificationDto(ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto) OxfordNanoporeRunDto(uk.ac.bbsrc.tgac.miso.dto.run.OxfordNanoporeRunDto) IlluminaRunDto(uk.ac.bbsrc.tgac.miso.dto.run.IlluminaRunDto) NotificationDto(ca.on.oicr.gsi.runscanner.dto.NotificationDto) OxfordNanoporeNotificationDto(ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto) RunDto(uk.ac.bbsrc.tgac.miso.dto.run.RunDto) SolidRunDto(uk.ac.bbsrc.tgac.miso.dto.run.SolidRunDto) OrderAliquotDto(uk.ac.bbsrc.tgac.miso.dto.PoolOrderDto.OrderAliquotDto)

Example 3 with InstrumentPosition

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

the class DefaultInstrumentModelService method loadChildEntities.

@Override
protected void loadChildEntities(InstrumentModel object) throws IOException {
    Set<InstrumentPosition> positions = new HashSet<>();
    for (InstrumentPosition pos : object.getPositions()) {
        if (pos.isSaved()) {
            positions.add(instrumentModelStore.getPosition(pos.getId()));
        } else {
            positions.add(pos);
        }
    }
    object.getPositions().clear();
    object.getPositions().addAll(positions);
    Set<SequencingContainerModel> models = new HashSet<>();
    for (SequencingContainerModel model : object.getContainerModels()) {
        models.add(containerModelService.get(model.getId()));
    }
    object.getContainerModels().clear();
    object.getContainerModels().addAll(models);
}
Also used : SequencingContainerModel(uk.ac.bbsrc.tgac.miso.core.data.impl.SequencingContainerModel) InstrumentPosition(uk.ac.bbsrc.tgac.miso.core.data.InstrumentPosition) HashSet(java.util.HashSet)

Example 4 with InstrumentPosition

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

the class EditServiceRecordController method showPage.

public ModelAndView showPage(ServiceRecord record, ModelMap model) throws JsonProcessingException {
    if (!record.isSaved()) {
        model.put("title", "New Service Record");
    } else {
        model.put("title", "Service Record " + record.getId());
    }
    ObjectMapper mapper = new ObjectMapper();
    model.put("serviceRecord", record);
    model.put("serviceRecordDto", mapper.writeValueAsString(Dtos.asDto(record)));
    ArrayNode positions = mapper.createArrayNode();
    for (InstrumentPosition pos : record.getInstrument().getInstrumentModel().getPositions()) {
        ObjectNode dto = positions.addObject();
        dto.put("id", pos.getId());
        dto.put("alias", pos.getAlias());
    }
    model.put("instrumentPositions", mapper.writeValueAsString(positions));
    return new ModelAndView("/WEB-INF/pages/editServiceRecord.jsp", model);
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ModelAndView(org.springframework.web.servlet.ModelAndView) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) InstrumentPosition(uk.ac.bbsrc.tgac.miso.core.data.InstrumentPosition) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with InstrumentPosition

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

the class HibernateInstrumentModelDaoIT method testDeletePosition.

@Test
public void testDeletePosition() throws Exception {
    long id = 3L;
    InstrumentPosition before = (InstrumentPosition) currentSession().get(InstrumentPosition.class, id);
    assertNotNull(before);
    dao.deletePosition(before);
    clearSession();
    InstrumentPosition after = (InstrumentPosition) currentSession().get(InstrumentPosition.class, id);
    assertNull(after);
}
Also used : InstrumentPosition(uk.ac.bbsrc.tgac.miso.core.data.InstrumentPosition) Test(org.junit.Test) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest)

Aggregations

InstrumentPosition (uk.ac.bbsrc.tgac.miso.core.data.InstrumentPosition)11 Test (org.junit.Test)4 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)4 InstrumentModel (uk.ac.bbsrc.tgac.miso.core.data.InstrumentModel)4 SequencingContainerModel (uk.ac.bbsrc.tgac.miso.core.data.impl.SequencingContainerModel)4 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 Consumer (java.util.function.Consumer)3 Collectors (java.util.stream.Collectors)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Service (org.springframework.stereotype.Service)3 Transactional (org.springframework.transaction.annotation.Transactional)3 InstrumentDataManglingPolicy (uk.ac.bbsrc.tgac.miso.core.data.InstrumentDataManglingPolicy)3 IlluminaNotificationDto (ca.on.oicr.gsi.runscanner.dto.IlluminaNotificationDto)2 NotificationDto (ca.on.oicr.gsi.runscanner.dto.NotificationDto)2 OxfordNanoporeNotificationDto (ca.on.oicr.gsi.runscanner.dto.OxfordNanoporeNotificationDto)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 List (java.util.List)2 Set (java.util.Set)2