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

Rename properties and support for name variants #2488

Merged
merged 29 commits into from
Oct 2, 2019

Conversation

benbosman
Copy link
Member

@benbosman benbosman commented Aug 13, 2019

This PR contains the implementation for DSpace/RestContract#67

  • The leftLabel is renamed to leftWardType at the relationship type level to clarify e.g. isAuthorOfPublication is the name of the arrow pointing from the right item to the left item. The term leftLabel created some confusion in the past.
  • Support for name variants has also been included with an leftWardValue property at the relationship level to specify an alternative name used in the arrow pointing from the right item to the left item.

The name variants can be exposed in the virtual metadata as well, so this direct property will primarily be used for storing and updating the label.

jpelgrims-atmire and others added 21 commits July 31, 2019 11:57
Modified the Relationship so that it also has a leftWardLabel and a
rightWardLabel for storing alternative labels (name variants). Also
created an sql migration to add two columns for these labels to the
relationship table.
Refactor the integration tests for the RelationshipRestRepository
to reduce the amount of code duplication. Many tests contained code
to create a number of variables to be used in the test, this code
was pretty much the same for every test. I refactored the integration
test class so that all variables used in multiple tests are now declared
at the top and are initialized in an @before function. Test-specific
variables are unchanged.
Renamed the columns 'left_label' and 'right_label' in the table
'relationship_type' to 'leftward_label' and 'rightward_label'.
Also renamed all instances of [l|L]eftLabel and [r|R]ightLabel
to [l|L]eftwardLabel and [r|R]ightwardLabel, respectively.
 into feature-name-variants

# Conflicts:
#	dspace-api/src/main/java/org/dspace/content/ItemServiceImpl.java
#	dspace-api/src/main/java/org/dspace/content/RelationshipMetadataServiceImpl.java
Renamed the leftwardLabel and rightwardlabel for Relationship to
leftwardValue and rightwardValue. Renamed the same values for
RelationshipType to leftwardType and rightwardType.
@benbosman benbosman added work in progress PR is still being worked on & is not currently ready for review component: configurable entities Related to Configurable Entities feature interface: REST API v7+ REST API for v7 and later (dspace-server-webapp module) and removed work in progress PR is still being worked on & is not currently ready for review labels Aug 13, 2019
@tdonohue
Copy link
Member

@benbosman : Gave this a quick look today. Unfortunately, though this PR is pointing out some more possible confusion in our naming of relationships.

It definitely looks odd to me that we have a RelationshipType object that has properties leftType and rightType (which are both IDs referring to an EntityType) and properties leftwardType and rightwardType (which are both Strings which name the RelationshipType based on the direction of the relationship). This causes some confusingly named methods in this implementation like EntityService.getRelationshipTypesByType...which is using String types (leftwardType and rightwardType) and not EntityTypes (leftType and rightType).

While I like the idea of leftwardType and rightwardType in the REST Contract, I wonder if we need to cleanup the language in the Java Code to be something like leftwardTypeName? Or maybe leftType should really be leftEntityType (to distinguish it as an EntityType and not a RelationshipType)? "Type" itself is just being used in multiple ways, so we may need to clarify which Type we are talking about in the Java/database layer.

Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

@benbosman : I think this PR needs more attention in the code itself. Each time I try to review it, the method names trip me up (they are very confusing to me), and I end up having to (literally) open up the entire source code to understand what the methods names are trying to say. This implies to me that these methods are likely misnamed (or maybe trying to do too much?), and it'd be extremely hard for other developers to learn.

The best example here is the large number of methods that all start with handle. While it's accurate that they are all "handling" some process, the word handle itself provides no description of what they are doing. Some handle methods seem to be doing validation (like a validate method would), while others seem like they are gathering together information (like a find or get method would). But, overall, the name of the method doesn't give me any clues as to what it is trying to achieve.

Sorry to pester yet again on a PR that seems like it should be "straightforward", but I cannot seem to even get 1/2 way through this PR in over an hour's review time. It's just not making sense to me, without having to try and open up the entire source code :(

Could you take a closer look at the methods names here and see if they make sense to you? Perhaps we can simply clean up the method names to be more descriptive?

Add javadocs to complex private methods
Add javadocs to complex private methods
@benbosman
Copy link
Member Author

@tdonohue @mwoodiupui The method names and JavaDoc has been updated to make it easier to understand.

Copy link
Member

@tdonohue tdonohue 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 the explanations & updates to the method names @benbosman ! I think the code is looking a ton better. I've noticed on other method with an awkward name handle* (which might be nice to cleanup here). But, more importantly, it looks like we are missing Unit tests in one area (see below). At a minimum, I think the latter should be fixed before merger.

Overall though, nice work. This is looking much better.


@Test
@Ignore
public void testGetRelationshipMetadata() throws Exception {
Copy link
Member

Choose a reason for hiding this comment

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

This test class is essentially empty (unfinished). It seems like we should be implementing tests for the new RelationshipMetadataService interface, and it's single method (getRelationshipMetadata()). There's a lot of complexity in our implementation (RelationshipMetadataServiceImpl) that isn't being tested out via Unit Tests

Copy link
Member Author

Choose a reason for hiding this comment

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

I've asked Raf to implement the tests for the new RelationshipMetadataService interface.
It's indeed currently only tested indirectly in the ITs, but an explicit test of the service was planned to be included as well

Copy link
Member Author

Choose a reason for hiding this comment

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

Raf has completed the tests for the new RelationshipMetadataService interface.

Copy link

@dimitrispie dimitrispie left a comment

Choose a reason for hiding this comment

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

No issues found

Copy link
Contributor

@paulo-graca paulo-graca left a comment

Choose a reason for hiding this comment

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

It's working as expected. I just have some minor comments. But overall it's ok by me.

Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

Overall, I'm nearly a +1 now. I found just a few more minor things to clean up, and then I think this can be merged.

Copy link
Contributor

@paulo-graca paulo-graca left a comment

Choose a reason for hiding this comment

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

Thank you @benbosman !

Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

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

👍 Thanks as well, looks good to me! As this is at +2, merging immediately.

@tdonohue tdonohue merged commit e638c47 into DSpace:master Oct 2, 2019
@benbosman benbosman deleted the feature-name-variants branch September 11, 2020 07:31
@tdonohue tdonohue added this to the 7.0beta1 milestone Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: configurable entities Related to Configurable Entities feature interface: REST API v7+ REST API for v7 and later (dspace-server-webapp module)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants