diff --git a/src/main/java/info/bukova/isspst/AppInitListener.java b/src/main/java/info/bukova/isspst/AppInitListener.java index 361938c0..5c9ec19c 100644 --- a/src/main/java/info/bukova/isspst/AppInitListener.java +++ b/src/main/java/info/bukova/isspst/AppInitListener.java @@ -11,7 +11,7 @@ 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.requirements.RequirementTypeService; +import info.bukova.isspst.services.requirement.RequirementTypeService; import info.bukova.isspst.services.users.PermissionService; import info.bukova.isspst.services.users.RoleService; import info.bukova.isspst.services.users.UserService; diff --git a/src/main/java/info/bukova/isspst/Constants.java b/src/main/java/info/bukova/isspst/Constants.java index 92704251..396a19a4 100644 --- a/src/main/java/info/bukova/isspst/Constants.java +++ b/src/main/java/info/bukova/isspst/Constants.java @@ -8,9 +8,10 @@ import info.bukova.isspst.reporting.Report; import info.bukova.isspst.reporting.ReportMapping; import info.bukova.isspst.services.addressbook.AdbService; import info.bukova.isspst.services.buildings.BuildingService; -import info.bukova.isspst.services.munits.MUnitService; import info.bukova.isspst.services.material.MaterialService; -import info.bukova.isspst.services.requirements.RequirementTypeService; +import info.bukova.isspst.services.munits.MUnitService; +import info.bukova.isspst.services.requirement.RequirementService; +import info.bukova.isspst.services.requirement.RequirementTypeService; import info.bukova.isspst.services.users.RoleService; import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.workgroups.WorkgroupService; @@ -68,7 +69,7 @@ public class Constants { new Module(MOD_MUNITS, "Měrné jednotky", MUnitService.class), new Module(MOD_MATERIAL, "Materiál", MaterialService.class), new Module(MOD_WORKGROUPS, "Pracovní skupiny", WorkgroupService.class), - new Module(MOD_REQUIREMENTS, "Požadavky", null), + new Module(MOD_REQUIREMENTS, "Požadavky", RequirementService.class), new Module(MOD_WORKFLOW, "Procesy schválení", RequirementTypeService.class) }; diff --git a/src/main/java/info/bukova/isspst/DateTimeUtils.java b/src/main/java/info/bukova/isspst/DateTimeUtils.java new file mode 100644 index 00000000..884c5bf7 --- /dev/null +++ b/src/main/java/info/bukova/isspst/DateTimeUtils.java @@ -0,0 +1,57 @@ +package info.bukova.isspst; + +import java.util.Calendar; +import java.util.Date; + +import org.apache.commons.lang.time.DateUtils; + +public class DateTimeUtils +{ + public static Date getDate(Date value) + { + if (value == null) + { + return value; + } + + // Keep date - truncate time + return DateUtils.truncate(value, Calendar.DAY_OF_MONTH); + } + + public static boolean isEqualByDate(Date d1, Date d2) + { + if (d1 != null && d2 != null) + { + d1 = DateTimeUtils.getDate(d1); + d2 = DateTimeUtils.getDate(d2); + boolean equals = (d1.compareTo(d2) == 0); + return equals; + } + + return false; + } + + public static boolean isEqualByDateForFilter(Date value, Date search) + { + if (search == null) + { + return true; + } + else if (value != null) + { + return DateTimeUtils.isEqualByDate(value, search); + } + + return false; + } + + public static Date getCurrDateTime() + { + return new Date(); + } + + public static Date getCurrDate() + { + return DateTimeUtils.getDate(DateTimeUtils.getCurrDateTime()); + } +} diff --git a/src/main/java/info/bukova/isspst/StringUtils.java b/src/main/java/info/bukova/isspst/StringUtils.java index d3b8bcf2..f3728dfd 100644 --- a/src/main/java/info/bukova/isspst/StringUtils.java +++ b/src/main/java/info/bukova/isspst/StringUtils.java @@ -44,4 +44,10 @@ public class StringUtils { return Labels.getLabel("Db" + key); } + public static boolean isEqualForFilter(String value, String search) + { + value = StringUtils.nullStr(value).toLowerCase(); + search = StringUtils.nullStr(search).toLowerCase(); + return value.contains(search); + } } diff --git a/src/main/java/info/bukova/isspst/filters/RequirementFilter.java b/src/main/java/info/bukova/isspst/filters/RequirementFilter.java index a8663e2b..6a6296dd 100644 --- a/src/main/java/info/bukova/isspst/filters/RequirementFilter.java +++ b/src/main/java/info/bukova/isspst/filters/RequirementFilter.java @@ -1,6 +1,7 @@ package info.bukova.isspst.filters; -import static info.bukova.isspst.StringUtils.nullStr; +import info.bukova.isspst.DateTimeUtils; +import info.bukova.isspst.StringUtils; import info.bukova.isspst.data.Requirement; import org.hamcrest.Description; @@ -37,10 +38,11 @@ public class RequirementFilter implements Filter @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()); + boolean foundNumser = StringUtils.isEqualForFilter(item.getNumser(), condition.getNumser()); + boolean foundReqDate = DateTimeUtils.isEqualByDateForFilter(item.getReqDate(), condition.getReqDate()); + boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); + boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate()); + return foundNumser && foundReqDate && foundDescription && foundDeliveryDate; } @Factory diff --git a/src/main/java/info/bukova/isspst/services/AbstractService.java b/src/main/java/info/bukova/isspst/services/AbstractService.java index b0fbb427..32c8d7b4 100644 --- a/src/main/java/info/bukova/isspst/services/AbstractService.java +++ b/src/main/java/info/bukova/isspst/services/AbstractService.java @@ -5,8 +5,10 @@ import info.bukova.isspst.Constants; import info.bukova.isspst.Module; import info.bukova.isspst.dao.BaseDao; import info.bukova.isspst.data.DataModel; +import info.bukova.isspst.data.NumberSeries; import info.bukova.isspst.filters.Filter; import info.bukova.isspst.reporting.Report; +import info.bukova.isspst.services.numberseries.NumberSeriesService; import java.util.Arrays; import java.util.Date; @@ -25,7 +27,20 @@ public abstract class AbstractService implements Service protected BaseDao dao; private Validator validator; + + private NumberSeriesService numberSeriesService; + + public NumberSeriesService getNumberSeriesService() + { + return numberSeriesService; + } + + public void setNumberSeriesService(NumberSeriesService numberSeriesService) + { + this.numberSeriesService = numberSeriesService; + } + public void setDao(BaseDao dao) { this.dao = dao; } @@ -150,4 +165,22 @@ public abstract class AbstractService implements Service } } + protected String getNumberSerie() + { + String currentNumber = ""; + + if (numberSeriesService != null) + { + String moduleName = this.getModule().getId(); + NumberSeries ns = numberSeriesService.getNumberSerie(moduleName); + + if (ns != null) + { + currentNumber = ns.getCurrentNumber(); + numberSeriesService.increase(ns); + } + } + + return currentNumber; + } } diff --git a/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesServiceImpl.java b/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesServiceImpl.java index e38ecb54..fc275425 100644 --- a/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/numberseries/NumberSeriesServiceImpl.java @@ -1,10 +1,10 @@ package info.bukova.isspst.services.numberseries; -import org.springframework.transaction.annotation.Transactional; - import info.bukova.isspst.data.NumberSeries; import info.bukova.isspst.services.AbstractService; +import org.springframework.transaction.annotation.Transactional; + public class NumberSeriesServiceImpl extends AbstractService implements NumberSeriesService { @Transactional diff --git a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java index 4206d5ea..d0e9c52a 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementServiceImpl.java @@ -1,9 +1,31 @@ package info.bukova.isspst.services.requirement; import info.bukova.isspst.data.Requirement; -import info.bukova.isspst.services.AbstractService; +import info.bukova.isspst.services.AbstractOwnedService; -public class RequirementServiceImpl extends AbstractService implements RequirementService +import java.util.Date; + +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.transaction.annotation.Transactional; + +public class RequirementServiceImpl extends AbstractOwnedService implements RequirementService { + @Override + protected Requirement createEntity() + { + Requirement entity = new Requirement(); + + entity.setReqDate(new Date()); + + return entity; + } + @Override + @Transactional + @PreAuthorize("hasPermission(this, 'PERM_ADD')") + public void add(Requirement entity) + { + entity.setNumser(this.getNumberSerie()); + super.add(entity); + } } diff --git a/src/main/java/info/bukova/isspst/services/requirements/RequirementTypeService.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementTypeService.java similarity index 77% rename from src/main/java/info/bukova/isspst/services/requirements/RequirementTypeService.java rename to src/main/java/info/bukova/isspst/services/requirement/RequirementTypeService.java index 53727d34..60fd752e 100644 --- a/src/main/java/info/bukova/isspst/services/requirements/RequirementTypeService.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementTypeService.java @@ -1,4 +1,4 @@ -package info.bukova.isspst.services.requirements; +package info.bukova.isspst.services.requirement; import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.services.Service; diff --git a/src/main/java/info/bukova/isspst/services/requirements/RequirementTypeServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/RequirementTypeServiceImpl.java similarity index 82% rename from src/main/java/info/bukova/isspst/services/requirements/RequirementTypeServiceImpl.java rename to src/main/java/info/bukova/isspst/services/requirement/RequirementTypeServiceImpl.java index 276d8917..ee7d9ada 100644 --- a/src/main/java/info/bukova/isspst/services/requirements/RequirementTypeServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/RequirementTypeServiceImpl.java @@ -1,4 +1,4 @@ -package info.bukova.isspst.services.requirements; +package info.bukova.isspst.services.requirement; import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.services.AbstractOwnedService; diff --git a/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java index 61144417..d2c3646e 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementForm.java @@ -1,15 +1,77 @@ package info.bukova.isspst.ui.requirement; import info.bukova.isspst.data.Requirement; +import info.bukova.isspst.data.RequirementSubject; +import info.bukova.isspst.data.Workgroup; +import info.bukova.isspst.services.requirement.RequirementService; +import info.bukova.isspst.services.users.UserService; +import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.FormViewModel; +import java.util.List; + +import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.Init; +import org.zkoss.bind.annotation.NotifyChange; +import org.zkoss.zk.ui.select.annotation.WireVariable; public class RequirementForm extends FormViewModel { + @WireVariable + private UserService userService; + + @WireVariable + private WorkgroupService workgroupService; + + public List getCentres() { + return workgroupService.getUserCentres(userService.getCurrent()); + } + @WireVariable + private RequirementService requirementService; + + private RequirementSubject item; + + private int selItemIndex; + @Init(superclass = true) public void init() { + this.setSelItemIndex(-1); + } + + public RequirementSubject getItem() + { + return item; + } + + public void setItem(RequirementSubject item) + { + this.item = item; + } + + public int getSelItemIndex() + { + return selItemIndex; + } + public void setSelItemIndex(int selItemIndex) + { + this.selItemIndex = selItemIndex; + } + + @Command + @NotifyChange({"dataBean", "selItemIndex"}) + public void addItem() { +// RequirementSubject item = new Material(); +// requirementService.addItem(getDataBean(), item); +// selItemIndex = getDataBean().getItems().indexOf(item); + } +/* + @Command + @NotifyChange({"dataBean", "selItemIndex"}) + public void removeItem(@BindingParam("item") RequirementItem item) { + requirementService.removeItem(getDataBean(), item); + selItemIndex = -1; } +*/ } diff --git a/src/main/java/info/bukova/isspst/ui/requirements/RequirementTypesVM.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java similarity index 97% rename from src/main/java/info/bukova/isspst/ui/requirements/RequirementTypesVM.java rename to src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java index 0b6807a9..b1506eb0 100644 --- a/src/main/java/info/bukova/isspst/ui/requirements/RequirementTypesVM.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementTypesVM.java @@ -1,10 +1,10 @@ -package info.bukova.isspst.ui.requirements; +package info.bukova.isspst.ui.requirement; import info.bukova.isspst.Constants; import info.bukova.isspst.data.RequirementType; import info.bukova.isspst.data.Role; import info.bukova.isspst.data.Workflow; -import info.bukova.isspst.services.requirements.RequirementTypeService; +import info.bukova.isspst.services.requirement.RequirementTypeService; import info.bukova.isspst.services.users.RoleService; import java.util.ArrayList; diff --git a/src/main/resources/log4j.xml b/src/main/resources/log4j.xml index e4394694..5281aee1 100644 --- a/src/main/resources/log4j.xml +++ b/src/main/resources/log4j.xml @@ -12,24 +12,28 @@ - + - + - + - + - + + + + + diff --git a/src/main/webapp/WEB-INF/locales/zk-label.properties b/src/main/webapp/WEB-INF/locales/zk-label.properties index f66657a0..9bae6ea5 100644 --- a/src/main/webapp/WEB-INF/locales/zk-label.properties +++ b/src/main/webapp/WEB-INF/locales/zk-label.properties @@ -10,7 +10,17 @@ MenuUser=Uživatel AgendaActRequirements=Aktuální požadavky AgendaRequirementsHistory=Ukončené požadavky -RequirementsFormTitle="Požadavek" +RequirementsFormTitle=Požadavek +RequirementsFormNumberSerie=Číslo +RequirementsFormReqDate=Datum požadavku +RequirementsFormCenter=Středisko +RequirementsFormDescription=Popis +RequirementsFormDeliveryDate=Datum dodání +RequirementsGridNumberSerie=Číslo +RequirementsGridReqDate=Datum požadavku +RequirementsGridCenter=Středisko +RequirementsGridDescription=Popis +RequirementsGridDeliveryDate=Datum dodání AgendaMyOrders=Aktuální AgendaOrdersHistory=Ukončené @@ -141,4 +151,8 @@ DbValidationError=Chyba validace true=Ano false=Ne + +DateFormat=dd. MM. yyyy + +AddItem=Přidat položku... \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/spring/root-context.xml b/src/main/webapp/WEB-INF/spring/root-context.xml index b503cbbc..7bf44b4d 100644 --- a/src/main/webapp/WEB-INF/spring/root-context.xml +++ b/src/main/webapp/WEB-INF/spring/root-context.xml @@ -36,7 +36,7 @@ ${jdbc.dialect} - true + false update @@ -202,7 +202,7 @@ - + @@ -210,6 +210,7 @@ + diff --git a/src/main/webapp/WEB-INF/zk.xml b/src/main/webapp/WEB-INF/zk.xml index 287ac23d..5eaade67 100644 --- a/src/main/webapp/WEB-INF/zk.xml +++ b/src/main/webapp/WEB-INF/zk.xml @@ -1,43 +1,28 @@ - + - - + - true - - - org.zkoss.web.classWebResource.cache - false - - - - /WEB-INF/locales/zk-label.properties - /WEB-INF/locales/columns.properties - /WEB-INF/locales/validators.properties - - + true + + + org.zkoss.web.classWebResource.cache + false + + + /WEB-INF/locales/zk-label.properties + /WEB-INF/locales/columns.properties + /WEB-INF/locales/validators.properties + - /WEB-INF/lang-addons/mapa-lang-addon.xml - /WEB-INF/lang-addons/ckez-bind-lang-addon.xml - /WEB-INF/lang-addons/CzechSortListheader.xml - - + /WEB-INF/lang-addons/mapa-lang-addon.xml + /WEB-INF/lang-addons/ckez-bind-lang-addon.xml + /WEB-INF/lang-addons/CzechSortListheader.xml + /css/zk-modify.css /css/form.css /css/page.css - - - + + \ No newline at end of file diff --git a/src/main/webapp/img/item-add.png b/src/main/webapp/img/item-add.png new file mode 100644 index 00000000..271ad40f Binary files /dev/null and b/src/main/webapp/img/item-add.png differ diff --git a/src/main/webapp/img/item-remove.png b/src/main/webapp/img/item-remove.png new file mode 100644 index 00000000..1355f25e Binary files /dev/null and b/src/main/webapp/img/item-remove.png differ diff --git a/src/main/webapp/requirements/actual/requirements.zul b/src/main/webapp/requirements/actual/requirements.zul index 5945c28d..9cf94a1e 100644 --- a/src/main/webapp/requirements/actual/requirements.zul +++ b/src/main/webapp/requirements/actual/requirements.zul @@ -1,22 +1,50 @@ - - + + - - + - - - + + + + + - - +
- +
@@ -26,7 +54,42 @@
- + +
+
+ +
+
+
+ +
+ + + +
+ +
+
+
+ +
+
+
@@ -36,7 +99,13 @@
- +
@@ -44,15 +113,15 @@
- - \ No newline at end of file diff --git a/src/main/webapp/requirements/actual/requirementsForm.zul b/src/main/webapp/requirements/actual/requirementsForm.zul index 01a57305..958234f0 100644 --- a/src/main/webapp/requirements/actual/requirementsForm.zul +++ b/src/main/webapp/requirements/actual/requirementsForm.zul @@ -1,34 +1,87 @@ - - + + - + - ${labels.BuildingsFormCode} : + ${labels.RequirementsFormNumberSerie} : - + - ${labels.BuildingsFormName} : + ${labels.RequirementsFormReqDate} : - + - ${labels.BuildingsFormDescription} : + ${labels.RequirementsFormCenter} : - + + + + + + + ${labels.RequirementsFormDescription} : + + + + + + ${labels.RequirementsFormDeliveryDate} : + + + +