* Terms - Prepared support for rename * ObjectType.java - Added ID for serialization - Added RELATIONSHIP class constant * struts.xml - Added Relationship actions * General - Relationships between two terms can be added and listed - Clean-up: + Renamed methods according to their purpose + Fixed RDM and corresponding properties/annotations + RelationShipTypeAction.java
/trunk/src/ch/ffhs/webE/domain/Relationship.java |
---|
12,7 → 12,9 |
import javax.persistence.OneToOne; |
import javax.persistence.PrimaryKeyJoinColumn; |
import javax.persistence.Table; |
import javax.persistence.Transient; |
import javax.persistence.UniqueConstraint; |
import org.hibernate.annotations.GenericGenerator; |
import org.hibernate.annotations.Parameter; |
21,24 → 23,29 |
*/ |
@Entity |
@Table(name = "relationship", catalog = "webengineering", uniqueConstraints = @UniqueConstraint(columnNames = { |
"term_from", "term_to", "type" })) |
public class Relationship implements java.io.Serializable { |
"term_from", "term_to", "type_id" })) |
public class Relationship implements java.io.Serializable |
{ |
private int objectId; |
private int objectId; |
private Term termByTermTo; |
@Transient |
private ObjectEntity object; |
private Term termFrom; |
private Term termTo; |
private RelationshipType relationshipType; |
private Term termByTermFrom; |
public Relationship() { |
public Relationship() |
{ |
} |
public Relationship(Term termByTermTo, ObjectEntity object, |
RelationshipType relationshipType, Term termByTermFrom) { |
this.termByTermTo = termByTermTo; |
RelationshipType relationshipType, Term termByTermFrom) |
{ |
this.termTo = termByTermTo; |
this.object = object; |
this.relationshipType = relationshipType; |
this.termByTermFrom = termByTermFrom; |
this.termFrom = termByTermFrom; |
} |
@GenericGenerator(name = "generator", strategy = "foreign", parameters = @Parameter(name = "property", value = "object")) |
45,52 → 52,62 |
@Id |
@GeneratedValue(generator = "generator") |
@Column(name = "object_id", unique = true, nullable = false) |
public int getObjectId() { |
public int getObjectId() |
{ |
return this.objectId; |
} |
public void setObjectId(int objectId) { |
public void setObjectId(int objectId) |
{ |
this.objectId = objectId; |
} |
@ManyToOne(fetch = FetchType.LAZY) |
@JoinColumn(name = "term_to", nullable = false) |
public Term getTermByTermTo() { |
return this.termByTermTo; |
public Term getTermTo() |
{ |
return this.termTo; |
} |
public void setTermByTermTo(Term termByTermTo) { |
this.termByTermTo = termByTermTo; |
public void setTermTo(Term termByTermTo) |
{ |
this.termTo = termByTermTo; |
} |
@OneToOne(fetch = FetchType.LAZY) |
@PrimaryKeyJoinColumn |
public ObjectEntity getObject() { |
public ObjectEntity getObject() |
{ |
return this.object; |
} |
public void setObject(ObjectEntity object) { |
public void setObject(ObjectEntity object) |
{ |
this.object = object; |
} |
@ManyToOne(fetch = FetchType.LAZY) |
@JoinColumn(name = "type", nullable = false) |
public RelationshipType getRelationshipType() { |
@JoinColumn(name = "type_id", nullable = false) |
public RelationshipType getRelationshipType() |
{ |
return this.relationshipType; |
} |
public void setRelationshipType(RelationshipType relationshipType) { |
public void setRelationshipType(RelationshipType relationshipType) |
{ |
this.relationshipType = relationshipType; |
} |
@ManyToOne(fetch = FetchType.LAZY) |
@JoinColumn(name = "term_from", nullable = false) |
public Term getTermByTermFrom() { |
return this.termByTermFrom; |
public Term getTermFrom() |
{ |
return this.termFrom; |
} |
public void setTermByTermFrom(Term termByTermFrom) { |
this.termByTermFrom = termByTermFrom; |
public void setTermFrom(Term termByTermFrom) |
{ |
this.termFrom = termByTermFrom; |
} |
} |
/trunk/src/ch/ffhs/webE/domain/RelationshipType.java |
---|
2,13 → 2,15 |
// Generated 19.12.2010 14:46:08 by Hibernate Tools 3.4.0.Beta1 |
import static javax.persistence.GenerationType.IDENTITY; |
import java.util.HashSet; |
import java.util.Set; |
import javax.persistence.Column; |
import javax.persistence.Entity; |
import javax.persistence.FetchType; |
import javax.persistence.GeneratedValue; |
import static javax.persistence.GenerationType.IDENTITY; |
import javax.persistence.Id; |
import javax.persistence.OneToMany; |
import javax.persistence.Table; |
19,23 → 21,27 |
*/ |
@Entity |
@Table(name = "relationship_type", catalog = "webengineering", uniqueConstraints = @UniqueConstraint(columnNames = "name_from")) |
public class RelationshipType implements java.io.Serializable { |
public class RelationshipType implements java.io.Serializable |
{ |
private Integer relationshipId; |
private Integer id; |
private String nameFrom; |
private String nameTo; |
private Set<Relationship> relationships = new HashSet<Relationship>(0); |
public RelationshipType() { |
public RelationshipType() |
{ |
} |
public RelationshipType(String nameFrom, String nameTo) { |
public RelationshipType(String nameFrom, String nameTo) |
{ |
this.nameFrom = nameFrom; |
this.nameTo = nameTo; |
} |
public RelationshipType(String nameFrom, String nameTo, |
Set<Relationship> relationships) { |
Set<Relationship> relationships) |
{ |
this.nameFrom = nameFrom; |
this.nameTo = nameTo; |
this.relationships = relationships; |
43,39 → 49,47 |
@Id |
@GeneratedValue(strategy = IDENTITY) |
@Column(name = "relationship_id", unique = true, nullable = false) |
public Integer getRelationshipId() { |
return this.relationshipId; |
@Column(name = "id", unique = true, nullable = false) |
public Integer getId() |
{ |
return this.id; |
} |
public void setRelationshipId(Integer relationshipId) { |
this.relationshipId = relationshipId; |
public void setId(Integer id) |
{ |
this.id = id; |
} |
@Column(name = "name_from", unique = true, nullable = false) |
public String getNameFrom() { |
public String getNameFrom() |
{ |
return this.nameFrom; |
} |
public void setNameFrom(String nameFrom) { |
public void setNameFrom(String nameFrom) |
{ |
this.nameFrom = nameFrom; |
} |
@Column(name = "name_to", nullable = false) |
public String getNameTo() { |
public String getNameTo() |
{ |
return this.nameTo; |
} |
public void setNameTo(String nameTo) { |
public void setNameTo(String nameTo) |
{ |
this.nameTo = nameTo; |
} |
@OneToMany(fetch = FetchType.LAZY, mappedBy = "relationshipType") |
public Set<Relationship> getRelationships() { |
public Set<Relationship> getRelationships() |
{ |
return this.relationships; |
} |
public void setRelationships(Set<Relationship> relationships) { |
public void setRelationships(Set<Relationship> relationships) |
{ |
this.relationships = relationships; |
} |
/trunk/src/ch/ffhs/webE/domain/Term.java |
---|
45,6 → 45,12 |
0); |
/** |
* @var <code>true</code> if the term is edited/renamed, <code>false</code> |
* otherwise |
*/ |
public boolean edit = false; |
/** |
* No-op constructor |
*/ |
public Term() |
130,7 → 136,7 |
this.name = name; |
} |
@OneToMany(fetch = FetchType.LAZY, mappedBy = "termByTermTo") |
@OneToMany(fetch = FetchType.LAZY, mappedBy = "termTo") |
public Set<Relationship> getRelationshipsForTermTo() |
{ |
return this.relationshipsForTermTo; |
147,7 → 153,7 |
/** |
* @return |
*/ |
@OneToMany(fetch = FetchType.LAZY, mappedBy = "termByTermFrom") |
@OneToMany(fetch = FetchType.LAZY, mappedBy = "termFrom") |
public Set<Relationship> getRelationshipsForTermFrom() |
{ |
return this.relationshipsForTermFrom; |
/trunk/src/ch/ffhs/webE/domain/ObjectType.java |
---|
21,11 → 21,21 |
public class ObjectType implements java.io.Serializable |
{ |
/** |
* Version ID for serialization |
*/ |
private static final long serialVersionUID = 1L; |
/** |
* ObjectEntity type ID for a term |
*/ |
public static final int TERM = 1; |
private int objectTypeId; |
/** |
* ObjectEntity type ID for a relationship |
*/ |
public static final int RELATIONSHIP = 2; |
private int id; |
private String name; |
private Set<ObjectEntity> objects = new HashSet<ObjectEntity>(0); |
33,28 → 43,28 |
{ |
} |
public ObjectType(int objectTypeId) |
public ObjectType(int id) |
{ |
this.objectTypeId = objectTypeId; |
this.id = id; |
} |
public ObjectType(int objectTypeId, String name, Set<ObjectEntity> objects) |
public ObjectType(int id, String name, Set<ObjectEntity> objects) |
{ |
this.objectTypeId = objectTypeId; |
this.id = id; |
this.name = name; |
this.objects = objects; |
} |
@Id |
@Column(name = "object_type_id", unique = true, nullable = false) |
public int getObjectTypeId() |
@Column(name = "id", unique = true, nullable = false) |
public int getId() |
{ |
return this.objectTypeId; |
return this.id; |
} |
public void setObjectTypeId(int objectTypeId) |
public void setId(int objectTypeId) |
{ |
this.objectTypeId = objectTypeId; |
this.id = objectTypeId; |
} |
@Column(name = "name", unique = true, length = 45) |