this.data = data;
}
/**
* Добавляет элемент истории к документу
*
* @param idUser Пользователь
* @param idAction Действие
*/
public void HistoryAdd(User idUser, UserAction idAction) {
DocumentHistory history = new DocumentHistory();
history.setIdDocument(this);
history.setIdUser(idUser);
history.setIdUserAction(idAction);
history.setRegistrationDate(new Date());
if (getDocumentHistoryCollection() == null) {
setDocumentHistoryCollection(new ArrayList<DocumentHistory>());
}
getDocumentHistoryCollection().add(history);
}
}
/**
* Класс (модель) для таблицы "История документа"
*/
@Entity
@Table(name = "document_history")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "DocumentHistory.findAll", query = "SELECT d FROM
DocumentHistory d")
, @NamedQuery(name = "DocumentHistory.findById", query = "SELECT d
FROM DocumentHistory d WHERE d.id = :id")
, @NamedQuery(name = "DocumentHistory.findByIdDocumnet", query =
"SELECT d FROM DocumentHistory d WHERE d.idDocument.id = :idDocument")
, @NamedQuery(name = "DocumentHistory.findByRegistrationDate", query =
"SELECT d FROM DocumentHistory d WHERE d.registrationDate =
:registrationDate")})
public class DocumentHistory implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Integer id;
@Column(name = "registration_date")
@Temporal(TemporalType.TIMESTAMP)
private Date registrationDate;