DMPRoadmap: Map all entities related to template
parent
eee9faee28
commit
fc7b3b01a4
@ -0,0 +1,30 @@
|
||||
package eu.eudat.migration.controllers;
|
||||
|
||||
import eu.eudat.migration.dao.TemplateRepository;
|
||||
import eu.eudat.migration.entities.Template;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/template")
|
||||
@ConditionalOnProperty(prefix = "roadmap", name="database.url")
|
||||
public class TemplateController {
|
||||
|
||||
private final TemplateRepository templateRepository;
|
||||
|
||||
@Autowired
|
||||
public TemplateController(TemplateRepository templateRepository) {
|
||||
this.templateRepository = templateRepository;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/all", produces = "application/json")
|
||||
public ResponseEntity<List<Template>> getAllTemplates() {
|
||||
return ResponseEntity.ok(this.templateRepository.findAll());
|
||||
}
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
package eu.eudat.migration.dao;
|
||||
|
||||
import eu.eudat.migration.entities.Template;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
@ConditionalOnProperty(prefix = "roadmap", name="database.url")
|
||||
public interface TemplateRepository extends JpaRepository<Template, Long> {
|
||||
}
|
||||
|
@ -0,0 +1,119 @@
|
||||
package eu.eudat.migration.entities;
|
||||
|
||||
import eu.eudat.migration.utils.ArrayTypeConverter;
|
||||
import eu.eudat.migration.utils.JsonTypeConverter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@Entity
|
||||
@Table(name = "conditions")
|
||||
@SuppressWarnings("JpaAttributeTypeInspection")
|
||||
public class Condition {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
@Column(name = "option_list")
|
||||
@Convert(converter = ArrayTypeConverter.class)
|
||||
private String[] optionList;
|
||||
@Column(name = "action_type")
|
||||
private ActionType actionType;
|
||||
private Long number;
|
||||
@Column(name = "remove_data")
|
||||
@Convert(converter = ArrayTypeConverter.class)
|
||||
private String[] removeData;
|
||||
@Column(name = "webhook_data")
|
||||
@Convert(converter = JsonTypeConverter.class)
|
||||
private Map<String, Object> webhookData;
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
|
||||
public enum ActionType {
|
||||
REMOVE,
|
||||
ADD_WEBHOOK
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Condition{" +
|
||||
"id=" + id +
|
||||
", optionList=" + Arrays.toString(optionList) +
|
||||
", actionType=" + actionType +
|
||||
", number=" + number +
|
||||
", removeData=" + Arrays.toString(removeData) +
|
||||
", webhookData=" + webhookData +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String[] getOptionList() {
|
||||
return optionList;
|
||||
}
|
||||
|
||||
public void setOptionList(String[] optionList) {
|
||||
this.optionList = optionList;
|
||||
}
|
||||
|
||||
public ActionType getActionType() {
|
||||
return actionType;
|
||||
}
|
||||
|
||||
public void setActionType(ActionType actionType) {
|
||||
this.actionType = actionType;
|
||||
}
|
||||
|
||||
public Long getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(Long number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public String[] getRemoveData() {
|
||||
return removeData;
|
||||
}
|
||||
|
||||
public void setRemoveData(String[] removeData) {
|
||||
this.removeData = removeData;
|
||||
}
|
||||
|
||||
public Map<String, Object> getWebhookData() {
|
||||
return webhookData;
|
||||
}
|
||||
|
||||
public void setWebhookData(Map<String, Object> webhookData) {
|
||||
this.webhookData = webhookData;
|
||||
}
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package eu.eudat.migration.entities;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@Entity
|
||||
@Table(name = "languages")
|
||||
public class Language {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String abbreviation;
|
||||
private String description;
|
||||
private String name;
|
||||
@Column(name = "default_language")
|
||||
private Boolean defaultLanguage;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Language{" +
|
||||
"id=" + id +
|
||||
", abbreviation='" + abbreviation + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", defaultLanguage=" + defaultLanguage +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getDefaultLanguage() {
|
||||
return defaultLanguage;
|
||||
}
|
||||
|
||||
public void setDefaultLanguage(Boolean defaultLanguage) {
|
||||
this.defaultLanguage = defaultLanguage;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,255 @@
|
||||
package eu.eudat.migration.entities;
|
||||
|
||||
|
||||
import eu.eudat.migration.utils.OrganizationTypeConverter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "orgs")
|
||||
public class Organization {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String name;
|
||||
private String abbreviation;
|
||||
@Column(name = "target_url")
|
||||
private String targetUrl;
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
@Column(name = "is_other")
|
||||
private Boolean isOther;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "region_id")
|
||||
private Region region;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "language_id")
|
||||
private Language language;
|
||||
@Column(name = "logo_uid")
|
||||
private String logoUid;
|
||||
@Column(name = "logo_name")
|
||||
private String logoName;
|
||||
@Column(name = "contact_email")
|
||||
private String contactEmail;
|
||||
@Column(name = "org_type")
|
||||
@Convert(converter = OrganizationTypeConverter.class)
|
||||
private Type orgType;
|
||||
private String links;
|
||||
@Column(name = "feedback_enabled")
|
||||
private Boolean feedbackEnabled;
|
||||
@Column(name = "feedback_msg")
|
||||
private String feedbackMsg;
|
||||
@Column(name = "contact_name")
|
||||
private String contactName;
|
||||
@Column(name = "helpdesk_email")
|
||||
private String helpdeskEmail;
|
||||
private Boolean managed;
|
||||
|
||||
public enum Type {
|
||||
INSTITUTION,
|
||||
FUNDER,
|
||||
ORGANIZATION,
|
||||
RESEARCH_INSTITUTE,
|
||||
PROJECT,
|
||||
SCHOOL
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Organization{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", abbreviation='" + abbreviation + '\'' +
|
||||
", targetUrl='" + targetUrl + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", isOther=" + isOther +
|
||||
", region=" + region +
|
||||
", language=" + language +
|
||||
", logoUid='" + logoUid + '\'' +
|
||||
", logoName='" + logoName + '\'' +
|
||||
", contactEmail='" + contactEmail + '\'' +
|
||||
", orgType=" + orgType +
|
||||
", links='" + links + '\'' +
|
||||
", feedbackEnabled=" + feedbackEnabled +
|
||||
", feedbackMsg='" + feedbackMsg + '\'' +
|
||||
", contactName='" + contactName + '\'' +
|
||||
", helpdeskEmail='" + helpdeskEmail + '\'' +
|
||||
", managed=" + managed +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
|
||||
public String getTargetUrl() {
|
||||
return targetUrl;
|
||||
}
|
||||
|
||||
public void setTargetUrl(String targetUrl) {
|
||||
this.targetUrl = targetUrl;
|
||||
}
|
||||
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Boolean getIsOther() {
|
||||
return isOther;
|
||||
}
|
||||
|
||||
public void setIsOther(Boolean isOther) {
|
||||
this.isOther = isOther;
|
||||
}
|
||||
|
||||
|
||||
public Region getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(Region regionId) {
|
||||
this.region = regionId;
|
||||
}
|
||||
|
||||
|
||||
public Language getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(Language languageId) {
|
||||
this.language = languageId;
|
||||
}
|
||||
|
||||
|
||||
public String getLogoUid() {
|
||||
return logoUid;
|
||||
}
|
||||
|
||||
public void setLogoUid(String logoUid) {
|
||||
this.logoUid = logoUid;
|
||||
}
|
||||
|
||||
|
||||
public String getLogoName() {
|
||||
return logoName;
|
||||
}
|
||||
|
||||
public void setLogoName(String logoName) {
|
||||
this.logoName = logoName;
|
||||
}
|
||||
|
||||
|
||||
public String getContactEmail() {
|
||||
return contactEmail;
|
||||
}
|
||||
|
||||
public void setContactEmail(String contactEmail) {
|
||||
this.contactEmail = contactEmail;
|
||||
}
|
||||
|
||||
|
||||
public Type getOrgType() {
|
||||
return orgType;
|
||||
}
|
||||
|
||||
public void setOrgType(Type orgType) {
|
||||
this.orgType = orgType;
|
||||
}
|
||||
|
||||
|
||||
public String getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public void setLinks(String links) {
|
||||
this.links = links;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getFeedbackEnabled() {
|
||||
return feedbackEnabled;
|
||||
}
|
||||
|
||||
public void setFeedbackEnabled(Boolean feedbackEnabled) {
|
||||
this.feedbackEnabled = feedbackEnabled;
|
||||
}
|
||||
|
||||
|
||||
public String getFeedbackMsg() {
|
||||
return feedbackMsg;
|
||||
}
|
||||
|
||||
public void setFeedbackMsg(String feedbackMsg) {
|
||||
this.feedbackMsg = feedbackMsg;
|
||||
}
|
||||
|
||||
|
||||
public String getContactName() {
|
||||
return contactName;
|
||||
}
|
||||
|
||||
public void setContactName(String contactName) {
|
||||
this.contactName = contactName;
|
||||
}
|
||||
|
||||
|
||||
public String getHelpdeskEmail() {
|
||||
return helpdeskEmail;
|
||||
}
|
||||
|
||||
public void setHelpdeskEmail(String helpdeskEmail) {
|
||||
this.helpdeskEmail = helpdeskEmail;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getManaged() {
|
||||
return managed;
|
||||
}
|
||||
|
||||
public void setManaged(Boolean managed) {
|
||||
this.managed = managed;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,128 @@
|
||||
package eu.eudat.migration.entities;
|
||||
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "phases")
|
||||
public class Phase {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String title;
|
||||
private String description;
|
||||
private Long number;
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
private Boolean modifiable;
|
||||
@Column(name = "versionable_id")
|
||||
private String versionableId;
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "phase_id")
|
||||
@OrderBy("number")
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private List<Section> sections = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Phase{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", number=" + number +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", modifiable=" + modifiable +
|
||||
", versionableId='" + versionableId + '\'' +
|
||||
", sections=" + sections +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public Long getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(Long number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getModifiable() {
|
||||
return modifiable;
|
||||
}
|
||||
|
||||
public void setModifiable(Boolean modifiable) {
|
||||
this.modifiable = modifiable;
|
||||
}
|
||||
|
||||
|
||||
public String getVersionableId() {
|
||||
return versionableId;
|
||||
}
|
||||
|
||||
public void setVersionableId(String versionableId) {
|
||||
this.versionableId = versionableId;
|
||||
}
|
||||
|
||||
public List<Section> getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
public void setSections(List<Section> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
package eu.eudat.migration.entities;
|
||||
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "questions")
|
||||
public class Question {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String text;
|
||||
@Column(name = "default_value")
|
||||
private String defaultValue;
|
||||
private Long number;
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "question_format_id")
|
||||
private QuestionFormat questionFormat;
|
||||
@Column(name = "option_comment_display")
|
||||
private Boolean optionCommentDisplay;
|
||||
private Boolean modifiable;
|
||||
@Column(name = "versionable_id")
|
||||
private String versionableId;
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "question_id")
|
||||
@OrderBy("number")
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private List<QuestionOption> options = new ArrayList<>();
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "question_id")
|
||||
@OrderBy("number")
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private List<Condition> conditions = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Question{" +
|
||||
"id=" + id +
|
||||
", text='" + text + '\'' +
|
||||
", defaultValue='" + defaultValue + '\'' +
|
||||
", number=" + number +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", questionFormat=" + questionFormat +
|
||||
", optionCommentDisplay=" + optionCommentDisplay +
|
||||
", modifiable=" + modifiable +
|
||||
", versionableId='" + versionableId + '\'' +
|
||||
", options=" + options +
|
||||
", conditions=" + conditions +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public Long getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(Long number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public QuestionFormat getQuestionFormat() {
|
||||
return questionFormat;
|
||||
}
|
||||
|
||||
public void setQuestionFormat(QuestionFormat questionFormat) {
|
||||
this.questionFormat = questionFormat;
|
||||
}
|
||||
|
||||
public Boolean getOptionCommentDisplay() {
|
||||
return optionCommentDisplay;
|
||||
}
|
||||
|
||||
public void setOptionCommentDisplay(Boolean optionCommentDisplay) {
|
||||
this.optionCommentDisplay = optionCommentDisplay;
|
||||
}
|
||||
|
||||
public Boolean getModifiable() {
|
||||
return modifiable;
|
||||
}
|
||||
|
||||
public void setModifiable(Boolean modifiable) {
|
||||
this.modifiable = modifiable;
|
||||
}
|
||||
|
||||
public String getVersionableId() {
|
||||
return versionableId;
|
||||
}
|
||||
|
||||
public void setVersionableId(String versionableId) {
|
||||
this.versionableId = versionableId;
|
||||
}
|
||||
|
||||
public List<QuestionOption> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public void setOptions(List<QuestionOption> options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
|
||||
public List<Condition> getConditions() {
|
||||
return conditions;
|
||||
}
|
||||
|
||||
public void setConditions(List<Condition> conditions) {
|
||||
this.conditions = conditions;
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package eu.eudat.migration.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "question_formats")
|
||||
public class QuestionFormat {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String title;
|
||||
private String description;
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
@Column(name = "option_based")
|
||||
private Boolean optionBased;
|
||||
private FormatType formattype;
|
||||
|
||||
public enum FormatType {
|
||||
TEXTAREA,
|
||||
TEXT_FIELD,
|
||||
RADIOBUTTON,
|
||||
CHECKBOX,
|
||||
DROPDOWN,
|
||||
MULTI_SELECT,
|
||||
DATE,
|
||||
RDA_METADATA
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "QuestionFormat{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", optionBased=" + optionBased +
|
||||
", formattype=" + formattype +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Boolean getOptionBased() {
|
||||
return optionBased;
|
||||
}
|
||||
|
||||
public void setOptionBased(Boolean optionBased) {
|
||||
this.optionBased = optionBased;
|
||||
}
|
||||
|
||||
public FormatType getFormattype() {
|
||||
return formattype;
|
||||
}
|
||||
|
||||
public void setFormattype(FormatType formattype) {
|
||||
this.formattype = formattype;
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package eu.eudat.migration.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "question_options")
|
||||
public class QuestionOption {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String text;
|
||||
private Long number;
|
||||
@Column(name = "is_default")
|
||||
private Boolean isDefault;
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
@Column(name = "versionable_id")
|
||||
private String versionableId;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "QuestionOption{" +
|
||||
"id=" + id +
|
||||
", text='" + text + '\'' +
|
||||
", number=" + number +
|
||||
", isDefault=" + isDefault +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", versionableId='" + versionableId + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Long getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(Long number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public Boolean getDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setDefault(Boolean aDefault) {
|
||||
isDefault = aDefault;
|
||||
}
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public String getVersionableId() {
|
||||
return versionableId;
|
||||
}
|
||||
|
||||
public void setVersionableId(String versionableId) {
|
||||
this.versionableId = versionableId;
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package eu.eudat.migration.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "regions")
|
||||
public class Region {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String abbreviation;
|
||||
private String description;
|
||||
private String name;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "super_region_id")
|
||||
private Region superRegion;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Region{" +
|
||||
"id=" + id +
|
||||
", abbreviation='" + abbreviation + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", name='" + name + '\'' +
|
||||
", superRegion=" + superRegion +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public Region getSuperRegion() {
|
||||
return superRegion;
|
||||
}
|
||||
|
||||
public void setSuperRegion(Region superRegion) {
|
||||
this.superRegion = superRegion;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
package eu.eudat.migration.entities;
|
||||
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "sections")
|
||||
public class Section {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String title;
|
||||
private String description;
|
||||
private Long number;
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
private Boolean modifiable;
|
||||
@Column(name = "versionable_id")
|
||||
private String versionableId;
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "section_id")
|
||||
@OrderBy("number")
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private List<Question> questions = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Section{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", number=" + number +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", modifiable=" + modifiable +
|
||||
", versionableId='" + versionableId + '\'' +
|
||||
", questions=" + questions +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public Long getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(Long number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Boolean getModifiable() {
|
||||
return modifiable;
|
||||
}
|
||||
|
||||
public void setModifiable(Boolean modifiable) {
|
||||
this.modifiable = modifiable;
|
||||
}
|
||||
|
||||
public String getVersionableId() {
|
||||
return versionableId;
|
||||
}
|
||||
|
||||
public void setVersionableId(String versionableId) {
|
||||
this.versionableId = versionableId;
|
||||
}
|
||||
|
||||
|
||||
public List<Question> getQuestions() {
|
||||
return questions;
|
||||
}
|
||||
|
||||
public void setQuestions(List<Question> questions) {
|
||||
this.questions = questions;
|
||||
}
|
||||
}
|
@ -1,190 +1,208 @@
|
||||
package eu.eudat.migration.entities;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "templates")
|
||||
public class Template {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String title;
|
||||
private String description;
|
||||
private String published;
|
||||
@Column(name = "org_id")
|
||||
private Long orgId;
|
||||
private String locale;
|
||||
@Column(name = "is_default")
|
||||
private String isDefault;
|
||||
@Column(name = "created_at")
|
||||
private java.sql.Timestamp createdAt;
|
||||
@Column(name = "updated_at")
|
||||
private java.sql.Timestamp updatedAt;
|
||||
private Long version;
|
||||
private Long visibility;
|
||||
@Column(name = "customization_of")
|
||||
private Long customizationOf;
|
||||
@Column(name = "family_id")
|
||||
private Long familyId;
|
||||
private String archived;
|
||||
private String links;
|
||||
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public String getPublished() {
|
||||
return published;
|
||||
}
|
||||
|
||||
public void setPublished(String published) {
|
||||
this.published = published;
|
||||
}
|
||||
|
||||
|
||||
public Long getOrgId() {
|
||||
return orgId;
|
||||
}
|
||||
|
||||
public void setOrgId(Long orgId) {
|
||||
this.orgId = orgId;
|
||||
}
|
||||
|
||||
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
@Id
|
||||
private Long id;
|
||||
private String title;
|
||||
private String description;
|
||||
private Boolean published;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "org_id")
|
||||
private Organization organization;
|
||||
private String locale;
|
||||
@Column(name = "is_default")
|
||||
private Boolean isDefault;
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
private Long version;
|
||||
private Visibility visibility;
|
||||
@Column(name = "customization_of")
|
||||
private Long customizationOf;
|
||||
@Column(name = "family_id")
|
||||
private Long familyId;
|
||||
private Boolean archived;
|
||||
private String links;
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "template_id")
|
||||
@OrderBy("number")
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private List<Phase> phases = new ArrayList<>();
|
||||
|
||||
public enum Visibility {
|
||||
ORGANIZATION,
|
||||
PUBLIC
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getIsDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setIsDefault(String isDefault) {
|
||||
this.isDefault = isDefault;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
|
||||
public java.sql.Timestamp getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setCreatedAt(java.sql.Timestamp createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public java.sql.Timestamp getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
public Boolean getPublished() {
|
||||
return published;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(java.sql.Timestamp updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
public void setPublished(Boolean published) {
|
||||
this.published = published;
|
||||
}
|
||||
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
public Organization getOrganization() {
|
||||
return organization;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
public void setOrganization(Organization organization) {
|
||||
this.organization = organization;
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public Date getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Date getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Date updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
||||
public Visibility getVisibility() {
|
||||
return visibility;
|
||||
}
|
||||
|
||||
public void setVisibility(Visibility visibility) {
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
|
||||
public Long getVisibility() {
|
||||
return visibility;
|
||||
}
|
||||
public Long getCustomizationOf() {
|
||||
return customizationOf;
|
||||
}
|
||||
|
||||
public void setVisibility(Long visibility) {
|
||||
this.visibility = visibility;
|
||||
}
|
||||
public void setCustomizationOf(Long customizationOf) {
|
||||
this.customizationOf = customizationOf;
|
||||
}
|
||||
|
||||
|
||||
public Long getCustomizationOf() {
|
||||
return customizationOf;
|
||||
}
|
||||
public Long getFamilyId() {
|
||||
return familyId;
|
||||
}
|
||||
|
||||
public void setCustomizationOf(Long customizationOf) {
|
||||
this.customizationOf = customizationOf;
|
||||
}
|
||||
public void setFamilyId(Long familyId) {
|
||||
this.familyId = familyId;
|
||||
}
|
||||
|
||||
|
||||
public Long getFamilyId() {
|
||||
return familyId;
|
||||
}
|
||||
public Boolean getArchived() {
|
||||
return archived;
|
||||
}
|
||||
|
||||
public void setFamilyId(Long familyId) {
|
||||
this.familyId = familyId;
|
||||
}
|
||||
public void setArchived(Boolean archived) {
|
||||
this.archived = archived;
|
||||
}
|
||||
|
||||
|
||||
public String getArchived() {
|
||||
return archived;
|
||||
}
|
||||
public String getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public void setArchived(String archived) {
|
||||
this.archived = archived;
|
||||
}
|
||||
public void setLinks(String links) {
|
||||
this.links = links;
|
||||
}
|
||||
|
||||
public Boolean getDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public String getLinks() {
|
||||
return links;
|
||||
}
|
||||
public void setDefault(Boolean aDefault) {
|
||||
isDefault = aDefault;
|
||||
}
|
||||
|
||||
public void setLinks(String links) {
|
||||
this.links = links;
|
||||
}
|
||||
public List<Phase> getPhases() {
|
||||
return phases;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Template{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", published='" + published + '\'' +
|
||||
", orgId=" + orgId +
|
||||
", locale='" + locale + '\'' +
|
||||
", isDefault='" + isDefault + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", version=" + version +
|
||||
", visibility=" + visibility +
|
||||
", customizationOf=" + customizationOf +
|
||||
", familyId=" + familyId +
|
||||
", archived='" + archived + '\'' +
|
||||
", links='" + links + '\'' +
|
||||
'}';
|
||||
}
|
||||
public void setPhases(List<Phase> phases) {
|
||||
this.phases = phases;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Template{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", published='" + published + '\'' +
|
||||
", organization=" + organization +
|
||||
", locale='" + locale + '\'' +
|
||||
", isDefault='" + isDefault + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", version=" + version +
|
||||
", visibility=" + visibility +
|
||||
", customizationOf=" + customizationOf +
|
||||
", familyId=" + familyId +
|
||||
", archived='" + archived + '\'' +
|
||||
", links='" + links + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package eu.eudat.migration.utils;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
@Converter
|
||||
public class ArrayTypeConverter implements AttributeConverter<String[], String> {
|
||||
|
||||
@Override
|
||||
public String convertToDatabaseColumn(String[] strings) {
|
||||
return strings != null?String.join(",", strings):null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] convertToEntityAttribute(String string) {
|
||||
return string != null?string.split(","):null;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package eu.eudat.migration.utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import java.util.Map;
|
||||
|
||||
public class JsonTypeConverter implements AttributeConverter<Map<String, Object>, String> {
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Override
|
||||
public String convertToDatabaseColumn(Map<String, Object> customerInfo) {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(customerInfo);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> convertToEntityAttribute(String customerInfoJSON) {
|
||||
try {
|
||||
return objectMapper.readValue(customerInfoJSON, Map.class);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package eu.eudat.migration.utils;
|
||||
|
||||
import eu.eudat.migration.entities.Organization;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
|
||||
@Converter
|
||||
public class OrganizationTypeConverter implements AttributeConverter<Organization.Type, Integer> {
|
||||
|
||||
@Override
|
||||
public Integer convertToDatabaseColumn(Organization.Type type) {
|
||||
if (type == null)
|
||||
return null;
|
||||
switch (type) {
|
||||
case INSTITUTION:
|
||||
return 1;
|
||||
case FUNDER:
|
||||
return 2;
|
||||
case ORGANIZATION:
|
||||
return 3;
|
||||
case RESEARCH_INSTITUTE:
|
||||
return 4;
|
||||
case PROJECT:
|
||||
return 5;
|
||||
case SCHOOL:
|
||||
return 6;
|
||||
default:
|
||||
throw new IllegalArgumentException(type + " not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Organization.Type convertToEntityAttribute(Integer type) {
|
||||
if (type == null)
|
||||
return null;
|
||||
switch (type) {
|
||||
case 1:
|
||||
return Organization.Type.INSTITUTION;
|
||||
case 2:
|
||||
return Organization.Type.FUNDER;
|
||||
case 3:
|
||||
return Organization.Type.ORGANIZATION;
|
||||
case 4:
|
||||
return Organization.Type.RESEARCH_INSTITUTE;
|
||||
case 5:
|
||||
return Organization.Type.PROJECT;
|
||||
case 6:
|
||||
return Organization.Type.SCHOOL;
|
||||
default:
|
||||
throw new IllegalArgumentException(type + " not supported.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue