1 /***
2 * ***************************************************************
3 * JADE - Java Agent DEvelopment Framework is a framework to develop
4 * multi-agent systems in compliance with the FIPA specifications.
5 * Copyright (C) 2000 CSELT S.p.A.
6 *
7 * GNU Lesser General Public License
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation,
12 * version 2.1 of the License.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
23 * **************************************************************
24 */
25 package JADE_SL.onto;
26
27 import JADE_SL.*;
28 import JADE_SL.schema.*;
29 import zeus.concepts.FIPA_AID_Address;
30 import java.util.List;
31
32
33 /***
34 * Ontology containing basic concepts.
35 *
36 * see JADE_SL.Ontology
37 *
38 * @author Federico Bergenti - Universita` di Parma
39 */
40 public class BasicOntology extends Ontology {
41
42 private static final BasicOntology theInstance = new BasicOntology();
43 static {
44 theInstance.initialize();
45 }
46
47
48 public static final String STRING = "BO_String";
49 public static final String FLOAT = "BO_Float";
50 public static final String INTEGER = "BO_Integer";
51 public static final String BOOLEAN = "BO_Boolean";
52 public static final String DATE = "BO_Date";
53 public static final String BYTE_SEQUENCE = "BO_Byte-sequence";
54
55
56 public static final String SEQUENCE = "sequence";
57 public static final String SET = "set";
58
59
60 public static final String CONTENT_ELEMENT_LIST = ContentElementListSchema.BASE_NAME;
61
62
63 public static final String AID = "agent-identifier";
64 public static final String FIPA_AID_Address_NAME = "name";
65 public static final String FIPA_AID_Address_ADDRESSES = "addresses";
66 public static final String FIPA_AID_Address_RESOLVERS = "resolvers";
67
68 public static final String ACLMSG = "acl-message";
69 public static final String ACLMSG_PERFORMATIVE = "performative";
70 public static final String ACLMSG_SENDER = "sender";
71 public static final String ACLMSG_RECEIVERS = "receivers";
72 public static final String ACLMSG_REPLY_TO = "reply-to";
73 public static final String ACLMSG_LANGUAGE = "language";
74 public static final String ACLMSG_ONTOLOGY = "ontology";
75 public static final String ACLMSG_PROTOCOL = "protocol";
76 public static final String ACLMSG_IN_REPLY_TO = "in-reply-to";
77 public static final String ACLMSG_REPLY_WITH = "reply-with";
78 public static final String ACLMSG_CONVERSATION_ID = "conversation-id";
79 public static final String ACLMSG_REPLY_BY = "reply-by";
80 public static final String ACLMSG_CONTENT = "content";
81 public static final String ACLMSG_BYTE_SEQUENCE_CONTENT = "bs-content";
82 public static final String ACLMSG_ENCODING = "encoding";
83
84
85 public static final String TRUE_PROPOSITION = "TRUE";
86
87
88 public static final String DONE = "DONE";
89 public static final String DONE_ACTION = "action";
90
91 public static final String RESULT = "RESULT";
92 public static final String RESULT_ACTION = "action";
93 public static final String RESULT_ITEMS = "items";
94
95 public static final String EQUALS = "EQUALS";
96 public static final String EQUALS_LEFT = "Left";
97 public static final String EQUALS_RIGHT = "Right";
98
99 public static final String ACTION = "ACTION";
100 public static final String ACTION_ACTOR = "Actor";
101 public static final String ACTION_ACTION = "Action";
102
103 /***
104 * Constructor
105 */
106 private BasicOntology() {
107 super("BASIC_ONTOLOGY", new BasicIntrospector());
108 }
109
110 private void initialize() {
111 try {
112
113 add(new PrimitiveSchema(STRING));
114 add(new PrimitiveSchema(FLOAT));
115 add(new PrimitiveSchema(INTEGER));
116 add(new PrimitiveSchema(BOOLEAN));
117 add(new PrimitiveSchema(DATE));
118 add(new PrimitiveSchema(BYTE_SEQUENCE));
119
120
121 add(new AggregateSchema(SEQUENCE));
122 add(new AggregateSchema(SET));
123
124
125
126
127
128
129
130
131
132 add(ContentElementListSchema.getBaseSchema());
133
134
135 ConceptSchema FIPA_AID_AddressSchema = new ConceptSchema(FIPA_AID_Address_ADDRESSES);
136 FIPA_AID_AddressSchema.add(FIPA_AID_Address_NAME, (TermSchema) getSchema(STRING));
137 FIPA_AID_AddressSchema.add(FIPA_AID_Address_ADDRESSES, (TermSchema) getSchema(STRING), 0, ObjectSchema.UNLIMITED);
138 FIPA_AID_AddressSchema.add(FIPA_AID_Address_RESOLVERS, FIPA_AID_AddressSchema, 0, ObjectSchema.UNLIMITED);
139 add(FIPA_AID_AddressSchema);
140
141
142 AgentActionSchema msgSchema = new AgentActionSchema(ACLMSG);
143 msgSchema.add(ACLMSG_PERFORMATIVE, (PrimitiveSchema) getSchema(INTEGER));
144 msgSchema.add(ACLMSG_SENDER, (ConceptSchema)getSchema(FIPA_AID_Address_ADDRESSES), ObjectSchema.OPTIONAL);
145 msgSchema.add(ACLMSG_RECEIVERS, (ConceptSchema) getSchema(FIPA_AID_Address_ADDRESSES), 0, ObjectSchema.UNLIMITED);
146 msgSchema.add(ACLMSG_REPLY_TO, (ConceptSchema) getSchema(FIPA_AID_Address_ADDRESSES), 0, ObjectSchema.UNLIMITED);
147 msgSchema.add(ACLMSG_LANGUAGE, (PrimitiveSchema) getSchema(STRING), ObjectSchema.OPTIONAL);
148 msgSchema.add(ACLMSG_ONTOLOGY, (PrimitiveSchema) getSchema(STRING), ObjectSchema.OPTIONAL);
149 msgSchema.add(ACLMSG_PROTOCOL, (PrimitiveSchema) getSchema(STRING), ObjectSchema.OPTIONAL);
150 msgSchema.add(ACLMSG_IN_REPLY_TO, (PrimitiveSchema) getSchema(STRING), ObjectSchema.OPTIONAL);
151 msgSchema.add(ACLMSG_REPLY_WITH, (PrimitiveSchema) getSchema(STRING), ObjectSchema.OPTIONAL);
152 msgSchema.add(ACLMSG_CONVERSATION_ID, (PrimitiveSchema) getSchema(STRING), ObjectSchema.OPTIONAL);
153 msgSchema.add(ACLMSG_REPLY_BY, (PrimitiveSchema) getSchema(DATE), ObjectSchema.OPTIONAL);
154 msgSchema.add(ACLMSG_CONTENT, (PrimitiveSchema) getSchema(STRING), ObjectSchema.OPTIONAL);
155 msgSchema.add(ACLMSG_BYTE_SEQUENCE_CONTENT, (PrimitiveSchema) getSchema(BYTE_SEQUENCE), ObjectSchema.OPTIONAL);
156 msgSchema.add(ACLMSG_ENCODING, (PrimitiveSchema) getSchema(STRING), ObjectSchema.OPTIONAL);
157 add(msgSchema);
158
159
160 PredicateSchema truePropSchema = new PredicateSchema(TRUE_PROPOSITION);
161 add(truePropSchema);
162
163
164 PredicateSchema doneSchema = new PredicateSchema(DONE);
165 doneSchema.add(DONE_ACTION, AgentActionSchema.getBaseSchema());
166 add(doneSchema);
167
168
169 PredicateSchema resultSchema = new PredicateSchema(RESULT);
170 resultSchema.add(RESULT_ACTION, (AgentActionSchema) AgentActionSchema.getBaseSchema());
171 resultSchema.add(RESULT_ITEMS, (TermSchema) getSchema(SEQUENCE));
172 add(resultSchema);
173
174
175 PredicateSchema equalsSchema = new PredicateSchema(EQUALS);
176 equalsSchema.add(EQUALS_LEFT, TermSchema.getBaseSchema());
177 equalsSchema.add(EQUALS_RIGHT, TermSchema.getBaseSchema());
178 add(equalsSchema);
179
180
181 AgentActionSchema actionSchema = new AgentActionSchema(ACTION);
182 actionSchema.add(ACTION_ACTOR, (TermSchema) getSchema(FIPA_AID_Address_ADDRESSES));
183 actionSchema.add(ACTION_ACTION, (TermSchema) ConceptSchema.getBaseSchema());
184 add(actionSchema);
185 }
186 catch (OntologyException oe) {
187 oe.printStackTrace();
188 }
189 }
190
191 /***
192 * Returns the singleton instance of the <code>BasicOntology</code>.
193 * @return the singleton instance of the <code>BasicOntology</code>
194 */
195 public static Ontology getInstance() {
196 return theInstance;
197 }
198 }