Conflicts:
	src/main/java/info/bukova/isspst/AppInitListener.java
	src/main/java/info/bukova/isspst/Constants.java
This commit is contained in:
2014-07-06 17:46:29 +02:00
59 changed files with 1446 additions and 50 deletions
@@ -1,8 +1,7 @@
package info.bukova.isspst;
import info.bukova.isspst.data.GlobalSettings;
import info.bukova.isspst.data.NumberSeries;
import java.util.List;
import info.bukova.isspst.data.Permission;
import info.bukova.isspst.data.RequirementType;
import info.bukova.isspst.data.Role;
@@ -12,10 +11,13 @@ import info.bukova.isspst.reporting.ReportMapping;
import info.bukova.isspst.reporting.ReportType;
import info.bukova.isspst.services.numberseries.NumberSeriesService;
import info.bukova.isspst.services.requirement.RequirementTypeService;
import info.bukova.isspst.services.settings.GlobalSettingsService;
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;
@@ -32,6 +34,7 @@ public class AppInitListener implements ServletContextListener {
private PermissionService permService;
private NumberSeriesService nsService;
private RequirementTypeService reqTypeService;
private GlobalSettingsService gSettingsService;
@Override
public void contextDestroyed(ServletContextEvent arg0) {
@@ -48,6 +51,7 @@ public class AppInitListener implements ServletContextListener {
userService = ctx.getBean(UserService.class);
permService = ctx.getBean(PermissionService.class);
nsService =ctx.getBean(NumberSeriesService.class);
gSettingsService = ctx.getBean(GlobalSettingsService.class);
reqTypeService = ctx.getBean(RequirementTypeService.class);
userService.grantAdmin();
@@ -57,6 +61,7 @@ public class AppInitListener implements ServletContextListener {
checkAllAdminRights();
this.checkNumberSeries();
checkReqTypes();
this.checkGlobalSettings();
userService.removeAccess();
loadModuleReports();
@@ -173,5 +178,13 @@ public class AppInitListener implements ServletContextListener {
nsService.add(ns);
}
}
private void checkGlobalSettings() {
if (gSettingsService.getAll().isEmpty()) {
GlobalSettings gs = new GlobalSettings();
gSettingsService.add(gs);
}
}
}
@@ -8,7 +8,8 @@ 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.material.MaterialService;
import info.bukova.isspst.services.reqsubjects.MaterialService;
import info.bukova.isspst.services.reqsubjects.ServiceItemService;
import info.bukova.isspst.services.munits.MUnitService;
import info.bukova.isspst.services.requirement.RequirementService;
import info.bukova.isspst.services.requirement.RequirementTypeService;
@@ -58,6 +59,7 @@ public class Constants {
public final static String MOD_BUILDINGS = "BUILDINGS";
public final static String MOD_MUNITS = "MUNITS";
public final static String MOD_MATERIAL = "MATERIAL";
public final static String MOD_SERVICES = "SERVICES";
public final static String MOD_WORKGROUPS = "WORKGROUPS";
public final static String MOD_REQUIREMENTS = "REQUIREMENTS";
public final static String MOD_WORKFLOW = "WORKFLOW";
@@ -68,6 +70,7 @@ public class Constants {
new Module(MOD_BUILDINGS, "Budovy", BuildingService.class),
new Module(MOD_MUNITS, "Měrné jednotky", MUnitService.class),
new Module(MOD_MATERIAL, "Materiál", MaterialService.class),
new Module(MOD_SERVICES, "Služby", ServiceItemService.class),
new Module(MOD_WORKGROUPS, "Pracovní skupiny", WorkgroupService.class),
new Module(MOD_REQUIREMENTS, "Požadavky", RequirementService.class),
new Module(MOD_WORKFLOW, "Procesy schválení", RequirementTypeService.class)
@@ -0,0 +1,7 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.GlobalSettings;
public interface GlobalSettingsDao extends BaseDao<GlobalSettings> {
}
@@ -0,0 +1,7 @@
package info.bukova.isspst.dao;
import info.bukova.isspst.data.ServiceItem;
public interface ServiceItemDao extends BaseDao<ServiceItem> {
}
@@ -0,0 +1,9 @@
package info.bukova.isspst.dao.jpa;
import info.bukova.isspst.dao.GlobalSettingsDao;
import info.bukova.isspst.data.GlobalSettings;
public class GlobalSettingsDaoJPA extends BaseDaoJPA<GlobalSettings> implements
GlobalSettingsDao {
}
@@ -0,0 +1,8 @@
package info.bukova.isspst.dao.jpa;
import info.bukova.isspst.dao.ServiceItemDao;
import info.bukova.isspst.data.ServiceItem;
public class ServiceItemDaoJPA extends BaseDaoJPA<ServiceItem> implements ServiceItemDao {
}
@@ -0,0 +1,22 @@
package info.bukova.isspst.data;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "GLOBALSETTINGS")
public class GlobalSettings extends BaseData {
@Column(name = "DATA", length = 1048576)
private String data;
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}
@@ -0,0 +1,81 @@
package info.bukova.isspst.data;
import javax.persistence.Column;
import javax.persistence.Embeddable;
@Embeddable
public class MUnitEmb {
@Column(name = "MUNIT_ID")
private Integer id;
@Column(name = "MUNIT_CODE")
private String code;
@Column(name = "MUNIT_DESCRIPTION")
private String description;
@Column(name = "MUNIT_NAME")
private String name;
public MUnitEmb() {
}
public MUnitEmb(MUnit munit) {
this.id = munit.getId();
this.code = munit.getCode();
this.description = munit.getDescription();
this.name = munit.getName();
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean eqWith(MUnit munit) {
return this.id == munit.getId()
&& this.code.equals(munit.getCode())
&& this.name.equals(munit.getName())
&& this.description.equals(munit.getDescription());
}
@Override
public boolean equals(Object munit) {
return munit != null
&& (munit instanceof MUnitEmb)
&& this.id == ((MUnitEmb)munit).getId()
&& (this.code == ((MUnitEmb)munit).getCode() || this.code.equals(((MUnitEmb)munit).getCode()))
&& (this.name == ((MUnitEmb)munit).getName() || this.name.equals(((MUnitEmb)munit).getName()))
&& (this.description == ((MUnitEmb)munit).getDescription() || this.description.equals(((MUnitEmb)munit).getDescription()));
}
@Override
public String toString() {
return this.code + " - " + this.name;
}
}
@@ -1,5 +1,6 @@
package info.bukova.isspst.data;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.Table;
@@ -7,6 +8,15 @@ import javax.persistence.Table;
@Table(name="MATERIAL")
public class Material extends RequirementSubject {
@Embedded
private MUnitEmb munit;
public MUnitEmb getMunit() {
return munit;
}
public void setMunit(MUnitEmb munit) {
this.munit = munit;
}
}
@@ -25,10 +25,10 @@ public abstract class RequirementSubject implements OwnedDataModel {
@Column(name =" ID")
@GeneratedValue(strategy = GenerationType.TABLE)
private int id;
@ManyToOne(fetch=FetchType.EAGER)
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="OWNED_BY_ID")
private User ownedBy;
@ManyToOne(fetch=FetchType.EAGER)
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name="MODIFIED_BY_ID")
private User modifiedBy;
@Column(name = "CREATED")
@@ -0,0 +1,10 @@
package info.bukova.isspst.data;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name = "SERVICE")
public class ServiceItem extends RequirementSubject {
}
@@ -0,0 +1,50 @@
package info.bukova.isspst.data;
import info.bukova.isspst.mail.MailMessage;
public class SettingsData {
private boolean enableRequirements;
private MailMessage newReqTemplate;
private MailMessage authReqTemplate;
private MailMessage confReqTemplate;
public SettingsData() {
newReqTemplate = new MailMessage();
authReqTemplate = new MailMessage();
confReqTemplate = new MailMessage();
}
public boolean isEnableRequirements() {
return enableRequirements;
}
public void setEnableRequirements(boolean enableRequirements) {
this.enableRequirements = enableRequirements;
}
public MailMessage getNewReqTemplate() {
return newReqTemplate;
}
public void setNewReqTemplate(MailMessage newReqTemplate) {
this.newReqTemplate = newReqTemplate;
}
public MailMessage getAuthReqTemplate() {
return authReqTemplate;
}
public void setAuthReqTemplate(MailMessage authReqTemplate) {
this.authReqTemplate = authReqTemplate;
}
public MailMessage getConfReqTemplate() {
return confReqTemplate;
}
public void setConfReqTemplate(MailMessage confReqTemplate) {
this.confReqTemplate = confReqTemplate;
}
}
@@ -1,5 +1,7 @@
package info.bukova.isspst.data;
import java.math.BigDecimal;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
@@ -21,6 +23,8 @@ public class Workflow extends BaseData {
private Role role;
@Column(name = "WORDER")
private Integer wOrder;
@Column(name = "WLIMIT", precision=15, scale=4)
private BigDecimal limit;
public Boolean getCentre() {
return centre;
@@ -56,4 +60,12 @@ public class Workflow extends BaseData {
this.wOrder = order;
}
public BigDecimal getLimit() {
return limit;
}
public void setLimit(BigDecimal limit) {
this.limit = limit;
}
}
@@ -0,0 +1,56 @@
package info.bukova.isspst.filters;
import static info.bukova.isspst.StringUtils.nullStr;
import info.bukova.isspst.data.ServiceItem;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
public class ServiceItemFilter implements Filter<ServiceItem> {
private ServiceItem condServiceItem;
public ServiceItemFilter(ServiceItem condServiceItem) {
this.condServiceItem = condServiceItem;
}
private static class ServiceItemMatcher extends TypeSafeMatcher<ServiceItem> {
private ServiceItem condServiceItem;
public ServiceItemMatcher(ServiceItem cond) {
this.condServiceItem = cond;
}
@Override
public void describeTo(Description desc) {
desc.appendText("material matches");
}
@Override
public boolean matchesSafely(ServiceItem item) {
return nullStr(item.getCode()).toLowerCase().contains(nullStr(condServiceItem.getCode()).toLowerCase())
&& nullStr(item.getName()).toLowerCase().contains(nullStr(condServiceItem.getName()).toLowerCase())
&& nullStr(item.getDescription()).toLowerCase().contains(nullStr(condServiceItem.getDescription()).toLowerCase());
}
@Factory
public static Matcher<ServiceItem> matchBuilding(ServiceItem material) {
return new ServiceItemMatcher(material);
}
}
@Override
public ServiceItemMatcher matcher() {
return new ServiceItemMatcher(condServiceItem);
}
@Override
public String queryString() {
// TODO query string
return "";
}
}
@@ -0,0 +1,49 @@
package info.bukova.isspst.mail;
import org.springframework.mail.SimpleMailMessage;
public class MailMessage extends SimpleMailMessage {
/**
*
*/
private static final long serialVersionUID = -3240551712942170018L;
private boolean html;
private String attachementName;
private byte[] attachementData;
private String contentType;
public boolean isHtml() {
return html;
}
public void setHtml(boolean html) {
this.html = html;
}
public byte[] getAttachementData() {
return attachementData;
}
public void setAttachementData(byte[] attachementData) {
this.attachementData = attachementData;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getAttachementName() {
return attachementName;
}
public void setAttachementName(String attachementName) {
this.attachementName = attachementName;
}
}
@@ -0,0 +1,7 @@
package info.bukova.isspst.mail;
public interface Mailer {
public void send(MailMessage message);
}
@@ -0,0 +1,57 @@
package info.bukova.isspst.mail;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.InputStreamSource;
import org.springframework.mail.MailParseException;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.scheduling.annotation.Async;
public class MailerWithAttachement implements Mailer {
private JavaMailSender sender;
private String from;
public MailerWithAttachement(JavaMailSender sender) {
this.sender = sender;
}
@Override
@Async
public void send(MailMessage message) {
MimeMessage mimeMessage = sender.createMimeMessage();
try {
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
if (message.getFrom() == null || message.getFrom().isEmpty()) {
if (from == null || from.isEmpty()) {
message.setFrom("tomcat@is.bukova.info");
} else {
message.setFrom(from);
}
}
helper.setFrom(message.getFrom());
helper.setTo(message.getTo());
helper.setSubject(message.getSubject());
helper.setText(message.getText(), message.isHtml());
if (message.getAttachementData() != null) {
InputStreamSource source = new ByteArrayResource(message.getAttachementData());
helper.addAttachment(message.getAttachementName(), source, message.getContentType());
}
} catch (MessagingException e) {
throw new MailParseException(e);
}
sender.send(mimeMessage);
}
public void setFrom(String from) {
this.from = from;
}
}
@@ -0,0 +1,33 @@
package info.bukova.isspst.mail;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.scheduling.annotation.Async;
public class SimpleMailer implements Mailer {
private JavaMailSender sender;
private String from;
public SimpleMailer(JavaMailSender sender) {
this.sender = sender;
}
@Override
@Async
public void send(MailMessage message) {
if (message.getFrom() == null || message.getFrom().isEmpty()) {
if (from == null || from.isEmpty()) {
message.setFrom("tomcat@is.bukova.info");
} else {
message.setFrom(from);
}
}
sender.send(message);
}
public void setFrom(String from) {
this.from = from;
}
}
@@ -41,11 +41,12 @@ public class IsspstPermissionEvaluator implements PermissionEvaluator {
private boolean evaluateGlobal(Service<?> service, String permission, List<Role> perms) {
String moduleId = "";
String perm = "";
String perm = permission;
for (Module m : Constants.MODULES) {
if (m.getServiceClass() != null && m.getServiceClass().isAssignableFrom(service.getClass())) {
moduleId = m.getId();
break;
}
}
@@ -1,4 +1,4 @@
package info.bukova.isspst.services.material;
package info.bukova.isspst.services.reqsubjects;
import info.bukova.isspst.data.Material;
import info.bukova.isspst.services.Service;
@@ -1,4 +1,4 @@
package info.bukova.isspst.services.material;
package info.bukova.isspst.services.reqsubjects;
import info.bukova.isspst.data.Material;
import info.bukova.isspst.services.AbstractOwnedService;
@@ -0,0 +1,8 @@
package info.bukova.isspst.services.reqsubjects;
import info.bukova.isspst.data.ServiceItem;
import info.bukova.isspst.services.Service;
public interface ServiceItemService extends Service<ServiceItem> {
}
@@ -0,0 +1,9 @@
package info.bukova.isspst.services.reqsubjects;
import info.bukova.isspst.data.ServiceItem;
import info.bukova.isspst.services.AbstractOwnedService;
public class ServiceItemServiceImpl extends AbstractOwnedService<ServiceItem> implements
ServiceItemService {
}
@@ -0,0 +1,110 @@
package info.bukova.isspst.services.settings;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import info.bukova.isspst.data.GlobalSettings;
import info.bukova.isspst.data.SettingsData;
import info.bukova.isspst.services.AbstractOwnedService;
import info.bukova.isspst.services.IsspstException;
public class GlobalSettingServiceImpl extends AbstractOwnedService<GlobalSettings> implements
GlobalSettingsService {
private final static Logger log = LoggerFactory.getLogger(GlobalSettingsService.class);
private final static String MARSHAL_ERROR = "Cannot marshal settings data: ";
private final static String UNMARSHAL_ERROR = "Cannot unmarshal settings data: ";
private Marshaller marshaller;
private Unmarshaller unmarshaller;
private SettingsData settings;
public GlobalSettingServiceImpl(Marshaller marshaller, Unmarshaller unmarshaller) {
this.marshaller = marshaller;
this.unmarshaller = unmarshaller;
}
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_ADD')")
public void add(GlobalSettings entity) {
if (!this.getAll().isEmpty()) {
throw new IsspstException("Global settings allready exists");
}
if (entity.getData() == null || entity.getData().isEmpty()) {
SettingsData data = new SettingsData();
entity.setData(marshalData(data));
}
super.add(entity);
}
private String marshalData(SettingsData data) {
StringWriter wr = new StringWriter();
try {
marshaller.setWriter(wr);
marshaller. marshal(data);
} catch (MarshalException e) {
log.error(MARSHAL_ERROR + e.getMessage());
} catch (ValidationException e) {
log.error(MARSHAL_ERROR + e.getMessage());
} catch (IOException e) {
log.error(MARSHAL_ERROR + e.getMessage());
}
return wr.toString();
}
private SettingsData unmarshalData(String data) {
StringReader sr = new StringReader(data);
try {
unmarshaller.setClass(SettingsData.class);
return (SettingsData) unmarshaller.unmarshal(sr);
} catch (MarshalException e) {
log.error(UNMARSHAL_ERROR + e.getMessage());
} catch (ValidationException e) {
log.error(UNMARSHAL_ERROR + e.getMessage());
}
return null;
}
@Override
@Transactional
public SettingsData getSettings() {
if (settings == null) {
GlobalSettings gs = this.getAll().get(0);
settings = unmarshalData(gs.getData());
}
return settings;
}
@Override
@Transactional
@PreAuthorize("hasPermission(this, 'PERM_EDIT')")
public void updateSettings() {
if (this.getAll().isEmpty()) {
throw new IsspstException("Global settings does not exists");
}
GlobalSettings gs = this.getAll().get(0);
gs.setData(marshalData(settings));
super.update(gs);
}
}
@@ -0,0 +1,12 @@
package info.bukova.isspst.services.settings;
import info.bukova.isspst.data.GlobalSettings;
import info.bukova.isspst.data.SettingsData;
import info.bukova.isspst.services.Service;
public interface GlobalSettingsService extends Service<GlobalSettings> {
public void updateSettings();
public SettingsData getSettings();
}
@@ -1,6 +1,12 @@
package info.bukova.isspst.sort;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
public class ReflectionTools {
@@ -46,4 +52,30 @@ public class ReflectionTools {
throw new IllegalArgumentException("Not getter method found for '" + propertyName + "', bean: " + bean);
}
public static List<String> getEntityFields(Class<?> clazz) {
BeanInfo beanInfo;
try {
beanInfo = Introspector.getBeanInfo(clazz);
} catch (IntrospectionException e) {
return null;
}
PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
List<String> properties = new ArrayList<String>();
for (PropertyDescriptor pd : pds) {
if (!(pd.getName().equals("password") || pd.getName().equals("class") || pd.getName().equals("id") || pd.getName().equals("valid"))) {
properties.add(pd.getName());
}
}
return properties;
}
public static List<String> getEntityFields(Object entity) {
if (entity == null) {
return null;
}
return getEntityFields(entity.getClass());
}
}
@@ -22,6 +22,18 @@ public class NavigationVM {
window.doModal();
}
@Command
public void numSeries() {
Window window = (Window)Executions.createComponents("/settings/numberSeries.zul", null, null);
window.doModal();
}
@Command
public void globalSettings() {
Window window = (Window)Executions.createComponents("/settings/globalSettings.zul", null, null);
window.doModal();
}
public String getContextPath() {
return contextPath;
}
@@ -0,0 +1,73 @@
package info.bukova.isspst.ui.mail;
import info.bukova.isspst.mail.MailMessage;
import info.bukova.isspst.mail.Mailer;
import info.bukova.isspst.reporting.Generator;
import info.bukova.isspst.reporting.GeneratorFactory;
import info.bukova.isspst.reporting.ReportDefinition;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ExecutionArgParam;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Window;
public class MailForm {
@WireVariable
private Mailer mailer;
@WireVariable
private ReportDefinition reportDefinition;
@WireVariable
private GeneratorFactory genFactory;
private MailMessage message;
private String to;
private String attachement;
private boolean report;
@Init
public void init(@ExecutionArgParam("report") Boolean report) {
message = new MailMessage();
message.setHtml(true);
this.report = report;
if (report) {
attachement = "report.pdf";
}
}
@Command
public void send(@BindingParam("window") Window window) {
message.setTo(to);
if (report) {
Generator generator = genFactory.createGenerator(reportDefinition);
message.setAttachementData(generator.generate());
message.setAttachementName("report.pdf");
message.setContentType("application/pdf");
}
mailer.send(message);
window.detach();
}
public MailMessage getMessage() {
return message;
}
public void setMessage(MailMessage message) {
this.message = message;
}
public String getTo() {
return to;
}
public void setTo(String to) {
this.to = to;
}
public String getAttachement() {
return attachement;
}
}
@@ -1,18 +1,14 @@
package info.bukova.isspst.ui.reporting;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
import java.util.List;
import info.bukova.isspst.reporting.Report;
import info.bukova.isspst.reporting.ReportDefinition;
import info.bukova.isspst.reporting.ReportType;
import info.bukova.isspst.sort.ReflectionTools;
import info.bukova.isspst.ui.ListChecks;
import info.bukova.isspst.ui.LocaleConverter;
import java.util.List;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
@@ -38,19 +34,7 @@ public class ColSelectVM {
return null;
}
BeanInfo beanInfo;
try {
beanInfo = Introspector.getBeanInfo(data.get(0).getClass());
} catch (IntrospectionException e) {
return null;
}
PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
List<String> properties = new ArrayList<String>();
for (PropertyDescriptor pd : pds) {
if (!(pd.getName().equals("password") || pd.getName().equals("class") || pd.getName().equals("id") || pd.getName().equals("valid"))) {
properties.add(pd.getName());
}
}
List<String> properties = ReflectionTools.getEntityFields(data.get(0));
ListChecks<String> columns = new ListChecks<String>(reportDefinition.getFieldsToPrint(), properties);
return columns;
@@ -1,6 +1,12 @@
package info.bukova.isspst.ui.reporting;
import java.util.HashMap;
import java.util.Map;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zul.Window;
public class ReportVM {
@@ -8,5 +14,13 @@ public class ReportVM {
public void init() {
}
@Command
public void send() {
Map<String, Boolean> params = new HashMap<String, Boolean>();
params.put("report", true);
Window mailForm = (Window) Executions.createComponents("/app/mailForm.zul", null, params);
mailForm.doModal();
}
}
@@ -0,0 +1,35 @@
package info.bukova.isspst.ui.reqsubjects;
import java.util.ArrayList;
import java.util.List;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import info.bukova.isspst.data.MUnit;
import info.bukova.isspst.data.MUnitEmb;
import info.bukova.isspst.data.Material;
import info.bukova.isspst.services.munits.MUnitService;
import info.bukova.isspst.ui.FormViewModel;
public class MaterialForm extends FormViewModel<Material> {
@WireVariable
private MUnitService munitService;
private List<MUnitEmb> munits;
@Init(superclass = true)
public void init() {
List<MUnit> mu = munitService.getAll();
munits = new ArrayList<MUnitEmb>();
for (MUnit m : mu) {
MUnitEmb muEmb = new MUnitEmb(m);
munits.add(muEmb);
}
}
public List<MUnitEmb> getMunits() {
return munits;
}
}
@@ -1,11 +1,11 @@
package info.bukova.isspst.ui.material;
package info.bukova.isspst.ui.reqsubjects;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import info.bukova.isspst.data.Material;
import info.bukova.isspst.filters.MaterialFilter;
import info.bukova.isspst.services.material.MaterialService;
import info.bukova.isspst.services.reqsubjects.MaterialService;
import info.bukova.isspst.ui.ListViewModel;
public class MaterialList extends ListViewModel<Material> {
@@ -1,15 +1,15 @@
package info.bukova.isspst.ui.material;
import org.zkoss.bind.annotation.Init;
package info.bukova.isspst.ui.reqsubjects;
import info.bukova.isspst.data.Material;
import info.bukova.isspst.ui.FormViewModel;
public class MaterialForm extends FormViewModel<Material> {
import org.zkoss.bind.annotation.Init;
public class ServiceItemForm extends FormViewModel<Material> {
@Init(superclass = true)
public void init() {
}
}
@@ -0,0 +1,24 @@
package info.bukova.isspst.ui.reqsubjects;
import info.bukova.isspst.data.ServiceItem;
import info.bukova.isspst.filters.ServiceItemFilter;
import info.bukova.isspst.services.reqsubjects.ServiceItemService;
import info.bukova.isspst.ui.ListViewModel;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
public class ServiceItemList extends ListViewModel<ServiceItem> {
@WireVariable
private ServiceItemService serviceItemService;
@Init
public void init() {
service = serviceItemService;
dataClass = ServiceItem.class;
formZul = "serviceForm.zul";
dataFilter = new ServiceItemFilter(getFilterTemplate());
}
}
@@ -7,16 +7,22 @@ import info.bukova.isspst.data.Workflow;
import info.bukova.isspst.services.requirement.RequirementTypeService;
import info.bukova.isspst.services.users.RoleService;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.GlobalCommand;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.DropEvent;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Window;
public class RequirementTypesVM {
@@ -28,6 +34,8 @@ public class RequirementTypesVM {
private List<Role> centreRoles;
private List<Role> workgroupRoles;
private RequirementType selected;
private Workflow wgSelWorkflow;
private Workflow centreSelWorkflow;
@Init
public void init() {
@@ -199,5 +207,42 @@ public class RequirementTypesVM {
this.selected = selected;
}
@Command
@NotifyChange({"selected", "centreSelWorkflow", "wgSelWorkflow"})
public void overLimit(@BindingParam("workflow") Workflow workflow) {
if (workflow.getLimit() != null && !workflow.getLimit().equals(BigDecimal.ZERO)) {
workflow.setLimit(null);
reqTypeService.update(selected);
return;
}
Map<String, Object> params = new HashMap<String, Object>();
params.put("workflow", workflow);
Window win = (Window) Executions.createComponents("/settings/workflow/limit.zul", null, params);
win.doModal();
}
@GlobalCommand
@NotifyChange("selected")
public void refresh() {
reqTypeService.update(selected);
}
public Workflow getWgSelWorkflow() {
return wgSelWorkflow;
}
public void setWgSelWorkflow(Workflow wgSelWorkflow) {
this.wgSelWorkflow = wgSelWorkflow;
}
public Workflow getCentreSelWorkflow() {
return centreSelWorkflow;
}
public void setCentreSelWorkflow(Workflow centreSelWorkflow) {
this.centreSelWorkflow = centreSelWorkflow;
}
}
@@ -0,0 +1,33 @@
package info.bukova.isspst.ui.requirements;
import info.bukova.isspst.data.Workflow;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.ExecutionArgParam;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zul.Window;
public class LimitVM {
private Workflow workflow;
@Init
public void init(@ExecutionArgParam("workflow") Workflow workflow) {
this.workflow = workflow;
}
public Workflow getWorkflow() {
return workflow;
}
@Command
public void save(@BindingParam("window") Window window) {
window.detach();
}
public boolean isCanSave() {
return true;
}
}
@@ -0,0 +1,60 @@
package info.bukova.isspst.ui.settings;
import java.util.List;
import org.zkoss.bind.annotation.BindingParam;
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;
import org.zkoss.zul.Window;
import info.bukova.isspst.data.Requirement;
import info.bukova.isspst.data.SettingsData;
import info.bukova.isspst.mail.MailMessage;
import info.bukova.isspst.services.settings.GlobalSettingsService;
import info.bukova.isspst.sort.ReflectionTools;
import info.bukova.isspst.ui.LocaleConverter;
public class GlobalSettingsVM {
@WireVariable
private GlobalSettingsService settingsService;
private SettingsData settings;
private LocaleConverter locConverter;
@Init
public void init() {
settings = settingsService.getSettings();
locConverter = new LocaleConverter();
}
public SettingsData getSettings() {
return settings;
}
@Command
public void save(@BindingParam("window") Window window) {
settingsService.updateSettings();
window.detach();
}
public List<String> getRequirementFields() {
return ReflectionTools.getEntityFields(Requirement.class);
}
public boolean isCanSave() {
return true;
}
public LocaleConverter getLocConverter() {
return locConverter;
}
@Command
@NotifyChange("settings")
public void insertField(@BindingParam("field") String field, @BindingParam("message") MailMessage message) {
message.setText(message.getText() + ":" + field + ":");
}
}
@@ -0,0 +1,55 @@
package info.bukova.isspst.ui.settings;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.Init;
import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.Window;
import info.bukova.isspst.Constants;
import info.bukova.isspst.Module;
import info.bukova.isspst.data.NumberSeries;
import info.bukova.isspst.services.numberseries.NumberSeriesService;
public class NumberSeriesVM {
@WireVariable
private NumberSeriesService numericSeriesService;
private List<NumberSeries> numberSeriesList;
private Map<String, Module> moduleMap;
@Init
public void init() {
numberSeriesList = new ArrayList<NumberSeries>(numericSeriesService.getAll());
moduleMap = new HashMap<String, Module>();
for (Module m : Constants.MODULES) {
moduleMap.put(m.getId(), m);
}
}
public List<NumberSeries> getNumberSeriesList() {
return numberSeriesList;
}
public boolean isCanSave() {
return true;
}
@Command
public void save(@BindingParam("window") Window window) {
for (NumberSeries ns : numberSeriesList) {
numericSeriesService.update(ns);
}
window.detach();
}
public Map<String, Module> getModuleMap() {
return moduleMap;
}
}