mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-17 23:13:10 +00:00
DS-3004: Added to group name as a column to the group entity and use to to find groups by name instead of searching in the metdata
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.dspace.eperson;
|
package org.dspace.eperson;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.dspace.content.DSpaceObject;
|
import org.dspace.content.DSpaceObject;
|
||||||
import org.dspace.content.DSpaceObjectLegacySupport;
|
import org.dspace.content.DSpaceObjectLegacySupport;
|
||||||
import org.dspace.content.MetadataSchema;
|
import org.dspace.content.MetadataSchema;
|
||||||
@@ -48,6 +49,9 @@ public class Group extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
@Column
|
@Column
|
||||||
private Boolean permanent = false;
|
private Boolean permanent = false;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
private String name;
|
||||||
|
|
||||||
/** lists of epeople and groups in the group */
|
/** lists of epeople and groups in the group */
|
||||||
@ManyToMany(fetch = FetchType.LAZY)
|
@ManyToMany(fetch = FetchType.LAZY)
|
||||||
@JoinTable(
|
@JoinTable(
|
||||||
@@ -197,14 +201,20 @@ public class Group extends DSpaceObject implements DSpaceObjectLegacySupport
|
|||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return getGroupService().getName(this);
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Change the name of this Group. */
|
/** Change the name of this Group. */
|
||||||
void setName(Context context, String name) throws SQLException
|
void setName(Context context, String name) throws SQLException
|
||||||
{
|
{
|
||||||
getGroupService().setMetadataSingleValue(context, this,
|
if(!StringUtils.equals(this.name, name)) {
|
||||||
MetadataSchema.DC_SCHEMA, "title", null, null, name);
|
this.name = name;
|
||||||
|
groupsChanged = true;
|
||||||
|
|
||||||
|
//Also update the name in the metadata
|
||||||
|
getGroupService().setMetadataSingleValue(context, this,
|
||||||
|
MetadataSchema.DC_SCHEMA, "title", null, null, name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGroupsChanged() {
|
public boolean isGroupsChanged() {
|
||||||
|
@@ -26,14 +26,13 @@ import org.dspace.eperson.factory.EPersonServiceFactory;
|
|||||||
import org.dspace.eperson.service.EPersonService;
|
import org.dspace.eperson.service.EPersonService;
|
||||||
import org.dspace.eperson.service.GroupService;
|
import org.dspace.eperson.service.GroupService;
|
||||||
import org.dspace.event.Event;
|
import org.dspace.event.Event;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service implementation for the Group object.
|
* Service implementation for the Group object.
|
||||||
* This class is responsible for all business logic calls for the Group object and is autowired by spring.
|
* This class is responsible for all business logic calls for the Group object and is autowired by spring.
|
||||||
@@ -247,7 +246,7 @@ public class GroupServiceImpl extends DSpaceObjectServiceImpl<Group> implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return groupDAO.findByMetadataField(context, name, metadataFieldService.findByElement(context, MetadataSchema.DC_SCHEMA, "title", null));
|
return groupDAO.findByName(context, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -41,4 +41,6 @@ public interface GroupDAO extends DSpaceObjectDAO<Group>, DSpaceObjectLegacySupp
|
|||||||
List<Group> getEmptyGroups(Context context) throws SQLException;
|
List<Group> getEmptyGroups(Context context) throws SQLException;
|
||||||
|
|
||||||
int countRows(Context context) throws SQLException;
|
int countRows(Context context) throws SQLException;
|
||||||
|
|
||||||
|
Group findByName(Context context, String name) throws SQLException;
|
||||||
}
|
}
|
||||||
|
@@ -79,6 +79,16 @@ public class GroupDAOImpl extends AbstractHibernateDSODAO<Group> implements Grou
|
|||||||
return list(query);
|
return list(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Group findByName(final Context context, final String name) throws SQLException {
|
||||||
|
Query query = createQuery(context,
|
||||||
|
"select g from Group g " +
|
||||||
|
"where g.name = :name ");
|
||||||
|
|
||||||
|
query.setParameter("name", name);
|
||||||
|
|
||||||
|
return uniqueResult(query);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Group> search(Context context, String query, List<MetadataField> queryFields, int offset, int limit) throws SQLException {
|
public List<Group> search(Context context, String query, List<MetadataField> queryFields, int offset, int limit) throws SQLException {
|
||||||
String groupTableName = "g";
|
String groupTableName = "g";
|
||||||
@@ -167,4 +177,5 @@ public class GroupDAOImpl extends AbstractHibernateDSODAO<Group> implements Grou
|
|||||||
public int countRows(Context context) throws SQLException {
|
public int countRows(Context context) throws SQLException {
|
||||||
return count(createQuery(context, "SELECT count(*) FROM Group"));
|
return count(createQuery(context, "SELECT count(*) FROM Group"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user