kugelbergerer

Untitled

Jan 7th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.39 KB | None | 0 0
  1. package Adminpage;
  2.  
  3.  
  4. import java.io.Serializable;
  5. import java.util.HashMap;
  6. import java.util.Map;
  7. import javax.annotation.PostConstruct;
  8. import javax.faces.application.FacesMessage;
  9. import javax.faces.bean.ManagedBean;
  10. import javax.faces.bean.ViewScoped;
  11. import javax.faces.context.FacesContext;
  12. import javax.inject.Inject;
  13.  
  14. import Security.C_SecurityGroup;
  15. import Security.C_SecurityGroup_JSF;
  16. import Security.C_Test;
  17. import Security.I_getSecurityGroup;
  18.  
  19. @ManagedBean
  20. @ViewScoped
  21. public class B_AdminAddUser implements Serializable {
  22.    
  23.     private static final long serialVersionUID = 1L;
  24. private Map<String,Map<String,String>> data = new HashMap<String, Map<String,String>>();
  25.    private String vorname;
  26.    private String nachname;
  27.    private String email;
  28.    private String username;
  29.    private String passwort;
  30.    private String confirmation;
  31.    private String securitygroup;
  32.    private String markt;
  33.    private String country;
  34.    private String city;
  35.    private Map<String,String> countries;
  36.    private Map<String,String> cities;
  37.    
  38.    private static Map<String, C_SecurityGroup_JSF> securitygroups;
  39.    private Map<String, M_Markt_JSF> marketlist;
  40.    
  41.    @Inject
  42.    I_getSecurityGroup getsecgroup;
  43.    
  44.    @Inject
  45.    I_getMarkets getmarkets;
  46.    
  47.    @Inject
  48.    I_UserService userservice;
  49.    
  50.    @PostConstruct
  51.    public void init() {
  52.        countries  = new HashMap<String, String>();
  53.        countries.put("USA", "USA");
  54.        countries.put("Germany", "Germany");
  55.        countries.put("Brazil", "Brazil");
  56.        
  57.        Map<String,String> map = new HashMap<String, String>();
  58.        map.put("New York", "New York");
  59.        map.put("San Francisco", "San Francisco");
  60.        map.put("Denver", "Denver");
  61.        data.put("USA", map);
  62.        
  63.        map = new HashMap<String, String>();
  64.        map.put("Berlin", "Berlin");
  65.        map.put("Munich", "Munich");
  66.        map.put("Frankfurt", "Frankfurt");
  67.        data.put("Germany", map);
  68.        
  69.        map = new HashMap<String, String>();
  70.        map.put("Sao Paolo", "Sao Paolo");
  71.        map.put("Rio de Janerio", "Rio de Janerio");
  72.        map.put("Salvador", "Salvador");
  73.        data.put("Brazil", map);
  74.    }
  75.  
  76.    public Map<String, Map<String, String>> getData() {
  77.        return data;
  78.    }
  79.    
  80.    
  81.    
  82.    
  83.    public String getMarkt() {
  84.     return markt;
  85. }
  86.  
  87. public void setMarkt(String markt) {
  88.     this.markt = markt;
  89. }
  90.  
  91. public Map<String, M_Markt_JSF> getMarketlist() {
  92.        marketlist = getmarkets.getMarkets();
  93.        return marketlist;
  94. }
  95.  
  96. public void setMarketlist(Map<String, M_Markt_JSF> marketlist) {
  97.     this.marketlist = marketlist;
  98. }
  99.  
  100. public String getEmail() {
  101.     return email;
  102. }
  103.  
  104. public void setEmail(String email) {
  105.     this.email = email;
  106. }
  107.  
  108. public String getUsername() {
  109.     return username;
  110. }
  111.  
  112. public void setUsername(String username) {
  113.     this.username = username;
  114. }
  115.  
  116. public String getPasswort() {
  117.     return passwort;
  118. }
  119.  
  120. public void setPasswort(String passwort) {
  121.     this.passwort = passwort;
  122. }
  123.  
  124. public String getConfirmation() {
  125.     return confirmation;
  126. }
  127.  
  128. public void setConfirmation(String confirmation) {
  129.     this.confirmation = confirmation;
  130. }
  131.  
  132. public Map<String, C_SecurityGroup_JSF> getSecuritygroups() {
  133.        securitygroups = getsecgroup.getSecurityGroups();
  134.        return securitygroups;
  135. }
  136.  
  137. public void setSecuritygroups(Map<String, C_SecurityGroup_JSF> securitygroups) {
  138.     this.securitygroups = securitygroups;
  139. }
  140.  
  141. public String getSecuritygroup() {
  142.     return securitygroup;
  143. }
  144.  
  145. public void setSecuritygroup(String securitygroup) {
  146.     this.securitygroup = securitygroup;
  147. }
  148.  
  149. public String getNachname() {
  150.     return nachname;
  151. }
  152.  
  153. public void setNachname(String nachname) {
  154.     this.nachname = nachname;
  155. }
  156.  
  157. public String getVorname() {
  158.     return vorname;
  159. }
  160.  
  161. public void setVorname(String vorname) {
  162.     this.vorname = vorname;
  163. }
  164.  
  165. public String getCountry() {
  166.        return country;
  167.    }
  168.  
  169.    public void setCountry(String country) {
  170.        this.country = country;
  171.    }
  172.  
  173.    public String getCity() {
  174.        return city;
  175.    }
  176.  
  177.    public void setCity(String city) {
  178.        this.city = city;
  179.    }
  180.  
  181.    public Map<String, String> getCountries() {
  182.        return countries;
  183.    }
  184.  
  185.    public Map<String, String> getCities() {
  186.        return cities;
  187.    }
  188.  
  189.    public void onCountryChange() {
  190.        if(country !=null && !country.equals(""))
  191.            cities = data.get(country);
  192.        else
  193.            cities = new HashMap<String, String>();
  194.    }
  195.    
  196.    public void checknewuser(){
  197.        FacesMessage msg;
  198.        if (passwort.equals(confirmation) == false){
  199.            msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Invalid", "Passwords do not match");
  200.        }
  201.        else{
  202.            msg = new FacesMessage("Erfolgreich!", "Neuer User: " + username + " wurde angelegt!");
  203.        }
  204.        FacesContext.getCurrentInstance().addMessage(null, msg);
  205.    }
  206.    
  207.    public void displayLocation() {
  208.        FacesMessage msg;
  209.        if(city != null && country != null)
  210.            msg = new FacesMessage("Selected", city + " of " + country + " Vorname: " + vorname);
  211.        else
  212.            msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Invalid", "City is not selected.");
  213.            
  214.        FacesContext.getCurrentInstance().addMessage(null, msg);  
  215.    }
  216.    
  217.    
  218.    public void newuser(){
  219.        userservice.adduser(vorname, nachname, email, username, passwort, markt, securitygroup);
  220.    }
  221.    
  222.    
  223. }
Add Comment
Please, Sign In to add comment