org.nuiton.topia.it.legacy.topiatest.DepartmentAbstract Maven / Gradle / Ivy
package org.nuiton.topia.it.legacy.topiatest;
import java.util.Collection;
import java.util.LinkedList;
import javax.annotation.Generated;
import org.nuiton.i18n.I18n;
import org.nuiton.topia.it.legacy.AbstractTopiaItLegacyEntity;
import org.nuiton.topia.persistence.TopiaEntity;
import org.nuiton.topia.persistence.TopiaEntityVisitor;
import org.nuiton.topia.persistence.TopiaException;
import org.nuiton.topia.persistence.util.TopiaEntityHelper;
@Generated(value = "org.nuiton.topia.templates.EntityTransformer", date = "Thu Oct 13 17:59:13 CEST 2016")
public abstract class DepartmentAbstract extends AbstractTopiaItLegacyEntity implements Department {
/**
* Nom de l'attribut en BD : name
*/
protected String name;
/**
* Nom de l'attribut en BD : leader
*/
protected Employe leader;
/**
* Nom de l'attribut en BD : company
*/
protected Company company;
/**
* Nom de l'attribut en BD : product
*/
protected Collection product;
private static final long serialVersionUID = 4120851041491432033L;
static {
I18n.n("topia.test.common.department");
I18n.n("topia.test.common.name");
I18n.n("topia.test.common.leader");
I18n.n("topia.test.common.company");
I18n.n("topia.test.common.product");
}
@Override
public void accept(TopiaEntityVisitor visitor) throws TopiaException {
visitor.start(this);
accept0(visitor);
visitor.end(this);
}
protected void accept0(TopiaEntityVisitor visitor) throws TopiaException {
visitor.visit(this, PROPERTY_NAME, String.class, name);
visitor.visit(this, PROPERTY_LEADER, Employe.class, leader);
visitor.visit(this, PROPERTY_COMPANY, Company.class, company);
visitor.visit(this, PROPERTY_PRODUCT, Collection.class, Product.class, product);
}
@Override
public void setName(String name) {
String oldValue = this.name;
fireOnPreWrite(PROPERTY_NAME, oldValue, name);
this.name = name;
fireOnPostWrite(PROPERTY_NAME, oldValue, name);
}
@Override
public String getName() {
fireOnPreRead(PROPERTY_NAME, name);
String result = this.name;
fireOnPostRead(PROPERTY_NAME, name);
return result;
}
@Override
public void setLeader(Employe leader) {
Employe oldValue = this.leader;
fireOnPreWrite(PROPERTY_LEADER, oldValue, leader);
this.leader = leader;
fireOnPostWrite(PROPERTY_LEADER, oldValue, leader);
}
@Override
public Employe getLeader() {
fireOnPreRead(PROPERTY_LEADER, leader);
Employe result = this.leader;
fireOnPostRead(PROPERTY_LEADER, leader);
return result;
}
@Override
public void setCompany(Company company) {
Company oldValue = this.company;
fireOnPreWrite(PROPERTY_COMPANY, oldValue, company);
this.company = company;
fireOnPostWrite(PROPERTY_COMPANY, oldValue, company);
}
@Override
public Company getCompany() {
fireOnPreRead(PROPERTY_COMPANY, company);
Company result = this.company;
fireOnPostRead(PROPERTY_COMPANY, company);
return result;
}
@Override
public void addProduct(Product product) {
fireOnPreWrite(PROPERTY_PRODUCT, null, product);
if (this.product == null) {
this.product = new LinkedList();
}
this.product.add(product);
fireOnPostWrite(PROPERTY_PRODUCT, this.product.size(), null, product);
}
@Override
public void addAllProduct(Iterable product) {
if (product == null) {
return;
}
for (Product item : product) {
addProduct(item);
}
}
@Override
public void setProduct(Collection product) {
// Copy elements to keep data for fire with new reference
Collection oldValue = this.product != null ? new LinkedList(this.product) : null;
fireOnPreWrite(PROPERTY_PRODUCT, oldValue, product);
this.product = product;
fireOnPostWrite(PROPERTY_PRODUCT, oldValue, product);
}
@Override
public void removeProduct(Product product) {
fireOnPreWrite(PROPERTY_PRODUCT, product, null);
if (this.product == null || !this.product.remove(product)) {
throw new IllegalArgumentException("List does not contain given element");
}
fireOnPostWrite(PROPERTY_PRODUCT, this.product.size() + 1, product, null);
}
@Override
public void clearProduct() {
if (this.product == null) {
return;
}
Collection oldValue = new LinkedList(this.product);
fireOnPreWrite(PROPERTY_PRODUCT, oldValue, this.product);
this.product.clear();
fireOnPostWrite(PROPERTY_PRODUCT, oldValue, this.product);
}
@Override
public Collection getProduct() {
return product;
}
@Override
public Product getProductByTopiaId(String topiaId) {
return TopiaEntityHelper.getEntityByTopiaId(product, topiaId);
}
@Override
public Collection getProductTopiaIds() {
Collection topiaIds = new LinkedList();
Collection tmp = getProduct();
if (tmp != null) {
for (TopiaEntity topiaEntity : tmp) {
topiaIds.add(topiaEntity.getTopiaId());
}
}
return topiaIds;
}
@Override
public int sizeProduct() {
if (product == null) {
return 0;
}
return product.size();
}
@Override
public boolean isProductEmpty() {
int size = sizeProduct();
return size == 0;
}
@Override
public boolean isProductNotEmpty() {
boolean empty = isProductEmpty();
return ! empty;
}
@Override
public boolean containsProduct(Product product) {
boolean contains = this.product !=null && this.product.contains(product);
return contains;
}
} //DepartmentAbstract
© 2015 - 2024 Weber Informatics LLC | Privacy Policy