parent
							
								
									91fdbd7a9d
								
							
						
					
					
						commit
						0cd4e039f8
					
				@ -1,90 +1,38 @@
 | 
				
			|||||||
package info.bukova.isspst.data;
 | 
					package info.bukova.isspst.data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import info.bukova.isspst.StringUtils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.persistence.Column;
 | 
					import javax.persistence.Column;
 | 
				
			||||||
import javax.persistence.Entity;
 | 
					import javax.persistence.Entity;
 | 
				
			||||||
import javax.persistence.Table;
 | 
					import javax.persistence.Table;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.hibernate.validator.constraints.NotBlank;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
@Entity
 | 
					@Entity
 | 
				
			||||||
@Table(name = "MUNIT")
 | 
					@Table(name = "MUNIT")
 | 
				
			||||||
public class MUnit extends BaseData implements DataModel {
 | 
					public class MUnit extends BaseData
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
	@Column(name = "CODE", unique = true)
 | 
					 | 
				
			||||||
	private String code;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Column(name = "NAME")
 | 
						@Column(name = "NAME")
 | 
				
			||||||
	private String name;
 | 
						private String name;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Column(name = "DESCRIPTION")
 | 
						@Column(name = "DESCRIPTION")
 | 
				
			||||||
	private String description;
 | 
						private String description;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						public String getName()
 | 
				
			||||||
	 * @return the code
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	@NotBlank(message = "{MUnitsFormCodeConstr}")
 | 
					 | 
				
			||||||
	public String getCode() {
 | 
					 | 
				
			||||||
		return code;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * @param code
 | 
					 | 
				
			||||||
	 *            the code to set
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public void setCode(String code) {
 | 
					 | 
				
			||||||
		this.code = code;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * @return the name
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public String getName() {
 | 
					 | 
				
			||||||
		return this.name;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/**
 | 
					 | 
				
			||||||
	 * @param name
 | 
					 | 
				
			||||||
	 *            the name to set
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public void setName(String name) {
 | 
					 | 
				
			||||||
		this.name = name;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public String getNameSpecial()
 | 
					 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		String special = this.getName();
 | 
							return StringUtils.decodeSpecialChars(this.name);
 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (special != null)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			special = special.replace("[up]2[/up]", "²");
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		return special;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public void setNameSpecial(String special)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		if (special != null)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			special = special.replace("²", "[up]2[/up]");
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		this.setName(special);
 | 
						public void setName(String name)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.name = StringUtils.encodeSpecialChars(name);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						public String getDescription()
 | 
				
			||||||
	 * @return the description
 | 
						{
 | 
				
			||||||
	 */
 | 
							return StringUtils.decodeSpecialChars(this.description);
 | 
				
			||||||
	public String getDescription() {
 | 
					 | 
				
			||||||
		return description;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/**
 | 
						public void setDescription(String description)
 | 
				
			||||||
	 * @param description
 | 
						{
 | 
				
			||||||
	 *            the description to set
 | 
							this.description = StringUtils.encodeSpecialChars(description);
 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
	public void setDescription(String description) {
 | 
					 | 
				
			||||||
		this.description = description;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,81 +1,86 @@
 | 
				
			|||||||
package info.bukova.isspst.data;
 | 
					package info.bukova.isspst.data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import info.bukova.isspst.StringUtils;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import javax.persistence.Column;
 | 
					import javax.persistence.Column;
 | 
				
			||||||
import javax.persistence.Embeddable;
 | 
					import javax.persistence.Embeddable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Embeddable
 | 
					@Embeddable
 | 
				
			||||||
public class MUnitEmb {
 | 
					public class MUnitEmb
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
	@Column(name = "MUNIT_ID")
 | 
						@Column(name = "MUNIT_ID")
 | 
				
			||||||
	private Integer id;
 | 
						private Integer id;
 | 
				
			||||||
	@Column(name = "MUNIT_CODE")
 | 
					
 | 
				
			||||||
	private String code;
 | 
					 | 
				
			||||||
	@Column(name = "MUNIT_DESCRIPTION")
 | 
					 | 
				
			||||||
	private String description;
 | 
					 | 
				
			||||||
	@Column(name = "MUNIT_NAME")
 | 
						@Column(name = "MUNIT_NAME")
 | 
				
			||||||
	private String name;
 | 
						private String name;
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public MUnitEmb() {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Column(name = "MUNIT_DESCRIPTION")
 | 
				
			||||||
 | 
						private String description;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public MUnitEmb()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	public MUnitEmb(MUnit munit) {
 | 
						public MUnitEmb(MUnit munit)
 | 
				
			||||||
		this.id = munit.getId();
 | 
						{
 | 
				
			||||||
		this.code = munit.getCode();
 | 
							this.setId(munit.getId());
 | 
				
			||||||
		this.description = munit.getDescription();
 | 
							this.setDescription(munit.getDescription());
 | 
				
			||||||
		this.name = munit.getName();
 | 
							this.setName(munit.getName());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public Integer getId() {
 | 
						public Integer getId()
 | 
				
			||||||
		return id;
 | 
						{
 | 
				
			||||||
 | 
							return this.id;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void setId(Integer id) {
 | 
						public void setId(Integer id)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
		this.id = id;
 | 
							this.id = id;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public String getCode() {
 | 
						public String getName()
 | 
				
			||||||
		return code;
 | 
						{
 | 
				
			||||||
 | 
							return StringUtils.decodeSpecialChars(this.name);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void setCode(String code) {
 | 
						public void setName(String name)
 | 
				
			||||||
		this.code = code;
 | 
						{
 | 
				
			||||||
 | 
							this.name = StringUtils.encodeSpecialChars(name);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public String getDescription() {
 | 
						public String getDescription()
 | 
				
			||||||
		return description;
 | 
						{
 | 
				
			||||||
 | 
							return StringUtils.decodeSpecialChars(this.description);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void setDescription(String description) {
 | 
						public void setDescription(String description)
 | 
				
			||||||
		this.description = description;
 | 
						{
 | 
				
			||||||
 | 
							this.description = StringUtils.encodeSpecialChars(description);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public String getName() {
 | 
						public boolean eqWith(MUnit munit)
 | 
				
			||||||
		return name;
 | 
						{
 | 
				
			||||||
	}
 | 
							if (munit == null)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return false;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void setName(String name) {
 | 
							return this.getId() == munit.getId() && this.getName().equals(munit.getName()) && this.getDescription().equals(munit.getDescription());
 | 
				
			||||||
		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
 | 
						@Override
 | 
				
			||||||
	public boolean equals(Object munit) {
 | 
						public boolean equals(Object munit)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
		return munit != null
 | 
							return munit != null
 | 
				
			||||||
				&& (munit instanceof MUnitEmb)
 | 
									&& (munit instanceof MUnitEmb)
 | 
				
			||||||
				&& this.id == ((MUnitEmb)munit).getId() 
 | 
									&& this.getId() == ((MUnitEmb) munit).getId()
 | 
				
			||||||
				&& (this.code == ((MUnitEmb)munit).getCode() || this.code.equals(((MUnitEmb)munit).getCode())) 
 | 
									&& (this.getName() == ((MUnitEmb) munit).getName() || this.getName().equals(((MUnitEmb) munit).getName()))
 | 
				
			||||||
				&& (this.name == ((MUnitEmb)munit).getName() || this.name.equals(((MUnitEmb)munit).getName()))
 | 
									&& (this.getDescription() == ((MUnitEmb) munit).getDescription() || this.getDescription().equals(((MUnitEmb) munit).getDescription()));
 | 
				
			||||||
				&& (this.description == ((MUnitEmb)munit).getDescription() || this.description.equals(((MUnitEmb)munit).getDescription()));
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String toString() {
 | 
						public String toString()
 | 
				
			||||||
		return this.code + " - " + this.name;
 | 
						{
 | 
				
			||||||
 | 
							return this.getName();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,8 +1,12 @@
 | 
				
			|||||||
package info.bukova.isspst.services.munits;
 | 
					package info.bukova.isspst.services.munits;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import info.bukova.isspst.data.MUnit;
 | 
					import info.bukova.isspst.data.MUnit;
 | 
				
			||||||
 | 
					import info.bukova.isspst.data.MUnitEmb;
 | 
				
			||||||
import info.bukova.isspst.services.Service;
 | 
					import info.bukova.isspst.services.Service;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public interface MUnitService  extends Service<MUnit> {
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface MUnitService extends Service<MUnit>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						public List<MUnitEmb> getEmbAll();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1,8 +1,29 @@
 | 
				
			|||||||
package info.bukova.isspst.services.munits;
 | 
					package info.bukova.isspst.services.munits;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import info.bukova.isspst.data.MUnit;
 | 
					import info.bukova.isspst.data.MUnit;
 | 
				
			||||||
 | 
					import info.bukova.isspst.data.MUnitEmb;
 | 
				
			||||||
import info.bukova.isspst.services.AbstractService;
 | 
					import info.bukova.isspst.services.AbstractService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class MUnitServiceImpl  extends AbstractService<MUnit> implements MUnitService{
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.springframework.transaction.annotation.Transactional;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MUnitServiceImpl extends AbstractService<MUnit> implements MUnitService
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						@Transactional
 | 
				
			||||||
 | 
						public List<MUnitEmb> getEmbAll()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							List<MUnit> munitList = this.getAll();
 | 
				
			||||||
 | 
							List<MUnitEmb> munitEmbList = new ArrayList<MUnitEmb>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for (MUnit m : munitList)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								MUnitEmb muEmb = new MUnitEmb(m);
 | 
				
			||||||
 | 
								munitEmbList.add(muEmb);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return munitEmbList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,62 @@
 | 
				
			|||||||
 | 
					package info.bukova.isspst.ui;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.math.BigDecimal;
 | 
				
			||||||
 | 
					import java.text.DecimalFormat;
 | 
				
			||||||
 | 
					import java.text.ParseException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
 | 
					import org.slf4j.LoggerFactory;
 | 
				
			||||||
 | 
					import org.zkoss.bind.BindContext;
 | 
				
			||||||
 | 
					import org.zkoss.bind.Converter;
 | 
				
			||||||
 | 
					import org.zkoss.zk.ui.Component;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class BigDecimalConverter implements Converter<String, BigDecimal, Component>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						private final static Logger log = LoggerFactory.getLogger(BigDecimalConverter.class.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public BigDecimal coerceToBean(String str, Component component, BindContext cx)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							BigDecimal val = BigDecimal.ZERO;
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							if (str != null)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								try
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									DecimalFormat format = new DecimalFormat();
 | 
				
			||||||
 | 
									format.setParseBigDecimal(true);
 | 
				
			||||||
 | 
									val = (BigDecimal) format.parse(str);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								catch (NumberFormatException e)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									log.warn(str, e);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								catch (ParseException e)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									log.warn(str, e);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							return val;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public String coerceToUi(BigDecimal val, Component component, BindContext cx)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (val == null)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								val = BigDecimal.ZERO;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							val = val.setScale(2, BigDecimal.ROUND_DOWN);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							DecimalFormat format = new DecimalFormat();
 | 
				
			||||||
 | 
							format.setMaximumFractionDigits(2);
 | 
				
			||||||
 | 
							format.setMinimumFractionDigits(2);
 | 
				
			||||||
 | 
							format.setGroupingUsed(true);
 | 
				
			||||||
 | 
							format.setGroupingSize(3);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return format.format(val);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,24 +1,45 @@
 | 
				
			|||||||
package info.bukova.isspst.ui.reqsubjects;
 | 
					package info.bukova.isspst.ui.reqsubjects;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import org.zkoss.bind.annotation.Init;
 | 
					import info.bukova.isspst.data.MUnitEmb;
 | 
				
			||||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import info.bukova.isspst.data.Material;
 | 
					import info.bukova.isspst.data.Material;
 | 
				
			||||||
import info.bukova.isspst.filters.MaterialFilter;
 | 
					import info.bukova.isspst.filters.MaterialFilter;
 | 
				
			||||||
 | 
					import info.bukova.isspst.services.munits.MUnitService;
 | 
				
			||||||
import info.bukova.isspst.services.reqsubjects.MaterialService;
 | 
					import info.bukova.isspst.services.reqsubjects.MaterialService;
 | 
				
			||||||
import info.bukova.isspst.ui.ListViewModel;
 | 
					import info.bukova.isspst.ui.ListViewModel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.zkoss.bind.annotation.Init;
 | 
				
			||||||
 | 
					import org.zkoss.zk.ui.select.annotation.WireVariable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class MaterialList extends ListViewModel<Material> {
 | 
					public class MaterialList extends ListViewModel<Material> {
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@WireVariable
 | 
						@WireVariable
 | 
				
			||||||
	private MaterialService materialService;
 | 
						private MaterialService materialService;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						@WireVariable
 | 
				
			||||||
 | 
						private MUnitService munitService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private List<MUnitEmb> munitList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Init
 | 
						@Init
 | 
				
			||||||
	public void init() {
 | 
						public void init() {
 | 
				
			||||||
		service = materialService;
 | 
							service = materialService;
 | 
				
			||||||
		dataClass = Material.class;
 | 
							dataClass = Material.class;
 | 
				
			||||||
		formZul = "materialForm.zul";
 | 
							formZul = "materialForm.zul";
 | 
				
			||||||
		dataFilter = new MaterialFilter(getFilterTemplate());
 | 
							dataFilter = new MaterialFilter(getFilterTemplate());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.setMunitList(munitService.getEmbAll());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public List<MUnitEmb> getMunitList()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return munitList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setMunitList(List<MUnitEmb> munitList)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.munitList = munitList;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,254 @@
 | 
				
			|||||||
 | 
					package info.bukova.isspst.ui.requirement;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import info.bukova.isspst.data.MUnitEmb;
 | 
				
			||||||
 | 
					import info.bukova.isspst.data.Material;
 | 
				
			||||||
 | 
					import info.bukova.isspst.data.RequirementSubject;
 | 
				
			||||||
 | 
					import info.bukova.isspst.data.ServiceItem;
 | 
				
			||||||
 | 
					import info.bukova.isspst.filters.MaterialFilter;
 | 
				
			||||||
 | 
					import info.bukova.isspst.filters.ServiceItemFilter;
 | 
				
			||||||
 | 
					import info.bukova.isspst.services.munits.MUnitService;
 | 
				
			||||||
 | 
					import info.bukova.isspst.services.reqsubjects.MaterialService;
 | 
				
			||||||
 | 
					import info.bukova.isspst.services.reqsubjects.ServiceItemService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SelectItems
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						@WireVariable
 | 
				
			||||||
 | 
						private MaterialService materialService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private List<Material> materialList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private List<Material> fullMaterialList;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private boolean activeFilterMaterial;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private Material filterTmpMaterial;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private MaterialFilter dataFilterMaterial;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@WireVariable
 | 
				
			||||||
 | 
						private ServiceItemService serviceItemService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private List<ServiceItem> serviceItemList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private List<ServiceItem> fullServiceItemList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						private boolean activeFilterService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private ServiceItem filterTmpService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private ServiceItemFilter dataFilterService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private RequirementSubject selectedItem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@WireVariable
 | 
				
			||||||
 | 
						private MUnitService munitService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private List<MUnitEmb> munitList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Init
 | 
				
			||||||
 | 
						public void init()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.setFullMaterialList(materialService.getAll());
 | 
				
			||||||
 | 
							this.setMaterialList(this.getFullMaterialList());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.setActiveFilterMaterial(false);
 | 
				
			||||||
 | 
							this.setFilterTmpMaterial(new Material());
 | 
				
			||||||
 | 
							this.setDataFilterMaterial(new MaterialFilter(this.getFilterTmpMaterial()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.setFullServiceItemList(serviceItemService.getAll());
 | 
				
			||||||
 | 
							this.setServiceItemList(this.getFullServiceItemList());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.setActiveFilterService(false);
 | 
				
			||||||
 | 
							this.setFilterTmpService(new ServiceItem());
 | 
				
			||||||
 | 
							this.setDataFilterService(new ServiceItemFilter(this.getFilterTmpService()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.setMunitList(munitService.getEmbAll());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public List<Material> getMaterialList()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return materialList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setMaterialList(List<Material> materialList)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.materialList = materialList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public List<Material> getFullMaterialList()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return fullMaterialList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setFullMaterialList(List<Material> fullMaterialList)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.fullMaterialList = fullMaterialList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public boolean isActiveFilterMaterial()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return activeFilterMaterial;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setActiveFilterMaterial(boolean activeFilterMaterial)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.activeFilterMaterial = activeFilterMaterial;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public Material getFilterTmpMaterial()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return this.filterTmpMaterial;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private void setFilterTmpMaterial(Material material)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.filterTmpMaterial = material;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public MaterialFilter getDataFilterMaterial()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return dataFilterMaterial;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setDataFilterMaterial(MaterialFilter dataFilterMaterial)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.dataFilterMaterial = dataFilterMaterial;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public List<ServiceItem> getServiceItemList()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return serviceItemList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setServiceItemList(List<ServiceItem> serviceItemList)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.serviceItemList = serviceItemList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public List<ServiceItem> getFullServiceItemList()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return fullServiceItemList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setFullServiceItemList(List<ServiceItem> fullServiceItemList)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.fullServiceItemList = fullServiceItemList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public boolean isActiveFilterService()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return activeFilterService;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setActiveFilterService(boolean activeFilterService)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.activeFilterService = activeFilterService;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public ServiceItem getFilterTmpService()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return this.filterTmpService;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private void setFilterTmpService(ServiceItem serviceItem)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.filterTmpService = serviceItem;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public ServiceItemFilter getDataFilterService()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return dataFilterService;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setDataFilterService(ServiceItemFilter dataFilterService)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.dataFilterService = dataFilterService;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public RequirementSubject getSelectedItem()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return selectedItem;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setSelectedItem(RequirementSubject selectedItem)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.selectedItem = selectedItem;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public List<MUnitEmb> getMunitList()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return munitList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public void setMunitList(List<MUnitEmb> munitList)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.munitList = munitList;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Command
 | 
				
			||||||
 | 
						@NotifyChange({ "activeFilterMaterial", "materialList", "selectedItem" })
 | 
				
			||||||
 | 
						public void onFilterMaterial()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.setSelectedItem(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.setActiveFilterMaterial(!this.isActiveFilterMaterial());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (this.isActiveFilterMaterial())
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								this.doFilterMaterial();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								this.setMaterialList(this.getFullMaterialList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Command
 | 
				
			||||||
 | 
						@NotifyChange("materialList")
 | 
				
			||||||
 | 
						public void doFilterMaterial()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.setSelectedItem(null);
 | 
				
			||||||
 | 
							List<Material> result = this.materialService.filterList(this.getFullMaterialList(), this.getDataFilterMaterial());
 | 
				
			||||||
 | 
							this.setMaterialList(result);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Command
 | 
				
			||||||
 | 
						@NotifyChange({ "activeFilterService", "serviceItemList", "selectedItem" })
 | 
				
			||||||
 | 
						public void onFilterService()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.setSelectedItem(null);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.setActiveFilterService(!this.isActiveFilterService());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (this.isActiveFilterService())
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								this.doFilterService();
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								this.setServiceItemList(this.getFullServiceItemList());
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Command
 | 
				
			||||||
 | 
						@NotifyChange("serviceItemList")
 | 
				
			||||||
 | 
						public void doFilterService()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.setSelectedItem(null);
 | 
				
			||||||
 | 
							List<ServiceItem> result = this.serviceItemService.filterList(this.getFullServiceItemList(), this.getDataFilterService());
 | 
				
			||||||
 | 
							this.setServiceItemList(result);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,82 +0,0 @@
 | 
				
			|||||||
package info.bukova.isspst.ui.requirements;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import info.bukova.isspst.data.Material;
 | 
					 | 
				
			||||||
import info.bukova.isspst.data.ServiceItem;
 | 
					 | 
				
			||||||
import info.bukova.isspst.services.reqsubjects.MaterialService;
 | 
					 | 
				
			||||||
import info.bukova.isspst.services.reqsubjects.ServiceItemService;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.List;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import org.zkoss.bind.annotation.Command;
 | 
					 | 
				
			||||||
import org.zkoss.bind.annotation.Init;
 | 
					 | 
				
			||||||
import org.zkoss.zk.ui.select.annotation.WireVariable;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class SelectItems
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	@WireVariable
 | 
					 | 
				
			||||||
	private MaterialService materialService;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	@WireVariable
 | 
					 | 
				
			||||||
	private ServiceItemService serviceItemService;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private List<Material> materialList;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	private List<ServiceItem> serviceItemList;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private Material selectedMaterial;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private ServiceItem selectedServiceItem;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Init
 | 
					 | 
				
			||||||
	public void init()
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		this.setMaterialList(materialService.getAll());
 | 
					 | 
				
			||||||
		this.setServiceItemList(serviceItemService.getAll());
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public List<Material> getMaterialList()
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		return materialList;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public void setMaterialList(List<Material> materialList)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		this.materialList = materialList;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public List<ServiceItem> getServiceItemList()
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		return serviceItemList;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public void setServiceItemList(List<ServiceItem> serviceItemList)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		this.serviceItemList = serviceItemList;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public Material getSelectedMaterial()
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		return selectedMaterial;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public void setSelectedMaterial(Material selectedMaterial)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		this.selectedMaterial = selectedMaterial;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public ServiceItem getSelectedServiceItem()
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		return selectedServiceItem;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	public void setSelectedServiceItem(ServiceItem selectedServiceItem)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		this.selectedServiceItem = selectedServiceItem;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	@Command
 | 
					 | 
				
			||||||
	public void addItem()
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		//this
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -0,0 +1,33 @@
 | 
				
			|||||||
 | 
					package info.bukova.isspst.validators;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import info.bukova.isspst.StringUtils;
 | 
				
			||||||
 | 
					import info.bukova.isspst.data.Workgroup;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
 | 
					import org.slf4j.LoggerFactory;
 | 
				
			||||||
 | 
					import org.zkoss.bind.Property;
 | 
				
			||||||
 | 
					import org.zkoss.bind.ValidationContext;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class RequirementFormValidator extends BaseValidator
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						private final static Logger log = LoggerFactory.getLogger(RequirementFormValidator.class.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						protected Logger getLogger()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return log;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void validate(ValidationContext ctx)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							Property propertyWorkgroup = ctx.getProperties("workgroup")[0];
 | 
				
			||||||
 | 
							Workgroup workgroup = (Workgroup) propertyWorkgroup.getValue();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (workgroup == null)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								this.errorMsg(ctx, StringUtils.localize("RequirementCenterIsEmpty"), "idReqCenter");
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
					Loading…
					
					
				
		Reference in New Issue