本文整理匯總了Java中com.hp.hpl.jena.rdf.model.Model.difference方法的典型用法代碼示例。如果您正苦於以下問題:Java Model.difference方法的具體用法?Java Model.difference怎麽用?Java Model.difference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hp.hpl.jena.rdf.model.Model
的用法示例。
在下文中一共展示了Model.difference方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: assertIsomorphic
import com.hp.hpl.jena.rdf.model.Model; //導入方法依賴的package包/類
public static void assertIsomorphic(Model expected, Model actual) {
if (!actual.isIsomorphicWith(expected)) {
Model missingStatements = expected.difference(actual);
Model unexpectedStatements = actual.difference(expected);
if (missingStatements.isEmpty() && unexpectedStatements.isEmpty()) {
fail("Models not isomorphic due to duplicate triples; expected: " +
asNTriples(expected, expected) +
" actual: " + asNTriples(actual, expected));
} else if (missingStatements.isEmpty()) {
fail("Unexpected statement(s): " +
asNTriples(unexpectedStatements, expected));
} else if (unexpectedStatements.isEmpty()) {
fail("Missing statement(s): " +
asNTriples(missingStatements, expected));
} else {
fail("Missing statement(s): " +
asNTriples(missingStatements, expected) +
" Unexpected statement(s): " +
asNTriples(unexpectedStatements, expected));
}
}
}
示例2: doTransforms
import com.hp.hpl.jena.rdf.model.Model; //導入方法依賴的package包/類
private void doTransforms() throws KarmaException, IOException {
ResultSet transforms = readConfig(config);
VIVOSPARQLClient vivoClient = new VIVOSPARQLClient();
// loop through config file.
while ( transforms.hasNext() ) {
QuerySolution soln = transforms.nextSolution();
// See if debug is set in the config.
Boolean debug = false;
Literal debugConfig = soln.getLiteral("debug");
if (debugConfig != null) {
debug = debugConfig.getBoolean();
}
String modelName = soln.getLiteral("name").toString();
log.info(String.format("Processing: %s model with debug set to %s", modelName, debug));
Literal sourceFile = soln.getLiteral("source");
Literal kmodel = soln.getLiteral("model");
String namedGraph = soln.getLiteral("namedGraph").toString();
String modelPath = BASE_DIRECTORY + kmodel;
String filename = BASE_DIRECTORY + sourceFile;
String karmaRdf = KarmaClient.applyModel(modelPath, modelName, filename, baseuri);
log.info("Reading Karma generated RDF into Jena model.");
//Get Jena models for incoming RDF and existing RDF
Model incoming = ModelUtils.getModelFromN3String(karmaRdf);
if ( sync ) {
log.info("Syncing triples to " + namedGraph);
//Diff the models
Model existing = vivoClient.getExistingNamedGraph(namedGraph);
Model additions = incoming.difference(existing);
Model subtractions = existing.difference(incoming);
if (debug) {
debugTrips(additions, subtractions);
} else {
vivoClient.syncNamedGraph(namedGraph, additions, subtractions);
log.info("Triples synced for: " + modelName);
}
} else {
log.info("Updating triples to " + namedGraph);
if (debug) {
debugTrips(incoming);
} else {
vivoClient.updateNamedGraph(namedGraph, incoming);
log.info("Added triples to: " + modelName);
}
}
}
}