|
|
@ -1,8 +1,8 @@
|
|
|
|
package info.bukova.isspst.services;
|
|
|
|
package info.bukova.isspst.services;
|
|
|
|
|
|
|
|
|
|
|
|
import static ch.lambdaj.Lambda.filter;
|
|
|
|
import static ch.lambdaj.Lambda.filter;
|
|
|
|
import info.bukova.isspst.Constants;
|
|
|
|
|
|
|
|
import info.bukova.isspst.Module;
|
|
|
|
import info.bukova.isspst.Module;
|
|
|
|
|
|
|
|
import info.bukova.isspst.ModuleUtils;
|
|
|
|
import info.bukova.isspst.SessionData;
|
|
|
|
import info.bukova.isspst.SessionData;
|
|
|
|
import info.bukova.isspst.dao.BaseDao;
|
|
|
|
import info.bukova.isspst.dao.BaseDao;
|
|
|
|
import info.bukova.isspst.dao.QueryDao;
|
|
|
|
import info.bukova.isspst.dao.QueryDao;
|
|
|
@ -73,6 +73,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (getModule() != null && !getModule().isActive()) {
|
|
|
|
|
|
|
|
throw new ModuleNotActiveException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
validate(entity);
|
|
|
|
validate(entity);
|
|
|
|
entity.setCreated(new Date());
|
|
|
|
entity.setCreated(new Date());
|
|
|
|
dao.add(entity);
|
|
|
|
dao.add(entity);
|
|
|
@ -86,6 +90,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (getModule() != null && !getModule().isActive()) {
|
|
|
|
|
|
|
|
throw new ModuleNotActiveException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
validate(entity);
|
|
|
|
validate(entity);
|
|
|
|
entity.setModified(new Date());
|
|
|
|
entity.setModified(new Date());
|
|
|
|
dao.modify(entity);
|
|
|
|
dao.modify(entity);
|
|
|
@ -99,6 +107,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (getModule() != null && !getModule().isActive()) {
|
|
|
|
|
|
|
|
throw new ModuleNotActiveException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dao.delete(entity);
|
|
|
|
dao.delete(entity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -137,6 +149,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (getModule() != null && !getModule().isActive()) {
|
|
|
|
|
|
|
|
throw new ModuleNotActiveException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dao.getById(id);
|
|
|
|
return dao.getById(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -148,6 +164,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (getModule() != null && !getModule().isActive()) {
|
|
|
|
|
|
|
|
throw new ModuleNotActiveException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dao.getAll();
|
|
|
|
return dao.getAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -159,6 +179,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (getModule() != null && !getModule().isActive()) {
|
|
|
|
|
|
|
|
throw new ModuleNotActiveException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return dao.execQuery(query);
|
|
|
|
return dao.execQuery(query);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -171,6 +195,10 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
throw new IsspstException("DAO is null");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (getModule() != null && !getModule().isActive()) {
|
|
|
|
|
|
|
|
throw new ModuleNotActiveException();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Query q = dao.getQuery(query);
|
|
|
|
Query q = dao.getQuery(query);
|
|
|
|
return (T) q.uniqueResult();
|
|
|
|
return (T) q.uniqueResult();
|
|
|
@ -189,13 +217,7 @@ public abstract class AbstractService<T extends DataModel> implements Service<T>
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Module getModule() {
|
|
|
|
public Module getModule() {
|
|
|
|
for (Module m : Constants.MODULES) {
|
|
|
|
return ModuleUtils.getModule(this.getClass());
|
|
|
|
if (Arrays.asList(this.getClass().getInterfaces()).contains(m.getServiceClass())) {
|
|
|
|
|
|
|
|
return m;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Report> getReports() {
|
|
|
|
public List<Report> getReports() {
|
|
|
|