Workflow.java
/*
* Copyright 2024 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gringlobal.model.workflow;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.genesys.blocks.model.Copyable;
import org.gringlobal.compatibility.SysTableInfo;
import org.gringlobal.model.CooperatorOwnedModel;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.validation.constraints.Pattern;
import java.util.List;
@Entity
@Table(name = "workflow")
@Getter
@Setter
@NoArgsConstructor
@SysTableInfo(ignore = true, area = "")
public class Workflow extends CooperatorOwnedModel implements Copyable<Workflow> {
private static final long serialVersionUID = -4620184523834940666L;
@Id
@JsonProperty
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "workflow_id", columnDefinition = "int")
private Long id;
/** Is this workflow active? */
@Column(name = "is_active", nullable = false)
@Pattern(regexp = "^Y|N$")
private String isActive = "Y";
/** Unique workflow code/key */
@Column(length = 100, unique = true, nullable = false, updatable = false)
private String code;
/** Contains the class name of target actions. For example "org.gringlobal.model.InventoryAction" **/
@Column(name = "action_type", length = 100, nullable = false, updatable = false)
private String actionType;
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL }, orphanRemoval = true, mappedBy = "workflow")
@OrderBy("workflow_transition_id")
private List<WorkflowTransition> transitions;
@OneToMany(cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY, orphanRemoval = true, mappedBy = "workflow")
private List<WorkflowStep> steps;
public Workflow(Long id) {
this.id = id;
}
@Override
public boolean canEqual(Object other) {
return other instanceof Workflow;
}
@Override
public Long getId() {
return id;
}
}