PageRenderTime 62ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/src/edu/stanford/smi/protegex/owl/swrl/bridge/builtins/tbox/SWRLBuiltInLibraryImpl.java

https://github.com/sspinc/protege-owl
Java | 1331 lines | 780 code | 245 blank | 306 comment | 146 complexity | d8789c348bf4015a79121fa62c99dfe7 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. // TODO: a lot of repetition here
  2. // cf. http://listserv.manchester.ac.uk/cgi-bin/wa?A2=ind0611&L=dig-wg&T=0&P=754
  3. // lca, max flow, shortest path, http://www.ifi.unizh.ch/ddis/isparql.html
  4. // icon to show OWL expressible SWRL rules.
  5. // How to extract axiom information:
  6. // c = class
  7. // i = individual
  8. // d = data value
  9. // p = property
  10. // a = axiom
  11. // ca = class axiom (composed of class descriptions)
  12. // pa = property axiom
  13. // ia = individual axiom
  14. // da = datatype axiom
  15. // r = restriction
  16. // Class descriptions: (six types: (1) URI, i.e., a c, (2) enumeration of individuals, (3) property restriction, (4) intersection, (5)
  17. // union, (6) complement
  18. // (1) URI, i.e., a named class
  19. // (2) enumeration of class description
  20. // 3.1.1 enumeration: isOWLEnumerationDescription(?cd), onIndividual(?cd, ?i)
  21. // (3) property restriction class descriptions
  22. // 3.1.2 cardinality restrictions = isCardinalityRestriction(?a), isMinCardinalityRestriction(?a), isMaxCardinalityRestriction(?a), hasCardinality(?a, ?d)
  23. // 3.1.2.1.1 allValuesFromRestriction: isAllValuesFromRestriction(?a), onProperty(?a, ?p), hasValue(?a, ?{i, d})
  24. // 3.1.2.1.2 someValuesFrom: isSomeValuesFrom(?a), onProperty(?a, ?p), hasValue(?a, ?{i,d})
  25. // 3.1.2.1.3 hasValueRestriction: isHasValueRestriction(?a), onProperty(?a, ?p), hasValue(?a, ?{i,d})
  26. // (4) intersection of class description
  27. // 3.1.3.1 intersectionOf: list of owl:oneOf class descriptions: isIntersectionOfClassDescription(?cd), onDescription(?cd, ?cd)
  28. // (5) union of class description
  29. // 3.1.3.2 unionOf: list of owl:oneOf class descriptions: isOWLUnionOfDescription(?cd), onDescription(?cd, ?cd)
  30. // (6) complement of class description
  31. // 3.1.3.3 complementOf: isOWLComplementOfDescription(?cd), onDescription(?cd, ?cd)
  32. // OWL Class axioms (which use cds)
  33. // 3.2.1 rdfs:subClassOf: isSubClassOf(?c, ?c), isOWLSubClassAxiom(?ca), ...
  34. // 3.2.2 owl:equivalentClass: isEquivalentClass(?c, ?c), isOWLEquivalentClassAxiom(?ca), onDescription(?ca, ?cd)
  35. // 3.2.3 isOWLOneOfDescription? how to distinguish from 3.1.1??
  36. // 3.2.4 owl:isDisjointWith: isDisjointWith(?c, ?c), isDisjointWithClassAxiom(?ca), onDescription(?ca, ?cd)
  37. // OWL Property axioms:
  38. // 4.1.1 rdfs:subPropertyOf: isSubPropertyOf(?p,?p), isDirectSubPropertyOf(?p, ?p)
  39. // 4.1.2 rdfs:domain: isInDomainOf(?p, ?c), isInDirectDomainOf(?p, ?c), isOWLInDomainOfAxiom(?pa), onDescription(?pa, ?cd)
  40. // 4.1.3 rdfs:range: isInRangeOf(?p, ?c), isInDirectRangeOf(?p, ?c), isOWLInRangeOfAxiom(?pa), onDescription(?pa, ?cd)
  41. // 4.2.1 owl:equivalentProperty: isEquivalentProperty(?p, ?p), isOWLEquivalentPropertyAxiom(?pa), onProperty(?pa, ?p)
  42. // 4.2.2 owl:inverseOf: isInverseOf(?p, ?p), isOWLInverseOfAxiom(?pa), onProperty(?pa, ?p)
  43. // 4.3.1 owl:FunctionalProperty: isOWLFunctionalProperty(?p), isFunctionalPropertyAxiom(?pa), onProperty(?pa, ?p)
  44. // 4.3.2 owl:InverseFunctionalProperty: isOWLInverseFunctionalProperty(?p), isInverseFunctionalPropertyAxiom(?pa), onProperty(?pa, ?p)
  45. // 4.4.1 owl:TransitiveProperty: isOWLTransitiveProperty(?p), isTransitivePropertyAxiom(?pa), onProperty(?pa, ?p)
  46. // OWL Individual axioms:
  47. // 5.2.1 owl:sameAs: isOWLSameAsAxiom(?ia), onIndividual(?ia, ?i)
  48. // 5.2.2 owl:differentFrom: isOWLDifferentFromAxiom(?ia), onIndividual(?ia, ?i)
  49. // 5.2.3 owl:AllDifferent: isOWLAllDifferentAxiom(?ia), onIndividual(?ia, ?i)
  50. //
  51. // Datatype axioms:
  52. // 6.2 Enumerated datatype: isOWLEnumeratedDatatypeAxiom(?da), onValue(?da, ?d)
  53. package edu.stanford.smi.protegex.owl.swrl.bridge.builtins.tbox;
  54. import java.util.List;
  55. import java.util.Set;
  56. import edu.stanford.smi.protegex.owl.model.OWLModel;
  57. import edu.stanford.smi.protegex.owl.swrl.bridge.BuiltInArgument;
  58. import edu.stanford.smi.protegex.owl.swrl.bridge.MultiArgument;
  59. import edu.stanford.smi.protegex.owl.swrl.bridge.builtins.AbstractSWRLBuiltInLibrary;
  60. import edu.stanford.smi.protegex.owl.swrl.bridge.exceptions.BuiltInException;
  61. import edu.stanford.smi.protegex.owl.swrl.bridge.exceptions.BuiltInNotImplementedException;
  62. import edu.stanford.smi.protegex.owl.swrl.bridge.exceptions.OWLConversionFactoryException;
  63. import edu.stanford.smi.protegex.owl.swrl.bridge.exceptions.SWRLBuiltInLibraryException;
  64. import edu.stanford.smi.protegex.owl.swrl.exceptions.SWRLOWLUtilException;
  65. import edu.stanford.smi.protegex.owl.swrl.owlapi.OWLDataFactory;
  66. import edu.stanford.smi.protegex.owl.swrl.owlapi.OWLProperty;
  67. import edu.stanford.smi.protegex.owl.swrl.owlapi.OWLSomeValuesFrom;
  68. import edu.stanford.smi.protegex.owl.swrl.util.SWRLOWLUtil;
  69. /**
  70. * Implementations library for SWRL TBox built-in methods. See <a
  71. * href="http://protege.cim3.net/cgi-bin/wiki.pl?SWRLTBoxBuiltIns">here</a> for documentation on this library.
  72. *
  73. * See <a href="http://protege.cim3.net/cgi-bin/wiki.pl?SWRLBuiltInBridge">here</a> for documentation on defining SWRL built-in libraries.
  74. */
  75. public class SWRLBuiltInLibraryImpl extends AbstractSWRLBuiltInLibrary
  76. {
  77. private static String SWRLTBoxLibraryName = "SWRLTBoxBuiltIns";
  78. public SWRLBuiltInLibraryImpl()
  79. {
  80. super(SWRLTBoxLibraryName);
  81. }
  82. public void reset() {}
  83. /**
  84. * Is the second annotation property argument associated with the first ontology, class, property or individual argument. If the second
  85. * argument is unbound, bind it to the annotation properties associated with the first argument (if any exist).
  86. */
  87. public boolean hasAnnotationProperty(List<BuiltInArgument> arguments) throws BuiltInException
  88. {
  89. boolean result = false;
  90. if (!result) throw new BuiltInNotImplementedException();
  91. return result;
  92. }
  93. /**
  94. * It the second integer argument equal to the cardinality specified by the first owl:Cardinality, owl:MaxCardinality, or
  95. * owl:MinCardinality restriction argument. If the second argument is unbound, bind it to the cardinality value.
  96. */
  97. public boolean hasCardinality(List<BuiltInArgument> arguments) throws BuiltInException
  98. {
  99. boolean result = false;
  100. if (!result) throw new BuiltInNotImplementedException();
  101. return result;
  102. }
  103. /**
  104. * Is the second string argument the value specified by the first rdfs:comment annotation property argument. If the second argument is
  105. * unbound, bind it to the value specified by the first rdfs:comment annotation property argument.
  106. */
  107. public boolean hasRDFSComment(List<BuiltInArgument> arguments) throws BuiltInException
  108. {
  109. boolean result = false;
  110. if (!result) throw new BuiltInNotImplementedException();
  111. return result;
  112. }
  113. /**
  114. * Is the second description argument associated with the first class or individual argument. If the second argument is unbound, bind it
  115. * to the descriptions associated with the first argument (if any exist).
  116. */
  117. public boolean hasDescription(List<BuiltInArgument> arguments) throws BuiltInException
  118. {
  119. boolean result = false;
  120. if (!result) throw new BuiltInNotImplementedException();
  121. return result;
  122. }
  123. /**
  124. * Is the second resource argument the value specified by the first rdfs:isDefinedBy annotation property argument. If the second argument
  125. * is unbound, bind it to the value specified by the first rdfs:isDefinedBy annotation property argument.
  126. */
  127. public boolean hasRDFSIsDefinedBy(List<BuiltInArgument> arguments) throws BuiltInException
  128. {
  129. boolean result = false;
  130. if (!result) throw new BuiltInNotImplementedException();
  131. return result;
  132. }
  133. /**
  134. * Is the second string argument the value specified by the first rdfs:label annotation property argument. If the second argument is
  135. * unbound, bind it to the value specified by the first rdfs:label annotation property argument.
  136. */
  137. public boolean hasRDFSLabel(List<BuiltInArgument> arguments) throws BuiltInException
  138. {
  139. boolean result = false;
  140. if (!result) throw new BuiltInNotImplementedException();
  141. return result;
  142. }
  143. /**
  144. * Is the second resource argument the value specified by the first rdfs:seeAlso annotation property argument. If the second argument
  145. * is unbound, bind it to the value specified by the first rdfs:seeAlso annotation property argument.
  146. */
  147. public boolean hasRDFSSeeAlso(List<BuiltInArgument> arguments) throws BuiltInException
  148. {
  149. boolean result = false;
  150. if (!result) throw new BuiltInNotImplementedException();
  151. return result;
  152. }
  153. /**
  154. * Is the second string argument the value specified by the first rdfs:versionInfo annotation property argument. If the second argument
  155. * is unbound, bind it to the value specified by the first rdfs:versionInfo annotation property argument.
  156. */
  157. public boolean hasVersionInfo(List<BuiltInArgument> arguments) throws BuiltInException
  158. {
  159. boolean result = false;
  160. if (!result) throw new BuiltInNotImplementedException();
  161. return result;
  162. }
  163. /**
  164. * Are all individual arguments declared to be the different from each other.
  165. */
  166. public boolean isAllDifferents(List<BuiltInArgument> arguments) throws BuiltInException
  167. {
  168. boolean result = false;
  169. if (!result) throw new BuiltInNotImplementedException();
  170. return result;
  171. }
  172. /**
  173. * Is the single argument an owl:AllDifferentsAxiom.
  174. */
  175. public boolean isAllDifferentsAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  176. {
  177. boolean result = false;
  178. if (!result) throw new BuiltInNotImplementedException();
  179. return result;
  180. }
  181. /**
  182. * Is the single argument an owl:AllValuesFrom restriction.
  183. */
  184. public boolean isAllValuesFromRestriction(List<BuiltInArgument> arguments) throws BuiltInException
  185. {
  186. boolean result = false;
  187. if (!result) throw new BuiltInNotImplementedException();
  188. return result;
  189. }
  190. /**
  191. * Is the single argument an annotation property.
  192. */
  193. public boolean isAnnotationProperty(List<BuiltInArgument> arguments) throws BuiltInException
  194. {
  195. checkNumberOfArgumentsEqualTo(1, arguments.size());
  196. String propertyURI = getArgumentAsAPropertyURI(0, arguments);
  197. boolean result = false;
  198. try {
  199. result = SWRLOWLUtil.isAnnotationProperty(getOWLModel(), propertyURI, true);
  200. } catch (SWRLOWLUtilException e) {
  201. throw new BuiltInException(e.getMessage());
  202. } // try
  203. return result;
  204. }
  205. /**
  206. * Is the single argument an owl:Cardinality restriction.
  207. */
  208. public boolean isCardinalityRestriction(List<BuiltInArgument> arguments) throws BuiltInException
  209. {
  210. boolean result = false;
  211. if (!result) throw new BuiltInNotImplementedException();
  212. return result;
  213. }
  214. /**
  215. * Determine if a single argument is an OWL named class. If the argument is unbound, bind it to all OWL named classes in an ontology.
  216. */
  217. public boolean isClass(List<BuiltInArgument> arguments) throws BuiltInException
  218. {
  219. checkNumberOfArgumentsEqualTo(1, arguments.size());
  220. boolean isUnboundArgument = isUnboundArgument(0, arguments);
  221. boolean result = false;
  222. try {
  223. if (getIsInConsequent()) {
  224. if (isArgumentAString(0, arguments)) {
  225. String classURI = SWRLOWLUtil.getFullName(getOWLModel(), getArgumentAsAString(0, arguments));
  226. if (!getBuiltInBridge().isOWLClass(classURI)) getBuiltInBridge().injectOWLClassDeclaration(classURI);
  227. } else checkThatArgumentIsAClass(0, arguments);
  228. result = true;
  229. } else {
  230. if (isUnboundArgument) {
  231. MultiArgument multiArgument = createMultiArgument();
  232. for (edu.stanford.smi.protegex.owl.model.OWLNamedClass cls : SWRLOWLUtil.getUserDefinedOWLNamedClasses(getOWLModel()))
  233. multiArgument.addArgument(createClassArgument(cls.getURI()));
  234. arguments.get(0).setBuiltInResult(multiArgument);
  235. result = !multiArgument.hasNoArguments();
  236. } else {
  237. String classURI = getArgumentAsAClassURI(0, arguments);
  238. result = getBuiltInBridge().isOWLClass(classURI);
  239. } // if
  240. } // if
  241. } catch (SWRLOWLUtilException e) {
  242. throw new BuiltInException(e.getMessage());
  243. } // try
  244. return result;
  245. }
  246. /**
  247. * Is the single argument an OWL class description.
  248. */
  249. public boolean isClassDescription(List<BuiltInArgument> arguments) throws BuiltInException
  250. {
  251. boolean result = false;
  252. if (!result) throw new BuiltInNotImplementedException();
  253. return result;
  254. }
  255. /**
  256. * Is the single argument an rdfs:comment annotation.
  257. */
  258. public boolean isRDFSComment(List<BuiltInArgument> arguments) throws BuiltInException
  259. {
  260. boolean result = false;
  261. if (!result) throw new BuiltInNotImplementedException();
  262. return result;
  263. }
  264. /**
  265. * Is the first class argument the complement of the second class argument. If the second argument is unbound, bind it to the complement
  266. * of the first argument.
  267. */
  268. public boolean isComplementOf(List<BuiltInArgument> arguments) throws BuiltInException
  269. {
  270. boolean result = false;
  271. if (!result) throw new BuiltInNotImplementedException();
  272. return result;
  273. }
  274. /**
  275. * Is the single argument an owl:ComplementOf class description.
  276. */
  277. public boolean isComplementOfDescription(List<BuiltInArgument> arguments) throws BuiltInException
  278. {
  279. boolean result = false;
  280. if (!result) throw new BuiltInNotImplementedException();
  281. return result;
  282. }
  283. /**
  284. * Determine if the single argument is an OWL data property. If the argument is unbound, bind it to all OWL datatype
  285. * properties in an ontology.
  286. */
  287. public boolean isDataProperty(List<BuiltInArgument> arguments) throws BuiltInException
  288. {
  289. checkNumberOfArgumentsEqualTo(1, arguments.size());
  290. boolean isUnboundArgument = isUnboundArgument(0, arguments);
  291. boolean result = false;
  292. try {
  293. if (isUnboundArgument) {
  294. MultiArgument multiArgument = createMultiArgument();
  295. for (edu.stanford.smi.protegex.owl.model.OWLProperty property : SWRLOWLUtil.getUserDefinedOWLDatatypeProperties(getOWLModel())) {
  296. if (property.isObjectProperty()) multiArgument.addArgument(createObjectPropertyArgument(property.getURI()));
  297. else multiArgument.addArgument(createDataPropertyArgument(property.getURI()));
  298. } // for
  299. arguments.get(0).setBuiltInResult(multiArgument);
  300. result = !multiArgument.hasNoArguments();
  301. } else {
  302. String propertyURI = getArgumentAsAPropertyURI(0, arguments);
  303. result = SWRLOWLUtil.isOWLDataProperty(getOWLModel(), propertyURI, false);
  304. } // if
  305. } catch (SWRLOWLUtilException e) {
  306. throw new BuiltInException(e.getMessage());
  307. } // try
  308. return result;
  309. }
  310. /**
  311. * Is the single argument an rdfs:isDefinedBy annotation.
  312. */
  313. public boolean isRDFSIsDefinedBy(List<BuiltInArgument> arguments) throws BuiltInException
  314. {
  315. boolean result = false;
  316. if (!result) throw new BuiltInNotImplementedException();
  317. return result;
  318. }
  319. /**
  320. * Is the single argument an owl:DifferentFrom axiom.
  321. */
  322. public boolean isDifferentFromAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  323. {
  324. boolean result = false;
  325. if (!result) throw new BuiltInNotImplementedException();
  326. return result;
  327. }
  328. /**
  329. * Check that the second class argument is a direct subclass of the first class argument. If the second argument is unbound, bind it to
  330. * the direct subclasses of the first argument (if any exist).
  331. */
  332. public boolean isDirectSubClassOf(List<BuiltInArgument> arguments) throws BuiltInException
  333. {
  334. return isSubClassOf(arguments, false);
  335. }
  336. /**
  337. * Determine if the second property argument is a direct subproperty of the first property argument. If the second argument is unbound,
  338. * bind it to the direct sub properties of the first argument (if any exist).
  339. */
  340. public boolean isDirectSubPropertyOf(List<BuiltInArgument> arguments) throws BuiltInException
  341. {
  342. return isSubPropertyOf(arguments, false);
  343. }
  344. /**
  345. * Check that the second class argument is a direct superclass of the first class argument. If the second argument is unbound, bind it to
  346. * the direct superclasses of the first argument (if any exist).
  347. */
  348. public boolean isDirectSuperClassOf(List<BuiltInArgument> arguments) throws BuiltInException
  349. {
  350. return isSuperClassOf(arguments, false);
  351. }
  352. /**
  353. * Determine if the second property argument is a direct superproperty of the first property argument. If the second argument is unbound,
  354. * bind it to the direct super properties of the first argument (if any exist).
  355. */
  356. public boolean isDirectSuperPropertyOf(List<BuiltInArgument> arguments) throws BuiltInException
  357. {
  358. return isSuperPropertyOf(arguments, false);
  359. }
  360. /**
  361. * Determine if the two class arguments represent classes or properties that are disjoint with each other. If the second argument is
  362. * unbound, bind it to the disjoint classes of the first argument (if any exist).
  363. */
  364. public boolean isDisjointWith(List<BuiltInArgument> arguments) throws BuiltInException
  365. {
  366. boolean result = false;
  367. if (!result) throw new BuiltInNotImplementedException();
  368. return result;
  369. }
  370. /**
  371. * Is the single argument an owl:DisjointWith axiom.
  372. */
  373. public boolean isDisjointWithAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  374. {
  375. boolean result = false;
  376. if (!result) throw new BuiltInNotImplementedException();
  377. return result;
  378. }
  379. /**
  380. * Is the single argument an enumerated datatype axiom.
  381. */
  382. public boolean isEnumeratedDatatypeAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  383. {
  384. boolean result = false;
  385. if (!result) throw new BuiltInNotImplementedException();
  386. return result;
  387. }
  388. /**
  389. * Determine if the two class arguments are equivalent to each other. If the second
  390. * argument is unbound, bind it to the equivalent classes of the first argument (if any exist).
  391. */
  392. public boolean isEquivalentClass(List<BuiltInArgument> arguments) throws BuiltInException
  393. {
  394. boolean result = false;
  395. if (!result) throw new BuiltInNotImplementedException();
  396. return result;
  397. }
  398. /**
  399. * Is the single argument an owl:EquivalentClass axiom.
  400. */
  401. public boolean isEquivalentClassAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  402. {
  403. boolean result = false;
  404. if (!result) throw new BuiltInNotImplementedException();
  405. return result;
  406. }
  407. /**
  408. * Determine if the two property arguments are equivalent to each other. If the second argument is unbound, bind it to the equivalent
  409. * properties of the first argument (if any exist).
  410. */
  411. public boolean isEquivalentProperty(List<BuiltInArgument> arguments) throws BuiltInException
  412. {
  413. boolean result = false;
  414. if (!result) throw new BuiltInNotImplementedException();
  415. return result;
  416. }
  417. /**
  418. * Is the single argument an owl:EquivalentProperty axiom.
  419. */
  420. public boolean isEquivalentPropertyAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  421. {
  422. boolean result = false;
  423. if (!result) throw new BuiltInNotImplementedException();
  424. return result;
  425. }
  426. /**
  427. * Determine if a single property argument is functional.
  428. */
  429. public boolean isFunctionalProperty(List<BuiltInArgument> arguments) throws BuiltInException
  430. {
  431. checkNumberOfArgumentsEqualTo(1, arguments.size());
  432. String propertyURI = getArgumentAsAPropertyURI(0, arguments);
  433. boolean result = false;
  434. try {
  435. result = SWRLOWLUtil.isOWLFunctionalProperty(getOWLModel(), propertyURI, true);
  436. } catch (SWRLOWLUtilException e) {
  437. throw new BuiltInException(e.getMessage());
  438. } // try
  439. return result;
  440. }
  441. /**
  442. * Is the single argument an owl:functionalProperty axiom.
  443. */
  444. public boolean isFunctionalPropertyAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  445. {
  446. boolean result = false;
  447. if (!result) throw new BuiltInNotImplementedException();
  448. return result;
  449. }
  450. /**
  451. * Is the single argument an owl:hasValue restriction
  452. */
  453. public boolean isHasValueRestriction(List<BuiltInArgument> arguments) throws BuiltInException
  454. {
  455. boolean result = false;
  456. if (!result) throw new BuiltInNotImplementedException();
  457. return result;
  458. }
  459. /**
  460. * Check that the first class argument is in the domain of the second property argument (excluding its superproperties). If the first
  461. * argument is unbound and the second argument is bound, bind the first argument to the domain(s) of the second property argument (if any
  462. * exist). If the first class argument is bound and the second argument is unbound, bind the second argument to the properties that have
  463. * the class in their domain (if any). An error is thrown if both arguments are unbound.
  464. */
  465. public boolean isInDirectDomainOf(List<BuiltInArgument> arguments) throws BuiltInException
  466. {
  467. return isInDomainOf(arguments, false);
  468. }
  469. /**
  470. * Check that the first class argument is in the range of the second property argument excluding its superproperties. If the first
  471. * argument is unbound, bind it to the range of the second argument (if any exist).
  472. */
  473. public boolean isInDirectRangeOf(List<BuiltInArgument> arguments) throws BuiltInException
  474. {
  475. return isInRangeOf(arguments, false);
  476. }
  477. /**
  478. * Check that the first class argument is in the domain of the second property argument (including its superproperties). If the first
  479. * argument is unbound and the second argument is bound, bind the first argument to the domain(s) of the second property argument (if any
  480. * exist). If the first class argument is bound and the second argument is unbound, bind the second argument to the properties that have
  481. * the class in their domain (if any). An error is thrown if both arguments are unbound.
  482. */
  483. public boolean isInDomainOf(List<BuiltInArgument> arguments) throws BuiltInException
  484. {
  485. return isInDomainOf(arguments, true);
  486. }
  487. /**
  488. * Is the single argument an OWL domain axiom.
  489. */
  490. public boolean isInDomainOfAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  491. {
  492. boolean result = false;
  493. if (!result) throw new BuiltInNotImplementedException();
  494. return result;
  495. }
  496. /**
  497. * Check that the first class argument is in the range of the second property argument (including its superproperties). If the first
  498. * argument is unbound, bind it to the range of the second argument (if any exist).
  499. */
  500. public boolean isInRangeOf(List<BuiltInArgument> arguments) throws BuiltInException
  501. {
  502. return isInRangeOf(arguments, true);
  503. }
  504. /**
  505. * Is the single argument an OWL range axiom.
  506. */
  507. public boolean isInRangeOfAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  508. {
  509. boolean result = false;
  510. if (!result) throw new BuiltInNotImplementedException();
  511. return result;
  512. }
  513. /**
  514. * Is the single argument an owl:InteresctionOf class description.
  515. */
  516. public boolean isIntersectionOfDescription(List<BuiltInArgument> arguments) throws BuiltInException
  517. {
  518. boolean result = false;
  519. if (!result) throw new BuiltInNotImplementedException();
  520. return result;
  521. }
  522. /**
  523. * Is the single argument an owl:InverseFunctionalProperty axiom.
  524. */
  525. public boolean isInverseFunctionalPropertyAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  526. {
  527. boolean result = false;
  528. if (!result) throw new BuiltInNotImplementedException();
  529. return result;
  530. }
  531. /**
  532. * Determine if the second property argument is the inverse of the first property argument.
  533. */
  534. public boolean isInverseOf(List<BuiltInArgument> arguments) throws BuiltInException
  535. {
  536. boolean result = false;
  537. if (!result) throw new BuiltInNotImplementedException();
  538. return result;
  539. }
  540. /**
  541. * Determine if a single property argument is inverse functional.
  542. */
  543. public boolean isInverseFunctionalProperty(List<BuiltInArgument> arguments) throws BuiltInException
  544. {
  545. checkNumberOfArgumentsEqualTo(1, arguments.size());
  546. String propertyURI = getArgumentAsAPropertyURI(0, arguments);
  547. boolean result = false;
  548. try {
  549. result = SWRLOWLUtil.isInverseFunctionalProperty(getOWLModel(), propertyURI, true);
  550. } catch (SWRLOWLUtilException e) {
  551. throw new BuiltInException(e.getMessage());
  552. } // try
  553. return result;
  554. }
  555. /**
  556. * Is the single argument an owl:inverseOf axiom.
  557. */
  558. public boolean isInverseOfAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  559. {
  560. boolean result = false;
  561. if (!result) throw new BuiltInNotImplementedException();
  562. return result;
  563. }
  564. /**
  565. * Is the single argument an rdfs:label annotation.
  566. */
  567. public boolean isRDFSLabelAnnotation(List<BuiltInArgument> arguments) throws BuiltInException
  568. {
  569. boolean result = false;
  570. if (!result) throw new BuiltInNotImplementedException();
  571. return result;
  572. }
  573. /**
  574. * Is the single argument an owl:MaxCardinality restriction.
  575. */
  576. public boolean isMaxCardinalityRestriction(List<BuiltInArgument> arguments) throws BuiltInException
  577. {
  578. boolean result = false;
  579. if (!result) throw new BuiltInNotImplementedException();
  580. return result;
  581. }
  582. /**
  583. * Is the single argument an owl:MinCardinality restriction.
  584. */
  585. public boolean isMinCardinalityRestriction(List<BuiltInArgument> arguments) throws BuiltInException
  586. {
  587. boolean result = false;
  588. if (!result) throw new BuiltInNotImplementedException();
  589. return result;
  590. }
  591. /**
  592. * Determine if a single argument is an OWL object property. If the argument is unbound, bind it to all OWL object properties in an
  593. * ontology.
  594. */
  595. public boolean isObjectProperty(List<BuiltInArgument> arguments) throws BuiltInException
  596. {
  597. checkNumberOfArgumentsEqualTo(1, arguments.size());
  598. boolean isUnboundArgument = isUnboundArgument(0, arguments);
  599. boolean result = false;
  600. try {
  601. if (isUnboundArgument) {
  602. MultiArgument multiArgument = createMultiArgument();
  603. for (edu.stanford.smi.protegex.owl.model.OWLProperty property : SWRLOWLUtil.getUserDefinedOWLObjectProperties(getOWLModel())) {
  604. if (property.isObjectProperty()) multiArgument.addArgument(createObjectPropertyArgument(property.getURI()));
  605. else multiArgument.addArgument(createDataPropertyArgument(property.getURI()));
  606. } // for
  607. arguments.get(0).setBuiltInResult(multiArgument);
  608. result = !multiArgument.hasNoArguments();
  609. } else {
  610. String propertyURI = getArgumentAsAPropertyURI(0, arguments);
  611. result = SWRLOWLUtil.isOWLObjectProperty(getOWLModel(), propertyURI, false);
  612. } // if
  613. } catch (SWRLOWLUtilException e) {
  614. throw new BuiltInException(e.getMessage());
  615. } // try
  616. return result;
  617. }
  618. /**
  619. * Is the single argument an owl:oneOf class description.
  620. */
  621. public boolean isOneOfClassDescription(List<BuiltInArgument> arguments) throws BuiltInException
  622. {
  623. boolean result = false;
  624. if (!result) throw new BuiltInNotImplementedException();
  625. return result;
  626. }
  627. /**
  628. * Is the single argument an owl:Ontology resource. If the argument is unbound, bind it to the current ontology.
  629. */
  630. public boolean isOntology(List<BuiltInArgument> arguments) throws BuiltInException
  631. {
  632. boolean result = false;
  633. if (!result) throw new BuiltInNotImplementedException();
  634. return result;
  635. }
  636. /**
  637. * Determine if a single property argument is an OWL object or data property. If the argument is unbound, bind it to all OWL properties in an ontology.
  638. */
  639. public boolean isProperty(List<BuiltInArgument> arguments) throws BuiltInException
  640. {
  641. checkNumberOfArgumentsEqualTo(1, arguments.size());
  642. boolean isUnboundArgument = isUnboundArgument(0, arguments);
  643. boolean result = false;
  644. try {
  645. if (isUnboundArgument) {
  646. MultiArgument multiArgument = createMultiArgument();
  647. for (edu.stanford.smi.protegex.owl.model.OWLProperty property : SWRLOWLUtil.getUserDefinedOWLProperties(getOWLModel())) {
  648. if (property.isObjectProperty()) multiArgument.addArgument(createObjectPropertyArgument(property.getURI()));
  649. else multiArgument.addArgument(createDataPropertyArgument(property.getURI()));
  650. } // for
  651. arguments.get(0).setBuiltInResult(multiArgument);
  652. result = !multiArgument.hasNoArguments();
  653. } else {
  654. String propertyURI = getArgumentAsAPropertyURI(0, arguments);
  655. result = SWRLOWLUtil.isOWLProperty(getOWLModel(), propertyURI, false);
  656. } // if
  657. } catch (SWRLOWLUtilException e) {
  658. throw new BuiltInException(e.getMessage());
  659. } // try
  660. return result;
  661. }
  662. /**
  663. * Is the single argument an rdfs:seeAlso annotation.
  664. */
  665. public boolean isRDFSSeeAlsoAnnotation(List<BuiltInArgument> arguments) throws BuiltInException
  666. {
  667. boolean result = false;
  668. if (!result) throw new BuiltInNotImplementedException();
  669. return result;
  670. }
  671. /**
  672. * Is the single argument an owl:SameAs axiom.
  673. */
  674. public boolean isSameAsAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  675. {
  676. boolean result = false;
  677. if (!result) throw new BuiltInNotImplementedException();
  678. return result;
  679. }
  680. /**
  681. * Check that the first class argument is a subclass of the second class argument. If the first argument is unbound, bind it to
  682. * the subclasses of the second argument (if any exist).
  683. */
  684. public boolean isSubClassOf(List<BuiltInArgument> arguments) throws BuiltInException
  685. {
  686. return isSubClassOf(arguments, true);
  687. }
  688. /**
  689. * Determine if the first property argument is a subproperty of the second property argument. If the first argument is unbound,
  690. * bind it to the sub properties of the second argument (if any exist).
  691. */
  692. public boolean isSubPropertyOf(List<BuiltInArgument> arguments) throws BuiltInException
  693. {
  694. return isSubPropertyOf(arguments, true);
  695. }
  696. /**
  697. * Check that the first class argument is a superclass of the second class argument. If the first argument is unbound, bind it to
  698. * the superclasses of the second argument (if any exist).
  699. */
  700. public boolean isSuperClassOf(List<BuiltInArgument> arguments) throws BuiltInException
  701. {
  702. return isSuperClassOf(arguments, true);
  703. }
  704. /**
  705. * Determine if the first property argument is a superproperty of the second property argument. If the first argument is unbound,
  706. * bind it to the super properties of the second argument (if any exist).
  707. */
  708. public boolean isSuperPropertyOf(List<BuiltInArgument> arguments) throws BuiltInException
  709. {
  710. return isSuperPropertyOf(arguments, true);
  711. }
  712. /**
  713. * Determine if a single property argument is symmetric.
  714. */
  715. public boolean isSymmetricProperty(List<BuiltInArgument> arguments) throws BuiltInException
  716. {
  717. checkNumberOfArgumentsEqualTo(1, arguments.size());
  718. String propertyURI = getArgumentAsAPropertyURI(0, arguments);
  719. boolean result = false;
  720. try {
  721. result = SWRLOWLUtil.isOWLSymmetricProperty(getOWLModel(), propertyURI, true);
  722. } catch (SWRLOWLUtilException e) {
  723. throw new BuiltInException(e.getMessage());
  724. } // try
  725. return result;
  726. }
  727. /**
  728. * Is the single argument an owl:SymmetricProperty axiom.
  729. */
  730. public boolean isSymmetricPropertyAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  731. {
  732. boolean result = false;
  733. if (!result) throw new BuiltInNotImplementedException();
  734. return result;
  735. }
  736. /**
  737. * Determine if a single property argument is a transitive property.
  738. */
  739. public boolean isTransitiveProperty(List<BuiltInArgument> arguments) throws BuiltInException
  740. {
  741. checkNumberOfArgumentsEqualTo(1, arguments.size());
  742. String propertyURI = getArgumentAsAPropertyURI(0, arguments);
  743. boolean result = false;
  744. try {
  745. result = SWRLOWLUtil.isOWLTransitiveProperty(getOWLModel(), propertyURI);
  746. } catch (SWRLOWLUtilException e) {
  747. throw new BuiltInException(e.getMessage());
  748. } // try
  749. return result;
  750. }
  751. /**
  752. * Is the single argument an owl:TransitiveProperty axiom.
  753. */
  754. public boolean isTransitivePropertyAxiom(List<BuiltInArgument> arguments) throws BuiltInException
  755. {
  756. boolean result = false;
  757. if (!result) throw new BuiltInNotImplementedException();
  758. return result;
  759. }
  760. public boolean isRestriction(List<BuiltInArgument> arguments) throws BuiltInException
  761. {
  762. checkNumberOfArgumentsEqualTo(1, arguments.size());
  763. String classURI = getArgumentAsAClassURI(0, arguments);
  764. boolean result = false;
  765. try {
  766. result = SWRLOWLUtil.isAnonymousResourceName(getOWLModel(), classURI);
  767. } catch (SWRLOWLUtilException e) {
  768. throw new BuiltInException(e.getMessage());
  769. } // try
  770. return result;
  771. }
  772. /**
  773. * Is the single argument an owl:UnionOf class description.
  774. */
  775. public boolean isUnionOfDescription(List<BuiltInArgument> arguments) throws BuiltInException
  776. {
  777. boolean result = false;
  778. if (!result) throw new BuiltInNotImplementedException();
  779. return result;
  780. }
  781. /**
  782. * Is the single argument an owl:versionInfo annotation.
  783. */
  784. public boolean isVersionInfoAnnotation(List<BuiltInArgument> arguments) throws BuiltInException
  785. {
  786. boolean result = false;
  787. if (!result) throw new BuiltInNotImplementedException();
  788. return result;
  789. }
  790. /**
  791. * It the second class description argument a subject of the first axiom argument. If the second argument is unbound, bind it to the the
  792. * axiom's subject(s).
  793. */
  794. public boolean onDescription(List<BuiltInArgument> arguments) throws BuiltInException
  795. {
  796. boolean result = false;
  797. if (!result) throw new BuiltInNotImplementedException();
  798. return result;
  799. }
  800. /**
  801. * It the second individual argument a subject of the first individual axiom argument. If the second argument is unbound, bind it to the
  802. * individual axiom's subject(s).
  803. */
  804. public boolean onIndividual(List<BuiltInArgument> arguments) throws BuiltInException
  805. {
  806. boolean result = false;
  807. if (!result) throw new BuiltInNotImplementedException();
  808. return result;
  809. }
  810. /**
  811. * It the second property argument a subject of the first property axiom argument. If the second argument is unbound, bind it to the
  812. * property axiom's subject(s).
  813. */
  814. public boolean isSomeValuesFrom(List<BuiltInArgument> arguments) throws BuiltInException
  815. {
  816. boolean result = false;
  817. String restrictionURI, onPropertyURI, onClassURI;
  818. checkNumberOfArgumentsEqualTo(3, arguments.size());
  819. restrictionURI = getArgumentAsAClassURI(0, arguments);
  820. onPropertyURI = getArgumentAsAPropertyURI(1, arguments);
  821. try {
  822. if (getIsInConsequent()) {
  823. OWLDataFactory owlFactory = getBuiltInBridge().getOWLDataFactory();
  824. OWLSomeValuesFrom someValuesFrom;
  825. OWLProperty onProperty;
  826. if (isArgumentAString(2, arguments)) {
  827. onClassURI = SWRLOWLUtil.getFullName(getOWLModel(), getArgumentAsAString(2, arguments));
  828. if (!getBuiltInBridge().isOWLClass(onClassURI)) getBuiltInBridge().injectOWLClassDeclaration(onClassURI);
  829. } else onClassURI = getArgumentAsAClassURI(2, arguments);
  830. if (SWRLOWLUtil.isOWLObjectProperty(getOWLModel(), onPropertyURI)) onProperty = owlFactory.getOWLObjectProperty(onPropertyURI);
  831. else onProperty = owlFactory.getOWLDataProperty(onPropertyURI);
  832. someValuesFrom = owlFactory.getOWLSomeValuesFrom(owlFactory.getOWLClass(restrictionURI), onProperty, owlFactory.getOWLClass(onClassURI));
  833. // getInvokingBridge().injectOWLAxiom(someValuesFrom); // TODO
  834. if (someValuesFrom != null) throw new BuiltInNotImplementedException();
  835. } else {
  836. onClassURI = getArgumentAsAClassURI(2, arguments);
  837. throw new BuiltInNotImplementedException();
  838. } // if
  839. } catch (OWLConversionFactoryException e) {
  840. throw new BuiltInException(e.getMessage());
  841. } // try
  842. return result;
  843. }
  844. /**
  845. * It the second datatype value argument a subject of the first datatype axiom argument. If the second argument is unbound, bind it to the
  846. * data value axiom's subject(s).
  847. */
  848. public boolean onValue(List<BuiltInArgument> arguments) throws BuiltInException
  849. {
  850. boolean result = false;
  851. if (!result) throw new BuiltInNotImplementedException();
  852. return result;
  853. }
  854. /**
  855. * Check that the two class or property arguments refer to the same underlying entity.
  856. */
  857. public boolean equalTo(List<BuiltInArgument> arguments) throws BuiltInException
  858. {
  859. checkNumberOfArgumentsEqualTo(2, arguments.size());
  860. String resourceURI1 = getArgumentAsAURI(0, arguments);
  861. String resourceURI2 = getArgumentAsAURI(1, arguments);
  862. return resourceURI1.equals(resourceURI2); // According to RDF specification URI names must character (and case) match.
  863. }
  864. /**
  865. * Check that the two class or property arguments do not refer to the same underlying entity.
  866. */
  867. public boolean notEqualTo(List<BuiltInArgument> arguments) throws BuiltInException
  868. {
  869. return !equalTo(arguments);
  870. }
  871. private boolean isSuperClassOf(List<BuiltInArgument> arguments, boolean transitive) throws BuiltInException
  872. {
  873. boolean superClassArgumentUnbound = false;
  874. String classURI;
  875. boolean result = false;
  876. checkNumberOfArgumentsEqualTo(2, arguments.size());
  877. superClassArgumentUnbound = isUnboundArgument(0, arguments);
  878. classURI = getArgumentAsAClassURI(1, arguments);
  879. try {
  880. if (superClassArgumentUnbound) {
  881. List<edu.stanford.smi.protegex.owl.model.OWLNamedClass> superClasses;
  882. if (transitive) superClasses = SWRLOWLUtil.getSuperClassesOf(getOWLModel(), classURI);
  883. else superClasses = SWRLOWLUtil.getDirectSuperClassesOf(getOWLModel(), classURI);
  884. if (!superClasses.isEmpty()) {
  885. MultiArgument multiArgument = createMultiArgument();
  886. for (edu.stanford.smi.protegex.owl.model.OWLNamedClass superClass : superClasses) multiArgument.addArgument(createClassArgument(superClass.getURI()));
  887. arguments.get(0).setBuiltInResult(multiArgument);
  888. result = !multiArgument.hasNoArguments();
  889. } // if
  890. } else {
  891. String superClassURI = getArgumentAsAClassURI(0, arguments);
  892. if (transitive) result = SWRLOWLUtil.isOWLSuperClassOf(getOWLModel(), superClassURI, classURI, true);
  893. else result = SWRLOWLUtil.isOWLDirectSuperClassOf(getOWLModel(), superClassURI, classURI, true);
  894. } // if
  895. } catch (SWRLOWLUtilException e) {
  896. throw new BuiltInException(e.getMessage());
  897. } // try
  898. return result;
  899. }
  900. private boolean isSubClassOf(List<BuiltInArgument> arguments, boolean transitive) throws BuiltInException
  901. {
  902. boolean subClassArgumentUnbound = false;
  903. String classURI;
  904. boolean result = false;
  905. checkNumberOfArgumentsEqualTo(2, arguments.size());
  906. subClassArgumentUnbound = isUnboundArgument(0, arguments);
  907. try {
  908. if (getIsInConsequent()) {
  909. OWLDataFactory owlFactory = getBuiltInBridge().getOWLDataFactory();
  910. String superclassURI;
  911. if (isArgumentAString(1, arguments)) {
  912. superclassURI = SWRLOWLUtil.getFullName(getOWLModel(), getArgumentAsAString(1, arguments));
  913. if (!getBuiltInBridge().isOWLClass(superclassURI)) getBuiltInBridge().injectOWLClassDeclaration(superclassURI);
  914. } else superclassURI = getArgumentAsAClassURI(1, arguments);
  915. if (isArgumentAString(0, arguments))
  916. classURI = SWRLOWLUtil.getFullName(getOWLModel(), getArgumentAsAString(0, arguments));
  917. else classURI = getArgumentAsAClassURI(0, arguments);
  918. getBuiltInBridge().injectOWLAxiom(owlFactory.getOWLSubClassAxiom(owlFactory.getOWLClass(classURI),owlFactory.getOWLClass(superclassURI)));
  919. result = true;
  920. } else {
  921. classURI = getArgumentAsAClassURI(1, arguments);
  922. if (subClassArgumentUnbound) {
  923. List<edu.stanford.smi.protegex.owl.model.OWLNamedClass> subClasses;
  924. if (transitive) subClasses = SWRLOWLUtil.getSubClassesOf(getOWLModel(), classURI);
  925. else subClasses = SWRLOWLUtil.getDirectSubClassesOf(getOWLModel(), classURI);
  926. if (!subClasses.isEmpty()) {
  927. MultiArgument multiArgument = createMultiArgument();
  928. for (edu.stanford.smi.protegex.owl.model.OWLNamedClass subClass : subClasses) multiArgument.addArgument(createClassArgument(subClass.getURI()));
  929. arguments.get(0).setBuiltInResult(multiArgument);
  930. result = !multiArgument.hasNoArguments();
  931. } // if
  932. } else {
  933. String subClassURI = getArgumentAsAClassURI(0, arguments);
  934. if (transitive) result = SWRLOWLUtil.isOWLSubClassOf(getOWLModel(), subClassURI, classURI, true);
  935. else result = SWRLOWLUtil.isOWLDirectSubClassOf(getOWLModel(), subClassURI, classURI, true);
  936. } // if
  937. } // if
  938. } catch (SWRLOWLUtilException e) {
  939. throw new BuiltInException(e.getMessage());
  940. } // try
  941. return result;
  942. }
  943. private boolean isSubPropertyOf(List<BuiltInArgument> arguments, boolean transitive) throws BuiltInException
  944. {
  945. boolean subPropertyArgumentUnbound = false;
  946. String propertyURI;
  947. boolean result = false;
  948. checkNumberOfArgumentsEqualTo(2, arguments.size());
  949. subPropertyArgumentUnbound = isUnboundArgument(0, arguments);
  950. propertyURI = getArgumentAsAPropertyURI(1, arguments);
  951. try {
  952. if (subPropertyArgumentUnbound) {
  953. List<edu.stanford.smi.protegex.owl.model.OWLProperty> subProperties;
  954. if (transitive) subProperties = SWRLOWLUtil.getSubPropertiesOf(getOWLModel(), propertyURI);
  955. else subProperties = SWRLOWLUtil.getDirectSubPropertiesOf(getOWLModel(), propertyURI);
  956. if (!subProperties.isEmpty()) {
  957. MultiArgument multiArgument = createMultiArgument();
  958. for (edu.stanford.smi.protegex.owl.model.OWLProperty subProperty : subProperties) {
  959. if (subProperty.isObjectProperty()) multiArgument.addArgument(createObjectPropertyArgument(subProperty.getURI()));
  960. else multiArgument.addArgument(createDataPropertyArgument(subProperty.getURI()));
  961. } // for
  962. arguments.get(0).setBuiltInResult(multiArgument);
  963. result = !multiArgument.hasNoArguments();
  964. } // if
  965. } else {
  966. String subPropertyURI = getArgumentAsAPropertyURI(0, arguments);
  967. if (transitive) result = SWRLOWLUtil.isOWLSubPropertyOf(getOWLModel(), subPropertyURI, propertyURI, true);
  968. else result = SWRLOWLUtil.isOWLDirectSubPropertyOf(getOWLModel(), subPropertyURI, propertyURI, true);
  969. } // if
  970. } catch (SWRLOWLUtilException e) {
  971. throw new BuiltInException(e.getMessage());
  972. } // try
  973. return result;
  974. }
  975. private boolean isSuperPropertyOf(List<BuiltInArgument> arguments, boolean transitive) throws BuiltInException
  976. {
  977. boolean superPropertyArgumentUnbound = false;
  978. String propertyURI;
  979. boolean result = false;
  980. checkNumberOfArgumentsEqualTo(2, arguments.size());
  981. superPropertyArgumentUnbound = isUnboundArgument(0, arguments);
  982. propertyURI = getArgumentAsAPropertyURI(1, arguments);
  983. try {
  984. if (superPropertyArgumentUnbound) {
  985. List<edu.stanford.smi.protegex.owl.model.OWLProperty> superProperties;
  986. if (transitive) superProperties = SWRLOWLUtil.getSuperPropertiesOf(getOWLModel(), propertyURI);
  987. else superProperties = SWRLOWLUtil.getDirectSuperPropertiesOf(getOWLModel(), propertyURI);
  988. if (!superProperties.isEmpty()) {
  989. MultiArgument multiArgument = createMultiArgument();
  990. for (edu.stanford.smi.protegex.owl.model.OWLProperty superProperty : superProperties) {
  991. if (superProperty.isObjectProperty()) multiArgument.addArgument(createObjectPropertyArgument(superProperty.getURI()));
  992. else multiArgument.addArgument(createDataPropertyArgument(superProperty.getURI()));
  993. } // for
  994. arguments.get(0).setBuiltInResult(multiArgument);
  995. result = !multiArgument.hasNoArguments();
  996. } // if
  997. } else {
  998. String superPropertyURI = getArgumentAsAPropertyURI(0, arguments);
  999. if (transitive) result = SWRLOWLUtil.isOWLSuperPropertyOf(getOWLModel(), superPropertyURI, propertyURI, true);
  1000. else result = SWRLOWLUtil.isOWLDirectSuperPropertyOf(getOWLModel(), superPropertyURI, propertyURI, true);
  1001. } // if
  1002. } catch (SWRLOWLUtilException e) {
  1003. throw new BuiltInException(e.getMessage());
  1004. } // try
  1005. return result;
  1006. }
  1007. private boolean isInDomainOf(List<BuiltInArgument> arguments, boolean includingSuperproperties) throws BuiltInException
  1008. {
  1009. boolean domainClassArgumentUnbound, propertyArgumentUnbound = false;
  1010. String propertyURI, domainClassURI;
  1011. boolean result = false;
  1012. checkNumberOfArgumentsEqualTo(2, arguments.size());
  1013. domainClassArgumentUnbound = isUnboundArgument(0, arguments);
  1014. propertyArgumentUnbound = isUnboundArgument(1, arguments);
  1015. if (domainClassArgumentUnbound && propertyArgumentUnbound) throw new BuiltInException("at least one argument must be bound");
  1016. try {
  1017. if (domainClassArgumentUnbound) {
  1018. Set<edu.stanford.smi.protegex.owl.model.OWLNamedClass> domainClasses;
  1019. propertyURI = getArgumentAsAPropertyURI(1, arguments);
  1020. if (includingSuperproperties) domainClasses = SWRLOWLUtil.getOWLDomainClasses(getOWLModel(), propertyURI);
  1021. else domainClasses = SWRLOWLUtil.getDirectOWLDomainClasses(getOWLModel(), propertyURI);
  1022. if (!domainClasses.isEmpty()) {
  1023. MultiArgument multiArgument = createMultiArgument();
  1024. for (edu.stanford.smi.protegex.owl.model.OWLNamedClass domainClass : domainClasses) multiArgument.addArgument(createClassArgument(domainClass.getURI()));
  1025. arguments.get(0).setBuiltInResult(multiArgument);
  1026. result = !multiArgument.hasNoArguments();
  1027. } // if
  1028. } else if (propertyArgumentUnbound) {
  1029. Set<edu.stanford.smi.protegex.owl.model.OWLProperty> domainProperties;
  1030. domainClassURI = getArgumentAsAClassURI(0, arguments);
  1031. domainProperties = SWRLOWLUtil.getDomainProperties(getOWLModel(), domainClassURI, includingSuperproperties);
  1032. if (!domainProperties.isEmpty()) {
  1033. MultiArgument multiArgument = createMultiArgument();
  1034. for (edu.stanford.smi.protegex.owl.model.OWLProperty property : domainProperties) {
  1035. if (property.isObjectProperty()) multiArgument.addArgument(createObjectPropertyArgument(property.getURI()));
  1036. else multiArgument.addArgument(createDataPropertyArgument(property.getURI()));
  1037. } // for
  1038. arguments.get(1).setBuiltInResult(multiArgument);
  1039. result = !multiArgument.hasNoArguments();
  1040. } // if
  1041. } else { // Both arguments bound
  1042. domainClassURI = getArgumentAsAClassURI(0, arguments);
  1043. propertyURI = getArgumentAsAPropertyURI(1, arguments);
  1044. if (includingSuperproperties)
  1045. result = SWRLOWLUtil.isInOWLPropertyDomain(getOWLModel(), propertyURI, domainClassURI, true);
  1046. else
  1047. result = SWRLOWLUtil.isInDirectOWLPropertyDomain(getOWLModel(), propertyURI, domainClassURI, true);
  1048. } // if
  1049. } catch (SWRLOWLUtilException e) {
  1050. throw new BuiltInException(e.getMessage());
  1051. } // try
  1052. return result;
  1053. }
  1054. private boolean isInRangeOf(List<BuiltInArgument> arguments, boolean includingSuperproperties) throws BuiltInException
  1055. {
  1056. boolean rangeClassArgumentUnbound = false;
  1057. String rangeClassURI, propertyURI;
  1058. boolean result = false;
  1059. checkNumberOfArgumentsEqualTo(2, arguments.size());
  1060. rangeClassArgumentUnbound = isUnboundArgument(0, arguments);
  1061. propertyURI = getArgumentAsAPropertyURI(1, arguments);
  1062. try {
  1063. if (rangeClassArgumentUnbound) {
  1064. Set<edu.stanford.smi.protegex.owl.model.OWLNamedClass> rangeClasses;
  1065. if (includingSuperproperties) rangeClasses = SWRLOWLUtil.getOWLRangeClasses(getOWLModel(), propertyURI);
  1066. else rangeClasses = SWRLOWLUtil.getOWLDirectRangeClasses(getOWLModel(), propertyURI);
  1067. if (!rangeClasses.isEmpty()) {
  1068. MultiArgument multiArgument = createMultiArgument();
  1069. for (edu.stanford.smi.protegex.owl.model.OWLNamedClass rangeClass : rangeClasses)
  1070. multiArgument.addArgument(createClassArgument(rangeClass.getURI()));
  1071. arguments.get(0).setBuiltInResult(multiArgument);
  1072. result = !multiArgument.hasNoArguments();
  1073. } // if
  1074. } else {
  1075. propertyURI = getArgumentAsAPropertyURI(1, arguments);
  1076. rangeClassURI = getArgumentAsAClassURI(0, arguments);
  1077. if (includingSuperproperties) result = SWRLOWLUtil.isInPropertyRange(getOWLModel(), propertyURI, rangeClassURI, true);
  1078. else result = SWR

Large files files are truncated, but you can click here to view the full file