Skip to content

Commit 2d31e47

Browse files
committed
Merge pull request #1 from ekharlamov/master
Initial move from ekharlamov to ot4i
2 parents 818d78a + 3e7ac86 commit 2d31e47

25 files changed

+1034
-0
lines changed

.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>rest-api-tutorial</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
</buildSpec>
9+
<natures>
10+
</natures>
11+
</projectDescription>

src/BARfiles/.project

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>BARfiles</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.ibm.etools.mft.applib.mbprojectbuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>com.ibm.etools.msg.validation.dfdl.mlibdfdlbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>com.ibm.etools.mft.flow.adapters.adapterbuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>com.ibm.etools.mft.flow.sca.scabuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
<buildCommand>
29+
<name>com.ibm.etools.msg.validation.dfdl.mbprojectresourcesbuilder</name>
30+
<arguments>
31+
</arguments>
32+
</buildCommand>
33+
<buildCommand>
34+
<name>com.ibm.etools.mft.esql.lang.esqllangbuilder</name>
35+
<arguments>
36+
</arguments>
37+
</buildCommand>
38+
<buildCommand>
39+
<name>com.ibm.etools.mft.map.builder.mslmappingbuilder</name>
40+
<arguments>
41+
</arguments>
42+
</buildCommand>
43+
<buildCommand>
44+
<name>com.ibm.etools.mft.flow.msgflowxsltbuilder</name>
45+
<arguments>
46+
</arguments>
47+
</buildCommand>
48+
<buildCommand>
49+
<name>com.ibm.etools.mft.flow.msgflowbuilder</name>
50+
<arguments>
51+
</arguments>
52+
</buildCommand>
53+
<buildCommand>
54+
<name>com.ibm.etools.mft.decision.service.ui.decisionservicerulebuilder</name>
55+
<arguments>
56+
</arguments>
57+
</buildCommand>
58+
<buildCommand>
59+
<name>com.ibm.etools.mft.pattern.capture.PatternBuilder</name>
60+
<arguments>
61+
</arguments>
62+
</buildCommand>
63+
<buildCommand>
64+
<name>com.ibm.etools.msg.validation.dfdl.dfdlqnamevalidator</name>
65+
<arguments>
66+
</arguments>
67+
</buildCommand>
68+
<buildCommand>
69+
<name>com.ibm.etools.mft.bar.ext.barbuilder</name>
70+
<arguments>
71+
</arguments>
72+
</buildCommand>
73+
<buildCommand>
74+
<name>com.ibm.etools.mft.unittest.ui.TestCaseBuilder</name>
75+
<arguments>
76+
</arguments>
77+
</buildCommand>
78+
</buildSpec>
79+
<natures>
80+
<nature>com.ibm.etools.msgbroker.tooling.messageBrokerProjectNature</nature>
81+
<nature>com.ibm.etools.mft.bar.ext.barnature</nature>
82+
</natures>
83+
</projectDescription>
19.4 KB
Binary file not shown.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path=""/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="var" path="JCN_HOME/javacompute.jar"/>
6+
<classpathentry kind="var" path="JCN_HOME/jplugin2.jar"/>
7+
<classpathentry kind="con" path="com.ibm.etools.mft.uri.classpath.MBProjectReference"/>
8+
<classpathentry kind="output" path=""/>
9+
</classpath>

src/CustomerDatabaseJava/.project

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>CustomerDatabaseJava</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>com.ibm.etools.mft.jcn.jcnbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>com.ibm.etools.mft.bar.ext.barbuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
</buildSpec>
24+
<natures>
25+
<nature>org.eclipse.jdt.core.javanature</nature>
26+
<nature>com.ibm.etools.mft.jcn.jcnnature</nature>
27+
<nature>com.ibm.etools.mft.bar.ext.barnature</nature>
28+
</natures>
29+
</projectDescription>
1.34 KB
Binary file not shown.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import java.util.concurrent.atomic.AtomicInteger;
2+
3+
public class Customer {
4+
5+
private static AtomicInteger currentID = new AtomicInteger(1);
6+
7+
private int id;
8+
private String firstname;
9+
private String lastname;
10+
private String address;
11+
12+
public Customer(String firstname, String lastname, String address) {
13+
id = currentID.getAndIncrement();
14+
this.firstname = firstname;
15+
this.lastname = lastname;
16+
this.address = address;
17+
}
18+
19+
public int getID() {
20+
return id;
21+
}
22+
23+
public String getFirstName() {
24+
return firstname;
25+
}
26+
27+
public void setFirstName(String firstname) {
28+
this.firstname = firstname;
29+
}
30+
31+
public String getLastName() {
32+
return lastname;
33+
}
34+
35+
public void setLastName(String lastname) {
36+
this.lastname = lastname;
37+
}
38+
39+
public String getAddress() {
40+
return address;
41+
}
42+
43+
public void setAddress(String address) {
44+
this.address = address;
45+
}
46+
47+
}
4.67 KB
Binary file not shown.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import java.util.ArrayList;
2+
import java.util.List;
3+
4+
import com.ibm.broker.plugin.MbElement;
5+
import com.ibm.broker.plugin.MbException;
6+
import com.ibm.broker.plugin.MbJSON;
7+
import com.ibm.broker.plugin.MbMessage;
8+
9+
public abstract class CustomerDatabase {
10+
11+
private static List<Customer> customers = new ArrayList<>();
12+
13+
static {
14+
customers.add(new Customer("Denis", "Darner", "1 The Street, The Town"));
15+
customers.add(new Customer("Elana", "Ericson", "2 The Street, The Town"));
16+
customers.add(new Customer("Lyle", "Longino", "3 The Street, The Town"));
17+
customers.add(new Customer("Gerri", "Gaertner", "4 The Street, The Town"));
18+
customers.add(new Customer("Willis", "Wicks", "5 The Street, The Town"));
19+
customers.add(new Customer("Jessika", "Jeon", "6 The Street, The Town"));
20+
customers.add(new Customer("Neil", "Newton", "7 The Street, The Town"));
21+
customers.add(new Customer("Ferne", "Foye", "8 The Street, The Town"));
22+
}
23+
24+
public static void getAllCustomers(Long max, MbElement[] output) {
25+
try {
26+
MbElement root = output[0];
27+
long counter = 0;
28+
for (Customer customer : customers) {
29+
if (max > -1 && counter >= max) {
30+
break;
31+
}
32+
MbElement item = root.createElementAsLastChild(MbJSON.OBJECT, MbJSON.ARRAY_ITEM_NAME, null);
33+
item.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "id", customer.getID());
34+
item.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "firstname", customer.getFirstName());
35+
item.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "lastname", customer.getLastName());
36+
item.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "address", customer.getAddress());
37+
counter++;
38+
}
39+
} catch (MbException e) {
40+
throw new RuntimeException(e);
41+
}
42+
}
43+
44+
public static MbElement getCustomer(int id) throws MbException {
45+
for (Customer customer : customers) {
46+
if (customer.getID() == id) {
47+
MbMessage message = new MbMessage();
48+
MbElement result = message.getRootElement().createElementAsLastChild(MbJSON.OBJECT, MbJSON.DATA_ELEMENT_NAME, null);
49+
result.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "id", customer.getID());
50+
result.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "firstname", customer.getFirstName());
51+
result.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "lastname", customer.getLastName());
52+
result.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "address", customer.getAddress());
53+
return result;
54+
}
55+
}
56+
return null;
57+
}
58+
59+
public static boolean deleteCustomer(int id) {
60+
for (Customer customer : customers) {
61+
if (customer.getID() == id) {
62+
customers.remove(customer);
63+
return true;
64+
}
65+
}
66+
return false;
67+
}
68+
69+
public static boolean customerExists(int id) {
70+
for (Customer customer : customers) {
71+
if (customer.getID() == id) {
72+
return true;
73+
}
74+
}
75+
return false;
76+
}
77+
78+
public static MbElement addCustomer(String firstname, String lastname, String address) throws MbException {
79+
Customer customer = new Customer(firstname, lastname, address);
80+
customers.add(customer);
81+
MbMessage message = new MbMessage();
82+
MbElement result = message.getRootElement().createElementAsLastChild(MbJSON.OBJECT, MbJSON.DATA_ELEMENT_NAME, null);
83+
result.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "message", "A new customer with ID '" + customer.getID() + "' was successfully added to the database.");
84+
return result;
85+
}
86+
87+
public static MbElement updateCustomer(int id, String firstname, String lastname, String address) throws MbException {
88+
for (Customer customer : customers) {
89+
if (customer.getID() == id) {
90+
customer.setFirstName(firstname);
91+
customer.setLastName(lastname);
92+
customer.setAddress(address);
93+
MbMessage message = new MbMessage();
94+
MbElement result = message.getRootElement().createElementAsLastChild(MbJSON.OBJECT, MbJSON.DATA_ELEMENT_NAME, null);
95+
result.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "message", "An existing customer with ID '" + customer.getID() + "' was successfully updated in the database.");
96+
return result;
97+
}
98+
}
99+
return null;
100+
}
101+
102+
}
4.31 KB
Binary file not shown.

0 commit comments

Comments
 (0)