本文整理汇总了Java中cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement类的典型用法代码示例。如果您正苦于以下问题:Java ResolvedStatement类的具体用法?Java ResolvedStatement怎么用?Java ResolvedStatement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResolvedStatement类属于cz.cuni.mff.odcleanstore.conflictresolution包,在下文中一共展示了ResolvedStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getsTripleRDFWriterWhenWritingMetadataIsDisabled
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Test
public void getsTripleRDFWriterWhenWritingMetadataIsDisabled() throws Exception {
ConfigContainer config = mock(ConfigContainer.class);
when(config.getWriteMetadata()).thenReturn(false);
when(config.getDataGraphSymbolicName()).thenReturn(FTConfigConstants.DEFAULT_DATA_GRAPH_NAME);
when(config.getMetadataGraphSymbolicName()).thenReturn(FTConfigConstants.DEFAULT_METADATA_GRAPH_NAME);
// Act
FusionToolDpuComponentFactory componentFactory = getComponentFactory(config);
try (CloseableRDFWriter writer = componentFactory.getRDFWriter()) {
// Assert
Statement statement = createStatement();
ResolvedStatement resolvedStatement = new ResolvedStatementImpl(statement, 0.5, ImmutableList.of((Resource) getUniqueURI()));
writer.write(resolvedStatement);
Statement actualStatement = Iterables.getOnlyElement(outputDataUnit.getAllStatements());
Resource dataGraph = outputDataUnit.addNewDataGraph(FTConfigConstants.DEFAULT_DATA_GRAPH_NAME);
MatcherAssert.assertThat(actualStatement, is(statement));
MatcherAssert.assertThat(actualStatement.getContext(), is(dataGraph));
outputDataUnit.getAllStatements();
}
}
示例2: resolve
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Override
public Collection<ResolvedStatement> resolve(Model statements, CRContext crContext) throws ConflictResolutionException {
int conflictClusterNumber = conflictClusterCounter.getAndIncrement();
Collection<ResolvedStatement> result = new ArrayList<>();
for (Statement statement : statements) {
Collection<Resource> source = Collections.singleton(statement.getContext());
double fQuality = getQuality(statement);
ResolvedStatement resolvedStatement = new MockResolvedStatement(
crContext.getResolvedStatementFactory().create(statement, fQuality, source).getStatement(),
fQuality,
source,
conflictClusterNumber,
crContext.getResolutionStrategy(),
crContext.getConflictingStatements());
result.add(resolvedStatement);
}
return result;
}
示例3: resolve
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Override
public Collection<ResolvedStatement> resolve(Model statements, CRContext crContext) throws ConflictResolutionException {
int conflictClusterNumber = conflictClusterCounter.getAndIncrement();
ResolvedStatement bestResolvedStatement = null;
double bestQuality = -1;
for (Statement statement : statements) {
Collection<Resource> source = Collections.singleton(statement.getContext());
double fQuality = getQuality(statement);
if (fQuality > bestQuality) {
bestResolvedStatement = new MockResolvedStatement(
crContext.getResolvedStatementFactory().create(statement, fQuality, source).getStatement(),
fQuality,
source,
conflictClusterNumber,
crContext.getResolutionStrategy(),
crContext.getConflictingStatements());
}
}
if (bestResolvedStatement == null) {
return Collections.emptySet();
} else {
return Collections.singleton(bestResolvedStatement);
}
}
示例4: matches
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Override
public boolean matches(Object actualValue) {
if (actualValue == null) {
return expectedSources == null;
} else if (!(actualValue instanceof ResolvedStatement)) {
return false;
}
ResolvedStatement actualResolvedStatement = (ResolvedStatement) actualValue;
Collection<Resource> actualSources = actualResolvedStatement.getSourceGraphNames();
HashSet<Resource> actualSourcesSet = new HashSet<>(actualSources);
if (actualSources.size() != actualSourcesSet.size()) {
return false; // sources are not unique
}
return actualSourcesSet.equals(expectedSources);
}
示例5: resolve
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Override
public Collection<ResolvedStatement> resolve(Model statements, CRContext crContext) throws ConflictResolutionException {
int conflictClusterNumber = conflictClusterCounter.getAndIncrement();
Collection<ResolvedStatement> result = new ArrayList<>();
for (Statement statement : statements) {
Collection<Resource> source = Collections.singleton(statement.getContext());
double fQuality = 1.0 / crContext.getConflictingStatements().size();
ResolvedStatement resolvedStatement = new MockResolvedStatement(
crContext.getResolvedStatementFactory().create(statement, fQuality, source).getStatement(),
fQuality,
source,
conflictClusterNumber,
crContext.getResolutionStrategy(),
crContext.getConflictingStatements());
result.add(resolvedStatement);
}
return result;
}
示例6: updateWithResolvedStatements
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Override
public void updateWithResolvedStatements(Collection<ResolvedStatement> resolvedStatements) {
super.updateWithResolvedStatements(resolvedStatements);
// Add discovered objects to the queue
UriMapping uriMapping = getUriMapping();
for (ResolvedStatement resolvedStatement : resolvedStatements) {
String uri = ODCSUtils.getNodeUri(resolvedStatement.getStatement().getObject());
if (uri == null) {
// not a referenceable node
continue;
}
// only add canonical URIs in order to save space
String canonicalURI = uriMapping.getCanonicalURI(uri);
if (!isResolvedCanonicalUri(canonicalURI)) {
// only add new URIs
subjectsQueue.add(canonicalURI);
}
}
}
示例7: processesAllInputStatements
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Test
public void processesAllInputStatements() throws Exception {
// Arrange
FusionExecutor executor = getLDFusionToolExecutor(Long.MAX_VALUE, false);
TestInputLoader inputLoader = new TestInputLoader(ImmutableList.of(
//(Collection<Statement>) ImmutableList.<Statement>of(),
(Collection<Statement>) ImmutableList.of(
createHttpStatement("s1", "p1", "o1", "g1"),
createHttpStatement("s1", "p1", "o1", "g2")),
ImmutableList.of(
createHttpStatement("s2", "p2", "o1", "g3"),
createHttpStatement("s2", "p2", "o2", "g3"))
));
TestRDFWriter rdfWriter = new TestRDFWriter();
// Act
executor.fuse(new TestConflictResolver(), inputLoader, rdfWriter);
// Assert
List<ResolvedStatement> resolvedStatements = rdfWriter.getCollectedResolvedStatements();
assertThat(resolvedStatements.get(0).getStatement(), contextAwareStatementIsEqual(createHttpStatement("s1", "p1", "o1", "g1")));
assertThat(resolvedStatements.get(1).getStatement(), contextAwareStatementIsEqual(createHttpStatement("s1", "p1", "o1", "g2")));
assertThat(resolvedStatements.get(2).getStatement(), contextAwareStatementIsEqual(createHttpStatement("s2", "p2", "o1", "g3")));
assertThat(resolvedStatements.get(3).getStatement(), contextAwareStatementIsEqual(createHttpStatement("s2", "p2", "o2", "g3")));
}
示例8: updateWithResolvedStatementsDoesNotThrowException
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Test
public void updateWithResolvedStatementsDoesNotThrowException() throws Exception {
// Act
ExternalSortingInputLoader inputLoader = createExternalSortingInputLoader(testInput1, false);
try {
inputLoader.initialize(uriMapping);
while (inputLoader.hasNext()) {
Collection<Statement> statements = inputLoader.next().getDescribingStatements();
Statement firstStatement = statements.iterator().next();
ResolvedStatement resolvedStatement = new ResolvedStatementImpl(firstStatement, 0.5, Collections.singleton(firstStatement.getContext()));
inputLoader.updateWithResolvedStatements(Collections.singleton(resolvedStatement));
}
} finally {
inputLoader.close();
}
}
示例9: write
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Override
public void write(ResolvedStatement resolvedStatement) throws IOException {
try {
IRI statementContext = dataUnit.addNewDataGraph(dataGraphSymbolicName + DATA_GRAPH_NAME_INFIX + Long.toString(counter.incrementAndGet()));
connection.add(resolvedStatement.getStatement(), statementContext);
connection.add(statementContext, ODCS.QUALITY, valueFactory.createLiteral(resolvedStatement.getQuality()), metadataContext);
for (Resource sourceGraph : resolvedStatement.getSourceGraphNames()) {
connection.add(statementContext, ODCS.SOURCE_GRAPH, sourceGraph, metadataContext);
}
} catch (DataUnitException | RepositoryException e) {
throw new IOException("Error writing to data unit", e);
}
}
示例10: getsQuadRDFWriterWhenWritingMetadataIsEnabled
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Test
public void getsQuadRDFWriterWhenWritingMetadataIsEnabled() throws Exception {
ConfigContainer config = mock(ConfigContainer.class);
when(config.getWriteMetadata()).thenReturn(true);
when(config.getDataGraphSymbolicName()).thenReturn(FTConfigConstants.DEFAULT_DATA_GRAPH_NAME);
when(config.getMetadataGraphSymbolicName()).thenReturn(FTConfigConstants.DEFAULT_METADATA_GRAPH_NAME);
// Act
FusionToolDpuComponentFactory componentFactory = getComponentFactory(config);
try (CloseableRDFWriter writer = componentFactory.getRDFWriter()) {
// Assert
Statement statement = createStatement();
ResolvedStatement resolvedStatement = new ResolvedStatementImpl(statement, 0.5, ImmutableList.of((Resource) createHttpUri("source1")));
writer.write(resolvedStatement);
IRI metadataGraph = outputDataUnit.addNewDataGraph(FTConfigConstants.DEFAULT_METADATA_GRAPH_NAME);
IRI statementGraph = outputDataUnit.addNewDataGraph(FTConfigConstants.DEFAULT_DATA_GRAPH_NAME + "-1");
List<Statement> expectedStatements = ImmutableList.of(
VF.createStatement(statement.getSubject(), statement.getPredicate(), statement.getObject(), statementGraph),
VF.createStatement(statementGraph, ODCS.QUALITY, VF.createLiteral(0.5), metadataGraph),
VF.createStatement(statementGraph, ODCS.SOURCE_GRAPH, createHttpUri("source1"), metadataGraph)
);
List<Statement> actualStatements = outputDataUnit.getAllStatements();
MatcherAssert.assertThat(actualStatements, containsInAnyOrder(Lists.transform(expectedStatements, STATEMENT_TO_MATCHER)));
}
}
示例11: writesResolvedStatementToDefaultGraph
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Test
public void writesResolvedStatementToDefaultGraph() throws Exception {
Statement statement = FTDPUTestUtils.createStatement();
ResolvedStatement resolvedStatement = new ResolvedStatementImpl(statement, 0.5, ImmutableList.of((Resource) FTDPUTestUtils.getUniqueURI()));
writer.write(resolvedStatement);
Statement actualStatement = Iterables.getOnlyElement(FTDPUTestUtils.getAllStatements(repository));
assertThat(actualStatement, is(statement));
assertThat(actualStatement.getContext(), is((Resource) DEFAULT_CONTEXT));
}
示例12: writesResolvedStatementToDefaultGraph
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Test
public void writesResolvedStatementToDefaultGraph() throws Exception {
Statement statement = FTDPUTestUtils.createStatement();
ResolvedStatement resolvedStatement = new ResolvedStatementImpl(
statement,
0.5,
ImmutableList.<Resource>of(FTDPUTestUtils.createHttpUri("source1"), FTDPUTestUtils.createHttpUri("source2")));
// Act
writer.write(resolvedStatement);
// Assert
Collection<IRI> addedGraphs = dataUnit.getAddedGraphs().values(); // must be first before calling dataUnit.addNewDataGraph()
IRI metadataGraph = dataUnit.addNewDataGraph(FTConfigConstants.DEFAULT_METADATA_GRAPH_NAME);
IRI statementGraph = dataUnit.addNewDataGraph(FTConfigConstants.DEFAULT_DATA_GRAPH_NAME + "-1");
assertThat(addedGraphs, containsInAnyOrder(
dataUnit.addNewDataGraph(FTConfigConstants.DEFAULT_DATA_GRAPH_NAME),
metadataGraph,
statementGraph));
List<Statement> expectedStatements = ImmutableList.of(
VF.createStatement(statement.getSubject(), statement.getPredicate(), statement.getObject(), statementGraph),
VF.createStatement(statementGraph, ODCS.QUALITY, VF.createLiteral(0.5), metadataGraph),
VF.createStatement(statementGraph, ODCS.SOURCE_GRAPH, FTDPUTestUtils.createHttpUri("source1"), metadataGraph),
VF.createStatement(statementGraph, ODCS.SOURCE_GRAPH, FTDPUTestUtils.createHttpUri("source2"), metadataGraph)
);
List<Statement> actualStatements = dataUnit.getAllStatements();
assertThat(actualStatements, containsInAnyOrder(Lists.transform(expectedStatements, ContextAwareStatementIsEqual.STATEMENT_TO_MATCHER)));
}
示例13: aggregateConflictClusterQuality
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Override
public double aggregateConflictClusterQuality(Collection<ResolvedStatement> conflictCluster) {
if (conflictCluster == null || conflictCluster.isEmpty()) {
return 0d;
}
double sum = 0d;
for (ResolvedStatement resolvedStatement : conflictCluster) {
sum += resolvedStatement.getQuality();
}
return sum / conflictCluster.size();
}
示例14: resolve
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
@Override
public Collection<ResolvedStatement> resolve(Model statements, CRContext context) throws ConflictResolutionException {
if (statements.isEmpty()) {
return Collections.emptyList();
}
Set<Resource> nestedResourceSubjects = new HashSet<>(statements.size());
boolean hasNonAggregableStatements = false;
for (Statement statement : statements) {
if (statement.getObject() instanceof Resource) {
nestedResourceSubjects.add((Resource) statement.getObject());
} else {
hasNonAggregableStatements = true;
}
}
URI canonicalProperty = context.getCanonicalProperty();
URI newObject = resolverContext.generateUniqueUri();
if (LOG.isTraceEnabled()) {
LOG.trace("... resolving values of description property {} of {} (new dependent resource is {})",
new Object[]{canonicalProperty, context.getCanonicalSubject(), newObject});
}
Collection<ResolvedStatement> resolvedStatements = resolverContext.resolveNestedResource(nestedResourceSubjects, newObject);
double aggregateQuality = nestedResourceDescriptionQualityCalculator.aggregateConflictClusterQuality(resolvedStatements);
Collection<Resource> sources = ResourceDescriptionConflictResolverUtils.collectContexts(resolvedStatements);
ResolvedStatement resultStatement = context.getResolvedStatementFactory().create(
context.getCanonicalSubject(), canonicalProperty, newObject, aggregateQuality, sources);
if (hasNonAggregableStatements) {
return handleNonAggregableStatements(statements, context, resultStatement);
} else {
return Collections.singleton(resultStatement);
}
}
示例15: handleNonAggregableStatements
import cz.cuni.mff.odcleanstore.conflictresolution.ResolvedStatement; //导入依赖的package包/类
private Collection<ResolvedStatement> handleNonAggregableStatements(Model statements, CRContext context, ResolvedStatement resultStatement) {
ArrayList<ResolvedStatement> result = new ArrayList<>();
result.add(resultStatement);
for (Statement statement : statements) {
if (!(statement.getObject() instanceof Resource)) {
handleNonAggregableStatement(statement, statements, context, result);
}
}
return result;
}