public void WriteDefinitions(TDefinitions definitions) { var definitionSerialized = _dmnTransformer.Transform(definitions); //TODO: add validations _dmnPersistence.WriteDefinitions(definitions.Name, definitionSerialized); }
public string Transform(TDefinitions definitions) { var xmlSerializer = new XmlSerializer(typeof(TDefinitions)); var dmnWriter = new StringWriter(); xmlSerializer.Serialize(dmnWriter, definitions); return(dmnWriter.ToString()); }
public void Tranform_ModelToString() { var mock = new Mock <ILogger <DMNTransformer> > (); ILogger <DMNTransformer> logger = mock.Object; var dmnTranformer = new DMNTransformer(logger); var definitions = new TDefinitions { Name = "test" }; var actual = dmnTranformer.Transform(definitions); }
private Task <List <string> > DuplicateChecks(TDefinitions definition) { var errorList = new List <string> (); errorList.AddRange(CheckDuplicates(definition.DrgElement.GroupBy(e => e.Id).Where(c => c.Count() > 1), "Element Id")); errorList.AddRange(CheckDuplicates(definition.DrgElement.GroupBy(e => e.Name).Where(c => c.Count() > 1), "Element Name")); errorList.AddRange(CheckDuplicates(definition.ItemDefinition.GroupBy(e => e.Name).Where(c => c.Count() > 1), "Item Definition Name")); return(Task.FromResult(errorList)); }
public void WriteDefinitions_With_Version() { var definitions = new TDefinitions { Name = "test_writedefinition" }; _fixture._dmnRepository.WriteDefinitions(definitions); var def = _fixture._dmnRepository.FindDefinitions("test_writedefinition", 1); Assert.NotNull(def); Assert.Equal <string> ("test_writedefinition", def.Name); }
public Dictionary <string, BkmMeta> BuildBkmMeta(TDefinitions definitions) { var bkmDict = new Dictionary <string, BkmMeta> (); foreach (var item in definitions.DrgElement) { if (item is TBusinessKnowledgeModel bkmModel) { bkmDict.Add(bkmModel.Name, new BkmMeta() { BKMModel = bkmModel }); } } return(bkmDict); }
private Dictionary <string, ItemDefinitionMeta> BuildItemDefinitionsMeta(TDefinitions definitions) { var itemDefMetaDict = new Dictionary <string, ItemDefinitionMeta> (); foreach (var item in definitions.ItemDefinition) { var itemDefMeta = new ItemDefinitionMeta { AllowedValues = item.AllowedValues, Name = item.Name, TypeName = item.TypeRef, TypeLanguage = item.TypeLanguage, IsCollection = item.IsCollection }; CreateItemDefinitionMeta(item.ItemComponent, ref itemDefMeta); itemDefMetaDict.Add(item.Name, itemDefMeta); } return(itemDefMetaDict); }
private void BuildDRGMeta(TDefinitions definitions, VariableContext context) { foreach (var item in definitions.DrgElement) { if (item is TDecisionService decisionService) { context.DecisionServiceMetaByName.Add(decisionService.Name, decisionService); foreach (var inputDecision in decisionService.InputDecision) { var cleanHref = inputDecision.Href.TrimStart('#'); if (!context.HrefInputDecisionToDecisionServices.TryAdd(cleanHref, new List <string> () { decisionService.Name })) { context.HrefInputDecisionToDecisionServices.TryGetValue(cleanHref, out var decServices); decServices.Add(decisionService.Name); } } } if (item is TDecision decision) { context.DecisionMetaByName.Add(decision.Name, decision); if (decision.Id != null) { context.DecisionMetaById.Add(decision.Id, decision); } } if (item is TBusinessKnowledgeModel bkmModel) { context.BKMMetaByName.Add(bkmModel.Name, new BkmMeta() { BKMModel = bkmModel }); } } }
public override async Task <object> Execute(BPMNOrchestratorInput input) { _model = await GetBpmnDefinition(input); _terminateCancellationTokenSource = new CancellationTokenSource(); _terminateTaskCompletionSource = new TaskCompletionSource <object>(); _compensations = new ConcurrentBag <Func <Task> >(); _nodeHits = new ConcurrentDictionary <string, int>(); _variables = new JObject(); var executableProcess = _model.RootElement.OfType <TProcess>() .Where(p => p.IsExecutable == true) .FirstOrDefault(); await WaitForAny( _terminateTaskCompletionSource.Task, VisitProcess(executableProcess) ); _terminateCancellationTokenSource.Cancel(); return(null); }
private (Dictionary <string, InputDataMeta>, Dictionary <string, InputDataMeta>) BuildInputDataMeta(TDefinitions definitions) { var inputById = new Dictionary <string, InputDataMeta> (); var inputByName = new Dictionary <string, InputDataMeta> (); foreach (var item in definitions.DrgElement) { if (item is TInputData inputDataItem) { var inputMeta = new InputDataMeta { Id = inputDataItem.Id, Name = inputDataItem.Name, TypeName = inputDataItem.Variable.TypeRef }; inputById.Add(inputMeta.Id, inputMeta); inputByName.Add(inputMeta.Name, inputMeta); } } return(inputByName, inputById); }
public (Dictionary <string, TDecisionService>, Dictionary <string, TDecisionService>) BuildDecisionServiceMeta(TDefinitions definitions) { var decisionDict = new Dictionary <string, TDecisionService> (); var decisionDictById = new Dictionary <string, TDecisionService> (); foreach (var item in definitions.DrgElement) { if (item is TDecisionService decision) { decisionDict.Add(decision.Name, decision); if (decision.Id != null) { decisionDict.Add(decision.Id, decision); } } } return(decisionDict, decisionDictById); }
public async Task <List <string> > Validate(TDefinitions definition) { var errorList = await DuplicateChecks(definition); return(errorList); }