com.greenpepper.server.domain.Reference Maven / Gradle / Ivy
package com.greenpepper.server.domain;
import static com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.REFERENCE_LAST_EXECUTION_IDX;
import static com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.REFERENCE_REQUIREMENT_IDX;
import static com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.REFERENCE_SECTIONS_IDX;
import static com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.REFERENCE_SPECIFICATION_IDX;
import static com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller.REFERENCE_SUT_IDX;
import com.greenpepper.server.rpc.xmlrpc.XmlRpcDataMarshaller;
import com.greenpepper.util.StringUtil;
import org.apache.commons.lang3.StringUtils;
import java.util.Vector;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
/**
* TestCase Class.
* Main association class between a requirement, a test docuement and a system under test.
*
* Copyright (c) 2006 Pyxis technologies inc. All Rights Reserved.
*
* @author JCHUET
* @version $Id: $Id
*/
@Entity
@Table(name="REFERENCE", uniqueConstraints = {@UniqueConstraint(columnNames={"REQUIREMENT_ID", "SPECIFICATION_ID", "SUT_ID", "SECTIONS"})})
@SuppressWarnings("serial")
public class Reference extends AbstractUniqueEntity implements Comparable
{
private String sections;
private Requirement requirement;
private Specification specification;
private SystemUnderTest systemUnderTest;
private Execution lastExecution;
/**
* newInstance.
*
* @param requirement a {@link com.greenpepper.server.domain.Requirement} object.
* @param specification a {@link com.greenpepper.server.domain.Specification} object.
* @param sut a {@link com.greenpepper.server.domain.SystemUnderTest} object.
* @return a {@link com.greenpepper.server.domain.Reference} object.
*/
public static Reference newInstance(Requirement requirement, Specification specification, SystemUnderTest sut)
{
return newInstance(requirement, specification, sut, null);
}
/**
* newInstance.
*
* @param requirement a {@link com.greenpepper.server.domain.Requirement} object.
* @param specification a {@link com.greenpepper.server.domain.Specification} object.
* @param sut a {@link com.greenpepper.server.domain.SystemUnderTest} object.
* @param sections a {@link java.lang.String} object.
* @return a {@link com.greenpepper.server.domain.Reference} object.
*/
public static Reference newInstance(Requirement requirement, Specification specification, SystemUnderTest sut, String sections)
{
Reference reference = new Reference();
reference.setSections(sections);
reference.setRequirement(requirement);
reference.setSpecification(specification);
reference.setSystemUnderTest(sut);
requirement.getReferences().add(reference);
specification.getReferences().add(reference);
return reference;
}
/**
* Getter for the field sections
.
*
* @return a {@link java.lang.String} object.
*/
@Basic
@Column(name = "SECTIONS", nullable = true, length=50)
public String getSections()
{
return sections;
}
/**
* Getter for the field requirement
.
*
* @return a {@link com.greenpepper.server.domain.Requirement} object.
*/
@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.ALL} )
@JoinColumn(name="REQUIREMENT_ID")
public Requirement getRequirement()
{
return requirement;
}
/**
* Getter for the field specification
.
*
* @return a {@link com.greenpepper.server.domain.Specification} object.
*/
@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
@JoinColumn(name="SPECIFICATION_ID")
public Specification getSpecification()
{
return specification;
}
/**
* Getter for the field systemUnderTest
.
*
* @return a {@link com.greenpepper.server.domain.SystemUnderTest} object.
*/
@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
@JoinColumn(name="SUT_ID")
public SystemUnderTest getSystemUnderTest()
{
return systemUnderTest;
}
/**
* Getter for the field lastExecution
.
*
* @return a {@link com.greenpepper.server.domain.Execution} object.
*/
@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
@JoinColumn(name="LAST_EXECUTION_ID")
public Execution getLastExecution()
{
return lastExecution;
}
/**
* Setter for the field sections
.
*
* @param sections a {@link java.lang.String} object.
*/
public void setSections(String sections)
{
this.sections = StringUtil.toNullIfEmpty(sections);
}
/**
* Setter for the field requirement
.
*
* @param requirement a {@link com.greenpepper.server.domain.Requirement} object.
*/
public void setRequirement(Requirement requirement)
{
this.requirement = requirement;
}
/**
* Setter for the field specification
.
*
* @param specification a {@link com.greenpepper.server.domain.Specification} object.
*/
public void setSpecification(Specification specification)
{
this.specification = specification;
}
/**
* Setter for the field systemUnderTest
.
*
* @param systemUnderTest a {@link com.greenpepper.server.domain.SystemUnderTest} object.
*/
public void setSystemUnderTest(SystemUnderTest systemUnderTest)
{
this.systemUnderTest = systemUnderTest;
}
/**
* Setter for the field lastExecution
.
*
* @param lastExecution a {@link com.greenpepper.server.domain.Execution} object.
*/
public void setLastExecution(Execution lastExecution)
{
this.lastExecution = lastExecution;
}
/**
* getStatus.
*
* @return a {@link java.lang.String} object.
*/
@Transient
public String getStatus()
{
return lastExecution != null ? lastExecution.getStatus() : Execution.IGNORED;
}
/**
* marshallize.
*
* @return a {@link java.util.Vector} object.
*/
public Vector
© 2015 - 2025 Weber Informatics LLC | Privacy Policy