Skip to content

Commit

Permalink
Merge pull request #8 from wso2/master
Browse files Browse the repository at this point in the history
Update fork
  • Loading branch information
samgnaniah committed Oct 6, 2019
2 parents 58ded33 + bfa3370 commit 75b2b47
Show file tree
Hide file tree
Showing 197 changed files with 7,140 additions and 729 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ We appreciate your help!

## Getting started with contribution

* Get started with the Ballerina Integrator by following the [Quick Start Guide](https://ei.docs.wso2.com/en/latest/ballerina-integrator/getting-started/quick-start-guide/). Start trying out our guides and tutorials available in the [Learn](https://ei.docs.wso2.com/en/latest/ballerina-integrator/learn/about-learn/) section.
* Get started with the Ballerina Integrator by following the [Quick Start Guide](https://ei.docs.wso2.com/en/latest/ballerina-integrator/get-started/quick-start-guide/). Start trying out our guides and tutorials available in the [Learn](https://ei.docs.wso2.com/en/latest/ballerina-integrator/learn/use-cases/) section.
* Submit issues and contribute code. Go to the **Issues** tab of the GitHub repo and click the New Issue button to file a bug report.
* Fix issues:
* Browse issues labeled easyfix,
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://wso2.org/jenkins/buildStatus/icon?job=products/ballerina-integrator)](https://wso2.org/jenkins/view/products/job/products/job/ballerina-integrator/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

A powerful, simple-to-learn, code-driven approach to programming integrations - based on the [Ballerina programming language](ballerina.io). It includes first-class cloud-native functions as well as a graphical sequence diagram tool.
A powerful, simple-to-learn, code-driven approach to programming integrations - based on the [Ballerina programming language](https://ballerina.io). It includes first-class cloud-native functions as well as a graphical sequence diagram tool.

The Ballerina Integrator appeals to those using decentralized integration architectures, Microservices, and cloud-native apps.

Expand All @@ -14,7 +14,7 @@ and integration.

Ballerina is a new general-purpose programming language that makes it easy to write cloud-native applications.

Please visit [ballerina.io](ballerina.io) to read more about Ballerina.
Please visit [ballerina.io](https://ballerina.io) to read more about Ballerina.

## Key Highlights

Expand Down Expand Up @@ -65,7 +65,7 @@ Mainly consists of below-stated components.

You can use the following options to try out Ballerina Integrator and get started.

* [Quick Start Guide](https://ei.docs.wso2.com/en/latest/ballerina-integrator/getting-started/quick-start-guide/)
* [Quick Start Guide](https://ei.docs.wso2.com/en/latest/ballerina-integrator/get-started/quick-start-guide/)
* [Learn Documentation](https://ei.docs.wso2.com/en/latest/ballerina-integrator/learn/use-cases/)

## Contributing to Ballerina
Expand Down
8 changes: 4 additions & 4 deletions docs/content/resources/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
{
"path": "src/learn/tutorials/integration-patterns-and-soa/content-based-routing",
"modules": [
"stockquote_service"
"content_based_routing"
],
"skipTests": false
},
Expand Down Expand Up @@ -61,7 +61,7 @@
{
"path": "src/learn/tutorials/integration-patterns-and-soa/pass-through-messaging",
"modules": [
"pass_through"
"pass_through_messaging"
],
"skipTests": false
},
Expand All @@ -82,7 +82,7 @@
{
"path": "src/learn/tutorials/integration-patterns-and-soa/scatter-gather-flow",
"modules": [
"employee_details_service"
"scatter_gather_flow"
],
"skipTests": false
},
Expand All @@ -103,7 +103,7 @@
{
"path": "src/learn/tutorials/integration-patterns-and-soa/service-composition",
"modules": [
"guide"
"service_composition"
],
"skipTests": false
},
Expand Down
Binary file added docs/content/src/assets/img/mongo-insert.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/content/src/assets/img/querying-mysql.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/content/src/develop/running-as-a-java-program.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ To run Ballerina code as a Java program, you need to have Oracle JDK 1.8.* insta

## Running the simple Java command

The following is an example of a `java -jar` command. This is used to run the project built in the [Quick Start Guide](../../getting-started/quick-start-guide).
The following is an example of a `java -jar` command. This is used to run the project built in the [Quick Start Guide](../../get-started/quick-start-guide).

```java

Expand Down
1 change: 1 addition & 0 deletions docs/content/src/get-started/healthcare-service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
org_name = "wso2"
version = "0.1.0"
lockfile_version = "1.0.0"
ballerina_version = "1.0.1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Grand Oak and Pine Valley Hospital Services

Gives out available doctors for a given doctor type for Grand Oak hospital and Pine Valley hospital

Available doctor types:
Pediatrician
Physician
Ophthalmologist

## Example requests

``curl -v http://localhost:9090/grandOak/doctors/Physician``

``curl -v http://localhost:9091/pineValley/doctors/Physician``


Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// Copyright (c) 2019 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/http;
import ballerina/log;

@http:ServiceConfig {
basePath: "/grandOak"
}
service grandOakService on new http:Listener(9091) {

@http:ResourceConfig {
path: "/doctors/{doctorType}",
methods: ["GET"]
}
resource function doctors(http:Caller caller, http:Request request, string doctorType) returns error? {

json responsePayload = {};
if (doctorType.toLowerAscii() == "ophthalmologist") {
responsePayload = {
"doctors": {
"doctor": [
{
"name": "John Mathew",
"time": "03:30 PM",
"hospital": "Grand Oak"
},
{
"name": "Allan Silvester",
"time": "04:30 PM",
"hospital": "Grand Oak"
}
]
}
};
} else if (doctorType.toLowerAscii() == "physician") {
responsePayload = {
"doctors": {
"doctor": [
{
"name": "Shane Martin",
"time": "07:30 AM",
"hospital": "Grand Oak"
},
{
"name": "Geln Ivan",
"time": "08:30 AM",
"hospital": "Grand Oak"
}
]
}
};
} else if (doctorType.toLowerAscii() == "pediatrician") {
responsePayload = {
"doctors": {
"doctor": [
{
"name": "Bob Watson",
"time": "05:30 PM",
"hospital": "Grand Oak"
},
{
"name": "Paul Johnson",
"time": "07:30 AM",
"hospital": "Grand Oak"
}
]
}
};
} else {
handleError(caller, "Invalid doctor category");
return;
}
http:Response response = new;
response.setJsonPayload(responsePayload, "application/json");
var result = caller->respond(response);
// Logs the `error` in case of a failure.
if (result is error) {
log:printError("Error sending response", err = result);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Copyright (c) 2019 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/http;
import ballerina/log;

http:Client grandOakHospital = new("http://localhost:9091/grandOak");
http:Client pineValleyHospital = new("http://localhost:9092/pineValley");

@http:ServiceConfig {
basePath: "/healthcare"
}
service healthcare on new http:Listener(9090) {

@http:ResourceConfig {
path: "/doctor/{doctorType}"
}
resource function getDoctors(http:Caller caller, http:Request request, string doctorType) returns error? {
json grandOakDoctors = {};
json pineValleyDoctors = {};
var grandOakResponse = grandOakHospital->get("/doctors/" + doctorType);
var pineValleyResponse = pineValleyHospital->post("/doctors", {doctorType: doctorType});
// Extract doctors array from grand oak hospital response
if (grandOakResponse is http:Response) {
json result = check grandOakResponse.getJsonPayload();
grandOakDoctors = check result.doctors.doctor;
} else {
handleError(caller, <@untained> grandOakResponse.reason());
}
// Extract doctors array from pine valley hospital response
if (pineValleyResponse is http:Response) {
json result = check pineValleyResponse.getJsonPayload();
pineValleyDoctors = check result.doctors.doctor;
} else {
handleError(caller, <@untained> pineValleyResponse.reason());
}
// Aggregate grand oak hospital's doctors with pine valley hospital's doctors
if (grandOakDoctors is json[] && pineValleyDoctors is json[]) {
foreach var item in pineValleyDoctors {
grandOakDoctors.push(item);
}
}
// Respond back to the caller with aggregated json response
http:Response response = new();
response.setJsonPayload(<@untained> grandOakDoctors);
var result = caller->respond(response);

if (result is error) {
log:printError("Error sending response", err = result);
}
}
}

function handleError(http:Caller caller, string errorMsg) {
http:Response response = new;

json responsePayload = {
"error": {
"message": errorMsg
}
};
response.setJsonPayload(responsePayload, "application/json");
var result = caller->respond(response);
if (result is error) {
log:printError("Error sending response", err = result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright (c) 2019 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

import ballerina/http;
import ballerina/log;

@http:ServiceConfig {
basePath: "/pineValley"
}
service pineValleyService on new http:Listener(9092) {

@http:ResourceConfig {
path: "/doctors",
methods: ["POST"]
}
resource function doctors(http:Caller caller, http:Request request) returns error? {

json doctors = check request.getJsonPayload();
string doctorType = <string>doctors.doctorType;
json responsePayload = {};
if (doctorType.toLowerAscii() == "ophthalmologist") {
responsePayload = {
"doctors": {
"doctor": [
{
"name": "John Mathew",
"time": "07:30 AM",
"hospital": "pineValley"
},
{
"name": "Roma Katherine",
"time": "04:30 PM",
"hospital": "pineValley"
}
]
}
};
} else if (doctorType.toLowerAscii() == "physician") {
responsePayload = {
"doctors": {
"doctor": [
{
"name": "Geln Ivan",
"time": "05:30 PM",
"hospital": "pineValley"
},
{
"name": "Daniel Lewis",
"time": "05:30 PM",
"hospital": "pineValley"
}
]
}
};
} else if (doctorType.toLowerAscii() == "pediatrician") {
responsePayload = {
"doctors": {
"doctor": [
{
"name": "Bob Watson",
"time": "07:30 AM",
"hospital": "pineValley"
},
{
"name": "Wilson Mcdonald",
"time": "07:30 AM",
"hospital": "pineValley"
}
]
}
};
} else {
handleError(caller, "Invalid doctor category");
return;
}
http:Response response = new;
response.setJsonPayload(responsePayload, "application/json");
var result = caller->respond(response);
// Logs the `error` in case of a failure.
if (result is error) {
log:printError("Error sending response", err = result);
}
}
}
Loading

0 comments on commit 75b2b47

Please sign in to comment.