From 041111d8459fa1617f9f7608a01764a3251eeb52 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Fri, 11 Sep 2015 17:26:42 +0200
Subject: [PATCH] introduce annotated class property on AbstractRemote pac is readonly property

---
 hsarback/src/de/hsadmin/mods/email/EMailAlias.java  |    2 +-
 hsarback/src/de/hsadmin/mods/user/UnixUser.java     |    4 ++--
 hsarback/src/de/hsadmin/remote/MysqlDbRemote.java   |    6 ++++++
 hsarback/src/de/hsadmin/remote/MysqlUserRemote.java |    6 ++++++
 hsarback/src/de/hsadmin/remote/PgsqlUserRemote.java |    6 ++++++
 hsarback/src/de/hsadmin/remote/PropertyRemote.java  |    2 +-
 hsarback/src/de/hsadmin/core/qserv/QueueTask.java   |    8 ++++++++
 hsarback/src/de/hsadmin/remote/PgsqlDbRemote.java   |    6 ++++++
 hsarback/src/de/hsadmin/remote/AbstractRemote.java  |    4 ++++
 9 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/hsarback/src/de/hsadmin/core/qserv/QueueTask.java b/hsarback/src/de/hsadmin/core/qserv/QueueTask.java
index 8b0b310..23cc72c 100644
--- a/hsarback/src/de/hsadmin/core/qserv/QueueTask.java
+++ b/hsarback/src/de/hsadmin/core/qserv/QueueTask.java
@@ -18,7 +18,9 @@
 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 @@
 	@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;
 
diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAlias.java b/hsarback/src/de/hsadmin/mods/email/EMailAlias.java
index f494555..1390d6f 100644
--- a/hsarback/src/de/hsadmin/mods/email/EMailAlias.java
+++ b/hsarback/src/de/hsadmin/mods/email/EMailAlias.java
@@ -45,7 +45,7 @@
 
 	@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)
diff --git a/hsarback/src/de/hsadmin/mods/user/UnixUser.java b/hsarback/src/de/hsadmin/mods/user/UnixUser.java
index d71daf1..2653103 100644
--- a/hsarback/src/de/hsadmin/mods/user/UnixUser.java
+++ b/hsarback/src/de/hsadmin/mods/user/UnixUser.java
@@ -48,7 +48,7 @@
 	@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 @@
 	@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;
 
diff --git a/hsarback/src/de/hsadmin/remote/AbstractRemote.java b/hsarback/src/de/hsadmin/remote/AbstractRemote.java
index fd19c68..1f7bf91 100644
--- a/hsarback/src/de/hsadmin/remote/AbstractRemote.java
+++ b/hsarback/src/de/hsadmin/remote/AbstractRemote.java
@@ -21,6 +21,10 @@
 
 	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;
diff --git a/hsarback/src/de/hsadmin/remote/MysqlDbRemote.java b/hsarback/src/de/hsadmin/remote/MysqlDbRemote.java
index c6d3d7a..107e10a 100644
--- a/hsarback/src/de/hsadmin/remote/MysqlDbRemote.java
+++ b/hsarback/src/de/hsadmin/remote/MysqlDbRemote.java
@@ -4,6 +4,7 @@
 
 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 {
@@ -28,6 +29,11 @@
 	}
 
 	@Override
+	protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
+		return Database.class;
+	}
+
+	@Override
 	protected Class<? extends AbstractEntity> getEntityClass() {
 		return MySqlDatabase.class;
 	}
diff --git a/hsarback/src/de/hsadmin/remote/MysqlUserRemote.java b/hsarback/src/de/hsadmin/remote/MysqlUserRemote.java
index 3990843..781c6e1 100644
--- a/hsarback/src/de/hsadmin/remote/MysqlUserRemote.java
+++ b/hsarback/src/de/hsadmin/remote/MysqlUserRemote.java
@@ -4,6 +4,7 @@
 
 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 {
@@ -24,6 +25,11 @@
 	}
 
 	@Override
+	protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
+		return DatabaseUser.class;
+	}
+
+	@Override
 	protected Class<? extends AbstractEntity> getEntityClass() {
 		return MySqlUser.class;
 	}
diff --git a/hsarback/src/de/hsadmin/remote/PgsqlDbRemote.java b/hsarback/src/de/hsadmin/remote/PgsqlDbRemote.java
index b0046a3..129e899 100644
--- a/hsarback/src/de/hsadmin/remote/PgsqlDbRemote.java
+++ b/hsarback/src/de/hsadmin/remote/PgsqlDbRemote.java
@@ -4,6 +4,7 @@
 
 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 {
@@ -28,6 +29,11 @@
 	}
 
 	@Override
+	protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
+		return Database.class;
+	}
+
+	@Override
 	protected Class<? extends AbstractEntity> getEntityClass() {
 		return PgSqlDatabase.class;
 	}
diff --git a/hsarback/src/de/hsadmin/remote/PgsqlUserRemote.java b/hsarback/src/de/hsadmin/remote/PgsqlUserRemote.java
index fce99bb..2b59455 100644
--- a/hsarback/src/de/hsadmin/remote/PgsqlUserRemote.java
+++ b/hsarback/src/de/hsadmin/remote/PgsqlUserRemote.java
@@ -4,6 +4,7 @@
 
 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 {
@@ -24,6 +25,11 @@
 	}
 
 	@Override
+	protected Class<? extends AbstractEntity> getAnnotatedEntityClass() {
+		return DatabaseUser.class;
+	}
+
+	@Override
 	protected Class<? extends AbstractEntity> getEntityClass() {
 		return PgSqlUser.class;
 	}
diff --git a/hsarback/src/de/hsadmin/remote/PropertyRemote.java b/hsarback/src/de/hsadmin/remote/PropertyRemote.java
index 6d924aa..2f84044 100644
--- a/hsarback/src/de/hsadmin/remote/PropertyRemote.java
+++ b/hsarback/src/de/hsadmin/remote/PropertyRemote.java
@@ -33,7 +33,7 @@
 					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) {

--
Gitblit v1.9.0-SNAPSHOT