Source Code Cross Referenced for InventoryPolicy.java in  » Science » Cougaar12_4 » org » cougaar » logistics » plugin » inventory » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » Cougaar12_4 » org.cougaar.logistics.plugin.inventory 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * <copyright>
003:         *  
004:         *  Copyright 1997-2004 BBNT Solutions, LLC
005:         *  under sponsorship of the Defense Advanced Research Projects
006:         *  Agency (DARPA).
007:         * 
008:         *  You can redistribute this software and/or modify it under the
009:         *  terms of the Cougaar Open Source License as published on the
010:         *  Cougaar Open Source Website (www.cougaar.org).
011:         * 
012:         *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013:         *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014:         *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015:         *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016:         *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017:         *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018:         *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019:         *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020:         *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021:         *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022:         *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023:         *  
024:         * </copyright>
025:         */
026:
027:        package org.cougaar.logistics.plugin.inventory;
028:
029:        import org.cougaar.planning.ldm.policy.BooleanRuleParameter;
030:        import org.cougaar.planning.ldm.policy.IntegerRuleParameter;
031:        import org.cougaar.planning.ldm.policy.DoubleRuleParameter;
032:        import org.cougaar.planning.ldm.policy.LongRuleParameter;
033:        import org.cougaar.planning.ldm.policy.Policy;
034:        import org.cougaar.planning.ldm.policy.RuleParameter;
035:        import org.cougaar.planning.ldm.policy.RuleParameterIllegalValueException;
036:        import org.cougaar.planning.ldm.policy.StringRuleParameter;
037:        import org.cougaar.util.log.Logging;
038:        import org.cougaar.util.log.Logger;
039:
040:        import java.text.SimpleDateFormat;
041:        import java.util.TimeZone;
042:        import java.util.Date;
043:
044:        import java.io.ObjectInputStream;
045:        import java.io.IOException;
046:
047:        public class InventoryPolicy extends Policy {
048:            public static final String AgentID = "AgentID";
049:            public static final String ResourceType = "ResourceType";
050:            public static final String InventoryManagerSpecifier = "InventoryManagerSpecifier";
051:            public static final String CriticalLevel = "CriticalLevel";
052:            public static final String SupplierAdvanceNoticeTime = "SupplierAdvanceNoticeTime";
053:            public static final String ReorderPeriod = "ReorderPeriod";
054:            public static final String HandlingTime = "HandlingTime";
055:            public static final String TransportTime = "TransportTime";
056:            public static final String OrderShipTime = "OrderShipTime";
057:            public static final String BucketSize = "BucketSize";
058:            public static final String FillToCapacity = "FillToCapacity";
059:            public static final String SupplierArrivalTime = "SupplierArrivalTime";
060:
061:            public SimpleDateFormat dateFormatter;
062:            private transient Logger logger;
063:
064:            public InventoryPolicy() {
065:                dateFormatter = new SimpleDateFormat("MM/dd/yyyy HH:mm");
066:                dateFormatter.setTimeZone(TimeZone.getTimeZone("GMT"));
067:
068:                logger = Logging.getLogger(this );
069:
070:                StringRuleParameter id = new StringRuleParameter(AgentID);
071:                String exception;
072:                try {
073:                    id.setValue(new String());
074:                } catch (RuleParameterIllegalValueException ex) {
075:                    if (logger.isErrorEnabled()) {
076:                        logger.error(ex.toString());
077:                    }
078:                    // Print exception, waiting for a static logger
079:                }
080:                Add(id);
081:                StringRuleParameter type = new StringRuleParameter(ResourceType);
082:                try {
083:                    type.setValue(new String());
084:                } catch (RuleParameterIllegalValueException ex) {
085:                    if (logger.isErrorEnabled()) {
086:                        logger.error("ResourceType-" + ex.toString());
087:                    }
088:                    // Print exception, waiting for a static logger
089:                }
090:                Add(type);
091:                StringRuleParameter arrivalDate = new StringRuleParameter(
092:                        SupplierArrivalTime);
093:                try {
094:                    arrivalDate.setValue(null);
095:                } catch (RuleParameterIllegalValueException ex) {
096:                    if (logger.isDebugEnabled()) {
097:                        logger.debug("SupplierArrivalTime-" + ex.toString());
098:                    }
099:                    // Print exception, waiting for a static logger
100:                }
101:                Add(arrivalDate);
102:                StringRuleParameter specifier = new StringRuleParameter(
103:                        InventoryManagerSpecifier);
104:                try {
105:                    type.setValue(new String());
106:                } catch (RuleParameterIllegalValueException ex) {
107:                    if (logger.isErrorEnabled()) {
108:                        logger.error("InventoryManagerSpecifier-"
109:                                + ex.toString());
110:                    }
111:                    // Print exception, waiting for a static logger
112:                }
113:                Add(specifier);
114:                IntegerRuleParameter cl = new IntegerRuleParameter(
115:                        CriticalLevel, 1, 40);
116:                try {
117:                    cl.setValue(new Integer(3));
118:                } catch (RuleParameterIllegalValueException ex) {
119:                    if (logger.isErrorEnabled()) {
120:                        logger.error("CriticalLevel-" + ex.toString());
121:                    }
122:                    // Print exception, waiting for a static logger
123:                }
124:                Add(cl);
125:                IntegerRuleParameter st = new IntegerRuleParameter(
126:                        SupplierAdvanceNoticeTime, 1, 100);
127:                try {
128:                    st.setValue(new Integer(1));
129:                } catch (RuleParameterIllegalValueException ex) {
130:                    if (logger.isErrorEnabled()) {
131:                        logger.error("SupplierAdvanceNoticeTime-"
132:                                + ex.toString());
133:                    }
134:                    // Print exception, waiting for a static logger
135:                }
136:                Add(st);
137:                IntegerRuleParameter of = new IntegerRuleParameter(
138:                        ReorderPeriod, 1, 40);
139:                try {
140:                    of.setValue(new Integer(3));
141:                } catch (RuleParameterIllegalValueException ex) {
142:                    if (logger.isErrorEnabled()) {
143:                        logger.error("ReorderPeriod-" + ex.toString());
144:                    }
145:                    // Print exception, waiting for a static logger
146:                }
147:                Add(of);
148:                IntegerRuleParameter ht = new IntegerRuleParameter(
149:                        HandlingTime, 0, 40);
150:                try {
151:                    ht.setValue(new Integer(0));
152:                } catch (RuleParameterIllegalValueException ex) {
153:                    if (logger.isErrorEnabled()) {
154:                        logger.error("HandlingTime-" + ex.toString());
155:                    }
156:                    // Print exception, waiting for a static logger
157:                }
158:                Add(ht);
159:                IntegerRuleParameter tt = new IntegerRuleParameter(
160:                        TransportTime, 1, 40);
161:                try {
162:                    tt.setValue(new Integer(3));
163:                } catch (RuleParameterIllegalValueException ex) {
164:                    if (logger.isErrorEnabled()) {
165:                        logger.error("TransportTime-" + ex.toString());
166:                    }
167:                    // Print exception, waiting for a static logger
168:                }
169:                Add(tt);
170:                IntegerRuleParameter ost = new IntegerRuleParameter(
171:                        OrderShipTime, 1, 40);
172:                try {
173:                    ost.setValue(new Integer(3));
174:                } catch (RuleParameterIllegalValueException ex) {
175:                    if (logger.isErrorEnabled()) {
176:                        logger.error("OrderShipTime-" + ex.toString());
177:                    }
178:                    // Print exception, waiting for a static logger
179:                }
180:                Add(ost);
181:                LongRuleParameter bucket = new LongRuleParameter(BucketSize,
182:                        TimeUtils.MSEC_PER_HOUR, Long.MAX_VALUE);
183:                try {
184:                    bucket.setValue(new Long(TimeUtils.MSEC_PER_DAY));
185:                } catch (RuleParameterIllegalValueException ex) {
186:                    if (logger.isErrorEnabled()) {
187:                        logger.error("BucketSize-" + ex.toString());
188:                    }
189:                }
190:                Add(bucket);
191:                BooleanRuleParameter fillToCap = new BooleanRuleParameter(
192:                        FillToCapacity, false);
193:                try {
194:                    fillToCap.setValue(new Boolean(false));
195:                } catch (RuleParameterIllegalValueException ex) {
196:                    if (logger.isErrorEnabled()) {
197:                        logger.error("FillToCapacity-" + ex.toString());
198:                    }
199:                }
200:                Add(fillToCap);
201:            }
202:
203:            public String getAgentID() {
204:                StringRuleParameter param = (StringRuleParameter) Lookup(AgentID);
205:                return (String) param.getValue();
206:            }
207:
208:            public void setAgentID(String name) {
209:                String exception;
210:                StringRuleParameter param = (StringRuleParameter) Lookup(AgentID);
211:                try {
212:                    param.setValue(name);
213:                } catch (RuleParameterIllegalValueException ex) {
214:                    if (logger.isErrorEnabled()) {
215:                        logger.error("Setting AgentID-" + ex.toString());
216:                    }
217:                    // Print exception, waiting for a static logger
218:                }
219:            }
220:
221:            public String getResourceType() {
222:                StringRuleParameter param = (StringRuleParameter) Lookup(ResourceType);
223:                return (String) param.getValue();
224:            }
225:
226:            public void setResourceType(String name) {
227:                String exception;
228:                StringRuleParameter param = (StringRuleParameter) Lookup(ResourceType);
229:                try {
230:                    param.setValue(name);
231:                } catch (RuleParameterIllegalValueException ex) {
232:                    if (logger.isErrorEnabled()) {
233:                        logger.error("Setting ResourceType-" + ex.toString());
234:                    }
235:                    // Print exception, waiting for a static logger
236:                }
237:            }
238:
239:            public long getSupplierArrivalTime() {
240:                StringRuleParameter param = (StringRuleParameter) Lookup(SupplierArrivalTime);
241:                if (param == null) {
242:                    return -1;
243:                }
244:                String arrivalDateStr = (String) param.getValue();
245:                if ((arrivalDateStr == null)
246:                        || (arrivalDateStr.trim().equals(""))) {
247:                    return -1;
248:                }
249:                try {
250:                    Date arrivalDate = dateFormatter.parse(arrivalDateStr);
251:                    return arrivalDate.getTime();
252:                } catch (Exception ex) {
253:                    logger.error(ex.toString());
254:                    return -1;
255:                }
256:            }
257:
258:            public void setSupplierArrivalTime(long arrivalTime) {
259:                String exception;
260:                StringRuleParameter param = (StringRuleParameter) Lookup(SupplierArrivalTime);
261:                String arrivalTimeStr = dateFormatter.format(new Date(
262:                        arrivalTime));
263:                try {
264:                    param.setValue(arrivalTimeStr);
265:                } catch (RuleParameterIllegalValueException ex) {
266:                    if (logger.isErrorEnabled()) {
267:                        logger.error("Setting SupplierArrivalTime-"
268:                                + ex.toString());
269:                    }
270:                    // Print exception, waiting for a static logger
271:                }
272:            }
273:
274:            public String getInventoryManagerSpecifier() {
275:                StringRuleParameter param = (StringRuleParameter) Lookup(InventoryManagerSpecifier);
276:                return (String) param.getValue();
277:            }
278:
279:            public void setInventoryManagerSpecifier(String name) {
280:                String exception;
281:                StringRuleParameter param = (StringRuleParameter) Lookup(InventoryManagerSpecifier);
282:                try {
283:                    param.setValue(name);
284:                } catch (RuleParameterIllegalValueException ex) {
285:                    if (logger.isErrorEnabled()) {
286:                        logger.error("Setting InventoryManagerSpecifier-"
287:                                + ex.toString());
288:                    }
289:                    // Print exception, waiting for a static logger
290:                }
291:            }
292:
293:            public int getCriticalLevel() {
294:                IntegerRuleParameter param = (IntegerRuleParameter) Lookup(CriticalLevel);
295:                return ((Integer) (param.getValue())).intValue();
296:            }
297:
298:            public void setCriticalLevel(int i) {
299:                String exception;
300:                IntegerRuleParameter param = (IntegerRuleParameter) Lookup(CriticalLevel);
301:                try {
302:                    param.setValue(new Integer(i));
303:                } catch (RuleParameterIllegalValueException ex) {
304:                    if (logger.isErrorEnabled()) {
305:                        logger.error("Setting CriticalLevel-" + ex.toString());
306:                    }
307:                    // Print exception, waiting for a static logger
308:                }
309:            }
310:
311:            public int getSupplierAdvanceNoticeTime() {
312:                IntegerRuleParameter param = (IntegerRuleParameter) Lookup(SupplierAdvanceNoticeTime);
313:                return ((Integer) (param.getValue())).intValue();
314:            }
315:
316:            public void setSupplierAdvanceNoticeTime(int i) {
317:                String exception;
318:                IntegerRuleParameter param = (IntegerRuleParameter) Lookup(SupplierAdvanceNoticeTime);
319:                try {
320:                    param.setValue(new Integer(i));
321:                } catch (RuleParameterIllegalValueException ex) {
322:                    if (logger.isErrorEnabled()) {
323:                        logger.error("Setting SupplierAdvanceNoticeTime-"
324:                                + ex.toString());
325:                    }
326:                    // Print exception, waiting for a static logger
327:                }
328:            }
329:
330:            public int getReorderPeriod() {
331:                IntegerRuleParameter param = (IntegerRuleParameter) Lookup(ReorderPeriod);
332:                return ((Integer) (param.getValue())).intValue();
333:            }
334:
335:            public void setReorderPeriod(int i) {
336:                String exception;
337:                IntegerRuleParameter param = (IntegerRuleParameter) Lookup(ReorderPeriod);
338:                try {
339:                    param.setValue(new Integer(i));
340:                } catch (RuleParameterIllegalValueException ex) {
341:                    if (logger.isErrorEnabled()) {
342:                        logger.error("Setting ReorderPeriod-" + ex.toString());
343:                    }
344:                    // Print exception, waiting for a static logger
345:                }
346:            }
347:
348:            public int getHandlingTime() {
349:                IntegerRuleParameter param = (IntegerRuleParameter) Lookup(HandlingTime);
350:                return ((Integer) (param.getValue())).intValue();
351:            }
352:
353:            public void setHandlingTime(int i) {
354:                String exception;
355:                IntegerRuleParameter param = (IntegerRuleParameter) Lookup(HandlingTime);
356:                try {
357:                    param.setValue(new Integer(i));
358:                } catch (RuleParameterIllegalValueException ex) {
359:                    if (logger.isErrorEnabled()) {
360:                        logger.error("Setting HandlingTime-" + ex.toString());
361:                    }
362:                    // Print exception, waiting for a static logger
363:                }
364:            }
365:
366:            public int getTransportTime() {
367:                IntegerRuleParameter param = (IntegerRuleParameter) Lookup(TransportTime);
368:                return ((Integer) (param.getValue())).intValue();
369:            }
370:
371:            public void setTransportTime(int i) {
372:                String exception;
373:                IntegerRuleParameter param = (IntegerRuleParameter) Lookup(TransportTime);
374:                try {
375:                    param.setValue(new Integer(i));
376:                } catch (RuleParameterIllegalValueException ex) {
377:                    if (logger.isErrorEnabled()) {
378:                        logger.error("Setting TransportTime-" + ex.toString());
379:                    }
380:                    // Print exception, waiting for a static logger
381:                }
382:            }
383:
384:            public int getOrderShipTime() {
385:                IntegerRuleParameter param = (IntegerRuleParameter) Lookup(OrderShipTime);
386:                return ((Integer) (param.getValue())).intValue();
387:            }
388:
389:            public void setOrderShipTime(int i) {
390:                String exception;
391:                IntegerRuleParameter param = (IntegerRuleParameter) Lookup(OrderShipTime);
392:                try {
393:                    param.setValue(new Integer(i));
394:                } catch (RuleParameterIllegalValueException ex) {
395:                    if (logger.isErrorEnabled()) {
396:                        logger.error("Settting OrderShipTime-" + ex.toString());
397:                    }
398:                    // Print exception, waiting for a static logger
399:                }
400:            }
401:
402:            public long getBucketSize() {
403:                LongRuleParameter param = (LongRuleParameter) Lookup(BucketSize);
404:                return ((Long) (param.getValue())).longValue();
405:            }
406:
407:            public void setBucketSize(long l) {
408:                String exception;
409:                LongRuleParameter param = (LongRuleParameter) Lookup(BucketSize);
410:                try {
411:                    param.setValue(new Long(l));
412:                } catch (RuleParameterIllegalValueException ex) {
413:                    if (logger.isErrorEnabled()) {
414:                        logger.error("Setting BucketSize-" + ex.toString());
415:                    }
416:                    // Print exception, waiting for a static logger
417:                }
418:            }
419:
420:            public boolean getFillToCapacity() {
421:                BooleanRuleParameter param = (BooleanRuleParameter) Lookup(FillToCapacity);
422:                return ((Boolean) (param.getValue())).booleanValue();
423:            }
424:
425:            public void setFillToCapacity(boolean b) {
426:                String exception;
427:                BooleanRuleParameter param = (BooleanRuleParameter) Lookup(FillToCapacity);
428:                try {
429:                    param.setValue(new Boolean(b));
430:                } catch (RuleParameterIllegalValueException ex) {
431:                    if (logger.isErrorEnabled()) {
432:                        logger.error("Setting FillToCapacity-" + ex.toString());
433:                    }
434:                    // Print exception, waiting for a static logger
435:                }
436:            }
437:
438:            private void readObject(ObjectInputStream stream)
439:                    throws ClassNotFoundException, IOException {
440:                stream.defaultReadObject();
441:                logger = Logging.getLogger(this);
442:            }
443:
444:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.