dspace-angular icon indicating copy to clipboard operation
dspace-angular copied to clipboard

Entities relations with invalid associations shown

Open paulo-graca opened this issue 4 years ago • 2 comments

Describe the bug My model has two relation types, with same relation name, but involving different entities:

	<type>
		<leftType>Publication</leftType>
		<rightType>Person</rightType>
		<leftwardType>isAuthorOfPublication</leftwardType>
		<rightwardType>isPublicationOfAuthor</rightwardType>
		<leftCardinality>
			<min>0</min>
		</leftCardinality>
		<rightCardinality>
			<min>0</min>
		</rightCardinality>
	</type>
	<type>
		<leftType>Publication</leftType>
		<rightType>OrgUnit</rightType>
		<leftwardType>isAuthorOfPublication</leftwardType>
		<rightwardType>isPublicationOfAuthor</rightwardType>
		<leftCardinality>
			<min>0</min>
		</leftCardinality>
		<rightCardinality>
			<min>0</min>
		</rightCardinality>
	</type>

But when I try to associate a Person as an author, that Person, will be shown simultaneously as Authors (persons) relation and Authors (organizational units)

To Reproduce Steps to reproduce the behavior:

  1. You can use /dspace/config/entities/openaire4-relationships.xml as your model
  2. And set dspace.​entity.​type = Publication to any existing Item
  3. At edit item Relationships separator, use lookup to associate an author
  4. After you added the relations to that entity, strange associations will be shown image

And if you refresh the page, you will get 2 associations: image

It seams an issue with Relationships separator, because item page is shown as expected.

Expected behavior I was expecting to have only one association, or to be shown only one Authors (persons) relation.

paulo-graca avatar Nov 02 '21 10:11 paulo-graca

@paulo-graca : I think the issue here is that we have two relationship types of the same name (i.e. two isAuthorOfPublication and two isPublicationOfAuthor). I don't believe that's currently supported in our Entities model. I think the relationship type name is expected to be unique (in the same way that Entity names are expected to be unique).

So, I think this would work correctly if the second relationship was renamed to be isOrgAuthorOfPublication like this...

        <type>
		<leftType>Publication</leftType>
		<rightType>Person</rightType>
		<leftwardType>isAuthorOfPublication</leftwardType>
		<rightwardType>isPublicationOfAuthor</rightwardType>
		<leftCardinality>
			<min>0</min>
		</leftCardinality>
		<rightCardinality>
			<min>0</min>
		</rightCardinality>
	</type>
	<type>
		<leftType>Publication</leftType>
		<rightType>OrgUnit</rightType>
		<leftwardType>isOrgAuthorOfPublication</leftwardType>
		<rightwardType>isPublicationOfOrgAuthor</rightwardType>
		<leftCardinality>
			<min>0</min>
		</leftCardinality>
		<rightCardinality>
			<min>0</min>
		</rightCardinality>
	</type>

See also our Configurable Entities docs about "Configuring the object model" which says "Determine a clear an unambiguous name for the relation in both directions" (I believe the "unambiguous" there means it also needs to be unique): https://wiki.lyrasis.org/display/DSDOC7x/Configurable+Entities#ConfigurableEntities-Configuringtheobjectmodel

So, to me, it looks like we may need to fix the openaire4-relationships.xml file to have unique names for relationship types.

tdonohue avatar Nov 03 '21 16:11 tdonohue

relationship-types.xml contains two different relationship types with identical names (isAuthorOfPublication and isPublicationOfAuthor). The names of left and right relationship types between Publication and OrgUnit should be adapted (same as in openaire4-relationships.xml).

saschaszott avatar Jul 22 '22 15:07 saschaszott

@tdonohue @saschaszott @paulo-graca I have opened a PR https://github.com/DSpace/DSpace/pull/8667 which just makes the small suggested change suggested by Tim. I think the new name makes more sense, as well as guaranteeing uniqueness of those directional rel names.

kshepherd avatar Feb 14 '23 21:02 kshepherd

Thank you @kshepherd! But as @benbosman wrote in the PR, the model supports specifying same relation label when having different entities involved in the relationship.

I have an use case where there occurs the need to have the same relationship for different entities: https://openaire-guidelines-for-literature-repository-managers.readthedocs.io/en/v4.0.0/field_creator.html

At the relation: isAuthorOfPublication an Author can be a Person or an Organization. Having a new relation like isAuthorOrgOfPublication we are saying that relation isn't the same thing, it isn't a proper Author, it is some other kind of relationship (specific for Organizations). I agree to the change of the relation if intends to describe a different purpose, like isContributorOfPublication, or isReviewerOfPublication, but not based on the entity types.

paulo-graca avatar Feb 15 '23 14:02 paulo-graca

@paulo-graca I see, this does make sense if I think of it as a predicate in a linked data sense, though I admit that isn't how I'd strictly interpreted the leftward/rightward types here.

kshepherd avatar Feb 15 '23 20:02 kshepherd

I created a fix for this issue, but it does require changes to the relationship endpoint, I had to add an additional parameter entityType to that endpoint. So I don't know if it would still be possible to fix this on 8.0, because ideally we should also have some tests for this.

alexandrevryghem avatar May 26 '24 22:05 alexandrevryghem