Refactored the usages of MetadataSchema.DC to use the enum instead

This commit is contained in:
Raf Ponsaerts
2018-11-21 09:35:11 +01:00
parent b8d6fa2fba
commit b905f69d63
51 changed files with 229 additions and 185 deletions

View File

@@ -139,10 +139,11 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
@Override
public List<Community> findAll(Context context) throws SQLException {
MetadataField sortField = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, "title", null);
MetadataField sortField = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
"title", null);
if (sortField == null) {
throw new IllegalArgumentException(
"Required metadata field '" + MetadataSchema.DC_SCHEMA + ".title' doesn't exist!");
"Required metadata field '" + MetadataSchemaEnum.DC.getName() + ".title' doesn't exist!");
}
return communityDAO.findAll(context, sortField);
@@ -150,10 +151,11 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
@Override
public List<Community> findAll(Context context, Integer limit, Integer offset) throws SQLException {
MetadataField nameField = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, "title", null);
MetadataField nameField = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
"title", null);
if (nameField == null) {
throw new IllegalArgumentException(
"Required metadata field '" + MetadataSchema.DC_SCHEMA + ".title' doesn't exist!");
"Required metadata field '" + MetadataSchemaEnum.DC.getName() + ".title' doesn't exist!");
}
return communityDAO.findAll(context, nameField, limit, offset);
@@ -162,10 +164,11 @@ public class CommunityServiceImpl extends DSpaceObjectServiceImpl<Community> imp
@Override
public List<Community> findAllTop(Context context) throws SQLException {
// get all communities that are not children
MetadataField sortField = metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, "title", null);
MetadataField sortField = metadataFieldService.findByElement(context, MetadataSchemaEnum.DC.getName(),
"title", null);
if (sortField == null) {
throw new IllegalArgumentException(
"Required metadata field '" + MetadataSchema.DC_SCHEMA + ".title' doesn't exist!");
"Required metadata field '" + MetadataSchemaEnum.DC.getName() + ".title' doesn't exist!");
}
return communityDAO.findAllNoParent(context, sortField);