001/*
002 * Stallion Core: A Modern Web Framework
003 *
004 * Copyright (C) 2015 - 2016 Stallion Software LLC.
005 *
006 * This program is free software: you can redistribute it and/or modify it under the terms of the
007 * GNU General Public License as published by the Free Software Foundation, either version 2 of
008 * the License, or (at your option) any later version. This program is distributed in the hope that
009 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
011 * License for more details. You should have received a copy of the GNU General Public License
012 * along with this program.  If not, see <http://www.gnu.org/licenses/gpl-2.0.html>.
013 *
014 *
015 *
016 */
017
018package io.stallion.forms;
019
020import io.stallion.dataAccess.AlternativeKey;
021import io.stallion.dataAccess.ModelBase;
022import io.stallion.dataAccess.file.ModelWithFilePath;
023import io.stallion.utils.DateUtils;
024import io.stallion.utils.GeneralUtils;
025
026import java.util.HashMap;
027import java.util.Map;
028
029public class SimpleFormSubmission extends ModelBase implements ModelWithFilePath {
030
031    private String email = "";
032    private Long submittedAt = 0L;
033    private Map<String, Object> data = new HashMap<String, Object>();
034    private String formName = "";
035    private String pageUrl = "";
036    private String pageTitle = "";
037    private String formId = "";
038    private String filePath = "";
039    private String antiSpamToken = "";
040
041
042    @AlternativeKey
043    public String getEmail() {
044        return email;
045    }
046
047    public SimpleFormSubmission setEmail(String email) {
048        this.email = email;
049        return this;
050    }
051
052    public Long getSubmittedAt() {
053        return submittedAt;
054    }
055
056    public SimpleFormSubmission setSubmittedAt(Long submittedAt) {
057        this.submittedAt = submittedAt;
058        return this;
059    }
060
061    public Map<String, Object> getData() {
062        return data;
063    }
064
065    public SimpleFormSubmission setData(Map<String, Object> data) {
066        this.data = data;
067        return this;
068    }
069
070    public String getFormName() {
071        return formName;
072    }
073
074    public SimpleFormSubmission setFormName(String formName) {
075        this.formName = formName;
076        return this;
077    }
078
079    public String getPageUrl() {
080        return pageUrl;
081    }
082
083
084    public SimpleFormSubmission setPageUrl(String pageUrl) {
085        this.pageUrl = pageUrl;
086        return this;
087    }
088
089    public String getPageTitle() {
090        return pageTitle;
091    }
092
093    public SimpleFormSubmission setPageTitle(String pageTitle) {
094        this.pageTitle = pageTitle;
095        return this;
096    }
097
098    public String getFormId() {
099        return formId;
100    }
101
102    public SimpleFormSubmission setFormId(String formId) {
103        this.formId = formId;
104        return this;
105    }
106
107
108    public String generateFilePath() {
109        return DateUtils.formatLocalDate(getSubmittedAt(), "YYYY-mm-dd-HHmmss-") + GeneralUtils.slugify(getEmail()) + "---" + getId() + ".json";
110    }
111
112    public String getFilePath() {
113        return filePath;
114    }
115
116    public void setFilePath(String filePath) {
117        this.filePath = filePath;
118    }
119
120    public String getAntiSpamToken() {
121        return antiSpamToken;
122    }
123
124    public SimpleFormSubmission setAntiSpamToken(String antiSpamToken) {
125        this.antiSpamToken = antiSpamToken;
126        return this;
127    }
128
129}