Search in sources :

Example 1 with ParentIdentityAttributes

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

the class Dtos method asDto.

public static LibraryAliquotDto asDto(@Nonnull ListLibraryAliquotView from) {
    LibraryAliquotDto dto = null;
    if (from.getParentAttributes() != null) {
        // indicates detailed sample
        DetailedLibraryAliquotDto detailedDto = new DetailedLibraryAliquotDto();
        setId(detailedDto::setLibraryDesignCodeId, from.getDesignCode());
        if (from.getSubprojectId() != null) {
            detailedDto.setSubprojectAlias(from.getSubprojectAlias());
            detailedDto.setSubprojectPriority(from.getSubprojectPriority());
        }
        if (from.getIdentityAttributes() != null) {
            ParentIdentityAttributes identity = from.getIdentityAttributes();
            setString(detailedDto::setIdentityConsentLevel, maybeGetProperty(identity.getConsentLevel(), ConsentLevel::getLabel));
            setString(detailedDto::setEffectiveExternalNames, identity.getExternalName());
        }
        if (from.getTissueAttributes() != null) {
            ParentTissueAttributes tissue = from.getTissueAttributes();
            setString(detailedDto::setEffectiveTissueOriginAlias, tissue.getTissueOrigin().getAlias());
            setString(detailedDto::setEffectiveTissueOriginDescription, tissue.getTissueOrigin().getDescription());
            setString(detailedDto::setEffectiveTissueTypeAlias, tissue.getTissueType().getAlias());
            setString(detailedDto::setEffectiveTissueTypeDescription, tissue.getTissueType().getDescription());
        }
        dto = detailedDto;
    } else {
        dto = new LibraryAliquotDto();
    }
    dto.setId(from.getId());
    dto.setName(from.getName());
    setString(dto::setAlias, from.getAlias());
    setString(dto::setCreatorName, maybeGetProperty(from.getCreator(), User::getFullName));
    setString(dto::setConcentration, from.getConcentration());
    dto.setConcentrationUnits(from.getConcentrationUnits());
    dto.setLastModified(formatDateTime(from.getLastModified()));
    dto.setCreationDate(formatDate(from.getCreated()));
    dto.setIdentificationBarcode(from.getAliquotBarcode());
    dto.setLocationLabel(BoxUtils.makeLocationLabel(from));
    dto.setIndexIds(Stream.of(from.getParentLibrary().getIndex1(), from.getParentLibrary().getIndex2()).filter(Objects::nonNull).map(Index::getId).collect(Collectors.toList()));
    dto.setIndexLabels(Stream.of(from.getParentLibrary().getIndex1(), from.getParentLibrary().getIndex2()).filter(Objects::nonNull).map(Index::getLabel).collect(Collectors.toList()));
    dto.setTargetedSequencingId(from.getTargetedSequencingId());
    setInteger(dto::setDnaSize, from.getDnaSize(), true);
    setString(dto::setVolume, from.getAliquotVolume());
    dto.setVolumeUnits(from.getAliquotVolumeUnits());
    setString(dto::setNgUsed, from.getNgUsed());
    setString(dto::setVolumeUsed, from.getVolumeUsed());
    dto.setLibraryId(from.getLibraryId());
    dto.setLibraryName(from.getLibraryName());
    dto.setLibraryAlias(from.getLibraryAlias());
    dto.setLibraryLowQuality(from.isLibraryLowQuality());
    dto.setLibraryPlatformType(from.getPlatformType().getKey());
    dto.setSampleId(from.getSampleId());
    dto.setSampleName(from.getSampleName());
    dto.setSampleAlias(from.getSampleAlias());
    setString(dto::setSequencingControlTypeAlias, maybeGetProperty(from.getSampleSequencingControlType(), SequencingControlType::getAlias));
    setId(dto::setDetailedQcStatusId, from.getDetailedQcStatus());
    setString(dto::setDetailedQcStatusNote, from.getDetailedQcStatusNote());
    setString(dto::setQcUserName, maybeGetProperty(from.getQcUser(), User::getFullName));
    setDateString(dto::setQcDate, from.getQcDate());
    List<Long> parentAliquotIds = new ArrayList<>();
    for (ParentAliquot parent = from.getParentAliquot(); parent != null; parent = parent.getParentAliquot()) {
        parentAliquotIds.add(parent.getId());
    }
    dto.setParentAliquotIds(parentAliquotIds);
    setEffectiveQcFailure(from, dto);
    return dto;
}
Also used : ParentTissueAttributes(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentTissueAttributes) ParentIdentityAttributes(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentIdentityAttributes) ArrayList(java.util.ArrayList) Index(uk.ac.bbsrc.tgac.miso.core.data.Index) ParentAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentAliquot)

Example 2 with ParentIdentityAttributes

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

the class Dtos method asMinimalDto.

public static SampleDto asMinimalDto(@Nonnull Sample from) {
    DetailedSampleDto dto = new DetailedSampleDto();
    copySampleFields(from, dto, false, 0);
    if (isDetailedSample(from)) {
        DetailedSample detailed = (DetailedSample) from;
        dto.setSampleClassId(detailed.getSampleClass().getId());
        setDateString(dto::setCreationDate, detailed.getCreationDate());
        if (detailed.getSubproject() != null) {
            dto.setSubprojectAlias(detailed.getSubproject().getAlias());
            dto.setSubprojectPriority(detailed.getSubproject().getPriority());
        }
        if (detailed.getIdentityAttributes() != null) {
            ParentIdentityAttributes identity = detailed.getIdentityAttributes();
            setString(dto::setIdentityConsentLevel, maybeGetProperty(identity.getConsentLevel(), ConsentLevel::getLabel));
            setString(dto::setEffectiveExternalNames, identity.getExternalName());
        }
        if (detailed.getTissueAttributes() != null) {
            ParentTissueAttributes tissue = detailed.getTissueAttributes();
            setString(dto::setEffectiveTissueOriginAlias, tissue.getTissueOrigin().getAlias());
            setString(dto::setEffectiveTissueOriginDescription, tissue.getTissueOrigin().getDescription());
            setString(dto::setEffectiveTissueTypeAlias, tissue.getTissueType().getAlias());
            setString(dto::setEffectiveTissueTypeDescription, tissue.getTissueType().getDescription());
            setString(dto::setEffectiveTimepoint, tissue.getTimepoint());
        }
        setEffectiveQcFailure(from, dto);
    }
    return dto;
}
Also used : ParentTissueAttributes(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentTissueAttributes) ParentIdentityAttributes(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentIdentityAttributes) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample)

Example 3 with ParentIdentityAttributes

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

the class Dtos method asDto.

public static LibraryAliquotDto asDto(@Nonnull LibraryAliquot from, boolean includeBoxPositions) {
    LibraryAliquotDto dto = null;
    Library library = from.getLibrary();
    Sample sample = library == null ? null : library.getSample();
    if (isDetailedLibraryAliquot(from)) {
        DetailedLibraryAliquotDto detailedDto = asDetailedDto((DetailedLibraryAliquot) from);
        DetailedSample detailed = (DetailedSample) sample;
        if (detailed.getSubproject() != null) {
            detailedDto.setSubprojectAlias(detailed.getSubproject().getAlias());
            detailedDto.setSubprojectPriority(detailed.getSubproject().getPriority());
        }
        if (detailed.getIdentityAttributes() != null) {
            ParentIdentityAttributes identity = detailed.getIdentityAttributes();
            setString(detailedDto::setIdentityConsentLevel, maybeGetProperty(identity.getConsentLevel(), ConsentLevel::getLabel));
            setString(detailedDto::setEffectiveExternalNames, identity.getExternalName());
        }
        if (detailed.getTissueAttributes() != null) {
            ParentTissueAttributes tissue = detailed.getTissueAttributes();
            setString(detailedDto::setEffectiveTissueOriginAlias, tissue.getTissueOrigin().getAlias());
            setString(detailedDto::setEffectiveTissueOriginDescription, tissue.getTissueOrigin().getDescription());
            setString(detailedDto::setEffectiveTissueTypeAlias, tissue.getTissueType().getAlias());
            setString(detailedDto::setEffectiveTissueTypeDescription, tissue.getTissueType().getDescription());
        }
        dto = detailedDto;
    } else {
        dto = new LibraryAliquotDto();
    }
    if (library != null) {
        setLong(dto::setLibraryId, library.getId(), true);
        setString(dto::setLibraryName, library.getName());
        setString(dto::setLibraryAlias, library.getAlias());
        setBoolean(dto::setLibraryLowQuality, library.isLowQuality(), false);
        setString(dto::setLibraryPlatformType, library.getPlatformType().getKey());
        if (library.getIndex1() != null) {
            List<Index> indices = Stream.of(library.getIndex1(), library.getIndex2()).filter(Objects::nonNull).collect(Collectors.toList());
            dto.setIndexIds(indices.stream().sorted(Comparator.comparingInt(Index::getPosition)).map(Index::getId).collect(Collectors.toList()));
            dto.setIndexLabels(indices.stream().sorted(Comparator.comparingInt(Index::getPosition)).map(Index::getLabel).collect(Collectors.toList()));
        }
        if (sample != null) {
            setLong(dto::setSampleId, sample.getId(), true);
            setString(dto::setSampleName, sample.getName());
            setString(dto::setSampleAlias, sample.getAlias());
        }
    }
    if (from.getParentAliquot() != null) {
        setLong(dto::setParentAliquotId, from.getParentAliquot().getId(), true);
        setString(dto::setParentAliquotAlias, from.getParentAliquot().getAlias());
    }
    setString(dto::setParentName, maybeGetProperty(from.getParent(), HierarchyEntity::getName));
    setString(dto::setParentVolume, maybeGetProperty(from.getParent(), HierarchyEntity::getVolume));
    dto.setId(from.getId());
    dto.setName(from.getName());
    setString(dto::setAlias, from.getAlias());
    setString(dto::setDescription, from.getDescription());
    dto.setCreatorName(from.getCreator().getFullName());
    setString(dto::setConcentration, from.getConcentration());
    dto.setConcentrationUnits(from.getConcentrationUnits());
    setString(dto::setVolume, from.getVolume());
    dto.setVolumeUnits(from.getVolumeUnits());
    setString(dto::setNgUsed, from.getNgUsed());
    setString(dto::setVolumeUsed, from.getVolumeUsed());
    setInteger(dto::setDnaSize, from.getDnaSize(), true);
    if (from.getCreationDate() != null) {
        dto.setCreationDate(formatDate(from.getCreationDate()));
    }
    dto.setIdentificationBarcode(from.getIdentificationBarcode());
    dto.setLocationLabel(BoxUtils.makeLocationLabel(from));
    if (from.getTargetedSequencing() != null) {
        dto.setTargetedSequencingId(from.getTargetedSequencing().getId());
    }
    if (from.getBox() != null) {
        dto.setBox(asDto(from.getBox(), includeBoxPositions));
        dto.setBoxPosition(from.getBoxPosition());
    }
    dto.setDiscarded(from.isDiscarded());
    setDateTimeString(dto::setLastModified, from.getLastModified());
    setId(dto::setDetailedQcStatusId, from.getDetailedQcStatus());
    setString(dto::setDetailedQcStatusNote, from.getDetailedQcStatusNote());
    setString(dto::setQcUserName, maybeGetProperty(from.getQcUser(), User::getFullName));
    setDateString(dto::setQcDate, from.getQcDate());
    setEffectiveQcFailure(from, dto);
    setId(dto::setKitDescriptorId, from.getKitDescriptor());
    setString(dto::setKitLot, from.getKitLot());
    Requisition requisition = from.getLibrary().getSample().getRequisition();
    if (requisition == null) {
        requisition = getParentRequisition(from.getLibrary().getSample());
    }
    setId(dto::setRequisitionId, requisition);
    setString(dto::setRequisitionAlias, maybeGetProperty(requisition, Requisition::getAlias));
    return dto;
}
Also used : ParentTissueAttributes(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentTissueAttributes) ParentSample(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentSample) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) WorksetSample(uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetSample) GrandparentSample(uk.ac.bbsrc.tgac.miso.core.data.impl.view.GrandparentSample) TransferSample(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferSample) ParentIdentityAttributes(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentIdentityAttributes) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Index(uk.ac.bbsrc.tgac.miso.core.data.Index) TransferLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibrary) ParentLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentLibrary) DetailedLibrary(uk.ac.bbsrc.tgac.miso.core.data.DetailedLibrary) WorksetLibrary(uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetLibrary) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) Requisition(uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition)

Example 4 with ParentIdentityAttributes

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

the class Dtos method asDetailedLibraryDto.

private static DetailedLibraryDto asDetailedLibraryDto(@Nonnull DetailedLibrary from) {
    DetailedLibraryDto dto = new DetailedLibraryDto();
    if (from.getLibraryDesign() != null) {
        dto.setLibraryDesignId(from.getLibraryDesign().getId());
    }
    dto.setLibraryDesignCodeId(from.getLibraryDesignCode().getId());
    dto.setPreMigrationId(from.getPreMigrationId());
    dto.setArchived(from.getArchived());
    dto.setNonStandardAlias(from.hasNonStandardAlias());
    GroupIdentifiable effective = from.getEffectiveGroupIdEntity();
    if (effective != null) {
        dto.setEffectiveGroupId(effective.getGroupId());
        dto.setEffectiveGroupIdSample(effective.getAlias());
    }
    if (from.getGroupId() != null) {
        dto.setGroupId(from.getGroupId());
    }
    if (from.getGroupDescription() != null) {
        dto.setGroupDescription(from.getGroupDescription());
    }
    if (from.getSample() != null) {
        DetailedSample detailed = (DetailedSample) from.getSample();
        if (detailed.getSubproject() != null) {
            dto.setSubprojectAlias(detailed.getSubproject().getAlias());
            dto.setSubprojectPriority(detailed.getSubproject().getPriority());
        }
        if (detailed.getIdentityAttributes() != null) {
            ParentIdentityAttributes identity = detailed.getIdentityAttributes();
            setString(dto::setIdentityConsentLevel, maybeGetProperty(identity.getConsentLevel(), ConsentLevel::getLabel));
        }
        if (detailed.getTissueAttributes() != null) {
            ParentTissueAttributes tissue = detailed.getTissueAttributes();
            setString(dto::setEffectiveTissueOriginAlias, tissue.getTissueOrigin().getAlias());
            setString(dto::setEffectiveTissueOriginDescription, tissue.getTissueOrigin().getDescription());
            setString(dto::setEffectiveTissueTypeAlias, tissue.getTissueType().getAlias());
            setString(dto::setEffectiveTissueTypeDescription, tissue.getTissueType().getDescription());
        }
    }
    return dto;
}
Also used : ParentTissueAttributes(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentTissueAttributes) ParentIdentityAttributes(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentIdentityAttributes) GroupIdentifiable(uk.ac.bbsrc.tgac.miso.core.data.GroupIdentifiable) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample)

Example 5 with ParentIdentityAttributes

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

the class Dtos method asDetailedSampleDto.

private static DetailedSampleDto asDetailedSampleDto(@Nonnull DetailedSample from) {
    DetailedSampleDto dto = null;
    if (isIdentitySample(from)) {
        dto = asIdentitySampleDto((SampleIdentity) from);
    } else if (isTissueSample(from)) {
        dto = asTissueSampleDto((SampleTissue) from);
    } else if (isTissueProcessingSample(from)) {
        dto = asTissueProcessingSampleDto((SampleTissueProcessing) from);
    } else if (isAliquotSample(from)) {
        dto = asAliquotSampleDto((SampleAliquot) from);
    } else if (isStockSample(from)) {
        dto = asStockSampleDto((SampleStock) from);
    } else {
        throw new IllegalArgumentException();
    }
    dto.setSampleClassId(from.getSampleClass().getId());
    dto.setSampleClassAlias(from.getSampleClass().getAlias());
    dto.setSampleCategory(from.getSampleClass().getSampleCategory());
    dto.setSampleSubcategory(from.getSampleClass().getSampleSubcategory());
    if (from.getSubproject() != null) {
        dto.setSubprojectId(from.getSubproject().getId());
        dto.setSubprojectAlias(from.getSubproject().getAlias());
        dto.setSubprojectPriority(from.getSubproject().getPriority());
    }
    if (from.getParent() != null) {
        DetailedSample parent = from.getParent();
        dto.setParentId(parent.getId());
        setString(dto::setParentName, parent.getName());
        dto.setParentAlias(parent.getAlias());
        dto.setParentSampleClassId(parent.getSampleClass().getId());
        if (parent.getBox() != null) {
            dto.setParentBoxPosition(parent.getBoxPosition());
            dto.setParentBoxPositionLabel(BoxUtils.makeBoxPositionLabel(parent.getBox().getAlias(), parent.getBoxPosition()));
        }
    }
    GroupIdentifiable effective = from.getEffectiveGroupIdEntity();
    if (effective != null) {
        dto.setEffectiveGroupId(effective.getGroupId());
        dto.setEffectiveGroupIdSample(effective.getAlias());
    }
    if (from.getGroupId() != null) {
        dto.setGroupId(from.getGroupId());
    }
    if (from.getGroupDescription() != null) {
        dto.setGroupDescription(from.getGroupDescription());
    }
    if (from.isSynthetic() != null) {
        dto.setSynthetic(from.isSynthetic());
    }
    setDateString(dto::setCreationDate, from.getCreationDate());
    dto.setNonStandardAlias(from.hasNonStandardAlias());
    setString(dto::setVolumeUsed, from.getVolumeUsed());
    setString(dto::setNgUsed, from.getNgUsed());
    if (from.getIdentityAttributes() != null) {
        ParentIdentityAttributes identity = from.getIdentityAttributes();
        setString(dto::setIdentityConsentLevel, maybeGetProperty(identity.getConsentLevel(), ConsentLevel::getLabel));
        setString(dto::setEffectiveExternalNames, identity.getExternalName());
    }
    if (from.getTissueAttributes() != null) {
        ParentTissueAttributes tissue = from.getTissueAttributes();
        setString(dto::setEffectiveTissueOriginAlias, tissue.getTissueOrigin().getAlias());
        setString(dto::setEffectiveTissueOriginDescription, tissue.getTissueOrigin().getDescription());
        setString(dto::setEffectiveTissueTypeAlias, tissue.getTissueType().getAlias());
        setString(dto::setEffectiveTissueTypeDescription, tissue.getTissueType().getDescription());
    }
    setEffectiveQcFailure(from, dto);
    if (from.getRequisition() == null) {
        Requisition requisition = getParentRequisition(from);
        setId(dto::setEffectiveRequisitionId, requisition);
        setString(dto::setEffectiveRequisitionAlias, maybeGetProperty(requisition, Requisition::getAlias));
    }
    return dto;
}
Also used : SampleTissueProcessing(uk.ac.bbsrc.tgac.miso.core.data.SampleTissueProcessing) ParentTissueAttributes(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentTissueAttributes) SampleIdentity(uk.ac.bbsrc.tgac.miso.core.data.SampleIdentity) ParentIdentityAttributes(uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentIdentityAttributes) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) GroupIdentifiable(uk.ac.bbsrc.tgac.miso.core.data.GroupIdentifiable) Requisition(uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition) SampleStock(uk.ac.bbsrc.tgac.miso.core.data.SampleStock)

Aggregations

ParentIdentityAttributes (uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentIdentityAttributes)5 ParentTissueAttributes (uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentTissueAttributes)5 DetailedSample (uk.ac.bbsrc.tgac.miso.core.data.DetailedSample)4 GroupIdentifiable (uk.ac.bbsrc.tgac.miso.core.data.GroupIdentifiable)2 Index (uk.ac.bbsrc.tgac.miso.core.data.Index)2 Requisition (uk.ac.bbsrc.tgac.miso.core.data.impl.Requisition)2 ArrayList (java.util.ArrayList)1 DetailedLibrary (uk.ac.bbsrc.tgac.miso.core.data.DetailedLibrary)1 Library (uk.ac.bbsrc.tgac.miso.core.data.Library)1 Sample (uk.ac.bbsrc.tgac.miso.core.data.Sample)1 SampleIdentity (uk.ac.bbsrc.tgac.miso.core.data.SampleIdentity)1 SampleStock (uk.ac.bbsrc.tgac.miso.core.data.SampleStock)1 SampleTissueProcessing (uk.ac.bbsrc.tgac.miso.core.data.SampleTissueProcessing)1 TransferLibrary (uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferLibrary)1 TransferSample (uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferSample)1 GrandparentSample (uk.ac.bbsrc.tgac.miso.core.data.impl.view.GrandparentSample)1 ParentAliquot (uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentAliquot)1 ParentLibrary (uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentLibrary)1 ParentSample (uk.ac.bbsrc.tgac.miso.core.data.impl.view.ParentSample)1 WorksetLibrary (uk.ac.bbsrc.tgac.miso.core.data.impl.workset.WorksetLibrary)1