mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-09 19:13:18 +00:00
Rename leftwardLabel and rightwardLabel
Renamed the leftwardLabel and rightwardlabel for Relationship to leftwardValue and rightwardValue. Renamed the same values for RelationshipType to leftwardType and rightwardType.
This commit is contained in:
@@ -640,7 +640,7 @@ public class MetadataImport {
|
|||||||
|
|
||||||
if (StringUtils.equals(schema, MetadataSchemaEnum.RELATION.getName())) {
|
if (StringUtils.equals(schema, MetadataSchemaEnum.RELATION.getName())) {
|
||||||
List<RelationshipType> relationshipTypeList = relationshipTypeService
|
List<RelationshipType> relationshipTypeList = relationshipTypeService
|
||||||
.findByLeftwardOrRightwardLabel(c, element);
|
.findByLeftwardOrRightwardType(c, element);
|
||||||
for (RelationshipType relationshipType : relationshipTypeList) {
|
for (RelationshipType relationshipType : relationshipTypeList) {
|
||||||
for (Relationship relationship : relationshipService
|
for (Relationship relationship : relationshipService
|
||||||
.findByItemAndRelationshipType(c, item, relationshipType)) {
|
.findByItemAndRelationshipType(c, item, relationshipType)) {
|
||||||
@@ -716,13 +716,13 @@ public class MetadataImport {
|
|||||||
List<RelationshipType> rightRelationshipTypesForEntity = entityService.getRightRelationshipTypes(c, entity);
|
List<RelationshipType> rightRelationshipTypesForEntity = entityService.getRightRelationshipTypes(c, entity);
|
||||||
|
|
||||||
for (RelationshipType relationshipType : entityService.getAllRelationshipTypes(c, entity)) {
|
for (RelationshipType relationshipType : entityService.getAllRelationshipTypes(c, entity)) {
|
||||||
if (StringUtils.equalsIgnoreCase(relationshipType.getLeftwardLabel(), element)) {
|
if (StringUtils.equalsIgnoreCase(relationshipType.getLeftwardType(), element)) {
|
||||||
left = handleLeftwardLabelEqualityRelationshipTypeElement(c, entity, relationEntity, left,
|
left = handleLeftwardTypeEqualityRelationshipTypeElement(c, entity, relationEntity, left,
|
||||||
acceptableRelationshipTypes,
|
acceptableRelationshipTypes,
|
||||||
leftRelationshipTypesForEntity,
|
leftRelationshipTypesForEntity,
|
||||||
relationshipType);
|
relationshipType);
|
||||||
} else if (StringUtils.equalsIgnoreCase(relationshipType.getRightwardLabel(), element)) {
|
} else if (StringUtils.equalsIgnoreCase(relationshipType.getRightwardType(), element)) {
|
||||||
left = handleRightwardLabelEqualityRelationshipTypeElement(c, entity, relationEntity, left,
|
left = handleRightwardTypeEqualityRelationshipTypeElement(c, entity, relationEntity, left,
|
||||||
acceptableRelationshipTypes,
|
acceptableRelationshipTypes,
|
||||||
rightRelationshipTypesForEntity,
|
rightRelationshipTypesForEntity,
|
||||||
relationshipType);
|
relationshipType);
|
||||||
@@ -789,12 +789,13 @@ public class MetadataImport {
|
|||||||
* be false in this case
|
* be false in this case
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
private boolean handleRightwardLabelEqualityRelationshipTypeElement(Context c, Entity entity, Entity relationEntity,
|
private boolean handleRightwardTypeEqualityRelationshipTypeElement(Context c, Entity entity,
|
||||||
boolean left,
|
Entity relationEntity,
|
||||||
List<RelationshipType> acceptableRelationshipTypes,
|
boolean left,
|
||||||
List<RelationshipType>
|
List<RelationshipType> acceptableRelationshipTypes,
|
||||||
rightRelationshipTypesForEntity,
|
List<RelationshipType>
|
||||||
RelationshipType relationshipType)
|
rightRelationshipTypesForEntity,
|
||||||
|
RelationshipType relationshipType)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
if (StringUtils.equalsIgnoreCase(entityService.getType(c, entity).getLabel(),
|
if (StringUtils.equalsIgnoreCase(entityService.getType(c, entity).getLabel(),
|
||||||
relationshipType.getRightType().getLabel()) &&
|
relationshipType.getRightType().getLabel()) &&
|
||||||
@@ -831,12 +832,12 @@ public class MetadataImport {
|
|||||||
* be true in this case
|
* be true in this case
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
private boolean handleLeftwardLabelEqualityRelationshipTypeElement(Context c, Entity entity, Entity relationEntity,
|
private boolean handleLeftwardTypeEqualityRelationshipTypeElement(Context c, Entity entity, Entity relationEntity,
|
||||||
boolean left,
|
boolean left,
|
||||||
List<RelationshipType> acceptableRelationshipTypes,
|
List<RelationshipType> acceptableRelationshipTypes,
|
||||||
List<RelationshipType>
|
List<RelationshipType>
|
||||||
leftRelationshipTypesForEntity,
|
leftRelationshipTypesForEntity,
|
||||||
RelationshipType relationshipType)
|
RelationshipType relationshipType)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
if (StringUtils.equalsIgnoreCase(entityService.getType(c, entity).getLabel(),
|
if (StringUtils.equalsIgnoreCase(entityService.getType(c, entity).getLabel(),
|
||||||
relationshipType.getLeftType().getLabel()) &&
|
relationshipType.getLeftType().getLabel()) &&
|
||||||
|
@@ -128,8 +128,8 @@ public class InitializeEntities {
|
|||||||
|
|
||||||
String leftType = eElement.getElementsByTagName("leftType").item(0).getTextContent();
|
String leftType = eElement.getElementsByTagName("leftType").item(0).getTextContent();
|
||||||
String rightType = eElement.getElementsByTagName("rightType").item(0).getTextContent();
|
String rightType = eElement.getElementsByTagName("rightType").item(0).getTextContent();
|
||||||
String leftwardLabel = eElement.getElementsByTagName("leftwardLabel").item(0).getTextContent();
|
String leftwardType = eElement.getElementsByTagName("leftwardType").item(0).getTextContent();
|
||||||
String rightwardLabel = eElement.getElementsByTagName("rightwardLabel").item(0).getTextContent();
|
String rightwardType = eElement.getElementsByTagName("rightwardType").item(0).getTextContent();
|
||||||
|
|
||||||
|
|
||||||
NodeList leftCardinalityList = eElement.getElementsByTagName("leftCardinality");
|
NodeList leftCardinalityList = eElement.getElementsByTagName("leftCardinality");
|
||||||
@@ -154,7 +154,7 @@ public class InitializeEntities {
|
|||||||
rightCardinalityMax = getString(rightCardinalityMax,(Element) node, "max");
|
rightCardinalityMax = getString(rightCardinalityMax,(Element) node, "max");
|
||||||
|
|
||||||
}
|
}
|
||||||
populateRelationshipType(context, leftType, rightType, leftwardLabel, rightwardLabel,
|
populateRelationshipType(context, leftType, rightType, leftwardType, rightwardType,
|
||||||
leftCardinalityMin, leftCardinalityMax,
|
leftCardinalityMin, leftCardinalityMax,
|
||||||
rightCardinalityMin, rightCardinalityMax);
|
rightCardinalityMin, rightCardinalityMax);
|
||||||
|
|
||||||
@@ -173,8 +173,8 @@ public class InitializeEntities {
|
|||||||
return leftCardinalityMin;
|
return leftCardinalityMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void populateRelationshipType(Context context, String leftType, String rightType, String leftwardLabel,
|
private void populateRelationshipType(Context context, String leftType, String rightType, String leftwardType,
|
||||||
String rightwardLabel, String leftCardinalityMin, String leftCardinalityMax,
|
String rightwardType, String leftCardinalityMin, String leftCardinalityMax,
|
||||||
String rightCardinalityMin, String rightCardinalityMax)
|
String rightCardinalityMin, String rightCardinalityMax)
|
||||||
throws SQLException, AuthorizeException {
|
throws SQLException, AuthorizeException {
|
||||||
|
|
||||||
@@ -211,9 +211,9 @@ public class InitializeEntities {
|
|||||||
rightCardinalityMaxInteger = null;
|
rightCardinalityMaxInteger = null;
|
||||||
}
|
}
|
||||||
RelationshipType relationshipType = relationshipTypeService
|
RelationshipType relationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, leftEntityType, rightEntityType, leftwardLabel, rightwardLabel);
|
.findbyTypesAndLabels(context, leftEntityType, rightEntityType, leftwardType, rightwardType);
|
||||||
if (relationshipType == null) {
|
if (relationshipType == null) {
|
||||||
relationshipTypeService.create(context, leftEntityType, rightEntityType, leftwardLabel, rightwardLabel,
|
relationshipTypeService.create(context, leftEntityType, rightEntityType, leftwardType, rightwardType,
|
||||||
leftCardinalityMinInteger, leftCardinalityMaxInteger,
|
leftCardinalityMinInteger, leftCardinalityMaxInteger,
|
||||||
rightCardinalityMinInteger, rightCardinalityMaxInteger);
|
rightCardinalityMinInteger, rightCardinalityMaxInteger);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -83,8 +83,8 @@ public class EntityServiceImpl implements EntityService {
|
|||||||
List<Relationship> relationshipList = relationshipService.findAll(context);
|
List<Relationship> relationshipList = relationshipService.findAll(context);
|
||||||
for (Relationship relationship : relationshipList) {
|
for (Relationship relationship : relationshipList) {
|
||||||
RelationshipType relationshipType = relationship.getRelationshipType();
|
RelationshipType relationshipType = relationship.getRelationshipType();
|
||||||
if (StringUtils.equals(relationshipType.getLeftwardLabel(),label) ||
|
if (StringUtils.equals(relationshipType.getLeftwardType(),label) ||
|
||||||
StringUtils.equals(relationshipType.getRightwardLabel(),label)) {
|
StringUtils.equals(relationshipType.getRightwardType(),label)) {
|
||||||
listToReturn.add(relationship);
|
listToReturn.add(relationship);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,11 +129,11 @@ public class EntityServiceImpl implements EntityService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RelationshipType> getRelationshipTypesByLabel(Context context, String label) throws SQLException {
|
public List<RelationshipType> getRelationshipTypesByType(Context context, String label) throws SQLException {
|
||||||
List<RelationshipType> listToReturn = new LinkedList<>();
|
List<RelationshipType> listToReturn = new LinkedList<>();
|
||||||
for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) {
|
for (RelationshipType relationshipType : relationshipTypeService.findAll(context)) {
|
||||||
if (StringUtils.equals(relationshipType.getLeftwardLabel(),label) ||
|
if (StringUtils.equals(relationshipType.getLeftwardType(),label) ||
|
||||||
StringUtils.equals(relationshipType.getRightwardLabel(),label)) {
|
StringUtils.equals(relationshipType.getRightwardType(),label)) {
|
||||||
listToReturn.add(relationshipType);
|
listToReturn.add(relationshipType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -78,16 +78,16 @@ public class Relationship implements ReloadableEntity<Integer> {
|
|||||||
private int rightPlace;
|
private int rightPlace;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A String containing an alternative label (name variant) for the left side
|
* A String containing an alternative value (name variant) for the left side
|
||||||
*/
|
*/
|
||||||
@Column(name = "leftward_label")
|
@Column(name = "leftward_value")
|
||||||
private String leftwardLabel;
|
private String leftwardValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A String containing an alternative label (name variant) for the right side
|
* A String containing an alternative value (name variant) for the right side
|
||||||
*/
|
*/
|
||||||
@Column(name = "rightward_label")
|
@Column(name = "rightward_value")
|
||||||
private String rightwardLabel;
|
private String rightwardValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Protected constructor, create object using:
|
* Protected constructor, create object using:
|
||||||
@@ -183,35 +183,35 @@ public class Relationship implements ReloadableEntity<Integer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard getter for the leftwardLabel String in this Relationship
|
* Standard getter for the leftwardValue String in this Relationship
|
||||||
* @return the leftwardlabel String for this relationship
|
* @return the leftwardValue String for this relationship
|
||||||
*/
|
*/
|
||||||
public String getLeftwardLabel() {
|
public String getLeftwardValue() {
|
||||||
return leftwardLabel;
|
return leftwardValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard setter for the leftwardlabel String in this Relationship
|
* Standard setter for the leftwardValue String in this Relationship
|
||||||
* @param leftwardLabel the leftwardLabel String that will be used in this relationship
|
* @param leftwardValue the leftwardValue String that will be used in this relationship
|
||||||
*/
|
*/
|
||||||
public void setLeftwardLabel(String leftwardLabel) {
|
public void setLeftwardValue(String leftwardValue) {
|
||||||
this.leftwardLabel = leftwardLabel;
|
this.leftwardValue = leftwardValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard getter for the rightwardlabel String in this Relationship
|
* Standard getter for the rightwardValue String in this Relationship
|
||||||
* @return the rightwardLabel string for this relationship
|
* @return the rightwardValue string for this relationship
|
||||||
*/
|
*/
|
||||||
public String getRightwardLabel() {
|
public String getRightwardValue() {
|
||||||
return rightwardLabel;
|
return rightwardValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard setter for the rightwardLabel String in this Relationship
|
* Standard setter for the rightwardValue String in this Relationship
|
||||||
* @param rightwardLabel the rightwardLabel String that will be used in this relationship
|
* @param rightwardValue the rightwardValue String that will be used in this relationship
|
||||||
*/
|
*/
|
||||||
public void setRightwardLabel(String rightwardLabel) {
|
public void setRightwardValue(String rightwardValue) {
|
||||||
this.rightwardLabel = rightwardLabel;
|
this.rightwardValue = rightwardValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -87,16 +87,16 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
|||||||
int place = 0;
|
int place = 0;
|
||||||
boolean isLeftwards;
|
boolean isLeftwards;
|
||||||
if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType)) {
|
if (StringUtils.equals(relationshipType.getLeftType().getLabel(), entityType)) {
|
||||||
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getLeftwardLabel());
|
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getLeftwardType());
|
||||||
otherItem = relationship.getRightItem();
|
otherItem = relationship.getRightItem();
|
||||||
relationName = relationship.getRelationshipType().getLeftwardLabel();
|
relationName = relationship.getRelationshipType().getLeftwardType();
|
||||||
place = relationship.getLeftPlace();
|
place = relationship.getLeftPlace();
|
||||||
isLeftwards = false; //if the current item is stored on the left,
|
isLeftwards = false; //if the current item is stored on the left,
|
||||||
// the name variant is retrieved from the rightwards label
|
// the name variant is retrieved from the rightwards label
|
||||||
} else if (StringUtils.equals(relationshipType.getRightType().getLabel(), entityType)) {
|
} else if (StringUtils.equals(relationshipType.getRightType().getLabel(), entityType)) {
|
||||||
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getRightwardLabel());
|
hashMaps = virtualMetadataPopulator.getMap().get(relationshipType.getRightwardType());
|
||||||
otherItem = relationship.getLeftItem();
|
otherItem = relationship.getLeftItem();
|
||||||
relationName = relationship.getRelationshipType().getRightwardLabel();
|
relationName = relationship.getRelationshipType().getRightwardType();
|
||||||
place = relationship.getRightPlace();
|
place = relationship.getRightPlace();
|
||||||
isLeftwards = true; //if the current item is stored on the right,
|
isLeftwards = true; //if the current item is stored on the right,
|
||||||
// the name variant is retrieved from the leftwards label
|
// the name variant is retrieved from the leftwards label
|
||||||
@@ -131,7 +131,7 @@ public class RelationshipMetadataServiceImpl implements RelationshipMetadataServ
|
|||||||
VirtualMetadataConfiguration virtualBean = entry.getValue();
|
VirtualMetadataConfiguration virtualBean = entry.getValue();
|
||||||
|
|
||||||
if (virtualBean.getPopulateWithNameVariant()) {
|
if (virtualBean.getPopulateWithNameVariant()) {
|
||||||
String wardLabel = isLeftwards ? relationship.getLeftwardLabel() : relationship.getRightwardLabel();
|
String wardLabel = isLeftwards ? relationship.getLeftwardValue() : relationship.getRightwardValue();
|
||||||
if (wardLabel != null) {
|
if (wardLabel != null) {
|
||||||
resultingMetadataValueList.add(
|
resultingMetadataValueList.add(
|
||||||
constructRelationshipMetadataValue(context, item, relationship.getID(), place, key, virtualBean,
|
constructRelationshipMetadataValue(context, item, relationship.getID(), place, key, virtualBean,
|
||||||
|
@@ -64,7 +64,7 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Relationship create(Context c, Item leftItem, Item rightItem, RelationshipType relationshipType,
|
public Relationship create(Context c, Item leftItem, Item rightItem, RelationshipType relationshipType,
|
||||||
int leftPlace, int rightPlace, String leftwardLabel, String rightwardLabel)
|
int leftPlace, int rightPlace, String leftwardValue, String rightwardValue)
|
||||||
throws AuthorizeException, SQLException {
|
throws AuthorizeException, SQLException {
|
||||||
Relationship relationship = new Relationship();
|
Relationship relationship = new Relationship();
|
||||||
relationship.setLeftItem(leftItem);
|
relationship.setLeftItem(leftItem);
|
||||||
@@ -72,8 +72,8 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
relationship.setRelationshipType(relationshipType);
|
relationship.setRelationshipType(relationshipType);
|
||||||
relationship.setLeftPlace(leftPlace);
|
relationship.setLeftPlace(leftPlace);
|
||||||
relationship.setRightPlace(rightPlace);
|
relationship.setRightPlace(rightPlace);
|
||||||
relationship.setLeftwardLabel(leftwardLabel);
|
relationship.setLeftwardValue(leftwardValue);
|
||||||
relationship.setRightwardLabel(rightwardLabel);
|
relationship.setRightwardValue(rightwardValue);
|
||||||
return create(c, relationship);
|
return create(c, relationship);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
false);
|
false);
|
||||||
|
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
//If useForPlace for the leftwardlabel is false for the relationshipType,
|
//If useForPlace for the leftwardType is false for the relationshipType,
|
||||||
// we need to sort the relationships here based on leftplace.
|
// we need to sort the relationships here based on leftplace.
|
||||||
if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), true)) {
|
if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), true)) {
|
||||||
if (!leftRelationships.isEmpty()) {
|
if (!leftRelationships.isEmpty()) {
|
||||||
@@ -125,7 +125,7 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//If useForPlace for the rightwardLabel is false for the relationshipType,
|
//If useForPlace for the rightwardType is false for the relationshipType,
|
||||||
// we need to sort the relationships here based on the rightplace.
|
// we need to sort the relationships here based on the rightplace.
|
||||||
if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), false)) {
|
if (!virtualMetadataPopulator.isUseForPlaceTrueForRelationshipType(relationship.getRelationshipType(), false)) {
|
||||||
if (!rightRelationships.isEmpty()) {
|
if (!rightRelationships.isEmpty()) {
|
||||||
@@ -230,8 +230,8 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
|
|
||||||
private void logRelationshipTypeDetailsForError(RelationshipType relationshipType) {
|
private void logRelationshipTypeDetailsForError(RelationshipType relationshipType) {
|
||||||
log.warn("The relationshipType's ID is: " + relationshipType.getID());
|
log.warn("The relationshipType's ID is: " + relationshipType.getID());
|
||||||
log.warn("The relationshipType's leftward label is: " + relationshipType.getLeftwardLabel());
|
log.warn("The relationshipType's leftward type is: " + relationshipType.getLeftwardType());
|
||||||
log.warn("The relationshipType's rightward label is: " + relationshipType.getRightwardLabel());
|
log.warn("The relationshipType's rightward type is: " + relationshipType.getRightwardType());
|
||||||
log.warn("The relationshipType's left entityType label is: " + relationshipType.getLeftType().getLabel());
|
log.warn("The relationshipType's left entityType label is: " + relationshipType.getLeftType().getLabel());
|
||||||
log.warn("The relationshipType's right entityType label is: " + relationshipType.getRightType().getLabel());
|
log.warn("The relationshipType's right entityType label is: " + relationshipType.getRightType().getLabel());
|
||||||
log.warn("The relationshipType's left min cardinality is: " + relationshipType.getLeftMinCardinality());
|
log.warn("The relationshipType's left min cardinality is: " + relationshipType.getLeftMinCardinality());
|
||||||
@@ -271,8 +271,8 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
List<Relationship> list = relationshipDAO.findByItem(context, item);
|
List<Relationship> list = relationshipDAO.findByItem(context, item);
|
||||||
|
|
||||||
list.sort((o1, o2) -> {
|
list.sort((o1, o2) -> {
|
||||||
int relationshipType = o1.getRelationshipType().getLeftwardLabel()
|
int relationshipType = o1.getRelationshipType().getLeftwardType()
|
||||||
.compareTo(o2.getRelationshipType().getLeftwardLabel());
|
.compareTo(o2.getRelationshipType().getLeftwardType());
|
||||||
if (relationshipType != 0) {
|
if (relationshipType != 0) {
|
||||||
return relationshipType;
|
return relationshipType;
|
||||||
} else {
|
} else {
|
||||||
@@ -386,14 +386,14 @@ public class RelationshipServiceImpl implements RelationshipService {
|
|||||||
if (isLeft) {
|
if (isLeft) {
|
||||||
if (StringUtils
|
if (StringUtils
|
||||||
.equals(
|
.equals(
|
||||||
relationship.getRelationshipType().getLeftwardLabel(), relationshipType.getLeftwardLabel())
|
relationship.getRelationshipType().getLeftwardType(), relationshipType.getLeftwardType())
|
||||||
) {
|
) {
|
||||||
listToReturn.add(relationship);
|
listToReturn.add(relationship);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (StringUtils
|
if (StringUtils
|
||||||
.equals(
|
.equals(
|
||||||
relationship.getRelationshipType().getRightwardLabel(), relationshipType.getRightwardLabel())
|
relationship.getRelationshipType().getRightwardType(), relationshipType.getRightwardType())
|
||||||
) {
|
) {
|
||||||
listToReturn.add(relationship);
|
listToReturn.add(relationship);
|
||||||
}
|
}
|
||||||
|
@@ -26,8 +26,8 @@ import org.dspace.core.ReloadableEntity;
|
|||||||
* Class representing a RelationshipType
|
* Class representing a RelationshipType
|
||||||
* This class contains an Integer ID that will be the unique value and primary key in the database.
|
* This class contains an Integer ID that will be the unique value and primary key in the database.
|
||||||
* This key is automatically generated
|
* This key is automatically generated
|
||||||
* It also has a leftType and rightType EntityType that describes the relationshipType together with a leftwardLabel and
|
* It also has a leftType and rightType EntityType that describes the relationshipType together with a leftwardType and
|
||||||
* rightwardLabel.
|
* rightwardType.
|
||||||
* The cardinality properties describe how many of each relations this relationshipType can support
|
* The cardinality properties describe how many of each relations this relationshipType can support
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@@ -61,20 +61,20 @@ public class RelationshipType implements ReloadableEntity<Integer> {
|
|||||||
private EntityType rightType;
|
private EntityType rightType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The leftwardLabel String field for the relationshipType
|
* The leftwardType String field for the relationshipType
|
||||||
* This is stored as a String and cannot be null
|
* This is stored as a String and cannot be null
|
||||||
* This is a textual representation of the name of the relationship that this RelationshipType is connected to
|
* This is a textual representation of the name of the relationship that this RelationshipType is connected to
|
||||||
*/
|
*/
|
||||||
@Column(name = "leftward_label", nullable = false)
|
@Column(name = "leftward_type", nullable = false)
|
||||||
private String leftwardLabel;
|
private String leftwardType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The rightwardLabel String field for the relationshipType
|
* The rightwardType String field for the relationshipType
|
||||||
* This is stored as a String and cannot be null
|
* This is stored as a String and cannot be null
|
||||||
* This is a textual representation of the name of the relationship that this RelationshipType is connected to
|
* This is a textual representation of the name of the relationship that this RelationshipType is connected to
|
||||||
*/
|
*/
|
||||||
@Column(name = "rightward_label", nullable = false)
|
@Column(name = "rightward_type", nullable = false)
|
||||||
private String rightwardLabel;
|
private String rightwardType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The minimum amount of relations for the leftItem that need to be present at all times
|
* The minimum amount of relations for the leftItem that need to be present at all times
|
||||||
@@ -149,35 +149,35 @@ public class RelationshipType implements ReloadableEntity<Integer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard getter for the leftwardLabel String for this RelationshipType
|
* Standard getter for the leftwardType String for this RelationshipType
|
||||||
* @return The leftwardLabel String of this RelationshipType
|
* @return The leftwardType String of this RelationshipType
|
||||||
*/
|
*/
|
||||||
public String getLeftwardLabel() {
|
public String getLeftwardType() {
|
||||||
return leftwardLabel;
|
return leftwardType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard setter for the leftwardLabel String for this RelationshipType
|
* Standard setter for the leftwardType String for this RelationshipType
|
||||||
* @param leftwardLabel The leftwardLabel String that this RelationshipType should receive
|
* @param leftwardType The leftwardType String that this RelationshipType should receive
|
||||||
*/
|
*/
|
||||||
public void setLeftwardLabel(String leftwardLabel) {
|
public void setLeftwardType(String leftwardType) {
|
||||||
this.leftwardLabel = leftwardLabel;
|
this.leftwardType = leftwardType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard getter for the rightwardLabel String for this RelationshipType
|
* Standard getter for the rightwardType String for this RelationshipType
|
||||||
* @return The rightwardLabel String of this RelationshipType
|
* @return The rightwardType String of this RelationshipType
|
||||||
*/
|
*/
|
||||||
public String getRightwardLabel() {
|
public String getRightwardType() {
|
||||||
return rightwardLabel;
|
return rightwardType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard setter for the rightwardLabel String for this RelationshipType
|
* Standard setter for the rightwardType String for this RelationshipType
|
||||||
* @param rightwardLabel The rightwardLabel String that this RelationshipType should receive
|
* @param rightwardType The rightwardType String that this RelationshipType should receive
|
||||||
*/
|
*/
|
||||||
public void setRightwardLabel(String rightwardLabel) {
|
public void setRightwardType(String rightwardType) {
|
||||||
this.rightwardLabel = rightwardLabel;
|
this.rightwardType = rightwardType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -48,8 +48,8 @@ public class RelationshipTypeServiceImpl implements RelationshipTypeService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelationshipType findbyTypesAndLabels(Context context,EntityType leftType,EntityType rightType,
|
public RelationshipType findbyTypesAndLabels(Context context,EntityType leftType,EntityType rightType,
|
||||||
String leftwardLabel,String rightwardLabel) throws SQLException {
|
String leftwardType,String rightwardType) throws SQLException {
|
||||||
return relationshipTypeDAO.findByTypesAndLabels(context, leftType, rightType, leftwardLabel, rightwardLabel);
|
return relationshipTypeDAO.findByTypesAndLabels(context, leftType, rightType, leftwardType, rightwardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -58,8 +58,8 @@ public class RelationshipTypeServiceImpl implements RelationshipTypeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RelationshipType> findByLeftwardOrRightwardLabel(Context context, String label) throws SQLException {
|
public List<RelationshipType> findByLeftwardOrRightwardType(Context context, String label) throws SQLException {
|
||||||
return relationshipTypeDAO.findByLeftwardOrRightwardLabel(context, label);
|
return relationshipTypeDAO.findByLeftwardOrRightwardType(context, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -69,15 +69,15 @@ public class RelationshipTypeServiceImpl implements RelationshipTypeService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelationshipType create(Context context, EntityType leftEntityType, EntityType rightEntityType,
|
public RelationshipType create(Context context, EntityType leftEntityType, EntityType rightEntityType,
|
||||||
String leftwardLabel, String rightwardLabel, Integer leftCardinalityMinInteger,
|
String leftwardType, String rightwardType, Integer leftCardinalityMinInteger,
|
||||||
Integer leftCardinalityMaxInteger, Integer rightCardinalityMinInteger,
|
Integer leftCardinalityMaxInteger, Integer rightCardinalityMinInteger,
|
||||||
Integer rightCardinalityMaxInteger)
|
Integer rightCardinalityMaxInteger)
|
||||||
throws SQLException, AuthorizeException {
|
throws SQLException, AuthorizeException {
|
||||||
RelationshipType relationshipType = new RelationshipType();
|
RelationshipType relationshipType = new RelationshipType();
|
||||||
relationshipType.setLeftType(leftEntityType);
|
relationshipType.setLeftType(leftEntityType);
|
||||||
relationshipType.setRightType(rightEntityType);
|
relationshipType.setRightType(rightEntityType);
|
||||||
relationshipType.setLeftwardLabel(leftwardLabel);
|
relationshipType.setLeftwardType(leftwardType);
|
||||||
relationshipType.setRightwardLabel(rightwardLabel);
|
relationshipType.setRightwardType(rightwardType);
|
||||||
relationshipType.setLeftMinCardinality(leftCardinalityMinInteger);
|
relationshipType.setLeftMinCardinality(leftCardinalityMinInteger);
|
||||||
relationshipType.setLeftMaxCardinality(leftCardinalityMaxInteger);
|
relationshipType.setLeftMaxCardinality(leftCardinalityMaxInteger);
|
||||||
relationshipType.setRightMinCardinality(rightCardinalityMinInteger);
|
relationshipType.setRightMinCardinality(rightCardinalityMinInteger);
|
||||||
|
@@ -25,30 +25,30 @@ public interface RelationshipTypeDAO extends GenericDAO<RelationshipType> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to retrieve the RelationshipType object that has the same
|
* This method is used to retrieve the RelationshipType object that has the same
|
||||||
* leftType, rightType, leftwardLabel and rightwardLabel as given in the parameters
|
* leftType, rightType, leftwardType and rightwardType as given in the parameters
|
||||||
* @param context The relevant DSpace context
|
* @param context The relevant DSpace context
|
||||||
* @param leftType The leftType EntityType object to be matched in the query
|
* @param leftType The leftType EntityType object to be matched in the query
|
||||||
* @param rightType The rightType EntityType object to be matched in the query
|
* @param rightType The rightType EntityType object to be matched in the query
|
||||||
* @param leftwardLabel The leftwardLabel String to be matched in the query
|
* @param leftwardType The leftwardType String to be matched in the query
|
||||||
* @param rightwardLabel The rightwardLabel String to be matched in the query
|
* @param rightwardType The rightwardType String to be matched in the query
|
||||||
* @return The RelationshipType object that matches all the given parameters
|
* @return The RelationshipType object that matches all the given parameters
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
RelationshipType findByTypesAndLabels(Context context, EntityType leftType,EntityType rightType,
|
RelationshipType findByTypesAndLabels(Context context, EntityType leftType,EntityType rightType,
|
||||||
String leftwardLabel,
|
String leftwardType,
|
||||||
String rightwardLabel)
|
String rightwardType)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will return a list of RelationshipType objects for which the given label is equal to
|
* This method will return a list of RelationshipType objects for which the given label is equal to
|
||||||
* either the leftwardLabel or rightwardLabel.
|
* either the leftwardType or rightwardType.
|
||||||
* @param context The relevant DSpace context
|
* @param context The relevant DSpace context
|
||||||
* @param label The label that will be used to check on
|
* @param type The label that will be used to check on
|
||||||
* @return A list of RelationshipType objects that have the given label as either the leftwardLabel
|
* @return A list of RelationshipType objects that have the given label as either the leftwardType
|
||||||
* or rightwardLabel
|
* or rightwardType
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
List<RelationshipType> findByLeftwardOrRightwardLabel(Context context, String label) throws SQLException;
|
List<RelationshipType> findByLeftwardOrRightwardType(Context context, String type) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will return a list of RelationshipType objects for which the given EntityType object is equal
|
* This method will return a list of RelationshipType objects for which the given EntityType object is equal
|
||||||
|
@@ -24,7 +24,7 @@ public class RelationshipTypeDAOImpl extends AbstractHibernateDAO<RelationshipTy
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RelationshipType findByTypesAndLabels(Context context, EntityType leftType, EntityType rightType,
|
public RelationshipType findByTypesAndLabels(Context context, EntityType leftType, EntityType rightType,
|
||||||
String leftwardLabel, String rightwardLabel)
|
String leftwardType, String rightwardType)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class);
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class);
|
||||||
@@ -34,21 +34,21 @@ public class RelationshipTypeDAOImpl extends AbstractHibernateDAO<RelationshipTy
|
|||||||
criteriaBuilder.and(
|
criteriaBuilder.and(
|
||||||
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.leftType), leftType),
|
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.leftType), leftType),
|
||||||
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.rightType), rightType),
|
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.rightType), rightType),
|
||||||
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.leftwardLabel), leftwardLabel),
|
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.leftwardType), leftwardType),
|
||||||
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.rightwardLabel), rightwardLabel)));
|
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.rightwardType), rightwardType)));
|
||||||
return uniqueResult(context, criteriaQuery, false, RelationshipType.class, -1, -1);
|
return uniqueResult(context, criteriaQuery, false, RelationshipType.class, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RelationshipType> findByLeftwardOrRightwardLabel(Context context, String label) throws SQLException {
|
public List<RelationshipType> findByLeftwardOrRightwardType(Context context, String type) throws SQLException {
|
||||||
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context);
|
||||||
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class);
|
CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, RelationshipType.class);
|
||||||
Root<RelationshipType> relationshipTypeRoot = criteriaQuery.from(RelationshipType.class);
|
Root<RelationshipType> relationshipTypeRoot = criteriaQuery.from(RelationshipType.class);
|
||||||
criteriaQuery.select(relationshipTypeRoot);
|
criteriaQuery.select(relationshipTypeRoot);
|
||||||
criteriaQuery.where(
|
criteriaQuery.where(
|
||||||
criteriaBuilder.or(
|
criteriaBuilder.or(
|
||||||
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.leftwardLabel), label),
|
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.leftwardType), type),
|
||||||
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.rightwardLabel), label)
|
criteriaBuilder.equal(relationshipTypeRoot.get(RelationshipType_.rightwardType), type)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return list(context, criteriaQuery, true, RelationshipType.class, -1, -1);
|
return list(context, criteriaQuery, true, RelationshipType.class, -1, -1);
|
||||||
|
@@ -122,6 +122,6 @@ public interface EntityService {
|
|||||||
* to the given label parameter
|
* to the given label parameter
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
List<RelationshipType> getRelationshipTypesByLabel(Context context, String label) throws SQLException;
|
List<RelationshipType> getRelationshipTypesByType(Context context, String label) throws SQLException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -134,14 +134,14 @@ public interface RelationshipService extends DSpaceCRUDService<Relationship> {
|
|||||||
* @param relationshipType The RelationshipType object for the relationship
|
* @param relationshipType The RelationshipType object for the relationship
|
||||||
* @param leftPlace The leftPlace integer for the relationship
|
* @param leftPlace The leftPlace integer for the relationship
|
||||||
* @param rightPlace The rightPlace integer for the relationship
|
* @param rightPlace The rightPlace integer for the relationship
|
||||||
* @param leftwardLabel The leftwardLabel string for the relationship
|
* @param leftwardValue The leftwardValue string for the relationship
|
||||||
* @param rightwardLabel The rightwardLabel string for the relationship
|
* @param rightwardValue The rightwardValue string for the relationship
|
||||||
* @return The created Relationship object with the given properties
|
* @return The created Relationship object with the given properties
|
||||||
* @throws AuthorizeException If something goes wrong
|
* @throws AuthorizeException If something goes wrong
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
Relationship create(Context c, Item leftItem, Item rightItem, RelationshipType relationshipType,
|
Relationship create(Context c, Item leftItem, Item rightItem, RelationshipType relationshipType,
|
||||||
int leftPlace, int rightPlace, String leftwardLabel, String rightwardLabel)
|
int leftPlace, int rightPlace, String leftwardValue, String rightwardValue)
|
||||||
throws AuthorizeException, SQLException;
|
throws AuthorizeException, SQLException;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -36,13 +36,13 @@ public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipT
|
|||||||
* @param context The relevant DSpace context
|
* @param context The relevant DSpace context
|
||||||
* @param leftType The rightType EntityType that needs to match for the returned RelationshipType
|
* @param leftType The rightType EntityType that needs to match for the returned RelationshipType
|
||||||
* @param rightType The rightType EntityType that needs to match for the returned RelationshipType
|
* @param rightType The rightType EntityType that needs to match for the returned RelationshipType
|
||||||
* @param leftwardLabel The leftwardLabel String that needs to match for the returned RelationshipType
|
* @param leftwardType The leftwardType String that needs to match for the returned RelationshipType
|
||||||
* @param rightwardLabel The rightwardLabel String that needs to match for the returned RelationshipType
|
* @param rightwardType The rightwardType String that needs to match for the returned RelationshipType
|
||||||
* @return
|
* @return
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
RelationshipType findbyTypesAndLabels(Context context,EntityType leftType,EntityType rightType,
|
RelationshipType findbyTypesAndLabels(Context context,EntityType leftType,EntityType rightType,
|
||||||
String leftwardLabel,String rightwardLabel)
|
String leftwardType,String rightwardType)
|
||||||
throws SQLException;
|
throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +54,7 @@ public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipT
|
|||||||
List<RelationshipType> findAll(Context context) throws SQLException;
|
List<RelationshipType> findAll(Context context) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all RelationshipType objects that have a left or right label that is
|
* Retrieves all RelationshipType objects that have a left or right type that is
|
||||||
* equal to the given String
|
* equal to the given String
|
||||||
* @param context The relevant DSpace context
|
* @param context The relevant DSpace context
|
||||||
* @param label The label that has to match
|
* @param label The label that has to match
|
||||||
@@ -62,7 +62,7 @@ public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipT
|
|||||||
* that is equal to the given label param
|
* that is equal to the given label param
|
||||||
* @throws SQLException If something goes wrong
|
* @throws SQLException If something goes wrong
|
||||||
*/
|
*/
|
||||||
List<RelationshipType> findByLeftwardOrRightwardLabel(Context context, String label) throws SQLException;
|
List<RelationshipType> findByLeftwardOrRightwardType(Context context, String label) throws SQLException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of RelationshipType objects for which the given EntityType is equal to either the leftType
|
* Returns a list of RelationshipType objects for which the given EntityType is equal to either the leftType
|
||||||
@@ -80,8 +80,8 @@ public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipT
|
|||||||
* @param context The relevant DSpace context
|
* @param context The relevant DSpace context
|
||||||
* @param leftEntityType The leftEntityType EntityType object for this relationshipType
|
* @param leftEntityType The leftEntityType EntityType object for this relationshipType
|
||||||
* @param rightEntityType The rightEntityType EntityType object for this relationshipType
|
* @param rightEntityType The rightEntityType EntityType object for this relationshipType
|
||||||
* @param leftwardLabel The leftwardLabel String object for this relationshipType
|
* @param leftwardType The leftwardType String object for this relationshipType
|
||||||
* @param rightwardLabel The rightwardLabel String object for this relationshipType
|
* @param rightwardType The rightwardType String object for this relationshipType
|
||||||
* @param leftCardinalityMinInteger The leftCardinalityMinInteger Integer object for this relationshipType
|
* @param leftCardinalityMinInteger The leftCardinalityMinInteger Integer object for this relationshipType
|
||||||
* @param leftCardinalityMaxInteger The leftCardinalityMaxInteger Integer object for this relationshipType
|
* @param leftCardinalityMaxInteger The leftCardinalityMaxInteger Integer object for this relationshipType
|
||||||
* @param rightCardinalityMinInteger The rightCardinalityMinInteger Integer object for this relationshipType
|
* @param rightCardinalityMinInteger The rightCardinalityMinInteger Integer object for this relationshipType
|
||||||
@@ -91,7 +91,7 @@ public interface RelationshipTypeService extends DSpaceCRUDService<RelationshipT
|
|||||||
* @throws AuthorizeException If something goes wrong
|
* @throws AuthorizeException If something goes wrong
|
||||||
*/
|
*/
|
||||||
RelationshipType create(Context context, EntityType leftEntityType, EntityType rightEntityType,
|
RelationshipType create(Context context, EntityType leftEntityType, EntityType rightEntityType,
|
||||||
String leftwardLabel, String rightwardLabel, Integer leftCardinalityMinInteger,
|
String leftwardType, String rightwardType, Integer leftCardinalityMinInteger,
|
||||||
Integer leftCardinalityMaxInteger, Integer rightCardinalityMinInteger,
|
Integer leftCardinalityMaxInteger, Integer rightCardinalityMinInteger,
|
||||||
Integer rightCardinalityMaxInteger)
|
Integer rightCardinalityMaxInteger)
|
||||||
throws SQLException, AuthorizeException;
|
throws SQLException, AuthorizeException;
|
||||||
|
@@ -155,8 +155,8 @@ public class Related implements VirtualMetadataConfiguration {
|
|||||||
List<RelationshipType> relationshipTypes = entityService.getAllRelationshipTypes(context, entity);
|
List<RelationshipType> relationshipTypes = entityService.getAllRelationshipTypes(context, entity);
|
||||||
List<RelationshipType> possibleRelationshipTypes = new LinkedList<>();
|
List<RelationshipType> possibleRelationshipTypes = new LinkedList<>();
|
||||||
for (RelationshipType relationshipType : relationshipTypes) {
|
for (RelationshipType relationshipType : relationshipTypes) {
|
||||||
if (StringUtils.equals(relationshipType.getLeftwardLabel(), relationshipTypeString) || StringUtils
|
if (StringUtils.equals(relationshipType.getLeftwardType(), relationshipTypeString) || StringUtils
|
||||||
.equals(relationshipType.getRightwardLabel(), relationshipTypeString)) {
|
.equals(relationshipType.getRightwardType(), relationshipTypeString)) {
|
||||||
possibleRelationshipTypes.add(relationshipType);
|
possibleRelationshipTypes.add(relationshipType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,17 +42,17 @@ public class VirtualMetadataPopulator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will return a boolean indicating whether the useForPlace is true or false for the given
|
* This method will return a boolean indicating whether the useForPlace is true or false for the given
|
||||||
* RelationshipType for the left or right label as indicated by the second parameter.
|
* RelationshipType for the left or right type as indicated by the second parameter.
|
||||||
* @param relationshipType The relationshipType for which this should be checked
|
* @param relationshipType The relationshipType for which this should be checked
|
||||||
* @param isLeft The boolean indicating whether to check the left or the right label
|
* @param isLeft The boolean indicating whether to check the left or the right type
|
||||||
* @return A boolean indicating whether the useForPlace is true or not for the given parameters
|
* @return A boolean indicating whether the useForPlace is true or not for the given parameters
|
||||||
*/
|
*/
|
||||||
public boolean isUseForPlaceTrueForRelationshipType(RelationshipType relationshipType, boolean isLeft) {
|
public boolean isUseForPlaceTrueForRelationshipType(RelationshipType relationshipType, boolean isLeft) {
|
||||||
HashMap<String, VirtualMetadataConfiguration> hashMaps;
|
HashMap<String, VirtualMetadataConfiguration> hashMaps;
|
||||||
if (isLeft) {
|
if (isLeft) {
|
||||||
hashMaps = this.getMap().get(relationshipType.getLeftwardLabel());
|
hashMaps = this.getMap().get(relationshipType.getLeftwardType());
|
||||||
} else {
|
} else {
|
||||||
hashMaps = this.getMap().get(relationshipType.getRightwardLabel());
|
hashMaps = this.getMap().get(relationshipType.getRightwardType());
|
||||||
}
|
}
|
||||||
if (hashMaps != null) {
|
if (hashMaps != null) {
|
||||||
for (Map.Entry<String, VirtualMetadataConfiguration> entry : hashMaps.entrySet()) {
|
for (Map.Entry<String, VirtualMetadataConfiguration> entry : hashMaps.entrySet()) {
|
||||||
|
@@ -7,12 +7,12 @@
|
|||||||
--
|
--
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------
|
||||||
-- Create columns leftwardLabel and rightwardLabel in table relationship
|
-- Create columns leftwardValue and rightwardValue in table relationship
|
||||||
-- Rename columns left_label and right_label to leftward_label and rightward_label
|
-- Rename columns left_label and right_label to leftward_type and rightward_type
|
||||||
-----------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
ALTER TABLE relationship ADD leftward_label VARCHAR;
|
ALTER TABLE relationship ADD leftward_value VARCHAR;
|
||||||
ALTER TABLE relationship ADD rightward_label VARCHAR;
|
ALTER TABLE relationship ADD rightward_value VARCHAR;
|
||||||
|
|
||||||
ALTER TABLE relationship_type ALTER COLUMN left_label RENAME TO leftward_label;
|
ALTER TABLE relationship_type ALTER COLUMN left_label RENAME TO leftward_type;
|
||||||
ALTER TABLE relationship_type ALTER COLUMN right_label RENAME TO rightward_label;
|
ALTER TABLE relationship_type ALTER COLUMN right_label RENAME TO rightward_type;
|
@@ -7,12 +7,12 @@
|
|||||||
--
|
--
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------
|
||||||
-- Create columns leftwardLabel and rightwardLabel in table relationship
|
-- Create columns leftwardValue and rightwardValue in table relationship
|
||||||
-- Rename columns left_label and right_label to leftward_label and rightward_label
|
-- Rename columns left_label and right_label to leftward_type and rightward_type
|
||||||
-----------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
ALTER TABLE relationship ADD leftward_label VARCHAR;
|
ALTER TABLE relationship ADD leftward_value VARCHAR;
|
||||||
ALTER TABLE relationship ADD rightward_label VARCHAR;
|
ALTER TABLE relationship ADD rightward_value VARCHAR;
|
||||||
|
|
||||||
ALTER TABLE relationship_type RENAME left_label TO leftward_label;
|
ALTER TABLE relationship_type RENAME left_label TO leftward_type;
|
||||||
ALTER TABLE relationship_type RENAME right_label TO rightward_label;
|
ALTER TABLE relationship_type RENAME right_label TO rightward_type;
|
@@ -7,12 +7,12 @@
|
|||||||
--
|
--
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------
|
||||||
-- Create columns leftwardLabel and rightwardLabel in table relationship
|
-- Create columns leftwardValue and rightwardValue in table relationship
|
||||||
-- Rename columns left_label and right_label to leftward_label and rightward_label
|
-- Rename columns left_label and right_label to leftward_type and rightward_type
|
||||||
-----------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
ALTER TABLE relationship ADD leftward_label VARCHAR;
|
ALTER TABLE relationship ADD leftward_value VARCHAR;
|
||||||
ALTER TABLE relationship ADD rightward_label VARCHAR;
|
ALTER TABLE relationship ADD rightward_value VARCHAR;
|
||||||
|
|
||||||
ALTER TABLE relationship_type RENAME COLUMN left_label TO leftward_label;
|
ALTER TABLE relationship_type RENAME COLUMN left_label TO leftward_type;
|
||||||
ALTER TABLE relationship_type RENAME COLUMN right_label TO rightward_label;
|
ALTER TABLE relationship_type RENAME COLUMN right_label TO rightward_type;
|
@@ -5,8 +5,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Publication</leftType>
|
<leftType>Publication</leftType>
|
||||||
<rightType>Person</rightType>
|
<rightType>Person</rightType>
|
||||||
<leftwardLabel>isAuthorOfPublication</leftwardLabel>
|
<leftwardType>isAuthorOfPublication</leftwardType>
|
||||||
<rightwardLabel>isPublicationOfAuthor</rightwardLabel>
|
<rightwardType>isPublicationOfAuthor</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>10</min>
|
<min>10</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Publication</leftType>
|
<leftType>Publication</leftType>
|
||||||
<rightType>Project</rightType>
|
<rightType>Project</rightType>
|
||||||
<leftwardLabel>isProjectOfPublication</leftwardLabel>
|
<leftwardType>isProjectOfPublication</leftwardType>
|
||||||
<rightwardLabel>isPublicationOfProject</rightwardLabel>
|
<rightwardType>isPublicationOfProject</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -29,8 +29,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Publication</leftType>
|
<leftType>Publication</leftType>
|
||||||
<rightType>OrgUnit</rightType>
|
<rightType>OrgUnit</rightType>
|
||||||
<leftwardLabel>isOrgUnitOfPublication</leftwardLabel>
|
<leftwardType>isOrgUnitOfPublication</leftwardType>
|
||||||
<rightwardLabel>isPublicationOfOrgUnit</rightwardLabel>
|
<rightwardType>isPublicationOfOrgUnit</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -41,8 +41,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Person</leftType>
|
<leftType>Person</leftType>
|
||||||
<rightType>Project</rightType>
|
<rightType>Project</rightType>
|
||||||
<leftwardLabel>isProjectOfPerson</leftwardLabel>
|
<leftwardType>isProjectOfPerson</leftwardType>
|
||||||
<rightwardLabel>isPersonOfProject</rightwardLabel>
|
<rightwardType>isPersonOfProject</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -53,8 +53,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Person</leftType>
|
<leftType>Person</leftType>
|
||||||
<rightType>OrgUnit</rightType>
|
<rightType>OrgUnit</rightType>
|
||||||
<leftwardLabel>isOrgUnitOfPerson</leftwardLabel>
|
<leftwardType>isOrgUnitOfPerson</leftwardType>
|
||||||
<rightwardLabel>isPersonOfOrgUnit</rightwardLabel>
|
<rightwardType>isPersonOfOrgUnit</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -65,8 +65,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Project</leftType>
|
<leftType>Project</leftType>
|
||||||
<rightType>OrgUnit</rightType>
|
<rightType>OrgUnit</rightType>
|
||||||
<leftwardLabel>isOrgUnitOfProject</leftwardLabel>
|
<leftwardType>isOrgUnitOfProject</leftwardType>
|
||||||
<rightwardLabel>isProjectOfOrgUnit</rightwardLabel>
|
<rightwardType>isProjectOfOrgUnit</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -77,8 +77,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Journal</leftType>
|
<leftType>Journal</leftType>
|
||||||
<rightType>JournalVolume</rightType>
|
<rightType>JournalVolume</rightType>
|
||||||
<leftwardLabel>isVolumeOfJournal</leftwardLabel>
|
<leftwardType>isVolumeOfJournal</leftwardType>
|
||||||
<rightwardLabel>isJournalOfVolume</rightwardLabel>
|
<rightwardType>isJournalOfVolume</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -89,8 +89,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>JournalVolume</leftType>
|
<leftType>JournalVolume</leftType>
|
||||||
<rightType>JournalIssue</rightType>
|
<rightType>JournalIssue</rightType>
|
||||||
<leftwardLabel>isIssueOfJournalVolume</leftwardLabel>
|
<leftwardType>isIssueOfJournalVolume</leftwardType>
|
||||||
<rightwardLabel>isJournalVolumeOfIssue</rightwardLabel>
|
<rightwardType>isJournalVolumeOfIssue</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -102,8 +102,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Publication</leftType>
|
<leftType>Publication</leftType>
|
||||||
<rightType>OrgUnit</rightType>
|
<rightType>OrgUnit</rightType>
|
||||||
<leftwardLabel>isAuthorOfPublication</leftwardLabel>
|
<leftwardType>isAuthorOfPublication</leftwardType>
|
||||||
<rightwardLabel>isPublicationOfAuthor</rightwardLabel>
|
<rightwardType>isPublicationOfAuthor</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -114,8 +114,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>JournalIssue</leftType>
|
<leftType>JournalIssue</leftType>
|
||||||
<rightType>Publication</rightType>
|
<rightType>Publication</rightType>
|
||||||
<leftwardLabel>isPublicationOfJournalIssue</leftwardLabel>
|
<leftwardType>isPublicationOfJournalIssue</leftwardType>
|
||||||
<rightwardLabel>isJournalIssueOfPublication</rightwardLabel>
|
<rightwardType>isJournalIssueOfPublication</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
|
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
|
|
||||||
<!ELEMENT relationships (type)*>
|
<!ELEMENT relationships (type)*>
|
||||||
<!ELEMENT type (leftType|rightType|leftwardLabel|rightwardLabel|leftCardinality|rightCardinality)*>
|
<!ELEMENT type (leftType|rightType|leftwardType|rightwardType|leftCardinality|rightCardinality)*>
|
||||||
<!ELEMENT leftType (#PCDATA)>
|
<!ELEMENT leftType (#PCDATA)>
|
||||||
<!ELEMENT rightType (#PCDATA)>
|
<!ELEMENT rightType (#PCDATA)>
|
||||||
<!ELEMENT leftwardLabel (#PCDATA)>
|
<!ELEMENT leftwardType (#PCDATA)>
|
||||||
<!ELEMENT rightwardLabel (#PCDATA)>
|
<!ELEMENT rightwardType (#PCDATA)>
|
||||||
<!ELEMENT leftCardinality (min|max)*>
|
<!ELEMENT leftCardinality (min|max)*>
|
||||||
<!ELEMENT min (#PCDATA)>
|
<!ELEMENT min (#PCDATA)>
|
||||||
<!ELEMENT rightCardinality (min|max)*>
|
<!ELEMENT rightCardinality (min|max)*>
|
||||||
|
@@ -5,8 +5,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Publication</leftType>
|
<leftType>Publication</leftType>
|
||||||
<rightType>Person</rightType>
|
<rightType>Person</rightType>
|
||||||
<leftwardLabel>isAuthorOfPublication</leftwardLabel>
|
<leftwardType>isAuthorOfPublication</leftwardType>
|
||||||
<rightwardLabel>isPublicationOfAuthor</rightwardLabel>
|
<rightwardType>isPublicationOfAuthor</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Publication</leftType>
|
<leftType>Publication</leftType>
|
||||||
<rightType>Project</rightType>
|
<rightType>Project</rightType>
|
||||||
<leftwardLabel>isProjectOfPublication</leftwardLabel>
|
<leftwardType>isProjectOfPublication</leftwardType>
|
||||||
<rightwardLabel>isPublicationOfProject</rightwardLabel>
|
<rightwardType>isPublicationOfProject</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -29,8 +29,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Publication</leftType>
|
<leftType>Publication</leftType>
|
||||||
<rightType>OrgUnit</rightType>
|
<rightType>OrgUnit</rightType>
|
||||||
<leftwardLabel>isOrgUnitOfPublication</leftwardLabel>
|
<leftwardType>isOrgUnitOfPublication</leftwardType>
|
||||||
<rightwardLabel>isPublicationOfOrgUnit</rightwardLabel>
|
<rightwardType>isPublicationOfOrgUnit</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -41,8 +41,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Person</leftType>
|
<leftType>Person</leftType>
|
||||||
<rightType>Project</rightType>
|
<rightType>Project</rightType>
|
||||||
<leftwardLabel>isProjectOfPerson</leftwardLabel>
|
<leftwardType>isProjectOfPerson</leftwardType>
|
||||||
<rightwardLabel>isPersonOfProject</rightwardLabel>
|
<rightwardType>isPersonOfProject</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -53,8 +53,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Person</leftType>
|
<leftType>Person</leftType>
|
||||||
<rightType>OrgUnit</rightType>
|
<rightType>OrgUnit</rightType>
|
||||||
<leftwardLabel>isOrgUnitOfPerson</leftwardLabel>
|
<leftwardType>isOrgUnitOfPerson</leftwardType>
|
||||||
<rightwardLabel>isPersonOfOrgUnit</rightwardLabel>
|
<rightwardType>isPersonOfOrgUnit</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -65,8 +65,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Project</leftType>
|
<leftType>Project</leftType>
|
||||||
<rightType>OrgUnit</rightType>
|
<rightType>OrgUnit</rightType>
|
||||||
<leftwardLabel>isOrgUnitOfProject</leftwardLabel>
|
<leftwardType>isOrgUnitOfProject</leftwardType>
|
||||||
<rightwardLabel>isProjectOfOrgUnit</rightwardLabel>
|
<rightwardType>isProjectOfOrgUnit</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -77,8 +77,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Journal</leftType>
|
<leftType>Journal</leftType>
|
||||||
<rightType>JournalVolume</rightType>
|
<rightType>JournalVolume</rightType>
|
||||||
<leftwardLabel>isVolumeOfJournal</leftwardLabel>
|
<leftwardType>isVolumeOfJournal</leftwardType>
|
||||||
<rightwardLabel>isJournalOfVolume</rightwardLabel>
|
<rightwardType>isJournalOfVolume</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -89,8 +89,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>JournalVolume</leftType>
|
<leftType>JournalVolume</leftType>
|
||||||
<rightType>JournalIssue</rightType>
|
<rightType>JournalIssue</rightType>
|
||||||
<leftwardLabel>isIssueOfJournalVolume</leftwardLabel>
|
<leftwardType>isIssueOfJournalVolume</leftwardType>
|
||||||
<rightwardLabel>isJournalVolumeOfIssue</rightwardLabel>
|
<rightwardType>isJournalVolumeOfIssue</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -102,8 +102,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>Publication</leftType>
|
<leftType>Publication</leftType>
|
||||||
<rightType>OrgUnit</rightType>
|
<rightType>OrgUnit</rightType>
|
||||||
<leftwardLabel>isAuthorOfPublication</leftwardLabel>
|
<leftwardType>isAuthorOfPublication</leftwardType>
|
||||||
<rightwardLabel>isPublicationOfAuthor</rightwardLabel>
|
<rightwardType>isPublicationOfAuthor</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
@@ -114,8 +114,8 @@
|
|||||||
<type>
|
<type>
|
||||||
<leftType>JournalIssue</leftType>
|
<leftType>JournalIssue</leftType>
|
||||||
<rightType>Publication</rightType>
|
<rightType>Publication</rightType>
|
||||||
<leftwardLabel>isPublicationOfJournalIssue</leftwardLabel>
|
<leftwardType>isPublicationOfJournalIssue</leftwardType>
|
||||||
<rightwardLabel>isJournalIssueOfPublication</rightwardLabel>
|
<rightwardType>isJournalIssueOfPublication</rightwardType>
|
||||||
<leftCardinality>
|
<leftCardinality>
|
||||||
<min>0</min>
|
<min>0</min>
|
||||||
</leftCardinality>
|
</leftCardinality>
|
||||||
|
@@ -145,15 +145,15 @@ public class EntityServiceImplTest {
|
|||||||
List<Relationship> relationshipList = new ArrayList<>();
|
List<Relationship> relationshipList = new ArrayList<>();
|
||||||
relationshipList.add(relationship);
|
relationshipList.add(relationship);
|
||||||
|
|
||||||
// Mock the state of objects utilized in getRelationsByLabel() to meet the success criteria of an invocation
|
// Mock the state of objects utilized in getRelationsByType() to meet the success criteria of an invocation
|
||||||
when(relationshipService.findAll(context)).thenReturn(relationshipList);
|
when(relationshipService.findAll(context)).thenReturn(relationshipList);
|
||||||
when(relationship.getRelationshipType()).thenReturn(relationshipType);
|
when(relationship.getRelationshipType()).thenReturn(relationshipType);
|
||||||
when(relationshipType.getLeftwardLabel()).thenReturn("leftwardLabel");
|
when(relationshipType.getLeftwardType()).thenReturn("leftwardType");
|
||||||
when(relationshipType.getRightwardLabel()).thenReturn("rightwardLabel");
|
when(relationshipType.getRightwardType()).thenReturn("rightwardType");
|
||||||
|
|
||||||
// The relation(s) reported from our defined label should match our relationshipList
|
// The relation(s) reported from our defined type should match our relationshipList
|
||||||
assertEquals("TestGetRelationsByLabel 0", relationshipList,
|
assertEquals("TestGetRelationsByLabel 0", relationshipList,
|
||||||
entityService.getRelationsByLabel(context, "leftwardLabel"));
|
entityService.getRelationsByLabel(context, "leftwardType"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -260,15 +260,15 @@ public class EntityServiceImplTest {
|
|||||||
RelationshipType relationshipType = mock(RelationshipType.class);
|
RelationshipType relationshipType = mock(RelationshipType.class);
|
||||||
list.add(relationshipType);
|
list.add(relationshipType);
|
||||||
|
|
||||||
// Mock the state of objects utilized in getRelationshipTypesByLabel()
|
// Mock the state of objects utilized in getRelationshipTypesByType()
|
||||||
// to meet the success criteria of the invocation
|
// to meet the success criteria of the invocation
|
||||||
when(relationshipTypeService.findAll(context)).thenReturn(list);
|
when(relationshipTypeService.findAll(context)).thenReturn(list);
|
||||||
when(relationshipType.getLeftwardLabel()).thenReturn("leftwardLabel");
|
when(relationshipType.getLeftwardType()).thenReturn("leftwardType");
|
||||||
when(relationshipType.getRightwardLabel()).thenReturn("rightwardLabel");
|
when(relationshipType.getRightwardType()).thenReturn("rightwardType");
|
||||||
|
|
||||||
// The RelationshipType(s) reported from our mocked Entity should match our list
|
// The RelationshipType(s) reported from our mocked Entity should match our list
|
||||||
assertEquals("TestGetRelationshipTypesByLabel 0", list,
|
assertEquals("TestGetRelationshipTypesByLabel 0", list,
|
||||||
entityService.getRelationshipTypesByLabel(context, "leftwardLabel"));
|
entityService.getRelationshipTypesByType(context, "leftwardType"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -84,12 +84,12 @@ public class RelationshipServiceImplTest {
|
|||||||
RelationshipType hasDog = new RelationshipType();
|
RelationshipType hasDog = new RelationshipType();
|
||||||
RelationshipType hasFather = new RelationshipType();
|
RelationshipType hasFather = new RelationshipType();
|
||||||
RelationshipType hasMother = new RelationshipType();
|
RelationshipType hasMother = new RelationshipType();
|
||||||
hasDog.setLeftwardLabel("hasDog");
|
hasDog.setLeftwardType("hasDog");
|
||||||
hasDog.setRightwardLabel("isDogOf");
|
hasDog.setRightwardType("isDogOf");
|
||||||
hasFather.setLeftwardLabel("hasFather");
|
hasFather.setLeftwardType("hasFather");
|
||||||
hasFather.setRightwardLabel("isFatherOf");
|
hasFather.setRightwardType("isFatherOf");
|
||||||
hasMother.setLeftwardLabel("hasMother");
|
hasMother.setLeftwardType("hasMother");
|
||||||
hasMother.setRightwardLabel("isMotherOf");
|
hasMother.setRightwardType("isMotherOf");
|
||||||
|
|
||||||
relationshipTest.add(getRelationship(cindy, spot, hasDog,0,0));
|
relationshipTest.add(getRelationship(cindy, spot, hasDog,0,0));
|
||||||
relationshipTest.add(getRelationship(cindy, jasper, hasDog,0,1));
|
relationshipTest.add(getRelationship(cindy, jasper, hasDog,0,1));
|
||||||
@@ -194,8 +194,8 @@ public class RelationshipServiceImplTest {
|
|||||||
EntityType rightEntityType = mock(EntityType.class);
|
EntityType rightEntityType = mock(EntityType.class);
|
||||||
testRel.setLeftType(leftEntityType);
|
testRel.setLeftType(leftEntityType);
|
||||||
testRel.setRightType(rightEntityType);
|
testRel.setRightType(rightEntityType);
|
||||||
testRel.setLeftwardLabel("Entitylabel");
|
testRel.setLeftwardType("Entitylabel");
|
||||||
testRel.setRightwardLabel("Entitylabel");
|
testRel.setRightwardType("Entitylabel");
|
||||||
metsList.add(metVal);
|
metsList.add(metVal);
|
||||||
relationship = getRelationship(leftItem, rightItem, testRel, 0,0);
|
relationship = getRelationship(leftItem, rightItem, testRel, 0,0);
|
||||||
leftTypelist.add(relationship);
|
leftTypelist.add(relationship);
|
||||||
@@ -247,8 +247,8 @@ public class RelationshipServiceImplTest {
|
|||||||
EntityType rightEntityType = mock(EntityType.class);
|
EntityType rightEntityType = mock(EntityType.class);
|
||||||
testRel.setLeftType(leftEntityType);
|
testRel.setLeftType(leftEntityType);
|
||||||
testRel.setRightType(rightEntityType);
|
testRel.setRightType(rightEntityType);
|
||||||
testRel.setLeftwardLabel("Entitylabel");
|
testRel.setLeftwardType("Entitylabel");
|
||||||
testRel.setRightwardLabel("Entitylabel");
|
testRel.setRightwardType("Entitylabel");
|
||||||
testRel.setLeftMinCardinality(0);
|
testRel.setLeftMinCardinality(0);
|
||||||
testRel.setRightMinCardinality(0);
|
testRel.setRightMinCardinality(0);
|
||||||
metsList.add(metVal);
|
metsList.add(metVal);
|
||||||
@@ -299,8 +299,8 @@ public class RelationshipServiceImplTest {
|
|||||||
EntityType rightEntityType = mock(EntityType.class);
|
EntityType rightEntityType = mock(EntityType.class);
|
||||||
testRel.setLeftType(leftEntityType);
|
testRel.setLeftType(leftEntityType);
|
||||||
testRel.setRightType(rightEntityType);
|
testRel.setRightType(rightEntityType);
|
||||||
testRel.setLeftwardLabel("Entitylabel");
|
testRel.setLeftwardType("Entitylabel");
|
||||||
testRel.setRightwardLabel("Entitylabel");
|
testRel.setRightwardType("Entitylabel");
|
||||||
testRel.setLeftMinCardinality(0);
|
testRel.setLeftMinCardinality(0);
|
||||||
testRel.setRightMinCardinality(0);
|
testRel.setRightMinCardinality(0);
|
||||||
metsList.add(metVal);
|
metsList.add(metVal);
|
||||||
|
@@ -51,8 +51,8 @@ public class RelationshipTypeTest {
|
|||||||
firstRelationshipType.setId(1);
|
firstRelationshipType.setId(1);
|
||||||
firstRelationshipType.setLeftType(mock(EntityType.class));
|
firstRelationshipType.setLeftType(mock(EntityType.class));
|
||||||
firstRelationshipType.setRightType(mock(EntityType.class));
|
firstRelationshipType.setRightType(mock(EntityType.class));
|
||||||
firstRelationshipType.setLeftwardLabel("isAuthorOfPublication");
|
firstRelationshipType.setLeftwardType("isAuthorOfPublication");
|
||||||
firstRelationshipType.setRightwardLabel("isPublicationOfAuthor");
|
firstRelationshipType.setRightwardType("isPublicationOfAuthor");
|
||||||
firstRelationshipType.setLeftMinCardinality(0);
|
firstRelationshipType.setLeftMinCardinality(0);
|
||||||
firstRelationshipType.setLeftMaxCardinality(null);
|
firstRelationshipType.setLeftMaxCardinality(null);
|
||||||
firstRelationshipType.setRightMinCardinality(0);
|
firstRelationshipType.setRightMinCardinality(0);
|
||||||
@@ -63,8 +63,8 @@ public class RelationshipTypeTest {
|
|||||||
secondRelationshipType.setId(new Random().nextInt());
|
secondRelationshipType.setId(new Random().nextInt());
|
||||||
secondRelationshipType.setLeftType(mock(EntityType.class));
|
secondRelationshipType.setLeftType(mock(EntityType.class));
|
||||||
secondRelationshipType.setRightType(mock(EntityType.class));
|
secondRelationshipType.setRightType(mock(EntityType.class));
|
||||||
secondRelationshipType.setLeftwardLabel("isProjectOfPerson");
|
secondRelationshipType.setLeftwardType("isProjectOfPerson");
|
||||||
secondRelationshipType.setRightwardLabel("isPersonOfProject");
|
secondRelationshipType.setRightwardType("isPersonOfProject");
|
||||||
secondRelationshipType.setLeftMinCardinality(0);
|
secondRelationshipType.setLeftMinCardinality(0);
|
||||||
secondRelationshipType.setLeftMaxCardinality(null);
|
secondRelationshipType.setLeftMaxCardinality(null);
|
||||||
secondRelationshipType.setRightMinCardinality(0);
|
secondRelationshipType.setRightMinCardinality(0);
|
||||||
@@ -118,16 +118,16 @@ public class RelationshipTypeTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testRelationshipTypeFindByLeftOrRightwardLabel() throws Exception {
|
public void testRelationshipTypeFindByLeftOrRightwardType() throws Exception {
|
||||||
// Declare objects utilized for this test
|
// Declare objects utilized for this test
|
||||||
List<RelationshipType> mockedList = new LinkedList<>();
|
List<RelationshipType> mockedList = new LinkedList<>();
|
||||||
mockedList.add(firstRelationshipType);
|
mockedList.add(firstRelationshipType);
|
||||||
|
|
||||||
// Mock DAO to return our mockedList
|
// Mock DAO to return our mockedList
|
||||||
when(relationshipTypeDAO.findByLeftwardOrRightwardLabel(any(), any())).thenReturn(mockedList);
|
when(relationshipTypeDAO.findByLeftwardOrRightwardType(any(), any())).thenReturn(mockedList);
|
||||||
|
|
||||||
// Invoke findByLeftwardOrRightwardLabel()
|
// Invoke findByLeftwardOrRightwardType()
|
||||||
List<RelationshipType> found = relationshipTypeService.findByLeftwardOrRightwardLabel(context, "mock");
|
List<RelationshipType> found = relationshipTypeService.findByLeftwardOrRightwardType(context, "mock");
|
||||||
|
|
||||||
// Assert that our expected list contains our expected RelationshipType and nothing more
|
// Assert that our expected list contains our expected RelationshipType and nothing more
|
||||||
assertThat(found, notNullValue());
|
assertThat(found, notNullValue());
|
||||||
@@ -160,8 +160,8 @@ public class RelationshipTypeTest {
|
|||||||
*/
|
*/
|
||||||
private void checkRelationshipTypeValues(RelationshipType found, RelationshipType original) {
|
private void checkRelationshipTypeValues(RelationshipType found, RelationshipType original) {
|
||||||
assertThat(found, notNullValue());
|
assertThat(found, notNullValue());
|
||||||
assertThat(found.getLeftwardLabel(), equalTo(original.getLeftwardLabel()));
|
assertThat(found.getLeftwardType(), equalTo(original.getLeftwardType()));
|
||||||
assertThat(found.getRightwardLabel(), equalTo(original.getRightwardLabel()));
|
assertThat(found.getRightwardType(), equalTo(original.getRightwardType()));
|
||||||
assertThat(found.getLeftType(), equalTo(original.getLeftType()));
|
assertThat(found.getLeftType(), equalTo(original.getLeftType()));
|
||||||
assertThat(found.getRightType(), equalTo(original.getRightType()));
|
assertThat(found.getRightType(), equalTo(original.getRightType()));
|
||||||
assertThat(found.getLeftMinCardinality(), equalTo(original.getLeftMinCardinality()));
|
assertThat(found.getLeftMinCardinality(), equalTo(original.getLeftMinCardinality()));
|
||||||
|
@@ -124,15 +124,15 @@ public class RelatedTest {
|
|||||||
Entity entity = mock(Entity.class);
|
Entity entity = mock(Entity.class);
|
||||||
EntityType entityType = mock(EntityType.class);
|
EntityType entityType = mock(EntityType.class);
|
||||||
RelationshipType relationshipType = mock(RelationshipType.class);
|
RelationshipType relationshipType = mock(RelationshipType.class);
|
||||||
related.setRelationshipTypeString("LeftwardLabel");
|
related.setRelationshipTypeString("LeftwardType");
|
||||||
relationshipTypeList.add(relationshipType);
|
relationshipTypeList.add(relationshipType);
|
||||||
relationshipList.add(relationship);
|
relationshipList.add(relationship);
|
||||||
related.setPlace(0);
|
related.setPlace(0);
|
||||||
|
|
||||||
// Mock the state of objects utilized in getRelationsByLabel() to meet the success criteria of an invocation
|
// Mock the state of objects utilized in getRelationsByLabel() to meet the success criteria of an invocation
|
||||||
when(item.getID()).thenReturn(UUID.randomUUID());
|
when(item.getID()).thenReturn(UUID.randomUUID());
|
||||||
when(relationshipType.getLeftwardLabel()).thenReturn("LeftwardLabel");
|
when(relationshipType.getLeftwardType()).thenReturn("LeftwardType");
|
||||||
when(relationshipType.getRightwardLabel()).thenReturn("RightwardLabel");
|
when(relationshipType.getRightwardType()).thenReturn("RightwardType");
|
||||||
when(relationshipType.getLeftType()).thenReturn(entityType);
|
when(relationshipType.getLeftType()).thenReturn(entityType);
|
||||||
when(relationshipType.getRightType()).thenReturn(entityType);
|
when(relationshipType.getRightType()).thenReturn(entityType);
|
||||||
when(entityService.getAllRelationshipTypes(context, entity)).thenReturn(relationshipTypeList);
|
when(entityService.getAllRelationshipTypes(context, entity)).thenReturn(relationshipTypeList);
|
||||||
|
@@ -62,15 +62,15 @@ public class VirtualMetadataPopulatorTest {
|
|||||||
HashMap<String, VirtualMetadataConfiguration> mapExt = new HashMap<>();
|
HashMap<String, VirtualMetadataConfiguration> mapExt = new HashMap<>();
|
||||||
VirtualMetadataConfiguration virtualMetadataConfiguration = mock(VirtualMetadataConfiguration.class);
|
VirtualMetadataConfiguration virtualMetadataConfiguration = mock(VirtualMetadataConfiguration.class);
|
||||||
mapExt.put("hashKey", virtualMetadataConfiguration);
|
mapExt.put("hashKey", virtualMetadataConfiguration);
|
||||||
map.put("LeftwardLabel", mapExt);
|
map.put("LeftwardType", mapExt);
|
||||||
map.put("NotRightwardLabel", mapExt);
|
map.put("NotRightwardType", mapExt);
|
||||||
virtualMetadataPopulator.setMap(map);
|
virtualMetadataPopulator.setMap(map);
|
||||||
|
|
||||||
// Mock the state of objects utilized in isUseForPlaceTrueForRelationshipType()
|
// Mock the state of objects utilized in isUseForPlaceTrueForRelationshipType()
|
||||||
// to meet the success criteria of an invocation
|
// to meet the success criteria of an invocation
|
||||||
when(virtualMetadataConfiguration.getUseForPlace()).thenReturn(true);
|
when(virtualMetadataConfiguration.getUseForPlace()).thenReturn(true);
|
||||||
when(relationshipType.getLeftwardLabel()).thenReturn("LeftwardLabel");
|
when(relationshipType.getLeftwardType()).thenReturn("LeftwardType");
|
||||||
when(relationshipType.getRightwardLabel()).thenReturn("RightwardLabel");
|
when(relationshipType.getRightwardType()).thenReturn("RightwardType");
|
||||||
|
|
||||||
// Assert that the useForPlace for our mocked relationshipType is false
|
// Assert that the useForPlace for our mocked relationshipType is false
|
||||||
assertEquals("TestGetFields 0", false,
|
assertEquals("TestGetFields 0", false,
|
||||||
|
@@ -38,8 +38,8 @@ public class RelationshipConverter implements DSpaceConverter<Relationship, Rela
|
|||||||
relationshipRest.setRightId(obj.getRightItem().getID());
|
relationshipRest.setRightId(obj.getRightItem().getID());
|
||||||
relationshipRest.setLeftPlace(obj.getLeftPlace());
|
relationshipRest.setLeftPlace(obj.getLeftPlace());
|
||||||
relationshipRest.setRightPlace(obj.getRightPlace());
|
relationshipRest.setRightPlace(obj.getRightPlace());
|
||||||
relationshipRest.setLeftwardLabel(obj.getLeftwardLabel());
|
relationshipRest.setLeftwardValue(obj.getLeftwardValue());
|
||||||
relationshipRest.setRightwardLabel(obj.getRightwardLabel());
|
relationshipRest.setRightwardValue(obj.getRightwardValue());
|
||||||
return relationshipRest;
|
return relationshipRest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,8 +32,8 @@ public class RelationshipTypeConverter implements DSpaceConverter<RelationshipTy
|
|||||||
RelationshipTypeRest relationshipTypeRest = new RelationshipTypeRest();
|
RelationshipTypeRest relationshipTypeRest = new RelationshipTypeRest();
|
||||||
|
|
||||||
relationshipTypeRest.setId(obj.getID());
|
relationshipTypeRest.setId(obj.getID());
|
||||||
relationshipTypeRest.setLeftwardLabel(obj.getLeftwardLabel());
|
relationshipTypeRest.setLeftwardType(obj.getLeftwardType());
|
||||||
relationshipTypeRest.setRightwardLabel(obj.getRightwardLabel());
|
relationshipTypeRest.setRightwardType(obj.getRightwardType());
|
||||||
relationshipTypeRest.setLeftMinCardinality(obj.getLeftMinCardinality());
|
relationshipTypeRest.setLeftMinCardinality(obj.getLeftMinCardinality());
|
||||||
relationshipTypeRest.setLeftMaxCardinality(obj.getLeftMaxCardinality());
|
relationshipTypeRest.setLeftMaxCardinality(obj.getLeftMaxCardinality());
|
||||||
relationshipTypeRest.setRightMinCardinality(obj.getRightMinCardinality());
|
relationshipTypeRest.setRightMinCardinality(obj.getRightMinCardinality());
|
||||||
|
@@ -30,8 +30,8 @@ public class RelationshipRest extends BaseObjectRest<Integer> {
|
|||||||
private RelationshipTypeRest relationshipType;
|
private RelationshipTypeRest relationshipType;
|
||||||
private int leftPlace;
|
private int leftPlace;
|
||||||
private int rightPlace;
|
private int rightPlace;
|
||||||
private String leftwardLabel;
|
private String leftwardValue;
|
||||||
private String rightwardLabel;
|
private String rightwardValue;
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return NAME;
|
return NAME;
|
||||||
@@ -95,19 +95,19 @@ public class RelationshipRest extends BaseObjectRest<Integer> {
|
|||||||
this.relationshipTypeId = relationshipTypeId;
|
this.relationshipTypeId = relationshipTypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRightwardLabel() {
|
public String getRightwardValue() {
|
||||||
return rightwardLabel;
|
return rightwardValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightwardLabel(String rightwardLabel) {
|
public void setRightwardValue(String rightwardValue) {
|
||||||
this.rightwardLabel = rightwardLabel;
|
this.rightwardValue = rightwardValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLeftwardLabel() {
|
public String getLeftwardValue() {
|
||||||
return leftwardLabel;
|
return leftwardValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeftwardLabel(String leftwardLabel) {
|
public void setLeftwardValue(String leftwardValue) {
|
||||||
this.leftwardLabel = leftwardLabel;
|
this.leftwardValue = leftwardValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,8 +20,8 @@ public class RelationshipTypeRest extends BaseObjectRest<Integer> {
|
|||||||
public static final String NAME = "relationshiptype";
|
public static final String NAME = "relationshiptype";
|
||||||
public static final String CATEGORY = "core";
|
public static final String CATEGORY = "core";
|
||||||
|
|
||||||
private String leftwardLabel;
|
private String leftwardType;
|
||||||
private String rightwardLabel;
|
private String rightwardType;
|
||||||
private Integer leftMinCardinality;
|
private Integer leftMinCardinality;
|
||||||
private Integer leftMaxCardinality;
|
private Integer leftMaxCardinality;
|
||||||
private Integer rightMinCardinality;
|
private Integer rightMinCardinality;
|
||||||
@@ -41,20 +41,20 @@ public class RelationshipTypeRest extends BaseObjectRest<Integer> {
|
|||||||
return RestResourceController.class;
|
return RestResourceController.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLeftwardLabel() {
|
public String getLeftwardType() {
|
||||||
return leftwardLabel;
|
return leftwardType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeftwardLabel(String leftwardLabel) {
|
public void setLeftwardType(String leftwardType) {
|
||||||
this.leftwardLabel = leftwardLabel;
|
this.leftwardType = leftwardType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRightwardLabel() {
|
public String getRightwardType() {
|
||||||
return rightwardLabel;
|
return rightwardType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightwardLabel(String rightwardLabel) {
|
public void setRightwardType(String rightwardType) {
|
||||||
this.rightwardLabel = rightwardLabel;
|
this.rightwardType = rightwardType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getLeftMinCardinality() {
|
public Integer getLeftMinCardinality() {
|
||||||
|
@@ -112,14 +112,14 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
|
|||||||
RelationshipType relationshipType = relationshipTypeService
|
RelationshipType relationshipType = relationshipTypeService
|
||||||
.find(context, Integer.parseInt(req.getParameter("relationshipType")));
|
.find(context, Integer.parseInt(req.getParameter("relationshipType")));
|
||||||
|
|
||||||
String leftwardLabel = req.getParameter("leftwardLabel");
|
String leftwardValue = req.getParameter("leftwardValue");
|
||||||
String rightwardLabel = req.getParameter("rightwardLabel");
|
String rightwardValue = req.getParameter("rightwardValue");
|
||||||
|
|
||||||
EPerson ePerson = context.getCurrentUser();
|
EPerson ePerson = context.getCurrentUser();
|
||||||
if (authorizeService.authorizeActionBoolean(context, leftItem, Constants.WRITE) ||
|
if (authorizeService.authorizeActionBoolean(context, leftItem, Constants.WRITE) ||
|
||||||
authorizeService.authorizeActionBoolean(context, rightItem, Constants.WRITE)) {
|
authorizeService.authorizeActionBoolean(context, rightItem, Constants.WRITE)) {
|
||||||
Relationship relationship = relationshipService.create(context, leftItem, rightItem,
|
Relationship relationship = relationshipService.create(context, leftItem, rightItem,
|
||||||
relationshipType, 0, 0, leftwardLabel, rightwardLabel);
|
relationshipType, 0, 0, leftwardValue, rightwardValue);
|
||||||
// The above if check deals with the case that a Relationship can be created if the user has write
|
// The above if check deals with the case that a Relationship can be created if the user has write
|
||||||
// rights on one of the two items. The following updateItem calls can however call the
|
// rights on one of the two items. The following updateItem calls can however call the
|
||||||
// ItemService.update() functions which would fail if the user doesn't have permission on both items.
|
// ItemService.update() functions which would fail if the user doesn't have permission on both items.
|
||||||
@@ -243,8 +243,8 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
|
|||||||
throw new UnprocessableEntityException("Error parsing request body: " + e.toString());
|
throw new UnprocessableEntityException("Error parsing request body: " + e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
relationship.setLeftwardLabel(relationshipRest.getLeftwardLabel());
|
relationship.setLeftwardValue(relationshipRest.getLeftwardValue());
|
||||||
relationship.setRightwardLabel(relationshipRest.getRightwardLabel());
|
relationship.setRightwardValue(relationshipRest.getRightwardValue());
|
||||||
|
|
||||||
if (jsonNode.hasNonNull("rightPlace")) {
|
if (jsonNode.hasNonNull("rightPlace")) {
|
||||||
relationship.setRightPlace(relationshipRest.getRightPlace());
|
relationship.setRightPlace(relationshipRest.getRightPlace());
|
||||||
@@ -320,7 +320,7 @@ public class RelationshipRestRepository extends DSpaceRestRepository<Relationshi
|
|||||||
Context context = obtainContext();
|
Context context = obtainContext();
|
||||||
|
|
||||||
List<RelationshipType> relationshipTypeList =
|
List<RelationshipType> relationshipTypeList =
|
||||||
relationshipTypeService.findByLeftwardOrRightwardLabel(context, label);
|
relationshipTypeService.findByLeftwardOrRightwardType(context, label);
|
||||||
List<Relationship> relationships = new LinkedList<>();
|
List<Relationship> relationships = new LinkedList<>();
|
||||||
if (dsoId != null) {
|
if (dsoId != null) {
|
||||||
|
|
||||||
|
@@ -357,7 +357,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createRelationshipWithLeftwardLabel() throws Exception {
|
public void createRelationshipWithLeftWardValue() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
||||||
@@ -367,13 +367,13 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String token = getAuthToken(user1.getEmail(), password);
|
String token = getAuthToken(user1.getEmail(), password);
|
||||||
String leftwardLabel = "Name variant test left";
|
String leftwardValue = "Name variant test left";
|
||||||
|
|
||||||
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
||||||
.param("relationshipType",
|
.param("relationshipType",
|
||||||
isAuthorOfPublicationRelationshipType.getID()
|
isAuthorOfPublicationRelationshipType.getID()
|
||||||
.toString())
|
.toString())
|
||||||
.param("leftwardLabel", leftwardLabel)
|
.param("leftwardValue", leftwardValue)
|
||||||
.contentType(MediaType.parseMediaType
|
.contentType(MediaType.parseMediaType
|
||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
@@ -394,12 +394,12 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.id", is(relationshipId)))
|
.andExpect(jsonPath("$.id", is(relationshipId)))
|
||||||
.andExpect(jsonPath("$.leftwardLabel", containsString(leftwardLabel)))
|
.andExpect(jsonPath("$.leftwardValue", containsString(leftwardValue)))
|
||||||
.andExpect(jsonPath("$.rightwardLabel", is(nullValue())));
|
.andExpect(jsonPath("$.rightwardValue", is(nullValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createRelationshipWithRightwardLabel() throws Exception {
|
public void createRelationshipWithRightwardValue() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
||||||
@@ -409,13 +409,13 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String token = getAuthToken(user1.getEmail(), password);
|
String token = getAuthToken(user1.getEmail(), password);
|
||||||
String rightwardLabel = "Name variant test right";
|
String rightwardValue = "Name variant test right";
|
||||||
|
|
||||||
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
||||||
.param("relationshipType",
|
.param("relationshipType",
|
||||||
isAuthorOfPublicationRelationshipType.getID()
|
isAuthorOfPublicationRelationshipType.getID()
|
||||||
.toString())
|
.toString())
|
||||||
.param("rightwardLabel", rightwardLabel)
|
.param("rightwardValue", rightwardValue)
|
||||||
.contentType(MediaType.parseMediaType
|
.contentType(MediaType.parseMediaType
|
||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
@@ -436,12 +436,12 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.id", is(relationshipId)))
|
.andExpect(jsonPath("$.id", is(relationshipId)))
|
||||||
.andExpect(jsonPath("$.leftwardLabel", is(nullValue())))
|
.andExpect(jsonPath("$.leftwardValue", is(nullValue())))
|
||||||
.andExpect(jsonPath("$.rightwardLabel", containsString(rightwardLabel)));
|
.andExpect(jsonPath("$.rightwardValue", containsString(rightwardValue)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createRelationshipWithRightwardLabelAndLeftwardLabel() throws Exception {
|
public void createRelationshipWithRightwardValueAndLeftWardValue() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
||||||
@@ -451,15 +451,15 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String token = getAuthToken(user1.getEmail(), password);
|
String token = getAuthToken(user1.getEmail(), password);
|
||||||
String leftwardLabel = "Name variant test left";
|
String leftwardValue = "Name variant test left";
|
||||||
String rightwardLabel = "Name variant test right";
|
String rightwardValue = "Name variant test right";
|
||||||
|
|
||||||
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
||||||
.param("relationshipType",
|
.param("relationshipType",
|
||||||
isAuthorOfPublicationRelationshipType.getID()
|
isAuthorOfPublicationRelationshipType.getID()
|
||||||
.toString())
|
.toString())
|
||||||
.param("leftwardLabel", leftwardLabel)
|
.param("leftwardValue", leftwardValue)
|
||||||
.param("rightwardLabel", rightwardLabel)
|
.param("rightwardValue", rightwardValue)
|
||||||
.contentType(MediaType.parseMediaType
|
.contentType(MediaType.parseMediaType
|
||||||
(org.springframework.data.rest.webmvc.RestMediaTypes
|
(org.springframework.data.rest.webmvc.RestMediaTypes
|
||||||
.TEXT_URI_LIST_VALUE))
|
.TEXT_URI_LIST_VALUE))
|
||||||
@@ -480,12 +480,12 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.id", is(relationshipId)))
|
.andExpect(jsonPath("$.id", is(relationshipId)))
|
||||||
.andExpect(jsonPath("$.leftwardLabel", containsString(leftwardLabel)))
|
.andExpect(jsonPath("$.leftwardValue", containsString(leftwardValue)))
|
||||||
.andExpect(jsonPath("$.rightwardLabel", containsString(rightwardLabel)));
|
.andExpect(jsonPath("$.rightwardValue", containsString(rightwardValue)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createRelationshipAndAddLeftwardLabelAfterwards() throws Exception {
|
public void createRelationshipAndAddLeftWardValueAfterwards() throws Exception {
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
authorizeService.addPolicy(context, publication1, Constants.WRITE, user1);
|
||||||
@@ -495,7 +495,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String token = getAuthToken(user1.getEmail(), password);
|
String token = getAuthToken(user1.getEmail(), password);
|
||||||
String leftwardLabel = "Name variant test label";
|
String leftwardValue = "Name variant test label";
|
||||||
|
|
||||||
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
||||||
.param("relationshipType",
|
.param("relationshipType",
|
||||||
@@ -522,24 +522,24 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.id", is(relationshipId)))
|
.andExpect(jsonPath("$.id", is(relationshipId)))
|
||||||
.andExpect(jsonPath("$.leftwardLabel", is(nullValue())))
|
.andExpect(jsonPath("$.leftwardValue", is(nullValue())))
|
||||||
.andExpect(jsonPath("$.rightwardLabel", is(nullValue())));
|
.andExpect(jsonPath("$.rightwardValue", is(nullValue())));
|
||||||
|
|
||||||
JsonObject contentObj = new JsonObject();
|
JsonObject contentObj = new JsonObject();
|
||||||
contentObj.addProperty("leftwardLabel", leftwardLabel);
|
contentObj.addProperty("leftwardValue", leftwardValue);
|
||||||
|
|
||||||
// Add leftwardlabel
|
// Add leftwardValue
|
||||||
getClient(token).perform(put("/api/core/relationships/" + relationshipId)
|
getClient(token).perform(put("/api/core/relationships/" + relationshipId)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.content(contentObj.toString()))
|
.content(contentObj.toString()))
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
// Verify leftwardlabel is present and rightwardlabel not
|
// Verify leftwardValue is present and rightwardValue not
|
||||||
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.id", is(relationshipId)))
|
.andExpect(jsonPath("$.id", is(relationshipId)))
|
||||||
.andExpect(jsonPath("$.leftwardLabel", containsString(leftwardLabel)))
|
.andExpect(jsonPath("$.leftwardValue", containsString(leftwardValue)))
|
||||||
.andExpect(jsonPath("$.rightwardLabel", is(nullValue())));
|
.andExpect(jsonPath("$.rightwardValue", is(nullValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -553,8 +553,8 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
String token = getAuthToken(user1.getEmail(), password);
|
String token = getAuthToken(user1.getEmail(), password);
|
||||||
String leftwardLabel = "Name variant test left";
|
String leftwardValue = "Name variant test left";
|
||||||
String rightwardLabel = "Name variant test right";
|
String rightwardValue = "Name variant test right";
|
||||||
|
|
||||||
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
MvcResult mvcResult = getClient(token).perform(post("/api/core/relationships")
|
||||||
.param("relationshipType",
|
.param("relationshipType",
|
||||||
@@ -581,38 +581,38 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.id", is(relationshipId)))
|
.andExpect(jsonPath("$.id", is(relationshipId)))
|
||||||
.andExpect(jsonPath("$.leftwardLabel", is(nullValue())))
|
.andExpect(jsonPath("$.leftwardValue", is(nullValue())))
|
||||||
.andExpect(jsonPath("$.rightwardLabel", is(nullValue())));
|
.andExpect(jsonPath("$.rightwardValue", is(nullValue())));
|
||||||
|
|
||||||
JsonObject contentObj = new JsonObject();
|
JsonObject contentObj = new JsonObject();
|
||||||
contentObj.addProperty("leftwardLabel", leftwardLabel);
|
contentObj.addProperty("leftwardValue", leftwardValue);
|
||||||
contentObj.addProperty("rightwardLabel", rightwardLabel);
|
contentObj.addProperty("rightwardValue", rightwardValue);
|
||||||
|
|
||||||
// Add leftwardlabel and rightwardlabel
|
// Add leftwardValue and rightwardValue
|
||||||
getClient(token).perform(put("/api/core/relationships/" + relationshipId)
|
getClient(token).perform(put("/api/core/relationships/" + relationshipId)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.content(contentObj.toString()))
|
.content(contentObj.toString()))
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
// Verify leftwardlabel and rightwardlabel are present
|
// Verify leftwardValue and rightwardValue are present
|
||||||
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.id", is(relationshipId)))
|
.andExpect(jsonPath("$.id", is(relationshipId)))
|
||||||
.andExpect(jsonPath("$.leftwardLabel", containsString(leftwardLabel)))
|
.andExpect(jsonPath("$.leftwardValue", containsString(leftwardValue)))
|
||||||
.andExpect(jsonPath("$.rightwardLabel", containsString(rightwardLabel)));
|
.andExpect(jsonPath("$.rightwardValue", containsString(rightwardValue)));
|
||||||
|
|
||||||
// Remove leftwardlabel and rightwardlabel
|
// Remove leftwardValue and rightwardValue
|
||||||
getClient(token).perform(put("/api/core/relationships/" + relationshipId)
|
getClient(token).perform(put("/api/core/relationships/" + relationshipId)
|
||||||
.contentType("application/json")
|
.contentType("application/json")
|
||||||
.content("{}"))
|
.content("{}"))
|
||||||
.andExpect(status().isOk());
|
.andExpect(status().isOk());
|
||||||
|
|
||||||
// Verify leftwardlabel and rightwardlabel are both gone
|
// Verify leftwardValue and rightwardValue are both gone
|
||||||
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
getClient().perform(get("/api/core/relationships/" + relationshipId))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.id", is(relationshipId)))
|
.andExpect(jsonPath("$.id", is(relationshipId)))
|
||||||
.andExpect(jsonPath("$.leftwardLabel", is(nullValue())))
|
.andExpect(jsonPath("$.leftwardValue", is(nullValue())))
|
||||||
.andExpect(jsonPath("$.rightwardLabel", is(nullValue())));
|
.andExpect(jsonPath("$.rightwardValue", is(nullValue())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2250,12 +2250,12 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify when a rightward label is present which has been configured to
|
* Verify when a rightward value is present which has been configured to
|
||||||
* be used for virtual metadata, that the virtual metadata is populated
|
* be used for virtual metadata, that the virtual metadata is populated
|
||||||
* with the custom label
|
* with the custom value
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void rightwardLabelRelationshipTest() throws Exception {
|
public void rightwardValueRelationshipTest() throws Exception {
|
||||||
|
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
@@ -2266,7 +2266,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
|
|
||||||
Relationship relationship3 = RelationshipBuilder
|
Relationship relationship3 = RelationshipBuilder
|
||||||
.createRelationshipBuilder(context, publication1, author1, isAuthorOfPublicationRelationshipType)
|
.createRelationshipBuilder(context, publication1, author1, isAuthorOfPublicationRelationshipType)
|
||||||
.withRightwardLabel("RightwardLabelTest").build();
|
.withRightwardValue("RightwardValueTest").build();
|
||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
@@ -2283,16 +2283,16 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
getClient().perform(get("/api/core/items/" + publication1.getID()))
|
getClient().perform(get("/api/core/items/" + publication1.getID()))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(jsonPath("$.metadata", allOf(
|
.andExpect(jsonPath("$.metadata", allOf(
|
||||||
matchMetadata("dc.contributor.author", "RightwardLabelTest"),
|
matchMetadata("dc.contributor.author", "RightwardValueTest"),
|
||||||
matchMetadata("dc.title", "Publication1"))));
|
matchMetadata("dc.title", "Publication1"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify when no rightward label is present, that the virtual metadata is populated
|
* Verify when no rightward value is present, that the virtual metadata is populated
|
||||||
* with the metadata from the related item
|
* with the metadata from the related item
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void nonRightwardLabelRelationshipTest() throws Exception {
|
public void nonRightwardValueRelationshipTest() throws Exception {
|
||||||
|
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
@@ -2326,13 +2326,13 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify when a rightward label is present which has been configured to
|
* Verify when a rightward value is present which has been configured to
|
||||||
* be used for virtual metadata, that the virtual metadata is populated
|
* be used for virtual metadata, that the virtual metadata is populated
|
||||||
* with the custom label
|
* with the custom value
|
||||||
* Verify that only the relationship containing the rightward label will be updated
|
* Verify that only the relationship containing the rightward value will be updated
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void mixedRightwardLabelAndRegularRelationshipTest() throws Exception {
|
public void mixedRightwardValueAndRegularRelationshipTest() throws Exception {
|
||||||
|
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
@@ -2356,7 +2356,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
|
|
||||||
Relationship relationship2 = RelationshipBuilder
|
Relationship relationship2 = RelationshipBuilder
|
||||||
.createRelationshipBuilder(context, publication1, author1, isAuthorOfPublicationRelationshipType)
|
.createRelationshipBuilder(context, publication1, author1, isAuthorOfPublicationRelationshipType)
|
||||||
.withRightwardLabel("TestingRightwardLabel").build();
|
.withRightwardValue("TestingRightwardValue").build();
|
||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
@@ -2376,18 +2376,18 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
.andExpect(jsonPath("$.metadata", allOf(
|
.andExpect(jsonPath("$.metadata", allOf(
|
||||||
matchMetadata("dc.contributor.author", "Maybe, Maybe"),
|
matchMetadata("dc.contributor.author", "Maybe, Maybe"),
|
||||||
matchMetadata("dc.contributor.author", "Testy, TEst"),
|
matchMetadata("dc.contributor.author", "Testy, TEst"),
|
||||||
matchMetadata("dc.contributor.author", "TestingRightwardLabel"),
|
matchMetadata("dc.contributor.author", "TestingRightwardValue"),
|
||||||
not(matchMetadata("dc.contributor.author", "testingLastName, testingFirstName")),
|
not(matchMetadata("dc.contributor.author", "testingLastName, testingFirstName")),
|
||||||
matchMetadata("dc.title", "Publication1"))));
|
matchMetadata("dc.title", "Publication1"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify when a leftward label is present which has NOT been configured to
|
* Verify when a leftward value is present which has NOT been configured to
|
||||||
* be used for virtual metadata, that the virtual metadata is NOT populated
|
* be used for virtual metadata, that the virtual metadata is NOT populated
|
||||||
* with the custom label
|
* with the custom value
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void leftwardLabelRelationshipTest() throws Exception {
|
public void leftwardValueRelationshipTest() throws Exception {
|
||||||
|
|
||||||
context.turnOffAuthorisationSystem();
|
context.turnOffAuthorisationSystem();
|
||||||
|
|
||||||
@@ -2398,7 +2398,7 @@ public class RelationshipRestRepositoryIT extends AbstractEntityIntegrationTest
|
|||||||
|
|
||||||
Relationship relationship3 = RelationshipBuilder
|
Relationship relationship3 = RelationshipBuilder
|
||||||
.createRelationshipBuilder(context, publication1, author3, isAuthorOfPublicationRelationshipType)
|
.createRelationshipBuilder(context, publication1, author3, isAuthorOfPublicationRelationshipType)
|
||||||
.withLeftwardLabel("leftwardLabel").withLeftPlace(1).build();
|
.withLeftwardValue("leftwardValue").withLeftPlace(1).build();
|
||||||
|
|
||||||
context.restoreAuthSystemState();
|
context.restoreAuthSystemState();
|
||||||
|
|
||||||
|
@@ -49,87 +49,87 @@ public class RelationshipTypeRestRepositoryIT extends AbstractEntityIntegrationT
|
|||||||
public void findPublicationPersonRelationshipType() throws SQLException {
|
public void findPublicationPersonRelationshipType() throws SQLException {
|
||||||
String leftTypeString = "Publication";
|
String leftTypeString = "Publication";
|
||||||
String rightTypeString = "Person";
|
String rightTypeString = "Person";
|
||||||
String leftwardLabel = "isAuthorOfPublication";
|
String leftwardType = "isAuthorOfPublication";
|
||||||
String rightwardLabel = "isPublicationOfAuthor";
|
String rightwardType = "isPublicationOfAuthor";
|
||||||
checkRelationshipType(leftTypeString, rightTypeString, leftwardLabel, rightwardLabel);
|
checkRelationshipType(leftTypeString, rightTypeString, leftwardType, rightwardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findPublicationProjectRelationshipType() throws SQLException {
|
public void findPublicationProjectRelationshipType() throws SQLException {
|
||||||
String leftTypeString = "Publication";
|
String leftTypeString = "Publication";
|
||||||
String rightTypeString = "Project";
|
String rightTypeString = "Project";
|
||||||
String leftwardLabel = "isProjectOfPublication";
|
String leftwardType = "isProjectOfPublication";
|
||||||
String rightwardLabel = "isPublicationOfProject";
|
String rightwardType = "isPublicationOfProject";
|
||||||
checkRelationshipType(leftTypeString, rightTypeString, leftwardLabel, rightwardLabel);
|
checkRelationshipType(leftTypeString, rightTypeString, leftwardType, rightwardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findPublicationOrgUnitRelationshipType() throws SQLException {
|
public void findPublicationOrgUnitRelationshipType() throws SQLException {
|
||||||
String leftTypeString = "Publication";
|
String leftTypeString = "Publication";
|
||||||
String rightTypeString = "OrgUnit";
|
String rightTypeString = "OrgUnit";
|
||||||
String leftwardLabel = "isOrgUnitOfPublication";
|
String leftwardType = "isOrgUnitOfPublication";
|
||||||
String rightwardLabel = "isPublicationOfOrgUnit";
|
String rightwardType = "isPublicationOfOrgUnit";
|
||||||
checkRelationshipType(leftTypeString, rightTypeString, leftwardLabel, rightwardLabel);
|
checkRelationshipType(leftTypeString, rightTypeString, leftwardType, rightwardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findPersonProjectRelationshipType() throws SQLException {
|
public void findPersonProjectRelationshipType() throws SQLException {
|
||||||
String leftTypeString = "Person";
|
String leftTypeString = "Person";
|
||||||
String rightTypeString = "Project";
|
String rightTypeString = "Project";
|
||||||
String leftwardLabel = "isProjectOfPerson";
|
String leftwardType = "isProjectOfPerson";
|
||||||
String rightwardLabel = "isPersonOfProject";
|
String rightwardType = "isPersonOfProject";
|
||||||
checkRelationshipType(leftTypeString, rightTypeString, leftwardLabel, rightwardLabel);
|
checkRelationshipType(leftTypeString, rightTypeString, leftwardType, rightwardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findPersonOrgUnitRelationshipType() throws SQLException {
|
public void findPersonOrgUnitRelationshipType() throws SQLException {
|
||||||
String leftTypeString = "Person";
|
String leftTypeString = "Person";
|
||||||
String rightTypeString = "OrgUnit";
|
String rightTypeString = "OrgUnit";
|
||||||
String leftwardLabel = "isOrgUnitOfPerson";
|
String leftwardType = "isOrgUnitOfPerson";
|
||||||
String rightwardLabel = "isPersonOfOrgUnit";
|
String rightwardType = "isPersonOfOrgUnit";
|
||||||
checkRelationshipType(leftTypeString, rightTypeString, leftwardLabel, rightwardLabel);
|
checkRelationshipType(leftTypeString, rightTypeString, leftwardType, rightwardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findProjectOrgUnitRelationshipType() throws SQLException {
|
public void findProjectOrgUnitRelationshipType() throws SQLException {
|
||||||
String leftTypeString = "Project";
|
String leftTypeString = "Project";
|
||||||
String rightTypeString = "OrgUnit";
|
String rightTypeString = "OrgUnit";
|
||||||
String leftwardLabel = "isOrgUnitOfProject";
|
String leftwardType = "isOrgUnitOfProject";
|
||||||
String rightwardLabel = "isProjectOfOrgUnit";
|
String rightwardType = "isProjectOfOrgUnit";
|
||||||
checkRelationshipType(leftTypeString, rightTypeString, leftwardLabel, rightwardLabel);
|
checkRelationshipType(leftTypeString, rightTypeString, leftwardType, rightwardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findJournalJournalVolumeRelationshipType() throws SQLException {
|
public void findJournalJournalVolumeRelationshipType() throws SQLException {
|
||||||
String leftTypeString = "Journal";
|
String leftTypeString = "Journal";
|
||||||
String rightTypeString = "JournalVolume";
|
String rightTypeString = "JournalVolume";
|
||||||
String leftwardLabel = "isVolumeOfJournal";
|
String leftwardType = "isVolumeOfJournal";
|
||||||
String rightwardLabel = "isJournalOfVolume";
|
String rightwardType = "isJournalOfVolume";
|
||||||
checkRelationshipType(leftTypeString, rightTypeString, leftwardLabel, rightwardLabel);
|
checkRelationshipType(leftTypeString, rightTypeString, leftwardType, rightwardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void findJournalVolumeJournalIssueRelationshipType() throws SQLException {
|
public void findJournalVolumeJournalIssueRelationshipType() throws SQLException {
|
||||||
String leftTypeString = "JournalVolume";
|
String leftTypeString = "JournalVolume";
|
||||||
String rightTypeString = "JournalIssue";
|
String rightTypeString = "JournalIssue";
|
||||||
String leftwardLabel = "isIssueOfJournalVolume";
|
String leftwardType = "isIssueOfJournalVolume";
|
||||||
String rightwardLabel = "isJournalVolumeOfIssue";
|
String rightwardType = "isJournalVolumeOfIssue";
|
||||||
checkRelationshipType(leftTypeString, rightTypeString, leftwardLabel, rightwardLabel);
|
checkRelationshipType(leftTypeString, rightTypeString, leftwardType, rightwardType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkRelationshipType(String leftType, String rightType, String leftwardLabel, String rightwardLabel)
|
private void checkRelationshipType(String leftType, String rightType, String leftwardType, String rightwardType)
|
||||||
throws SQLException {
|
throws SQLException {
|
||||||
RelationshipType relationshipType = relationshipTypeService
|
RelationshipType relationshipType = relationshipTypeService
|
||||||
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, leftType),
|
.findbyTypesAndLabels(context, entityTypeService.findByEntityType(context, leftType),
|
||||||
entityTypeService.findByEntityType(context, rightType),
|
entityTypeService.findByEntityType(context, rightType),
|
||||||
leftwardLabel, rightwardLabel);
|
leftwardType, rightwardType);
|
||||||
assertNotNull(relationshipType);
|
assertNotNull(relationshipType);
|
||||||
assertEquals(entityTypeService.findByEntityType(context, leftType),
|
assertEquals(entityTypeService.findByEntityType(context, leftType),
|
||||||
relationshipType.getLeftType());
|
relationshipType.getLeftType());
|
||||||
assertEquals(entityTypeService.findByEntityType(context, rightType),
|
assertEquals(entityTypeService.findByEntityType(context, rightType),
|
||||||
relationshipType.getRightType());
|
relationshipType.getRightType());
|
||||||
assertEquals(leftwardLabel, relationshipType.getLeftwardLabel());
|
assertEquals(leftwardType, relationshipType.getLeftwardType());
|
||||||
assertEquals(rightwardLabel, relationshipType.getRightwardLabel());
|
assertEquals(rightwardType, relationshipType.getRightwardType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -167,8 +167,8 @@ public class RelationshipTypeRestRepositoryIT extends AbstractEntityIntegrationT
|
|||||||
|
|
||||||
RelationshipType foundRelationshipType = null;
|
RelationshipType foundRelationshipType = null;
|
||||||
for (RelationshipType relationshipType : relationshipTypes) {
|
for (RelationshipType relationshipType : relationshipTypes) {
|
||||||
if (StringUtils.equals(relationshipType.getLeftwardLabel(), "isAuthorOfPublication") && StringUtils
|
if (StringUtils.equals(relationshipType.getLeftwardType(), "isAuthorOfPublication") && StringUtils
|
||||||
.equals(relationshipType.getRightwardLabel(), "isPublicationOfAuthor")) {
|
.equals(relationshipType.getRightwardType(), "isPublicationOfAuthor")) {
|
||||||
foundRelationshipType = relationshipType;
|
foundRelationshipType = relationshipType;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -212,8 +212,8 @@ public class RelationshipTypeRestRepositoryIT extends AbstractEntityIntegrationT
|
|||||||
|
|
||||||
RelationshipType foundRelationshipType = null;
|
RelationshipType foundRelationshipType = null;
|
||||||
for (RelationshipType relationshipType : relationshipTypes) {
|
for (RelationshipType relationshipType : relationshipTypes) {
|
||||||
if (StringUtils.equals(relationshipType.getLeftwardLabel(), "isIssueOfJournalVolume") && StringUtils
|
if (StringUtils.equals(relationshipType.getLeftwardType(), "isIssueOfJournalVolume") && StringUtils
|
||||||
.equals(relationshipType.getRightwardLabel(), "isJournalVolumeOfIssue")) {
|
.equals(relationshipType.getRightwardType(), "isJournalVolumeOfIssue")) {
|
||||||
foundRelationshipType = relationshipType;
|
foundRelationshipType = relationshipType;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -85,13 +85,13 @@ public class RelationshipBuilder extends AbstractBuilder<Relationship, Relations
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelationshipBuilder withLeftwardLabel(String leftWardLabel) throws SQLException {
|
public RelationshipBuilder withLeftwardValue(String leftwardValue) throws SQLException {
|
||||||
relationship.setLeftwardLabel(leftWardLabel);
|
relationship.setLeftwardValue(leftwardValue);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelationshipBuilder withRightwardLabel(String rightWardLabel) throws SQLException {
|
public RelationshipBuilder withRightwardValue(String rightwardValue) throws SQLException {
|
||||||
relationship.setRightwardLabel(rightWardLabel);
|
relationship.setRightwardValue(rightwardValue);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -75,29 +75,29 @@ public class RelationshipTypeBuilder extends AbstractBuilder<RelationshipType, R
|
|||||||
|
|
||||||
public static RelationshipTypeBuilder createRelationshipTypeBuilder(Context context, EntityType leftType,
|
public static RelationshipTypeBuilder createRelationshipTypeBuilder(Context context, EntityType leftType,
|
||||||
EntityType rightType,
|
EntityType rightType,
|
||||||
String leftwardLabel,
|
String leftwardType,
|
||||||
String rightwardLabel,
|
String rightwardType,
|
||||||
Integer leftCardinalityMin,
|
Integer leftCardinalityMin,
|
||||||
Integer leftCardinalityMax,
|
Integer leftCardinalityMax,
|
||||||
Integer rightCardinalityMin,
|
Integer rightCardinalityMin,
|
||||||
Integer rightCardinalityMax) {
|
Integer rightCardinalityMax) {
|
||||||
RelationshipTypeBuilder relationshipBuilder = new RelationshipTypeBuilder(context);
|
RelationshipTypeBuilder relationshipBuilder = new RelationshipTypeBuilder(context);
|
||||||
return relationshipBuilder.create(context, leftType,
|
return relationshipBuilder.create(context, leftType,
|
||||||
rightType, leftwardLabel,
|
rightType, leftwardType,
|
||||||
rightwardLabel, leftCardinalityMin,
|
rightwardType, leftCardinalityMin,
|
||||||
leftCardinalityMax, rightCardinalityMin,
|
leftCardinalityMax, rightCardinalityMin,
|
||||||
rightCardinalityMax);
|
rightCardinalityMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RelationshipTypeBuilder create(Context context, EntityType leftEntityType, EntityType rightEntityType,
|
private RelationshipTypeBuilder create(Context context, EntityType leftEntityType, EntityType rightEntityType,
|
||||||
String leftwardLabel, String rightwardLabel, Integer leftCardinalityMin,
|
String leftwardType, String rightwardType, Integer leftCardinalityMin,
|
||||||
Integer leftCardinalityMax, Integer rightCardinalityMin,
|
Integer leftCardinalityMax, Integer rightCardinalityMin,
|
||||||
Integer rightCardinalityMax) {
|
Integer rightCardinalityMax) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.relationshipType = relationshipTypeService
|
this.relationshipType = relationshipTypeService
|
||||||
.create(context, leftEntityType, rightEntityType, leftwardLabel, rightwardLabel, leftCardinalityMin,
|
.create(context, leftEntityType, rightEntityType, leftwardType, rightwardType, leftCardinalityMin,
|
||||||
leftCardinalityMax, rightCardinalityMin, rightCardinalityMax);
|
leftCardinalityMax, rightCardinalityMin, rightCardinalityMax);
|
||||||
|
|
||||||
} catch (SQLException | AuthorizeException e) {
|
} catch (SQLException | AuthorizeException e) {
|
||||||
|
@@ -38,8 +38,8 @@ public class RelationshipTypeMatcher {
|
|||||||
String rightEntityTypeLabel) {
|
String rightEntityTypeLabel) {
|
||||||
|
|
||||||
return matchExplicitRelationshipTypeValuesAndExplicitEntityTypeValues(relationshipType.getID(),
|
return matchExplicitRelationshipTypeValuesAndExplicitEntityTypeValues(relationshipType.getID(),
|
||||||
relationshipType.getLeftwardLabel(),
|
relationshipType.getLeftwardType(),
|
||||||
relationshipType.getRightwardLabel(),
|
relationshipType.getRightwardType(),
|
||||||
relationshipType.getLeftMinCardinality(),
|
relationshipType.getLeftMinCardinality(),
|
||||||
relationshipType.getLeftMaxCardinality(),
|
relationshipType.getLeftMaxCardinality(),
|
||||||
relationshipType.getRightMinCardinality(),
|
relationshipType.getRightMinCardinality(),
|
||||||
@@ -49,10 +49,10 @@ public class RelationshipTypeMatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Matcher<? super Object> matchExplicitRelationshipTypeValuesAndExplicitEntityType(int id,
|
private static Matcher<? super Object> matchExplicitRelationshipTypeValuesAndExplicitEntityType(int id,
|
||||||
String leftwardLabel, String rightwardLabel, Integer leftMinCardinality, Integer leftMaxCardinality,
|
String leftwardType, String rightwardType, Integer leftMinCardinality, Integer leftMaxCardinality,
|
||||||
Integer rightMinCardinality, Integer rightMaxCardinality,
|
Integer rightMinCardinality, Integer rightMaxCardinality,
|
||||||
EntityType leftEntityType, EntityType rightEntityType) {
|
EntityType leftEntityType, EntityType rightEntityType) {
|
||||||
return matchExplicitRelationshipTypeValuesAndExplicitEntityTypeValues(id, leftwardLabel, rightwardLabel,
|
return matchExplicitRelationshipTypeValuesAndExplicitEntityTypeValues(id, leftwardType, rightwardType,
|
||||||
leftMinCardinality, leftMaxCardinality,
|
leftMinCardinality, leftMaxCardinality,
|
||||||
rightMinCardinality,
|
rightMinCardinality,
|
||||||
rightMaxCardinality,
|
rightMaxCardinality,
|
||||||
@@ -63,13 +63,13 @@ public class RelationshipTypeMatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Matcher<? super Object> matchExplicitRelationshipTypeValuesAndExplicitEntityTypeValues(int id,
|
private static Matcher<? super Object> matchExplicitRelationshipTypeValuesAndExplicitEntityTypeValues(int id,
|
||||||
String leftwardLabel, String rightwardLabel, Integer leftMinCardinality, Integer leftMaxCardinality,
|
String leftwardType, String rightwardType, Integer leftMinCardinality, Integer leftMaxCardinality,
|
||||||
Integer rightMinCardinality, Integer rightMaxCardinality, int leftEntityTypeId, String leftEntityTypeLabel,
|
Integer rightMinCardinality, Integer rightMaxCardinality, int leftEntityTypeId, String leftEntityTypeLabel,
|
||||||
int rightEntityTypeId, String rightEntityTypeLabel) {
|
int rightEntityTypeId, String rightEntityTypeLabel) {
|
||||||
return allOf(
|
return allOf(
|
||||||
hasJsonPath("$.id", is(id)),
|
hasJsonPath("$.id", is(id)),
|
||||||
hasJsonPath("$.leftwardLabel", is(leftwardLabel)),
|
hasJsonPath("$.leftwardType", is(leftwardType)),
|
||||||
hasJsonPath("$.rightwardLabel", is(rightwardLabel)),
|
hasJsonPath("$.rightwardType", is(rightwardType)),
|
||||||
hasJsonPath("$.leftMinCardinality", is(leftMinCardinality)),
|
hasJsonPath("$.leftMinCardinality", is(leftMinCardinality)),
|
||||||
hasJsonPath("$.leftMaxCardinality", is(leftMaxCardinality)),
|
hasJsonPath("$.leftMaxCardinality", is(leftMaxCardinality)),
|
||||||
hasJsonPath("$.rightMinCardinality", is(rightMinCardinality)),
|
hasJsonPath("$.rightMinCardinality", is(rightMinCardinality)),
|
||||||
|
Reference in New Issue
Block a user