From 328f850d0b5775bc8aed8f5ced1a6ef6269cb831 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Tue, 6 Aug 2013 18:53:14 +0200 Subject: - Change UserBase implementation - starts with general MOAID Config --- .../moa/id/commons/db/ConfigurationDBRead.java | 35 +-- .../moa/id/commons/db/dao/config/UserDatabase.java | 263 --------------------- .../id/commons/db/dao/session/OASessionStore.java | 1 - 3 files changed, 3 insertions(+), 296 deletions(-) delete mode 100644 id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/UserDatabase.java (limited to 'id/server/moa-id-commons/src/main/java/at') diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java index e815f2a69..67bc2b918 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java @@ -22,10 +22,8 @@ public class ConfigurationDBRead { QUERIES.put("getOnlineApplicationWithDBID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.hjid = :id"); QUERIES.put("getAllOnlineApplications", "select onlineapplication from OnlineApplication onlineapplication"); QUERIES.put("getMOAIDConfiguration", "select moaidconfiguration from MOAIDConfiguration moaidconfiguration"); - QUERIES.put("getUserWithUserID", "select userdatabase from UserDatabase userdatabase where userdatabase.id = :id"); - QUERIES.put("searchOnlineApplicationsWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.friendlyName like :id"); - QUERIES.put("searchOnlineApplicationsFormUserWithID", "select onlineapplication from UserDatabase userdatabase, OnlineApplication onlineapplication where userdatabase.id = :userid and userdatabase.registratedOAs.friendlyName like :oaid"); - } + QUERIES.put("getUserWithUserID", "select userdatabase from UserDatabase userdatabase where userdatabase.hjid = :id"); + QUERIES.put("searchOnlineApplicationsWithID", "select onlineapplication from OnlineApplication onlineapplication where onlineapplication.friendlyName like :id"); } @SuppressWarnings("rawtypes") public static OnlineApplication getActiveOnlineApplication(String id) { @@ -156,34 +154,7 @@ public class ConfigurationDBRead { return result; } - - @SuppressWarnings("rawtypes") - public static List searchOnlineApplicationsFromUser(long userid, String oaid) { - MiscUtil.assertNotNull(oaid, "OnlineApplictionID"); - MiscUtil.assertNotNull(userid, "UserID"); - - Logger.trace("Getting OnlineApplication with ID " + oaid - + " from user with UserID " + userid + " database."); - - List result; - EntityManager session = ConfigurationDBUtils.getCurrentSession(); - - javax.persistence.Query query = session.createQuery(QUERIES.get("searchOnlineApplicationsFormUserWithID")); - query.setParameter("userid", userid); - query.setParameter("oaid", "%"+oaid+"%"); - - result = query.getResultList(); - - Logger.trace("Found entries: " + result.size()); - - if (result.size() == 0) { - Logger.trace("No entries found."); - return null; - } - - return result; - } - + public static UserDatabase getUserWithID(long id) { MiscUtil.assertNotNull(id, "UserID"); Logger.trace("Getting Userinformation with ID " + id + " from database."); diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/UserDatabase.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/UserDatabase.java deleted file mode 100644 index d1887bfa6..000000000 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/config/UserDatabase.java +++ /dev/null @@ -1,263 +0,0 @@ -package at.gv.egovernment.moa.id.commons.db.dao.config; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToMany; -import javax.persistence.PreUpdate; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - -import org.hibernate.annotations.DynamicUpdate; - -import at.gv.egovernment.moa.id.commons.db.dao.config.OnlineApplication; - - -@Entity -@DynamicUpdate(value=true) -@Table(name = "userdatabase") -public class UserDatabase implements Serializable{ - - private static final long serialVersionUID = 1L; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id", unique=true, nullable=false) - private long id; - - @Column(name = "givenname", nullable=false) - private String givenname; - - @Column(name = "familyname", nullable=false) - private String familyname; - - @Column(name = "institut", nullable=false) - private String institut; - - @Column(name = "mail", nullable=false) - private String mail; - - @Column(name = "phone", nullable=false) - private String phone; - - @Column(name = "username", unique=true, nullable=false) - private String username; - - @Column(name = "password", nullable=false) - private String password; - - @Column(name = "bpk", unique=true, nullable=false) - private String bpk; - - @Column(name = "isadmin", nullable=false) - private boolean isadmin; - - @Column(name = "isactive", nullable=false) - private boolean isactive; - - @OneToMany(mappedBy="hjid", cascade=CascadeType.REFRESH) - private List registratedOAs = null; - - @Column(name = "lastlogin") - @Temporal(TemporalType.TIMESTAMP) - private Date lastlogin; - - @PreUpdate - protected void lastUpdate() { - this.lastlogin = new Date(); - } - - /** - * @return the id - */ - public long getId() { - return id; - } - - /** - * @param id the id to set - */ - public void setId(long id) { - this.id = id; - } - - /** - * @return the givenname - */ - public String getGivenname() { - return givenname; - } - - /** - * @param givenname the givenname to set - */ - public void setGivenname(String givenname) { - this.givenname = givenname; - } - - /** - * @return the familyname - */ - public String getFamilyname() { - return familyname; - } - - /** - * @param familyname the familyname to set - */ - public void setFamilyname(String familyname) { - this.familyname = familyname; - } - - /** - * @return the institut - */ - public String getInstitut() { - return institut; - } - - /** - * @param institut the institut to set - */ - public void setInstitut(String institut) { - this.institut = institut; - } - - /** - * @return the mail - */ - public String getMail() { - return mail; - } - - /** - * @param mail the mail to set - */ - public void setMail(String mail) { - this.mail = mail; - } - - /** - * @return the phone - */ - public String getPhone() { - return phone; - } - - /** - * @param phone the phone to set - */ - public void setPhone(String phone) { - this.phone = phone; - } - - /** - * @return the username - */ - public String getUsername() { - return username; - } - - /** - * @param username the username to set - */ - public void setUsername(String username) { - this.username = username; - } - - /** - * @return the password - */ - public String getPassword() { - return password; - } - - /** - * @param password the password to set - */ - public void setPassword(String password) { - this.password = password; - } - - /** - * @return the bpk - */ - public String getBpk() { - return bpk; - } - - /** - * @param bpk the bpk to set - */ - public void setBpk(String bpk) { - this.bpk = bpk; - } - - /** - * @return the isadmin - */ - public boolean isIsadmin() { - return isadmin; - } - - /** - * @param isadmin the isadmin to set - */ - public void setIsadmin(boolean isadmin) { - this.isadmin = isadmin; - } - - /** - * @return the isactive - */ - public boolean isIsactive() { - return isactive; - } - - /** - * @param isactive the isactive to set - */ - public void setIsactive(boolean isactive) { - this.isactive = isactive; - } - - /** - * @return the registratedOAs - */ - public List getRegistratedOAs() { - return registratedOAs; - } - - /** - * @param registratedOAs the registratedOAs to set - */ - public void setRegistratedOAs(List registratedOAs) { - this.registratedOAs = registratedOAs; - } - - /** - * @return the lastlogin - */ - public Date getLastlogin() { - return lastlogin; - } - - /** - * @param lastlogin the lastlogin to set - */ - public void setLastlogin(Date lastlogin) { - this.lastlogin = lastlogin; - } - - -} - - diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OASessionStore.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OASessionStore.java index c7672f9ba..6e0f47805 100644 --- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OASessionStore.java +++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/dao/session/OASessionStore.java @@ -45,7 +45,6 @@ public class OASessionStore implements Serializable{ // this.created = new Date(); // } - //@ManyToOne(fetch=FetchType.LAZY) @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name = "moasession") private AuthenticatedSessionStore moasession; -- cgit v1.2.3