View Javadoc

1   /*
2   * The contents of this file are subject to the BT "ZEUS" Open Source 
3   * Licence (L77741), Version 1.0 (the "Licence"); you may not use this file 
4   * except in compliance with the Licence. You may obtain a copy of the Licence
5   * from $ZEUS_INSTALL/licence.html or alternatively from
6   * http://www.labs.bt.com/projects/agents/zeus/licence.htm
7   * 
8   * Except as stated in Clause 7 of the Licence, software distributed under the
9   * Licence is distributed WITHOUT WARRANTY OF ANY KIND, either express or 
10  * implied. See the Licence for the specific language governing rights and 
11  * limitations under the Licence.
12  * 
13  * The Original Code is within the package zeus.*.
14  * The Initial Developer of the Original Code is British Telecommunications
15  * public limited company, whose registered office is at 81 Newgate Street, 
16  * London, EC1A 7AJ, England. Portions created by British Telecommunications 
17  * public limited company are Copyright 1996-9. All Rights Reserved.
18  * 
19  * THIS NOTICE MUST BE INCLUDED ON ANY COPY OF THIS FILE
20  */
21  
22  
23  
24  package zeus.concepts;
25  
26  import java.util.*;
27  import zeus.util.*;
28  import zeus.concepts.fn.*;
29  
30  /*** 
31   *this interface is instantiatied by a number of different types of task, and 
32   *is used to store user defined parameters and info that are entered into the 
33   *task at design time using the Zeus Agent Generator tool
34   *CHANGE LOG
35   *20/9/02 added a description field to let users put in a description of the task 
36   *for some use cases; this information is used by the service description system
37   *I have added some feilds and client methods to the class to collect service 
38   *description information, I think that this is the right place to do it because
39   *while the Zeus reasoner only looks at plan atoms (primitive tasks) in an
40   *open environment the ability to write service descriptions for reactive 
41   *tasks may be useful, so this interface provides the common root that the two 
42   *subclasses can inheret the functionality from. 
43   */
44  public abstract class AbstractTask {
45  
46     public static final int PRIMITIVE = 0;
47     public static final int SUMMARY   = 1;
48     public static final int BEHAVIOUR = 2;
49     public static final int SCRIPT    = 3;
50  
51    private List restrictions;
52  
53    public AbstractTask() {
54      restrictions = new Vector();
55    }
56  
57     static String[] TaskTypes = {
58        "Primitive", "Summary", "Rulebase", "PlanScript"
59     };
60  
61     public static int getType(String typeName) {
62        return Misc.whichPosition(typeName,TaskTypes);
63     }
64     public static String getTypeName(int type) {
65        return TaskTypes[type];
66     }
67  
68     protected String name = SystemProps.getProperty("task.default.name");
69     protected int    type = PRIMITIVE;
70  
71     public void setName(String name)  {
72        Assert.notNull(name);
73        Assert.notFalse( !name.equals("") );
74        this.name = name;
75     }
76  
77     public String getName()     { return name; }
78     public int    getType()     { return type; }
79     public String getTypeName() { return TaskTypes[type]; }
80  
81     public boolean isPrimitive() { return type == PRIMITIVE; }
82     public boolean isSummary()   { return type == SUMMARY;   }
83     public boolean isBehaviour() { return type == BEHAVIOUR; }
84     public boolean isScript()    { return type == SCRIPT;    }
85  
86     public AbstractTask duplicate(String name, GenSym genSym) {
87        DuplicationTable table = new DuplicationTable(name,genSym);
88        return duplicate(table);
89     }
90     public String pprint() {
91        return pprint(0);
92     }
93  
94     public abstract AbstractTask duplicate(DuplicationTable table);
95     public abstract boolean      isValid();
96     public abstract String       pprint(int sp);
97     public abstract boolean      resolve(Bindings bindings);
98     private String textInfo = ""; 
99     private String phoneInfo = "";
100    private String faxInfo = ""; 
101    private String emailInfo = "";
102    private String physicalInfo = "";
103    private String geoInfo = "";
104    
105    public void setTextInfo (String in) {
106        this.textInfo = in; 
107    }
108    
109    
110    public String getTextInfo() {
111        return this.textInfo;
112    }
113    
114    public void setPhoneInfo (String in) {
115        this.phoneInfo = in;
116    }
117    
118    public String getPhoneInfo () {
119        return this.phoneInfo;
120    }
121    
122    
123    public void setFaxInfo (String in) {
124        this.faxInfo = in;
125    }
126    
127    
128    public String getFaxInfo () {
129        return this.faxInfo;
130    }
131    
132    
133    public void setEmailInfo (String in) {
134        this.emailInfo = in;
135    }
136    
137    public String getEmailInfo () { 
138        return this.emailInfo;
139    }
140    
141    public void setPhysicalInfo (String in) {
142        this.physicalInfo = in; 
143    }
144    
145    public String getPhysicalInfo () { 
146        return this.physicalInfo;
147    }
148    
149    public void setGeoInfo (String in) {
150        this.geoInfo = in;
151    }
152    
153    public String getGeoInfo () {
154        return this.geoInfo;
155    }
156    
157   public void addRestriction(String fact, String attribute, String value) {
158     restrictions.add(new Restriction(getName(), fact, attribute, value));
159   }
160 
161   public List getRestrictions() {
162     return restrictions;
163   }
164 }