protected internal virtual string DoConvertToString(IDmnModelInstance modelInstance) { // validate DOM document DoValidateModel(modelInstance); // convert to XML string return(IoUtil.ConvertXmlDocumentToString(modelInstance.Document)); }
public virtual void testRepositoryService() { string decisionDefinitionId = repositoryService.CreateDecisionDefinitionQuery(c => c.Key == DECISION_KEY).First().Id; IDmnModelInstance modelInstance = repositoryService.GetDmnModelInstance(decisionDefinitionId); Assert.NotNull(modelInstance); var decisions = modelInstance.GetModelElementsByType <IDecision>(typeof(IDecision)); Assert.AreEqual(1, decisions.Count()); var decisionTables = modelInstance.GetModelElementsByType <IDecisionTable>(typeof(IDecisionTable)); Assert.AreEqual(1, decisionTables.Count()); var inputs = modelInstance.GetModelElementsByType <IInput>(typeof(IInput)); Assert.AreEqual(1, inputs.Count()); var outputs = modelInstance.GetModelElementsByType <IOutput>(typeof(IOutput)); Assert.AreEqual(1, outputs.Count()); var rules = modelInstance.GetModelElementsByType <IRule>(typeof(IRule)); Assert.AreEqual(2, rules.Count()); }
public virtual IDmnDecisionRequirementsGraph ParseDecisionRequirementsGraph(IDmnModelInstance dmnModelInstance) { EnsureUtil.EnsureNotNull("dmnModelInstance", dmnModelInstance); return (transformer.createTransform() .modelInstance(dmnModelInstance) .transformDecisionRequirementsGraph <IDmnDecisionRequirementsGraph>()); }
public virtual void getDmnModelInstanceDisabledTenantCheck() { processEngineConfiguration.SetTenantCheckEnabled(false); identityService.SetAuthentication("user", null, null); IDmnModelInstance modelInstance = repositoryService.GetDmnModelInstance(decisionDefinitionId); Assert.That(modelInstance != null); }
public virtual IDeploymentBuilder AddModelInstance(string resourceName, IDmnModelInstance modelInstance) { EnsureUtil.EnsureNotNull("modelInstance", modelInstance); var outputStream = new MemoryStream(); Model.Dmn.Dmn.WriteModelToStream(outputStream, modelInstance); return(AddBytes(resourceName, outputStream.ToArray())); }
public virtual void getDmnModelInstanceWithAuthenticatedTenant() { identityService.SetAuthentication("user", null, new List <string>() { TENANT_ONE }); IDmnModelInstance modelInstance = repositoryService.GetDmnModelInstance(decisionDefinitionId); Assert.That(modelInstance != null); }
public virtual void SetModelInstance(string file) { EnsureUtil.EnsureNotNull("file", file); try { modelInstance_Renamed = Model.Dmn.Dmn.ReadModelFromFile(file); } catch (DmnModelException e) { throw LOG.UnableToTransformDecisionsFromFile(file, e); } }
public virtual void SetModelInstance(Stream inputStream) { EnsureUtil.EnsureNotNull("inputStream", inputStream); try { modelInstance_Renamed = Model.Dmn.Dmn.ReadModelFromStream(inputStream); } catch (DmnModelException e) { throw LOG.UnableToTransformDecisionsFromInputStream(e); } }
public virtual void testGetDmnModelInstance() { // given string decisionDefinitionId = selectDecisionDefinitionByKey(DECISION_DEFINITION_KEY).Id; createGrantAuthorization(Resources.DecisionDefinition, DECISION_DEFINITION_KEY, userId, Permissions.Read); // when IDmnModelInstance modelInstance = repositoryService.GetDmnModelInstance(decisionDefinitionId); // then Assert.NotNull(modelInstance); }
public virtual IDmnDecisionResult EvaluateDecision(string decisionKey, IDmnModelInstance dmnModelInstance, IVariableContext variableContext) { EnsureUtil.EnsureNotNull("decisionKey", decisionKey); var decisions = ParseDecisions(dmnModelInstance); foreach (var decision in decisions) { if (decisionKey.Equals(decision.Key)) { return(EvaluateDecision(decision, variableContext)); } } throw LOG.unableToFindDecisionWithKey(decisionKey); }
public virtual IDmnDecision ParseDecision(string decisionKey, IDmnModelInstance dmnModelInstance) { EnsureUtil.EnsureNotNull("decisionKey", decisionKey); var decisions = ParseDecisions(dmnModelInstance); foreach (var decision in decisions) { if (decisionKey.Equals(decision.Key)) { return(decision); } } //return null; throw LOG.unableToFindDecisionWithKey(decisionKey); }
protected internal virtual void DoWriteModelToFile(string file, IDmnModelInstance modelInstance) { System.IO.Stream os = null; try { os = new System.IO.FileStream(file, System.IO.FileMode.Create, System.IO.FileAccess.Write); DoWriteModelToOutputStream(os, modelInstance); } catch (FileNotFoundException) { throw new DmnModelException("Cannot write model to file " + file + ": file does not exist."); } finally { os.Dispose(); } }
protected internal virtual void DoValidateModel(IDmnModelInstance modelInstance) { _dmnParser.ValidateModel(modelInstance.Document); }
public virtual IDmnTransform modelInstance(IDmnModelInstance modelInstance) { SetModelInstance(modelInstance); return(this); }
public virtual void SetModelInstance(IDmnModelInstance modelInstance) { EnsureUtil.EnsureNotNull("dmnModelInstance", modelInstance); modelInstance_Renamed = modelInstance; }
public virtual IDmnDecisionResult EvaluateDecision(string decisionKey, IDmnModelInstance dmnModelInstance, IDictionary <string, ITypedValue> variables) { EnsureUtil.EnsureNotNull("variables", variables); return(EvaluateDecision(decisionKey, dmnModelInstance, Variables.FromMap(variables).AsVariableContext())); }
/// <summary> /// Allows the conversion of a <seealso cref="IDmnModelInstance"/> to an <seealso cref="String"/>. It will /// be validated before conversion. /// </summary> /// <param name="modelInstance"> the model instance to convert </param> /// <returns> the XML string representation of the model instance </returns> public static string ConvertToString(IDmnModelInstance modelInstance) { return(Instance.DoConvertToString(modelInstance)); }
/// <summary> /// Allows writing a <seealso cref="IDmnModelInstance"/> to an <seealso cref="OutputStream"/>. It will be /// validated before writing. /// </summary> /// <param name="stream"> the <seealso cref="OutputStream"/> to write the <seealso cref="IDmnModelInstance"/> to </param> /// <param name="modelInstance"> the <seealso cref="IDmnModelInstance"/> to write </param> /// <exception cref="ModelException"> if the model cannot be written </exception> /// <exception cref="ModelValidationException"> if the model is not valid </exception> public static void WriteModelToStream(System.IO.Stream stream, IDmnModelInstance modelInstance) { Instance.DoWriteModelToOutputStream(stream, modelInstance); }
/// <summary> /// Allows writing a <seealso cref="IDmnModelInstance"/> to a File. It will be /// validated before writing. /// </summary> /// <param name="file"> the <seealso cref="File"/> to write the <seealso cref="IDmnModelInstance"/> to </param> /// <param name="modelInstance"> the <seealso cref="IDmnModelInstance"/> to write </param> /// <exception cref="DmnModelException"> if the model cannot be written </exception> /// <exception cref="ModelValidationException"> if the model is not valid </exception> public static void WriteModelToFile(string file, IDmnModelInstance modelInstance) { Instance.DoWriteModelToFile(file, modelInstance); }
public virtual IList <IDmnDecision> ParseDecisions(IDmnModelInstance dmnModelInstance) { EnsureUtil.EnsureNotNull("dmnModelInstance", dmnModelInstance); return(transformer.createTransform().modelInstance(dmnModelInstance).transformDecisions <IDmnDecision>()); }
protected internal virtual void DoWriteModelToOutputStream(System.IO.Stream os, IDmnModelInstance modelInstance) { // validate DOM document DoValidateModel(modelInstance); // write XML IoUtil.WriteDocumentToOutputStream(modelInstance.Document, os); }
/// <summary> /// Validate model DOM document /// </summary> /// <param name="modelInstance"> the <seealso cref="IDmnModelInstance"/> to validate </param> /// <exception cref="ModelValidationException"> if the model is not valid </exception> public static void ValidateModel(IDmnModelInstance modelInstance) { Instance.DoValidateModel(modelInstance); }