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