01: /*--------------------------------------------------------------------------
02: * <copyright>
03: *
04: * Copyright 2001-2004 BBNT Solutions, LLC
05: * under sponsorship of the Defense Advanced Research Projects
06: * Agency (DARPA).
07: *
08: * You can redistribute this software and/or modify it under the
09: * terms of the Cougaar Open Source License as published on the
10: * Cougaar Open Source Website (www.cougaar.org).
11: *
12: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
16: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
17: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
18: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23: *
24: * </copyright>
25: * --------------------------------------------------------------------------*/
26: package org.cougaar.mlm.construction;
27:
28: import org.cougaar.glm.ldm.asset.InventoryBG;
29: import org.cougaar.glm.ldm.asset.InventoryPG;
30: import org.cougaar.glm.ldm.asset.NewInventoryPG;
31: import org.cougaar.planning.ldm.asset.PGDelegate;
32: import org.cougaar.planning.ldm.asset.PropertyGroup;
33: import org.cougaar.planning.ldm.measure.Count;
34: import org.cougaar.util.log.Logger;
35: import org.cougaar.util.log.Logging;
36:
37: public class ConstructionInventoryBG extends InventoryBG {
38: protected Logger logger = Logging
39: .getLogger(ConstructionInventoryBG.class);
40:
41: public ConstructionInventoryBG(InventoryPG pg) {
42: super (pg);
43: }
44:
45: public boolean initialize(double[] levels) {
46:
47: try {
48: double capacity = levels[0];
49: double erq = levels[2];
50: ((NewInventoryPG) myPG_).setCapacity(new Count(levels[0],
51: Count.EACHES));
52: ((NewInventoryPG) myPG_).setInitialLevel(new Count(
53: levels[1], Count.EACHES));
54: ((NewInventoryPG) myPG_).setReorderLevel(new Count(
55: levels[2], Count.EACHES));
56: ((NewInventoryPG) myPG_).setMinReorder(new Count(levels[3],
57: Count.EACHES));
58: ((NewInventoryPG) myPG_).setUnobtainable(new Count(0.0,
59: Count.EACHES));
60: ((NewInventoryPG) myPG_).setFillToCapacity(false);
61:
62: ((NewInventoryPG) myPG_).setMaintainAtCapacity(false);
63:
64: if ((capacity < erq) || (erq < 0)) {
65: if (logger.isErrorEnabled()) {
66: logger.error("Cannot create InventoryBG, capacity "
67: + capacity + " < erq " + erq);
68: }
69: initialized_ = false;
70: } else {
71: initialized_ = true;
72: if (logger.isDebugEnabled()) {
73: logger.debug("Initialized InventoryPG, capacity "
74: + capacity + ", erq " + erq
75: + ", initiali level: " + levels[1]
76: + ", min reorder: " + levels[3]);
77: }
78: }
79: } catch (NullPointerException npe) {
80: initialized_ = false;
81: }
82: return initialized_;
83:
84: }
85:
86: public PGDelegate copy(PropertyGroup pg) {
87: ConstructionInventoryBG bg = new ConstructionInventoryBG(
88: (InventoryPG) pg);
89: return bg;
90: }
91: }
|