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

47 lines
1.2 KiB
Java

package de.hsadmin.mods.db;
import java.io.Serializable;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.ModuleImpl;
import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac;
@Entity(name = "MySqlDatabases")
@DiscriminatorValue("mysql")
@EntityInfo(name = "MySQL Datenbank")
@SearchFilter("obj.instance = 'mysql' AND (" + " obj.pac = :loginUserPac OR "
+ " obj.pac.customer.memberCode = :loginUserName )")
@ModuleImpl(de.hsadmin.mods.db.MySqlDatabaseModuleImpl.class)
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;
}
public static String restriction() {
return "obj.instance='mysql' AND ( " + Database.restriction() + " )";
}
}