return group;
}
+ /**
+ *
+ * @param name
+ * @return
+ */
private boolean groupExists(String name) {
Group group = null;
Query q = em.createNamedQuery("Group.findByName");
return false;
}
+ /**
+ *
+ * @param groupId
+ * @return
+ */
public boolean deleteGroup(long groupId) {
Group group = findGroup(groupId);
if (group != null) {
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package com.edf.gde.entities;
import com.edf.gde.transferables.FileTO;
setResult(resultTO, groupTO);
}
break;
- case ADDTOGROUP: {
- long groupId = commandTO.getLong("id");
- LongListTO listTO = fromJson(commandTO.getData(), LongListTO.class);
- userDAO.addToGroup(groupId, listTO.getList());
- }
- break;
case REMOVEFROMGROUP: {
long groupId = commandTO.getLong("groupId");
long userId = commandTO.getLong("userId");
userDAO.deleteGroup(groupId);
}
break;
+ case ADDTOGROUP: {
+ long groupId = commandTO.getLong("groupId");
+ long userId = commandTO.getLong("userId");
+ addToGroup(groupId, userId);
+ }
+ break;
}
} catch (RuntimeException ex) {
// Return error on any error...
resultTO.setData(toJson(data));
}
+ protected void addToGroup(long groupId, long userId) {
+ userDAO.addToGroup(groupId, userId);
+ }
+
protected GroupTO createGroup(String groupName) {
Group group = userDAO.createGroup(groupName);
return group.toGroupTO();
DROP TABLE IF EXISTS USERGROUP CASCADE;
CREATE TABLE USERGROUP (
id bigint NOT NULL PRIMARY KEY,
- groupId bigint references GROUP_(id),
- userId bigint references USERS(id)
+ groupId bigint references GROUP_(id) on delete cascade,
+ userId bigint references USERS(id) on delete cascade
);
+create index usergroup_groupId_idx ON USERGROUP(groupId);
DROP TABLE IF EXISTS USERPERMISSIONS CASCADE;
CREATE TABLE USERPERMISSIONS (