Пример #1
0
  public void check(ExistsCondition condition) throws VerificationException {

    Resource resource = condition.getResource();
    assert resource.isInstantiated();
    assert resource.isLoaded();
    if (ONTOLOGY.equals(resource.getType().toString())) {
      URL url = (URL) resource.getValue();
      OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
      try {
        manager.loadOntologyFromPhysicalURI(url.toURI());
      } catch (Exception x) {
        throw new VerificationException("The resource " + url + " cannot be parsed as ontology", x);
      }
    }
  }
Пример #2
0
  public Object load(URI type, String name, Connector connector) throws ResourceLoaderException {

    if (!type.toString().startsWith(NS))
      throw new ResourceLoaderException(
          "This plugin cannot be used to instantiate resources of this type: " + type);
    try {
      // check whether this is a OWL resource - try to parse it
      OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
      EclipsePlugin plugin = (EclipsePlugin) connector.getOwner();
      Bundle bundle = plugin.getBundle();
      return bundle.getEntry(name);
    } catch (Exception x) {
      Logger.error(
          "Error loading ontology " + name + " from plugin " + connector.getOwner().getId());
      throw new ResourceLoaderException(
          "Error loading ontology " + name + " from plugin " + connector.getOwner().getId(), x);
    }
  }