Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #737 Allow lot project service to return multiple rows per lot #738

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions modules/GenericDataParser/src/server/generic_data_parser.R
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,28 @@ validateCalculatedResults <- function(calculatedResults, dryRun, curveNames, tes
if (currentProj$isRestricted) {
# columns of batchProjects must include "Project.Code" and "Requested.Name", both strings
batchProjects <- getProjectForBatch(c(unique(calculatedResults$batchCode[batchesToCheck])), mainCode)
batchProjectRestriced <- merge(batchProjects, projectDF, by.x="Project.Code", by.y="code")
# Compounds in a restricted project may not be entered into another project
rCompoundsDF <- batchProjectRestriced[batchProjectRestriced$isRestricted & batchProjectRestriced$Project.Code!=projectCode,]
rCompounds <- rCompoundsDF$Requested.Name

# Check if each project is allowed to be loaded to this experiment
# A project can only be used in the experiment if it's an unrestricted project or belongs to the project which this experiment belongs to
projectsDT <- data.table(projectDF)

# Loop through by project code and create a projectAllowedForExperiment column
projectsDT[ , projectAllowedForExperiment := {
# Check if the project is unrestricted or if it equals the projectCode of the experiment
!isRestricted | code == projectCode
}, by = code]

# Merge batch projects to project restrition information
batchProjectWithRestrictionInfo <- as.data.table(merge(batchProjects, projectsDT, by.x="Project.Code", by.y="code"))

# Create a data table with one row per batch with a boolean column as to whether it can be used in the experiment
# if any of the projects the batch belongs to is allowed to be loaded to this experiment, then the batch can be loaded to the experiment
canUseBatchDT <- batchProjectWithRestrictionInfo[ , any(projectAllowedForExperiment), by = Requested.Name]
setnames(canUseBatchDT, "V1", "batchCanBeLoadedToExperimentProject")

# Get a list of batches which are restricted and cannot be used in this experiment's project
rCompounds <- canUseBatchDT[batchCanBeLoadedToExperimentProject == FALSE]$Requested.Name

if (length(rCompounds) > 0) {
addProjectError <- TRUE
shouldCheckRole <- configList$server.project.roles.enable & !is.null(configList$client.roles.crossProjectLoaderRole)
Expand Down