introduce annotated class property on AbstractRemote

pac is readonly property
This commit is contained in:
Peter Hormanns 2015-09-11 17:26:42 +02:00
parent fa75194cf3
commit 041111d845
9 changed files with 40 additions and 4 deletions

View File

@ -18,7 +18,9 @@ import javax.persistence.Temporal;
import javax.persistence.Transient;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AnnFieldIO;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.core.model.ReadWriteAccess;
import de.hsadmin.mods.qstat.QTaskModuleImpl;
import de.hsadmin.mods.user.UnixUser;
@ -35,26 +37,32 @@ public class QueueTask extends AbstractEntity implements Serializable {
@Column(name = "task_id", columnDefinition = "integer")
private long id;
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
@JoinColumn(name="user_id", columnDefinition="integer", nullable=true)
@ManyToOne(fetch=FetchType.EAGER)
private UnixUser user;
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
@Column(name = "started", columnDefinition = "date")
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date started;
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
@Column(name = "finished", columnDefinition = "date", nullable = true)
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
private Date finished;
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
@Column(name = "title", columnDefinition = "character varying(192)")
private String title;
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
@Column(name = "details", columnDefinition = "text", nullable = true)
private String details;
private Processor proc;
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
@Column(name = "exception", columnDefinition = "text", nullable = true)
private String exception;

View File

@ -45,7 +45,7 @@ public class EMailAlias extends AbstractEntity implements Serializable {
@ManyToOne()
@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;
@AnnFieldIO(validation="[a-z0-9\\_\\-\\.\\+]*", rw=ReadWriteAccess.WRITEONCE)

View File

@ -48,7 +48,7 @@ public class UnixUser extends AbstractEntity implements Serializable {
@Transient
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)
@ManyToOne(fetch = FetchType.LAZY)
private Pac pac;
@ -65,7 +65,7 @@ public class UnixUser extends AbstractEntity implements Serializable {
@Column(name = "homedir", columnDefinition = "character varying(48)", updatable=false)
private String homedir;
@AnnFieldIO(rw=ReadWriteAccess.READWRITE)
@AnnFieldIO(rw=ReadWriteAccess.READONLY)
@Column(name = "locked", columnDefinition = "boolean")
private boolean locked;

View File

@ -21,6 +21,10 @@ public abstract class AbstractRemote implements IRemote {
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 map2entity(Transaction tx, Map<String, Object> setParams, AbstractEntity entity) throws HSAdminException;

View File

@ -4,6 +4,7 @@ import java.util.Map;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.Transaction;
import de.hsadmin.mods.db.Database;
import de.hsadmin.mods.db.MySqlDatabase;
public class MysqlDbRemote extends AbstractRemote {
@ -27,6 +28,11 @@ public class MysqlDbRemote extends AbstractRemote {
map.put("encoding", encoding);
}
@Override
protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
return Database.class;
}
@Override
protected Class<? extends AbstractEntity> getEntityClass() {
return MySqlDatabase.class;

View File

@ -4,6 +4,7 @@ import java.util.Map;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.Transaction;
import de.hsadmin.mods.db.DatabaseUser;
import de.hsadmin.mods.db.MySqlUser;
public class MysqlUserRemote extends AbstractRemote {
@ -23,6 +24,11 @@ public class MysqlUserRemote extends AbstractRemote {
map.put("instance", instance);
}
@Override
protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
return DatabaseUser.class;
}
@Override
protected Class<? extends AbstractEntity> getEntityClass() {
return MySqlUser.class;

View File

@ -4,6 +4,7 @@ import java.util.Map;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.Transaction;
import de.hsadmin.mods.db.Database;
import de.hsadmin.mods.db.PgSqlDatabase;
public class PgsqlDbRemote extends AbstractRemote {
@ -27,6 +28,11 @@ public class PgsqlDbRemote extends AbstractRemote {
map.put("encoding", encoding);
}
@Override
protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
return Database.class;
}
@Override
protected Class<? extends AbstractEntity> getEntityClass() {
return PgSqlDatabase.class;

View File

@ -4,6 +4,7 @@ import java.util.Map;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.Transaction;
import de.hsadmin.mods.db.DatabaseUser;
import de.hsadmin.mods.db.PgSqlUser;
public class PgsqlUserRemote extends AbstractRemote {
@ -23,6 +24,11 @@ public class PgsqlUserRemote extends AbstractRemote {
map.put("instance", instance);
}
@Override
protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
return DatabaseUser.class;
}
@Override
protected Class<? extends AbstractEntity> getEntityClass() {
return PgSqlUser.class;

View File

@ -33,7 +33,7 @@ public class PropertyRemote implements IRemote {
Object newInstance = remoteClass.newInstance();
if (newInstance instanceof AbstractRemote) {
AbstractRemote remote = (AbstractRemote) newInstance;
Class<? extends AbstractEntity> entityClass = remote.getEntityClass();
Class<? extends AbstractEntity> entityClass = remote.getAnnotatedEntityClass();
for (Field f: entityClass.getDeclaredFields()) {
AnnFieldIO fieldIO = f.getAnnotation(AnnFieldIO.class);
if (fieldIO != null) {