private ISchemaItem mapFrom(FlatSchemaItem flatSchemaItem) { var schemaItem = new SchemaItem(); schemaItem.Name = flatSchemaItem.Name; schemaItem.ApplicationType = ApplicationTypes.ByName(flatSchemaItem.ApplicationType); // temporarily create parent container hierarchy of the //schema item container in order to retrieve parameters from the DB FlatContainerId flatContainer = flatSchemaItem; IContainer container = schemaItem; while (_flatContainerRepo.ParentContainerFrom(flatContainer.Id) != null) { var flatParentContainer = _flatContainerRepo.ParentContainerFrom(flatContainer.Id); container.ParentContainer = new Container { Name = flatParentContainer.Name }; container = container.ParentContainer; flatContainer = flatParentContainer; } // now parameters can be added _parameterContainerTask.AddSchemaItemParametersTo(schemaItem); return(schemaItem); }
private Task <ModelProtocol> createSimpleProtocolFrom(SnapshotProtocol snapshotProtocol) { var applicationType = ApplicationTypes.ByName(snapshotProtocol.ApplicationType); var simpleProtocol = _protocolFactory.Create(ProtocolMode.Simple, applicationType).DowncastTo <SimpleProtocol>(); simpleProtocol.DosingInterval = DosingIntervals.ById(snapshotProtocol.DosingInterval); simpleProtocol.TargetOrgan = snapshotProtocol.TargetOrgan; simpleProtocol.TargetCompartment = snapshotProtocol.TargetCompartment; return(Task.FromResult <ModelProtocol>(simpleProtocol)); }
public override async Task <ModelSchemaItem> MapToModel(SnapshotSchemaItem snapshot) { var applicationType = ApplicationTypes.ByName(snapshot.ApplicationType); var schemaItem = _schemaItemFactory.Create(applicationType); MapSnapshotPropertiesToModel(snapshot, schemaItem); await UpdateParametersFromSnapshot(snapshot, schemaItem, PKSimConstants.ObjectTypes.SchemaItem); schemaItem.FormulationKey = snapshot.FormulationKey; schemaItem.TargetOrgan = snapshot.TargetOrgan; schemaItem.TargetCompartment = snapshot.TargetCompartment; return(schemaItem); }
public ApplicationDTO MapFrom(IContainer schemaItemContainer) { //schemaItemContainer are saved within en event group container var eventGroup = schemaItemContainer.ParentContainer as IEventGroup; string applicationIcon = string.Empty; if (eventGroup != null && !string.IsNullOrEmpty(eventGroup.EventGroupType)) { applicationIcon = ApplicationTypes.ByName(eventGroup.EventGroupType).IconName; } var applicationDTO = new ApplicationDTO { Name = schemaItemContainer.ParentContainer.Name, Icon = applicationIcon }; schemaItemContainer.AllParameters().Where(p => p.Visible).Each(p => applicationDTO.AddParameter(_parameterDTOMapper.MapFrom(p))); return(applicationDTO); }
public Protocol MapFrom(ApplicationProtocol batchProtocol) { var applicationType = ApplicationTypes.ByName(batchProtocol.ApplicationType); var dosingIntervalId = EnumHelper.ParseValue <DosingIntervalId>(batchProtocol.DosingInterval); var simpleProtocol = _protocolFactory.Create(ProtocolMode.Simple, applicationType).DowncastTo <SimpleProtocol>(); simpleProtocol.Name = batchProtocol.Name ?? "Protocol"; simpleProtocol.EndTimeParameter.Value = batchProtocol.EndTime; simpleProtocol.Dose.DisplayUnit = simpleProtocol.Dose.Dimension.Unit(batchProtocol.DoseUnit); simpleProtocol.Dose.Value = simpleProtocol.Dose.Dimension.UnitValueToBaseUnitValue(simpleProtocol.Dose.DisplayUnit, batchProtocol.Dose); simpleProtocol.DosingInterval = DosingIntervals.ById(dosingIntervalId); _logger.AddDebug($"Application Type = {applicationType.Name}"); _logger.AddDebug($"Dosing Interval = {simpleProtocol.DosingInterval.DisplayName}"); _logger.AddDebug($"Application Dose = {simpleProtocol.Dose.Value} [{simpleProtocol.Dose.DisplayUnit}]"); _logger.AddDebug($"Application End Time = {simpleProtocol.EndTime}"); return(simpleProtocol); }
public override object ConvertFrom(string attributeValue, SerializationContext context) { return(ApplicationTypes.ByName(attributeValue)); }