private async Task updateParameters(ModelSimulation simulation, LocalizedParameter[] snapshotParameters, WithIdRepository withIdRepository) { await _parameterMapper.MapLocalizedParameters(snapshotParameters, simulation.Model.Root); //The parameter mapper does not update the original building block in the simulation. We need to make sure we are keeping these values in sync so // that update and commit will work as expected (or building block difference ) var allParameters = _containerTask.CacheAllChildren <IParameter>(simulation.Model.Root); snapshotParameters?.Each(x => { var parameter = allParameters[x.Path]; //Somehow the localized parameter path was edited by hand or does not exist anymore. Warning was already shown during mapping. if (parameter == null) { return; } var buildingBlockParameter = withIdRepository.Get <IParameter>(parameter.Origin.ParameterId); if (buildingBlockParameter == null || !parameterDiffersFromTemplate(buildingBlockParameter, parameter)) { return; } buildingBlockParameter.Value = parameter.Value; buildingBlockParameter.IsDefault = false; }); }
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); }
private Task updateIndividualParameters(SnapshotIndividual snapshot, ModelIndividual individual) { return(_parameterMapper.MapLocalizedParameters(snapshot.Parameters, individual.Organism)); }
private Task updateParameters(ModelSimulation simulation, LocalizedParameter[] snapshotParameters) { return(_parameterMapper.MapLocalizedParameters(snapshotParameters, simulation.Model.Root)); }
private Task updateIndividualParameters(SnapshotIndividual snapshot, ModelIndividual individual, SnapshotContext snapshotContext) { //We do not show warning for v10 format as we will FOR SURE have missing parameters return(_parameterMapper.MapLocalizedParameters(snapshot.Parameters, individual, snapshotContext, showParameterNotFoundWarning: !snapshotContext.IsV10FormatOrEarlier)); }