diff --git a/src/main/java/info/bukova/isspst/AppInitListener.java b/src/main/java/info/bukova/isspst/AppInitListener.java index 2daddb32..48d24734 100644 --- a/src/main/java/info/bukova/isspst/AppInitListener.java +++ b/src/main/java/info/bukova/isspst/AppInitListener.java @@ -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); + } + } } diff --git a/src/main/java/info/bukova/isspst/dao/NumberSeriesDao.java b/src/main/java/info/bukova/isspst/dao/NumberSeriesDao.java new file mode 100644 index 00000000..8794315d --- /dev/null +++ b/src/main/java/info/bukova/isspst/dao/NumberSeriesDao.java @@ -0,0 +1,7 @@ +package info.bukova.isspst.dao; + +import info.bukova.isspst.data.NumberSeries; + +public interface NumberSeriesDao extends BaseDao { + +} \ No newline at end of file diff --git a/src/main/java/info/bukova/isspst/dao/RequirementDao.java b/src/main/java/info/bukova/isspst/dao/RequirementDao.java new file mode 100644 index 00000000..0363e977 --- /dev/null +++ b/src/main/java/info/bukova/isspst/dao/RequirementDao.java @@ -0,0 +1,7 @@ +package info.bukova.isspst.dao; + +import info.bukova.isspst.data.Requirement; + +public interface RequirementDao extends BaseDao { + +} \ No newline at end of file diff --git a/src/main/java/info/bukova/isspst/dao/jpa/NumberSeriesDaoJPA.java b/src/main/java/info/bukova/isspst/dao/jpa/NumberSeriesDaoJPA.java new file mode 100644 index 00000000..812fff17 --- /dev/null +++ b/src/main/java/info/bukova/isspst/dao/jpa/NumberSeriesDaoJPA.java @@ -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 implements NumberSeriesDao { +} diff --git a/src/main/java/info/bukova/isspst/dao/jpa/RequirementDaoJPA.java b/src/main/java/info/bukova/isspst/dao/jpa/RequirementDaoJPA.java new file mode 100644 index 00000000..53de8190 --- /dev/null +++ b/src/main/java/info/bukova/isspst/dao/jpa/RequirementDaoJPA.java @@ -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 implements RequirementDao { +} diff --git a/src/main/java/info/bukova/isspst/data/NumberSeries.java b/src/main/java/info/bukova/isspst/data/NumberSeries.java new file mode 100644 index 00000000..a26e2538 --- /dev/null +++ b/src/main/java/info/bukova/isspst/data/NumberSeries.java @@ -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; + } +} diff --git a/src/main/java/info/bukova/isspst/data/Requirement.java b/src/main/java/info/bukova/isspst/data/Requirement.java new file mode 100644 index 00000000..6e6ecaff --- /dev/null +++ b/src/main/java/info/bukova/isspst/data/Requirement.java @@ -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; + } +} diff --git a/src/main/java/info/bukova/isspst/filters/RequirementFilter.java b/src/main/java/info/bukova/isspst/filters/RequirementFilter.java new file mode 100644 index 00000000..a8663e2b --- /dev/null +++ b/src/main/java/info/bukova/isspst/filters/RequirementFilter.java @@ -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 +{ + + private Requirement condition; + + public RequirementFilter(Requirement cond) + { + this.condition = cond; + } + + private static class RequirementMatcher extends TypeSafeMatcher + { + + 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 matchBuilding(Requirement building) + { + return new RequirementMatcher(building); + } + } + + @Override + public RequirementMatcher matcher() + { + return new RequirementMatcher(condition); + } + + @Override + public String queryString() + { + return ""; + } + +} diff --git a/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesService.java b/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesService.java new file mode 100644 index 00000000..37671f10 --- /dev/null +++ b/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesService.java @@ -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 +{ + public NumberSeries getNumberSerie(String module); + + public void increase(NumberSeries ns); +} diff --git a/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesServiceImpl.java b/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesServiceImpl.java new file mode 100644 index 00000000..e38ecb54 --- /dev/null +++ b/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesServiceImpl.java @@ -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 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); + } +} diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementService.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementService.java new file mode 100644 index 00000000..6a05d509 --- /dev/null +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementService.java @@ -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 { + +} diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java new file mode 100644 index 00000000..4206d5ea --- /dev/null +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java @@ -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 implements RequirementService +{ + +} diff --git a/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java new file mode 100644 index 00000000..61144417 --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java @@ -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 +{ + @Init(superclass = true) + public void init() + { + + } +} diff --git a/src/main/java/info/bukova/isspst/ui/requirement/RequirementList.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementList.java new file mode 100644 index 00000000..064d430c --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementList.java @@ -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 { + + @WireVariable + private RequirementService requirementService; + + @Init + public void init() { + service = requirementService; + dataClass = Requirement.class; + formZul = "requirementsForm.zul"; + dataFilter = new RequirementFilter(getFilterTemplate()); + } + +} diff --git a/src/main/resources/hibernate.cfg.xml b/src/main/resources/hibernate.cfg.xml index 3c62d43a..b9d9fb5e 100644 --- a/src/main/resources/hibernate.cfg.xml +++ b/src/main/resources/hibernate.cfg.xml @@ -16,6 +16,7 @@ - + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index 2d0850ab..5d855b3e 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -8,8 +8,9 @@ MenuSettings=Nastavení MenuAdministration=Administrace MenuUser=Uživatel -AgendaMyRequirements=Aktuální -AgendaRequirementsHistory=Ukončené +AgendaActRequirements=Aktuální požadavky +AgendaRequirementsHistory=Ukončené požadavky +RequirementsFormTitle="Požadavek" AgendaMyOrders=Aktuální AgendaOrdersHistory=Ukončené diff --git a/src/main/webapp/WEB-INF/spring/root-context.xml b/src/main/webapp/WEB-INF/spring/root-context.xml index 6ef6e9ad..28506495 100644 --- a/src/main/webapp/WEB-INF/spring/root-context.xml +++ b/src/main/webapp/WEB-INF/spring/root-context.xml @@ -127,6 +127,14 @@ + + + + + + + + @@ -190,4 +198,13 @@ + + + + + + + + + diff --git a/src/main/webapp/app/navigation.zul b/src/main/webapp/app/navigation.zul index 15f28161..b07ec495 100644 --- a/src/main/webapp/app/navigation.zul +++ b/src/main/webapp/app/navigation.zul @@ -16,7 +16,7 @@ - + diff --git a/src/main/webapp/img/reqact.png b/src/main/webapp/img/reqact.png new file mode 100644 index 00000000..f0d5476c Binary files /dev/null and b/src/main/webapp/img/reqact.png differ diff --git a/src/main/webapp/img/reqdone.png b/src/main/webapp/img/reqdone.png new file mode 100644 index 00000000..bff75d99 Binary files /dev/null and b/src/main/webapp/img/reqdone.png differ diff --git a/src/main/webapp/requirements/actual/index.zul b/src/main/webapp/requirements/actual/index.zul new file mode 100644 index 00000000..86024360 --- /dev/null +++ b/src/main/webapp/requirements/actual/index.zul @@ -0,0 +1,10 @@ + + + + + String gridZul = "requirements.zul"; + + + + + \ No newline at end of file diff --git a/src/main/webapp/requirements/actual/requirements.zul b/src/main/webapp/requirements/actual/requirements.zul new file mode 100644 index 00000000..5945c28d --- /dev/null +++ b/src/main/webapp/requirements/actual/requirements.zul @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+
+ + +
+ +
+
\ No newline at end of file diff --git a/src/main/webapp/requirements/actual/requirementsForm.zul b/src/main/webapp/requirements/actual/requirementsForm.zul new file mode 100644 index 00000000..01a57305 --- /dev/null +++ b/src/main/webapp/requirements/actual/requirementsForm.zul @@ -0,0 +1,35 @@ + + + + + + + + + + + + + ${labels.BuildingsFormCode} : + + + + + + ${labels.BuildingsFormName} : + + + + + + ${labels.BuildingsFormDescription} : + + + + + + + + + + \ No newline at end of file