12 |
13 |
14 |
15 | IBM
16 | 10
17 | 100
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/test/resources/rule-engine-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/features/service/org.wso2.carbon.rule.service.server.feature/resources/conf/rule-engine-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/features/mediation/org.wso2.carbon.rule.mediation.server.feature/resources/conf/rule-engine-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | carbon-rules
2 | ============
3 |
4 | This project contains the modules implementing Business Rules integration layer for WSO2 Business Rules Server Product.
5 | The project structure consist of service-stubs, components and features.
6 |
7 | In the service-stubs section, services providing admin service API's and their respective clients are implemented.
8 |
9 | In the components section, components corresponding to following functionality are available.
10 |
11 | 1. Rule Engine - Drools rule engine integration and JAVA built-in JSR-94 implementation layer and UI
12 | 2. Mediation- Rule Mediator
13 | 3. Rule Service - Exposing rule implementation as a web service
14 |
15 | In the features section , these individual components are packaged into features as application deployer , mediation and service.
16 |
--------------------------------------------------------------------------------
/issue_template.md:
--------------------------------------------------------------------------------
1 | **Description:**
2 |
3 |
4 | **Suggested Labels:**
5 |
6 |
7 | **Suggested Assignees:**
8 |
9 |
10 | **Affected Product Version:**
11 |
12 | **OS, DB, other environment details and versions:**
13 |
14 | **Steps to reproduce:**
15 |
16 |
17 | **Related Issues:**
18 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.mediation/src/test/resources/ruleMediator.xml:
--------------------------------------------------------------------------------
1 |
2 | soapBody|soapHeader|$foo|$bar
3 | soapBody|soapHeader|$foo|$bar
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
23 |
24 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/config/RuleEngineConfigService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package org.wso2.carbon.rule.kernel.config;
19 |
20 | public interface RuleEngineConfigService {
21 |
22 | public RuleEngineConfig getRuleConfig();
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws/src/main/java/org/wso2/carbon/rule/ws/internal/schema/DummyRuleService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.ws.internal.schema;
18 |
19 | /**
20 | * this is a dummy class used to trick a call for an axis2 schema generator.
21 | */
22 | public class DummyRuleService {
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.backend/src/test/java/samples/userguide/OrderReject.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package samples.userguide;
18 |
19 | public class OrderReject {
20 |
21 | private String reason;
22 |
23 | public String getReason() {
24 | return reason;
25 | }
26 |
27 | public void setReason(String reason) {
28 | this.reason = reason;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.ui/src/main/java/org/wso2/carbon/rule/ws/ui/Servicemanagement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.wso2.carbon.rule.ws.ui;
20 |
21 | public class Servicemanagement {
22 | }
23 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.backend/src/test/java/samples/userguide/OrderAccept.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package samples.userguide;
18 |
19 | public class OrderAccept {
20 |
21 | private String message;
22 |
23 | public String getMessage() {
24 | return message;
25 | }
26 |
27 | public void setMessage(String message) {
28 | this.message = message;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/test/java/org/wso2/carbon/rule/kernel/engine/DummyRuleSession.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.kernel.engine;
18 |
19 | import org.wso2.carbon.rule.kernel.backend.Session;
20 |
21 | import java.util.List;
22 |
23 | public class DummyRuleSession implements Session {
24 |
25 | public List execute(List facts) {
26 | return facts;
27 | }
28 |
29 | public void destroy() {
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/config/RuleEngineConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.kernel.config;
18 |
19 | public class RuleEngineConfig {
20 |
21 | private RuleEngineProvider ruleEngineProvider;
22 |
23 | public RuleEngineProvider getRuleEngineProvider() {
24 | return ruleEngineProvider;
25 | }
26 |
27 | public void setRuleEngineProvider(RuleEngineProvider ruleEngineProvider) {
28 | this.ruleEngineProvider = ruleEngineProvider;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/exception/RuleRuntimeException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.common.exception;
18 |
19 | public class RuleRuntimeException extends Exception{
20 |
21 | public RuleRuntimeException() {
22 | }
23 |
24 | public RuleRuntimeException(String message) {
25 | super(message);
26 | }
27 |
28 | public RuleRuntimeException(String message, Throwable cause) {
29 | super(message, cause);
30 | }
31 |
32 | public RuleRuntimeException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/exception/RuleConfigurationException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.common.exception;
18 |
19 | public class RuleConfigurationException extends Exception {
20 |
21 | public RuleConfigurationException() {
22 | }
23 |
24 | public RuleConfigurationException(String message) {
25 | super(message);
26 | }
27 |
28 | public RuleConfigurationException(String message, Throwable cause) {
29 | super(message, cause);
30 | }
31 |
32 | public RuleConfigurationException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.admin/src/main/java/org/wso2/carbon/rule/ws/admin/exception/RuleServiceAdminException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.ws.admin.exception;
18 |
19 | public class RuleServiceAdminException extends Exception {
20 |
21 | public RuleServiceAdminException() {
22 | }
23 |
24 | public RuleServiceAdminException(String message) {
25 | super(message);
26 | }
27 |
28 | public RuleServiceAdminException(String message, Throwable cause) {
29 | super(message, cause);
30 | }
31 |
32 | public RuleServiceAdminException(Throwable cause) {
33 | super(cause);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/test/java/org/wso2/carbon/rule/kernel/engine/DummyRuleBackendRuntimeFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.kernel.engine;
18 |
19 | import org.wso2.carbon.rule.kernel.backend.RuleBackendRuntimeFactory;
20 | import org.wso2.carbon.rule.kernel.backend.RuleBackendRuntime;
21 |
22 | import java.util.Map;
23 |
24 | public class DummyRuleBackendRuntimeFactory implements RuleBackendRuntimeFactory{
25 |
26 | public RuleBackendRuntime getRuleBackendRuntime(Map properties,
27 | ClassLoader classLoader) {
28 | return new DummyRuleBackendRuntime();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws/src/main/resources/META-INF/component.xml:
--------------------------------------------------------------------------------
1 |
18 |
19 |
20 |
21 | ruleservices
22 | aar
23 | org.wso2.carbon.rule.ws.deploy.RuleServiceDeployer
24 |
25 |
26 | ruleservices
27 | rsl
28 | org.wso2.carbon.rule.ws.deploy.RuleServiceDeployer
29 |
30 |
31 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.admin/src/main/java/org/wso2/carbon/rule/ws/admin/internal/config/RuleServiceHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.ws.admin.internal.config;
18 |
19 | import org.apache.axiom.om.OMElement;
20 | import org.wso2.carbon.rule.common.config.HelperUtil;
21 | import org.wso2.carbon.rule.common.util.Constants;
22 |
23 | public class RuleServiceHelper {
24 |
25 | public static RuleService getRuleService(OMElement ruleServiceElement){
26 | RuleService ruleService = new RuleService(ruleServiceElement);
27 | ruleService.setName(HelperUtil.getAttributeValue(ruleServiceElement, Constants.RULE_CONF_ATTR_NAME));
28 | return ruleService;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.mediation/src/main/java/org/wso2/carbon/rule/mediator/RuleMediatorSerializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.mediator;
18 |
19 | import org.apache.axiom.om.OMElement;
20 | import org.apache.synapse.Mediator;
21 | import org.apache.synapse.config.xml.AbstractMediatorSerializer;
22 |
23 | public class RuleMediatorSerializer extends AbstractMediatorSerializer {
24 |
25 | protected OMElement serializeSpecificMediator(Mediator mediator) {
26 | RuleMediator ruleMediator = (RuleMediator) mediator;
27 | return ruleMediator.getRuleOMElement();
28 | }
29 |
30 | public String getMediatorClassName() {
31 | return RuleMediator.class.getName();
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/rule_service/extra_config.jsp:
--------------------------------------------------------------------------------
1 |
18 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
19 | <%
20 | String serviceName = request.getParameter("serviceName");
21 | %>
22 |
23 |
24 |
29 |
30 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.backend/src/test/resources/test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | 23.4
7 | 23
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.backend/src/test/java/samples/userguide/PlaceOrder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package samples.userguide;
18 |
19 | public class PlaceOrder {
20 |
21 | String symbol;
22 | int quantity;
23 | double price;
24 |
25 | public String getSymbol() {
26 | return symbol;
27 | }
28 |
29 | public void setSymbol(String symbol) {
30 | this.symbol = symbol;
31 | }
32 |
33 | public int getQuantity() {
34 | return quantity;
35 | }
36 |
37 | public void setQuantity(int quantity) {
38 | this.quantity = quantity;
39 | }
40 |
41 | public double getPrice() {
42 | return price;
43 | }
44 |
45 | public void setPrice(double price) {
46 | this.price = price;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/resources/rule/always_ibm.xml:
--------------------------------------------------------------------------------
1 |
18 |
22 |
23 |
24 |
25 |
26 | symbol.equals("MSFT") || symbol.equals("SUN")
27 |
28 |
29 | update(drools.getWorkingMemory().getFactHandle(symbol),"IBM");
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/test/java/org/wso2/carbon/rule/kernel/engine/DummyRuleBackendRuntime.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.kernel.engine;
18 |
19 | import org.wso2.carbon.rule.kernel.backend.RuleBackendRuntime;
20 | import org.wso2.carbon.rule.kernel.backend.Session;
21 | import org.wso2.carbon.rule.common.exception.RuleConfigurationException;
22 | import org.wso2.carbon.rule.common.exception.RuleRuntimeException;
23 | import org.wso2.carbon.rule.common.RuleSet;
24 |
25 | public class DummyRuleBackendRuntime implements RuleBackendRuntime {
26 |
27 | public void addRuleSet(RuleSet ruleSet) throws RuleConfigurationException {
28 |
29 | }
30 |
31 | public Session createSession(int type) throws RuleRuntimeException {
32 | return new DummyRuleSession();
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/test/java/org/wso2/carbon/rule/kernel/engine/PlaceOrder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.kernel.engine;
18 |
19 | public class PlaceOrder {
20 |
21 | private String symbol;
22 | private int quantity;
23 | private double price;
24 |
25 | public String getSymbol() {
26 | return symbol;
27 | }
28 |
29 | public void setSymbol(String symbol) {
30 | this.symbol = symbol;
31 | }
32 |
33 | public int getQuantity() {
34 | return quantity;
35 | }
36 |
37 | public void setQuantity(int quantity) {
38 | this.quantity = quantity;
39 | }
40 |
41 | public double getPrice() {
42 | return price;
43 | }
44 |
45 | public void setPrice(double price) {
46 | this.price = price;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/internal/config/CarbonRuleEngineConfigService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package org.wso2.carbon.rule.kernel.internal.config;
19 |
20 | import org.wso2.carbon.rule.kernel.config.RuleEngineConfigService;
21 | import org.wso2.carbon.rule.kernel.config.RuleEngineConfig;
22 |
23 | /**
24 | * implementation object of the rule engine provider interface
25 | */
26 | public class CarbonRuleEngineConfigService implements RuleEngineConfigService {
27 |
28 | private RuleEngineConfig ruleEngineConfig;
29 |
30 | public CarbonRuleEngineConfigService(RuleEngineConfig ruleEngineConfig) {
31 | this.ruleEngineConfig = ruleEngineConfig;
32 | }
33 |
34 | public RuleEngineConfig getRuleConfig() {
35 | return this.ruleEngineConfig;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws/src/test/java/org/wso2/carbon/rule/ws/internal/schema/PlaceOrder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.ws.internal.schema;
18 |
19 | public class PlaceOrder {
20 |
21 | private String symbol;
22 | private int quantity;
23 | private double price;
24 |
25 | public String getSymbol() {
26 | return symbol;
27 | }
28 |
29 | public void setSymbol(String symbol) {
30 | this.symbol = symbol;
31 | }
32 |
33 | public int getQuantity() {
34 | return quantity;
35 | }
36 |
37 | public void setQuantity(int quantity) {
38 | this.quantity = quantity;
39 | }
40 |
41 | public double getPrice() {
42 | return price;
43 | }
44 |
45 | public void setPrice(double price) {
46 | this.price = price;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/test/java/org/wso2/carbon/rule/kernel/internal/util/PlaceOrder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.kernel.internal.util;
18 |
19 | public class PlaceOrder {
20 |
21 | private String symbol;
22 | private int quantity;
23 | private double price;
24 |
25 | public String getSymbol() {
26 | return symbol;
27 | }
28 |
29 | public void setSymbol(String symbol) {
30 | this.symbol = symbol;
31 | }
32 |
33 | public int getQuantity() {
34 | return quantity;
35 | }
36 |
37 | public void setQuantity(int quantity) {
38 | this.quantity = quantity;
39 | }
40 |
41 | public double getPrice() {
42 | return price;
43 | }
44 |
45 | public void setPrice(double price) {
46 | this.price = price;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.backend/src/main/resources/META-INF/kie.conf:
--------------------------------------------------------------------------------
1 | org.kie.api.KieServices = org.drools.compiler.kie.builder.impl.KieServicesImpl
2 | # org.kie.api.KieBase = org.drools.core.impl.KnowledgeBaseImpl
3 | ?org.kie.internal.builder.KnowledgeBuilderFactoryService = org.drools.compiler.builder.impl.KnowledgeBuilderFactoryServiceImpl
4 | ?org.kie.internal.builder.JaxbConfigurationFactoryService = org.drools.compiler.builder.impl.JaxbConfigurationFactoryServiceImpl
5 | org.drools.compiler.kie.builder.impl.KieBaseUpdaters = org.drools.compiler.kie.builder.impl.KieBaseUpdatersImpl
6 | # org.kie.api.io.KieResources = org.drools.core.io.impl.ResourceFactoryServiceImpl
7 | # org.kie.api.concurrent.KieExecutors = org.drools.core.concurrent.ExecutorProviderImpl
8 | # org.drools.compiler.rule.builder.ConstraintBuilder = org.drools.mvel.MVELConstraintBuilder
9 | # org.drools.core.base.CoreComponentsBuilder = org.drools.mvel.MVELCoreComponentsBuilder
10 | # org.drools.core.base.FieldAccessorFactory = org.drools.mvel.asm.ClassFieldAccessorFactory
11 | # org.drools.core.factmodel.ClassBuilderFactory = org.drools.mvel.asm.DefaultClassBuilderFactory
12 | # org.kie.api.internal.assembler.KieAssemblers = org.kie.internal.services.KieAssemblersImpl
13 | # org.kie.api.internal.runtime.KieRuntimes = org.kie.internal.services.KieRuntimesImpl
14 | # org.kie.api.internal.weaver.KieWeavers = org.kie.internal.services.KieWeaversImpl
15 | # org.kie.api.internal.runtime.beliefs.KieBeliefs = org.kie.internal.services.KieBeliefsImpl
16 |
17 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/org/wso2/carbon/rule/ws/ui/i18n/JSResources.properties:
--------------------------------------------------------------------------------
1 | service.rule.menu.text=Rule Service
2 | rule.fact.editor=Fact Editor
3 | property.editor=Property Editor
4 | rule.result.editor=Result Editor
5 | rule.facteditor.error=Error loading Fact Editor!!!
6 | property.editor.error=Error loading Property Editor!!!
7 | rule.action.delete=Delete
8 | error.occurred=Error calling operation delete ajax processor!!!
9 | resource.tree= Resource Tree
10 | resource.tree.loading= Resource Tree Loading
11 | ns.editor.waiting.text=Namespace editor loading please wait ..
12 | ns.editor.title=Namespace Editor
13 | ns.editor.load.error=Error in loading the Namespace Editor
14 | property.save.error=Error in saving properties
15 | ns.editor.delete.confirmation=Are you sure you want to delete the namespace permanently?
16 | ns.uri.empty=URI of the namespace is empty
17 | ns.prefix.empty=Prefix of the namespace is empty
18 | rule.ns.editor=NS Editor
19 | rule.namespaces=NameSpaces
20 | invalid.fact=Fact type is mandatory
21 | invalid.result=Result type is mandatory
22 | invalid.inputFact=Input Fact type is mandatory
23 | invalid.outputFact=Output Fact type is mandatory
24 | fact.type=Fact Type
25 | result.type=Result Type
26 | fact.delete.confirmation= Are you sure you want to delete the fact permanently?
27 | result.delete.confirmation= Are you sure you want to delete the result permanently?
28 | operation.delete.confirmation= Are you sure you want to delete the operation permanently?
29 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.samples/src/main/java/org/wso2/carbon/rule/samples/GetQuoteResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.wso2.carbon.rule.samples;
20 |
21 | /**
22 | *
23 | */
24 | public class GetQuoteResponse {
25 |
26 | private String symbol;
27 | private String last;
28 |
29 | public String getSymbol() {
30 | return symbol;
31 | }
32 |
33 | public void setSymbol(String symbol) {
34 | this.symbol = symbol;
35 | }
36 |
37 | public String getLast() {
38 | return last;
39 | }
40 |
41 | public void setLast(String last) {
42 | this.last = last;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/resources/rule/simple_rule_base.xml:
--------------------------------------------------------------------------------
1 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | symbol.equals("IBM")
30 |
31 |
32 | mc.setProperty("execute_children","true");
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.admin/src/main/java/org/wso2/carbon/rule/ws/admin/internal/config/RuleService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.ws.admin.internal.config;
18 |
19 | import org.apache.axiom.om.OMElement;
20 |
21 | import javax.xml.stream.XMLStreamException;
22 | import java.io.OutputStream;
23 |
24 | public class RuleService {
25 |
26 | private String name;
27 | private OMElement ruleServiceElemet;
28 |
29 | public RuleService(OMElement ruleServiceElemet) {
30 | this.ruleServiceElemet = ruleServiceElemet;
31 | }
32 |
33 | public void serialize(OutputStream outputStream) throws XMLStreamException {
34 | this.ruleServiceElemet.serialize(outputStream);
35 | }
36 |
37 | public String getName() {
38 | return name;
39 | }
40 |
41 | public void setName(String name) {
42 | this.name = name;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/op_delete-ajaxprocessor.jsp:
--------------------------------------------------------------------------------
1 |
18 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %>
19 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %>
20 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
21 | <%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
22 | <%
23 | RuleServiceAdminClient ruleServiceAdminClient =
24 | new RuleServiceAdminClient(config.getServletContext(), session);
25 | RuleService ruleService = ruleServiceAdminClient.getRuleServiceDescription(request);
26 |
27 | String name = request.getParameter("opname");
28 | if (name != null) {
29 | ruleService.removeOperation(name);
30 | }
31 | %>
32 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/config/RuleHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.common.config;
18 |
19 | import org.wso2.carbon.rule.common.Rule;
20 | import org.wso2.carbon.rule.common.util.Constants;
21 | import org.apache.axiom.om.OMElement;
22 |
23 | public class RuleHelper {
24 |
25 | public static Rule getRule(OMElement ruleElement){
26 | Rule rule = new Rule();
27 | rule.setResourceType(HelperUtil.getAttributeValue(
28 | ruleElement, Constants.RULE_CONF_ATTR_RESOURCE_TYPE));
29 | rule.setSourceType(HelperUtil.getAttributeValue(
30 | ruleElement, Constants.RULE_CONF_ATTR_SOURCE_TYPE));
31 | rule.setDescription(HelperUtil.getAttributeValue(
32 | ruleElement, Constants.RULE_CONF_ATTR_DESCRIPTION));
33 | rule.setValue(ruleElement.getText());
34 | return rule;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.admin/src/main/java/org/wso2/carbon/rule/ws/admin/Paths.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.wso2.carbon.rule.ws.admin;
20 |
21 | /**
22 | * Represent the service path and the working directory path for the service
23 | */
24 | public class Paths {
25 |
26 | private String servicePath;
27 | private String workingDirPath;
28 |
29 | public Paths(String servicePath, String workingDirPath) {
30 | this.servicePath = servicePath;
31 | this.workingDirPath = workingDirPath;
32 | }
33 |
34 | public String getServicePath() {
35 | return servicePath;
36 | }
37 |
38 | public String getWorkingDirPath() {
39 | return workingDirPath;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.samples/src/main/java/org/wso2/carbon/rule/samples/GetQuoteRequest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.wso2.carbon.rule.samples;
20 |
21 | /**
22 | *
23 | */
24 | public class GetQuoteRequest {
25 | private String symbol;
26 |
27 | public String getSymbol() {
28 | return symbol;
29 | }
30 |
31 | public void setSymbol(String symbol) {
32 | this.symbol = symbol;
33 | }
34 |
35 | public String toXML() {
36 | return "" +
37 | "" +
38 | "" + symbol + "" +
39 | "" +
40 | "";
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.ui/src/main/java/org/wso2/carbon/rule/ws/ui/RuleServiceClientException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.wso2.carbon.rule.ws.ui;
20 |
21 |
22 | /**
23 | * Acts as a decorator and do log in addition to the existing behaviour of the exception
24 | */
25 | public class RuleServiceClientException extends RuntimeException {
26 |
27 | public RuleServiceClientException() {
28 | }
29 |
30 | public RuleServiceClientException(String message) {
31 | super(message);
32 | }
33 |
34 | public RuleServiceClientException(String message, Throwable cause) {
35 | super(message, cause);
36 | }
37 |
38 | public RuleServiceClientException(Throwable cause) {
39 | super(cause);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/config/FactHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.common.config;
18 |
19 | import org.wso2.carbon.rule.common.Fact;
20 | import org.wso2.carbon.rule.common.util.Constants;
21 | import org.apache.axiom.om.OMElement;
22 |
23 | public class FactHelper {
24 |
25 | public static Fact getFact(OMElement factElement) {
26 |
27 | Fact fact = new Fact();
28 | fact.setType(HelperUtil.getAttributeValue(factElement, Constants.RULE_CONF_ATTR_TYPE));
29 | fact.setElementName(HelperUtil.getAttributeValue(factElement, Constants.RULE_CONF_ATTR_ELEMENT_NAME));
30 | fact.setNamespace(HelperUtil.getAttributeValue(factElement, Constants.RULE_CONF_ATTR_NAMESPACE));
31 | fact.setXpath(HelperUtil.getAttributeValue(factElement, Constants.RULE_CONF_ATTR_XPATH));
32 | fact.setPrefixToNamespaceMap(HelperUtil.getPrefixToNamespaceMap(factElement));
33 | return fact;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/test/resources/testService.rsl:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.ui/src/main/java/org/wso2/carbon/rule/ws/ui/ns/NameSpacesInformationRepositoryRegistrar.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.ws.ui.ns;
18 |
19 | import javax.servlet.http.HttpSession;
20 |
21 | /**
22 | * Register / un-register NameSpacesInformationRepository instances
23 | */
24 | public class NameSpacesInformationRepositoryRegistrar {
25 |
26 | public static void unRegisterNameSpacesInformationRepository(HttpSession httpSession) {
27 | httpSession.removeAttribute(
28 | NameSpacesInformationRepository.NAMESPACES_INFORMATION_REPOSITORY);
29 | }
30 |
31 | public static void registerNameSpacesInformationRepository(
32 | NameSpacesInformationRepository repository,
33 | HttpSession httpSession) {
34 | httpSession.setAttribute(
35 | NameSpacesInformationRepository.NAMESPACES_INFORMATION_REPOSITORY, repository);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/rule_delete_all_files-ajaxprocessor.jsp:
--------------------------------------------------------------------------------
1 |
18 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %>
19 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %>
20 | <%@ page import="java.util.*" %>
21 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
22 | <%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
23 | <%
24 | RuleServiceAdminClient ruleServiceAdminClient =
25 | new RuleServiceAdminClient(config.getServletContext(), session);
26 | RuleService ruleService = ruleServiceAdminClient.getRuleServiceDescription(request);
27 | Map scriptList = (Map) session.getAttribute(RuleServiceAdminClient.SCRIPTS);
28 | if(scriptList!=null && !scriptList.isEmpty()){
29 | ruleServiceAdminClient.deleteAllRuleFiles(ruleService, session);
30 |
31 | }
32 |
33 | %>
--------------------------------------------------------------------------------
/features/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 | org.wso2.carbon.rules
22 | carbon-rule
23 | 4.5.11-SNAPSHOT
24 | ../pom.xml
25 |
26 |
27 | 4.0.0
28 | rule-feature
29 | pom
30 | WSO2 Carbon - Rule Feature Aggregator Module
31 | http://wso2.org
32 |
33 |
34 | application-deployer/org.wso2.carbon.application.deployer.rule.feature
35 | service
36 | mediation
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.backend/src/main/java/org/wso2/carbon/rule/backend/internal/RuleServiceValueHolder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.backend.internal;
18 |
19 | import org.wso2.carbon.registry.core.exceptions.RegistryException;
20 | import org.wso2.carbon.registry.core.service.RegistryService;
21 |
22 | public class RuleServiceValueHolder {
23 | private RegistryService registryService;
24 | private static RuleServiceValueHolder ruleServiceValueHolder = new RuleServiceValueHolder();
25 |
26 |
27 | public static RuleServiceValueHolder getInstance() {
28 | return ruleServiceValueHolder;
29 | }
30 |
31 | public RegistryService getRegistryService() throws RegistryException {
32 | return registryService;
33 | }
34 |
35 | public void setRegistryService(RegistryService registryService) {
36 | this.registryService = registryService;
37 | }
38 |
39 | public void unsetRegistryService() {
40 | this.registryService = null;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/service-stubs/rule/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 | org.wso2.carbon.rules
23 | carbon-rule
24 | 4.5.11-SNAPSHOT
25 | ../../pom.xml
26 |
27 |
28 | 4.0.0
29 | rule-stubs
30 | pom
31 | WSO2 Carbon - Rule Service Stubs Parent Module
32 | WSO2 Carbon Service Management
33 | http://wso2.org
34 |
35 |
36 | org.wso2.carbon.rule.service.stub
37 | org.wso2.carbon.rule.ws.stub
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/resources/rule/commission_rule.xml:
--------------------------------------------------------------------------------
1 |
18 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | symbol.equals("MSFT") || symbol.equals("SUN")
31 |
32 |
33 |
34 | Double newPrice = price.doubleValue()+ 3000.68;
35 | update(drools.getWorkingMemory().getFactHandle(price),newPrice);
36 | retract(drools.getWorkingMemory().getFactHandle(symbol));
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/backend/Session.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.kernel.backend;
18 |
19 | import org.wso2.carbon.rule.common.exception.RuleRuntimeException;
20 |
21 | import java.util.List;
22 |
23 | /**
24 | * This interface abstracts the rule session concept. Backend can create a session according to the type requested.
25 | * Then session can execute the different fact sets.
26 | */
27 | public interface Session {
28 |
29 | /**
30 | * apply the rules to the given sent of facts and send the result facts back.
31 | * @param facts - list of facts given as POJOs to be executed against backend runtime
32 | * @return - list of facts after applying the rules
33 | * @throws RuleRuntimeException - if there is a problem occurs
34 | */
35 | public List execute(List facts) throws RuleRuntimeException;
36 |
37 | /**
38 | *
39 | * @throws RuleRuntimeException - if there is a problem occurs
40 | */
41 | public void destroy() throws RuleRuntimeException;
42 | }
43 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.mediation/src/main/java/org/wso2/carbon/rule/mediator/internal/config/SourceHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.mediator.internal.config;
18 |
19 | import org.wso2.carbon.rule.mediator.config.Source;
20 | import org.wso2.carbon.rule.common.config.HelperUtil;
21 | import org.wso2.carbon.rule.common.util.Constants;
22 | import org.apache.axiom.om.OMElement;
23 | import org.apache.axiom.om.OMNamespace;
24 |
25 | import java.util.Iterator;
26 | import java.util.Map;
27 | import java.util.HashMap;
28 |
29 | public class SourceHelper {
30 |
31 | public static Source getSource(OMElement sourceOMElement){
32 | Source source = new Source();
33 |
34 | if (sourceOMElement.getText() != null) {
35 | source.setValue(sourceOMElement.getText());
36 | }
37 | source.setXpath(HelperUtil.getAttributeValue(sourceOMElement,
38 | Constants.RULE_CONF_ATTR_XPATH));
39 | source.setPrefixToNamespaceMap(HelperUtil.getPrefixToNamespaceMap(sourceOMElement));
40 | return source;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/backend/RuleBackendRuntimeFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.kernel.backend;
18 |
19 | import org.wso2.carbon.rule.common.exception.RuleConfigurationException;
20 |
21 | import java.util.Map;
22 |
23 | /**
24 | * Factory interface to create the real back end runtimes.
25 | */
26 | public interface RuleBackendRuntimeFactory {
27 |
28 | /**
29 | * This interface is used to create the Back end runtimes in different types. We use a factory to pass properties
30 | * and other backend specific things so that the factory and take care of creating the real runtimes.
31 | * @param properties - backend runtime properties
32 | * @param classLoader - class loader to be used to load the classes
33 | * @return - back end runtime object corresponding to the given factory
34 | */
35 | public RuleBackendRuntime getRuleBackendRuntime(Map properties,
36 | ClassLoader classLoader) throws RuleConfigurationException;
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws/src/test/java/org/wso2/carbon/rule/ws/internal/config/TestRuleServiceHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.ws.internal.config;
18 |
19 | import junit.framework.TestCase;
20 | import org.apache.axiom.om.impl.builder.StAXOMBuilder;
21 | import org.wso2.carbon.rule.common.RuleService;
22 | import org.wso2.carbon.rule.common.config.RuleServiceHelper;
23 | import org.wso2.carbon.rule.common.exception.RuleConfigurationException;
24 |
25 | import javax.xml.stream.XMLStreamException;
26 |
27 | public class TestRuleServiceHelper extends TestCase {
28 |
29 | public void testGetRuleService(){
30 |
31 | try {
32 | StAXOMBuilder stAXOMBuilder =
33 | new StAXOMBuilder(this.getClass().getResourceAsStream("/placeOrder.rsl"));
34 | RuleService ruleService =
35 | RuleServiceHelper.getRuleService(stAXOMBuilder.getDocumentElement());
36 | System.out.println("OK");
37 |
38 | } catch (XMLStreamException e) {
39 | e.printStackTrace();
40 | } catch (RuleConfigurationException e) {
41 | e.printStackTrace();
42 | }
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/fact_archive_delete-ajaxprocessor.jsp:
--------------------------------------------------------------------------------
1 |
18 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %>
19 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %>
20 | <%@ page import="java.util.ArrayList" %>
21 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
22 | <%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
23 | <%
24 | RuleServiceAdminClient ruleServiceAdminClient =
25 | new RuleServiceAdminClient(config.getServletContext(), session);
26 | RuleService ruleService = ruleServiceAdminClient.getRuleServiceDescription(request);
27 | String filename = request.getParameter("factArchiveName");
28 | if (filename != null) {
29 | ruleServiceAdminClient.deleteFactArchive(ruleService,filename, session);
30 | ArrayList factArchiveList = (ArrayList) session.getAttribute(RuleServiceAdminClient.FACTS);
31 | factArchiveList.remove(filename);
32 | session.setAttribute(RuleServiceAdminClient.FACTS, factArchiveList);
33 | }
34 | %>
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/internal/event/RuleChangeEventDispacher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.kernel.internal.event;
18 |
19 | import org.wso2.carbon.event.core.subscription.EventDispatcher;
20 | import org.wso2.carbon.event.core.subscription.Subscription;
21 | import org.wso2.carbon.event.core.Message;
22 | import org.wso2.carbon.rule.kernel.engine.RuleEngine;
23 | import org.wso2.carbon.rule.common.exception.RuleConfigurationException;
24 | import org.apache.commons.logging.Log;
25 | import org.apache.commons.logging.LogFactory;
26 |
27 | public class RuleChangeEventDispacher implements EventDispatcher{
28 |
29 | private static Log log = LogFactory.getLog(RuleChangeEventDispacher.class);
30 |
31 | private RuleEngine ruleEngine;
32 |
33 | public RuleChangeEventDispacher(RuleEngine ruleEngine) {
34 | this.ruleEngine = ruleEngine;
35 | }
36 |
37 | public void notify(Message message, Subscription subscription) {
38 | try {
39 | this.ruleEngine.loadRuleBackendRuntime();
40 | } catch (RuleConfigurationException e) {
41 | log.error("Can not refresh the rule set ", e);
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.samples/src/main/java/org/wso2/carbon/rule/samples/CheckPriceResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.wso2.carbon.rule.samples;
20 |
21 | /**
22 | *
23 | */
24 | public class CheckPriceResponse {
25 | private String code;
26 | private Double price;
27 |
28 | public String getCode() {
29 | return code;
30 | }
31 |
32 | public void setCode(String code) {
33 | this.code = code;
34 | }
35 |
36 | public Double getPrice() {
37 | return price;
38 | }
39 |
40 | public void setPrice(Double price) {
41 | this.price = price;
42 | }
43 |
44 | public String toXML() {
45 | return "" +
47 | "" + code + "" +
48 | "" + price + "" +
49 | "";
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/config/RuleEngineProvider.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 |
18 | package org.wso2.carbon.rule.kernel.config;
19 |
20 | import java.util.Map;
21 | import java.util.HashMap;
22 |
23 | /**
24 | * class to represents the rule engine provider.
25 | */
26 | public class RuleEngineProvider {
27 |
28 | /**
29 | * factory class name with implements the back end runtime.
30 | */
31 | private String className;
32 |
33 | /**
34 | * other properties of the engine provider
35 | */
36 | private Map properties;
37 |
38 | public RuleEngineProvider() {
39 | this.properties = new HashMap();
40 | }
41 |
42 | public void addProperty(String name, String value){
43 | this.properties.put(name, value);
44 | }
45 |
46 | public String getClassName() {
47 | return className;
48 | }
49 |
50 | public void setClassName(String className) {
51 | this.className = className;
52 | }
53 |
54 | public Map getProperties() {
55 | return properties;
56 | }
57 |
58 | public void setProperties(Map properties) {
59 | this.properties = properties;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/components/rule/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 | org.wso2.carbon.rules
21 | carbon-rule
22 | 4.5.11-SNAPSHOT
23 | ../../pom.xml
24 |
25 |
26 | 4.0.0
27 | rule
28 | pom
29 | WSO2 Carbon - Rule Aggregator Module
30 | http://wso2.org
31 |
32 |
33 | org.wso2.carbon.application.deployer.rule
34 | org.wso2.carbon.rule.common
35 | org.wso2.carbon.rule.ws
36 | org.wso2.carbon.rule.kernel
37 | org.wso2.carbon.rule.backend
38 | org.wso2.carbon.rule.ws.admin
39 | org.wso2.carbon.rule.ws.ui
40 | org.wso2.carbon.rule.mediation
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.backend/src/main/java/org/wso2/carbon/rule/backend/drools/DroolsBackendRuntimeFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.backend.drools;
18 |
19 | import org.kie.api.KieServices;
20 | import org.kie.api.builder.KieFileSystem;
21 | import org.wso2.carbon.rule.kernel.backend.RuleBackendRuntime;
22 | import org.wso2.carbon.rule.kernel.backend.RuleBackendRuntimeFactory;
23 |
24 | import java.util.Map;
25 | import java.util.Properties;
26 |
27 | public class DroolsBackendRuntimeFactory implements RuleBackendRuntimeFactory {
28 |
29 | public RuleBackendRuntime getRuleBackendRuntime(Map properties,
30 | ClassLoader classLoader) {
31 |
32 | ClassLoader existingClassLoader = Thread.currentThread().getContextClassLoader();
33 | try {
34 | Thread.currentThread().setContextClassLoader(classLoader);
35 |
36 | KieServices kieServices = KieServices.Factory.get();
37 | KieFileSystem kieFileSystem = kieServices.newKieFileSystem();
38 | return new DroolsBackendRuntime(kieServices, kieFileSystem , classLoader);
39 | } finally {
40 | Thread.currentThread().setContextClassLoader(existingClassLoader);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.backend/src/test/resources/OrderApproval.drl:
--------------------------------------------------------------------------------
1 | package OrderApproval;
2 |
3 | import samples.userguide.OrderAccept;
4 | import samples.userguide.OrderReject;
5 | import samples.userguide.PlaceOrder;
6 |
7 | rule "Order Approval Rule" dialect "mvel" no-loop true salience 4
8 |
9 | when
10 | $placeOrder : PlaceOrder( ( symbol == "IBM" && quantity > 10 ) || ( symbol == "SUN" && price > 100 ) || ( symbol == "MSFT" && price > 50 && quantity < 200 ) )
11 | then
12 |
13 | OrderAccept orderAccept = new OrderAccept();
14 | orderAccept.setMessage("Accepted order for: "+ $placeOrder.quantity + " stocks of "+
15 | $placeOrder.symbol +" at$ " + $placeOrder.price);
16 | insertLogical(orderAccept);
17 |
18 | end
19 |
20 | rule "IBM Order Deny Rule" dialect "mvel" no-loop true salience 3
21 |
22 | when
23 | not ( OrderAccept())
24 | $placeOrder : PlaceOrder( symbol == "IBM" )
25 | then
26 | retract($placeOrder);
27 | OrderReject orderReject = new OrderReject();
28 | orderReject.setReason("An Order for stocks of IBM is accepted only if the number of stocks is higher than 10.");
29 | insertLogical(orderReject);
30 | end
31 |
32 | rule "SUN Order Deny Rule" dialect "mvel" no-loop true salience 2
33 | when
34 | not ( OrderAccept())
35 | $placeOrder : PlaceOrder( symbol == "SUN" )
36 | then
37 | retract($placeOrder);
38 | OrderReject orderReject = new OrderReject();
39 | orderReject.setReason("An Order for stocks of SUN is accepted only if the stock price is higher than 100 $.");
40 | insertLogical(orderReject);
41 | end
42 |
43 | rule "MSFT Order Deny Rule" dialect "mvel" no-loop true salience 1
44 | when
45 | not ( OrderAccept())
46 | $placeOrder : PlaceOrder( symbol == "MSFT" )
47 | then
48 | retract($placeOrder);
49 | OrderReject orderReject = new OrderReject();
50 | orderReject.setReason("An Order for stocks of MSFT is accepted only if the stock price is higher than 50 $ and the number of stocks is lower than 200.");
51 | insertLogical(orderReject);
52 | end
53 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.mediation/src/main/java/org/wso2/carbon/rule/mediator/internal/config/TargetHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.mediator.internal.config;
18 |
19 | import org.wso2.carbon.rule.mediator.config.Target;
20 | import org.wso2.carbon.rule.common.config.HelperUtil;
21 | import org.wso2.carbon.rule.common.util.Constants;
22 | import org.apache.axiom.om.OMElement;
23 |
24 | public class TargetHelper {
25 |
26 | public static Target getTarget(OMElement targetOMElement){
27 | Target target = new Target();
28 |
29 | if (targetOMElement.getText() != null){
30 | target.setValue(targetOMElement.getText());
31 | }
32 |
33 | target.setXpath(HelperUtil.getAttributeValue(targetOMElement,
34 | Constants.RULE_CONF_ATTR_XPATH));
35 | target.setResultXpath(HelperUtil.getAttributeValue(targetOMElement,
36 | Constants.RULE_CONF_ATTR_RESULT_XPATH));
37 | target.setAction(HelperUtil.getAttributeValue(targetOMElement,
38 | Constants.RULE_CONF_ATTR_ACTION));
39 | target.setPrefixToNamespaceMap(HelperUtil.getPrefixToNamespaceMap(targetOMElement));
40 | return target;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/config/OperationHelper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.common.config;
18 |
19 | import org.apache.axiom.om.OMElement;
20 | import org.wso2.carbon.rule.common.Operation;
21 | import org.wso2.carbon.rule.common.util.Constants;
22 |
23 | import javax.xml.namespace.QName;
24 |
25 | public class OperationHelper {
26 |
27 | public static Operation getOperation(OMElement operationElement){
28 | Operation operation = new Operation();
29 |
30 | operation.setName(HelperUtil.getAttributeValue(
31 | operationElement, Constants.RULE_CONF_ATTR_NAME));
32 |
33 | OMElement inputOMElement =
34 | operationElement.getFirstChildWithName(new QName(
35 | Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_INPUT));
36 |
37 | operation.setInput(InputHelper.getInput(inputOMElement));
38 |
39 | OMElement outputElement =
40 | operationElement.getFirstChildWithName(new QName(
41 | Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_OUTPUT));
42 | if(outputElement != null){
43 |
44 | operation.setOutput(OutputHelper.getOutput(outputElement));
45 | }
46 |
47 | return operation;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/rule_script_add-ajaxprocessor.jsp:
--------------------------------------------------------------------------------
1 |
18 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %>
19 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %>
20 | <%@ page import="java.util.*" %>
21 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
22 | <%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
23 | <%
24 | RuleServiceAdminClient ruleServiceAdminClient =
25 | new RuleServiceAdminClient(config.getServletContext(), session);
26 | RuleService ruleService = ruleServiceAdminClient.getRuleServiceDescription(request);
27 | String scriptValue = request.getParameter("scriptValue");
28 | String scriptSourceType = request.getParameter("scriptSourceType");
29 |
30 | if(scriptValue != null && !scriptValue.equals("")){
31 | Map scriptList = (Map) session.getAttribute(RuleServiceAdminClient.SCRIPTS);
32 | if(scriptList == null){
33 | scriptList = new HashMap();
34 | }
35 | scriptList.put(scriptValue, scriptSourceType);
36 | session.setAttribute(RuleServiceAdminClient.SCRIPTS, scriptList);
37 |
38 |
39 | }
40 |
41 | %>
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws/src/main/java/org/wso2/carbon/rule/ws/internal/schema/RuleSchemaGenerator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.ws.internal.schema;
18 |
19 | import org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator;
20 | import org.apache.axis2.description.AxisService;
21 | import org.apache.ws.commons.schema.XmlSchema;
22 |
23 | import javax.xml.namespace.QName;
24 | import java.util.List;
25 | import java.util.ArrayList;
26 |
27 | /**
28 | * this class orverrides some methods of the axis2 schema generator.
29 | */
30 | public class RuleSchemaGenerator extends DefaultSchemaGenerator {
31 |
32 | public RuleSchemaGenerator(ClassLoader classLoader,
33 | AxisService axisService) throws Exception {
34 | super(classLoader, DummyRuleService.class.getName(), null, null, axisService);
35 | }
36 |
37 | public QName generateSchema(Class> aClass) throws Exception {
38 | return super.generateSchema(aClass);
39 | }
40 |
41 | public XmlSchema getXmlSchema(String targetNamespace) {
42 | return super.getXmlSchema(targetNamespace);
43 | }
44 |
45 | public List getSchemaList(){
46 | List schemas = new ArrayList();
47 | schemas.addAll(this.schemaMap.values());
48 | return schemas;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/rule_file_delete-ajaxprocessor.jsp:
--------------------------------------------------------------------------------
1 |
18 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %>
19 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %>
20 | <%@ page import="java.util.*" %>
21 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
22 | <%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %>
23 | <%
24 | RuleServiceAdminClient ruleServiceAdminClient =
25 | new RuleServiceAdminClient(config.getServletContext(), session);
26 | RuleService ruleService = ruleServiceAdminClient.getRuleServiceDescription(request);
27 | String filename = request.getParameter("ruleFileName");
28 | String sourceType = request.getParameter("sourceType");
29 | if (filename != null) {
30 | if(sourceType.equals("file")){
31 |
32 | ruleServiceAdminClient.deleteRuleFile(ruleService,filename, session);
33 | }
34 | Map scriptList = (Map) session.getAttribute(RuleServiceAdminClient.SCRIPTS);
35 | if(scriptList!=null){
36 | scriptList.remove(filename);
37 | }
38 | session.setAttribute(RuleServiceAdminClient.SCRIPTS, scriptList);
39 |
40 | }
41 | %>
--------------------------------------------------------------------------------
/components/rule/org.wso2.carbon.rule.backend/src/main/java/org/wso2/carbon/rule/backend/drools/DroolsStatefulSession.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2004,2005 The Apache Software Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.wso2.carbon.rule.backend.drools;
18 |
19 | import org.kie.api.runtime.KieSession;
20 | import org.wso2.carbon.rule.kernel.backend.Session;
21 |
22 | import java.util.ArrayList;
23 | import java.util.Iterator;
24 | import java.util.List;
25 |
26 | public class DroolsStatefulSession implements Session {
27 |
28 | private KieSession statefulKnowledgeSession;
29 |
30 | public DroolsStatefulSession(KieSession statefulKnowledgeSession) {
31 | this.statefulKnowledgeSession = statefulKnowledgeSession;
32 | }
33 |
34 | public List execute(List facts) {
35 |
36 | for (Object fact : facts) {
37 | this.statefulKnowledgeSession.insert(fact);
38 | }
39 | this.statefulKnowledgeSession.fireAllRules();
40 | Iterator results = this.statefulKnowledgeSession.getObjects().iterator();
41 | List