introduce annotated class property on AbstractRemote
pac is readonly property
This commit is contained in:
parent
fa75194cf3
commit
041111d845
@ -18,7 +18,9 @@ import javax.persistence.Temporal;
|
|||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
import de.hsadmin.core.model.AbstractEntity;
|
import de.hsadmin.core.model.AbstractEntity;
|
||||||
|
import de.hsadmin.core.model.AnnFieldIO;
|
||||||
import de.hsadmin.core.model.AnnModuleImpl;
|
import de.hsadmin.core.model.AnnModuleImpl;
|
||||||
|
import de.hsadmin.core.model.ReadWriteAccess;
|
||||||
import de.hsadmin.mods.qstat.QTaskModuleImpl;
|
import de.hsadmin.mods.qstat.QTaskModuleImpl;
|
||||||
import de.hsadmin.mods.user.UnixUser;
|
import de.hsadmin.mods.user.UnixUser;
|
||||||
|
|
||||||
@ -35,26 +37,32 @@ public class QueueTask extends AbstractEntity implements Serializable {
|
|||||||
@Column(name = "task_id", columnDefinition = "integer")
|
@Column(name = "task_id", columnDefinition = "integer")
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
|
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
|
||||||
@JoinColumn(name="user_id", columnDefinition="integer", nullable=true)
|
@JoinColumn(name="user_id", columnDefinition="integer", nullable=true)
|
||||||
@ManyToOne(fetch=FetchType.EAGER)
|
@ManyToOne(fetch=FetchType.EAGER)
|
||||||
private UnixUser user;
|
private UnixUser user;
|
||||||
|
|
||||||
|
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
|
||||||
@Column(name = "started", columnDefinition = "date")
|
@Column(name = "started", columnDefinition = "date")
|
||||||
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
|
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
|
||||||
private Date started;
|
private Date started;
|
||||||
|
|
||||||
|
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
|
||||||
@Column(name = "finished", columnDefinition = "date", nullable = true)
|
@Column(name = "finished", columnDefinition = "date", nullable = true)
|
||||||
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
|
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
|
||||||
private Date finished;
|
private Date finished;
|
||||||
|
|
||||||
|
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
|
||||||
@Column(name = "title", columnDefinition = "character varying(192)")
|
@Column(name = "title", columnDefinition = "character varying(192)")
|
||||||
private String title;
|
private String title;
|
||||||
|
|
||||||
|
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
|
||||||
@Column(name = "details", columnDefinition = "text", nullable = true)
|
@Column(name = "details", columnDefinition = "text", nullable = true)
|
||||||
private String details;
|
private String details;
|
||||||
|
|
||||||
private Processor proc;
|
private Processor proc;
|
||||||
|
|
||||||
|
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
|
||||||
@Column(name = "exception", columnDefinition = "text", nullable = true)
|
@Column(name = "exception", columnDefinition = "text", nullable = true)
|
||||||
private String exception;
|
private String exception;
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class EMailAlias extends AbstractEntity implements Serializable {
|
|||||||
|
|
||||||
@ManyToOne()
|
@ManyToOne()
|
||||||
@JoinColumn(name = "pac_id", columnDefinition = "integer")
|
@JoinColumn(name = "pac_id", columnDefinition = "integer")
|
||||||
@AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.WRITEONCE)
|
@AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.READONLY)
|
||||||
private Pac pac;
|
private Pac pac;
|
||||||
|
|
||||||
@AnnFieldIO(validation="[a-z0-9\\_\\-\\.\\+]*", rw=ReadWriteAccess.WRITEONCE)
|
@AnnFieldIO(validation="[a-z0-9\\_\\-\\.\\+]*", rw=ReadWriteAccess.WRITEONCE)
|
||||||
|
@ -48,7 +48,7 @@ public class UnixUser extends AbstractEntity implements Serializable {
|
|||||||
@Transient
|
@Transient
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.WRITEONCE)
|
@AnnFieldIO(validation="[a-z0-9]*", rw=ReadWriteAccess.READONLY)
|
||||||
@JoinColumn(name = "packet_id", columnDefinition = "integer", updatable=false)
|
@JoinColumn(name = "packet_id", columnDefinition = "integer", updatable=false)
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
private Pac pac;
|
private Pac pac;
|
||||||
@ -65,7 +65,7 @@ public class UnixUser extends AbstractEntity implements Serializable {
|
|||||||
@Column(name = "homedir", columnDefinition = "character varying(48)", updatable=false)
|
@Column(name = "homedir", columnDefinition = "character varying(48)", updatable=false)
|
||||||
private String homedir;
|
private String homedir;
|
||||||
|
|
||||||
@AnnFieldIO(rw=ReadWriteAccess.READWRITE)
|
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
|
||||||
@Column(name = "locked", columnDefinition = "boolean")
|
@Column(name = "locked", columnDefinition = "boolean")
|
||||||
private boolean locked;
|
private boolean locked;
|
||||||
|
|
||||||
|
@ -21,6 +21,10 @@ public abstract class AbstractRemote implements IRemote {
|
|||||||
|
|
||||||
protected abstract Class<? extends AbstractEntity> getEntityClass();
|
protected abstract Class<? extends AbstractEntity> getEntityClass();
|
||||||
|
|
||||||
|
protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
|
||||||
|
return getEntityClass();
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void entity2map(Transaction tx, AbstractEntity entity, Map<String, Object> resultMap);
|
protected abstract void entity2map(Transaction tx, AbstractEntity entity, Map<String, Object> resultMap);
|
||||||
|
|
||||||
protected abstract void map2entity(Transaction tx, Map<String, Object> setParams, AbstractEntity entity) throws HSAdminException;
|
protected abstract void map2entity(Transaction tx, Map<String, Object> setParams, AbstractEntity entity) throws HSAdminException;
|
||||||
|
@ -4,6 +4,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import de.hsadmin.core.model.AbstractEntity;
|
import de.hsadmin.core.model.AbstractEntity;
|
||||||
import de.hsadmin.core.model.Transaction;
|
import de.hsadmin.core.model.Transaction;
|
||||||
|
import de.hsadmin.mods.db.Database;
|
||||||
import de.hsadmin.mods.db.MySqlDatabase;
|
import de.hsadmin.mods.db.MySqlDatabase;
|
||||||
|
|
||||||
public class MysqlDbRemote extends AbstractRemote {
|
public class MysqlDbRemote extends AbstractRemote {
|
||||||
@ -27,6 +28,11 @@ public class MysqlDbRemote extends AbstractRemote {
|
|||||||
map.put("encoding", encoding);
|
map.put("encoding", encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
|
||||||
|
return Database.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<? extends AbstractEntity> getEntityClass() {
|
protected Class<? extends AbstractEntity> getEntityClass() {
|
||||||
return MySqlDatabase.class;
|
return MySqlDatabase.class;
|
||||||
|
@ -4,6 +4,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import de.hsadmin.core.model.AbstractEntity;
|
import de.hsadmin.core.model.AbstractEntity;
|
||||||
import de.hsadmin.core.model.Transaction;
|
import de.hsadmin.core.model.Transaction;
|
||||||
|
import de.hsadmin.mods.db.DatabaseUser;
|
||||||
import de.hsadmin.mods.db.MySqlUser;
|
import de.hsadmin.mods.db.MySqlUser;
|
||||||
|
|
||||||
public class MysqlUserRemote extends AbstractRemote {
|
public class MysqlUserRemote extends AbstractRemote {
|
||||||
@ -23,6 +24,11 @@ public class MysqlUserRemote extends AbstractRemote {
|
|||||||
map.put("instance", instance);
|
map.put("instance", instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
|
||||||
|
return DatabaseUser.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<? extends AbstractEntity> getEntityClass() {
|
protected Class<? extends AbstractEntity> getEntityClass() {
|
||||||
return MySqlUser.class;
|
return MySqlUser.class;
|
||||||
|
@ -4,6 +4,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import de.hsadmin.core.model.AbstractEntity;
|
import de.hsadmin.core.model.AbstractEntity;
|
||||||
import de.hsadmin.core.model.Transaction;
|
import de.hsadmin.core.model.Transaction;
|
||||||
|
import de.hsadmin.mods.db.Database;
|
||||||
import de.hsadmin.mods.db.PgSqlDatabase;
|
import de.hsadmin.mods.db.PgSqlDatabase;
|
||||||
|
|
||||||
public class PgsqlDbRemote extends AbstractRemote {
|
public class PgsqlDbRemote extends AbstractRemote {
|
||||||
@ -27,6 +28,11 @@ public class PgsqlDbRemote extends AbstractRemote {
|
|||||||
map.put("encoding", encoding);
|
map.put("encoding", encoding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
|
||||||
|
return Database.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<? extends AbstractEntity> getEntityClass() {
|
protected Class<? extends AbstractEntity> getEntityClass() {
|
||||||
return PgSqlDatabase.class;
|
return PgSqlDatabase.class;
|
||||||
|
@ -4,6 +4,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import de.hsadmin.core.model.AbstractEntity;
|
import de.hsadmin.core.model.AbstractEntity;
|
||||||
import de.hsadmin.core.model.Transaction;
|
import de.hsadmin.core.model.Transaction;
|
||||||
|
import de.hsadmin.mods.db.DatabaseUser;
|
||||||
import de.hsadmin.mods.db.PgSqlUser;
|
import de.hsadmin.mods.db.PgSqlUser;
|
||||||
|
|
||||||
public class PgsqlUserRemote extends AbstractRemote {
|
public class PgsqlUserRemote extends AbstractRemote {
|
||||||
@ -23,6 +24,11 @@ public class PgsqlUserRemote extends AbstractRemote {
|
|||||||
map.put("instance", instance);
|
map.put("instance", instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
|
||||||
|
return DatabaseUser.class;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Class<? extends AbstractEntity> getEntityClass() {
|
protected Class<? extends AbstractEntity> getEntityClass() {
|
||||||
return PgSqlUser.class;
|
return PgSqlUser.class;
|
||||||
|
@ -33,7 +33,7 @@ public class PropertyRemote implements IRemote {
|
|||||||
Object newInstance = remoteClass.newInstance();
|
Object newInstance = remoteClass.newInstance();
|
||||||
if (newInstance instanceof AbstractRemote) {
|
if (newInstance instanceof AbstractRemote) {
|
||||||
AbstractRemote remote = (AbstractRemote) newInstance;
|
AbstractRemote remote = (AbstractRemote) newInstance;
|
||||||
Class<? extends AbstractEntity> entityClass = remote.getEntityClass();
|
Class<? extends AbstractEntity> entityClass = remote.getAnnotatedEntityClass();
|
||||||
for (Field f: entityClass.getDeclaredFields()) {
|
for (Field f: entityClass.getDeclaredFields()) {
|
||||||
AnnFieldIO fieldIO = f.getAnnotation(AnnFieldIO.class);
|
AnnFieldIO fieldIO = f.getAnnotation(AnnFieldIO.class);
|
||||||
if (fieldIO != null) {
|
if (fieldIO != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user