Merge branch 'master' of https://git.bukova.info/repos/git/isspst
Conflicts: src/main/webapp/app/navigation.zulmultitenant
						commit
						6dcc93ee83
					
				@ -0,0 +1,7 @@
 | 
			
		||||
package info.bukova.isspst.dao;
 | 
			
		||||
 | 
			
		||||
import info.bukova.isspst.data.Workgroup;
 | 
			
		||||
 | 
			
		||||
public interface WorkgroupDao extends BaseDao<Workgroup> {
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,13 @@
 | 
			
		||||
package info.bukova.isspst.dao.jpa;
 | 
			
		||||
 | 
			
		||||
import info.bukova.isspst.dao.WorkgroupDao;
 | 
			
		||||
import info.bukova.isspst.data.Workgroup;
 | 
			
		||||
 | 
			
		||||
public class WorkgroupDaoJPA extends BaseDaoJPA<Workgroup> implements WorkgroupDao {
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getEntityName() {
 | 
			
		||||
		return Workgroup.class.getSimpleName();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,71 @@
 | 
			
		||||
package info.bukova.isspst.data;
 | 
			
		||||
 | 
			
		||||
import javax.persistence.Column;
 | 
			
		||||
import javax.persistence.Entity;
 | 
			
		||||
import javax.persistence.FetchType;
 | 
			
		||||
import javax.persistence.GeneratedValue;
 | 
			
		||||
import javax.persistence.Id;
 | 
			
		||||
import javax.persistence.JoinColumn;
 | 
			
		||||
import javax.persistence.JoinTable;
 | 
			
		||||
import javax.persistence.ManyToOne;
 | 
			
		||||
import javax.persistence.Table;
 | 
			
		||||
 | 
			
		||||
@Entity
 | 
			
		||||
@Table(name = "JOBMAPPING")
 | 
			
		||||
public class JobMapping {
 | 
			
		||||
 | 
			
		||||
	@Id
 | 
			
		||||
	@Column(name = "ID")
 | 
			
		||||
	@GeneratedValue
 | 
			
		||||
	private int id;
 | 
			
		||||
	@ManyToOne(fetch = FetchType.EAGER)
 | 
			
		||||
	@JoinTable(name = "JOB_MEMBER", joinColumns = { @JoinColumn(name = "JOB_ID") }, inverseJoinColumns = { @JoinColumn(name = "MEMBER_ID") })
 | 
			
		||||
	private Member member;
 | 
			
		||||
	@ManyToOne(fetch = FetchType.EAGER)
 | 
			
		||||
	@JoinTable(name = "JOB_ROLE", joinColumns = { @JoinColumn(name = "JOB_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") })
 | 
			
		||||
	private Role role;
 | 
			
		||||
	
 | 
			
		||||
	public JobMapping() {
 | 
			
		||||
		
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public JobMapping(Member member, Role role) {
 | 
			
		||||
		this.member = member;
 | 
			
		||||
		this.role = role;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public int getId() {
 | 
			
		||||
		return id;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setId(int id) {
 | 
			
		||||
		this.id = id;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Member getMember() {
 | 
			
		||||
		return member;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setMember(Member member) {
 | 
			
		||||
		this.member = member;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Role getRole() {
 | 
			
		||||
		return role;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setRole(Role role) {
 | 
			
		||||
		this.role = role;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean equals(Object o) {
 | 
			
		||||
		if (o instanceof JobMapping 
 | 
			
		||||
				&& ((JobMapping)o).getMember().equals(this.getMember())
 | 
			
		||||
				&& ((JobMapping)o).getRole().equals(this.getRole())) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,63 @@
 | 
			
		||||
package info.bukova.isspst.data;
 | 
			
		||||
 | 
			
		||||
import java.util.Date;
 | 
			
		||||
 | 
			
		||||
import javax.persistence.Column;
 | 
			
		||||
import javax.persistence.Entity;
 | 
			
		||||
import javax.persistence.GeneratedValue;
 | 
			
		||||
import javax.persistence.GenerationType;
 | 
			
		||||
import javax.persistence.Id;
 | 
			
		||||
import javax.persistence.Inheritance;
 | 
			
		||||
import javax.persistence.InheritanceType;
 | 
			
		||||
import javax.persistence.Transient;
 | 
			
		||||
 | 
			
		||||
@Entity
 | 
			
		||||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
 | 
			
		||||
public abstract class Member implements DataModel {
 | 
			
		||||
 | 
			
		||||
	@Id
 | 
			
		||||
	@GeneratedValue(strategy = GenerationType.TABLE)
 | 
			
		||||
	private int id;
 | 
			
		||||
	@Column(name = "CREATED")
 | 
			
		||||
	private Date created;
 | 
			
		||||
	@Column(name = "MODIFIED")
 | 
			
		||||
	private Date modified;
 | 
			
		||||
	@Transient
 | 
			
		||||
	private boolean valid;
 | 
			
		||||
	
 | 
			
		||||
	public abstract String getFullName();
 | 
			
		||||
	public abstract boolean isHasJob();
 | 
			
		||||
 | 
			
		||||
	public int getId() {
 | 
			
		||||
		return id;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setId(int id) {
 | 
			
		||||
		this.id = id;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Date getCreated() {
 | 
			
		||||
		return created;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setCreated(Date created) {
 | 
			
		||||
		this.created = created;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public Date getModified() {
 | 
			
		||||
		return modified;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setModified(Date modified) {
 | 
			
		||||
		this.modified = modified;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public boolean isValid() {
 | 
			
		||||
		return valid;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setValid(boolean valid) {
 | 
			
		||||
		this.valid = valid;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,9 @@
 | 
			
		||||
package info.bukova.isspst.data;
 | 
			
		||||
 | 
			
		||||
public enum PermissionType {
 | 
			
		||||
	
 | 
			
		||||
	GLOBAL,
 | 
			
		||||
	WORKGROUP,
 | 
			
		||||
	CENTRE
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,125 @@
 | 
			
		||||
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.FetchType;
 | 
			
		||||
import javax.persistence.JoinColumn;
 | 
			
		||||
import javax.persistence.JoinTable;
 | 
			
		||||
import javax.persistence.ManyToMany;
 | 
			
		||||
import javax.persistence.ManyToOne;
 | 
			
		||||
import javax.persistence.Table;
 | 
			
		||||
 | 
			
		||||
import org.hibernate.annotations.LazyCollection;
 | 
			
		||||
import org.hibernate.annotations.LazyCollectionOption;
 | 
			
		||||
 | 
			
		||||
@Entity
 | 
			
		||||
@Table(name = "WORKGROUP")
 | 
			
		||||
public class Workgroup extends Member implements OwnedDataModel { 
 | 
			
		||||
	
 | 
			
		||||
	@Column(name = "CODE")
 | 
			
		||||
	private String code;
 | 
			
		||||
	@Column(name = "NAME")
 | 
			
		||||
	private String name;
 | 
			
		||||
	@ManyToMany(cascade = {CascadeType.ALL})
 | 
			
		||||
	@LazyCollection(LazyCollectionOption.FALSE)
 | 
			
		||||
	@JoinTable(name="WORKGROUP_MEMBER", joinColumns={@JoinColumn(name="WORKGROUP_ID")}, inverseJoinColumns={@JoinColumn(name="JOBMAPPING_ID")})
 | 
			
		||||
	private List<JobMapping> members;
 | 
			
		||||
	@Column(name = "CENTRE")
 | 
			
		||||
	private boolean centre;
 | 
			
		||||
	//BaseData
 | 
			
		||||
	@ManyToOne(fetch=FetchType.EAGER)
 | 
			
		||||
	@JoinColumn(name="OWNED_BY_ID")
 | 
			
		||||
	private User ownedBy;
 | 
			
		||||
	@ManyToOne(fetch=FetchType.EAGER)
 | 
			
		||||
	@JoinColumn(name="MODIFIED_BY_ID")
 | 
			
		||||
	private User modifiedBy;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	public Workgroup() {
 | 
			
		||||
		members = new ArrayList<JobMapping>();
 | 
			
		||||
		centre = false;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public String getCode() {
 | 
			
		||||
		return code;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setCode(String code) {
 | 
			
		||||
		this.code = code;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public String getName() {
 | 
			
		||||
		return name;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setName(String name) {
 | 
			
		||||
		this.name = name;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public boolean isCentre() {
 | 
			
		||||
		return centre;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setCentre(boolean centre) {
 | 
			
		||||
		this.centre = centre;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public void setOwnedBy(User user) {
 | 
			
		||||
		this.ownedBy = user;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public User getOwnedBy() {
 | 
			
		||||
		return ownedBy;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public void setModifiedBy(User user) {
 | 
			
		||||
		this.modifiedBy = user;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public User getModifiedBy() {
 | 
			
		||||
		return modifiedBy;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getFullName() {
 | 
			
		||||
		return name;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean isHasJob() {
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public List<JobMapping> getMembers() {
 | 
			
		||||
		return members;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public void setMembers(List<JobMapping> members) {
 | 
			
		||||
		this.members = members;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void removeMember(JobMapping mapping) {
 | 
			
		||||
		members.remove(mapping);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public void removeMember(Member member, Role role) {
 | 
			
		||||
		JobMapping mapping = new JobMapping(member, role);
 | 
			
		||||
		members.remove(mapping);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public boolean equals(Object o) {
 | 
			
		||||
		if (o instanceof Workgroup && ((Workgroup)o).getId() == this.getId()) {
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@ -1,10 +1,14 @@
 | 
			
		||||
package info.bukova.isspst.services.users;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import info.bukova.isspst.data.Role;
 | 
			
		||||
import info.bukova.isspst.services.Service;
 | 
			
		||||
 | 
			
		||||
public interface RoleService extends Service<Role> {
 | 
			
		||||
 | 
			
		||||
	public Role getRoleByAuthority(String authority);
 | 
			
		||||
	public List<Role> getWorkgroupRoles();
 | 
			
		||||
	public List<Role> getCentreRoles();
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,20 @@
 | 
			
		||||
package info.bukova.isspst.services.workgroups;
 | 
			
		||||
 | 
			
		||||
import info.bukova.isspst.services.IsspstException;
 | 
			
		||||
 | 
			
		||||
public class WorkgroupException extends IsspstException {
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * 
 | 
			
		||||
	 */
 | 
			
		||||
	private static final long serialVersionUID = -1729975111741519801L;
 | 
			
		||||
	
 | 
			
		||||
	public final static String NO_WORGROUP = "WorkgroupNotAllowed";
 | 
			
		||||
	public final static String MSUT_HAS_CENTER = "RoleMustHasCentre";
 | 
			
		||||
	public final static String MUST_HAS_WORKGROUP = "WorkgroupMustHasCentre";
 | 
			
		||||
	
 | 
			
		||||
	public WorkgroupException(String message) {
 | 
			
		||||
		super(message);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,17 @@
 | 
			
		||||
package info.bukova.isspst.services.workgroups;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import info.bukova.isspst.data.Member;
 | 
			
		||||
import info.bukova.isspst.data.Role;
 | 
			
		||||
import info.bukova.isspst.data.Workgroup;
 | 
			
		||||
import info.bukova.isspst.services.Service;
 | 
			
		||||
 | 
			
		||||
public interface WorkgroupService extends Service<Workgroup>  {
 | 
			
		||||
	
 | 
			
		||||
	public void addMember(Workgroup workgroup, Member member, Role role);
 | 
			
		||||
	public List<Workgroup> getWorkgroups();
 | 
			
		||||
	public List<Workgroup> getCentres();
 | 
			
		||||
	public boolean isMember(Workgroup workgroup, Member member);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,57 @@
 | 
			
		||||
package info.bukova.isspst.services.workgroups;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
 | 
			
		||||
import info.bukova.isspst.Constants;
 | 
			
		||||
import info.bukova.isspst.data.JobMapping;
 | 
			
		||||
import info.bukova.isspst.data.Member;
 | 
			
		||||
import info.bukova.isspst.data.Role;
 | 
			
		||||
import info.bukova.isspst.data.Workgroup;
 | 
			
		||||
import info.bukova.isspst.services.AbstractOwnedService;
 | 
			
		||||
 | 
			
		||||
public class WorkgroupServiceImpl extends AbstractOwnedService<Workgroup> implements WorkgroupService {
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public void addMember(Workgroup workgroup, Member member, Role role) {
 | 
			
		||||
		if (!member.isHasJob() && !role.getAuthority().equals(Constants.ROLE_USER)) {
 | 
			
		||||
			throw new WorkgroupException(WorkgroupException.NO_WORGROUP);
 | 
			
		||||
		}
 | 
			
		||||
		if (workgroup.isCentre() && !role.isCentre()) {
 | 
			
		||||
			throw new WorkgroupException(WorkgroupException.MSUT_HAS_CENTER);
 | 
			
		||||
		}
 | 
			
		||||
		if (!workgroup.isCentre() && !role.isWorkgroup()) {
 | 
			
		||||
			throw new WorkgroupException(WorkgroupException.MUST_HAS_WORKGROUP);
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		JobMapping mapping = new JobMapping(member, role);
 | 
			
		||||
		if (!workgroup.getMembers().contains(mapping)) {
 | 
			
		||||
			workgroup.getMembers().add(mapping);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	@Transactional
 | 
			
		||||
	public List<Workgroup> getWorkgroups() {
 | 
			
		||||
		return this.execQuery("from Workgroup where centre = false");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	@Transactional
 | 
			
		||||
	public List<Workgroup> getCentres() {
 | 
			
		||||
		return this.execQuery("from Workgroup where centre = true");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@Override
 | 
			
		||||
	public boolean isMember(Workgroup workgroup, Member member) {
 | 
			
		||||
		for (JobMapping jm : workgroup.getMembers()) {
 | 
			
		||||
			if (jm.getMember().equals(member)) {
 | 
			
		||||
				return true;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,145 @@
 | 
			
		||||
package info.bukova.isspst.ui.workgroups;
 | 
			
		||||
 | 
			
		||||
import info.bukova.isspst.data.JobMapping;
 | 
			
		||||
import info.bukova.isspst.data.Member;
 | 
			
		||||
import info.bukova.isspst.data.Role;
 | 
			
		||||
import info.bukova.isspst.data.Workgroup;
 | 
			
		||||
import info.bukova.isspst.services.users.RoleService;
 | 
			
		||||
import info.bukova.isspst.services.users.UserService;
 | 
			
		||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
 | 
			
		||||
import info.bukova.isspst.ui.FormViewModel;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
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 WorkgroupForm extends FormViewModel<Workgroup> {
 | 
			
		||||
	
 | 
			
		||||
	@WireVariable
 | 
			
		||||
	private UserService userService;
 | 
			
		||||
	@WireVariable
 | 
			
		||||
	private RoleService roleService;
 | 
			
		||||
	@WireVariable
 | 
			
		||||
	private WorkgroupService workgroupService;
 | 
			
		||||
	private List<Member> users;
 | 
			
		||||
 | 
			
		||||
	@Init(superclass = true)
 | 
			
		||||
	public void init() {
 | 
			
		||||
		users = new ArrayList<Member>();
 | 
			
		||||
		users.addAll(userService.getAll());
 | 
			
		||||
		List<Workgroup> wg = workgroupService.getWorkgroups();
 | 
			
		||||
		
 | 
			
		||||
		for (Workgroup w : wg) {
 | 
			
		||||
			if (!workgroupService.isMember(getDataBean(), w)) {
 | 
			
		||||
				users.add(w);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public List<Member> getUsers() {
 | 
			
		||||
		return users;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public List<Role> getWorkgroupRoles() {
 | 
			
		||||
		if (getDataBean().isCentre()) {
 | 
			
		||||
			return roleService.getCentreRoles();
 | 
			
		||||
		} else {
 | 
			
		||||
			return roleService.getWorkgroupRoles();
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@NotifyChange({"workgroupRoles", "centre"})
 | 
			
		||||
	public void setCentre(boolean centre) {
 | 
			
		||||
		getDataBean().setCentre(centre);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public boolean getCentre() {
 | 
			
		||||
		return getDataBean().isCentre();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Command
 | 
			
		||||
	@NotifyChange({"users", "dataBean"})
 | 
			
		||||
	public void addMember(@BindingParam("event") DropEvent event) {
 | 
			
		||||
		 Set<Listitem> selected = ((Listitem)event.getDragged()).getListbox().getSelectedItems();
 | 
			
		||||
		 
 | 
			
		||||
		 if (selected.isEmpty()) {
 | 
			
		||||
			 try {
 | 
			
		||||
				 Member u = ((Listitem)event.getDragged()).getValue();
 | 
			
		||||
				 moveUser(u, event);
 | 
			
		||||
			 } catch(ClassCastException e) {
 | 
			
		||||
				 JobMapping u = ((Listitem)event.getDragged()).getValue();
 | 
			
		||||
				 moveUser(u, event);
 | 
			
		||||
			 }
 | 
			
		||||
			 
 | 
			
		||||
			 
 | 
			
		||||
			 return;
 | 
			
		||||
		 }
 | 
			
		||||
		 
 | 
			
		||||
		 for (Listitem li : selected) {
 | 
			
		||||
			 try {
 | 
			
		||||
				 Member u = li.getValue();
 | 
			
		||||
				 moveUser(u, event);
 | 
			
		||||
			 } catch (ClassCastException e) {
 | 
			
		||||
				 JobMapping u = li.getValue();
 | 
			
		||||
				 moveUser(u, event);
 | 
			
		||||
			 }
 | 
			
		||||
		 }
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void moveUser(JobMapping u, DropEvent event) {
 | 
			
		||||
		String source = getSource(event);
 | 
			
		||||
		String target = getTarget(event);
 | 
			
		||||
		
 | 
			
		||||
		if (source.equals(target)) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		getDataBean().removeMember(u);
 | 
			
		||||
		
 | 
			
		||||
		if (!target.equals("users")) {
 | 
			
		||||
			moveUser(u.getMember(), event);
 | 
			
		||||
		} else if (!u.getMember().isHasJob()) {
 | 
			
		||||
			users.add(u.getMember());
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private void moveUser(Member u, DropEvent event) {
 | 
			
		||||
		String source = getSource(event);
 | 
			
		||||
		String target = getTarget(event);
 | 
			
		||||
		
 | 
			
		||||
		if (source.equals(target)) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		workgroupService.addMember(getDataBean(), u, roleService.getRoleByAuthority(target));
 | 
			
		||||
		
 | 
			
		||||
		if (!u.isHasJob()) {
 | 
			
		||||
			users.remove(u);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private String getSource(DropEvent event) {
 | 
			
		||||
		return ((Listitem)event.getDragged()).getListbox().getId();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private String getTarget(DropEvent event) {
 | 
			
		||||
		String target;
 | 
			
		||||
		
 | 
			
		||||
		if (event.getTarget() instanceof Listitem) {
 | 
			
		||||
			target = ((Listitem)event.getTarget()).getListbox().getId();
 | 
			
		||||
		} else {
 | 
			
		||||
			target = event.getTarget().getId();
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return target;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,22 @@
 | 
			
		||||
package info.bukova.isspst.ui.workgroups;
 | 
			
		||||
 | 
			
		||||
import org.zkoss.bind.annotation.Init;
 | 
			
		||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
 | 
			
		||||
 | 
			
		||||
import info.bukova.isspst.data.Workgroup;
 | 
			
		||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
 | 
			
		||||
import info.bukova.isspst.ui.ListViewModel;
 | 
			
		||||
 | 
			
		||||
public class WorkgroupList extends ListViewModel<Workgroup> {
 | 
			
		||||
 | 
			
		||||
	@WireVariable
 | 
			
		||||
	private WorkgroupService workgroupService;
 | 
			
		||||
	
 | 
			
		||||
	@Init
 | 
			
		||||
	public void init() {
 | 
			
		||||
		service = workgroupService;
 | 
			
		||||
		dataClass = Workgroup.class;
 | 
			
		||||
		formZul = "workgroupForm.zul";
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
}
 | 
			
		||||
											
												Binary file not shown.
											
										
									
								| 
		 After Width: | Height: | Size: 1.6 KiB  | 
											
												Binary file not shown.
											
										
									
								| 
		 After Width: | Height: | Size: 3.3 KiB  | 
											
												Binary file not shown.
											
										
									
								| 
		 After Width: | Height: | Size: 3.8 KiB  | 
											
												Binary file not shown.
											
										
									
								| 
		 After Width: | Height: | Size: 4.0 KiB  | 
											
												Binary file not shown.
											
										
									
								| 
		 After Width: | Height: | Size: 30 KiB  | 
@ -0,0 +1,10 @@
 | 
			
		||||
<?page title="${labels.AgendaCommissions}" contentType="text/html;charset=UTF-8"?>
 | 
			
		||||
<zk>
 | 
			
		||||
 | 
			
		||||
<zscript>
 | 
			
		||||
	String gridZul = "workgroups.zul";
 | 
			
		||||
</zscript>
 | 
			
		||||
 | 
			
		||||
<include src="/app/template.zhtml"/>
 | 
			
		||||
 | 
			
		||||
</zk>
 | 
			
		||||
@ -0,0 +1,67 @@
 | 
			
		||||
<?page title="${labels.WorkgroupFormTitle}" 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.workgroups.WorkgroupForm')">
 | 
			
		||||
		<caption src="/img/commission.png" zclass="form-caption" label="${labels.WorkgroupFormTitle}" />
 | 
			
		||||
		<vlayout>
 | 
			
		||||
			<grid hflex="min">
 | 
			
		||||
				<columns>
 | 
			
		||||
					<column align="right" hflex="min" />
 | 
			
		||||
					<column />
 | 
			
		||||
				</columns>
 | 
			
		||||
				<rows>
 | 
			
		||||
					<row>
 | 
			
		||||
						<cell sclass="row-title">${labels.code} :</cell>
 | 
			
		||||
						<cell>
 | 
			
		||||
							<textbox id="code" constraint="@load(vm.constriant)" width="200px" value="@bind(vm.dataBean.code)" />
 | 
			
		||||
						</cell>
 | 
			
		||||
					</row>
 | 
			
		||||
					<row>
 | 
			
		||||
						<cell sclass="row-title">${labels.name} :</cell>
 | 
			
		||||
						<cell>
 | 
			
		||||
							<textbox id="name" width="200px" value="@bind(vm.dataBean.name)" />
 | 
			
		||||
						</cell>
 | 
			
		||||
					</row>
 | 
			
		||||
					<row>
 | 
			
		||||
						<cell>
 | 
			
		||||
							<checkbox label="Středisko" checked="@bind(vm.centre)"/>
 | 
			
		||||
						</cell>
 | 
			
		||||
					</row>
 | 
			
		||||
				</rows>
 | 
			
		||||
			</grid>
 | 
			
		||||
			<label value="Přetáhněte myší:"/>
 | 
			
		||||
			<hlayout>	
 | 
			
		||||
				<listbox id="users" model="@bind(vm.users)" height="280px" width="200px" multiple="true"
 | 
			
		||||
					droppable="true" onDrop="@command('addMember', event=event)">
 | 
			
		||||
					<listhead>
 | 
			
		||||
						<listheader label="Uživatelé" sort="czech(fullName)"/>
 | 
			
		||||
					</listhead>
 | 
			
		||||
					<template name="model">
 | 
			
		||||
						<listitem image="@load(each.hasJob ? '/img/user-small.png' : '/img/commission-small.png')" label="@load(each.fullName)" draggable="user" droppable="user"
 | 
			
		||||
						onDrop="@command('addMember', event=event)" attributes.item="@load(each)"/>
 | 
			
		||||
					</template>
 | 
			
		||||
				</listbox>
 | 
			
		||||
				
 | 
			
		||||
				
 | 
			
		||||
				
 | 
			
		||||
				<vlayout children="@load(vm.workgroupRoles)">
 | 
			
		||||
					<template name="children">
 | 
			
		||||
						<listbox id="@load(each.authority)" model="@bind(vm.dataBean.members)" height="120px" width="200px" multiple="true" 
 | 
			
		||||
						droppable="true" onDrop="@command('addMember', event=event)">
 | 
			
		||||
						<listhead>
 | 
			
		||||
							<listheader label="@load(each.description)" sort="czech(fullName)"/>
 | 
			
		||||
						</listhead>
 | 
			
		||||
						<template name="model" var="member">
 | 
			
		||||
							<listitem image="@load(member.member.hasJob ? '/img/user-small.png' : '/img/commission-small.png')" label="@load(member.member.fullName)" draggable="user" droppable="user"
 | 
			
		||||
							onDrop="@command('addMember', event=event)" attributes.item="@load(member)" visible="@load(member.role.authority eq each.authority)"/>
 | 
			
		||||
						</template>
 | 
			
		||||
					</listbox>	
 | 
			
		||||
					</template>
 | 
			
		||||
				
 | 
			
		||||
				</vlayout>
 | 
			
		||||
				
 | 
			
		||||
			</hlayout>
 | 
			
		||||
			<include src="/app/formButtons.zul" />
 | 
			
		||||
		</vlayout>	
 | 
			
		||||
	</window>
 | 
			
		||||
</zk>
 | 
			
		||||
@ -0,0 +1,94 @@
 | 
			
		||||
<?page title="${labels.AgendaWorkgroups}" 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.workgroups.WorkgroupList')">
 | 
			
		||||
		<caption zclass="form-caption" label="${labels.AgendaWorkgroups}" />
 | 
			
		||||
		<include src="/app/toolbar.zul" />
 | 
			
		||||
 | 
			
		||||
		<hbox width="100%" height="500px">
 | 
			
		||||
		
 | 
			
		||||
			<listbox model="@load(vm.dataList)" selectedItem="@bind(vm.dataBean)"  width="680px" height="480px">
 | 
			
		||||
				<listhead menupopup="auto">
 | 
			
		||||
					<listheader label="${labels.code}" sort="czech(code)" width="10%" />
 | 
			
		||||
					<listheader label="${labels.name}" sort="czech(name)" width="30%" />
 | 
			
		||||
				</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.code)" 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.name)" 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.code)" />
 | 
			
		||||
						<listcell label="@load(each.name)" />
 | 
			
		||||
					</listitem>
 | 
			
		||||
				</template>
 | 
			
		||||
			</listbox>
 | 
			
		||||
			
 | 
			
		||||
			<!-- <panel hflex="1" width="70%" height="480px">
 | 
			
		||||
				<panelchildren>
 | 
			
		||||
					<grid model="@load(vm.dataBean.approvers)" height="90px">
 | 
			
		||||
						<columns>
 | 
			
		||||
							<column label="Vedoucí" sort="auto(fullName)"/>
 | 
			
		||||
						</columns>
 | 
			
		||||
						<rows>
 | 
			
		||||
							<template name="model">
 | 
			
		||||
								<row>
 | 
			
		||||
									<cell>
 | 
			
		||||
										<image src="/img/user-small-red.png"/><label value="@load(each.fullName)"/>
 | 
			
		||||
									</cell>
 | 
			
		||||
								</row>
 | 
			
		||||
							</template>
 | 
			
		||||
						</rows>
 | 
			
		||||
					</grid>
 | 
			
		||||
									
 | 
			
		||||
					<grid model="@load(vm.dataBean.members)" height="290px">
 | 
			
		||||
						<columns>
 | 
			
		||||
							<column label="Členové" sort="auto(fullName)"/>
 | 
			
		||||
						</columns>
 | 
			
		||||
						<rows>
 | 
			
		||||
							<template name="model">
 | 
			
		||||
								<row>
 | 
			
		||||
									<cell>
 | 
			
		||||
										<image src="/img/user-small.png"/><label value="@load(each.fullName)"/>
 | 
			
		||||
									</cell>
 | 
			
		||||
								</row>
 | 
			
		||||
							</template>
 | 
			
		||||
						</rows>
 | 
			
		||||
					</grid>
 | 
			
		||||
				</panelchildren>
 | 
			
		||||
			</panel> -->
 | 
			
		||||
			
 | 
			
		||||
		</hbox>
 | 
			
		||||
	</window>
 | 
			
		||||
</zk>
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue