Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-2749 Include Namespaces in Statement imports from NamespaceAware collections #4262

Conversation

Dzeri96
Copy link
Contributor

@Dzeri96 Dzeri96 commented Nov 1, 2022

Signed-off-by: Dzerom Dzenkins dzeri96@proton.me

GitHub issue resolved: #2749

Briefly describe the changes proposed in this PR:

As suggested by @jeenbroekstra, I've added a call to setNamespace for all new namespaces coming from the imported Statements, and I've removed the appropriate overrides in the SPARQL repository, as it seems like the code was almost identical. Please correct me if I'm wrong.

Since this is a WIP, there are some things to clear up:

  1. Where do I put the unit tests for this? I couldn't find an appropriate place with similar tests.
  2. What should we do with the deprecated Iteration overload of the add method? I suspect this might get removed with the next release so I haven't added any changes there.
  3. What about the remove method? Should we prune unused Namespaces?

As soon as these questions are cleared up, and the flaky tests are fixed, I'll continue working on this PR!


PR Author Checklist (see the contributor guidelines for more details):

  • my pull request is self-contained
  • I've added tests for the changes I made
  • I've applied code formatting (you can use mvn process-resources to format from the command line)
  • I've squashed my commits where necessary
  • every commit message starts with the issue number (GH-xxxx) followed by a meaningful description of the change

Copy link
Contributor

@abrokenjester abrokenjester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for supplying this PR @Dzeri96 ! I've left a couple of suggestions for improvements. Also: can you make sure that you add some tests to cover the desired behavior? The RepositoryConnectionTest class (in rdf4j-repository-testsuite) is probably a good spot for this - these are integration tests more than unit tests, but the nice thing about that is that you automatically get coverage for all implementations of the abstract class.

If you additionally want unit tests, you're welcome to just add a new AbstractRepositoryConnectionTest class in src/test/java in the repository-api module. Please note we use JUnit 5 for all new tests (some of our older tests are still on JUnit 4 though), and have a preference for AssertJ assertions (no hard rule though).

Signed-off-by: Dzeri96 <dzeri96@proton.me>
@Dzeri96 Dzeri96 force-pushed the GH-2749-add-statements-with-namespaces branch from a2bd536 to 8b8ea97 Compare December 13, 2022 17:33
@Dzeri96
Copy link
Contributor Author

Dzeri96 commented Dec 13, 2022

@jeenbroekstra Please have a look at the second iteration of my implementation. I've added a simple test, however some implementations of the RepositoryConnectionTest fail to execute on my machine, even on the latest main branch. These are:

  • ElasticSearchStoreConnectionIT
  • HTTPStoreConnectionTest
  • RDFSchemaRepositoryConnectionTest
  • SPARQLStoreConnectionTest

I've nevertheless added a skipping override for the test in the SPARQLStoreConnectionTest

Signed-off-by: Dzeri96 <dzeri96@proton.me>
@Dzeri96 Dzeri96 force-pushed the GH-2749-add-statements-with-namespaces branch from 8b8ea97 to 9b1ab6a Compare December 13, 2022 17:40
Copy link
Contributor

@abrokenjester abrokenjester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @Dzeri96 - this looks good to me!

Not sure why some tests fail in your local setup, but the Github build succeeded without failure so I don't think it's your code that's the problem.

Comment on lines +377 to +385
if (statements instanceof NamespaceAware) {
var newNamespaces = ((NamespaceAware) statements).getNamespaces();
for (Namespace newNamespace : newNamespaces) {
String nsPrefix = newNamespace.getPrefix();
if (getNamespace(nsPrefix) == null) {
setNamespace(nsPrefix, newNamespace.getName());
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@Dzeri96 Dzeri96 marked this pull request as ready for review December 17, 2022 10:50
@abrokenjester abrokenjester changed the title Include Namespaces in Statement imports - Work in Progress GH-2749 Include Namespaces in Statement imports from NamespaceAware collections Dec 17, 2022
@abrokenjester abrokenjester merged commit 1657d05 into eclipse-rdf4j:main Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding a Model to a repository doesn't transfer its namespaces
2 participants