@Test public void splitsToCorrectConflictClusters() throws Exception { Resource resource = createHttpUri("s4"); Collection<Statement> testInput = ImmutableList.of( createHttpStatement("s4", "p1", "o1", "g1"), createHttpStatement("s4", "p1", "o1", "g2"), createHttpStatement("s4", "p2", "o1", "g1"), createHttpStatement("s4", "p2", "o2", "g2"), createHttpStatement("s4", "p3", "o1", "g1"), createHttpStatement("s4", "p3", "o2", "g2"), createHttpStatement("s4", "p3", "o2", "g2") ); ResourceDescriptionConflictResolver resolver = createResolver(); Collection<ResolvedStatement> result = resolver.resolveConflicts(new ResourceDescriptionImpl(resource, testInput)); Collection<Collection<MockResolvedStatement>> conflictClusters = getConflictClusters(result); for (Collection<MockResolvedStatement> conflictCluster : conflictClusters) { MockResolvedStatement first = conflictCluster.iterator().next(); for (MockResolvedStatement mockResolvedStatement : conflictCluster) { assertThat(mockResolvedStatement.getStatement().getSubject(), is(first.getStatement().getSubject())); assertThat(mockResolvedStatement.getStatement().getPredicate(), is(first.getStatement().getPredicate())); } } }
@Override public Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription) throws ConflictResolutionException { int inputStatementCount = resourceDescription.getDescribingStatements().size(); long startTime = logStarted(inputStatementCount); ConflictClustersMap conflictClustersMap = ConflictClustersMap.fromCollection(resourceDescription.getDescribingStatements(), uriMapping); ResolvedResult totalResult = new ResolvedResult(); Resource canonicalResource = uriMapping.mapResource(resourceDescription.getResource()); Collection<ResolvedStatement> resourceResolvedStatements = resolveResource( conflictClustersMap.getResourceStatementsMap(canonicalResource), canonicalResource, totalResult, conflictClustersMap, new HashSet<Resource>(1)); totalResult.addToResult(resourceResolvedStatements); logFinished(startTime, inputStatementCount, totalResult); return totalResult.getResult(); }
ResourceDescriptionConflictResolverImpl implements ResourceDescriptionConflictResolver { @Override public Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription) throws ConflictResolutionException { int inputStatementCount = resourceDescription.getDescribingStatements().size(); long startTime = logStarted(inputStatementCount); ConflictClustersMap conflictClustersMap = ConflictClustersMap.fromCollection(resourceDescription.getDescribingStatements(), uriMapping); ResolvedResult totalResult = new ResolvedResult(); Resource canonicalResource = uriMapping.mapResource(resourceDescription.getResource()); Collection<ResolvedStatement> resourceResolvedStatements = resolveResource( conflictClustersMap.getResourceStatementsMap(canonicalResource), canonicalResource, totalResult, conflictClustersMap, new HashSet<Resource>(1)); totalResult.addToResult(resourceResolvedStatements); logFinished(startTime, inputStatementCount, totalResult); return totalResult.getResult(); } }
ResourceDescriptionConflictResolverImpl implements ResourceDescriptionConflictResolver { @Override public Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription) throws ConflictResolutionException { int inputStatementCount = resourceDescription.getDescribingStatements().size(); long startTime = logStarted(inputStatementCount); ConflictClustersMap conflictClustersMap = ConflictClustersMap.fromCollection(resourceDescription.getDescribingStatements(), uriMapping); ResolvedResult totalResult = new ResolvedResult(); Resource canonicalResource = uriMapping.mapResource(resourceDescription.getResource()); Collection<ResolvedStatement> resourceResolvedStatements = resolveResource( conflictClustersMap.getResourceStatementsMap(canonicalResource), canonicalResource, totalResult, conflictClustersMap, new HashSet<Resource>(1)); totalResult.addToResult(resourceResolvedStatements); logFinished(startTime, inputStatementCount, totalResult); return totalResult.getResult(); } ResourceDescriptionConflictResolverImpl(
            ResolutionFunctionRegistry resolutionFunctionRegistry,
            ConflictResolutionPolicy conflictResolutionPolicy,
            UriMapping uriMapping,
            Model metadata,
            String resolvedGraphsURIPrefix, // TODO: replace with UriGenerator class generating uris both for contexts and generated dependent resources
            NestedResourceDescriptionQualityCalculator nestedResourceDescriptionQualityCalculator); }
ResourceDescriptionConflictResolverImpl implements ResourceDescriptionConflictResolver { @Override public Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription) throws ConflictResolutionException { int inputStatementCount = resourceDescription.getDescribingStatements().size(); long startTime = logStarted(inputStatementCount); ConflictClustersMap conflictClustersMap = ConflictClustersMap.fromCollection(resourceDescription.getDescribingStatements(), uriMapping); ResolvedResult totalResult = new ResolvedResult(); Resource canonicalResource = uriMapping.mapResource(resourceDescription.getResource()); Collection<ResolvedStatement> resourceResolvedStatements = resolveResource( conflictClustersMap.getResourceStatementsMap(canonicalResource), canonicalResource, totalResult, conflictClustersMap, new HashSet<Resource>(1)); totalResult.addToResult(resourceResolvedStatements); logFinished(startTime, inputStatementCount, totalResult); return totalResult.getResult(); } ResourceDescriptionConflictResolverImpl(
            ResolutionFunctionRegistry resolutionFunctionRegistry,
            ConflictResolutionPolicy conflictResolutionPolicy,
            UriMapping uriMapping,
            Model metadata,
            String resolvedGraphsURIPrefix, // TODO: replace with UriGenerator class generating uris both for contexts and generated dependent resources
            NestedResourceDescriptionQualityCalculator nestedResourceDescriptionQualityCalculator); @Override Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription); }
ResourceDescriptionConflictResolverImpl implements ResourceDescriptionConflictResolver { @Override public Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription) throws ConflictResolutionException { int inputStatementCount = resourceDescription.getDescribingStatements().size(); long startTime = logStarted(inputStatementCount); ConflictClustersMap conflictClustersMap = ConflictClustersMap.fromCollection(resourceDescription.getDescribingStatements(), uriMapping); ResolvedResult totalResult = new ResolvedResult(); Resource canonicalResource = uriMapping.mapResource(resourceDescription.getResource()); Collection<ResolvedStatement> resourceResolvedStatements = resolveResource( conflictClustersMap.getResourceStatementsMap(canonicalResource), canonicalResource, totalResult, conflictClustersMap, new HashSet<Resource>(1)); totalResult.addToResult(resourceResolvedStatements); logFinished(startTime, inputStatementCount, totalResult); return totalResult.getResult(); } ResourceDescriptionConflictResolverImpl(
            ResolutionFunctionRegistry resolutionFunctionRegistry,
            ConflictResolutionPolicy conflictResolutionPolicy,
            UriMapping uriMapping,
            Model metadata,
            String resolvedGraphsURIPrefix, // TODO: replace with UriGenerator class generating uris both for contexts and generated dependent resources
            NestedResourceDescriptionQualityCalculator nestedResourceDescriptionQualityCalculator); @Override Collection<ResolvedStatement> resolveConflicts(ResourceDescription resourceDescription); static final ResolutionStrategy DEFAULT_RESOLUTION_STRATEGY; static final String DEFAULT_RESOLVED_GRAPHS_URI_PREFIX; }