aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/jdbc/example/corba/StockItemImpl.java
blob: 7f6c5be930772b0360e2a3b9c5ddaedaa8fd7828 (plain)
1
2
3
4
5
6
7
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package example.corba;

import org.omg.CosNaming.*;

/**
 * This class implements the server side of the example.
 *
 * $Id: StockItemImpl.java,v 1.1 1999/01/25 21:22:04 scrappy Exp $
 */
public class StockItemImpl extends stock._StockItemImplBase
{
    private StockDB db;
    private String instanceName;
    
    public StockItemImpl(String[] args,String iname) {
	super();
	try {
	    db =new StockDB();
	    db.connect(args[1],args[2],args[3]);
	    System.out.println("StockDB object "+iname+" created");
	    instanceName = iname;
	} catch(Exception e) {
	    e.printStackTrace();
	}
    }
    
    /**
     * This is defined in stock.idl
     *
     * It sets the item to view
     */
    public void fetchItem(int id) throws stock.StockException {
	try {
	    db.fetchItem(id);
	} catch(Exception e) {
	    throw new stock.StockException(e.toString());
	}
    }
    
    
    /**
     * This is defined in stock.idl
     *
     * It sets the item to view
     */
    public int newItem() throws stock.StockException {
	try {
	    return db.newItem();
	} catch(Exception e) {
	    throw new stock.StockException(e.toString());
	}
    }
    
    /**
     * This is defined in stock.idl
     *
     * It returns the description of a Stock item
     */
    public String getDescription() throws stock.StockException {
	try {
	    return db.getDescription();
	} catch(Exception e) {
	    throw new stock.StockException(e.toString());
	}
    }
    
    /**
     * This is defined in stock.idl
     *
     * It returns the description of a Stock item
     */
    public int getAvailable() throws stock.StockException {
	try {
	    return db.getAvailable();
	} catch(Exception e) {
	    throw new stock.StockException(e.toString());
	}
    }
        
    /**
     * This is defined in stock.idl
     *
     * It returns the description of a Stock item
     */
    public int getOrdered() throws stock.StockException {
	try {
	    return db.getOrdered();
	} catch(Exception e) {
	    throw new stock.StockException(e.toString());
	}
    }
    
    /**
     * This is defined in stock.idl
     *
     * It returns the description of a Stock item
     */
    public boolean isItemValid() throws stock.StockException {
	try {
	    return db.isItemValid();
	} catch(Exception e) {
	    throw new stock.StockException(e.toString());
	}
    }
    
    /**
     * This is defined in stock.idl
     *
     * It returns the description of a Stock item
     */
    public void addNewStock(int id) throws stock.StockException {
	try {
	    db.addNewStock(id);
	} catch(Exception e) {
	    throw new stock.StockException(e.toString());
	}
    }

    /**
     * This is defined in stock.idl
     *
     * It returns the description of a Stock item
     */
    public void removeStock(int id) throws stock.StockException {
	try {
	    db.removeStock(id);
	} catch(Exception e) {
	    throw new stock.StockException(e.toString());
	}
    }
    
    /**
     * This is defined in stock.idl
     *
     * It returns the description of a Stock item
     */
    public void orderStock(int id) throws stock.StockException {
	try {
	    db.orderStock(id);
	} catch(Exception e) {
	    throw new stock.StockException(e.toString());
	}
    }
    
    /**
     * This returns the highest id used, hence the number of items available
     */
    public int getLastID() throws stock.StockException {
	try {
	    return db.getLastID();
	} catch(Exception e) {
	    throw new stock.StockException(e.toString());
	}
    }
    
    /**
     * This is used by our Dispenser
     */
    public String getInstanceName() {
	return instanceName;
    }
}