001/*
002 *  Copyright 2022 Anyware Services
003 *
004 *  Licensed under the Apache License, Version 2.0 (the "License");
005 *  you may not use this file except in compliance with the License.
006 *  You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *  Unless required by applicable law or agreed to in writing, software
011 *  distributed under the License is distributed on an "AS IS" BASIS,
012 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *  See the License for the specific language governing permissions and
014 *  limitations under the License.
015 */
016package org.ametys.plugins.forms.data;
017
018import java.util.Date;
019import java.util.Optional;
020
021import org.ametys.core.user.UserIdentity;
022
023/**
024 * Object representing an answer with common attribute for each forms
025 */
026public class Answer
027{
028    private String _id;
029    private Long _number;
030    private String _formId;
031    private String _formLabel;
032    private String _workflowName;
033    private Date _creationDate;
034    private Integer _workflowId;
035    private Boolean _inQueue;
036    private UserIdentity _user;
037    
038    /**
039     * The constructor
040     * @param id the id of the answer
041     * @param number the number of the answer
042     * @param formId the form id
043     * @param formLabel the form label
044     * @param creationDate the creation date
045     * @param workflowName the workflow name
046     * @param workflowId the workflow id
047     * @param user the user
048     */
049    public Answer(String id, Long number, String formId, String formLabel, Date creationDate, String workflowName, Integer workflowId, UserIdentity user)
050    {
051        this(id, number, formId, formLabel, creationDate, workflowName, workflowId, null, user);
052    }
053    
054    /**
055     * The constructor
056     * @param id the id of the answer
057     * @param number the number of the answer
058     * @param formId the form id
059     * @param formLabel the form label
060     * @param creationDate the creation date
061     * @param workflowName the workflow name
062     * @param workflowId the workflow id
063     * @param inQueue is the answer is in queue
064     * @param user the user
065     */
066    public Answer(String id, Long number, String formId, String formLabel, Date creationDate, String workflowName, Integer workflowId, Boolean inQueue, UserIdentity user)
067    {
068        this._id = id;
069        this._number = number;
070        this._formId = formId;
071        this._formLabel = formLabel;
072        this._creationDate = creationDate;
073        this._workflowName = workflowName;
074        this._workflowId = workflowId;
075        this._inQueue = inQueue;
076        this._user = user;
077    }
078
079    /**
080     * Get the id of the answer
081     * @return the id
082     */
083    public String getId()
084    {
085        return this._id;
086    }
087    
088    /**
089     * Get the number of the answer
090     * @return the number
091     */
092    public Long getNumber()
093    {
094        return this._number;
095    }
096    
097    /**
098     * Get the form id
099     * @return the form id
100     */
101    public String getFormId()
102    {
103        return this._formId;
104    }
105    
106    /**
107     * Get the form label
108     * @return the form label
109     */
110    public String getFormLabel()
111    {
112        return this._formLabel;
113    }
114    
115    /**
116     * Get the creation date
117     * @return the creation date
118     */
119    public Date getCreationDate()
120    {
121        return this._creationDate;
122    }
123    
124    /**
125     * Get the workflow name
126     * @return the workflow workflow
127     */
128    public String getWorkflowName()
129    {
130        return this._workflowName;
131    }
132    
133    /**
134     * Get the workflow id. Can be null.
135     * @return the workflow id. Can be null.
136     */
137    public Integer getWorkflowId()
138    {
139        return this._workflowId;
140    }
141    
142    /**
143     * <code>true</code> is the answer is in queue
144     * @return <code>true</code> is the answer is in queue. Return empty is the answer belong to a form with no queue
145     */
146    public Optional<Boolean> isInQueue()
147    {
148        return Optional.ofNullable(this._inQueue);
149    }
150    
151    /**
152     * Get the user of the answer
153     * @return the user
154     */
155    public UserIdentity getUser()
156    {
157        return _user;
158    }
159}