Arbeit am member-Modul
This commit is contained in:
parent
4dd9894b86
commit
a6c4debb06
@ -13,7 +13,7 @@ import java.util.Map;
|
||||
|
||||
import de.hsadmin.cliClientConnector.CLIClientConnectorServlet.FunctionNotKnownException;
|
||||
import de.hsadmin.cliClientConnector.CLIClientConnectorServlet.UnknownModuleException;
|
||||
import de.hsadmin.core.model.Entity;
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.core.model.ModuleInterface;
|
||||
|
||||
/**
|
||||
@ -98,7 +98,7 @@ public class ArgumentParser {
|
||||
} else if( type.equals("java.util.Set") ) {
|
||||
val = "<Set>";
|
||||
} else try {
|
||||
Entity v = (Entity)value;
|
||||
AbstractEntity v = (AbstractEntity)value;
|
||||
val = v.createStringKey();
|
||||
if( deep && !foundObjects.contains(v) ) {
|
||||
foundObjects.add(v);
|
||||
|
@ -16,7 +16,7 @@ import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import de.hsadmin.core.model.Entity;
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.core.model.GenericModuleImpl;
|
||||
import de.hsadmin.core.model.ModuleInterface;
|
||||
import de.hsadmin.core.model.TicketAuthentication;
|
||||
@ -210,7 +210,7 @@ public class CLIClientConnectorServlet extends HttpServlet {
|
||||
String kname = hasGetter(eType, k);
|
||||
if (kname != null) {
|
||||
rval += (first ? "" : " and ")
|
||||
+ "(obj." + Entity.escapeString(kname) + " = '" + Entity.escapeString(where.get(k)) + "')";
|
||||
+ "(obj." + AbstractEntity.escapeString(kname) + " = '" + AbstractEntity.escapeString(where.get(k)) + "')";
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
@ -250,7 +250,7 @@ public class CLIClientConnectorServlet extends HttpServlet {
|
||||
Transaction transaction = module.getTransaction();
|
||||
transaction.beginTransaction();
|
||||
try {
|
||||
Method m = module.getClass().getMethod("add", Entity.class);
|
||||
Method m = module.getClass().getMethod("add", AbstractEntity.class);
|
||||
Object o = cls.newInstance();
|
||||
setValues(o, set, module);
|
||||
m.invoke(module, o);
|
||||
@ -278,11 +278,11 @@ public class CLIClientConnectorServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
// / checks wheather all 'oids' are in 'list'
|
||||
private void checkOids(List<Entity> list, List<String> oids) {
|
||||
private void checkOids(List<AbstractEntity> list, List<String> oids) {
|
||||
List<String> oidsNotFound = new ArrayList<String>();
|
||||
for (String id : oids) {
|
||||
boolean found = false;
|
||||
for (Entity e : list) {
|
||||
for (AbstractEntity e : list) {
|
||||
String foundKey = e.createStringKey();
|
||||
if (foundKey.equals(id)) {
|
||||
found = true;
|
||||
@ -310,12 +310,12 @@ public class CLIClientConnectorServlet extends HttpServlet {
|
||||
try {
|
||||
Method m = module.getClass().getMethod("search", Class.class,
|
||||
String.class, String.class);
|
||||
List<Entity> list = (List<Entity>) m.invoke(module, cls,
|
||||
List<AbstractEntity> list = (List<AbstractEntity>) m.invoke(module, cls,
|
||||
buildQuery(cls, where, oids), null);
|
||||
checkOids(list, oids);
|
||||
Method m2 = module.getClass().getMethod("update", Entity.class);
|
||||
Method m2 = module.getClass().getMethod("update", AbstractEntity.class);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Entity entity = list.get(i);
|
||||
AbstractEntity entity = list.get(i);
|
||||
tx.detach(entity);
|
||||
setValues(entity, set, module);
|
||||
m2.invoke(module, entity);
|
||||
@ -341,10 +341,10 @@ public class CLIClientConnectorServlet extends HttpServlet {
|
||||
try {
|
||||
Method m =
|
||||
module.getClass().getMethod("search", Class.class, String.class, String.class);
|
||||
List<Entity> list =
|
||||
(List<Entity>) m.invoke(module, cls, buildQuery(cls, where, oids), null);
|
||||
List<AbstractEntity> list =
|
||||
(List<AbstractEntity>) m.invoke(module, cls, buildQuery(cls, where, oids), null);
|
||||
checkOids(list, oids);
|
||||
Method m2 = module.getClass().getMethod("delete", Entity.class);
|
||||
Method m2 = module.getClass().getMethod("delete", AbstractEntity.class);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Object o = list.get(i);
|
||||
m2.invoke(module, o);
|
||||
|
@ -9,7 +9,7 @@ import javax.persistence.EntityManager;
|
||||
|
||||
import de.hsadmin.mods.user.UnixUser;
|
||||
|
||||
public abstract class Entity {
|
||||
public abstract class AbstractEntity {
|
||||
|
||||
/**
|
||||
* trims whitespace from both ends, but a null remains null.
|
||||
@ -137,7 +137,7 @@ public abstract class Entity {
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public boolean sameIdAs(Entity entity) {
|
||||
public boolean sameIdAs(AbstractEntity entity) {
|
||||
if (entity == null)
|
||||
return false;
|
||||
if (getClass() != entity.getClass())
|
||||
@ -183,7 +183,7 @@ public abstract class Entity {
|
||||
* @param em
|
||||
* @param loginUser
|
||||
*/
|
||||
public Entity merge(EntityManager em, UnixUser loginUser) {
|
||||
public AbstractEntity merge(EntityManager em, UnixUser loginUser) {
|
||||
return em.merge(this);
|
||||
}
|
||||
|
||||
@ -228,7 +228,7 @@ public abstract class Entity {
|
||||
* JBoss 5.1.
|
||||
* This is just for testing, it does not use the proper class loader!
|
||||
*/
|
||||
public <T extends Entity> T replicate() {
|
||||
public <T extends AbstractEntity> T replicate() {
|
||||
try {
|
||||
ByteArrayOutputStream baOut = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oOut = new ObjectOutputStream(baOut);
|
@ -39,7 +39,7 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
* @return
|
||||
*/
|
||||
private String restrict(Class<?> entityClass, UnixUser loginUser, String condition) {
|
||||
String restriction = Entity.restriction(entityClass, loginUser);
|
||||
String restriction = AbstractEntity.restriction(entityClass, loginUser);
|
||||
if (restriction == null)
|
||||
return condition;
|
||||
if (condition != null && condition.length() > 0)
|
||||
@ -53,13 +53,13 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
return transaction;
|
||||
}
|
||||
|
||||
public Entity initialize(Entity newEntity)
|
||||
public AbstractEntity initialize(AbstractEntity newEntity)
|
||||
throws AuthorisationException {
|
||||
newEntity.initialize(transaction.getEntityManager(), getLoginUser());
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
public Entity add(Entity newEntity) throws HSAdminException {
|
||||
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
|
||||
// get the user who is logged in
|
||||
UnixUser loginUser = getLoginUser();
|
||||
|
||||
@ -95,8 +95,8 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
public Entity find(Class<? extends Entity> entityClass, Object key) throws HSAdminException {
|
||||
Entity entity = transaction.getEntityManager().find(entityClass, key);
|
||||
public AbstractEntity find(Class<? extends AbstractEntity> entityClass, Object key) throws HSAdminException {
|
||||
AbstractEntity entity = transaction.getEntityManager().find(entityClass, key);
|
||||
|
||||
// check rights
|
||||
UnixUser loginUser = getLoginUser();
|
||||
@ -106,7 +106,7 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public Entity findByString(Class<? extends Entity> entityClass, String key) throws HSAdminException {
|
||||
public AbstractEntity findByString(Class<? extends AbstractEntity> entityClass, String key) throws HSAdminException {
|
||||
// find a static method which creates the query
|
||||
java.lang.reflect.Method method = null;
|
||||
try {
|
||||
@ -117,7 +117,7 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
method = null;
|
||||
}
|
||||
|
||||
Entity entity;
|
||||
AbstractEntity entity;
|
||||
if (method == null)
|
||||
entity = transaction.getEntityManager().find(entityClass, key);
|
||||
else {
|
||||
@ -131,7 +131,7 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
}
|
||||
|
||||
// perform the query
|
||||
List<Entity> result = search(entityClass, query, null);
|
||||
List<AbstractEntity> result = search(entityClass, query, null);
|
||||
if (result.size() > 1)
|
||||
throw new javax.persistence.NonUniqueResultException();
|
||||
if (result.size() == 0)
|
||||
@ -147,7 +147,7 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public List<Entity> search(Class<? extends Entity> entityClass, String condition, String orderBy) throws HSAdminException {
|
||||
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy) throws HSAdminException {
|
||||
// restrict query
|
||||
UnixUser loginUser = getLoginUser();
|
||||
condition = restrict(entityClass, loginUser, condition);
|
||||
@ -161,7 +161,7 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
|
||||
// Fix problem with queries WHERE .. AND (FALSE) -- pe
|
||||
if (condition != null && condition.contains("AND (FALSE)")) {
|
||||
return new LinkedList<Entity>();
|
||||
return new LinkedList<AbstractEntity>();
|
||||
}
|
||||
|
||||
if (orderBy != null) {
|
||||
@ -181,12 +181,12 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
// do query
|
||||
try {
|
||||
List<?> res = query.getResultList();
|
||||
List<Entity> ret = new LinkedList<Entity>();
|
||||
List<AbstractEntity> ret = new LinkedList<AbstractEntity>();
|
||||
|
||||
// remove entities where login user has no access rights
|
||||
for (Object entity : res) {
|
||||
if (entity instanceof Entity) {
|
||||
Entity returnedEntity = (Entity) entity;
|
||||
if (entity instanceof AbstractEntity) {
|
||||
AbstractEntity returnedEntity = (AbstractEntity) entity;
|
||||
if (returnedEntity.isReadAllowedFor(getLoginUser())) {
|
||||
ret.add(returnedEntity);
|
||||
}
|
||||
@ -196,11 +196,11 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
// return clean result
|
||||
return ret;
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
throw new HSAdminException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public Entity update(Entity existingEntity) throws HSAdminException {
|
||||
public AbstractEntity update(AbstractEntity existingEntity) throws HSAdminException {
|
||||
// get the user who is logged in
|
||||
UnixUser loginUser = getLoginUser();
|
||||
|
||||
@ -236,7 +236,7 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
return existingEntity;
|
||||
}
|
||||
|
||||
public void delete(Entity existingEntity) throws HSAdminException {
|
||||
public void delete(AbstractEntity existingEntity) throws HSAdminException {
|
||||
// get the user who is logged in
|
||||
UnixUser user = getLoginUser();
|
||||
|
||||
@ -280,7 +280,7 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
queueProcessor(proc, user, existingEntity, "geloescht");
|
||||
}
|
||||
|
||||
public EntityProcessorFactory createProcessorFactory(Class<? extends Entity> entityClass) {
|
||||
public EntityProcessorFactory createProcessorFactory(Class<? extends AbstractEntity> entityClass) {
|
||||
try {
|
||||
String procFactName = entityClass.getCanonicalName()
|
||||
+ "ProcessorFactory";
|
||||
@ -310,7 +310,7 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
public void queueProcessor(Processor proc, UnixUser user, Entity entity, String action) {
|
||||
public void queueProcessor(Processor proc, UnixUser user, AbstractEntity entity, String action) {
|
||||
log.debug("queueing processor for user " + user.getId() + "/"
|
||||
+ user.getUserId() + "/" + user.getName());
|
||||
EntityInfo entityInfo =
|
||||
|
@ -8,7 +8,7 @@ public class AuthorisationException extends HSAdminException {
|
||||
|
||||
private UnixUser user;
|
||||
private String method;
|
||||
private Entity entity;
|
||||
private AbstractEntity entity;
|
||||
private String field;
|
||||
|
||||
public UnixUser getUser() {
|
||||
@ -19,7 +19,7 @@ public class AuthorisationException extends HSAdminException {
|
||||
return method;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
public AbstractEntity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ public class AuthorisationException extends HSAdminException {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public AuthorisationException(UnixUser user, String method, Entity entity) {
|
||||
public AuthorisationException(UnixUser user, String method, AbstractEntity entity) {
|
||||
super("nicht authorisiert fuer " + method + "("
|
||||
+ entity.createStringKey() + ")");
|
||||
|
||||
@ -43,7 +43,7 @@ public class AuthorisationException extends HSAdminException {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
public AuthorisationException(UnixUser user, String method, Entity entity,
|
||||
public AuthorisationException(UnixUser user, String method, AbstractEntity entity,
|
||||
String field) {
|
||||
super("nicht authorisiert fuer " + method + "("
|
||||
+ entity.createStringKey() + "." + field + ")");
|
||||
|
@ -13,7 +13,7 @@ public class EntitySessionHelper {
|
||||
* @param entityClass
|
||||
* @return
|
||||
*/
|
||||
public static AbstractModuleImpl createEntitySessionWrapper(Class<? extends Entity> entityClass) {
|
||||
public static AbstractModuleImpl createEntitySessionWrapper(Class<? extends AbstractEntity> entityClass) {
|
||||
// get in instance
|
||||
AbstractModuleImpl impl = null;
|
||||
try {
|
||||
|
@ -20,7 +20,7 @@ public class GenericModuleImpl implements ModuleInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity initialize(Entity newEntity) throws HSAdminException {
|
||||
public AbstractEntity initialize(AbstractEntity newEntity) throws HSAdminException {
|
||||
log.trace("initialize(" + newEntity + ")");
|
||||
AbstractModuleImpl wrapper =
|
||||
EntitySessionHelper.createEntitySessionWrapper(newEntity.getClass());
|
||||
@ -29,14 +29,14 @@ public class GenericModuleImpl implements ModuleInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity add(Entity newEntity) throws HSAdminException {
|
||||
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
|
||||
if (!newEntity.isNew())
|
||||
throw new HSAdminException("cannot add an already persistent entity");
|
||||
log.trace("add(" + newEntity + ")");
|
||||
AbstractModuleImpl wrapper =
|
||||
EntitySessionHelper.createEntitySessionWrapper(newEntity.getClass());
|
||||
wrapper.construct(tx);
|
||||
Entity result = null;
|
||||
AbstractEntity result = null;
|
||||
try {
|
||||
result = wrapper.add(newEntity);
|
||||
return result;
|
||||
@ -46,7 +46,7 @@ public class GenericModuleImpl implements ModuleInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity find(Class<? extends Entity> entityClass, Object key) throws HSAdminException {
|
||||
public AbstractEntity find(Class<? extends AbstractEntity> entityClass, Object key) throws HSAdminException {
|
||||
log.trace("find(" + entityClass + ", " + key + ")");
|
||||
AbstractModuleImpl wrapper = EntitySessionHelper.createEntitySessionWrapper(entityClass);
|
||||
wrapper.construct(tx);
|
||||
@ -54,7 +54,7 @@ public class GenericModuleImpl implements ModuleInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity findByString(Class<? extends Entity> entityClass, String key) throws HSAdminException {
|
||||
public AbstractEntity findByString(Class<? extends AbstractEntity> entityClass, String key) throws HSAdminException {
|
||||
log.trace("find(" + entityClass + ", " + key + ")");
|
||||
AbstractModuleImpl wrapper = EntitySessionHelper.createEntitySessionWrapper(entityClass);
|
||||
wrapper.construct(tx);
|
||||
@ -62,7 +62,7 @@ public class GenericModuleImpl implements ModuleInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Entity> search(Class<? extends Entity> entityClass, String condition, String orderBy) throws HSAdminException {
|
||||
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy) throws HSAdminException {
|
||||
log.trace("search(" + entityClass + ", " + condition + ")");
|
||||
AbstractModuleImpl wrapper = EntitySessionHelper.createEntitySessionWrapper(entityClass);
|
||||
wrapper.construct(tx);
|
||||
@ -70,7 +70,7 @@ public class GenericModuleImpl implements ModuleInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity update(Entity existingEntity) throws HSAdminException {
|
||||
public AbstractEntity update(AbstractEntity existingEntity) throws HSAdminException {
|
||||
if (existingEntity.isNew())
|
||||
return add(existingEntity);
|
||||
log.debug("update(" + existingEntity + ")");
|
||||
@ -84,7 +84,7 @@ public class GenericModuleImpl implements ModuleInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Entity existingEntity) throws HSAdminException {
|
||||
public void delete(AbstractEntity existingEntity) throws HSAdminException {
|
||||
log.trace("delete(" + existingEntity + ")");
|
||||
AbstractModuleImpl wrapper =
|
||||
EntitySessionHelper.createEntitySessionWrapper(existingEntity.getClass());
|
||||
|
@ -14,37 +14,37 @@ public interface ModuleInterface {
|
||||
/**
|
||||
* initializes a newly created entity.
|
||||
*/
|
||||
public Entity initialize(Entity newEntity) throws HSAdminException;
|
||||
public AbstractEntity initialize(AbstractEntity newEntity) throws HSAdminException;
|
||||
|
||||
/**
|
||||
* Adds a new entity instance to the model.
|
||||
*/
|
||||
public Entity add(Entity newEntity) throws HSAdminException;
|
||||
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException;
|
||||
|
||||
/**
|
||||
* Finds an entity instance in the model, using its primary key.
|
||||
*/
|
||||
public Entity find(Class<? extends Entity> entityClass, Object key) throws HSAdminException;
|
||||
public AbstractEntity find(Class<? extends AbstractEntity> entityClass, Object key) throws HSAdminException;
|
||||
|
||||
/**
|
||||
* Finds an entity instance in the model, using its primary key in a String
|
||||
* representation.
|
||||
*/
|
||||
public Entity findByString(Class<? extends Entity> entityClass, String key) throws HSAdminException;
|
||||
public AbstractEntity findByString(Class<? extends AbstractEntity> entityClass, String key) throws HSAdminException;
|
||||
|
||||
/**
|
||||
* Searches entity instances in the model, using a simplified JPA-QL query.
|
||||
*/
|
||||
public List<Entity> search(Class<? extends Entity> entityClass, String query, String orderBy) throws HSAdminException;
|
||||
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String query, String orderBy) throws HSAdminException;
|
||||
|
||||
/**
|
||||
* Updates an existing entity in the model.
|
||||
*/
|
||||
public Entity update(Entity existingEntity) throws HSAdminException;
|
||||
public AbstractEntity update(AbstractEntity existingEntity) throws HSAdminException;
|
||||
|
||||
/**
|
||||
* Deletes an existing entity from the model.
|
||||
*/
|
||||
public void delete(Entity existingEntity) throws HSAdminException;
|
||||
public void delete(AbstractEntity existingEntity) throws HSAdminException;
|
||||
|
||||
}
|
||||
|
@ -11,28 +11,28 @@ public class SecureDefaultModuleImpl extends AbstractModuleImpl {
|
||||
private static final long serialVersionUID = 4567381515459292565L;
|
||||
|
||||
@Override
|
||||
public Entity initialize(Entity newEntity) throws AuthorisationException {
|
||||
public AbstractEntity initialize(AbstractEntity newEntity) throws AuthorisationException {
|
||||
return super.initialize(newEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity find(Class<? extends Entity> entityClass, Object key) throws HSAdminException {
|
||||
Entity entity = super.find(entityClass, key);
|
||||
public AbstractEntity find(Class<? extends AbstractEntity> entityClass, Object key) throws HSAdminException {
|
||||
AbstractEntity entity = super.find(entityClass, key);
|
||||
if (entity != null && !entity.isReadAllowedFor(getLoginUser()))
|
||||
throw new AuthorisationException(getLoginUser(), "find");
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity findByString(Class<? extends Entity> entityClass, String key) throws HSAdminException {
|
||||
Entity entity = super.findByString(entityClass, key);
|
||||
public AbstractEntity findByString(Class<? extends AbstractEntity> entityClass, String key) throws HSAdminException {
|
||||
AbstractEntity entity = super.findByString(entityClass, key);
|
||||
if (entity != null && !entity.isReadAllowedFor(getLoginUser()))
|
||||
throw new AuthorisationException(getLoginUser(), "findByString");
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Entity> search(Class<? extends Entity> entityClass, String condition, String orderBy)
|
||||
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy)
|
||||
throws HSAdminException {
|
||||
// restrict query to entities where the loginUser could have rights on
|
||||
SearchFilter filterAnnot;
|
||||
@ -47,13 +47,13 @@ public class SecureDefaultModuleImpl extends AbstractModuleImpl {
|
||||
}
|
||||
|
||||
// do query
|
||||
List<Entity> res = super.search(entityClass, condition, orderBy);
|
||||
List<Entity> ret = new LinkedList<Entity>();
|
||||
List<AbstractEntity> res = super.search(entityClass, condition, orderBy);
|
||||
List<AbstractEntity> ret = new LinkedList<AbstractEntity>();
|
||||
|
||||
// remove entities where login user has no access rights
|
||||
if (res != null) {
|
||||
for (Entity entity : res) {
|
||||
Entity returnedEntity = entity;
|
||||
for (AbstractEntity entity : res) {
|
||||
AbstractEntity returnedEntity = entity;
|
||||
if (returnedEntity.isReadAllowedFor(getLoginUser()))
|
||||
ret.add(returnedEntity);
|
||||
}
|
||||
@ -77,21 +77,21 @@ public class SecureDefaultModuleImpl extends AbstractModuleImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity add(Entity newEntity) throws HSAdminException {
|
||||
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
|
||||
// access rights checking is done by base class
|
||||
return super.add(newEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity update(Entity existingEntity) throws HSAdminException {
|
||||
public AbstractEntity update(AbstractEntity existingEntity) throws HSAdminException {
|
||||
// access rights checking is done by base class
|
||||
return super.update(existingEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Entity detachedEntity) throws HSAdminException {
|
||||
public void delete(AbstractEntity detachedEntity) throws HSAdminException {
|
||||
// get the entity from the database
|
||||
Entity attachedEntity = getTransaction().getEntityManager().find(detachedEntity.getClass(),
|
||||
AbstractEntity attachedEntity = getTransaction().getEntityManager().find(detachedEntity.getClass(),
|
||||
detachedEntity.id());
|
||||
|
||||
// does the login user have the right to delete?
|
||||
|
@ -150,7 +150,7 @@ public class Transaction {
|
||||
* Used to detach entities before update. Makes it possible to compare
|
||||
* old and new attribute values.
|
||||
*/
|
||||
public void detach(Entity entity) {
|
||||
public void detach(AbstractEntity entity) {
|
||||
// TODO: replace hibernate specific implmentation
|
||||
// org.hibernate.Session hSession = (Session) entityManager.getDelegate();
|
||||
// hSession.evict(entity);
|
||||
|
@ -13,6 +13,15 @@ public class PersistenceManager {
|
||||
|
||||
private Map<String, EntityManagerFactory> persistenceUnits;
|
||||
|
||||
public static EntityManager getEntityManager(String persistUnitName) {
|
||||
EntityManagerFactory emf = PersistenceManager.getInstance().getEMF(persistUnitName);
|
||||
return emf.createEntityManager();
|
||||
}
|
||||
|
||||
public static void close() {
|
||||
getInstance().closeFactories();
|
||||
}
|
||||
|
||||
private PersistenceManager() {
|
||||
persistenceUnits = new HashMap<String, EntityManagerFactory>();
|
||||
}
|
||||
@ -26,12 +35,6 @@ public class PersistenceManager {
|
||||
return emf;
|
||||
}
|
||||
|
||||
public static EntityManager getEntityManager(String persistUnitName) {
|
||||
PersistenceManager pm = PersistenceManager.getInstance();
|
||||
EntityManagerFactory emf = pm.getEMF(persistUnitName);
|
||||
return emf.createEntityManager();
|
||||
}
|
||||
|
||||
private static PersistenceManager getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new PersistenceManager();
|
||||
@ -39,5 +42,12 @@ public class PersistenceManager {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
private void closeFactories() {
|
||||
for (String puName : persistenceUnits.keySet()) {
|
||||
System.out.println("Persistence Unit: " + puName);
|
||||
EntityManagerFactory emf = persistenceUnits.get(puName);
|
||||
emf.close();
|
||||
persistenceUnits.remove(puName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package de.hsadmin.core.model.onetier;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
public class PersistenceManagerContextListener implements ServletContextListener {
|
||||
|
||||
public PersistenceManagerContextListener() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent contextEvent) {
|
||||
System.out.println("PersistenceManager.contextDestroyed()");
|
||||
PersistenceManager.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent contextEvent) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -2,7 +2,7 @@ package de.hsadmin.core.qserv;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import de.hsadmin.core.model.Entity;
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
|
||||
/**
|
||||
* Most processor factories need only these methods.
|
||||
@ -10,13 +10,13 @@ import de.hsadmin.core.model.Entity;
|
||||
* @author peter
|
||||
*/
|
||||
public interface EntityProcessorFactory {
|
||||
public <T extends Entity> Processor createCreateProcessor(EntityManager em,
|
||||
public <T extends AbstractEntity> Processor createCreateProcessor(EntityManager em,
|
||||
T entity) throws ProcessorException;
|
||||
|
||||
public <T extends Entity> Processor createUpdateProcessor(EntityManager em,
|
||||
public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em,
|
||||
T newEntity) throws ProcessorException;
|
||||
|
||||
public <T extends Entity> Processor createDeleteProcessor(EntityManager em,
|
||||
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em,
|
||||
T entity) throws ProcessorException;
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import javax.persistence.EntityManager;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GenerationType;
|
||||
|
||||
import de.hsadmin.core.model.Entity;
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.core.model.EntityInfo;
|
||||
import de.hsadmin.core.model.ModuleImpl;
|
||||
import de.hsadmin.mods.qstat.QTaskModuleImpl;
|
||||
@ -18,7 +18,7 @@ import de.hsadmin.mods.user.UnixUser;
|
||||
@javax.persistence.SequenceGenerator(name = "QueueTaskSeqGen", sequenceName = "queue_task_id_seq")
|
||||
@EntityInfo(name = "Systemauftrag")
|
||||
@ModuleImpl(QTaskModuleImpl.class)
|
||||
public class QueueTask extends Entity implements Serializable {
|
||||
public class QueueTask extends AbstractEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2171870783383767875L;
|
||||
|
||||
|
@ -2,16 +2,57 @@ package de.hsadmin.mods.cust;
|
||||
|
||||
import static javax.persistence.FetchType.EAGER;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.mods.user.UnixUser;
|
||||
|
||||
@javax.persistence.Entity(name = "BankAccounts")
|
||||
@javax.persistence.Table(name = "bank_account")
|
||||
public class BankAccount extends de.hsadmin.core.model.Entity implements
|
||||
java.io.Serializable {
|
||||
@Entity(name = "BankAccounts")
|
||||
@Table(name = "bank_account")
|
||||
public class BankAccount extends AbstractEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2965368183976686458L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "bank_account_id", columnDefinition = "integer")
|
||||
private long id;
|
||||
|
||||
@JoinColumn(name = "bp_id", columnDefinition = "integer")
|
||||
@OneToOne(fetch = EAGER)
|
||||
private Customer customer;
|
||||
|
||||
@Column(name = "autodebit_ga", columnDefinition = "boolean", nullable = true)
|
||||
private Boolean autoDebitGA;
|
||||
|
||||
@Column(name = "autodebit_ar", columnDefinition = "boolean", nullable = true)
|
||||
private Boolean autoDebitAR;
|
||||
|
||||
@Column(name = "autodebit_op", columnDefinition = "boolean", nullable = true)
|
||||
private Boolean autoDebitOP;
|
||||
|
||||
@Column(name = "bank_customer", columnDefinition = "character varying(50)", nullable = true)
|
||||
private String bankCustomer;
|
||||
|
||||
@Column(name = "bank_account", columnDefinition = "character varying(10)", nullable = true)
|
||||
private String bankAccount;
|
||||
|
||||
@Column(name = "bank_code", columnDefinition = "character varying(8)", nullable = true)
|
||||
private String bankCode;
|
||||
|
||||
@Column(name = "bank_name", columnDefinition = "character varying(50)", nullable = true)
|
||||
private String bankName;
|
||||
|
||||
public static String createQueryFromStringKey(String humanKey) {
|
||||
return "customer.name = " + humanKey;
|
||||
}
|
||||
@ -26,13 +67,6 @@ public class BankAccount extends de.hsadmin.core.model.Entity implements
|
||||
return id;
|
||||
}
|
||||
|
||||
// attribute id
|
||||
@javax.persistence.Id
|
||||
@javax.persistence.GeneratedValue(strategy = javax.persistence.GenerationType.SEQUENCE)
|
||||
@javax.persistence.SequenceGenerator(name = "bank_account_id_seq_gen", sequenceName = "bank_account_bank_account_i_seq", allocationSize = 20)
|
||||
@javax.persistence.Column(name = "bank_account_id", columnDefinition = "integer")
|
||||
private long id;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
@ -41,11 +75,6 @@ public class BankAccount extends de.hsadmin.core.model.Entity implements
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
// attribute customer
|
||||
@javax.persistence.JoinColumn(name = "bp_id", columnDefinition = "integer")
|
||||
@javax.persistence.OneToOne(fetch = EAGER)
|
||||
private Customer customer;
|
||||
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
@ -54,10 +83,6 @@ public class BankAccount extends de.hsadmin.core.model.Entity implements
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
// attribute autoDebitGA
|
||||
@javax.persistence.Column(name = "autodebit_ga", columnDefinition = "boolean", nullable = true)
|
||||
private Boolean autoDebitGA;
|
||||
|
||||
public Boolean isAutoDebitGA() {
|
||||
return autoDebitGA;
|
||||
}
|
||||
@ -70,10 +95,6 @@ public class BankAccount extends de.hsadmin.core.model.Entity implements
|
||||
this.autoDebitGA = autoDebitGA;
|
||||
}
|
||||
|
||||
// attribute autoDebitAR
|
||||
@javax.persistence.Column(name = "autodebit_ar", columnDefinition = "boolean", nullable = true)
|
||||
private Boolean autoDebitAR;
|
||||
|
||||
public Boolean isAutoDebitAR() {
|
||||
return autoDebitAR;
|
||||
}
|
||||
@ -86,10 +107,6 @@ public class BankAccount extends de.hsadmin.core.model.Entity implements
|
||||
this.autoDebitAR = autoDebitAR;
|
||||
}
|
||||
|
||||
// attribute autoDebitOP
|
||||
@javax.persistence.Column(name = "autodebit_op", columnDefinition = "boolean", nullable = true)
|
||||
private Boolean autoDebitOP;
|
||||
|
||||
public Boolean isAutoDebitOP() {
|
||||
return autoDebitOP;
|
||||
}
|
||||
@ -102,10 +119,6 @@ public class BankAccount extends de.hsadmin.core.model.Entity implements
|
||||
this.autoDebitOP = autoDebitOP;
|
||||
}
|
||||
|
||||
// attribute bankCustomer
|
||||
@javax.persistence.Column(name = "bank_customer", columnDefinition = "character varying(50)", nullable = true)
|
||||
private String bankCustomer;
|
||||
|
||||
public String getBankCustomer() {
|
||||
return bankCustomer;
|
||||
}
|
||||
@ -114,10 +127,6 @@ public class BankAccount extends de.hsadmin.core.model.Entity implements
|
||||
this.bankCustomer = bankCustomer;
|
||||
}
|
||||
|
||||
// attribute bankAccount
|
||||
@javax.persistence.Column(name = "bank_account", columnDefinition = "character varying(10)", nullable = true)
|
||||
private String bankAccount;
|
||||
|
||||
public String getBankAccount() {
|
||||
return bankAccount;
|
||||
}
|
||||
@ -126,10 +135,6 @@ public class BankAccount extends de.hsadmin.core.model.Entity implements
|
||||
this.bankAccount = bankAccount;
|
||||
}
|
||||
|
||||
// attribute bankCode
|
||||
@javax.persistence.Column(name = "bank_code", columnDefinition = "character varying(8)", nullable = true)
|
||||
private String bankCode;
|
||||
|
||||
public String getBankCode() {
|
||||
return bankCode;
|
||||
}
|
||||
@ -138,10 +143,6 @@ public class BankAccount extends de.hsadmin.core.model.Entity implements
|
||||
this.bankCode = bankCode;
|
||||
}
|
||||
|
||||
// attribute bankName
|
||||
@javax.persistence.Column(name = "bank_name", columnDefinition = "character varying(50)", nullable = true)
|
||||
private String bankName;
|
||||
|
||||
public String getBankName() {
|
||||
return bankName;
|
||||
}
|
||||
@ -150,13 +151,11 @@ public class BankAccount extends de.hsadmin.core.model.Entity implements
|
||||
this.bankName = bankName;
|
||||
}
|
||||
|
||||
// / {$inheritDoc}
|
||||
@Override
|
||||
public boolean isNew() {
|
||||
return id == 0;
|
||||
}
|
||||
|
||||
// / {@inheritDoc}
|
||||
@Override
|
||||
public UnixUser owningUser(EntityManager em) {
|
||||
return customer.owningUser(em);
|
||||
|
@ -1,88 +1,72 @@
|
||||
package de.hsadmin.mods.cust;
|
||||
|
||||
import static javax.persistence.FetchType.EAGER;
|
||||
import static javax.persistence.GenerationType.SEQUENCE;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.GenerationType;
|
||||
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.mods.user.UnixUser;
|
||||
|
||||
@javax.persistence.Entity(name = "Contacts")
|
||||
@javax.persistence.Table(name = "contact")
|
||||
@javax.persistence.SequenceGenerator(name = "ContactsSeqGen", sequenceName = "contact_contact_id_seq")
|
||||
public class Contact extends de.hsadmin.core.model.Entity implements
|
||||
java.io.Serializable {
|
||||
public class Contact extends AbstractEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 9119607911598098558L;
|
||||
|
||||
// attribute id
|
||||
@javax.persistence.Id
|
||||
@javax.persistence.GeneratedValue(strategy = SEQUENCE, generator = "ContactsSeqGen")
|
||||
@javax.persistence.GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@javax.persistence.Column(name = "contact_id", columnDefinition = "integer")
|
||||
private long id;
|
||||
|
||||
// attribute customer
|
||||
@javax.persistence.JoinColumn(name = "bp_id", columnDefinition = "integer")
|
||||
@javax.persistence.ManyToOne(fetch = EAGER)
|
||||
private Customer customer;
|
||||
|
||||
// attribute salut
|
||||
@javax.persistence.Column(name = "salut", columnDefinition = "character varying(30)")
|
||||
private String salut;
|
||||
|
||||
// attribute firstName
|
||||
@javax.persistence.Column(name = "first_name", columnDefinition = "character varying(40)")
|
||||
private String firstName;
|
||||
|
||||
// attribute lastName
|
||||
@javax.persistence.Column(name = "last_name", columnDefinition = "character varying(40)")
|
||||
private String lastName;
|
||||
|
||||
// attribute title
|
||||
@javax.persistence.Column(name = "title", columnDefinition = "character varying(20)")
|
||||
private String title;
|
||||
|
||||
// attribute firma
|
||||
@javax.persistence.Column(name = "firma", columnDefinition = "character varying(120)")
|
||||
private String firma;
|
||||
|
||||
// attribute co
|
||||
@javax.persistence.Column(name = "co", columnDefinition = "character varying(50)")
|
||||
private String co;
|
||||
|
||||
// attribute street
|
||||
@javax.persistence.Column(name = "street", columnDefinition = "character varying(50)")
|
||||
private String street;
|
||||
|
||||
// attribute zipCode
|
||||
@javax.persistence.Column(name = "zipcode", columnDefinition = "character varying(10)")
|
||||
private String zipCode;
|
||||
|
||||
// attribute city
|
||||
@javax.persistence.Column(name = "city", columnDefinition = "character varying(40)")
|
||||
private String city;
|
||||
|
||||
// attribute country
|
||||
@javax.persistence.Column(name = "country", columnDefinition = "character varying(30)")
|
||||
private String country;
|
||||
|
||||
// attribute phonePrivate
|
||||
@javax.persistence.Column(name = "phone_private", columnDefinition = "character varying(30)")
|
||||
private String phonePrivate;
|
||||
|
||||
// attribute phoneOffice
|
||||
@javax.persistence.Column(name = "phone_office", columnDefinition = "character varying(30)")
|
||||
private String phoneOffice;
|
||||
|
||||
// attribute phoneMobile
|
||||
@javax.persistence.Column(name = "phone_mobile", columnDefinition = "character varying(30)")
|
||||
private String phoneMobile;
|
||||
|
||||
// attribute fax
|
||||
@javax.persistence.Column(name = "fax", columnDefinition = "character varying(30)")
|
||||
private String fax;
|
||||
|
||||
// attribute email
|
||||
@javax.persistence.Column(name = "email", columnDefinition = "character varying(50)")
|
||||
private String email;
|
||||
|
||||
@ -115,18 +99,15 @@ public class Contact extends de.hsadmin.core.model.Entity implements
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
// / {@inheritDoc}
|
||||
public static String createQueryFromStringKey(String humanKey) {
|
||||
return "name='" + humanKey + "'";
|
||||
}
|
||||
|
||||
// / {@inheritDoc}
|
||||
@Override
|
||||
public String createStringKey() {
|
||||
return getCustomer().getName();
|
||||
}
|
||||
|
||||
// / {@inheritDoc}
|
||||
@Override
|
||||
public long id() {
|
||||
return id;
|
||||
@ -268,13 +249,11 @@ public class Contact extends de.hsadmin.core.model.Entity implements
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
// / {$inheritDoc}
|
||||
@Override
|
||||
public boolean isNew() {
|
||||
return id == 0;
|
||||
}
|
||||
|
||||
// / {@inheritDoc}
|
||||
@Override
|
||||
public UnixUser owningUser(EntityManager em) {
|
||||
return null; // TODO: no access yet
|
||||
|
@ -3,78 +3,83 @@ package de.hsadmin.mods.cust;
|
||||
import static javax.persistence.CascadeType.ALL;
|
||||
import static javax.persistence.FetchType.EAGER;
|
||||
import static javax.persistence.FetchType.LAZY;
|
||||
import static javax.persistence.GenerationType.SEQUENCE;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.OrderBy;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Temporal;
|
||||
|
||||
import de.hsadmin.mods.pac.Pac;
|
||||
import de.hsadmin.mods.user.UnixUser;
|
||||
|
||||
@javax.persistence.Entity(name = "Customers")
|
||||
@javax.persistence.Table(name = "business_partner")
|
||||
@javax.persistence.SequenceGenerator(name = "CustomersSeqGen", sequenceName = "business_partner_bp_id_seq")
|
||||
public class Customer extends de.hsadmin.core.model.Entity implements Serializable {
|
||||
@Entity(name = "Customers")
|
||||
@Table(name = "business_partner")
|
||||
public class Customer extends de.hsadmin.core.model.AbstractEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7450594652238392616L;
|
||||
|
||||
@javax.persistence.Id
|
||||
@javax.persistence.GeneratedValue(strategy = SEQUENCE, generator = "CustomersSeqGen")
|
||||
@javax.persistence.Column(name = "bp_id", columnDefinition = "integer")
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "bp_id", columnDefinition = "integer")
|
||||
private long id;
|
||||
|
||||
@javax.persistence.Column(name = "member_id", columnDefinition = "integer")
|
||||
@Column(name = "member_id", columnDefinition = "integer")
|
||||
private int memberNo;
|
||||
|
||||
@javax.persistence.Column(name = "member_code", columnDefinition = "character varying(20)")
|
||||
@Column(name = "member_code", columnDefinition = "character varying(20)")
|
||||
private String name;
|
||||
|
||||
@javax.persistence.Column(name = "member_since", columnDefinition = "date", nullable = true)
|
||||
@Column(name = "member_since", columnDefinition = "date", nullable = true)
|
||||
private Date memberSince;
|
||||
|
||||
@javax.persistence.Column(name = "member_until", columnDefinition = "date", nullable = true)
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
@Column(name = "member_until", columnDefinition = "date", nullable = true)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date memberUntil;
|
||||
|
||||
@javax.persistence.Column(name = "member_role", columnDefinition = "character varying(100)", nullable = true)
|
||||
@Column(name = "member_role", columnDefinition = "character varying(100)", nullable = true)
|
||||
private String memberRole;
|
||||
|
||||
@javax.persistence.Column(name = "author_contract", columnDefinition = "date", nullable = true)
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
@Column(name = "author_contract", columnDefinition = "date", nullable = true)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date authorContract;
|
||||
|
||||
@javax.persistence.Column(name = "nondisc_contract", columnDefinition = "date", nullable = true)
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
@Column(name = "nondisc_contract", columnDefinition = "date", nullable = true)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date nonDiscContract;
|
||||
|
||||
@javax.persistence.Column(name = "shares_updated", columnDefinition = "date", nullable = true)
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
@Column(name = "shares_updated", columnDefinition = "date", nullable = true)
|
||||
@Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date sharesUpdated;
|
||||
|
||||
@javax.persistence.Column(name = "shares_signed", columnDefinition = "integer")
|
||||
@Column(name = "shares_signed", columnDefinition = "integer")
|
||||
private int sharesSigned;
|
||||
|
||||
@javax.persistence.Column(name = "uid_vat", columnDefinition = "character varying(20)", nullable = true)
|
||||
@Column(name = "uid_vat", columnDefinition = "character varying(20)", nullable = true)
|
||||
private String uidVAT;
|
||||
|
||||
@javax.persistence.OneToMany(fetch = EAGER, cascade = ALL, mappedBy = "customer")
|
||||
@OneToMany(fetch = EAGER, cascade = ALL, mappedBy = "customer")
|
||||
private Set<Contact> contacts;
|
||||
|
||||
// virtual attribute bankAccount
|
||||
@javax.persistence.OneToOne(fetch = EAGER, cascade = ALL, mappedBy = "customer")
|
||||
@OneToOne(fetch = EAGER, cascade = ALL, mappedBy = "customer")
|
||||
private BankAccount bankAccount;
|
||||
|
||||
// virtual attribute billData
|
||||
@javax.persistence.OneToOne(fetch = EAGER, cascade = ALL, mappedBy = "customer")
|
||||
@OneToOne(fetch = EAGER, cascade = ALL, mappedBy = "customer")
|
||||
private CustomersTariff billData;
|
||||
|
||||
// virtual attribute pacs
|
||||
@javax.persistence.OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "customer")
|
||||
@javax.persistence.OrderBy("name")
|
||||
@OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "customer")
|
||||
@OrderBy("name")
|
||||
private Set<Pac> pacs;
|
||||
|
||||
public Customer() {
|
||||
@ -262,6 +267,6 @@ public class Customer extends de.hsadmin.core.model.Entity implements Serializab
|
||||
}
|
||||
|
||||
public static String restriction() {
|
||||
return "name=:loginUserName";
|
||||
return "obj.name=:loginUserName";
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package de.hsadmin.mods.cust;
|
||||
|
||||
import de.hsadmin.core.model.AbstractModuleImpl;
|
||||
|
||||
public class CustomerModuleImpl extends AbstractModuleImpl {
|
||||
|
||||
}
|
@ -1,23 +1,63 @@
|
||||
package de.hsadmin.mods.cust;
|
||||
|
||||
import static javax.persistence.FetchType.EAGER;
|
||||
import static javax.persistence.GenerationType.SEQUENCE;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.GenerationType;
|
||||
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.mods.user.UnixUser;
|
||||
|
||||
@javax.persistence.Entity(name = "CustomersTariffs")
|
||||
@javax.persistence.Table(name = "billdata")
|
||||
@javax.persistence.SequenceGenerator(name = "CustomersTariffsSeqGen", sequenceName = "billdata_billdata_id_seq")
|
||||
public class CustomersTariff extends de.hsadmin.core.model.Entity implements
|
||||
java.io.Serializable {
|
||||
public class CustomersTariff extends AbstractEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3628577459027111705L;
|
||||
|
||||
// / bean ctor
|
||||
@javax.persistence.Id
|
||||
@javax.persistence.GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@javax.persistence.Column(name = "billdata_id", columnDefinition = "integer")
|
||||
private long id;
|
||||
|
||||
@javax.persistence.JoinColumn(name = "bp_id", columnDefinition = "integer")
|
||||
@javax.persistence.OneToOne(fetch = EAGER)
|
||||
private Customer customer;
|
||||
|
||||
@javax.persistence.Column(name = "tariff_domain_discount_since", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date domainDiscountSince;
|
||||
|
||||
@javax.persistence.Column(name = "tariff_domain_discount_until", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date domainDiscountUntil;
|
||||
|
||||
@javax.persistence.Column(name = "tariff_traffic_discount_since", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date trafficDiscountSince;
|
||||
|
||||
@javax.persistence.Column(name = "tariff_traffic_discount_until", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date trafficDiscountUntil;
|
||||
|
||||
@javax.persistence.Column(name = "tariff_quota_discount_since", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date quotaDiscountSince;
|
||||
|
||||
@javax.persistence.Column(name = "tariff_quota_discount_until", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date quotaDiscountUntil;
|
||||
|
||||
@javax.persistence.Column(name = "tariff_discount_since", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date discountSince;
|
||||
|
||||
@javax.persistence.Column(name = "tariff_discount_until", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date discountUntil;
|
||||
|
||||
public CustomersTariff() {
|
||||
}
|
||||
|
||||
@ -25,29 +65,20 @@ public class CustomersTariff extends de.hsadmin.core.model.Entity implements
|
||||
this.customer = cust;
|
||||
}
|
||||
|
||||
// / {@inheritDoc}
|
||||
public static String createQueryFromStringKey(String humanKey) {
|
||||
return "customer.name = '" + humanKey + "'";
|
||||
}
|
||||
|
||||
// / {@inheritDoc}
|
||||
@Override
|
||||
public String createStringKey() {
|
||||
return getCustomer().getName();
|
||||
}
|
||||
|
||||
// / {@inheritDoc}
|
||||
@Override
|
||||
public long id() {
|
||||
return id;
|
||||
}
|
||||
|
||||
// attribute id
|
||||
@javax.persistence.Id
|
||||
@javax.persistence.GeneratedValue(strategy = SEQUENCE, generator = "CustomersTariffsSeqGen")
|
||||
@javax.persistence.Column(name = "billdata_id", columnDefinition = "integer")
|
||||
private long id;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
@ -56,12 +87,6 @@ public class CustomersTariff extends de.hsadmin.core.model.Entity implements
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
// attribute customer
|
||||
@javax.persistence.JoinColumn(name = "bp_id", columnDefinition = "integer")
|
||||
@javax.persistence.OneToOne(fetch = EAGER)
|
||||
// TODO: das will ich gar nicht, geht aber nicht ohne?!?
|
||||
private Customer customer;
|
||||
|
||||
public Customer getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
@ -70,11 +95,6 @@ public class CustomersTariff extends de.hsadmin.core.model.Entity implements
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
// attribute domainDiscountSince
|
||||
@javax.persistence.Column(name = "tariff_domain_discount_since", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date domainDiscountSince;
|
||||
|
||||
public Date getDomainDiscountSince() {
|
||||
return domainDiscountSince;
|
||||
}
|
||||
@ -83,11 +103,6 @@ public class CustomersTariff extends de.hsadmin.core.model.Entity implements
|
||||
this.domainDiscountSince = domainDiscountSince;
|
||||
}
|
||||
|
||||
// attribute domainDiscountUntil
|
||||
@javax.persistence.Column(name = "tariff_domain_discount_until", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date domainDiscountUntil;
|
||||
|
||||
public Date getDomainDiscountUntil() {
|
||||
return domainDiscountUntil;
|
||||
}
|
||||
@ -96,11 +111,6 @@ public class CustomersTariff extends de.hsadmin.core.model.Entity implements
|
||||
this.domainDiscountUntil = domainDiscountUntil;
|
||||
}
|
||||
|
||||
// attribute trafficDiscountSince
|
||||
@javax.persistence.Column(name = "tariff_traffic_discount_since", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date trafficDiscountSince;
|
||||
|
||||
public Date getTrafficDiscountSince() {
|
||||
return trafficDiscountSince;
|
||||
}
|
||||
@ -109,11 +119,6 @@ public class CustomersTariff extends de.hsadmin.core.model.Entity implements
|
||||
this.trafficDiscountSince = trafficDiscountSince;
|
||||
}
|
||||
|
||||
// attribute trafficDiscountUntil
|
||||
@javax.persistence.Column(name = "tariff_traffic_discount_until", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date trafficDiscountUntil;
|
||||
|
||||
public Date getTrafficDiscountUntil() {
|
||||
return trafficDiscountUntil;
|
||||
}
|
||||
@ -122,11 +127,6 @@ public class CustomersTariff extends de.hsadmin.core.model.Entity implements
|
||||
this.trafficDiscountUntil = trafficDiscountUntil;
|
||||
}
|
||||
|
||||
// attribute quotaDiscountSince
|
||||
@javax.persistence.Column(name = "tariff_quota_discount_since", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date quotaDiscountSince;
|
||||
|
||||
public Date getQuotaDiscountSince() {
|
||||
return quotaDiscountSince;
|
||||
}
|
||||
@ -135,11 +135,6 @@ public class CustomersTariff extends de.hsadmin.core.model.Entity implements
|
||||
this.quotaDiscountSince = quotaDiscountSince;
|
||||
}
|
||||
|
||||
// attribute quotaDiscountUntil
|
||||
@javax.persistence.Column(name = "tariff_quota_discount_until", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date quotaDiscountUntil;
|
||||
|
||||
public Date getQuotaDiscountUntil() {
|
||||
return quotaDiscountUntil;
|
||||
}
|
||||
@ -148,11 +143,6 @@ public class CustomersTariff extends de.hsadmin.core.model.Entity implements
|
||||
this.quotaDiscountUntil = quotaDiscountUntil;
|
||||
}
|
||||
|
||||
// attribute discountSince
|
||||
@javax.persistence.Column(name = "tariff_discount_since", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date discountSince;
|
||||
|
||||
public Date getDiscountSince() {
|
||||
return discountSince;
|
||||
}
|
||||
@ -161,11 +151,6 @@ public class CustomersTariff extends de.hsadmin.core.model.Entity implements
|
||||
this.discountSince = discountSince;
|
||||
}
|
||||
|
||||
// attribute discountUntil
|
||||
@javax.persistence.Column(name = "tariff_discount_until", columnDefinition = "date")
|
||||
@javax.persistence.Temporal(javax.persistence.TemporalType.DATE)
|
||||
private Date discountUntil;
|
||||
|
||||
public Date getDiscountUntil() {
|
||||
return discountUntil;
|
||||
}
|
||||
@ -174,13 +159,11 @@ public class CustomersTariff extends de.hsadmin.core.model.Entity implements
|
||||
this.discountUntil = discountUntil;
|
||||
}
|
||||
|
||||
// / {$inheritDoc}
|
||||
@Override
|
||||
public boolean isNew() {
|
||||
return id == 0;
|
||||
}
|
||||
|
||||
// / {@inheritDoc}
|
||||
@Override
|
||||
public UnixUser owningUser(EntityManager em) {
|
||||
return customer.owningUser(em);
|
||||
|
@ -11,7 +11,7 @@ import de.hsadmin.mods.user.UnixUser;
|
||||
@javax.persistence.Entity(name = "BaseComponents")
|
||||
@javax.persistence.Table(name = " basecomponent")
|
||||
@javax.persistence.SequenceGenerator(name = "BaseComponentsSeqGen", sequenceName = "basecomponent_basecomponent_seq")
|
||||
public class BaseComponent extends de.hsadmin.core.model.Entity implements Serializable {
|
||||
public class BaseComponent extends de.hsadmin.core.model.AbstractEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8161827018235142603L;
|
||||
|
||||
|
@ -15,7 +15,7 @@ import de.hsadmin.mods.user.UnixUser;
|
||||
@javax.persistence.Table(name="hive")
|
||||
@javax.persistence.SequenceGenerator(name="HivesSeqGen", sequenceName="hive_hive_id_seq")
|
||||
public class Hive
|
||||
extends de.hsadmin.core.model.Entity
|
||||
extends de.hsadmin.core.model.AbstractEntity
|
||||
implements java.io.Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -2270234313165009590L;
|
||||
|
@ -10,7 +10,7 @@ import de.hsadmin.mods.user.UnixUser;
|
||||
@javax.persistence.Table(name="inet_addr")
|
||||
@javax.persistence.SequenceGenerator(name="INetAddressesSeqGen", sequenceName="inet_addr_inet_addr_id_seq")
|
||||
public class INetAddress
|
||||
extends de.hsadmin.core.model.Entity
|
||||
extends de.hsadmin.core.model.AbstractEntity
|
||||
implements java.io.Serializable
|
||||
{
|
||||
private static final long serialVersionUID = -5792279453911426607L;
|
||||
|
@ -17,7 +17,7 @@ import de.hsadmin.mods.user.UnixUser;
|
||||
@javax.persistence.Table(name = "packet")
|
||||
@javax.persistence.SequenceGenerator(name = "PacsSeqGen", sequenceName = "packet_packet_id_seq")
|
||||
@de.hsadmin.core.model.EntityInfo(name = "Paket")
|
||||
public class Pac extends de.hsadmin.core.model.Entity implements Serializable {
|
||||
public class Pac extends de.hsadmin.core.model.AbstractEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1201899873300190132L;
|
||||
|
||||
|
@ -3,7 +3,7 @@ package de.hsadmin.mods.qstat;
|
||||
import java.util.List;
|
||||
|
||||
import de.hsadmin.core.model.AbstractModuleImpl;
|
||||
import de.hsadmin.core.model.Entity;
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.core.model.HSAdminException;
|
||||
import de.hsadmin.mods.user.UnixUser;
|
||||
|
||||
@ -15,7 +15,7 @@ public class QTaskModuleImpl extends AbstractModuleImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Entity> search(Class<? extends Entity> entityClass, String condition, String orderBy) throws HSAdminException {
|
||||
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy) throws HSAdminException {
|
||||
// do query and return result
|
||||
if (orderBy == null || orderBy.length() == 0) {
|
||||
orderBy = "ORDER BY obj.started DESC";
|
||||
|
@ -23,7 +23,7 @@ import de.hsadmin.mods.pac.Pac;
|
||||
@Table(name = "unixuser")
|
||||
@SequenceGenerator(name = "UnixUsersSeqGen", sequenceName = "unixuser_unixuser_id_seq")
|
||||
@EntityInfo(name = "UNIX-Zugang/Mailbox")
|
||||
public class UnixUser extends de.hsadmin.core.model.Entity implements Serializable {
|
||||
public class UnixUser extends de.hsadmin.core.model.AbstractEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7823071611805642906L;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import javax.persistence.EntityManager;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import de.hsadmin.core.model.AuthorisationException;
|
||||
import de.hsadmin.core.model.Entity;
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.core.model.AbstractModuleImpl;
|
||||
import de.hsadmin.core.model.HSAdminException;
|
||||
import de.hsadmin.mods.pac.Pac;
|
||||
@ -20,14 +20,14 @@ public class UnixUserModuleImpl extends AbstractModuleImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity initialize(Entity newEntity) throws AuthorisationException {
|
||||
public AbstractEntity initialize(AbstractEntity newEntity) throws AuthorisationException {
|
||||
UnixUser newUnixUser = (UnixUser) super.initialize(newEntity);
|
||||
newUnixUser.setName(getLoginUser().getPac().getName() + '-');
|
||||
return newUnixUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity find(Class<? extends Entity> entityClass, Object key) throws HSAdminException {
|
||||
public AbstractEntity find(Class<? extends AbstractEntity> entityClass, Object key) throws HSAdminException {
|
||||
// do query
|
||||
UnixUser res = (UnixUser) super.find(entityClass, key);
|
||||
|
||||
@ -39,7 +39,7 @@ public class UnixUserModuleImpl extends AbstractModuleImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity findByString(Class<? extends Entity> entityClass, String key) throws HSAdminException {
|
||||
public AbstractEntity findByString(Class<? extends AbstractEntity> entityClass, String key) throws HSAdminException {
|
||||
// do query
|
||||
UnixUser res = (UnixUser) super.findByString(entityClass, key);
|
||||
|
||||
@ -49,17 +49,17 @@ public class UnixUserModuleImpl extends AbstractModuleImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Entity> search(Class<? extends Entity> entityClass, String condition, String orderBy) throws HSAdminException {
|
||||
public List<AbstractEntity> search(Class<? extends AbstractEntity> entityClass, String condition, String orderBy) throws HSAdminException {
|
||||
// do query
|
||||
if (orderBy == null || orderBy.length() == 0) {
|
||||
orderBy = "ORDER BY obj.name ASC";
|
||||
}
|
||||
List<Entity> res = super.search(entityClass, condition, orderBy);
|
||||
List<Entity> ret = new LinkedList<Entity>();
|
||||
List<AbstractEntity> res = super.search(entityClass, condition, orderBy);
|
||||
List<AbstractEntity> ret = new LinkedList<AbstractEntity>();
|
||||
|
||||
// remove entities where login user has no access rights
|
||||
if (res != null) {
|
||||
for (Entity entity : res) {
|
||||
for (AbstractEntity entity : res) {
|
||||
try {
|
||||
UnixUser returnedUnixUser = (UnixUser) entity;
|
||||
needsPartialAccessOnPacOf(returnedUnixUser, "search");
|
||||
@ -74,7 +74,7 @@ public class UnixUserModuleImpl extends AbstractModuleImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity add(Entity newEntity) throws HSAdminException {
|
||||
public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException {
|
||||
EntityManager em = getEntityManager();
|
||||
// only allow pac which matches the username (TODO: hard coded
|
||||
// Hostsharing convention)
|
||||
@ -143,7 +143,7 @@ public class UnixUserModuleImpl extends AbstractModuleImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity update(Entity existingEntity) throws HSAdminException {
|
||||
public AbstractEntity update(AbstractEntity existingEntity) throws HSAdminException {
|
||||
// get the entity from the database
|
||||
UnixUser detachedUnixUser = (UnixUser) existingEntity;
|
||||
UnixUser attachedUnixUser = getEntityManager().find(detachedUnixUser.getClass(),
|
||||
@ -202,7 +202,7 @@ public class UnixUserModuleImpl extends AbstractModuleImpl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Entity existingEntity) throws HSAdminException {
|
||||
public void delete(AbstractEntity existingEntity) throws HSAdminException {
|
||||
// get the entity from the database
|
||||
UnixUser detachedUnixUser = (UnixUser) existingEntity;
|
||||
UnixUser attachedUnixUser = getEntityManager().find(detachedUnixUser.getClass(),
|
||||
|
@ -5,7 +5,7 @@ import java.util.Date;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import de.hsadmin.core.model.Entity;
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.core.qserv.CompoundProcessor;
|
||||
import de.hsadmin.core.qserv.EntityProcessorFactory;
|
||||
import de.hsadmin.core.qserv.Processor;
|
||||
@ -22,7 +22,7 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
|
||||
/**
|
||||
* @return a Processor which creates a new UNIX user account
|
||||
*/
|
||||
public <T extends Entity> Processor createCreateProcessor(EntityManager em,
|
||||
public <T extends AbstractEntity> Processor createCreateProcessor(EntityManager em,
|
||||
T entity) {
|
||||
UnixUser user = (UnixUser) entity;
|
||||
CompoundProcessor aCP = new CompoundProcessor(new ShellProcessor(
|
||||
@ -38,7 +38,7 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
|
||||
/**
|
||||
* @return a Processor which updates an existing UNIX user account
|
||||
*/
|
||||
public <T extends Entity> Processor createUpdateProcessor(EntityManager em,
|
||||
public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em,
|
||||
T entity) {
|
||||
UnixUser user = (UnixUser) entity;
|
||||
CompoundProcessor aCP = new CompoundProcessor(new ShellProcessor(
|
||||
@ -55,7 +55,7 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
|
||||
/**
|
||||
* @return a Processor which deletes an existing UNIX user account
|
||||
*/
|
||||
public <T extends Entity> Processor createDeleteProcessor(EntityManager em,
|
||||
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em,
|
||||
T entity) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyMMdd-HHmm-");
|
||||
String trashPrefix = "/home/trash/" + sdf.format(new Date());
|
||||
|
@ -10,7 +10,7 @@ import java.util.Map;
|
||||
|
||||
import de.hsadmin.core.model.AuthenticationException;
|
||||
import de.hsadmin.core.model.AuthorisationException;
|
||||
import de.hsadmin.core.model.Entity;
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.core.model.GenericModuleImpl;
|
||||
import de.hsadmin.core.model.HSAdminException;
|
||||
import de.hsadmin.core.model.ModuleInterface;
|
||||
@ -26,17 +26,14 @@ public abstract class AbstractRemote implements IRemote {
|
||||
authentication = new TicketAuthentication();
|
||||
}
|
||||
|
||||
protected abstract Class<? extends Entity> getEntityClass();
|
||||
protected abstract Class<? extends AbstractEntity> getEntityClass();
|
||||
|
||||
protected abstract void entity2map(Entity entity, Map<String, String> resultMap);
|
||||
protected abstract void entity2map(AbstractEntity entity, Map<String, String> resultMap);
|
||||
|
||||
protected abstract void map2entity(Map<String, String> setParams, Entity entity);
|
||||
protected abstract void map2entity(Map<String, String> setParams, AbstractEntity entity);
|
||||
|
||||
protected abstract void regularizeKeys(Map<String, String> whereParams);
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see de.hsadmin.remote.IRemote#search(java.lang.String, java.lang.String, java.util.Map)
|
||||
*/
|
||||
public List<Map<String, String>> search(String runAsUser, String ticket,
|
||||
Map<String, String> whereParams) throws HSAdminException {
|
||||
String user = runAsUser;
|
||||
@ -46,10 +43,13 @@ public abstract class AbstractRemote implements IRemote {
|
||||
ModuleInterface module = new GenericModuleImpl(transaction);
|
||||
UnixUser unixUser = null;
|
||||
unixUser = (UnixUser) module.findByString(UnixUser.class, user);
|
||||
List<Entity> list = module.search(getEntityClass(),
|
||||
List<AbstractEntity> list = module.search(getEntityClass(),
|
||||
buildQueryCondition(whereParams), null);
|
||||
if (list == null) {
|
||||
throw new HSAdminException("result list is null, runtime-error?");
|
||||
}
|
||||
ArrayList<Map<String, String>> result = new ArrayList<Map<String, String>>();
|
||||
for (Entity e : list) {
|
||||
for (AbstractEntity e : list) {
|
||||
HashMap<String, String> entry = new HashMap<String, String>();
|
||||
entity2map(e, entry);
|
||||
if (e.isReadAllowedFor(unixUser)) {
|
||||
@ -69,9 +69,6 @@ public abstract class AbstractRemote implements IRemote {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see de.hsadmin.remote.IRemote#add(java.lang.String, java.lang.String, java.util.Map)
|
||||
*/
|
||||
public Map<String, String> add(String runAsUser, String ticket,
|
||||
Map<String, String> setParams) throws HSAdminException {
|
||||
String user = runAsUser;
|
||||
@ -79,12 +76,12 @@ public abstract class AbstractRemote implements IRemote {
|
||||
try {
|
||||
if (authentication.login(user, ticket)) {
|
||||
ModuleInterface module = new GenericModuleImpl(transaction);
|
||||
Constructor<? extends Entity> constructor =
|
||||
Constructor<? extends AbstractEntity> constructor =
|
||||
getEntityClass().getConstructor();
|
||||
Entity entity = constructor.newInstance();
|
||||
AbstractEntity entity = constructor.newInstance();
|
||||
map2entity(setParams, entity);
|
||||
transaction.beginTransaction();
|
||||
Entity insertedEntity = module.add(entity);
|
||||
AbstractEntity insertedEntity = module.add(entity);
|
||||
transaction.commitTransaction();
|
||||
HashMap<String, String> entry = new HashMap<String, String>();
|
||||
entity2map(insertedEntity, entry);
|
||||
@ -99,9 +96,6 @@ public abstract class AbstractRemote implements IRemote {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see de.hsadmin.remote.IRemote#delete(java.lang.String, java.lang.String, java.util.Map)
|
||||
*/
|
||||
public void delete(String runAsUser, String ticket,
|
||||
Map<String, String> whereParams) throws HSAdminException {
|
||||
String user = runAsUser;
|
||||
@ -116,10 +110,10 @@ public abstract class AbstractRemote implements IRemote {
|
||||
throw new HSAdminException(
|
||||
"better safe than sorry: no where parameter found");
|
||||
}
|
||||
List<Entity> list = module.search(getEntityClass(),
|
||||
List<AbstractEntity> list = module.search(getEntityClass(),
|
||||
queryCondition, null);
|
||||
transaction.beginTransaction();
|
||||
for (Entity e : list) {
|
||||
for (AbstractEntity e : list) {
|
||||
if (e.isWriteAllowedFor(unixUser)) {
|
||||
module.delete(e);
|
||||
} else {
|
||||
@ -139,9 +133,6 @@ public abstract class AbstractRemote implements IRemote {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see de.hsadmin.remote.IRemote#update(java.lang.String, java.lang.String, java.util.Map, java.util.Map)
|
||||
*/
|
||||
public List<Map<String, String>> update(String runAsUser, String ticket,
|
||||
Map<String, String> setParams, Map<String, String> whereParams)
|
||||
throws HSAdminException {
|
||||
@ -158,10 +149,10 @@ public abstract class AbstractRemote implements IRemote {
|
||||
throw new HSAdminException(
|
||||
"better safe than sorry: no where parameter found");
|
||||
}
|
||||
List<Entity> list = module.search(getEntityClass(),
|
||||
queryCondition, "ORDER BY name ASC");
|
||||
List<AbstractEntity> list = module.search(getEntityClass(),
|
||||
queryCondition, "ORDER BY obj.name ASC");
|
||||
transaction.beginTransaction();
|
||||
for (Entity update : list) {
|
||||
for (AbstractEntity update : list) {
|
||||
if (update.isWriteAllowedFor(unixUser)) {
|
||||
transaction.detach(update);
|
||||
map2entity(setParams, update);
|
||||
|
269
hsarback/src/de/hsadmin/remote/CustomerRemote.java
Normal file
269
hsarback/src/de/hsadmin/remote/CustomerRemote.java
Normal file
@ -0,0 +1,269 @@
|
||||
package de.hsadmin.remote;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.mods.cust.BankAccount;
|
||||
import de.hsadmin.mods.cust.Contact;
|
||||
import de.hsadmin.mods.cust.Customer;
|
||||
|
||||
public class CustomerRemote extends AbstractRemote {
|
||||
|
||||
private static final DateFormat df = SimpleDateFormat.getDateInstance(DateFormat.SHORT);
|
||||
|
||||
@Override
|
||||
protected Class<? extends AbstractEntity> getEntityClass() {
|
||||
return Customer.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entity2map(AbstractEntity entity,
|
||||
Map<String, String> resultMap) {
|
||||
Customer cust = (Customer) entity;
|
||||
resultMap.put("id", Long.toString(cust.getId()));
|
||||
resultMap.put("membercode", cust.getName());
|
||||
resultMap.put("memberno", Integer.toString(cust.getMemberNo()));
|
||||
Date memberSince = cust.getMemberSince();
|
||||
if (assertNotNull(memberSince)) {
|
||||
resultMap.put("membersince", df.format(memberSince));
|
||||
}
|
||||
Date memberUntil = cust.getMemberUntil();
|
||||
if (assertNotNull(memberUntil)) {
|
||||
resultMap.put("memberuntil", df.format(memberUntil));
|
||||
}
|
||||
resultMap.put("memberrole", cust.getMemberRole());
|
||||
Date authorContract = cust.getAuthorContract();
|
||||
if (assertNotNull(authorContract)) {
|
||||
resultMap.put("authorcontract", df.format(authorContract));
|
||||
}
|
||||
Date nonDiscContract = cust.getNonDiscContract();
|
||||
if (assertNotNull(nonDiscContract)) {
|
||||
resultMap.put("nondisccontract", df.format(nonDiscContract));
|
||||
}
|
||||
Date sharesUpdated = cust.getSharesUpdated();
|
||||
if (assertNotNull(sharesUpdated)) {
|
||||
resultMap.put("sharesupdated", df.format(sharesUpdated));
|
||||
}
|
||||
resultMap.put("sharessigned", Integer.toString(cust.getSharesSigned()));
|
||||
resultMap.put("uidvat", cust.getUidVAT());
|
||||
BankAccount bank = cust.getBankAccount();
|
||||
if (bank != null) {
|
||||
resultMap.put("autodebit_ga", bank.getAutoDebitGA() != null && bank.getAutoDebitGA() ? "Yes" : "No");
|
||||
resultMap.put("autodebit_ar", bank.getAutoDebitAR() != null && bank.getAutoDebitAR() ? "Yes" : "No");
|
||||
resultMap.put("autodebit_op", bank.getAutoDebitOP() != null && bank.getAutoDebitOP() ? "Yes" : "No");
|
||||
resultMap.put("bank_customer", bank.getBankCustomer());
|
||||
resultMap.put("bank_account", bank.getBankAccount());
|
||||
resultMap.put("bank_code", bank.getBankCode());
|
||||
resultMap.put("bank_name", bank.getBankName());
|
||||
}
|
||||
Set<Contact> contacts = cust.getContacts();
|
||||
if (contacts != null && !contacts.isEmpty()) {
|
||||
Contact c = contacts.iterator().next();
|
||||
resultMap.put("contact_salut", c.getSalut());
|
||||
resultMap.put("contact_title", c.getTitle());
|
||||
resultMap.put("contact_firstname", c.getFirstName());
|
||||
resultMap.put("contact_lastname", c.getLastName());
|
||||
resultMap.put("contact_firma", c.getFirma());
|
||||
resultMap.put("contact_co", c.getCo());
|
||||
resultMap.put("contact_street", c.getStreet());
|
||||
resultMap.put("contact_zipcode", c.getZipCode());
|
||||
resultMap.put("contact_city", c.getCity());
|
||||
resultMap.put("contact_country", c.getCountry());
|
||||
resultMap.put("contact_phone_private", c.getPhonePrivate());
|
||||
resultMap.put("contact_phone_office", c.getPhoneOffice());
|
||||
resultMap.put("contact_phone_mobile", c.getPhoneMobile());
|
||||
resultMap.put("contact_fax", c.getFax());
|
||||
resultMap.put("contact_email", c.getEmail());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void map2entity(Map<String, String> setParams,
|
||||
AbstractEntity entity) {
|
||||
Customer cust = (Customer) entity;
|
||||
String idStr = setParams.get("id");
|
||||
if (assertNotNull(idStr)) {
|
||||
cust.setId(Long.parseLong(idStr));
|
||||
}
|
||||
String memberCode = setParams.get("membercode");
|
||||
if (assertNotNull(memberCode)) {
|
||||
cust.setName(memberCode);
|
||||
}
|
||||
String memberNo = setParams.get("memberno");
|
||||
if (assertNotNull(memberNo)) {
|
||||
cust.setMemberNo(Integer.parseInt(memberNo));
|
||||
}
|
||||
String memberSince = setParams.get("membersince");
|
||||
if (assertNotNull(memberSince)) {
|
||||
try {
|
||||
cust.setMemberSince(df.parse(memberSince));
|
||||
} catch (ParseException e) {
|
||||
// don't care
|
||||
}
|
||||
}
|
||||
String memberUntil = setParams.get("memberuntil");
|
||||
if (assertNotNull(memberUntil)) {
|
||||
try {
|
||||
cust.setMemberUntil(df.parse(memberUntil));
|
||||
} catch (ParseException e) {
|
||||
// don't care
|
||||
}
|
||||
}
|
||||
String memberRole = setParams.get("memberrole");
|
||||
if (assertNotNull(memberRole)) {
|
||||
cust.setMemberRole(memberRole);
|
||||
}
|
||||
String authorContract = setParams.get("authorcontract");
|
||||
if (assertNotNull(authorContract)) {
|
||||
try {
|
||||
cust.setAuthorContract(df.parse(authorContract));
|
||||
} catch (ParseException e) {
|
||||
// don't care
|
||||
}
|
||||
}
|
||||
String nonDiscContract = setParams.get("nondisccontract");
|
||||
if (assertNotNull(nonDiscContract)) {
|
||||
try {
|
||||
cust.setNonDiscContract(df.parse(nonDiscContract));
|
||||
} catch (ParseException e) {
|
||||
// don't care
|
||||
}
|
||||
}
|
||||
String sharesUpdated = setParams.get("sharesupdated");
|
||||
if (assertNotNull(sharesUpdated)) {
|
||||
try {
|
||||
cust.setSharesUpdated(df.parse(sharesUpdated));
|
||||
} catch (ParseException e) {
|
||||
// don't care
|
||||
}
|
||||
}
|
||||
String sharesSigned = setParams.get("sharessigned");
|
||||
if (assertNotNull(sharesSigned)) {
|
||||
cust.setId(Integer.parseInt(sharesSigned));
|
||||
}
|
||||
String uidVat = setParams.get("uidvat");
|
||||
if (assertNotNull(uidVat)) {
|
||||
cust.setUidVAT(uidVat);
|
||||
}
|
||||
BankAccount bank = cust.getBankAccount();
|
||||
if (bank == null) {
|
||||
bank = new BankAccount();
|
||||
bank.setCustomer(cust);
|
||||
cust.setBankAccount(bank);
|
||||
}
|
||||
String autoDebitGA = setParams.get("autodebit_ga");
|
||||
if (assertNotNull(autoDebitGA)) {
|
||||
autoDebitGA = autoDebitGA.toUpperCase();
|
||||
bank.setAutoDebitGA(new Boolean(autoDebitGA.startsWith("T") || autoDebitGA.startsWith("Y")));
|
||||
}
|
||||
String autoDebitAR = setParams.get("autodebit_ar");
|
||||
if (assertNotNull(autoDebitAR)) {
|
||||
autoDebitAR = autoDebitAR.toUpperCase();
|
||||
bank.setAutoDebitAR(new Boolean(autoDebitAR.startsWith("T") || autoDebitAR.startsWith("Y")));
|
||||
}
|
||||
String autoDebitOP = setParams.get("autodebit_op");
|
||||
if (assertNotNull(autoDebitOP)) {
|
||||
autoDebitOP = autoDebitOP.toUpperCase();
|
||||
bank.setAutoDebitOP(new Boolean(autoDebitOP.startsWith("T") || autoDebitOP.startsWith("Y")));
|
||||
}
|
||||
String bankCustomer = setParams.get("bank_customer");
|
||||
if (assertNotNull(bankCustomer)) {
|
||||
bank.setBankCustomer(bankCustomer);
|
||||
}
|
||||
String bankAccount = setParams.get("bank_account");
|
||||
if (assertNotNull(bankAccount)) {
|
||||
bank.setBankAccount(bankAccount);
|
||||
}
|
||||
String bankCode = setParams.get("bank_code");
|
||||
if (assertNotNull(bankCode)) {
|
||||
bank.setBankCode(bankCode);
|
||||
}
|
||||
String bankName = setParams.get("bank_name");
|
||||
if (assertNotNull(bankName)) {
|
||||
bank.setBankName(bankName);
|
||||
}
|
||||
Set<Contact> contacts = cust.getContacts();
|
||||
Contact c = null;
|
||||
if (contacts == null || contacts.isEmpty()) {
|
||||
c = new Contact(cust);
|
||||
contacts.add(c);
|
||||
} else {
|
||||
c = contacts.iterator().next();
|
||||
}
|
||||
String salut = setParams.get("contact_salut");
|
||||
if (assertNotNull(salut)) {
|
||||
c.setSalut(salut);
|
||||
}
|
||||
String title = setParams.get("contact_title");
|
||||
if (assertNotNull(title)) {
|
||||
c.setTitle(title);
|
||||
}
|
||||
String firstName = setParams.get("contact_firstname");
|
||||
if (assertNotNull(firstName)) {
|
||||
c.setFirstName(firstName);
|
||||
}
|
||||
String lastName = setParams.get("contact_lastname");
|
||||
if (assertNotNull(lastName)) {
|
||||
c.setLastName(lastName);
|
||||
}
|
||||
String firma = setParams.get("contact_firma");
|
||||
if (assertNotNull(firma)) {
|
||||
c.setLastName(firma);
|
||||
}
|
||||
String co = setParams.get("contact_co");
|
||||
if (assertNotNull(co)) {
|
||||
c.setCo(co);
|
||||
}
|
||||
String street = setParams.get("contact_street");
|
||||
if (assertNotNull(street)) {
|
||||
c.setStreet(street);
|
||||
}
|
||||
String zipCode = setParams.get("contact_zipcode");
|
||||
if (assertNotNull(zipCode)) {
|
||||
c.setZipCode(zipCode);
|
||||
}
|
||||
String city = setParams.get("contact_city");
|
||||
if (assertNotNull(city)) {
|
||||
c.setCity(city);
|
||||
}
|
||||
String country = setParams.get("contact_country");
|
||||
if (assertNotNull(country)) {
|
||||
c.setCountry(country);
|
||||
}
|
||||
String phonePrivate = setParams.get("contact_phone_private");
|
||||
if (assertNotNull(phonePrivate)) {
|
||||
c.setPhonePrivate(phonePrivate);
|
||||
}
|
||||
String phoneOffice = setParams.get("contact_phone_office");
|
||||
if (assertNotNull(phoneOffice)) {
|
||||
c.setPhoneOffice(phoneOffice);
|
||||
}
|
||||
String phoneMobile = setParams.get("contact_phone_mobile");
|
||||
if (assertNotNull(phoneMobile)) {
|
||||
c.setPhoneMobile(phoneMobile);
|
||||
}
|
||||
String fax = setParams.get("contact_fax");
|
||||
if (assertNotNull(fax)) {
|
||||
c.setFax(fax);
|
||||
}
|
||||
String eMail = setParams.get("contact_email");
|
||||
if (assertNotNull(eMail)) {
|
||||
c.setEmail(eMail);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void regularizeKeys(Map<String, String> whereParams) {
|
||||
// nothing to do
|
||||
replaceKey(whereParams, "membercode", "name");
|
||||
replaceKey(whereParams, "memberno", "memberNo");
|
||||
replaceKey(whereParams, "membersince", "memberSince");
|
||||
replaceKey(whereParams, "memberuntil", "memberUntil");
|
||||
}
|
||||
|
||||
}
|
@ -5,7 +5,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.core.model.Entity;
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.core.qserv.QueueTask;
|
||||
|
||||
public class QueueTaskRemote extends AbstractRemote {
|
||||
@ -13,12 +13,12 @@ public class QueueTaskRemote extends AbstractRemote {
|
||||
private static final DateFormat df = SimpleDateFormat.getDateInstance(DateFormat.SHORT);
|
||||
|
||||
@Override
|
||||
protected Class<? extends Entity> getEntityClass() {
|
||||
protected Class<? extends AbstractEntity> getEntityClass() {
|
||||
return QueueTask.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entity2map(Entity entity, Map<String, String> resultMap) {
|
||||
protected void entity2map(AbstractEntity entity, Map<String, String> resultMap) {
|
||||
QueueTask task = (QueueTask) entity;
|
||||
resultMap.put("id", Long.toString(task.getId()));
|
||||
resultMap.put("status", task.getStatus().toString());
|
||||
@ -37,7 +37,7 @@ public class QueueTaskRemote extends AbstractRemote {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void map2entity(Map<String, String> setParams, Entity entity) {
|
||||
protected void map2entity(Map<String, String> setParams, AbstractEntity entity) {
|
||||
// never used
|
||||
}
|
||||
|
||||
|
@ -2,18 +2,18 @@ package de.hsadmin.remote;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import de.hsadmin.core.model.Entity;
|
||||
import de.hsadmin.core.model.AbstractEntity;
|
||||
import de.hsadmin.mods.user.UnixUser;
|
||||
|
||||
public class UnixUserRemote extends AbstractRemote {
|
||||
|
||||
@Override
|
||||
protected Class<? extends Entity> getEntityClass() {
|
||||
protected Class<? extends AbstractEntity> getEntityClass() {
|
||||
return UnixUser.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entity2map(Entity entity, Map<String, String> map) {
|
||||
protected void entity2map(AbstractEntity entity, Map<String, String> map) {
|
||||
UnixUser user = (UnixUser) entity;
|
||||
map.put("id", Long.toString(user.getId()));
|
||||
map.put("name", user.getName());
|
||||
@ -33,7 +33,7 @@ public class UnixUserRemote extends AbstractRemote {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void map2entity(Map<String, String> map, Entity entity) {
|
||||
protected void map2entity(Map<String, String> map, AbstractEntity entity) {
|
||||
UnixUser user = (UnixUser) entity;
|
||||
String id = map.get("id");
|
||||
if (assertNotNull(id)) {
|
||||
|
@ -1,2 +1,3 @@
|
||||
member=de.hsadmin.remote.CustomerRemote
|
||||
user=de.hsadmin.remote.UnixUserRemote
|
||||
q=de.hsadmin.remote.QueueTaskRemote
|
||||
|
198
hsarback/test/de/hsadmin/remote/CustomerTest.java
Normal file
198
hsarback/test/de/hsadmin/remote/CustomerTest.java
Normal file
@ -0,0 +1,198 @@
|
||||
package de.hsadmin.remote;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
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 CustomerTest {
|
||||
|
||||
private static final String MODULE = "member";
|
||||
|
||||
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 testAddAsHostmaster() {
|
||||
String user = "pe";
|
||||
int membersCount = -9999;
|
||||
try {
|
||||
membersCount = getMembersCount(user);
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
setParams.put("membercode", "hsh00-aaa");
|
||||
setParams.put("memberno", "20001");
|
||||
setParams.put("membersince", "01.10.2010");
|
||||
setParams.put("contact_salut", "Herr");
|
||||
setParams.put("contact_title", "Dr.");
|
||||
setParams.put("contact_firstname", "Rainer");
|
||||
setParams.put("contact_lastname", "Mustermann");
|
||||
setParams.put("contact_salut", "Herr");
|
||||
setParams.put("contact_street", "Hauptstr. 1");
|
||||
setParams.put("contact_zipcode", "99998");
|
||||
setParams.put("contact_city", "Musterstadt");
|
||||
setParams.put("contact_country", "D");
|
||||
setParams.put("contact_phone_private", "+49 9999 123456");
|
||||
setParams.put("contact_email", "rainer.mustermann@example.org");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
setParams };
|
||||
try {
|
||||
client.execute(MODULE + ".add", params);
|
||||
// Object execute = client.execute(MODULE + ".add", params);
|
||||
// Map<?, ?> result = (Map<?, ?>) execute;
|
||||
// System.out.println(result);
|
||||
assertEquals(membersCount + 1, getMembersCount(user));
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchAsHostmaster() {
|
||||
String user = "pe";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
whereParams };
|
||||
try {
|
||||
Object execute = client.execute(MODULE + ".search", params);
|
||||
Object[] result = (Object[]) execute;
|
||||
assertTrue(result.length > 100);
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchAsPacAdmin() {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
whereParams };
|
||||
try {
|
||||
Object execute = client.execute(MODULE + ".search", params);
|
||||
Object[] result = (Object[]) execute;
|
||||
assertTrue(result.length == 0);
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchAsPacUser() {
|
||||
String user = "peh00-phor";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
whereParams };
|
||||
try {
|
||||
Object execute = client.execute(MODULE + ".search", params);
|
||||
Object[] result = (Object[]) execute;
|
||||
assertTrue(result.length == 0);
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchAsMember() {
|
||||
String user = "hsh00-peh";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
whereParams };
|
||||
try {
|
||||
Object execute = client.execute(MODULE + ".search", params);
|
||||
Object[] result = (Object[]) execute;
|
||||
assertTrue(result.length == 1);
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAsMember() {
|
||||
String user = "hsh00-aaa";
|
||||
int membersCount = -9999;
|
||||
try {
|
||||
membersCount = getMembersCount(user);
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
whereParams.put("membercode", "hsh00-aaa");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
whereParams };
|
||||
try {
|
||||
client.execute(MODULE + ".delete", params);
|
||||
assertEquals(membersCount - 1, getMembersCount(user));
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteAsHostmaster() {
|
||||
String user = "pe";
|
||||
int membersCount = -9999;
|
||||
try {
|
||||
membersCount = getMembersCount(user);
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
whereParams.put("membercode", "hsh00-aaa");
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
whereParams };
|
||||
try {
|
||||
client.execute(MODULE + ".delete", params);
|
||||
assertEquals(membersCount - 1, getMembersCount(user));
|
||||
} catch (XmlRpcException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private int getMembersCount(String user) throws XmlRpcException {
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
whereParams };
|
||||
Object execute = client.execute(MODULE + ".search", params);
|
||||
Object[] result = (Object[]) execute;
|
||||
return result.length;
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ public class QueueTaskTest {
|
||||
@Test
|
||||
public void testSearchAllAsPacAdmin() {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
@ -44,7 +44,7 @@ public class QueueTaskTest {
|
||||
try {
|
||||
Object execute = client.execute(MODULE + ".search", params);
|
||||
Object[] result = (Object[]) execute;
|
||||
assertTrue(result.length > 100);
|
||||
assertTrue(result.length > 20);
|
||||
for (Object o : result) {
|
||||
if (o instanceof Map<?, ?>) {
|
||||
Map<?, ?> row = (Map<?, ?>) o;
|
||||
@ -61,7 +61,7 @@ public class QueueTaskTest {
|
||||
@Test
|
||||
public void testUpdate() {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
setParams.put("details", "Test");
|
||||
@ -82,7 +82,7 @@ public class QueueTaskTest {
|
||||
@Test
|
||||
public void testCreateFails() {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
setParams.put("status", "done");
|
||||
setParams.put("title", "Test");
|
||||
@ -107,7 +107,7 @@ public class QueueTaskTest {
|
||||
@Test
|
||||
public void testDeleteAsPacAdminFails() {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
whereParams.put("user", "peh00");
|
||||
Object[] params = new Object[] { user,
|
||||
|
@ -34,20 +34,8 @@ public class RemoteCASHelper {
|
||||
loginURL = config.getProperty("loginURL", LOGIN_URL);
|
||||
}
|
||||
|
||||
public String getGrantingTicketURL(String user, String pw) {
|
||||
if ("peh00".equals(pw)) {
|
||||
pw = config.getProperty("peh00.passWord", "-");
|
||||
}
|
||||
if ("peh01".equals(pw)) {
|
||||
pw = config.getProperty("peh01.passWord", "-");
|
||||
}
|
||||
if ("pe".equals(pw)) {
|
||||
pw = config.getProperty("pe.passWord", "-");
|
||||
}
|
||||
if (user.equals(pw)) {
|
||||
System.err.println("Unknown Password for: " + pw);
|
||||
return null;
|
||||
}
|
||||
public String getGrantingTicketURL(String user) {
|
||||
String pw = config.getProperty(user + ".passWord", "-");
|
||||
try {
|
||||
String encodedParams = URLEncoder.encode("username", "UTF-8")
|
||||
+ "=" + URLEncoder.encode(user, "UTF-8")
|
||||
|
@ -5,6 +5,7 @@ import org.junit.runners.Suite;
|
||||
|
||||
@RunWith(Suite.class)
|
||||
@Suite.SuiteClasses({
|
||||
CustomerTest.class,
|
||||
UnixUserTest.class,
|
||||
// MySqlDatabaseTest.class,
|
||||
// MySqlUserTest.class,
|
||||
|
@ -35,7 +35,7 @@ public class UnixUserTest {
|
||||
@Test
|
||||
public void testSearchAsPacAdmin() {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
@ -62,7 +62,7 @@ public class UnixUserTest {
|
||||
int count = getObjectCount();
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
setParams.put("name", "peh00-test2");
|
||||
setParams.put("password", "test123");
|
||||
@ -91,7 +91,7 @@ public class UnixUserTest {
|
||||
int count = getObjectCount();
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
setParams.put("name", "peh01-testfail");
|
||||
setParams.put("password", "test123");
|
||||
@ -112,7 +112,7 @@ public class UnixUserTest {
|
||||
int count = getObjectCount();
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
setParams.put("name", "peh00-langer-name");
|
||||
setParams.put("password", "test123");
|
||||
@ -133,7 +133,7 @@ public class UnixUserTest {
|
||||
int count = getObjectCount();
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Map<String, String> setParams = new HashMap<String, String>();
|
||||
whereParams.put("name", "peh00-test2");
|
||||
@ -167,7 +167,7 @@ public class UnixUserTest {
|
||||
int count = getObjectCount();
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
whereParams.put("name", "peh00-langer-name");
|
||||
Object[] params = new Object[] { user,
|
||||
@ -186,7 +186,7 @@ public class UnixUserTest {
|
||||
int count = getObjectCount();
|
||||
try {
|
||||
String user = "peh01";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
whereParams.put("name", "peh00-test2");
|
||||
Object[] params = new Object[] { user,
|
||||
@ -205,7 +205,7 @@ public class UnixUserTest {
|
||||
int count = getObjectCount();
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
whereParams.put("name", "peh00-test2");
|
||||
Object[] params = new Object[] { user,
|
||||
@ -223,7 +223,7 @@ public class UnixUserTest {
|
||||
int count = -1;
|
||||
try {
|
||||
String user = "peh00";
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user, user);
|
||||
String grantingTicketURL = cas.getGrantingTicketURL(user);
|
||||
Map<String, String> whereParams = new HashMap<String, String>();
|
||||
Object[] params = new Object[] { user,
|
||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.BACKEND_URL),
|
||||
|
@ -4,6 +4,10 @@
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
version="2.5">
|
||||
|
||||
<listener>
|
||||
<listener-class>de.hsadmin.core.model.onetier.PersistenceManagerContextListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>Queue Status Servlet</servlet-name>
|
||||
<servlet-class>de.hsadmin.core.qserv.QueueStatusReceiverServlet</servlet-class>
|
||||
|
Loading…
Reference in New Issue
Block a user