mirror of
https://github.com/sismics/docs.git
synced 2025-12-13 09:46:17 +00:00
#18: PUT /group
This commit is contained in:
@@ -20,15 +20,17 @@ import com.sismics.util.context.ThreadLocalContext;
|
||||
*/
|
||||
public class GroupDao {
|
||||
/**
|
||||
* Gets a group by its ID.
|
||||
* Returns a group by name.
|
||||
*
|
||||
* @param id Group ID
|
||||
* @return Group
|
||||
* @param name Name
|
||||
* @return Tag
|
||||
*/
|
||||
public Group getById(String id) {
|
||||
public Group getByName(String name) {
|
||||
EntityManager em = ThreadLocalContext.get().getEntityManager();
|
||||
Query q = em.createQuery("select g from Group g where g.name = :name and g.deleteDate is null");
|
||||
q.setParameter("name", name);
|
||||
try {
|
||||
return em.find(Group.class, id);
|
||||
return (Group) q.getSingleResult();
|
||||
} catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -46,24 +46,27 @@ public class Group implements Loggable {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
public Group setId(String id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
public Group setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
public Group setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -71,8 +74,9 @@ public class Group implements Loggable {
|
||||
return deleteDate;
|
||||
}
|
||||
|
||||
public void setDeleteDate(Date deleteDate) {
|
||||
public Group setDeleteDate(Date deleteDate) {
|
||||
this.deleteDate = deleteDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user