org.apache.jena.rdf.model.Model.union()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中org.apache.jena.rdf.model.Model.union()方法的一些代码示例,展示了Model.union()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.union()方法的具体详情如下:
包路径:org.apache.jena.rdf.model.Model
类名称:Model
方法名:union

Model.union介绍

[英]Create a new, independant, model containing all the statements in this model together with all of those in another given model. By independant we mean that changes to the result model do not affect the operand models, and vice versa.

The new model need not be of the same type as either this model or the argument model: typically it will be a memory-based model, even if this model is a database model.
[中]创建一个新的独立模型,包含此模型中的所有语句以及另一个给定模型中的所有语句。所谓独立,我们的意思是对结果模型的更改不会影响操作数模型,反之亦然。
新模型不必与此模型或参数模型的类型相同:通常它将是基于内存的模型,即使此模型是数据库模型。

代码示例

代码示例来源:origin: vivo-project/Vitro

@Override
public Model union(Model model) {
  return inner.union(model);
}

代码示例来源:origin: apache/jena

@Override
public Model union(final Model model) throws ReadDeniedException, AuthenticationRequiredException {
  checkRead();
  if (canRead(Triple.ANY)) {
    return holder.getBaseItem().union(model);
  } else {
    return createCopy().union(model);
  }
}

代码示例来源:origin: apache/odftoolkit

/**
 * Get all two types of RDF Metadata through GRDDL XSLT:
 * http://docs.oasis-open.org/office/v1.2/os/OpenDocument-v1.2-os-part1.html#__RefHeading__1415068_253892949
 */
public Model getRDFMetadata() throws Exception {
  Model m = getInContentMetadata().union(this.getManifestRDFMetadata());
  return m;
}

代码示例来源:origin: AKSW/RDFUnit

@Override
public void readDataset(Dataset dataset){
  dataset.setDefaultModel(dataset.getDefaultModel().union(read()));
}

代码示例来源:origin: org.aksw.rdfunit/rdfunit-io

@Override
public void readDataset(Dataset dataset){
  dataset.setDefaultModel(dataset.getDefaultModel().union(read()));
}

代码示例来源:origin: apache/odftoolkit

/**
 * Get in-content metadata cache model
 *
 * @return The in-content metadata cache model
 * @throws Exception
 */
public Model getInContentMetadataFromCache() throws Exception {
  Model m = ModelFactory.createDefaultModel();
  // find and merge the RDF triples cache from the OdfXMLFile files
  for (OdfXMLFile file : OdfXMLFile.values()) {
    for (Model m1 : this.getFileDom(file).getInContentMetadataCache().values()) {
      m = m.union(m1);
    }
  }
  return m;
}

代码示例来源:origin: apache/odftoolkit

/**
   * Get in-content metadata model of bookmarks
   *
   * @return The in-content metadata model of bookmarks
   * @throws Exception
   */
  public Model getBookmarkRDFMetadata() throws Exception {
    Model m = ModelFactory.createDefaultModel();
    for (OdfXMLFile file : OdfXMLFile.values()) {
      OdfFileDom dom = getFileDom(file);
      m = m.union(dom.getBookmarkRDFMetadata());
    }
    return m;
  }
}

代码示例来源:origin: apache/jena

@Override
  public BiConsumer<Dataset, Dataset> accumulator() {
    return (d1, d2) -> {
      d1.getDefaultModel().add(d2.getDefaultModel());
      d2.listNames().forEachRemaining(name -> {
        Model union = d1.getNamedModel(name).union(d2.getNamedModel(name));
        d1.replaceNamedModel(name, union);
      });
    };
  }
}

代码示例来源:origin: com.powsybl/powsybl-triple-store-impl-jena

@Override
public void read(String base, String contextName, InputStream is) {
  Model m = ModelFactory.createDefaultModel();
  m.read(is, base, formatFromName(contextName));
  dataset.addNamedModel(namedModelFromName(contextName), m);
  union = union.union(m);
}

代码示例来源:origin: apache/jena

public void testFollowOwlImportsDeeply()
  {
  final Model 
    m1 = model( "this hasMarker M1; _x owl:imports M2" ),
    m2 = model( "this hasMarker M2" );
  Model  m = model( "x ja:reasoner y; _x owl:imports M1" );
  FileManager fm = new FixedFileManager() 
    .add( "eh:/M1", m1 ).add( "eh:/M2", m2 );
  Model result = new ImportManager().withImports( fm, m );
  assertInstanceOf( MultiUnion.class, result.getGraph() );
  assertIsoModels( m1.union(m2).union(m), result );
  }

代码示例来源:origin: org.apache.jena/jena-core

public void testFollowOwlImportsDeeply()
  {
  final Model 
    m1 = model( "this hasMarker M1; _x owl:imports M2" ),
    m2 = model( "this hasMarker M2" );
  Model  m = model( "x ja:reasoner y; _x owl:imports M1" );
  FileManager fm = new FixedFileManager() 
    .add( "eh:/M1", m1 ).add( "eh:/M2", m2 );
  Model result = new ImportManager().withImports( fm, m );
  assertInstanceOf( MultiUnion.class, result.getGraph() );
  assertIsoModels( m1.union(m2).union(m), result );
  }

代码示例来源:origin: apache/jena

public void testCatchesCircularity()
  {
  final Model 
    m1 = model( "this hasMarker Mx; _x owl:imports My" ),
    m2 = model( "this hasMarker My; _x owl:imports Mx" );
  FileManager fm = new FixedFileManager()
    .add( "eh:/Mx", m1 ).add( "eh:/My", m2 );
  Model result = new ImportManager().withImports( fm, m1 );
  assertIsoModels( m1.union( m2 ), result );
  }

代码示例来源:origin: org.apache.jena/jena-core

public void testCatchesCircularity()
  {
  final Model 
    m1 = model( "this hasMarker Mx; _x owl:imports My" ),
    m2 = model( "this hasMarker My; _x owl:imports Mx" );
  FileManager fm = new FixedFileManager()
    .add( "eh:/Mx", m1 ).add( "eh:/My", m2 );
  Model result = new ImportManager().withImports( fm, m1 );
  assertIsoModels( m1.union( m2 ), result );
  }

代码示例来源:origin: apache/jena

public void testFollowOwlImports()
  {
  final Model modelToLoad = model( "this hasMarker B5" );
  Model  m = model( "x ja:reasoner y; _x owl:imports eh:/loadMe" );
  FileManager fm = new FixedFileManager().add( "eh:/loadMe", modelToLoad ); 
  Model m2 = new ImportManager().withImports( fm, m );
  assertInstanceOf( MultiUnion.class, m2.getGraph() );
  assertIsoModels( modelToLoad.union( m ), m2 );
  }

代码示例来源:origin: apache/jena

public void testImportMayBeLiteral()
  {
  final Model modelToLoad = model( "this hasMarker B5" );
  Model  m = model( "x ja:reasoner y; _x ja:imports 'eh:/loadMe'" );
  FileManager fm = new FixedFileManager().add( "eh:/loadMe", modelToLoad ); 
  Model m2 = new ImportManager().withImports( fm, m );
  assertInstanceOf( MultiUnion.class, m2.getGraph() );
  assertIsoModels( modelToLoad.union( m ), m2 );
  }

代码示例来源:origin: org.apache.jena/jena-core

public void testFollowOwlImports()
  {
  final Model modelToLoad = model( "this hasMarker B5" );
  Model  m = model( "x ja:reasoner y; _x owl:imports eh:/loadMe" );
  FileManager fm = new FixedFileManager().add( "eh:/loadMe", modelToLoad ); 
  Model m2 = new ImportManager().withImports( fm, m );
  assertInstanceOf( MultiUnion.class, m2.getGraph() );
  assertIsoModels( modelToLoad.union( m ), m2 );
  }

代码示例来源:origin: apache/jena

public void testFollowJAImports()
  {
  final Model modelToLoad = model( "this hasMarker B5" );
  Model  m = model( "x ja:reasoner y; _x ja:imports eh:/loadMe" );
  FileManager fm = new FixedFileManager().add( "eh:/loadMe", modelToLoad ); 
  Model m2 = new ImportManager().withImports( fm, m );
  assertInstanceOf( MultiUnion.class, m2.getGraph() );
  assertIsoModels( modelToLoad.union( m ), m2 );
  }

代码示例来源:origin: org.apache.jena/jena-core

public void testImportMayBeLiteral()
  {
  final Model modelToLoad = model( "this hasMarker B5" );
  Model  m = model( "x ja:reasoner y; _x ja:imports 'eh:/loadMe'" );
  FileManager fm = new FixedFileManager().add( "eh:/loadMe", modelToLoad ); 
  Model m2 = new ImportManager().withImports( fm, m );
  assertInstanceOf( MultiUnion.class, m2.getGraph() );
  assertIsoModels( modelToLoad.union( m ), m2 );
  }

代码示例来源:origin: org.apache.jena/jena-core

public void testFollowJAImports()
  {
  final Model modelToLoad = model( "this hasMarker B5" );
  Model  m = model( "x ja:reasoner y; _x ja:imports eh:/loadMe" );
  FileManager fm = new FixedFileManager().add( "eh:/loadMe", modelToLoad ); 
  Model m2 = new ImportManager().withImports( fm, m );
  assertInstanceOf( MultiUnion.class, m2.getGraph() );
  assertIsoModels( modelToLoad.union( m ), m2 );
  }

代码示例来源:origin: apache/jena

/**
   * Test problem with bindSchema not interacting properly with validation.
   */
  public void testBindSchemaValidate() {
    Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
    Model schema = FileManager.get().loadModel("file:testing/reasoners/bugs/sbug.owl");
    Model data = FileManager.get().loadModel("file:testing/reasoners/bugs/sbug.rdf");

    // Union version
    InfModel infu = ModelFactory.createInfModel(reasoner, data.union(schema));
    ValidityReport validity = infu.validate();
    assertTrue( ! validity.isValid());
    // debug print
//        for (Iterator i = validity.getReports(); i.hasNext(); ) {
//            System.out.println(" - " + i.next());
//        }

    // bindSchema version
    InfModel inf = ModelFactory.createInfModel(reasoner.bindSchema(schema), data);
    validity = inf.validate();
    assertTrue( ! validity.isValid());
  }

相关文章

Model类方法