mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-12 20:43:18 +00:00
DS-3782: Restore lines that should not be modified
This commit is contained in:
@@ -680,6 +680,7 @@ public abstract class DSpaceObjectServiceImpl<T extends DSpaceObject> implements
|
|||||||
moved.getAuthority(), moved.getConfidence());
|
moved.getAuthority(), moved.getConfidence());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void replaceMetadata(Context context, T dso, String schema, String element, String qualifier, String lang,
|
public void replaceMetadata(Context context, T dso, String schema, String element, String qualifier, String lang,
|
||||||
String value, String authority, int confidence, int index) throws SQLException {
|
String value, String authority, int confidence, int index) throws SQLException {
|
||||||
|
@@ -59,7 +59,7 @@ public class MetadataFieldServiceImpl implements MetadataFieldService {
|
|||||||
// Ensure the element and qualifier are unique within a given schema.
|
// Ensure the element and qualifier are unique within a given schema.
|
||||||
if (hasElement(context, -1, metadataSchema, element, qualifier)) {
|
if (hasElement(context, -1, metadataSchema, element, qualifier)) {
|
||||||
throw new NonUniqueMetadataException("Please make " + element + "."
|
throw new NonUniqueMetadataException("Please make " + element + "."
|
||||||
+ qualifier + " unique within schema #" + metadataSchema.getID());
|
+ qualifier + " unique within schema #" + metadataSchema.getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a table row and update it with the values
|
// Create a table row and update it with the values
|
||||||
@@ -72,7 +72,7 @@ public class MetadataFieldServiceImpl implements MetadataFieldService {
|
|||||||
metadataFieldDAO.save(context, metadataField);
|
metadataFieldDAO.save(context, metadataField);
|
||||||
|
|
||||||
log.info(LogManager.getHeader(context, "create_metadata_field",
|
log.info(LogManager.getHeader(context, "create_metadata_field",
|
||||||
"metadata_field_id=" + metadataField.getID()));
|
"metadata_field_id=" + metadataField.getID()));
|
||||||
return metadataField;
|
return metadataField;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ public class MetadataFieldServiceImpl implements MetadataFieldService {
|
|||||||
|
|
||||||
// Ensure the element and qualifier are unique within a given schema.
|
// Ensure the element and qualifier are unique within a given schema.
|
||||||
if (hasElement(context, metadataField.getID(), metadataField.getMetadataSchema(), metadataField.getElement(),
|
if (hasElement(context, metadataField.getID(), metadataField.getMetadataSchema(), metadataField.getElement(),
|
||||||
metadataField.getQualifier())) {
|
metadataField.getQualifier())) {
|
||||||
throw new NonUniqueMetadataException(
|
throw new NonUniqueMetadataException(
|
||||||
"Please make " + metadataField.getMetadataSchema().getName() + "." + metadataField.getElement() + "."
|
"Please make " + metadataField.getMetadataSchema().getName() + "." + metadataField.getElement() + "."
|
||||||
+ metadataField.getQualifier());
|
+ metadataField.getQualifier());
|
||||||
@@ -130,9 +130,9 @@ public class MetadataFieldServiceImpl implements MetadataFieldService {
|
|||||||
metadataFieldDAO.save(context, metadataField);
|
metadataFieldDAO.save(context, metadataField);
|
||||||
|
|
||||||
log.info(LogManager.getHeader(context, "update_metadatafieldregistry",
|
log.info(LogManager.getHeader(context, "update_metadatafieldregistry",
|
||||||
"metadata_field_id=" + metadataField.getID() + "element=" + metadataField
|
"metadata_field_id=" + metadataField.getID() + "element=" + metadataField
|
||||||
.getElement()
|
.getElement()
|
||||||
+ "qualifier=" + metadataField.getQualifier()));
|
+ "qualifier=" + metadataField.getQualifier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -160,7 +160,7 @@ public class MetadataFieldServiceImpl implements MetadataFieldService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info(LogManager.getHeader(context, "delete_metadata_field",
|
log.info(LogManager.getHeader(context, "delete_metadata_field",
|
||||||
"metadata_field_id=" + metadataField.getID()));
|
"metadata_field_id=" + metadataField.getID()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -56,7 +56,7 @@ public class CommunityDAOImpl extends AbstractHibernateDSODAO<Community> impleme
|
|||||||
throws SQLException {
|
throws SQLException {
|
||||||
StringBuilder queryBuilder = new StringBuilder();
|
StringBuilder queryBuilder = new StringBuilder();
|
||||||
queryBuilder.append("SELECT ").append(Community.class.getSimpleName()).append(" FROM Community as ")
|
queryBuilder.append("SELECT ").append(Community.class.getSimpleName()).append(" FROM Community as ")
|
||||||
.append(Community.class.getSimpleName()).append(" ");
|
.append(Community.class.getSimpleName()).append(" ");
|
||||||
addMetadataLeftJoin(queryBuilder, Community.class.getSimpleName(), Arrays.asList(sortField));
|
addMetadataLeftJoin(queryBuilder, Community.class.getSimpleName(), Arrays.asList(sortField));
|
||||||
addMetadataSortQuery(queryBuilder, Arrays.asList(sortField), Collections.EMPTY_LIST);
|
addMetadataSortQuery(queryBuilder, Arrays.asList(sortField), Collections.EMPTY_LIST);
|
||||||
|
|
||||||
|
@@ -228,7 +228,7 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator {
|
|||||||
agentCreator.setOTHERTYPE("DSpace Software");
|
agentCreator.setOTHERTYPE("DSpace Software");
|
||||||
Name creatorName = new Name();
|
Name creatorName = new Name();
|
||||||
creatorName.getContent()
|
creatorName.getContent()
|
||||||
.add(new PCData("DSpace " + Util.getSourceVersion()));
|
.add(new PCData("DSpace " + Util.getSourceVersion()));
|
||||||
agentCreator.getContent().add(creatorName);
|
agentCreator.getContent().add(creatorName);
|
||||||
metsHdr.getContent().add(agentCreator);
|
metsHdr.getContent().add(agentCreator);
|
||||||
|
|
||||||
@@ -254,7 +254,7 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator {
|
|||||||
throws SQLException, IOException, AuthorizeException {
|
throws SQLException, IOException, AuthorizeException {
|
||||||
String[] dmdTypes = configurationService.getArrayProperty("aip.disseminate.dmd");
|
String[] dmdTypes = configurationService.getArrayProperty("aip.disseminate.dmd");
|
||||||
if (ArrayUtils.isEmpty(dmdTypes)) {
|
if (ArrayUtils.isEmpty(dmdTypes)) {
|
||||||
return new String[]{"MODS", "DIM"};
|
return new String[] {"MODS", "DIM"};
|
||||||
} else {
|
} else {
|
||||||
return dmdTypes;
|
return dmdTypes;
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,7 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator {
|
|||||||
String[] techTypes = configurationService.getArrayProperty("aip.disseminate.techMD");
|
String[] techTypes = configurationService.getArrayProperty("aip.disseminate.techMD");
|
||||||
if (ArrayUtils.isEmpty(techTypes)) {
|
if (ArrayUtils.isEmpty(techTypes)) {
|
||||||
if (dso.getType() == Constants.BITSTREAM) {
|
if (dso.getType() == Constants.BITSTREAM) {
|
||||||
return new String[]{"PREMIS"};
|
return new String[] {"PREMIS"};
|
||||||
} else {
|
} else {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
@@ -312,7 +312,7 @@ public class DSpaceAIPDisseminator extends AbstractMETSDisseminator {
|
|||||||
throws SQLException, IOException, AuthorizeException {
|
throws SQLException, IOException, AuthorizeException {
|
||||||
String[] sourceTypes = configurationService.getArrayProperty("aip.disseminate.sourceMD");
|
String[] sourceTypes = configurationService.getArrayProperty("aip.disseminate.sourceMD");
|
||||||
if (ArrayUtils.isEmpty(sourceTypes)) {
|
if (ArrayUtils.isEmpty(sourceTypes)) {
|
||||||
return new String[]{"AIP-TECHMD"};
|
return new String[] {"AIP-TECHMD"};
|
||||||
} else {
|
} else {
|
||||||
return sourceTypes;
|
return sourceTypes;
|
||||||
}
|
}
|
||||||
|
@@ -63,7 +63,7 @@ public abstract class AbstractHibernateDSODAO<T extends DSpaceObject> extends Ab
|
|||||||
for (MetadataField metadataField : metadataFields) {
|
for (MetadataField metadataField : metadataFields) {
|
||||||
query.append(" left join ").append(tableIdentifier).append(".metadata ").append(metadataField.toString());
|
query.append(" left join ").append(tableIdentifier).append(".metadata ").append(metadataField.toString());
|
||||||
query.append(" WITH ").append(metadataField.toString()).append(".metadataField.id").append(" = :")
|
query.append(" WITH ").append(metadataField.toString()).append(".metadataField.id").append(" = :")
|
||||||
.append(metadataField.toString());
|
.append(metadataField.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ public abstract class AbstractHibernateDSODAO<T extends DSpaceObject> extends Ab
|
|||||||
if (StringUtils.isNotBlank(operator)) {
|
if (StringUtils.isNotBlank(operator)) {
|
||||||
query.append(" (");
|
query.append(" (");
|
||||||
query.append("lower(STR(" + metadataField.toString()).append(".value)) ").append(operator)
|
query.append("lower(STR(" + metadataField.toString()).append(".value)) ").append(operator)
|
||||||
.append(" lower(:queryParam)");
|
.append(" lower(:queryParam)");
|
||||||
query.append(")");
|
query.append(")");
|
||||||
if (i < metadataFields.size() - 1) {
|
if (i < metadataFields.size() - 1) {
|
||||||
query.append(" OR ");
|
query.append(" OR ");
|
||||||
|
@@ -64,7 +64,7 @@ public class EPersonDAOImpl extends AbstractHibernateDSODAO<EPerson> implements
|
|||||||
public List<EPerson> search(Context context, String query, List<MetadataField> queryFields,
|
public List<EPerson> search(Context context, String query, List<MetadataField> queryFields,
|
||||||
List<MetadataField> sortFields, int offset, int limit) throws SQLException {
|
List<MetadataField> sortFields, int offset, int limit) throws SQLException {
|
||||||
String queryString = "SELECT " + EPerson.class.getSimpleName()
|
String queryString = "SELECT " + EPerson.class.getSimpleName()
|
||||||
.toLowerCase() + " FROM EPerson as " + EPerson.class
|
.toLowerCase() + " FROM EPerson as " + EPerson.class
|
||||||
.getSimpleName().toLowerCase() + " ";
|
.getSimpleName().toLowerCase() + " ";
|
||||||
if (query != null) {
|
if (query != null) {
|
||||||
query = "%" + query.toLowerCase() + "%";
|
query = "%" + query.toLowerCase() + "%";
|
||||||
@@ -92,18 +92,17 @@ public class EPersonDAOImpl extends AbstractHibernateDSODAO<EPerson> implements
|
|||||||
public List<EPerson> findAll(Context context, MetadataField metadataSortField, String sortField, int pageSize,
|
public List<EPerson> findAll(Context context, MetadataField metadataSortField, String sortField, int pageSize,
|
||||||
int offset) throws SQLException {
|
int offset) throws SQLException {
|
||||||
String queryString = "SELECT " + EPerson.class.getSimpleName()
|
String queryString = "SELECT " + EPerson.class.getSimpleName()
|
||||||
.toLowerCase() + " FROM EPerson as " + EPerson.class
|
.toLowerCase() + " FROM EPerson as " + EPerson.class
|
||||||
.getSimpleName().toLowerCase();
|
.getSimpleName().toLowerCase();
|
||||||
|
|
||||||
List<MetadataField> sortFields = Collections.EMPTY_LIST;
|
List<MetadataField> sortFields = Collections.EMPTY_LIST;
|
||||||
|
|
||||||
if (metadataSortField != null) {
|
if (metadataSortField != null) {ItemRestRepositoryIT
|
||||||
sortFields = Collections.singletonList(metadataSortField);
|
sortFields = Collections.singletonList(metadataSortField);
|
||||||
}
|
}
|
||||||
|
|
||||||
Query query = getSearchQuery(context, queryString, null, Collections.EMPTY_LIST, sortFields, sortField,
|
Query query = getSearchQuery(context, queryString, null, Collections.EMPTY_LIST, sortFields,
|
||||||
pageSize,
|
sortField, pageSize, offset);
|
||||||
offset);
|
|
||||||
return list(query);
|
return list(query);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -111,9 +110,9 @@ public class EPersonDAOImpl extends AbstractHibernateDSODAO<EPerson> implements
|
|||||||
@Override
|
@Override
|
||||||
public List<EPerson> findByGroups(Context context, Set<Group> groups) throws SQLException {
|
public List<EPerson> findByGroups(Context context, Set<Group> groups) throws SQLException {
|
||||||
Query query = createQuery(context,
|
Query query = createQuery(context,
|
||||||
"SELECT DISTINCT e FROM EPerson e " +
|
"SELECT DISTINCT e FROM EPerson e " +
|
||||||
"JOIN e.groups g " +
|
"JOIN e.groups g " +
|
||||||
"WHERE g.id IN (:idList) ");
|
"WHERE g.id IN (:idList) ");
|
||||||
|
|
||||||
List<UUID> idList = new ArrayList<>(groups.size());
|
List<UUID> idList = new ArrayList<>(groups.size());
|
||||||
for (Group group : groups) {
|
for (Group group : groups) {
|
||||||
@@ -163,7 +162,7 @@ public class EPersonDAOImpl extends AbstractHibernateDSODAO<EPerson> implements
|
|||||||
}
|
}
|
||||||
if (queryParam != null) {
|
if (queryParam != null) {
|
||||||
addMetadataValueWhereQuery(queryBuilder, queryFields, "like",
|
addMetadataValueWhereQuery(queryBuilder, queryFields, "like",
|
||||||
EPerson.class.getSimpleName().toLowerCase() + ".email like :queryParam");
|
EPerson.class.getSimpleName().toLowerCase() + ".email like :queryParam");
|
||||||
}
|
}
|
||||||
if (!CollectionUtils.isEmpty(sortFields)) {
|
if (!CollectionUtils.isEmpty(sortFields)) {
|
||||||
addMetadataSortQuery(queryBuilder, sortFields, Collections.singletonList(sortField));
|
addMetadataSortQuery(queryBuilder, sortFields, Collections.singletonList(sortField));
|
||||||
|
@@ -12,7 +12,6 @@ import java.util.Collection;
|
|||||||
|
|
||||||
import org.apache.commons.collections4.map.MultiValueMap;
|
import org.apache.commons.collections4.map.MultiValueMap;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a query to a source. Subclasses may enforce stricter typing or more verbose setting of parameters.
|
* Represents a query to a source. Subclasses may enforce stricter typing or more verbose setting of parameters.
|
||||||
*
|
*
|
||||||
|
@@ -17,12 +17,8 @@ import static org.junit.Assert.assertThat;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
|
||||||
import org.dspace.core.Constants;
|
|
||||||
import org.dspace.core.Context;
|
|
||||||
import mockit.NonStrictExpectations;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -31,9 +27,13 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import mockit.NonStrictExpectations;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.dspace.authorize.AuthorizeException;
|
import org.dspace.authorize.AuthorizeException;
|
||||||
import org.dspace.authorize.ResourcePolicy;
|
import org.dspace.authorize.ResourcePolicy;
|
||||||
|
import org.dspace.core.Constants;
|
||||||
|
import org.dspace.core.Context;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
Reference in New Issue
Block a user