2011-03-22 23:02:06 +01:00
|
|
|
package de.hsadmin.mods.db;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
2011-04-01 18:53:37 +02:00
|
|
|
import javax.persistence.DiscriminatorValue;
|
2011-03-22 23:02:06 +01:00
|
|
|
import javax.persistence.Entity;
|
|
|
|
|
2012-07-27 11:18:08 +02:00
|
|
|
import de.hsadmin.core.model.AnnModuleImpl;
|
2011-03-22 23:02:06 +01:00
|
|
|
import de.hsadmin.core.model.SearchFilter;
|
|
|
|
import de.hsadmin.mods.pac.Pac;
|
|
|
|
|
|
|
|
@Entity(name = "MySqlDatabases")
|
2011-04-01 18:53:37 +02:00
|
|
|
@DiscriminatorValue("mysql")
|
|
|
|
@SearchFilter("obj.instance = 'mysql' AND (" + " obj.pac = :loginUserPac OR "
|
|
|
|
+ " obj.pac.customer.memberCode = :loginUserName )")
|
2012-07-27 11:18:08 +02:00
|
|
|
@AnnModuleImpl(de.hsadmin.mods.db.MySqlDatabaseModuleImpl.class)
|
2011-03-22 23:02:06 +01:00
|
|
|
public class MySqlDatabase extends Database implements Serializable {
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 2862112440807946042L;
|
|
|
|
|
|
|
|
public MySqlDatabase() {
|
|
|
|
setInstance("mysql");
|
|
|
|
setEncoding("UTF-8");
|
|
|
|
}
|
|
|
|
|
|
|
|
public MySqlDatabase(Pac pac, String name, String owner, String encoding) {
|
|
|
|
super("mysql", pac, name, owner, encoding);
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getSystemEncoding() {
|
|
|
|
String sysEnc = getEncoding().toLowerCase().replaceAll("-", "");
|
|
|
|
return sysEnc;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Class<? extends DatabaseUser> getSqlUserClass() {
|
|
|
|
return MySqlUser.class;
|
|
|
|
}
|
|
|
|
|
2011-08-29 16:09:20 +02:00
|
|
|
public static String createQueryFromStringKey(String humanKey) {
|
|
|
|
return "obj.name='" + humanKey + "'";
|
|
|
|
}
|
|
|
|
|
2011-03-22 23:02:06 +01:00
|
|
|
public static String restriction() {
|
2011-04-01 18:53:37 +02:00
|
|
|
return "obj.instance='mysql' AND ( " + Database.restriction() + " )";
|
2011-03-22 23:02:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|