Vložen bázový kód pro agendu Požadavky / Aktivní.

refs #100
multitenant
František Přibyl 11 years ago
parent a834b91091
commit 177e29fe23

@ -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();
@ -141,4 +146,18 @@ 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());
}
}

@ -16,6 +16,7 @@
<mapping class="info.bukova.isspst.data.Workgroup"></mapping>
<mapping class="info.bukova.isspst.data.Member"></mapping>
<mapping class="info.bukova.isspst.data.JobMapping"></mapping>
<mapping class="info.bukova.isspst.data.NumberSeries"></mapping>
<mapping class="info.bukova.isspst.data.Requirement"></mapping>
</session-factory>
</hibernate-configuration>

@ -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é

@ -128,6 +128,14 @@
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="requirementDao" class="info.bukova.isspst.dao.jpa.RequirementDaoJPA">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="numericSeriesDao" class="info.bukova.isspst.dao.jpa.NumberSeriesDaoJPA">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- Business logic -->
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
@ -190,4 +198,13 @@
<property name="validator" ref="validator"/>
</bean>
<bean id="requirementService" class="info.bukova.isspst.services.requirement.RequirementServiceImpl">
<property name="dao" ref="requirementDao" />
<property name="validator" ref="validator" />
</bean>
<bean id="numericSeriesService" class="info.bukova.isspst.services.numberseries.NumberSeriesServiceImpl">
<property name="dao" ref="numericSeriesDao" />
<property name="validator" ref="validator" />
</bean>
</beans>

@ -16,7 +16,7 @@
<tabpanels hflex="1">
<tabpanel>
<menubar orient="vertical">
<menuitem label="${labels.AgendaMyRequirements}" href="/requirements/actual" />
<menuitem label="${labels.AgendaActRequirements}" href="/requirements/actual" />
<menuitem label="${labels.AgendaRequirementsHistory}" href="/requirements/history" />
</menubar>
</tabpanel>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

@ -0,0 +1,10 @@
<?page title="${labels.AgendaActRequirements}" contentType="text/html;charset=UTF-8"?>
<zk>
<zscript>
String gridZul = "requirements.zul";
</zscript>
<include src="../../app/template.zhtml"/>
</zk>

@ -0,0 +1,58 @@
<?page title="${labels.AgendaActRequirements}" contentType="text/html;charset=UTF-8"?>
<zk>
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
<window border="normal" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.RequirementList')">
<caption zclass="form-caption" label="${labels.AgendaActRequirements}" />
<include src="/app/toolbar.zul" />
<listbox model="@load(vm.dataList)" selectedItem="@bind(vm.dataBean)">
<listhead menupopup="auto">
<listheader label="${labels.BuildingsGridColumnCode}" sort="czech(numser)" width="10%" />
<listheader label="${labels.BuildingsGridColumnName}" sort="auto(reqDate)" width="30%" />
<listheader label="${labels.BuildingsGridColumnDescription}" sort="czech(description)" width="60%" />
</listhead>
<auxhead sclass="category-center" visible="@load(vm.filter)">
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<textbox value="@bind(vm.filterTemplate.numser)" instant="true" onChange="@command('doFilter')" sclass="find-grid-textbox" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<datebox value="@bind(vm.filterTemplate.reqDate)" instant="true" onChange="@command('doFilter')" sclass="find-grid-textbox" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<textbox value="@bind(vm.filterTemplate.description)" instant="true" onChange="@command('doFilter')" sclass="find-grid-textbox" />
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader>
</auxhead>
<template name="model">
<listitem>
<listcell label="@load(each.numser)" />
<listcell label="@load(each.reqDate)" />
<listcell label="@load(each.description)" />
</listitem>
</template>
</listbox>
</window>
</zk>

@ -0,0 +1,35 @@
<?page title="${labels.RequirementsFormTitle}" contentType="text/html;charset=UTF-8"?>
<zk>
<window id="editWin" closable="true" border="normal" position="center" apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('info.bukova.isspst.ui.requirement.RequirementForm')">
<caption src="/img/reqact.png" zclass="form-caption" label="RequirementsFormTitle" />
<vlayout>
<grid hflex="min">
<columns>
<column align="right" hflex="min" />
<column />
</columns>
<rows>
<row>
<cell sclass="row-title">${labels.BuildingsFormCode} :</cell>
<cell>
<textbox id="code" constraint="@load(vm.constriant)" width="200px" value="@bind(vm.dataBean.numser)" />
</cell>
</row>
<row>
<cell sclass="row-title">${labels.BuildingsFormName} :</cell>
<cell>
<datebox id="name" width="200px" value="@bind(vm.dataBean.reqDate)" />
</cell>
</row>
<row>
<cell sclass="row-title">${labels.BuildingsFormDescription} :</cell>
<cell>
<textbox id="description" width="300px" value="@bind(vm.dataBean.description)" />
</cell>
</row>
</rows>
</grid>
<include src="/app/formButtons.zul" />
</vlayout>
</window>
</zk>
Loading…
Cancel
Save