private async Task updateExpression(Molecule snapshot, ExpressionContainerMapperContext context) { await _expressionContainerMapper.MapToModels(snapshot.Expression, context); //once expression have been set, we need to update normalized parameter var normalizeExpressionCommand = new NormalizeRelativeExpressionCommand(context.Molecule, _executionContext); normalizeExpressionCommand.Execute(_executionContext); }
public override async Task <ModelExpressionProfile> MapToModel(SnapshotExpressionProfile snapshot, SnapshotContext snapshotContext) { var expressionProfile = _expressionProfileFactory.Create(snapshot.Type, snapshot.Species, snapshot.Molecule); expressionProfile.Description = snapshot.Description; expressionProfile.Category = snapshot.Category; var(molecule, individual) = expressionProfile; //Update molecule properties first updateMoleculePropertiesToMolecule(molecule, snapshot, individual, snapshotContext); //Then override all parameters that were set await _parameterMapper.MapLocalizedParameters(snapshot.Parameters, individual, snapshotContext, !snapshotContext.IsV9FormatOrEarlier); var snapshotWithSubjectContext = new SnapshotContextWithSubject(individual, snapshotContext); var ontogeny = await _ontogenyMapper.MapToModel(snapshot.Ontogeny, snapshotWithSubjectContext); _ontogenyTask.SetOntogenyForMolecule(molecule, ontogeny, individual); var context = new ExpressionContainerMapperContext(snapshotContext) { Molecule = molecule, ExpressionParameters = individual.AllExpressionParametersFor(molecule), MoleculeExpressionContainers = individual.AllMoleculeContainersFor(molecule), }; await _expressionContainerMapper.MapToModels(snapshot.Expression, context); //We need to normalize relative expressions when loading from old format if (snapshotContext.IsV9FormatOrEarlier) { //Make sure we load the default parameters from db just in case we were dealing with a standard molecule _moleculeParameterTask.SetDefaultMoleculeParameters(molecule); //Global parameters were saved directly under the snapshot parameter await updateGlobalMoleculeParameters(snapshot, molecule, snapshotContext); NormalizeRelativeExpressionCommand.NormalizeExpressions(individual, molecule); } return(expressionProfile); }