ItEr25S12AltaTipoDeEtiquetas: Create Label and LabelType entities, added a bidirectional relationship between OrderElement and Label
This commit is contained in:
parent
672cc52e9d
commit
109d9aeb97
3 changed files with 143 additions and 0 deletions
|
|
@ -0,0 +1,69 @@
|
|||
package org.navalplanner.business.labels.entities;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.NotEmpty;
|
||||
import org.hibernate.validator.NotNull;
|
||||
import org.navalplanner.business.common.BaseEntity;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
|
||||
/**
|
||||
* Label entity
|
||||
*
|
||||
* @author Diego Pino Garcia<dpino@igalia.com
|
||||
*
|
||||
*/
|
||||
public class Label extends BaseEntity {
|
||||
|
||||
@NotEmpty
|
||||
private String name;
|
||||
|
||||
@NotNull
|
||||
private LabelType type;
|
||||
|
||||
private Set<OrderElement> orderElements;
|
||||
|
||||
// Default constructor, needed by Hibernate
|
||||
private Label() {
|
||||
|
||||
}
|
||||
|
||||
public static Label create(String name) {
|
||||
return (Label) create(new Label(name));
|
||||
}
|
||||
|
||||
protected Label(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public LabelType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(LabelType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Set<OrderElement> getOrderElements() {
|
||||
return Collections.unmodifiableSet(orderElements);
|
||||
}
|
||||
|
||||
public void addOrderElement(OrderElement orderElement) {
|
||||
Validate.notNull(orderElement);
|
||||
orderElements.add(orderElement);
|
||||
}
|
||||
|
||||
public void removeOrderElement(OrderElement orderElement) {
|
||||
orderElements.add(orderElement);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
package org.navalplanner.business.labels.entities;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.NotEmpty;
|
||||
import org.navalplanner.business.common.BaseEntity;
|
||||
|
||||
/**
|
||||
* LabeType entity
|
||||
*
|
||||
* @author Diego Pino Garcia<dpino@igalia.com>
|
||||
*
|
||||
*/
|
||||
public class LabelType extends BaseEntity {
|
||||
|
||||
@NotEmpty
|
||||
private String name;
|
||||
|
||||
private Set<Label> labels;
|
||||
|
||||
// Default constructor, needed by Hibernate
|
||||
private LabelType() {
|
||||
|
||||
}
|
||||
|
||||
public static LabelType create(String name) {
|
||||
return (LabelType) create(new LabelType(name));
|
||||
}
|
||||
|
||||
protected LabelType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Set<Label> getLabels() {
|
||||
return Collections.unmodifiableSet(labels);
|
||||
}
|
||||
|
||||
public void addLabel(Label label) {
|
||||
Validate.notNull(label);
|
||||
labels.add(label);
|
||||
}
|
||||
|
||||
public void removeLabel(Label label) {
|
||||
labels.remove(label);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -6,12 +6,14 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.hibernate.validator.NotEmpty;
|
||||
import org.navalplanner.business.advance.entities.AdvanceAssigment;
|
||||
import org.navalplanner.business.advance.entities.AdvanceType;
|
||||
import org.navalplanner.business.advance.exceptions.DuplicateAdvanceAssigmentForOrderElementException;
|
||||
import org.navalplanner.business.advance.exceptions.DuplicateValueTrueReportGlobalAdvanceException;
|
||||
import org.navalplanner.business.common.BaseEntity;
|
||||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
|
||||
public abstract class OrderElement extends BaseEntity {
|
||||
|
|
@ -31,6 +33,8 @@ public abstract class OrderElement extends BaseEntity {
|
|||
|
||||
private Set<AdvanceAssigment> advanceAssigments = new HashSet<AdvanceAssigment>();
|
||||
|
||||
private Set<Label> labels = new HashSet<Label>();
|
||||
|
||||
@NotEmpty
|
||||
private String code;
|
||||
|
||||
|
|
@ -150,6 +154,19 @@ public abstract class OrderElement extends BaseEntity {
|
|||
advanceAssigments.remove(advanceAssigment);
|
||||
}
|
||||
|
||||
public Set<Label> getLabels() {
|
||||
return Collections.unmodifiableSet(labels);
|
||||
}
|
||||
|
||||
public void addLabel(Label label) {
|
||||
Validate.notNull(label);
|
||||
labels.add(label);
|
||||
}
|
||||
|
||||
public void removeLabel(Label label) {
|
||||
labels.remove(label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate if the advanceAssigment can be added to the order element.The
|
||||
* list of advanceAssigments must be attached.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue