@@ -1,17 +1,19 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import info.bukova.isspst.data.NumberSeries;
|
||||
import info.bukova.isspst.data.Permission;
|
||||
import info.bukova.isspst.data.Role;
|
||||
import info.bukova.isspst.data.User;
|
||||
import info.bukova.isspst.reporting.Report;
|
||||
import info.bukova.isspst.reporting.ReportMapping;
|
||||
import info.bukova.isspst.reporting.ReportType;
|
||||
import info.bukova.isspst.services.numberseries.NumberSeriesService;
|
||||
import info.bukova.isspst.services.users.PermissionService;
|
||||
import info.bukova.isspst.services.users.RoleService;
|
||||
import info.bukova.isspst.services.users.UserService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
|
||||
@@ -26,6 +28,7 @@ public class AppInitListener implements ServletContextListener {
|
||||
private RoleService roleService;
|
||||
private UserService userService;
|
||||
private PermissionService permService;
|
||||
private NumberSeriesService nsService;
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
@@ -41,12 +44,14 @@ public class AppInitListener implements ServletContextListener {
|
||||
roleService = ctx.getBean(RoleService.class);
|
||||
userService = ctx.getBean(UserService.class);
|
||||
permService = ctx.getBean(PermissionService.class);
|
||||
nsService =ctx.getBean(NumberSeriesService.class);
|
||||
|
||||
userService.grantAdmin();
|
||||
checkRoles();
|
||||
checkUsers();
|
||||
checkPermissions();
|
||||
checkAllAdminRights();
|
||||
this.checkNumberSeries();
|
||||
userService.removeAccess();
|
||||
|
||||
loadModuleReports();
|
||||
@@ -140,5 +145,19 @@ public class AppInitListener implements ServletContextListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkNumberSeries()
|
||||
{
|
||||
NumberSeries ns = nsService.getNumberSerie(Constants.MOD_REQUIREMENTS);
|
||||
|
||||
if (ns == null)
|
||||
{
|
||||
ns = new NumberSeries();
|
||||
ns.setModule(Constants.MOD_REQUIREMENTS);
|
||||
ns.setPrefix("");
|
||||
ns.setNumber(1);
|
||||
nsService.add(ns);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.NumberSeries;
|
||||
|
||||
public interface NumberSeriesDao extends BaseDao<NumberSeries> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package info.bukova.isspst.dao;
|
||||
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
|
||||
public interface RequirementDao extends BaseDao<Requirement> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.NumberSeriesDao;
|
||||
import info.bukova.isspst.data.NumberSeries;
|
||||
|
||||
public class NumberSeriesDaoJPA extends BaseDaoJPA<NumberSeries> implements NumberSeriesDao {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package info.bukova.isspst.dao.jpa;
|
||||
|
||||
import info.bukova.isspst.dao.RequirementDao;
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
|
||||
public class RequirementDaoJPA extends BaseDaoJPA<Requirement> implements RequirementDao {
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "NUMBERSERIES")
|
||||
public class NumberSeries extends BaseSimpleData
|
||||
{
|
||||
@Column(name = "MODULE")
|
||||
private String module;
|
||||
|
||||
@Column(name = "PREFIX")
|
||||
private String prefix;
|
||||
|
||||
@Column(name = "NUMBER")
|
||||
private int number;
|
||||
|
||||
public String getCurrentNumber()
|
||||
{
|
||||
return String.format("%s%06d", this.getPrefix(), this.getNumber());
|
||||
}
|
||||
|
||||
public String getModule()
|
||||
{
|
||||
return module;
|
||||
}
|
||||
|
||||
public void setModule(String module)
|
||||
{
|
||||
this.module = module;
|
||||
}
|
||||
|
||||
public String getPrefix()
|
||||
{
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix)
|
||||
{
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public int getNumber()
|
||||
{
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(int number)
|
||||
{
|
||||
this.number = number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "REQUIREMENT")
|
||||
public class Requirement extends BaseData implements DataModel
|
||||
{
|
||||
@Column(name = "NUMSER", unique = true)
|
||||
private String numser;
|
||||
|
||||
@Column(name = "REQDATE")
|
||||
private Date reqDate;
|
||||
|
||||
@Column(name = "DELIVERYDATE")
|
||||
private Date deliveryDate;
|
||||
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "WORKGROUP_ID")
|
||||
private Workgroup workgroup;
|
||||
|
||||
@Column(name = "DESCRIPTION")
|
||||
private String description;
|
||||
|
||||
public String getNumser()
|
||||
{
|
||||
return numser;
|
||||
}
|
||||
|
||||
public void setNumser(String numser)
|
||||
{
|
||||
this.numser = numser;
|
||||
}
|
||||
|
||||
public Date getReqDate()
|
||||
{
|
||||
return reqDate;
|
||||
}
|
||||
|
||||
public void setReqDate(Date reqDate)
|
||||
{
|
||||
this.reqDate = reqDate;
|
||||
}
|
||||
|
||||
public Date getDeliveryDate()
|
||||
{
|
||||
return deliveryDate;
|
||||
}
|
||||
|
||||
public void setDeliveryDate(Date deliveryDate)
|
||||
{
|
||||
this.deliveryDate = deliveryDate;
|
||||
}
|
||||
|
||||
public Workgroup getWorkgroup()
|
||||
{
|
||||
return workgroup;
|
||||
}
|
||||
|
||||
public void setWorkgroup(Workgroup workgroup)
|
||||
{
|
||||
this.workgroup = workgroup;
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description)
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import static info.bukova.isspst.StringUtils.nullStr;
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Factory;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
|
||||
public class RequirementFilter implements Filter<Requirement>
|
||||
{
|
||||
|
||||
private Requirement condition;
|
||||
|
||||
public RequirementFilter(Requirement cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
private static class RequirementMatcher extends TypeSafeMatcher<Requirement>
|
||||
{
|
||||
|
||||
private Requirement condition;
|
||||
|
||||
public RequirementMatcher(Requirement cond)
|
||||
{
|
||||
this.condition = cond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description desc)
|
||||
{
|
||||
desc.appendText("requirement matches");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(Requirement item)
|
||||
{
|
||||
return nullStr(item.getNumser()).toLowerCase().contains(nullStr(condition.getNumser()).toLowerCase())
|
||||
&& item.getReqDate().equals(condition.getReqDate())
|
||||
&& item.getDeliveryDate().equals(condition.getDeliveryDate())
|
||||
&& nullStr(item.getDescription()).toLowerCase().contains(nullStr(condition.getDescription()).toLowerCase());
|
||||
}
|
||||
|
||||
@Factory
|
||||
public static Matcher<Requirement> matchBuilding(Requirement building)
|
||||
{
|
||||
return new RequirementMatcher(building);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RequirementMatcher matcher()
|
||||
{
|
||||
return new RequirementMatcher(condition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryString()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package info.bukova.isspst.services.numberseries;
|
||||
|
||||
import info.bukova.isspst.data.NumberSeries;
|
||||
import info.bukova.isspst.services.Service;
|
||||
|
||||
public interface NumberSeriesService extends Service<NumberSeries>
|
||||
{
|
||||
public NumberSeries getNumberSerie(String module);
|
||||
|
||||
public void increase(NumberSeries ns);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package info.bukova.isspst.services.numberseries;
|
||||
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import info.bukova.isspst.data.NumberSeries;
|
||||
import info.bukova.isspst.services.AbstractService;
|
||||
|
||||
public class NumberSeriesServiceImpl extends AbstractService<NumberSeries> implements NumberSeriesService
|
||||
{
|
||||
@Transactional
|
||||
@Override
|
||||
public NumberSeries getNumberSerie(String module)
|
||||
{
|
||||
return this.selectSingle("from NumberSeries where MODULE = '" + module + "'");
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void increase(NumberSeries ns)
|
||||
{
|
||||
ns.setNumber(ns.getNumber() + 1);
|
||||
this.update(ns);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package info.bukova.isspst.services.requirement;
|
||||
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
import info.bukova.isspst.services.Service;
|
||||
|
||||
public interface RequirementService extends Service<Requirement> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package info.bukova.isspst.services.requirement;
|
||||
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
import info.bukova.isspst.services.AbstractService;
|
||||
|
||||
public class RequirementServiceImpl extends AbstractService<Requirement> implements RequirementService
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package info.bukova.isspst.ui.requirement;
|
||||
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
import info.bukova.isspst.ui.FormViewModel;
|
||||
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
|
||||
public class RequirementForm extends FormViewModel<Requirement>
|
||||
{
|
||||
@Init(superclass = true)
|
||||
public void init()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package info.bukova.isspst.ui.requirement;
|
||||
|
||||
import info.bukova.isspst.data.Requirement;
|
||||
import info.bukova.isspst.filters.RequirementFilter;
|
||||
import info.bukova.isspst.services.requirement.RequirementService;
|
||||
import info.bukova.isspst.ui.ListViewModel;
|
||||
|
||||
import org.zkoss.bind.annotation.Init;
|
||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
||||
|
||||
public class RequirementList extends ListViewModel<Requirement> {
|
||||
|
||||
@WireVariable
|
||||
private RequirementService requirementService;
|
||||
|
||||
@Init
|
||||
public void init() {
|
||||
service = requirementService;
|
||||
dataClass = Requirement.class;
|
||||
formZul = "requirementsForm.zul";
|
||||
dataFilter = new RequirementFilter(getFilterTemplate());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user