Merge branch 'master' of https://git.bukova.info/repos/git/isspst
Conflicts: src/main/java/info/bukova/isspst/AppInitListener.java src/main/resources/hibernate.cfg.xmlmultitenant
						commit
						a074dd376d
					
				@ -0,0 +1,7 @@
 | 
			
		||||
package info.bukova.isspst.dao;
 | 
			
		||||
 | 
			
		||||
import info.bukova.isspst.data.RequirementType;
 | 
			
		||||
 | 
			
		||||
public interface RequirementTypeDao extends BaseDao<RequirementType> {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,8 @@
 | 
			
		||||
package info.bukova.isspst.dao.jpa;
 | 
			
		||||
 | 
			
		||||
import info.bukova.isspst.dao.RequirementTypeDao;
 | 
			
		||||
import info.bukova.isspst.data.RequirementType;
 | 
			
		||||
 | 
			
		||||
public class RequirementTypeDaoJPA extends BaseDaoJPA<RequirementType> implements RequirementTypeDao {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,71 @@
 | 
			
		||||
package info.bukova.isspst.data;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import javax.persistence.CascadeType;
 | 
			
		||||
import javax.persistence.Column;
 | 
			
		||||
import javax.persistence.Entity;
 | 
			
		||||
import javax.persistence.OneToMany;
 | 
			
		||||
import javax.persistence.OrderBy;
 | 
			
		||||
import javax.persistence.Table;
 | 
			
		||||
 | 
			
		||||
import org.hibernate.annotations.LazyCollection;
 | 
			
		||||
import org.hibernate.annotations.LazyCollectionOption;
 | 
			
		||||
 | 
			
		||||
@Entity
 | 
			
		||||
@Table(name = "REQUIREMENTTYPE")
 | 
			
		||||
public class RequirementType extends BaseData {
 | 
			
		||||
	
 | 
			
		||||
	@Column(name = "TYPE")
 | 
			
		||||
	private String type;
 | 
			
		||||
	@Column(name = "DESCRIPTION")
 | 
			
		||||
	private String description;
 | 
			
		||||
	@OneToMany(cascade = CascadeType.ALL)
 | 
			
		||||
	@LazyCollection(LazyCollectionOption.FALSE)
 | 
			
		||||
	@OrderBy("WORDER")
 | 
			
		||||
	private List<Workflow> workflow;
 | 
			
		||||
	
 | 
			
		||||
	public RequirementType() {
 | 
			
		||||
		workflow = new ArrayList<Workflow>();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public RequirementType(String type, String description) {
 | 
			
		||||
		this();
 | 
			
		||||
		this.type = type;
 | 
			
		||||
		this.description = description;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public String getType() {
 | 
			
		||||
		return type;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setType(String type) {
 | 
			
		||||
		this.type = type;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public String getDescription() {
 | 
			
		||||
		return description;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setDescription(String description) {
 | 
			
		||||
		this.description = description;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public List<Workflow> getWorkflow() {
 | 
			
		||||
		return workflow;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setWorkflow(List<Workflow> workflow) {
 | 
			
		||||
		this.workflow = workflow;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public boolean equals(Object o) {
 | 
			
		||||
		if (o instanceof RequirementType && ((RequirementType)o).getType().equals(this.type)) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,59 @@
 | 
			
		||||
package info.bukova.isspst.data;
 | 
			
		||||
 | 
			
		||||
import javax.persistence.Column;
 | 
			
		||||
import javax.persistence.Entity;
 | 
			
		||||
import javax.persistence.JoinColumn;
 | 
			
		||||
import javax.persistence.ManyToOne;
 | 
			
		||||
import javax.persistence.Table;
 | 
			
		||||
 | 
			
		||||
import org.hibernate.annotations.LazyCollection;
 | 
			
		||||
import org.hibernate.annotations.LazyCollectionOption;
 | 
			
		||||
 | 
			
		||||
@Entity
 | 
			
		||||
@Table(name = "WORKFLOW")
 | 
			
		||||
public class Workflow extends BaseData {
 | 
			
		||||
	
 | 
			
		||||
	@Column(name = "CENTRE")
 | 
			
		||||
	private Boolean centre;
 | 
			
		||||
	@ManyToOne
 | 
			
		||||
	@LazyCollection(LazyCollectionOption.FALSE)
 | 
			
		||||
	@JoinColumn(name = "ROLE_ID")
 | 
			
		||||
	private Role role;
 | 
			
		||||
	@Column(name = "WORDER")
 | 
			
		||||
	private Integer wOrder;
 | 
			
		||||
 | 
			
		||||
	public Boolean getCentre() {
 | 
			
		||||
		return centre;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setCentre(Boolean centre) {
 | 
			
		||||
		this.centre = centre;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Role getRole() {
 | 
			
		||||
		return role;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setRole(Role role) {
 | 
			
		||||
		this.role = role;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public boolean equals(Object o) {
 | 
			
		||||
		if (o instanceof Workflow
 | 
			
		||||
				&& ((Workflow)o).getCentre().equals(centre) 
 | 
			
		||||
				&& ((Workflow)o).getRole().equals(role)) {
 | 
			
		||||
			return true;
 | 
			
		||||
		} 
 | 
			
		||||
		
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Integer getOrder() {
 | 
			
		||||
		return wOrder;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setOrder(Integer order) {
 | 
			
		||||
		this.wOrder = order;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,8 @@
 | 
			
		||||
package info.bukova.isspst.services.requirements;
 | 
			
		||||
 | 
			
		||||
import info.bukova.isspst.data.RequirementType;
 | 
			
		||||
import info.bukova.isspst.services.Service;
 | 
			
		||||
 | 
			
		||||
public interface RequirementTypeService  extends Service<RequirementType> {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,8 @@
 | 
			
		||||
package info.bukova.isspst.services.requirements;
 | 
			
		||||
 | 
			
		||||
import info.bukova.isspst.data.RequirementType;
 | 
			
		||||
import info.bukova.isspst.services.AbstractOwnedService;
 | 
			
		||||
 | 
			
		||||
public class RequirementTypeServiceImpl  extends AbstractOwnedService<RequirementType> implements RequirementTypeService {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,203 @@
 | 
			
		||||
package info.bukova.isspst.ui.requirements;
 | 
			
		||||
 | 
			
		||||
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.users.RoleService;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
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.event.DropEvent;
 | 
			
		||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
 | 
			
		||||
import org.zkoss.zul.Listitem;
 | 
			
		||||
 | 
			
		||||
public class RequirementTypesVM {
 | 
			
		||||
	
 | 
			
		||||
	@WireVariable
 | 
			
		||||
	private RequirementTypeService reqTypeService;
 | 
			
		||||
	@WireVariable
 | 
			
		||||
	private RoleService roleService;
 | 
			
		||||
	private List<RequirementType> reqTypes;
 | 
			
		||||
	private List<Role> centreRoles;
 | 
			
		||||
	private List<Role> workgroupRoles;
 | 
			
		||||
	private RequirementType selected;
 | 
			
		||||
	
 | 
			
		||||
	@Init
 | 
			
		||||
	public void init() {
 | 
			
		||||
		reqTypes = reqTypeService.getAll();
 | 
			
		||||
		initRoles();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void initRoles() {
 | 
			
		||||
		centreRoles = new ArrayList<Role>(roleService.getRolesWithPermission(Constants.PERM_APPROVE, true));
 | 
			
		||||
		workgroupRoles = new ArrayList<Role>(roleService.getRolesWithPermission(Constants.PERM_APPROVE, false));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Command
 | 
			
		||||
	@NotifyChange({"selected", "centreRoles", "workgroupRoles"})
 | 
			
		||||
	public void addRoleWg(@BindingParam("event") DropEvent event) {
 | 
			
		||||
		Role r;
 | 
			
		||||
		try {
 | 
			
		||||
			r = ((Listitem)event.getDragged()).getValue();
 | 
			
		||||
		} catch (ClassCastException e) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		addRole(r, false);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Command
 | 
			
		||||
	@NotifyChange({"selected", "centreRoles", "workgroupRoles"})
 | 
			
		||||
	public void addRoleCentre(@BindingParam("event") DropEvent event) {
 | 
			
		||||
		Role r;
 | 
			
		||||
		try {
 | 
			
		||||
			r = ((Listitem)event.getDragged()).getValue();
 | 
			
		||||
		} catch (ClassCastException e) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		addRole(r, true);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void addRole(Role r, boolean centre) {
 | 
			
		||||
		Workflow w = new Workflow();
 | 
			
		||||
		w.setRole(r);
 | 
			
		||||
		w.setCentre(centre);
 | 
			
		||||
		w.setOrder(selected.getWorkflow().size());
 | 
			
		||||
		
 | 
			
		||||
		if (!selected.getWorkflow().contains(w)) {
 | 
			
		||||
			selected.getWorkflow().add(w);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (centre) {
 | 
			
		||||
			centreRoles.remove(r);
 | 
			
		||||
		} else {
 | 
			
		||||
			workgroupRoles.remove(r);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		reqTypeService.update(selected);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Command
 | 
			
		||||
	@NotifyChange({"selected", "centreRoles", "workgroupRoles"})
 | 
			
		||||
	public void removeRoleWg(@BindingParam("event") DropEvent event) {
 | 
			
		||||
		removeWorkflow((Workflow) ((Listitem)event.getDragged()).getValue());	
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Command
 | 
			
		||||
	@NotifyChange({"selected", "centreRoles", "workgroupRoles"})
 | 
			
		||||
	public void removeRoleCentre(@BindingParam("event") DropEvent event) {
 | 
			
		||||
		removeWorkflow((Workflow) ((Listitem)event.getDragged()).getValue());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void removeWorkflow(Workflow w) {
 | 
			
		||||
		selected.getWorkflow().remove(w);
 | 
			
		||||
		
 | 
			
		||||
		if (w.getCentre()) {
 | 
			
		||||
			centreRoles.add(w.getRole());
 | 
			
		||||
		} else {
 | 
			
		||||
			workgroupRoles.add(w.getRole());
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		resetOrder();
 | 
			
		||||
		
 | 
			
		||||
		reqTypeService.update(selected);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Command
 | 
			
		||||
	@NotifyChange({"selected", "centreRoles", "workgroupRoles"})
 | 
			
		||||
	public void reorderWg(@BindingParam("event") DropEvent event) {
 | 
			
		||||
		reorder(event, false);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Command
 | 
			
		||||
	@NotifyChange({"selected", "centreRoles", "workgroupRoles"})
 | 
			
		||||
	public void reorderCentre(@BindingParam("event") DropEvent event) {
 | 
			
		||||
		reorder(event, true);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void reorder(DropEvent event, boolean centre) {
 | 
			
		||||
		Workflow w;
 | 
			
		||||
		
 | 
			
		||||
		try {
 | 
			
		||||
			w = ((Listitem)event.getDragged()).getValue();
 | 
			
		||||
		} catch (ClassCastException e) {
 | 
			
		||||
			if (centre) {
 | 
			
		||||
				addRoleCentre(event);
 | 
			
		||||
			} else {
 | 
			
		||||
				addRoleWg(event);
 | 
			
		||||
			}
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		Workflow target = ((Listitem)event.getTarget()).getValue();
 | 
			
		||||
		List<Workflow> wf = selected.getWorkflow();
 | 
			
		||||
		int dragIndex = wf.indexOf(w);
 | 
			
		||||
		int dropIndex = wf.indexOf(target);
 | 
			
		||||
		
 | 
			
		||||
		if (dragIndex > dropIndex) {
 | 
			
		||||
			wf.remove(w);
 | 
			
		||||
			wf.add(dropIndex, w);
 | 
			
		||||
		} else {
 | 
			
		||||
			for (int i = dragIndex; i < dropIndex; i++) {
 | 
			
		||||
				wf.add(i, wf.get(i + 1));
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			wf.remove(w);
 | 
			
		||||
			wf.remove(dropIndex);
 | 
			
		||||
			wf.add(dropIndex, w);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		w.setOrder(wf.indexOf(w));
 | 
			
		||||
		resetOrder();
 | 
			
		||||
		
 | 
			
		||||
		reqTypeService.update(selected);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void resetOrder() {
 | 
			
		||||
		for (int i = 0; i < selected.getWorkflow().size(); i++) {
 | 
			
		||||
			selected.getWorkflow().get(i).setOrder(i);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public List<RequirementType> getReqTypes() {
 | 
			
		||||
		return reqTypes;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public List<Role> getCentreRoles() {
 | 
			
		||||
		return centreRoles;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public List<Role> getWorkgroupRoles() {
 | 
			
		||||
		return workgroupRoles;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public RequirementType getSelected() {
 | 
			
		||||
		return selected;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@NotifyChange({"selected", "workgroupRoles", "centreRoles"})
 | 
			
		||||
	public void setSelected(RequirementType selected) {
 | 
			
		||||
		if (selected == null) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		initRoles();
 | 
			
		||||
		
 | 
			
		||||
		for (Workflow w : selected.getWorkflow()) {
 | 
			
		||||
			if (w.getCentre()) {
 | 
			
		||||
				centreRoles.remove(w.getRole());
 | 
			
		||||
			} else {
 | 
			
		||||
				workgroupRoles.remove(w.getRole());
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		this.selected = selected;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
jdbc.driverClassName=com.mysql.jdbc.Driver
 | 
			
		||||
jdbc.dialect=org.hibernate.dialect.MySQLDialect
 | 
			
		||||
jdbc.databaseurl=jdbc:mysql://127.0.0.1:3306/isspst?characterEncoding=latin2
 | 
			
		||||
jdbc.databaseurl=jdbc:mysql://127.0.0.1:3306/isspst?characterEncoding=latin2&autoReconnect=true
 | 
			
		||||
jdbc.username=isspst
 | 
			
		||||
jdbc.password=xsacfgd
 | 
			
		||||
@ -0,0 +1,10 @@
 | 
			
		||||
<?page title="${labels.AgendaWorkflow}" contentType="text/html;charset=UTF-8"?>
 | 
			
		||||
<zk>
 | 
			
		||||
 | 
			
		||||
<zscript>
 | 
			
		||||
	String gridZul = "workflow.zul";
 | 
			
		||||
</zscript>
 | 
			
		||||
 | 
			
		||||
<include src="/app/template.zhtml"/>
 | 
			
		||||
 | 
			
		||||
</zk>
 | 
			
		||||
@ -0,0 +1,73 @@
 | 
			
		||||
<?page title="${labels.AgendaWorkflow}" contentType="text/html;charset=UTF-8"?>
 | 
			
		||||
<zk>
 | 
			
		||||
<window border="normal" apply="org.zkoss.bind.BindComposer"
 | 
			
		||||
	viewModel="@id('vm') @init('info.bukova.isspst.ui.requirements.RequirementTypesVM')">
 | 
			
		||||
<caption zclass="form-caption" label="${labels.AgendaWorkflow}" />
 | 
			
		||||
<vbox>
 | 
			
		||||
	<hbox>
 | 
			
		||||
		<label value="${labels.RequirementType}"/>
 | 
			
		||||
		<combobox model="@load(vm.reqTypes)" readonly="true" width="300px" selectedItem="@bind(vm.selected)">
 | 
			
		||||
			<template name="model">
 | 
			
		||||
				<comboitem label="@load(each.description)"/>
 | 
			
		||||
			</template>
 | 
			
		||||
		</combobox>
 | 
			
		||||
	</hbox>
 | 
			
		||||
	<hbox>
 | 
			
		||||
		<div hflex="1">
 | 
			
		||||
		<groupbox mold="3d" hflex="1">
 | 
			
		||||
		<caption label="${labels.AvailableRoles}"/>
 | 
			
		||||
			<vbox>
 | 
			
		||||
				<listbox id="allWgRoles" model="@load(vm.workgroupRoles)" droppable="workgroup" 
 | 
			
		||||
				onDrop="@command('removeRoleWg', event=event)">
 | 
			
		||||
					<listhead>
 | 
			
		||||
						<listheader label="${labels.WorkgroupRoles}"/>
 | 
			
		||||
					</listhead>
 | 
			
		||||
					<template name="model">
 | 
			
		||||
						<listitem label="@load(each.description)" draggable="workgroup" droppable="workgroup"
 | 
			
		||||
						onDrop="@command('removeRoleCentre', event=event)"/>
 | 
			
		||||
					</template>
 | 
			
		||||
				</listbox>
 | 
			
		||||
				<listbox id="allCentreRoles" model="@load(vm.centreRoles)" droppable="centre" 
 | 
			
		||||
				onDrop="@command('removeRoleCentre', event=event)">
 | 
			
		||||
					<listhead>
 | 
			
		||||
						<listheader label="${labels.CentreRoles }"/>
 | 
			
		||||
					</listhead>
 | 
			
		||||
					<template name="model">
 | 
			
		||||
						<listitem label="@load(each.description)" draggable="centre" droppable="centre"
 | 
			
		||||
						onDrop="@command('removeRoleCentre', event=event)"/>
 | 
			
		||||
					</template>
 | 
			
		||||
				</listbox>
 | 
			
		||||
			</vbox>
 | 
			
		||||
		</groupbox>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div hflex="1">
 | 
			
		||||
		<groupbox mold="3d" visible="@load(not empty vm.selected)">
 | 
			
		||||
		<caption label="${labels.Workflow}"/>
 | 
			
		||||
			<vbox>
 | 
			
		||||
				<listbox id="wgWorkflow" model="@load(vm.selected.workflow)" droppable="workgroup"
 | 
			
		||||
				onDrop="@command('addRoleWg', event=event)">
 | 
			
		||||
					<listhead>
 | 
			
		||||
						<listheader label="${labels.WorkgroupWorkflow}"/>
 | 
			
		||||
					</listhead>
 | 
			
		||||
					<template name="model">
 | 
			
		||||
						<listitem label="@load(each.role.description)" visible="@load(not each.centre)"
 | 
			
		||||
						onDrop="@command('reorderWg', event=event)" draggable="workgroup" droppable="workgroup"/>
 | 
			
		||||
					</template>
 | 
			
		||||
				</listbox>
 | 
			
		||||
				<listbox id="centreWorkflow" model="@load(vm.selected.workflow)" droppable="centre"
 | 
			
		||||
				onDrop="@command('addRoleCentre', event=event)">
 | 
			
		||||
					<listhead>
 | 
			
		||||
						<listheader label="${labels.CentreWorkflow}"/>
 | 
			
		||||
					</listhead>
 | 
			
		||||
					<template name="model">
 | 
			
		||||
						<listitem label="@load(each.role.description)" visible="@load(each.centre)"
 | 
			
		||||
						onDrop="@command('reorderCentre', event=event)" draggable="centre" droppable="centre"/>
 | 
			
		||||
					</template>
 | 
			
		||||
				</listbox>
 | 
			
		||||
			</vbox>
 | 
			
		||||
		</groupbox>
 | 
			
		||||
		</div>
 | 
			
		||||
	</hbox>
 | 
			
		||||
</vbox>
 | 
			
		||||
</window>
 | 
			
		||||
</zk>
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue