예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void setup()
        {
            modelInstance = Cmmn.createEmptyModel();
            definitions   = modelInstance.newInstance(typeof(Definitions));
            definitions.TargetNamespace = "http://camunda.org/examples";
            modelInstance.Definitions   = definitions;

            caseDefinition = createElement(definitions, "aCaseDefinition", typeof(Case));
            casePlanModel  = createElement(caseDefinition, "aCasePlanModel", typeof(CasePlanModel));

            context = new CmmnHandlerContext();

            CaseDefinitionEntity caseDefinition = new CaseDefinitionEntity();

            caseDefinition.TaskDefinitions = new Dictionary <string, TaskDefinition>();
            context.CaseDefinition         = caseDefinition;

            ExpressionManager expressionManager = new ExpressionManager();

            context.ExpressionManager = expressionManager;

            DeploymentEntity deployment = new DeploymentEntity();

            deployment.Id      = "foo";
            context.Deployment = deployment;
        }
예제 #2
0
        protected internal virtual ISet <string> retrieveProcessKeysFromResources(IDictionary <string, ResourceEntity> resources)
        {
            ISet <string> keys = new HashSet <string>();

            foreach (ResourceEntity resource in resources.Values)
            {
                if (isBpmnResource(resource))
                {
                    MemoryStream      byteStream = new MemoryStream(resource.Bytes);
                    BpmnModelInstance model      = Bpmn.readModelFromStream(byteStream);
                    foreach (Process process in model.Definitions.getChildElementsByType(typeof(Process)))
                    {
                        keys.Add(process.Id);
                    }
                }
                else if (isCmmnResource(resource))
                {
                    MemoryStream      byteStream = new MemoryStream(resource.Bytes);
                    CmmnModelInstance model      = Cmmn.readModelFromStream(byteStream);
                    foreach (Case cmmnCase in model.Definitions.Cases)
                    {
                        keys.Add(cmmnCase.Id);
                    }
                }
            }

            return(keys);
        }
예제 #3
0
        public virtual DeploymentBuilder addModelInstance(string resourceName, CmmnModelInstance modelInstance)
        {
            ensureNotNull("modelInstance", modelInstance);

            validateResouceName(resourceName, CmmnDeployer.CMMN_RESOURCE_SUFFIXES);

            MemoryStream outputStream = new MemoryStream();

            Cmmn.writeModelToStream(outputStream, modelInstance);

            return(addBytes(resourceName, outputStream.toByteArray()));
        }
예제 #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void setup()
        {
            CmmnTransformer transformerWrapper = new CmmnTransformer(null, new DefaultCmmnElementHandlerRegistry(), null);

            transformer = new CmmnTransform(transformerWrapper);

            deployment    = new DeploymentEntity();
            deployment.Id = "aDeploymentId";

            transformer.Deployment = deployment;

            modelInstance = Cmmn.createEmptyModel();
            definitions   = modelInstance.newInstance(typeof(Definitions));
            definitions.TargetNamespace = "http://camunda.org/examples";
            modelInstance.Definitions   = definitions;

            caseDefinition = createElement(definitions, "aCaseDefinition", typeof(Case));
            casePlanModel  = createElement(caseDefinition, "aCasePlanModel", typeof(CasePlanModel));
        }
예제 #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testRequiredRuleByDefaultPlanItemControl()
        public virtual void testRequiredRuleByDefaultPlanItemControl()
        {
            // given
            PlanItemControl     defaultControl = createElement(decisionTask, "ItemControl_1", typeof(DefaultControl));
            RequiredRule        requiredRule   = createElement(defaultControl, "RequiredRule_1", typeof(RequiredRule));
            ConditionExpression expression     = createElement(requiredRule, "Expression_1", typeof(ConditionExpression));

            expression.Text = "${true}";

            Cmmn.validateModel(modelInstance);

            // when
            CmmnActivity newActivity = handler.handleElement(planItem, context);

            // then
            object rule = newActivity.getProperty(PROPERTY_REQUIRED_RULE);

            assertNotNull(rule);
            assertTrue(rule is CaseControlRule);
        }
예제 #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testManualActivationRule()
        public virtual void testManualActivationRule()
        {
            // given
            ItemControl          itemControl          = createElement(planItem, "ItemControl_1", typeof(ItemControl));
            ManualActivationRule manualActivationRule = createElement(itemControl, "ManualActivationRule_1", typeof(ManualActivationRule));
            ConditionExpression  expression           = createElement(manualActivationRule, "Expression_1", typeof(ConditionExpression));

            expression.Text = "${true}";

            Cmmn.validateModel(modelInstance);

            // when
            CmmnActivity newActivity = handler.handleElement(planItem, context);

            // then
            object rule = newActivity.getProperty(PROPERTY_MANUAL_ACTIVATION_RULE);

            assertNotNull(rule);
            assertTrue(rule is CaseControlRule);
        }
예제 #7
0
        public virtual IList <CaseDefinitionEntity> transform()
        {
            // get name of resource
            string resourceName = resource_Renamed.Name;

            // create an input stream
            sbyte[]      bytes       = resource_Renamed.Bytes;
            MemoryStream inputStream = new MemoryStream(bytes);

            try
            {
                // read input stream
                model = Cmmn.readModelFromStream(inputStream);
            }
            catch (CmmnModelException e)
            {
                throw LOG.transformResourceException(resourceName, e);
            }

            // TODO: use model API to validate (ie.
            // semantic and execution validation) model

            context.Model             = model;
            context.Deployment        = deployment_Renamed;
            context.ExpressionManager = expressionManager;

            try
            {
                transformRootElement();
            }
            catch (Exception e)
            {
                // ALL unexpected exceptions should bubble up since they are not handled
                // accordingly by underlying parse-methods and the process can't be deployed
                throw LOG.parseProcessException(resourceName, e);
            }

            return(caseDefinitions);
        }
예제 #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testDeployEmptyCaseDefinition() throws Exception
        public virtual void testDeployEmptyCaseDefinition()
        {
            // given empty case model
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.model.cmmn.CmmnModelInstance modelInstance = org.camunda.bpm.model.cmmn.Cmmn.createEmptyModel();
            CmmnModelInstance modelInstance = Cmmn.createEmptyModel();

            org.camunda.bpm.model.cmmn.instance.Definitions definitions = modelInstance.newInstance(typeof(org.camunda.bpm.model.cmmn.instance.Definitions));
            definitions.TargetNamespace = "http://camunda.org/examples";
            modelInstance.Definitions   = definitions;

            // when case model is deployed
            DeploymentWithDefinitions deployment = repositoryService.createDeployment().addModelInstance("foo.cmmn", modelInstance).deployWithResult();

            deploymentIds.Add(deployment.Id);

            // then no case definition is deployed
            assertNull(deployment.DeployedCaseDefinitions);

            // and there exist not persisted case definition
            assertNull(repositoryService.createCaseDefinitionQuery().caseDefinitionResourceName("foo.cmmn").singleResult());
        }
예제 #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testRepetitionRuleStandardEventsByDefaultPlanItemControl()
        public virtual void testRepetitionRuleStandardEventsByDefaultPlanItemControl()
        {
            // given
            PlanItemControl     defaultControl = createElement(decisionTask, "DefaultControl_1", typeof(DefaultControl));
            RepetitionRule      repetitionRule = createElement(defaultControl, "RepititionRule_1", typeof(RepetitionRule));
            ConditionExpression expression     = createElement(repetitionRule, "Expression_1", typeof(ConditionExpression));

            expression.Text = "${true}";

            Cmmn.validateModel(modelInstance);

            // when
            CmmnActivity newActivity = handler.handleElement(planItem, context);

            // then
            IList <string> events = newActivity.Properties.get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);

            assertNotNull(events);
            assertEquals(2, events.Count);
            assertTrue(events.Contains([email protected]_Fields.COMPLETE));
            assertTrue(events.Contains([email protected]_Fields.TERMINATE));
        }
예제 #10
0
        protected internal static CmmnModelInstance createCmmnModelInstance()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.model.cmmn.CmmnModelInstance modelInstance = org.camunda.bpm.model.cmmn.Cmmn.createEmptyModel();
            CmmnModelInstance modelInstance = Cmmn.createEmptyModel();

            org.camunda.bpm.model.cmmn.instance.Definitions definitions = modelInstance.newInstance(typeof(org.camunda.bpm.model.cmmn.instance.Definitions));
            definitions.TargetNamespace = "http://camunda.org/examples";
            modelInstance.Definitions   = definitions;

            Case caseElement = modelInstance.newInstance(typeof(Case));

            caseElement.Id = "a-case";
            definitions.addChildElement(caseElement);

            CasePlanModel casePlanModel = modelInstance.newInstance(typeof(CasePlanModel));

            caseElement.CasePlanModel = casePlanModel;

            Cmmn.writeModelToStream(System.out, modelInstance);

            return(modelInstance);
        }
예제 #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testRepetitionRuleCustomStandardEvents()
        public virtual void testRepetitionRuleCustomStandardEvents()
        {
            // given
            ItemControl         itemControl    = createElement(planItem, "ItemControl_1", typeof(ItemControl));
            RepetitionRule      repetitionRule = createElement(itemControl, "RepititionRule_1", typeof(RepetitionRule));
            ConditionExpression expression     = createElement(repetitionRule, "Expression_1", typeof(ConditionExpression));

            expression.Text = "${true}";

            repetitionRule.CamundaRepeatOnStandardEvent = [email protected]_Fields.DISABLE;

            Cmmn.validateModel(modelInstance);

            // when
            CmmnActivity newActivity = handler.handleElement(planItem, context);

            // then
            IList <string> events = newActivity.Properties.get(CmmnProperties.REPEAT_ON_STANDARD_EVENTS);

            assertNotNull(events);
            assertEquals(1, events.Count);
            assertTrue(events.Contains([email protected]_Fields.DISABLE));
        }
예제 #12
0
        protected internal virtual IList <CaseDefinitionEntity> transform()
        {
            // convert the model to the XML string representation
            Stream outputStream = new MemoryStream();

            Cmmn.writeModelToStream(outputStream, modelInstance);
            Stream inputStream = IoUtil.convertOutputStreamToInputStream(outputStream);

            sbyte[] model = org.camunda.bpm.engine.impl.util.IoUtil.readInputStream(inputStream, "model");

            ResourceEntity resource = new ResourceEntity();

            resource.Bytes = model;
            resource.Name  = "test";

            transformer.Resource = resource;
            IList <CaseDefinitionEntity> definitions = transformer.transform();

            IoUtil.closeSilently(outputStream);
            IoUtil.closeSilently(inputStream);

            return(definitions);
        }
예제 #13
0
 protected internal override CmmnModelInstance readModelFromStream(Stream cmmnResourceInputStream)
 {
     return(Cmmn.readModelFromStream(cmmnResourceInputStream));
 }