parent
							
								
									0e0fb3a43c
								
							
						
					
					
						commit
						35131d555d
					
				@ -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,15 +1,35 @@
 | 
			
		||||
package info.bukova.isspst.ui.material;
 | 
			
		||||
 | 
			
		||||
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;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue