Požadavky na objednávky přepracovány do záložek.

Funkčnost sjednocena s požadavky na cestovní příkaz.

closes #109
multitenant
František Přibyl 10 years ago
parent c48fb65949
commit 50ee0215c0

@ -20,13 +20,13 @@ public class EntityMessageBuilder implements MessageBuilder {
@Override @Override
public MailMessage buildMessage(MailMessage template, Object data) { public MailMessage buildMessage(MailMessage template, Object data) {
MailMessage msg = new MailMessage(template); MailMessage msg = new MailMessage(template);
msg.setSubject(replacaProperties(msg.getSubject(), data)); msg.setSubject(replaceProperties(msg.getSubject(), data));
msg.setText(replacaProperties(msg.getText(), data)); msg.setText(replaceProperties(msg.getText(), data));
msg.setHtml(html); msg.setHtml(html);
return msg; return msg;
} }
private String replacaProperties(String src, Object data) { private String replaceProperties(String src, Object data) {
int current = 0; int current = 0;
List<String> properties = new ArrayList<String>(); List<String> properties = new ArrayList<String>();
boolean found = false; boolean found = false;

@ -2,10 +2,12 @@ package info.bukova.isspst.services.requirement;
import info.bukova.isspst.data.RequirementBase; import info.bukova.isspst.data.RequirementBase;
import info.bukova.isspst.data.User; import info.bukova.isspst.data.User;
import info.bukova.isspst.services.Service;
import java.util.List; import java.util.List;
public interface RequirementBaseService<T extends RequirementBase> { public interface RequirementBaseService<T extends RequirementBase> extends Service<T>
{
public void loadAuthItems(T data); public void loadAuthItems(T data);
public void loadType(T data); public void loadType(T data);
@ -14,4 +16,9 @@ public interface RequirementBaseService<T extends RequirementBase> {
public boolean canApprove(T entity); public boolean canApprove(T entity);
public List<User> getNextApprover(T entity); public List<User> getNextApprover(T entity);
public List<T> getMy();
public List<T> getCentreReq();
public List<T> getWorkgroupReq();
} }

@ -16,13 +16,16 @@ import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.LazyLoader; import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.settings.GlobalSettingsService;
import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.hibernate.LazyInitializationException; import org.hibernate.LazyInitializationException;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -37,6 +40,8 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
private GlobalSettingsService settingsService; private GlobalSettingsService settingsService;
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired
private WorkgroupService workgroupService;
@Override @Override
@Transactional @Transactional
@ -95,7 +100,28 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
wg = e.getWorkgroup(); wg = e.getWorkgroup();
} }
for (JobMapping jm : wg.getMembers()) {
try
{
if (wg.getMembers() == null)
{
throw new LazyInitializationException("");
}
wg.getMembers().size();
}
catch (LazyInitializationException ex)
{
Query q = dao.getQuery("from Workgroup where id = :id");
q.setParameter("id", wg.getId());
wg = (Workgroup) q.uniqueResult();
wg.getMembers().size();
}
for (JobMapping jm : wg.getMembers())
{
if (jm.getRole().equals(nextRole) && jm.getMember().isPerson()) { if (jm.getRole().equals(nextRole) && jm.getMember().isPerson()) {
users.add((User) jm.getMember()); users.add((User) jm.getMember());
} }
@ -248,4 +274,53 @@ public abstract class RequirementBaseServiceImpl<T extends RequirementBase> exte
return wf; return wf;
} }
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<T> getMy()
{
Query q = dao.getQuery("from " + dao.getEntityName() + " where ownedBy = :owner and state != :state");
q.setParameter("owner", getLoggedInUser());
q.setParameter("state", RequirementState.APPROVED);
return q.list();
}
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_SHOW_CENTRE_REQ')")
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')")
public List<T> getCentreReq()
{
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.centre c where tr.state != :state and c in (:wgList) order by tr.numser");
q.setParameterList("wgList", wgList);
q.setParameter("state", RequirementState.APPROVED);
return q.list();
}
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_SHOW_WORKGROUP_REQ')")
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_WORKGROUP_REQ')")
public List<T> getWorkgroupReq()
{
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
Query q = dao.getQuery("select tr from " + dao.getEntityName() + " tr join fetch tr.ownedBy join tr.workgroup w where tr.state != :state and w in (:wgList) order by tr.numser");
q.setParameterList("wgList", wgList);
q.setParameter("state", RequirementState.APPROVED);
return q.list();
}
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')")
public List<T> getAll()
{
Query q = dao.getQuery("from " + dao.getEntityName() + " as tr join fetch tr.ownedBy order by tr.numser");
return q.list();
}
} }

@ -1,8 +1,8 @@
package info.bukova.isspst.services.requirement; package info.bukova.isspst.services.requirement;
import info.bukova.isspst.data.Requirement; import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.services.Service;
public interface RequirementService extends Service<Requirement> { public interface RequirementService extends RequirementBaseService<Requirement>
{
} }

@ -24,6 +24,7 @@ public class RequirementServiceImpl extends
entity.setReqDate(new Date()); entity.setReqDate(new Date());
entity.setType(reqTypeService.getTypeById(Constants.REQTYPE_ORDER)); entity.setType(reqTypeService.getTypeById(Constants.REQTYPE_ORDER));
entity.setState(RequirementState.NEW); entity.setState(RequirementState.NEW);
this.addWorkflow(entity);
return entity; return entity;
} }

@ -1,15 +1,10 @@
package info.bukova.isspst.services.requirement; package info.bukova.isspst.services.requirement;
import info.bukova.isspst.data.TripRequirement; import info.bukova.isspst.data.TripRequirement;
import info.bukova.isspst.services.Service;
import java.util.List; public interface TripRequirementService extends RequirementBaseService<TripRequirement>
{
public interface TripRequirementService extends Service<TripRequirement> {
public List<TripRequirement> getCentreReq();
public List<TripRequirement> getWorkgroupReq();
public List<TripRequirement> getFromAll();
public void loadPassangers(TripRequirement entity); public void loadPassangers(TripRequirement entity);
} }

@ -8,12 +8,9 @@ import info.bukova.isspst.services.LazyLoader;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
import java.util.Date; import java.util.Date;
import java.util.List;
import org.hibernate.LazyInitializationException; import org.hibernate.LazyInitializationException;
import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -50,52 +47,6 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl<TripR
super.add(entity); super.add(entity);
} }
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_READ')")
public List<TripRequirement> getAll() {
Query q = dao.getQuery("from TripRequirement where ownedBy = :owner and state != :state");
q.setParameter("owner", getLoggedInUser());
q.setParameter("state", RequirementState.APPROVED);
return q.list();
}
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_SHOW_CENTRE_REQ')")
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_CENTRE_REQ')")
public List<TripRequirement> getCentreReq() {
List<Workgroup> wgList = workgroupService.getUserCentres(getLoggedInUser());
Query q = dao.getQuery("select tr from TripRequirement tr join fetch tr.ownedBy join tr.centre c where tr.state != :state and c in (:wgList) order by tr.numser");
q.setParameterList("wgList", wgList);
q.setParameter("state", RequirementState.APPROVED);
return q.list();
}
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_SHOW_WORKGROUP_REQ')")
@PostFilter("hasPermission(filterObject, 'PERM_SHOW_WORKGROUP_REQ')")
public List<TripRequirement> getWorkgroupReq() {
List<Workgroup> wgList = workgroupService.getUserWorkgroups(getLoggedInUser());
Query q = dao.getQuery("select tr from TripRequirement tr join fetch tr.ownedBy join tr.workgroup w where tr.state != :state and w in (:wgList) order by tr.numser");
q.setParameterList("wgList", wgList);
q.setParameter("state", RequirementState.APPROVED);
return q.list();
}
@SuppressWarnings("unchecked")
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_SHOW_ALL_REQ')")
public List<TripRequirement> getFromAll() {
Query q = dao.getQuery("from TripRequirement as tr join fetch tr.ownedBy order by tr.numser");
return q.list();
}
@Override @Override
@Transactional @Transactional
@LazyLoader("form") @LazyLoader("form")

@ -0,0 +1,56 @@
package info.bukova.isspst.ui.main;
import org.zkoss.bind.annotation.GlobalCommand;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
public class TabPanelsVM
{
private boolean showCentre;
private boolean showWorkgroup;
private boolean showAll;
@Init
public void init()
{
showCentre = true;
showWorkgroup = true;
showAll = true;
}
@GlobalCommand
@NotifyChange("showCentre")
public void disableCentre()
{
showCentre = false;
}
@GlobalCommand
@NotifyChange("showWorkgroup")
public void disableWorkgroup()
{
showWorkgroup = false;
}
@GlobalCommand
@NotifyChange("showAll")
public void disableAll()
{
showAll = false;
}
public boolean isShowCentre()
{
return showCentre;
}
public boolean isShowWorkgroup()
{
return showWorkgroup;
}
public boolean isShowAll()
{
return showAll;
}
}

@ -8,8 +8,11 @@ import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
import info.bukova.isspst.ui.requirement.RequirementSubpage; import info.bukova.isspst.ui.requirement.RequirementSubpage;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.security.access.AccessDeniedException;
import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zk.ui.select.annotation.WireVariable;
@ -43,6 +46,14 @@ public class ReqListMy extends RequirementSubpage<Requirement>
@Override @Override
protected List<Requirement> getListFromService() protected List<Requirement> getListFromService()
{ {
return super.getListFromService(); try
{
return requirementService.getMy();
}
catch (AccessDeniedException e)
{
BindUtils.postGlobalCommand(null, null, "disableAll", null);
return new ArrayList<Requirement>();
}
} }
} }

@ -8,8 +8,11 @@ import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
import info.bukova.isspst.ui.requirement.RequirementSubpage; import info.bukova.isspst.ui.requirement.RequirementSubpage;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.security.access.AccessDeniedException;
import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zk.ui.select.annotation.WireVariable;
@ -43,6 +46,14 @@ public class ReqListMyAll extends RequirementSubpage<Requirement>
@Override @Override
protected List<Requirement> getListFromService() protected List<Requirement> getListFromService()
{ {
return super.getListFromService(); try
{
return requirementService.getAll();
}
catch (AccessDeniedException e)
{
BindUtils.postGlobalCommand(null, null, "disableAll", null);
return new ArrayList<Requirement>();
}
} }
} }

@ -8,8 +8,11 @@ import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
import info.bukova.isspst.ui.requirement.RequirementSubpage; import info.bukova.isspst.ui.requirement.RequirementSubpage;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.security.access.AccessDeniedException;
import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zk.ui.select.annotation.WireVariable;
@ -43,6 +46,14 @@ public class ReqListMyCenters extends RequirementSubpage<Requirement>
@Override @Override
protected List<Requirement> getListFromService() protected List<Requirement> getListFromService()
{ {
return super.getListFromService(); try
{
return requirementService.getCentreReq();
}
catch (AccessDeniedException e)
{
BindUtils.postGlobalCommand(null, null, "disableCentre", null);
return new ArrayList<Requirement>();
}
} }
} }

@ -8,8 +8,11 @@ import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
import info.bukova.isspst.ui.requirement.RequirementSubpage; import info.bukova.isspst.ui.requirement.RequirementSubpage;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.security.access.AccessDeniedException;
import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zk.ui.select.annotation.WireVariable;
@ -43,6 +46,14 @@ public class ReqListMyWorkgroups extends RequirementSubpage<Requirement>
@Override @Override
protected List<Requirement> getListFromService() protected List<Requirement> getListFromService()
{ {
return super.getListFromService(); try
{
return requirementService.getWorkgroupReq();
}
catch (AccessDeniedException e)
{
BindUtils.postGlobalCommand(null, null, "disableWorkgroup", null);
return new ArrayList<Requirement>();
}
} }
} }

@ -8,8 +8,11 @@ import info.bukova.isspst.services.users.UserService;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
import info.bukova.isspst.ui.ListViewModel; import info.bukova.isspst.ui.ListViewModel;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.security.access.AccessDeniedException;
import org.zkoss.bind.BindUtils;
import org.zkoss.bind.annotation.GlobalCommand; import org.zkoss.bind.annotation.GlobalCommand;
import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.bind.annotation.NotifyChange;
@ -81,4 +84,18 @@ public class TripRequirementList extends ListViewModel<TripRequirement> {
tripRequirementService.loadPassangers(data); tripRequirementService.loadPassangers(data);
} }
@Override
protected List<TripRequirement> getListFromService()
{
try
{
return tripRequirementService.getMy();
}
catch (AccessDeniedException e)
{
BindUtils.postGlobalCommand(null, null, "disableAll", null);
return new ArrayList<TripRequirement>();
}
}
} }

@ -39,7 +39,7 @@ public class TripRequirementListAll extends RequirementSubpage<TripRequirement>
@Override @Override
protected List<TripRequirement> getListFromService() { protected List<TripRequirement> getListFromService() {
try { try {
return tripRequirementService.getFromAll(); return tripRequirementService.getAll();
} catch (AccessDeniedException e) { } catch (AccessDeniedException e) {
BindUtils.postGlobalCommand(null, null, "disableAll", null); BindUtils.postGlobalCommand(null, null, "disableAll", null);
return new ArrayList<TripRequirement>(); return new ArrayList<TripRequirement>();

@ -21,8 +21,8 @@ public class RequirementFormValidator extends BaseValidator
@Override @Override
public void validate(ValidationContext ctx) public void validate(ValidationContext ctx)
{ {
Property propertyWorkgroup = ctx.getProperties("workgroup")[0]; Property propertyCentre = ctx.getProperties("centre")[0];
Workgroup workgroup = (Workgroup) propertyWorkgroup.getValue(); Workgroup workgroup = (Workgroup) propertyCentre.getValue();
if (workgroup == null) if (workgroup == null)
{ {

@ -53,7 +53,7 @@
model="@load(vm.centres)" model="@load(vm.centres)"
readonly="true" readonly="true"
disabled="@load(vm.editRec)" disabled="@load(vm.editRec)"
selectedItem="@bind(fx.workgroup)"> selectedItem="@bind(fx.centre)">
<template name="model"> <template name="model">
<comboitem label="@load(each.fullName)" /> <comboitem label="@load(each.fullName)" />
</template> </template>
@ -94,7 +94,7 @@
</grid> </grid>
<hbox> <hbox>
<button <button
disabled="@load(empty fx.workgroup)" disabled="@load(empty fx.centre)"
image="/img/item-add.png" image="/img/item-add.png"
label="${labels.AddItem}" label="${labels.AddItem}"
onClick="@command('addSelectedItem')" onClick="@command('addSelectedItem')"

@ -6,8 +6,10 @@
apply="org.zkoss.bind.BindComposer" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.main.orders.requirements.ReqListMyAll')"> viewModel="@id('vm') @init('info.bukova.isspst.ui.main.orders.requirements.ReqListMyAll')">
<include src="/main/toolbar.zul" /> <include src="/main/toolbar.zul" />
<hbox vflex="1">
<listbox <listbox
vflex="1" vflex="1"
hflex="7"
selectedItem="@bind(vm.dataBean)" selectedItem="@bind(vm.dataBean)"
model="@load(vm.dataList)"> model="@load(vm.dataList)">
<listhead menupopup="auto"> <listhead menupopup="auto">
@ -140,5 +142,9 @@
</listitem> </listitem>
</template> </template>
</listbox> </listbox>
<div hflex="3">
<include src="/requirements/approveStatus.zul" />
</div>
</hbox>
</window> </window>
</zk> </zk>

@ -6,8 +6,10 @@
apply="org.zkoss.bind.BindComposer" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.main.orders.requirements.ReqListMyCenters')"> viewModel="@id('vm') @init('info.bukova.isspst.ui.main.orders.requirements.ReqListMyCenters')">
<include src="/main/toolbar.zul" /> <include src="/main/toolbar.zul" />
<hbox vflex="1">
<listbox <listbox
vflex="1" vflex="1"
hflex="7"
selectedItem="@bind(vm.dataBean)" selectedItem="@bind(vm.dataBean)"
model="@load(vm.dataList)"> model="@load(vm.dataList)">
<listhead menupopup="auto"> <listhead menupopup="auto">
@ -140,5 +142,9 @@
</listitem> </listitem>
</template> </template>
</listbox> </listbox>
<div hflex="3">
<include src="/requirements/approveStatus.zul" />
</div>
</hbox>
</window> </window>
</zk> </zk>

@ -6,8 +6,10 @@
apply="org.zkoss.bind.BindComposer" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.main.orders.requirements.ReqListMyWorkgroups')"> viewModel="@id('vm') @init('info.bukova.isspst.ui.main.orders.requirements.ReqListMyWorkgroups')">
<include src="/main/toolbar.zul" /> <include src="/main/toolbar.zul" />
<hbox vflex="1">
<listbox <listbox
vflex="1" vflex="1"
hflex="7"
selectedItem="@bind(vm.dataBean)" selectedItem="@bind(vm.dataBean)"
model="@load(vm.dataList)"> model="@load(vm.dataList)">
<listhead menupopup="auto"> <listhead menupopup="auto">
@ -140,5 +142,9 @@
</listitem> </listitem>
</template> </template>
</listbox> </listbox>
<div hflex="3">
<include src="/requirements/approveStatus.zul" />
</div>
</hbox>
</window> </window>
</zk> </zk>

@ -1,9 +1,18 @@
<tabbox vflex="1"> <tabbox
apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('info.bukova.isspst.ui.main.TabPanelsVM')"
vflex="1">
<tabs> <tabs>
<tab label="${labels.RequirementsGridMy}" /> <tab label="${labels.RequirementsGridMy}" />
<tab label="${labels.RequirementsGridMyCentres}" /> <tab
<tab label="${labels.RequirementsGridMyWorkgroups}" /> label="${labels.RequirementsGridMyCentres}"
<tab label="${labels.RequirementsGridAll}" /> disabled="@load(not vm.showCentre)" />
<tab
label="${labels.RequirementsGridMyWorkgroups}"
disabled="@load(not vm.showWorkgroup)" />
<tab
label="${labels.RequirementsGridAll}"
disabled="@load(not vm.showAll)" />
</tabs> </tabs>
<tabpanels> <tabpanels>
<tabpanel> <tabpanel>

Loading…
Cancel
Save