see #45
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
package de.jottyfan.camporganizer.module.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import de.jottyfan.camporganizer.db.jooq.enums.EnumModule;
|
||||
import de.jottyfan.camporganizer.module.camplist.CommonController;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
public class AdminPrivilegesController extends CommonController {
|
||||
|
||||
@Autowired
|
||||
private AdminPrivilegesService service;
|
||||
|
||||
@GetMapping("/admin/privileges/userbased")
|
||||
public String getUserbased(Model model) {
|
||||
model.addAttribute("list", service.getProfiles());
|
||||
return "/admin/privileges/userbased";
|
||||
}
|
||||
|
||||
@GetMapping("/admin/privileges/rolebased")
|
||||
public String getRolebased(Model model) {
|
||||
model.addAttribute("list", service.getAllModules());
|
||||
return "/admin/privileges/rolebased";
|
||||
}
|
||||
|
||||
@GetMapping("/admin/privileges/campbased")
|
||||
public String getCampbased(Model model) {
|
||||
model.addAttribute("list", service.getAllCamps());
|
||||
return "/admin/privileges/campbased";
|
||||
}
|
||||
|
||||
@GetMapping("/admin/privileges/rolebased/{role}")
|
||||
public String getRolebased(@PathVariable String role, Model model) {
|
||||
model.addAttribute("list", service.getAllModules());
|
||||
model.addAttribute("selected", role);
|
||||
model.addAttribute("container", service.getPersonCampMappingByModule(EnumModule.valueOf(role)));
|
||||
model.addAttribute("pagedest", "_admin_privileges_rolebased_" + role);
|
||||
return "/admin/privileges/rolebased";
|
||||
}
|
||||
|
||||
@GetMapping("/admin/privileges/campbased/{campid}")
|
||||
public String getCampbased(@PathVariable Integer campid, Model model) {
|
||||
List<CampBean> list = service.getAllCamps();
|
||||
model.addAttribute("list", list);
|
||||
String campname = "?";
|
||||
for (CampBean p : list) {
|
||||
if (p.getPk().equals(campid)) {
|
||||
campname = p.getFullname();
|
||||
}
|
||||
}
|
||||
model.addAttribute("selected", campname);
|
||||
model.addAttribute("container", service.getPersonModuleMappingByCamp(campid));
|
||||
model.addAttribute("pagedest", "_admin_privileges_campbased_" + campid);
|
||||
return "/admin/privileges/campbased";
|
||||
}
|
||||
|
||||
@GetMapping("/admin/privileges/userbased/{userid}")
|
||||
public String getUserbased(@PathVariable Integer userid, Model model) {
|
||||
List<ProfileBean> list = service.getProfiles();
|
||||
model.addAttribute("list", list);
|
||||
String selected = "?";
|
||||
for (ProfileBean p : list) {
|
||||
if (p.getPk().equals(userid)) {
|
||||
selected = p.getFullname();
|
||||
}
|
||||
}
|
||||
model.addAttribute("selected", selected);
|
||||
model.addAttribute("container", service.getModuleCampMappingByPerson(userid));
|
||||
model.addAttribute("pagedest", "_admin_privileges_userbased_" + userid);
|
||||
return "/admin/privileges/userbased";
|
||||
}
|
||||
|
||||
@GetMapping("/admin/privileges/delete/{id}/{pagedest}")
|
||||
public String deleteFromCampProfile(@PathVariable Integer id, @PathVariable String pagedest) {
|
||||
service.deleteFromCampProfile(id);
|
||||
return "redirect:" + pagedest.replace("_", "/");
|
||||
}
|
||||
|
||||
@GetMapping("/admin/privileges/add/{pagedest}")
|
||||
public String prepareAdd(Model model, @PathVariable String pagedest) {
|
||||
model.addAttribute("pagedest", pagedest);
|
||||
model.addAttribute("bean", new CampProfileBean());
|
||||
model.addAttribute("profiles", service.getProfiles());
|
||||
model.addAttribute("camps", service.getAllCamps());
|
||||
model.addAttribute("modules", service.getAllModules());
|
||||
return "/admin/privileges/add";
|
||||
}
|
||||
|
||||
@PostMapping("/admin/privileges/insert/{pagedest}")
|
||||
public String insertCampProfile(@Valid @ModelAttribute("bean") CampProfileBean bean, final BindingResult bindingResult, @PathVariable String pagedest, Model model) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
model.addAttribute("pagedest", pagedest);
|
||||
model.addAttribute("profiles", service.getProfiles());
|
||||
model.addAttribute("camps", service.getAllCamps());
|
||||
model.addAttribute("modules", service.getAllModules());
|
||||
return "/admin/privileges/add";
|
||||
}
|
||||
service.insertIntoCampProfile(bean);
|
||||
return "redirect:" + pagedest.replace("_", "/");
|
||||
}
|
||||
|
||||
@GetMapping("/admin/privileges/abortinsert/{pagedest}")
|
||||
public String abortInsert(@PathVariable String pagedest) {
|
||||
return "redirect:" + pagedest.replace("_", "/");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package de.jottyfan.camporganizer.module.admin;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import de.jottyfan.camporganizer.db.jooq.enums.EnumModule;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class AdminPrivilegesService {
|
||||
|
||||
@Autowired
|
||||
private AdminRepository adminRepository;
|
||||
|
||||
/**
|
||||
* get all camp beans from the database
|
||||
*
|
||||
* @return all camp beans; an empty list at least
|
||||
*/
|
||||
public List<CampBean> getAllCamps() {
|
||||
return adminRepository.getAllCamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* get all profiles from the db
|
||||
*
|
||||
* @return the profiles
|
||||
*/
|
||||
public List<ProfileBean> getProfiles() {
|
||||
return adminRepository.getProfiles();
|
||||
}
|
||||
|
||||
/**
|
||||
* get all roles
|
||||
*
|
||||
* @return all roles
|
||||
*/
|
||||
public List<String> getAllModules() {
|
||||
return adminRepository.getAllModules();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the mapping that contains the form bean for a selected module
|
||||
*
|
||||
* @param module the module
|
||||
* @return the container
|
||||
*/
|
||||
public PrivilegesContainerBean getPersonCampMappingByModule(EnumModule module) {
|
||||
return adminRepository.getPersonCampMappingByModule(module);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the mapping that contains the form bean for a selected camp
|
||||
*
|
||||
* @param camp the camp ID
|
||||
* @return the container
|
||||
*/
|
||||
public PrivilegesContainerBean getPersonModuleMappingByCamp(Integer camp) {
|
||||
return adminRepository.getPersonModuleMappingByCamp(camp);
|
||||
}
|
||||
|
||||
/**
|
||||
* get the mapping that contains the form bean for a selected user
|
||||
*
|
||||
* @param user the user ID
|
||||
* @return the container
|
||||
*/
|
||||
public PrivilegesContainerBean getModuleCampMappingByPerson(Integer user) {
|
||||
return adminRepository.getModuleCampMappingByPerson(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete from camp profile
|
||||
*
|
||||
* @param id the ID
|
||||
*/
|
||||
public void deleteFromCampProfile(Integer id) {
|
||||
adminRepository.deleteFromCampProfile(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* add the camp profile to the database
|
||||
*
|
||||
* @param bean the bean
|
||||
*/
|
||||
public void insertIntoCampProfile(CampProfileBean bean) {
|
||||
EnumModule m = bean.getModule() == null ? null : EnumModule.valueOf(bean.getModule());
|
||||
adminRepository.addToCampProfile(bean.getFkCamp(), bean.getFkProfile(), m);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.jottyfan.camporganizer.module.admin;
|
||||
|
||||
import static de.jottyfan.camporganizer.db.jooq.Tables.T_CAMP;
|
||||
import static de.jottyfan.camporganizer.db.jooq.Tables.T_CAMPPROFILE;
|
||||
import static de.jottyfan.camporganizer.db.jooq.Tables.T_DOCUMENT;
|
||||
import static de.jottyfan.camporganizer.db.jooq.Tables.T_DOCUMENTROLE;
|
||||
import static de.jottyfan.camporganizer.db.jooq.Tables.T_LOCATION;
|
||||
@@ -31,6 +32,7 @@ import org.jooq.Record4;
|
||||
import org.jooq.Record5;
|
||||
import org.jooq.SelectConditionStep;
|
||||
import org.jooq.SelectSeekStep1;
|
||||
import org.jooq.SelectSeekStep2;
|
||||
import org.jooq.SelectWhereStep;
|
||||
import org.jooq.UpdateConditionStep;
|
||||
import org.jooq.UpdateSetMoreStep;
|
||||
@@ -43,7 +45,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import de.jottyfan.camporganizer.db.jooq.enums.EnumCamprole;
|
||||
import de.jottyfan.camporganizer.db.jooq.enums.EnumDocument;
|
||||
import de.jottyfan.camporganizer.db.jooq.enums.EnumFiletype;
|
||||
import de.jottyfan.camporganizer.db.jooq.enums.EnumModule;
|
||||
import de.jottyfan.camporganizer.db.jooq.tables.records.TCampRecord;
|
||||
import de.jottyfan.camporganizer.db.jooq.tables.records.TCampprofileRecord;
|
||||
import de.jottyfan.camporganizer.db.jooq.tables.records.TDocumentRecord;
|
||||
import de.jottyfan.camporganizer.db.jooq.tables.records.TDocumentroleRecord;
|
||||
import de.jottyfan.camporganizer.db.jooq.tables.records.TLocationRecord;
|
||||
@@ -482,4 +486,160 @@ public class AdminRepository {
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* get all modules
|
||||
*
|
||||
* @return all modules
|
||||
*/
|
||||
public List<String> getAllModules() {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (EnumModule r : EnumModule.values()) {
|
||||
list.add(r.getLiteral());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the mapping that contains the form bean for a selected module
|
||||
*
|
||||
* @param module the module
|
||||
* @return the container
|
||||
*/
|
||||
public PrivilegesContainerBean getPersonCampMappingByModule(EnumModule module) {
|
||||
SelectSeekStep2<Record4<Integer, String, LocalDateTime, String>, LocalDateTime, Integer> sql = jooq
|
||||
// @formatter:off
|
||||
.select(T_CAMPPROFILE.PK,
|
||||
T_CAMP.NAME,
|
||||
T_CAMP.ARRIVE,
|
||||
T_PROFILE.FORENAME.concat(" ").concat(T_PROFILE.SURNAME).as(T_PROFILE.USERNAME))
|
||||
.from(T_CAMPPROFILE)
|
||||
.leftJoin(T_CAMP).on(T_CAMP.PK.eq(T_CAMPPROFILE.FK_CAMP))
|
||||
.leftJoin(T_PROFILE).on(T_PROFILE.PK.eq(T_CAMPPROFILE.FK_PROFILE))
|
||||
.where(T_CAMPPROFILE.MODULE.eq(module))
|
||||
.orderBy(T_CAMP.ARRIVE, T_PROFILE.PK);
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
PrivilegesContainerBean pcb = new PrivilegesContainerBean();
|
||||
for (Record4<Integer, String, LocalDateTime, String> r : sql.fetch()) {
|
||||
Integer fkCampProfile = r.get(T_CAMPPROFILE.PK);
|
||||
String username = r.get(T_PROFILE.USERNAME);
|
||||
String campname = r.get(T_CAMP.NAME);
|
||||
LocalDateTime ldt = r.get(T_CAMP.ARRIVE);
|
||||
String year = ldt != null ? String.valueOf(ldt.getYear()) : "?";
|
||||
campname = campname == null ? year : campname.concat(" ").concat(year);
|
||||
if (pcb.get(username) == null) {
|
||||
pcb.addKey(username);
|
||||
}
|
||||
pcb.add(username, IntKeyValueBean.of(fkCampProfile, campname));
|
||||
}
|
||||
return pcb;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the mapping that contains the form bean for a selected user
|
||||
*
|
||||
* @param user the user ID
|
||||
* @return the container
|
||||
*/
|
||||
public PrivilegesContainerBean getModuleCampMappingByPerson(Integer user) {
|
||||
SelectSeekStep1<Record4<Integer, String, LocalDateTime, EnumModule>, LocalDateTime> sql = jooq
|
||||
// @formatter:off
|
||||
.select(T_CAMPPROFILE.PK,
|
||||
T_CAMP.NAME,
|
||||
T_CAMP.ARRIVE,
|
||||
T_CAMPPROFILE.MODULE)
|
||||
.from(T_CAMPPROFILE)
|
||||
.leftJoin(T_CAMP).on(T_CAMP.PK.eq(T_CAMPPROFILE.FK_CAMP))
|
||||
.where(T_CAMPPROFILE.FK_PROFILE.eq(user))
|
||||
.orderBy(T_CAMP.ARRIVE);
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
PrivilegesContainerBean pcb = new PrivilegesContainerBean();
|
||||
for (Record4<Integer, String, LocalDateTime, EnumModule> r : sql.fetch()) {
|
||||
Integer fkCampProfile = r.get(T_CAMPPROFILE.PK);
|
||||
EnumModule moduleEnum = r.get(T_CAMPPROFILE.MODULE);
|
||||
String module = moduleEnum == null ? null : moduleEnum.getLiteral();
|
||||
String campname = r.get(T_CAMP.NAME);
|
||||
LocalDateTime ldt = r.get(T_CAMP.ARRIVE);
|
||||
String year = ldt != null ? String.valueOf(ldt.getYear()) : "?";
|
||||
campname = campname == null ? year : campname.concat(" ").concat(year);
|
||||
if (pcb.get(module) == null) {
|
||||
pcb.addKey(module);
|
||||
}
|
||||
pcb.add(module, IntKeyValueBean.of(fkCampProfile, campname));
|
||||
}
|
||||
return pcb;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the mapping that contains the form bean for a selected camp
|
||||
*
|
||||
* @param camp the camp ID
|
||||
* @return the container
|
||||
*/
|
||||
public PrivilegesContainerBean getPersonModuleMappingByCamp(Integer camp) {
|
||||
SelectSeekStep2<Record4<Integer, String, String, EnumModule>, String, String> sql = jooq
|
||||
// @formatter:off
|
||||
.select(T_CAMPPROFILE.PK,
|
||||
T_PROFILE.FORENAME,
|
||||
T_PROFILE.SURNAME,
|
||||
T_CAMPPROFILE.MODULE)
|
||||
.from(T_CAMPPROFILE)
|
||||
.leftJoin(T_CAMP).on(T_CAMP.PK.eq(T_CAMPPROFILE.FK_CAMP))
|
||||
.leftJoin(T_PROFILE).on(T_PROFILE.PK.eq(T_CAMPPROFILE.FK_PROFILE))
|
||||
.where(T_CAMPPROFILE.FK_CAMP.eq(camp))
|
||||
.orderBy(T_PROFILE.SURNAME, T_PROFILE.FORENAME);
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
PrivilegesContainerBean pcb = new PrivilegesContainerBean();
|
||||
for (Record4<Integer, String, String, EnumModule> r : sql.fetch()) {
|
||||
Integer fkCampProfile = r.get(T_CAMPPROFILE.PK);
|
||||
EnumModule moduleEnum = r.get(T_CAMPPROFILE.MODULE);
|
||||
String forename = r.get(T_PROFILE.FORENAME);
|
||||
String surname = r.get(T_PROFILE.SURNAME);
|
||||
String person = new StringBuilder().append(forename).append(" ").append(surname).toString();
|
||||
String module = moduleEnum == null ? null : moduleEnum.getLiteral();
|
||||
if (pcb.get(person) == null) {
|
||||
pcb.addKey(person);
|
||||
}
|
||||
pcb.add(person, IntKeyValueBean.of(fkCampProfile, module));
|
||||
}
|
||||
return pcb;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete entry from camp profile
|
||||
*
|
||||
* @param id the pk
|
||||
*/
|
||||
public void deleteFromCampProfile(Integer id) {
|
||||
DeleteConditionStep<TCampprofileRecord> sql = jooq.deleteFrom(T_CAMPPROFILE).where(T_CAMPPROFILE.PK.eq(id));
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* add entry to database
|
||||
*
|
||||
* @param fkCamp the camp ID
|
||||
* @param fkProfile the profile ID
|
||||
* @param module the module
|
||||
*/
|
||||
public void addToCampProfile(Integer fkCamp, Integer fkProfile, EnumModule module) {
|
||||
InsertReturningStep<TCampprofileRecord> sql = jooq
|
||||
// @formatter:off
|
||||
.insertInto(T_CAMPPROFILE,
|
||||
T_CAMPPROFILE.FK_CAMP,
|
||||
T_CAMPPROFILE.FK_PROFILE,
|
||||
T_CAMPPROFILE.MODULE)
|
||||
.values(fkCamp, fkProfile, module)
|
||||
.onConflict(T_CAMPPROFILE.FK_CAMP,
|
||||
T_CAMPPROFILE.FK_PROFILE,
|
||||
T_CAMPPROFILE.MODULE)
|
||||
.doNothing();
|
||||
// @formatter:on
|
||||
LOGGER.debug(sql.toString());
|
||||
sql.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package de.jottyfan.camporganizer.module.admin;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -73,6 +74,10 @@ public class CampBean implements Serializable {
|
||||
return bean;
|
||||
}
|
||||
|
||||
public String getFullname() {
|
||||
return new StringBuilder().append(name).append(" ").append(arrive == null ? "?" : arrive.format(DateTimeFormatter.ofPattern("yyyy"))).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pk
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package de.jottyfan.camporganizer.module.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class CampProfileBean implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer pk;
|
||||
|
||||
@NotNull
|
||||
private Integer fkCamp;
|
||||
@NotNull
|
||||
private Integer fkProfile;
|
||||
@NotBlank
|
||||
private String module;
|
||||
|
||||
/**
|
||||
* @return the pk
|
||||
*/
|
||||
public Integer getPk() {
|
||||
return pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pk the pk to set
|
||||
*/
|
||||
public void setPk(Integer pk) {
|
||||
this.pk = pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fkCamp
|
||||
*/
|
||||
public Integer getFkCamp() {
|
||||
return fkCamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fkCamp the fkCamp to set
|
||||
*/
|
||||
public void setFkCamp(Integer fkCamp) {
|
||||
this.fkCamp = fkCamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fkProfile
|
||||
*/
|
||||
public Integer getFkProfile() {
|
||||
return fkProfile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fkProfile the fkProfile to set
|
||||
*/
|
||||
public void setFkProfile(Integer fkProfile) {
|
||||
this.fkProfile = fkProfile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the module
|
||||
*/
|
||||
public String getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param module the module to set
|
||||
*/
|
||||
public void setModule(String module) {
|
||||
this.module = module;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package de.jottyfan.camporganizer.module.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class IntKeyValueBean implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer key;
|
||||
private String value;
|
||||
|
||||
public static final IntKeyValueBean of(Integer key, String value) {
|
||||
IntKeyValueBean bean = new IntKeyValueBean();
|
||||
bean.setKey(key);
|
||||
bean.setValue(value);
|
||||
return bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the key
|
||||
*/
|
||||
public Integer getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key the key to set
|
||||
*/
|
||||
public void setKey(Integer key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value the value to set
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package de.jottyfan.camporganizer.module.admin;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jotty
|
||||
*
|
||||
*/
|
||||
public class PrivilegesContainerBean implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Map<String, List<IntKeyValueBean>> map;
|
||||
|
||||
public PrivilegesContainerBean() {
|
||||
map = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* get the content of key
|
||||
*
|
||||
* @param key the key
|
||||
* @return the value
|
||||
*/
|
||||
public List<IntKeyValueBean> get(String key) {
|
||||
return map == null ? null : map.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* add the value to the key
|
||||
*
|
||||
* @param key the key
|
||||
* @param value the value
|
||||
*/
|
||||
public void add(String key, IntKeyValueBean value) {
|
||||
if (get(key) != null) {
|
||||
map.get(key).add(value);
|
||||
} else {
|
||||
throw new NullPointerException("key not found");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* add the key to this map
|
||||
*
|
||||
* @param key
|
||||
*/
|
||||
public void addKey(String key) {
|
||||
map.put(key, new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the map
|
||||
*/
|
||||
public Map<String, List<IntKeyValueBean>> getMap() {
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,10 @@ public class ProfileBean implements Serializable {
|
||||
return bean;
|
||||
}
|
||||
|
||||
public String getFullname() {
|
||||
return new StringBuilder().append(forename).append(" ").append(surname).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pk
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user