hs.hsadmin/hsarback/src/de/hsadmin/mods/db/MySqlDatabase.java

51 lines
1.4 KiB
Java
Raw Normal View History

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;
import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.ModuleImpl;
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")
2011-03-22 23:02:06 +01:00
@EntityInfo(name = "MySQL Datenbank")
2011-04-01 18:53:37 +02:00
@SearchFilter("obj.instance = 'mysql' AND (" + " obj.pac = :loginUserPac OR "
+ " obj.pac.customer.memberCode = :loginUserName )")
@ModuleImpl(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
}
}