Datenbank Module

This commit is contained in:
Peter Hormanns 2011-04-01 16:53:37 +00:00
parent 875d642f26
commit 2b6ce209aa
44 changed files with 1195 additions and 65 deletions

View File

@ -19,12 +19,12 @@
<class>de.hsadmin.mods.dom.Domain</class> <class>de.hsadmin.mods.dom.Domain</class>
<class>de.hsadmin.mods.email.EMailAddress</class> <class>de.hsadmin.mods.email.EMailAddress</class>
<class>de.hsadmin.mods.email.EMailAlias</class> <class>de.hsadmin.mods.email.EMailAlias</class>
<!-- <class>de.hsadmin.mods.db.DatabaseUser</class>
<class>de.hsadmin.mods.db.MySqlUser</class> <class>de.hsadmin.mods.db.MySqlUser</class>
<class>de.hsadmin.mods.db.MySqlDatabase</class>
<class>de.hsadmin.mods.db.PgSqlUser</class> <class>de.hsadmin.mods.db.PgSqlUser</class>
<class>de.hsadmin.mods.db.Database</class>
<class>de.hsadmin.mods.db.MySqlDatabase</class>
<class>de.hsadmin.mods.db.PgSqlDatabase</class> <class>de.hsadmin.mods.db.PgSqlDatabase</class>
-->
<properties> <properties>
<property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver"/> <property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver"/>
</properties> </properties>

View File

@ -6,15 +6,20 @@ import static javax.persistence.GenerationType.SEQUENCE;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.NoResultException; import javax.persistence.NoResultException;
import javax.persistence.Query; import javax.persistence.Query;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AbstractModuleImpl;
@ -23,8 +28,12 @@ import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
@MappedSuperclass @Entity
@SearchFilter("pac = :loginUserPac OR pac.customer.memberCode = :loginUserName") @Table(name = "database")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="engine", discriminatorType=DiscriminatorType.STRING)
@SequenceGenerator(name = "DatabaseSeqGen", sequenceName = "database_database_id_seq")
@SearchFilter("obj.pac = :loginUserPac OR obj.pac.customer.name = :loginUserName")
public abstract class Database extends AbstractEntity implements Serializable { public abstract class Database extends AbstractEntity implements Serializable {
private static final long serialVersionUID = 6243815106074846080L; private static final long serialVersionUID = 6243815106074846080L;
@ -82,8 +91,8 @@ public abstract class Database extends AbstractEntity implements Serializable {
String pacName = name.substring(0, 5); String pacName = name.substring(0, 5);
try { try {
// get the entities name (query part from FROM to WHERE) // get the entities name (query part from FROM to WHERE)
javax.persistence.Entity entityAnnot = Pac.class.getAnnotation(Entity.class); Entity entityAnnot = Pac.class.getAnnotation(Entity.class);
String queryString = "FROM " + entityAnnot.name() + " WHERE " String queryString = "SELECT obj FROM " + entityAnnot.name() + " obj WHERE "
+ Pac.createQueryFromStringKey(pacName); + Pac.createQueryFromStringKey(pacName);
// set parameters // set parameters
@ -215,8 +224,8 @@ public abstract class Database extends AbstractEntity implements Serializable {
public static String restriction() { public static String restriction() {
return return
// all databases of all pacs of customer // all databases of all pacs of customer
"pac.customer.memberCode=:loginUserName OR " + "obj.pac.customer.name=:loginUserName OR " +
// all aliases of packet admin // all aliases of packet admin
"pac.name=:loginUserName"; "obj.pac.name=:loginUserName";
} }
} }

View File

@ -6,14 +6,20 @@ import static javax.persistence.GenerationType.SEQUENCE;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.NoResultException; import javax.persistence.NoResultException;
import javax.persistence.Query; import javax.persistence.Query;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
@ -22,7 +28,11 @@ import de.hsadmin.core.model.FieldValidation;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
@MappedSuperclass @Entity
@Table(name = "database_user")
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="engine", discriminatorType=DiscriminatorType.STRING)
@SequenceGenerator(name = "DatabaseUserSeqGen", sequenceName = "dbuser_dbuser_id_seq")
public abstract class DatabaseUser extends AbstractEntity implements Serializable { public abstract class DatabaseUser extends AbstractEntity implements Serializable {
private static final long serialVersionUID = -4840133372566213014L; private static final long serialVersionUID = -4840133372566213014L;
@ -72,7 +82,7 @@ public abstract class DatabaseUser extends AbstractEntity implements Serializabl
// get the entities name (query part from FROM to WHERE) // get the entities name (query part from FROM to WHERE)
javax.persistence.Entity entityAnnot = Pac.class javax.persistence.Entity entityAnnot = Pac.class
.getAnnotation(javax.persistence.Entity.class); .getAnnotation(javax.persistence.Entity.class);
String queryString = "FROM " + entityAnnot.name() + " WHERE " String queryString = "SELECT obj FROM " + entityAnnot.name() + " obj WHERE "
+ Pac.createQueryFromStringKey(pacName); + Pac.createQueryFromStringKey(pacName);
// set parameters // set parameters
@ -193,8 +203,8 @@ public abstract class DatabaseUser extends AbstractEntity implements Serializabl
public static String restriction() { public static String restriction() {
return return
// all databases of all pacs of customer // all databases of all pacs of customer
"pac.customer.memberCode=:loginUserName OR " + "obj.pac.customer.name=:loginUserName OR " +
// all aliases of packet admin // all aliases of packet admin
"pac.name=:loginUserName"; "obj.pac.name=:loginUserName";
} }
} }

View File

@ -2,20 +2,18 @@ package de.hsadmin.mods.db;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import de.hsadmin.core.model.EntityInfo; import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.SearchFilter; import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;
@Entity(name = "MySqlDatabases") @Entity(name = "MySqlDatabases")
@Table(name = "database") @DiscriminatorValue("mysql")
@SequenceGenerator(name = "DatabaseSeqGen", sequenceName = "database_database_id_seq")
@EntityInfo(name = "MySQL Datenbank") @EntityInfo(name = "MySQL Datenbank")
@SearchFilter("instance = 'mysql' AND (" + " pac = :loginUserPac OR " @SearchFilter("obj.instance = 'mysql' AND (" + " obj.pac = :loginUserPac OR "
+ " pac.customer.memberCode = :loginUserName )") + " obj.pac.customer.memberCode = :loginUserName )")
public class MySqlDatabase extends Database implements Serializable { public class MySqlDatabase extends Database implements Serializable {
private static final long serialVersionUID = 2862112440807946042L; private static final long serialVersionUID = 2862112440807946042L;
@ -40,7 +38,7 @@ public class MySqlDatabase extends Database implements Serializable {
} }
public static String restriction() { public static String restriction() {
return "instance='mysql' AND ( " + Database.restriction() + " )"; return "obj.instance='mysql' AND ( " + Database.restriction() + " )";
} }
} }

View File

@ -16,7 +16,7 @@ public class MySqlDatabaseModuleImpl extends AbstractModuleImpl {
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass,
String condition, String orderBy) throws HSAdminException { String condition, String orderBy) throws HSAdminException {
if (orderBy == null || orderBy.length() == 0) { if (orderBy == null || orderBy.length() == 0) {
orderBy = "ORDER BY name ASC"; orderBy = "ORDER BY obj.name ASC";
} }
return super.search(entityClass, condition, orderBy); return super.search(entityClass, condition, orderBy);
} }

View File

@ -2,27 +2,25 @@ package de.hsadmin.mods.db;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import de.hsadmin.core.model.EntityInfo; import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.SearchFilter; import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;
@Entity(name = "MySqlUsers") @Entity(name = "MySqlUsers")
@Table(name = "database_user") @DiscriminatorValue("mysql")
@SequenceGenerator(name = "DatabaseUserSeqGen", sequenceName = "dbuser_dbuser_id_seq")
@EntityInfo(name = "MySQL Konto") @EntityInfo(name = "MySQL Konto")
@SearchFilter("instance = 'mysql' AND (" @SearchFilter("obj.instance = 'mysql' AND ("
+ " pac = :loginUserPac OR " + " obj.pac = :loginUserPac OR "
+ " pac.customer.memberCode = :loginUserName )") + " obj.pac.customer.memberCode = :loginUserName )")
public class MySqlUser extends DatabaseUser implements Serializable { public class MySqlUser extends DatabaseUser implements Serializable {
private static final long serialVersionUID = 6218494776881999478L; private static final long serialVersionUID = 6218494776881999478L;
public static String createQueryFromStringKey(String humanKey) { public static String createQueryFromStringKey(String humanKey) {
return "name='" + humanKey + "' AND instance='mysql'"; return "obj.name='" + humanKey + "' AND obj.instance='mysql'";
} }
public MySqlUser() { public MySqlUser() {
@ -37,7 +35,7 @@ public class MySqlUser extends DatabaseUser implements Serializable {
* query restriction for access control * query restriction for access control
*/ */
public static String restriction() { public static String restriction() {
return "instance='mysql' AND ( " + DatabaseUser.restriction() + " )"; return "obj.instance='mysql' AND ( " + DatabaseUser.restriction() + " )";
} }
} }

View File

@ -22,7 +22,7 @@ public class MySqlUserModuleImpl extends AbstractModuleImpl {
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass,
String condition, String orderBy) throws HSAdminException { String condition, String orderBy) throws HSAdminException {
if (orderBy == null || orderBy.length() == 0) { if (orderBy == null || orderBy.length() == 0) {
orderBy = "ORDER BY name ASC"; orderBy = "ORDER BY obj.name ASC";
} }
return super.search(entityClass, condition, orderBy); return super.search(entityClass, condition, orderBy);
} }

View File

@ -2,21 +2,19 @@ package de.hsadmin.mods.db;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import de.hsadmin.core.model.EntityInfo; import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.SearchFilter; import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;
@Entity(name = "PgSqlDatabases") @Entity(name = "PgSqlDatabases")
@Table(name = "database") @DiscriminatorValue("pgsql")
@SequenceGenerator(name = "DatabaseSeqGen", sequenceName = "database_database_id_seq")
@EntityInfo(name = "PostgreSQL Datenbank") @EntityInfo(name = "PostgreSQL Datenbank")
@SearchFilter("instance = 'pgsql' AND (" @SearchFilter("obj.instance = 'pgsql' AND ("
+ " pac = :loginUserPac OR " + " obj.pac = :loginUserPac OR "
+ " pac.customer.memberCode = :loginUserName )") + " obj.pac.customer.memberCode = :loginUserName )")
public class PgSqlDatabase extends Database implements Serializable { public class PgSqlDatabase extends Database implements Serializable {
private static final long serialVersionUID = 6688358817554938015L; private static final long serialVersionUID = 6688358817554938015L;
@ -43,7 +41,7 @@ public class PgSqlDatabase extends Database implements Serializable {
* query restriction for access control * query restriction for access control
*/ */
public static String restriction() { public static String restriction() {
return "instance='pgsql' AND ( " + Database.restriction() + " )"; return "obj.instance='pgsql' AND ( " + Database.restriction() + " )";
} }
} }

View File

@ -15,7 +15,7 @@ public class PgSqlDatabaseModuleImpl extends AbstractModuleImpl {
@Override @Override
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy) throws HSAdminException { public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy) throws HSAdminException {
if (orderBy == null || orderBy.length() == 0) { if (orderBy == null || orderBy.length() == 0) {
orderBy = "ORDER BY name ASC"; orderBy = "ORDER BY obj.name ASC";
} }
return super.search(entityClass, condition, orderBy); return super.search(entityClass, condition, orderBy);
} }

View File

@ -2,26 +2,24 @@ package de.hsadmin.mods.db;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import de.hsadmin.core.model.EntityInfo; import de.hsadmin.core.model.EntityInfo;
import de.hsadmin.core.model.SearchFilter; import de.hsadmin.core.model.SearchFilter;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;
@Entity(name = "PgSqlUsers") @Entity(name = "PgSqlUsers")
@Table(name = "database_user") @DiscriminatorValue("pgsql")
@SequenceGenerator(name = "DatabaseUserSeqGen", sequenceName = "dbuser_dbuser_id_seq")
@EntityInfo(name = "PostgreSQL Konto") @EntityInfo(name = "PostgreSQL Konto")
@SearchFilter("instance = 'pgsql' AND (" + " pac = :loginUserPac OR " @SearchFilter("obj.instance = 'pgsql' AND (" + " obj.pac = :loginUserPac OR "
+ " pac.customer.memberCode = :loginUserName )") + " obj.pac.customer.memberCode = :loginUserName )")
public class PgSqlUser extends DatabaseUser implements Serializable { public class PgSqlUser extends DatabaseUser implements Serializable {
private static final long serialVersionUID = -1097602753310286629L; private static final long serialVersionUID = -1097602753310286629L;
public static String createQueryFromStringKey(String humanKey) { public static String createQueryFromStringKey(String humanKey) {
return "name='" + humanKey + "' AND instance='pgsql'"; return "obj.name='" + humanKey + "' AND obj.instance='pgsql'";
} }
public PgSqlUser() { public PgSqlUser() {
@ -36,7 +34,7 @@ public class PgSqlUser extends DatabaseUser implements Serializable {
* query restriction for access control * query restriction for access control
*/ */
public static String restriction() { public static String restriction() {
return "instance='pgsql' AND ( " + DatabaseUser.restriction() + " )"; return "obj.instance='pgsql' AND ( " + DatabaseUser.restriction() + " )";
} }
} }

View File

@ -12,7 +12,7 @@ public class PgSqlUserModuleImpl extends AbstractModuleImpl {
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass,
String condition, String orderBy) throws HSAdminException { String condition, String orderBy) throws HSAdminException {
if (orderBy == null || orderBy.length() == 0) { if (orderBy == null || orderBy.length() == 0) {
orderBy = "ORDER BY name ASC"; orderBy = "ORDER BY obj.name ASC";
} }
return super.search(entityClass, condition, orderBy); return super.search(entityClass, condition, orderBy);
} }

View File

@ -0,0 +1,57 @@
package de.hsadmin.remote;
import java.util.Map;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.mods.db.MySqlDatabase;
public class MysqlDbRemote extends AbstractRemote {
@Override
protected void entity2map(AbstractEntity entity, Map<String, String> map) {
MySqlDatabase db = (MySqlDatabase) entity;
String id = Long.toString(db.getId());
String name = db.getName();
String instance = db.getInstance();
String owner = db.getOwner();
String encoding = db.getEncoding();
String pac = db.getPac().getName();
String hive = db.getHiveName();
map.put("id", id);
map.put("name", name);
map.put("instance", instance);
map.put("pac", pac);
map.put("hive", hive);
map.put("owner", owner);
map.put("encoding", encoding);
}
@Override
protected Class<? extends AbstractEntity> getEntityClass() {
return MySqlDatabase.class;
}
@Override
protected void map2entity(Map<String, String> map, AbstractEntity entity) {
MySqlDatabase db = (MySqlDatabase) entity;
db.setInstance("mysql");
String name = map.get("name");
String owner = map.get("owner");
String encoding = map.get("encoding");
if (assertNotNull(name)) {
db.setName(name);
}
if (assertNotNull(owner)) {
db.setOwner(owner);
}
if (assertNotNull(encoding)) {
db.setEncoding(encoding);
}
}
@Override
protected void regularizeKeys(Map<String, String> whereParams) {
replaceKey(whereParams, "pac", "pac.name");
}
}

View File

@ -0,0 +1,49 @@
package de.hsadmin.remote;
import java.util.Map;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.mods.db.MySqlUser;
public class MysqlUserRemote extends AbstractRemote {
@Override
protected void entity2map(AbstractEntity entity, Map<String, String> map) {
MySqlUser user = (MySqlUser) entity;
String id = Long.toString(user.getId());
String name = user.getName();
String instance = user.getInstance();
String pac = user.getPac().getName();
String hive = user.getHiveName();
map.put("id", id);
map.put("name", name);
map.put("pac", pac);
map.put("hive", hive);
map.put("instance", instance);
}
@Override
protected Class<? extends AbstractEntity> getEntityClass() {
return MySqlUser.class;
}
@Override
protected void map2entity(Map<String, String> map, AbstractEntity entity) {
MySqlUser user = (MySqlUser) entity;
user.setInstance("mysql");
String name = map.get("name");
String password = map.get("password");
if (assertNotNull(name)) {
user.setName(name);
}
if (assertNotNull(password)) {
user.setPassword(password);
}
}
@Override
protected void regularizeKeys(Map<String, String> whereParams) {
replaceKey(whereParams, "pac", "pac.name");
}
}

View File

@ -0,0 +1,57 @@
package de.hsadmin.remote;
import java.util.Map;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.mods.db.PgSqlDatabase;
public class PgsqlDbRemote extends AbstractRemote {
@Override
protected void entity2map(AbstractEntity entity, Map<String, String> map) {
PgSqlDatabase db = (PgSqlDatabase) entity;
String id = Long.toString(db.getId());
String name = db.getName();
String instance = db.getInstance();
String owner = db.getOwner();
String encoding = db.getEncoding();
String pac = db.getPac().getName();
String hive = db.getHiveName();
map.put("id", id);
map.put("name", name);
map.put("instance", instance);
map.put("pac", pac);
map.put("hive", hive);
map.put("owner", owner);
map.put("encoding", encoding);
}
@Override
protected Class<? extends AbstractEntity> getEntityClass() {
return PgSqlDatabase.class;
}
@Override
protected void map2entity(Map<String, String> map, AbstractEntity entity) {
PgSqlDatabase db = (PgSqlDatabase) entity;
db.setInstance("pgsql");
String name = map.get("name");
String owner = map.get("owner");
String encoding = map.get("encoding");
if (assertNotNull(name)) {
db.setName(name);
}
if (assertNotNull(owner)) {
db.setOwner(owner);
}
if (assertNotNull(encoding)) {
db.setEncoding(encoding);
}
}
@Override
protected void regularizeKeys(Map<String, String> whereParams) {
replaceKey(whereParams, "pac", "pac.name");
}
}

View File

@ -0,0 +1,49 @@
package de.hsadmin.remote;
import java.util.Map;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.mods.db.PgSqlUser;
public class PgsqlUserRemote extends AbstractRemote {
@Override
protected void entity2map(AbstractEntity entity, Map<String, String> map) {
PgSqlUser user = (PgSqlUser) entity;
String id = Long.toString(user.getId());
String name = user.getName();
String instance = user.getInstance();
String pac = user.getPac().getName();
String hive = user.getHiveName();
map.put("id", id);
map.put("name", name);
map.put("pac", pac);
map.put("hive", hive);
map.put("instance", instance);
}
@Override
protected Class<? extends AbstractEntity> getEntityClass() {
return PgSqlUser.class;
}
@Override
protected void map2entity(Map<String, String> map, AbstractEntity entity) {
PgSqlUser user = (PgSqlUser) entity;
user.setInstance("pgsql");
String name = map.get("name");
String password = map.get("password");
if (assertNotNull(name)) {
user.setName(name);
}
if (assertNotNull(password)) {
user.setPassword(password);
}
}
@Override
protected void regularizeKeys(Map<String, String> whereParams) {
replaceKey(whereParams, "pac", "pac.name");
}
}

View File

@ -6,3 +6,7 @@ emailalias=de.hsadmin.remote.EMailAliasRemote
emailaddress=de.hsadmin.remote.EMailAddressRemote emailaddress=de.hsadmin.remote.EMailAddressRemote
q=de.hsadmin.remote.QueueTaskRemote q=de.hsadmin.remote.QueueTaskRemote
role=de.hsadmin.remote.RoleRemote role=de.hsadmin.remote.RoleRemote
mysqluser=de.hsadmin.remote.MysqlUserRemote
postgresqluser=de.hsadmin.remote.PgsqlUserRemote
mysqldb=de.hsadmin.remote.MysqlDbRemote
postgresqldb=de.hsadmin.remote.PgsqlDbRemote

View File

@ -0,0 +1,111 @@
package de.hsadmin.remote;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class MysqlDbTest {
private static final String MODULE = "mysqldb";
private XmlRpcClient client;
private RemoteCASHelper cas;
@Before
public void setUp() throws Exception {
client = RemoteTestHelper.getClient();
cas = new RemoteCASHelper();
}
@After
public void tearDown() throws Exception {
client = null;
cas = null;
}
@Test
public void testCreate() {
int count = getDBsCount();
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>();
setParams.put("name", "aaa00_db1");
setParams.put("owner", "aaa00_dba");
setParams.put("encoding", "utf8");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams };
try {
Object execute = client.execute(MODULE + ".add", params);
assertTrue(execute instanceof Map<?, ?>);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
assertEquals(count + 1, getDBsCount());
}
@Test
public void testSearch() {
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".search", params);
Object[] result = (Object[]) execute;
assertEquals(1, result.length);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
}
@Test
public void testDelete() {
int count = getDBsCount();
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
whereParams.put("name", "aaa00_db1");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".delete", params);
assertNull(execute);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
assertEquals(count - 1, getDBsCount());
}
private int getDBsCount() {
int count = 0;
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".search", params);
Object[] result = (Object[]) execute;
count = result.length;
} catch (XmlRpcException e) {
fail(e.getMessage());
}
return count;
}
}

View File

@ -0,0 +1,110 @@
package de.hsadmin.remote;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class MysqlUserTest {
private static final String MODULE = "mysqluser";
private XmlRpcClient client;
private RemoteCASHelper cas;
@Before
public void setUp() throws Exception {
client = RemoteTestHelper.getClient();
cas = new RemoteCASHelper();
}
@After
public void tearDown() throws Exception {
client = null;
cas = null;
}
@Test
public void testCreate() {
int count = getDBsCount();
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>();
setParams.put("name", "aaa00_dba");
setParams.put("password", "geHeimNis");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams };
try {
Object execute = client.execute(MODULE + ".add", params);
assertTrue(execute instanceof Map<?, ?>);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
assertEquals(count + 1, getDBsCount());
}
@Test
public void testSearch() {
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".search", params);
Object[] result = (Object[]) execute;
assertEquals(1, result.length);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
}
@Test
public void testDelete() {
int count = getDBsCount();
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
whereParams.put("name", "aaa00_dba");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".delete", params);
assertNull(execute);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
assertEquals(count - 1, getDBsCount());
}
private int getDBsCount() {
int count = 0;
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".search", params);
Object[] result = (Object[]) execute;
count = result.length;
} catch (XmlRpcException e) {
fail(e.getMessage());
}
return count;
}
}

View File

@ -0,0 +1,111 @@
package de.hsadmin.remote;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class PgsqlDbTest {
private static final String MODULE = "postgresqldb";
private XmlRpcClient client;
private RemoteCASHelper cas;
@Before
public void setUp() throws Exception {
client = RemoteTestHelper.getClient();
cas = new RemoteCASHelper();
}
@After
public void tearDown() throws Exception {
client = null;
cas = null;
}
@Test
public void testCreate() {
int count = getDBsCount();
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>();
setParams.put("name", "aaa00_db1");
setParams.put("owner", "aaa00_dba");
setParams.put("encoding", "UTF-8");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams };
try {
Object execute = client.execute(MODULE + ".add", params);
assertTrue(execute instanceof Map<?, ?>);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
assertEquals(count + 1, getDBsCount());
}
@Test
public void testSearch() {
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".search", params);
Object[] result = (Object[]) execute;
assertEquals(1, result.length);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
}
@Test
public void testDelete() {
int count = getDBsCount();
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
whereParams.put("name", "aaa00_db1");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".delete", params);
assertNull(execute);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
assertEquals(count - 1, getDBsCount());
}
private int getDBsCount() {
int count = 0;
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".search", params);
Object[] result = (Object[]) execute;
count = result.length;
} catch (XmlRpcException e) {
fail(e.getMessage());
}
return count;
}
}

View File

@ -0,0 +1,110 @@
package de.hsadmin.remote;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class PgsqlUserTest {
private static final String MODULE = "postgresqluser";
private XmlRpcClient client;
private RemoteCASHelper cas;
@Before
public void setUp() throws Exception {
client = RemoteTestHelper.getClient();
cas = new RemoteCASHelper();
}
@After
public void tearDown() throws Exception {
client = null;
cas = null;
}
@Test
public void testCreate() {
int count = getDBsCount();
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>();
setParams.put("name", "aaa00_dba");
setParams.put("password", "geHeimNis");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams };
try {
Object execute = client.execute(MODULE + ".add", params);
assertTrue(execute instanceof Map<?, ?>);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
assertEquals(count + 1, getDBsCount());
}
@Test
public void testSearch() {
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".search", params);
Object[] result = (Object[]) execute;
assertEquals(1, result.length);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
}
@Test
public void testDelete() {
int count = getDBsCount();
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
whereParams.put("name", "aaa00_dba");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".delete", params);
assertNull(execute);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
assertEquals(count - 1, getDBsCount());
}
private int getDBsCount() {
int count = 0;
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".search", params);
Object[] result = (Object[]) execute;
count = result.length;
} catch (XmlRpcException e) {
fail(e.getMessage());
}
return count;
}
}

View File

@ -1,16 +1,15 @@
package de.hsadmin.web; package de.hsadmin.web;
import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.terminal.Sizeable; import com.vaadin.terminal.Sizeable;
import com.vaadin.terminal.ThemeResource; import com.vaadin.terminal.ThemeResource;
import com.vaadin.ui.Button; import com.vaadin.ui.Button;
import com.vaadin.ui.Component; import com.vaadin.ui.Component;
import com.vaadin.ui.Form; import com.vaadin.ui.Form;
import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Link;
import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window; import com.vaadin.ui.Window;
import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickEvent;
@ -21,8 +20,10 @@ import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.vaadin.GenericForm; import de.hsadmin.web.vaadin.GenericForm;
import de.hsadmin.web.vaadin.TableComponentFactory; import de.hsadmin.web.vaadin.TableComponentFactory;
public abstract class AbstractModule implements Module { public abstract class AbstractModule implements Module, Serializable {
private static final long serialVersionUID = 1L;
private MainApplication application; private MainApplication application;
private VerticalLayout layout; private VerticalLayout layout;
private Component component; private Component component;

View File

@ -0,0 +1,161 @@
package de.hsadmin.web;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig;
import de.hsadmin.web.config.PropertyDefaultValue;
import de.hsadmin.web.config.PropertySelectValues;
import de.hsadmin.web.config.PropertyTableColumn;
import de.hsadmin.web.vaadin.SelectPropertyFieldFactory;
public abstract class DatabaseModule extends GenericModule {
private static final long serialVersionUID = 1L;
private ModuleConfig moduleConfig;
public abstract String getModuleIdent();
public abstract String getUserModuleIdent();
public abstract String[] getEncodings();
@Override
protected void initModule() {
MainApplication application = getApplication();
moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale());
String login = application.getLogin();
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
idProp.setReadOnly(true);
PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class);
nameProp.setDefaultValue(new PropertyDefaultValue() {
@Override
public String getDefaultValue() {
if (pac.length() >= 5) {
return pac + "_";
}
return "";
}
});
nameProp.setWriteOnce(true);
PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory());
pacProp.setDefaultValue(new PropertyDefaultValue() {
@Override
public String getDefaultValue() {
return pac;
}
});
pacProp.setSelectValues(new PropertySelectValues() {
@Override
public boolean newItemsAllowed() {
return false;
}
@Override
public boolean hasSelectList() {
return true;
}
@Override
public Map<String, String> getSelectValues() {
List<String> list = getPackets();
TreeMap<String,String> map = new TreeMap<String, String>();
for (String pac : list) {
map.put(pac, pac);
}
return map;
}
});
pacProp.setWriteOnce(true);
PropertyConfig encodingProp = new PropertyConfig(moduleConfig, "encoding", String.class, new SelectPropertyFieldFactory());
encodingProp.setDefaultValue(new PropertyDefaultValue() {
@Override
public String getDefaultValue() {
return "utf8";
}
});
encodingProp.setSelectValues(new PropertySelectValues() {
@Override
public boolean newItemsAllowed() {
return false;
}
@Override
public Map<String, String> getSelectValues() {
String[] encodings = getEncodings();
Map<String,String> map = new TreeMap<String, String>();
for (String enc : encodings) {
map.put(enc, enc);
}
return map;
}
@Override
public boolean hasSelectList() {
return true;
}
});
encodingProp.setWriteOnce(true);
PropertyConfig ownerProp = new PropertyConfig(moduleConfig, "owner", String.class, new SelectPropertyFieldFactory());
ownerProp.setDefaultValue(new PropertyDefaultValue() {
@Override
public String getDefaultValue() {
return "";
}
});
ownerProp.setSelectValues(new PropertySelectValues() {
@Override
public boolean newItemsAllowed() {
return false;
}
@Override
public boolean hasSelectList() {
return true;
}
@Override
public Map<String, String> getSelectValues() {
List<String> list = getDatabaseUsers();
TreeMap<String,String> map = new TreeMap<String, String>();
for (String usr : list) {
map.put(usr, usr);
}
return map;
}
});
ownerProp.setWriteOnce(true);
moduleConfig.addProperty(idProp);
moduleConfig.addProperty(pacProp);
moduleConfig.addProperty(nameProp);
moduleConfig.addProperty(encodingProp);
moduleConfig.addProperty(ownerProp);
}
@Override
public ModuleConfig getModuleConfig() {
return moduleConfig;
}
public List<String> getDatabaseUsers() {
ArrayList<String> list = new ArrayList<String>();
try {
Object callSearch = getApplication().getRemote().callSearch(getUserModuleIdent(), new HashMap<String, String>());
if (callSearch instanceof Object[]) {
for (Object row : ((Object[])callSearch)) {
if (row instanceof Map<?, ?>) {
Object object = ((Map<?, ?>) row).get("name");
if (object instanceof String) {
list.add((String) object);
}
}
}
}
} catch (HsarwebException e) {
e.printStackTrace();
getApplication().showSystemException(e);
}
return list;
}
}

View File

@ -0,0 +1,81 @@
package de.hsadmin.web;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig;
import de.hsadmin.web.config.PropertyDefaultValue;
import de.hsadmin.web.config.PropertySelectValues;
import de.hsadmin.web.config.PropertyTableColumn;
import de.hsadmin.web.vaadin.PasswordPropertyFieldFactory;
import de.hsadmin.web.vaadin.SelectPropertyFieldFactory;
public abstract class DatabaseUserModule extends GenericModule {
private static final long serialVersionUID = 1L;
private ModuleConfig moduleConfig;
public abstract String getModuleIdent();
@Override
protected void initModule() {
MainApplication application = getApplication();
moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale());
String login = application.getLogin();
final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
idProp.setReadOnly(true);
PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class);
nameProp.setDefaultValue(new PropertyDefaultValue() {
@Override
public String getDefaultValue() {
if (pac.length() >= 5) {
return pac + "_";
}
return "";
}
});
nameProp.setWriteOnce(true);
PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory());
pacProp.setDefaultValue(new PropertyDefaultValue() {
@Override
public String getDefaultValue() {
return pac;
}
});
pacProp.setSelectValues(new PropertySelectValues() {
@Override
public boolean newItemsAllowed() {
return false;
}
@Override
public boolean hasSelectList() {
return true;
}
@Override
public Map<String, String> getSelectValues() {
List<String> list = getPackets();
TreeMap<String,String> map = new TreeMap<String, String>();
for (String pac : list) {
map.put(pac, pac);
}
return map;
}
});
pacProp.setWriteOnce(true);
PropertyConfig passwordProp = new PropertyConfig(moduleConfig, "password", String.class, PropertyTableColumn.NONE, new PasswordPropertyFieldFactory(this));
moduleConfig.addProperty(idProp);
moduleConfig.addProperty(pacProp);
moduleConfig.addProperty(nameProp);
moduleConfig.addProperty(passwordProp);
}
@Override
public ModuleConfig getModuleConfig() {
return moduleConfig;
}
}

View File

@ -10,6 +10,7 @@ import de.hsadmin.web.config.PropertyConfig;
import de.hsadmin.web.config.PropertyDefaultValue; import de.hsadmin.web.config.PropertyDefaultValue;
import de.hsadmin.web.config.PropertySelectValues; import de.hsadmin.web.config.PropertySelectValues;
import de.hsadmin.web.config.PropertyTableColumn; import de.hsadmin.web.config.PropertyTableColumn;
import de.hsadmin.web.vaadin.DatePropertyFieldFactory;
import de.hsadmin.web.vaadin.SelectPropertyFieldFactory; import de.hsadmin.web.vaadin.SelectPropertyFieldFactory;
public class DomainModule extends GenericModule { public class DomainModule extends GenericModule {
@ -65,7 +66,7 @@ public class DomainModule extends GenericModule {
pacProp.setReadOnly(true); pacProp.setReadOnly(true);
PropertyConfig hiveProp = new PropertyConfig(moduleConfig, "hive", String.class, PropertyTableColumn.HIDDEN); PropertyConfig hiveProp = new PropertyConfig(moduleConfig, "hive", String.class, PropertyTableColumn.HIDDEN);
hiveProp.setReadOnly(true); hiveProp.setReadOnly(true);
PropertyConfig sinceProp = new PropertyConfig(moduleConfig, "since", Date.class); PropertyConfig sinceProp = new PropertyConfig(moduleConfig, "since", Date.class, new DatePropertyFieldFactory());
sinceProp.setReadOnly(true); sinceProp.setReadOnly(true);
moduleConfig.addProperty(idProp); moduleConfig.addProperty(idProp);
moduleConfig.addProperty(nameProp); moduleConfig.addProperty(nameProp);

View File

@ -5,6 +5,7 @@ import java.util.Date;
import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyConfig;
import de.hsadmin.web.config.PropertyTableColumn; import de.hsadmin.web.config.PropertyTableColumn;
import de.hsadmin.web.vaadin.DatePropertyFieldFactory;
public class DomainReadonlyModule extends AbstractModule { public class DomainReadonlyModule extends AbstractModule {
@ -20,7 +21,7 @@ public class DomainReadonlyModule extends AbstractModule {
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class, PropertyTableColumn.HIDDEN)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class, PropertyTableColumn.HIDDEN));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "since", Date.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "since", Date.class, new DatePropertyFieldFactory()));
} }
@Override @Override

View File

@ -22,7 +22,6 @@ import com.vaadin.ui.Component;
import com.vaadin.ui.Embedded; import com.vaadin.ui.Embedded;
import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Link; import com.vaadin.ui.Link;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TabSheet; import com.vaadin.ui.TabSheet;
import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window; import com.vaadin.ui.Window;
@ -166,6 +165,7 @@ public class MainApplication extends Application implements HttpServletRequestLi
try { try {
module.reload(); module.reload();
} catch (HsarwebException e) { } catch (HsarwebException e) {
e.printStackTrace();
showSystemException(e); showSystemException(e);
} }
} }

View File

@ -0,0 +1,22 @@
package de.hsadmin.web;
public class MysqlDatabaseModule extends DatabaseModule {
private static final long serialVersionUID = 1L;
@Override
public String[] getEncodings() {
return new String[] { "utf8", "latin1" };
}
@Override
public String getModuleIdent() {
return "mysqldb";
}
@Override
public String getUserModuleIdent() {
return "mysqluser";
}
}

View File

@ -0,0 +1,12 @@
package de.hsadmin.web;
public class MysqlUserModule extends DatabaseUserModule {
private static final long serialVersionUID = 1L;
@Override
public String getModuleIdent() {
return "mysqluser";
}
}

View File

@ -5,6 +5,7 @@ import java.util.Date;
import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyConfig;
import de.hsadmin.web.config.PropertyTableColumn; import de.hsadmin.web.config.PropertyTableColumn;
import de.hsadmin.web.vaadin.DatePropertyFieldFactory;
public class PacketReadonlyModule extends AbstractModule { public class PacketReadonlyModule extends AbstractModule {
@ -21,7 +22,7 @@ public class PacketReadonlyModule extends AbstractModule {
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "components", String.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "components", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "curinetaddr", String.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "curinetaddr", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "created", Date.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "created", Date.class, new DatePropertyFieldFactory()));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "customer", String.class, PropertyTableColumn.HIDDEN)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "customer", String.class, PropertyTableColumn.HIDDEN));
} }

View File

@ -0,0 +1,22 @@
package de.hsadmin.web;
public class PgsqlDatabaseModule extends DatabaseModule {
private static final long serialVersionUID = 1L;
@Override
public String[] getEncodings() {
return new String[] { "UTF-8", "LATIN1" };
}
@Override
public String getModuleIdent() {
return "postgresqldb";
}
@Override
public String getUserModuleIdent() {
return "postgresqluser";
}
}

View File

@ -0,0 +1,12 @@
package de.hsadmin.web;
public class PgsqlUserModule extends DatabaseUserModule {
private static final long serialVersionUID = 1L;
@Override
public String getModuleIdent() {
return "postgresqluser";
}
}

View File

@ -5,6 +5,7 @@ import java.util.Date;
import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyConfig;
import de.hsadmin.web.config.PropertyTableColumn; import de.hsadmin.web.config.PropertyTableColumn;
import de.hsadmin.web.vaadin.DatePropertyFieldFactory;
public class QueueTaskModule extends AbstractModule { public class QueueTaskModule extends AbstractModule {
@ -18,8 +19,8 @@ public class QueueTaskModule extends AbstractModule {
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "title", String.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "title", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "status", String.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "status", String.class));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "started", Date.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "started", Date.class, new DatePropertyFieldFactory()));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "finished", Date.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "finished", Date.class, new DatePropertyFieldFactory()));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class, PropertyTableColumn.HIDDEN)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class, PropertyTableColumn.HIDDEN));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "details", String.class, PropertyTableColumn.HIDDEN)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "details", String.class, PropertyTableColumn.HIDDEN));
moduleConfig.addProperty(new PropertyConfig(moduleConfig, "exception", String.class, PropertyTableColumn.HIDDEN)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "exception", String.class, PropertyTableColumn.HIDDEN));

View File

@ -0,0 +1,70 @@
package de.hsadmin.web.vaadin;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
import com.vaadin.data.Property.ConversionException;
import com.vaadin.data.Property.ReadOnlyException;
import com.vaadin.terminal.Sizeable;
import com.vaadin.ui.DateField;
import com.vaadin.ui.PopupDateField;
import de.hsadmin.web.config.PropertyConfig;
import de.hsadmin.web.config.PropertyFieldFactory;
public class DatePropertyFieldFactory implements PropertyFieldFactory {
public static final DateFormat serverDf = DateFormat.getDateInstance(DateFormat.SHORT);
private boolean readOnly = false;
private boolean writeOnce;
@Override
public Object createFieldComponent(PropertyConfig prop, Object value) {
DateField dateField = new PopupDateField(prop.getLabel());
dateField.setDateFormat("dd.MM.yyyy");
dateField.setData(prop.getId());
dateField.setWidth(480.0f, Sizeable.UNITS_PIXELS);
try {
if (value != null) {
dateField.setValue(serverDf.parse((String) value));
dateField.setReadOnly(isReadOnly());
return dateField;
}
} catch (ReadOnlyException e) {
} catch (ConversionException e) {
} catch (ParseException e) {
}
dateField.setReadOnly(isReadOnly());
return dateField;
}
@Override
public String getValue(PropertyConfig prop, Object component) {
if (component instanceof DateField) {
return serverDf.format((Date) ((DateField) component).getValue());
}
return null;
}
@Override
public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}
public boolean isReadOnly() {
return readOnly;
}
@Override
public void setWriteOnce(boolean writeOnce) {
this.writeOnce = writeOnce;
}
@Override
public boolean isWriteOnce() {
return writeOnce;
}
}

View File

@ -11,6 +11,6 @@ logo.link=https://www.hostsharing.net/logo.png
modules.NONE=de.hsadmin.web.HomeModule modules.NONE=de.hsadmin.web.HomeModule
modules.USER=de.hsadmin.web.HomeModule modules.USER=de.hsadmin.web.HomeModule
modules.DOM_ADMIN=de.hsadmin.web.DomainReadonlyModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.HomeModule modules.DOM_ADMIN=de.hsadmin.web.DomainReadonlyModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.HomeModule
modules.PAC_ADMIN=de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.QueueTaskModule modules.PAC_ADMIN=de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.MysqlDatabaseModule,de.hsadmin.web.MysqlUserModule,de.hsadmin.web.PgsqlDatabaseModule,de.hsadmin.web.PgsqlUserModule,de.hsadmin.web.QueueTaskModule
modules.CUSTOMER=de.hsadmin.web.PacketReadonlyModule,de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.QueueTaskModule modules.CUSTOMER=de.hsadmin.web.PacketReadonlyModule,de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.MysqlDatabaseModule,de.hsadmin.web.MysqlUserModule,de.hsadmin.web.PgsqlDatabaseModule,de.hsadmin.web.PgsqlUserModule,de.hsadmin.web.QueueTaskModule
modules.HOSTMASTER=de.hsadmin.web.PacketReadonlyModule,de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.QueueTaskModule modules.HOSTMASTER=de.hsadmin.web.PacketReadonlyModule,de.hsadmin.web.UnixUserModule,de.hsadmin.web.DomainModule,de.hsadmin.web.EMailAddressModule,de.hsadmin.web.EMailAliasModule,de.hsadmin.web.MysqlDatabaseModule,de.hsadmin.web.MysqlUserModule,de.hsadmin.web.PgsqlDatabaseModule,de.hsadmin.web.PgsqlUserModule,de.hsadmin.web.QueueTaskModule

View File

@ -0,0 +1,9 @@
id=identifier
name=database
pac=packet
encoding=encoding
owner=owner
moduletitle=mysql db
new=create db
update=update db
moduleicon=../hs/icons/table.png

View File

@ -0,0 +1,9 @@
id=Schlüssel
name=MySQL Datenbank
pac=Paket
encoding=Zeichensatz
owner=Verwalter
moduletitle=MySQL DB
new=Datenbank anlegen
update=Datenbank ändern
moduleicon=../hs/icons/table.png

View File

@ -0,0 +1,10 @@
id=identifier
name=database username
password=password
password1=new password
password2=repeat password
pac=packet
moduletitle=mysql user
new=create user
update=change password
moduleicon=../hs/icons/table_key.png

View File

@ -0,0 +1,10 @@
id=Schlüssel
name=MySQL User
password=Passwort
password1=neues Passwort
password2=Passwort-Wiederholung
pac=Paket
moduletitle=MySQL User
new=User anlegen
update=Passwort ändern
moduleicon=../hs/icons/table_key.png

View File

@ -1,7 +1,7 @@
id=identifier id=identifier
name=packet name=packet
curinetaddr=inet address curinetaddr=inet address
created=created created=created on
basepac=packet type basepac=packet type
components=packet options components=packet options
hive=host hive=host

View File

@ -1,7 +1,7 @@
id=Schlüssel id=Schlüssel
name=Paket name=Paket
curinetaddr=IP Adresse curinetaddr=IP Adresse
created=angelegt created=angelegt am
basepac=Pakettyp basepac=Pakettyp
components=Paket-Optionen components=Paket-Optionen
hive=Server hive=Server

View File

@ -0,0 +1,9 @@
id=identifier
name=database
pac=packet
encoding=encoding
owner=owner
moduletitle=postgresql db
new=create db
update=database
moduleicon=../hs/icons/database.png

View File

@ -0,0 +1,9 @@
id=Schlüssel
name=Datenbank
pac=Paket
encoding=Zeichensatz
owner=Verwalter
moduletitle=PostgreSQL DB
new=Datenbank anlegen
update=Datenbank
moduleicon=../hs/icons/database.png

View File

@ -0,0 +1,10 @@
id=identifier
name=postgres username
password=password
password1=new password
password2=repeat password
pac=packet
moduletitle=postgres user
new=create user
update=change password
moduleicon=../hs/icons/database_key.png

View File

@ -0,0 +1,10 @@
id=Schlüssel
name=PostgreSQL User
password=Passwort
password1=neues Passwort
password2=Passwort-Wiederholung
pac=Paket
moduletitle=PostgreSQL User
new=User anlegen
update=Passwort ändern
moduleicon=../hs/icons/database_key.png