Create templates and DMP mapping
This commit is contained in:
parent
fc7b3b01a4
commit
9cb9cdb030
|
@ -1,25 +1,243 @@
|
|||
package eu.eudat.migration;
|
||||
|
||||
import eu.eudat.logic.managers.AdminManager;
|
||||
import eu.eudat.logic.managers.MetricsManager;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.migration.dao.TemplateRepository;
|
||||
import eu.eudat.migration.entities.Question;
|
||||
import eu.eudat.migration.entities.QuestionFormat;
|
||||
import eu.eudat.migration.entities.Template;
|
||||
import eu.eudat.migration.entities.Theme;
|
||||
import eu.eudat.models.data.admin.components.datasetprofile.Field;
|
||||
import eu.eudat.models.data.admin.components.datasetprofile.FieldSet;
|
||||
import eu.eudat.models.data.admin.components.datasetprofile.Page;
|
||||
import eu.eudat.models.data.admin.components.datasetprofile.Section;
|
||||
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||
import eu.eudat.models.data.components.commons.DefaultValue;
|
||||
import eu.eudat.models.data.components.commons.Multiplicity;
|
||||
import eu.eudat.models.data.components.commons.ViewStyle;
|
||||
import eu.eudat.models.data.components.commons.Visibility;
|
||||
import eu.eudat.types.MetricNames;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@ConditionalOnProperty(prefix = "roadmap", name="database.url")
|
||||
@ConditionalOnProperty(prefix = "roadmap", name = "database.url")
|
||||
public class DMPRoadmapMigration implements CommandLineRunner {
|
||||
|
||||
private final TemplateRepository templateRepository;
|
||||
private final ApiContext apiContext;
|
||||
private final MetricsManager metricsManager;
|
||||
/** Profiles */
|
||||
private final List<DatasetProfile> datasetProfiles = new ArrayList<>();
|
||||
private final List<eu.eudat.data.entities.DatasetProfile> profiles = new ArrayList<>();
|
||||
/** Metadata */
|
||||
private final Map<Long, UUID> groups = new HashMap<>();
|
||||
|
||||
@Autowired
|
||||
public DMPRoadmapMigration(TemplateRepository templateRepository) {
|
||||
public DMPRoadmapMigration(TemplateRepository templateRepository, ApiContext apiContext, MetricsManager metricsManager) {
|
||||
this.templateRepository = templateRepository;
|
||||
this.apiContext = apiContext;
|
||||
this.metricsManager = metricsManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
public void run(String... args) {
|
||||
List<Template> templates = templateRepository.findAll();
|
||||
templates.forEach(template -> {
|
||||
DatasetProfile datasetProfile = buildDatasetProfile(template);
|
||||
this.datasetProfiles.add(datasetProfile);
|
||||
this.createProfile(datasetProfile, template);
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional
|
||||
void createProfile(DatasetProfile profile, Template template) {
|
||||
DatasetProfile shortenProfile = profile.toShort();
|
||||
eu.eudat.data.entities.DatasetProfile datasetProfile = AdminManager.generateViewStyleDefinition(shortenProfile, this.apiContext);
|
||||
if(groups.get(template.getFamilyId()) == null) {
|
||||
groups.put(template.getFamilyId(), UUID.randomUUID());
|
||||
}
|
||||
datasetProfile.setGroupId(groups.get(template.getFamilyId()));
|
||||
datasetProfile.setVersion(template.getVersion());
|
||||
datasetProfile = this.apiContext.getOperationsContext().getDatabaseRepository().
|
||||
getDatasetProfileDao().createOrUpdate(datasetProfile);
|
||||
this.profiles.add(datasetProfile);
|
||||
metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricsManager.datasetTemplateStatus.get(datasetProfile.getStatus()));
|
||||
}
|
||||
|
||||
private DatasetProfile buildDatasetProfile(Template template) {
|
||||
DatasetProfile datasetProfile = new DatasetProfile();
|
||||
datasetProfile.setLabel(template.getTitle());
|
||||
datasetProfile.setDescription(template.getDescription());
|
||||
datasetProfile.setLanguage(template.getLocale());
|
||||
datasetProfile.setStatus((short) 1);
|
||||
datasetProfile.setVersion((short) 0);
|
||||
datasetProfile.setUsers(new ArrayList<>());
|
||||
this.buildPages(template, datasetProfile);
|
||||
return datasetProfile;
|
||||
}
|
||||
|
||||
private DatasetProfile buildPages(Template template, DatasetProfile datasetProfile) {
|
||||
List<Page> pages = new ArrayList<>();
|
||||
List<Section> sections = new ArrayList<>();
|
||||
template.getPhases().forEach(phase -> {
|
||||
Page page = new Page();
|
||||
page.setId(String.valueOf(UUID.randomUUID()));
|
||||
page.setOrdinal(Math.toIntExact(phase.getNumber()) - 1);
|
||||
page.setTitle(phase.getTitle());
|
||||
pages.add(page);
|
||||
sections.addAll(buildSections(phase.getSections(), page.getId()));
|
||||
});
|
||||
datasetProfile.setPages(pages);
|
||||
datasetProfile.setSections(sections);
|
||||
return datasetProfile;
|
||||
}
|
||||
|
||||
private List<Section> buildSections(List<eu.eudat.migration.entities.Section> sections, String pageId) {
|
||||
return sections.stream().map(s -> {
|
||||
Section section = new Section();
|
||||
section.setId(String.valueOf(UUID.randomUUID()));
|
||||
section.setPage(pageId);
|
||||
section.setTitle(s.getTitle());
|
||||
section.setDescription(s.getDescription());
|
||||
section.setOrdinal(Math.toIntExact(s.getNumber()) - 1);
|
||||
section.setDefaultVisibility(true);
|
||||
section.setMultiplicity(false);
|
||||
section.setSections(new ArrayList<>());
|
||||
section.setFieldSets(buildFieldSets(s.getQuestions()));
|
||||
return section;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<FieldSet> buildFieldSets(List<Question> questions) {
|
||||
return questions.stream().map(question -> {
|
||||
FieldSet fieldSet = new FieldSet();
|
||||
fieldSet.setId(String.valueOf(UUID.randomUUID()));
|
||||
fieldSet.setTitle(question.getText());
|
||||
fieldSet.setDescription(buildDescription(question.getThemes()));
|
||||
fieldSet.setOrdinal(Math.toIntExact(question.getNumber()) - 1);
|
||||
fieldSet.setMultiplicity(buildMultiplicity());
|
||||
fieldSet.setHasCommentField(question.getOptionCommentDisplay());
|
||||
fieldSet.setFields(buildFields(question));
|
||||
return fieldSet;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private String buildDescription(Set<Theme> themes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
themes.forEach(theme -> {
|
||||
if(theme.getTitle() != null) {
|
||||
sb.append("<b>").append(theme.getTitle()).append("</b><br>");
|
||||
}
|
||||
if(theme.getDescription() != null) {
|
||||
sb.append("<p>").append(theme.getDescription()).append("</p>");
|
||||
}
|
||||
if(theme.getGuidances().size() > 0) {
|
||||
theme.getGuidances().forEach(guidance -> {
|
||||
sb.append("<b>").append(guidance.getGuidanceGroup().getName()).append("</b><br>");
|
||||
sb.append("<p>").append(guidance.getText()).append("</p>");
|
||||
});
|
||||
}
|
||||
});
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private Multiplicity buildMultiplicity() {
|
||||
Multiplicity multiplicity = new Multiplicity();
|
||||
multiplicity.setPlaceholder("");
|
||||
return multiplicity;
|
||||
}
|
||||
|
||||
private List<Field> buildFields(Question question) {
|
||||
Field field = new Field();
|
||||
field.setId(String.valueOf(UUID.randomUUID()));
|
||||
field.setOrdinal(0);
|
||||
field.setDefaultValue(buildDefaultValue(question.getDefaultValue()));
|
||||
field.setValue(field.getDefaultValue().getValue());
|
||||
field.setValidations(buildValidators());
|
||||
field.setVisible(buildVisibility());
|
||||
field.setViewStyle(buildViewStyle(question.getQuestionFormat()));
|
||||
field.setData(buildData(question));
|
||||
return Collections.singletonList(field);
|
||||
}
|
||||
|
||||
private DefaultValue buildDefaultValue(String value) {
|
||||
DefaultValue defaultValue = new DefaultValue();
|
||||
defaultValue.setType("String");
|
||||
defaultValue.setValue((value != null)?value:"");
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private List<Integer> buildValidators() {
|
||||
return Collections.singletonList((int) Field.ValidationType.REQUIRED.getValue());
|
||||
}
|
||||
|
||||
private Visibility buildVisibility() {
|
||||
Visibility visibility = new Visibility();
|
||||
visibility.setRules(new ArrayList<>());
|
||||
visibility.setStyle("");
|
||||
return visibility;
|
||||
}
|
||||
|
||||
private ViewStyle buildViewStyle(QuestionFormat questionFormat) {
|
||||
ViewStyle viewStyle = new ViewStyle();
|
||||
viewStyle.setCssClass("");
|
||||
switch (questionFormat.getFormattype()) {
|
||||
case TEXT_FIELD:
|
||||
viewStyle.setRenderStyle("freetext");
|
||||
break;
|
||||
case TEXTAREA:
|
||||
viewStyle.setRenderStyle("richTextarea");
|
||||
break;
|
||||
case CHECKBOX:
|
||||
viewStyle.setRenderStyle("checkBox");
|
||||
break;
|
||||
case RADIOBUTTON:
|
||||
viewStyle.setRenderStyle("radiobox");
|
||||
break;
|
||||
case DATE:
|
||||
viewStyle.setRenderStyle("datePicker");
|
||||
break;
|
||||
case DROPDOWN:
|
||||
case MULTI_SELECT:
|
||||
viewStyle.setRenderStyle("combobox");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return viewStyle;
|
||||
}
|
||||
|
||||
private Map<String, Object> buildData(Question question) {
|
||||
Map<String, Object> object = new HashMap<>();
|
||||
object.put("label", "");
|
||||
if(question.getQuestionFormat().getOptionBased()) {
|
||||
object.put("options", question.getOptions().stream().map(questionOption -> {
|
||||
Map<String, Object> option = new HashMap<>();
|
||||
option.put(questionOption.getText(), questionOption.getText());
|
||||
return option;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
if(question.getQuestionFormat().getFormattype() == QuestionFormat.FormatType.DROPDOWN ||
|
||||
question.getQuestionFormat().getFormattype() == QuestionFormat.FormatType.MULTI_SELECT) {
|
||||
object.put("type", "wordlist");
|
||||
object.put("multiList", question.getQuestionFormat().getFormattype() == QuestionFormat.FormatType.MULTI_SELECT);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
public List<DatasetProfile> getDatesetProfiles() {
|
||||
return datasetProfiles;
|
||||
}
|
||||
|
||||
public List<eu.eudat.data.entities.DatasetProfile> getProfiles() {
|
||||
return profiles;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package eu.eudat.migration.controllers;
|
||||
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.migration.DMPRoadmapMigration;
|
||||
import eu.eudat.migration.dao.TemplateRepository;
|
||||
import eu.eudat.migration.entities.Template;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -17,14 +19,26 @@ import java.util.List;
|
|||
public class TemplateController {
|
||||
|
||||
private final TemplateRepository templateRepository;
|
||||
private final DMPRoadmapMigration roadmapMigration;
|
||||
|
||||
@Autowired
|
||||
public TemplateController(TemplateRepository templateRepository) {
|
||||
public TemplateController(TemplateRepository templateRepository, DMPRoadmapMigration roadmapMigration) {
|
||||
this.templateRepository = templateRepository;
|
||||
this.roadmapMigration = roadmapMigration;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/all", produces = "application/json")
|
||||
public ResponseEntity<List<Template>> getAllTemplates() {
|
||||
return ResponseEntity.ok(this.templateRepository.findAll());
|
||||
}
|
||||
|
||||
@GetMapping(path = "/argos/memory", produces = "application/json")
|
||||
public ResponseEntity<List<eu.eudat.models.data.admin.composite.DatasetProfile>> getDatasetProfiles() {
|
||||
return ResponseEntity.ok(this.roadmapMigration.getDatesetProfiles());
|
||||
}
|
||||
|
||||
@GetMapping(path = "/argos/saved", produces = "application/json")
|
||||
public ResponseEntity<List<DatasetProfile>> getProfiles() {
|
||||
return ResponseEntity.ok(this.roadmapMigration.getProfiles());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "api_clients")
|
||||
public class ApiClient {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String name;
|
||||
private String description;
|
||||
private String homepage;
|
||||
@Column(name = "contact_name")
|
||||
private String contactName;
|
||||
@Column(name = "contact_email")
|
||||
private String contactEmail;
|
||||
@Column(name = "client_id")
|
||||
private String clientId;
|
||||
@Column(name = "client_secret")
|
||||
private String clientSecret;
|
||||
@Column(name = "last_access")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date lastAccess;
|
||||
@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 = "org_id")
|
||||
private Organization organization;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ApiClient{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", homepage='" + homepage + '\'' +
|
||||
", contactName='" + contactName + '\'' +
|
||||
", contactEmail='" + contactEmail + '\'' +
|
||||
", clientId='" + clientId + '\'' +
|
||||
", clientSecret='" + clientSecret + '\'' +
|
||||
", lastAccess=" + lastAccess +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", organization=" + organization +
|
||||
'}';
|
||||
}
|
||||
|
||||
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 getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getHomepage() {
|
||||
return homepage;
|
||||
}
|
||||
|
||||
public void setHomepage(String homepage) {
|
||||
this.homepage = homepage;
|
||||
}
|
||||
|
||||
public String getContactName() {
|
||||
return contactName;
|
||||
}
|
||||
|
||||
public void setContactName(String contactName) {
|
||||
this.contactName = contactName;
|
||||
}
|
||||
|
||||
public String getContactEmail() {
|
||||
return contactEmail;
|
||||
}
|
||||
|
||||
public void setContactEmail(String contactEmail) {
|
||||
this.contactEmail = contactEmail;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public String getClientSecret() {
|
||||
return clientSecret;
|
||||
}
|
||||
|
||||
public void setClientSecret(String clientSecret) {
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
|
||||
public Date getLastAccess() {
|
||||
return lastAccess;
|
||||
}
|
||||
|
||||
public void setLastAccess(Date lastAccess) {
|
||||
this.lastAccess = lastAccess;
|
||||
}
|
||||
|
||||
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 Organization getOrganization() {
|
||||
return organization;
|
||||
}
|
||||
|
||||
public void setOrganization(Organization organization) {
|
||||
this.organization = organization;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "guidances")
|
||||
public class Guidance {
|
||||
|
||||
@Id
|
||||
private long id;
|
||||
private String text;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "guidance_group_id")
|
||||
private GuidanceGroup guidanceGroup;
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
private Boolean published;
|
||||
|
||||
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 GuidanceGroup getGuidanceGroup() {
|
||||
return guidanceGroup;
|
||||
}
|
||||
|
||||
public void setGuidanceGroup(GuidanceGroup guidanceGroup) {
|
||||
this.guidanceGroup = guidanceGroup;
|
||||
}
|
||||
|
||||
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 getPublished() {
|
||||
return published;
|
||||
}
|
||||
|
||||
public void setPublished(Boolean published) {
|
||||
this.published = published;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "guidance_groups")
|
||||
public class GuidanceGroup {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String name;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "org_id")
|
||||
private Organization organization;
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
@Column(name = "optional_subset")
|
||||
private Boolean optionalSubset;
|
||||
private Boolean published;
|
||||
|
||||
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 Organization getOrganization() {
|
||||
return organization;
|
||||
}
|
||||
|
||||
public void setOrganization(Organization organization) {
|
||||
this.organization = organization;
|
||||
}
|
||||
|
||||
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 getOptionalSubset() {
|
||||
return optionalSubset;
|
||||
}
|
||||
|
||||
public void setOptionalSubset(Boolean optionalSubset) {
|
||||
this.optionalSubset = optionalSubset;
|
||||
}
|
||||
|
||||
public Boolean getPublished() {
|
||||
return published;
|
||||
}
|
||||
|
||||
public void setPublished(Boolean published) {
|
||||
this.published = published;
|
||||
}
|
||||
}
|
|
@ -1,13 +1,16 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
|
||||
import eu.eudat.migration.utils.JsonTypeConverter;
|
||||
import eu.eudat.migration.utils.OrganizationTypeConverter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
@Entity
|
||||
@Table(name = "orgs")
|
||||
@SuppressWarnings("JpaAttributeTypeInspection")
|
||||
public class Organization {
|
||||
|
||||
@Id
|
||||
|
@ -39,7 +42,8 @@ public class Organization {
|
|||
@Column(name = "org_type")
|
||||
@Convert(converter = OrganizationTypeConverter.class)
|
||||
private Type orgType;
|
||||
private String links;
|
||||
@Convert(converter = JsonTypeConverter.class)
|
||||
private Map<String, Object> links;
|
||||
@Column(name = "feedback_enabled")
|
||||
private Boolean feedbackEnabled;
|
||||
@Column(name = "feedback_msg")
|
||||
|
@ -199,11 +203,11 @@ public class Organization {
|
|||
}
|
||||
|
||||
|
||||
public String getLinks() {
|
||||
public Map<String, Object> getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public void setLinks(String links) {
|
||||
public void setLinks(Map<String, Object> links) {
|
||||
this.links = links;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,227 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "plans")
|
||||
@SuppressWarnings("JpaAttributeTypeInspection")
|
||||
public class Plan {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String title;
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
private String identifier;
|
||||
private String description;
|
||||
private Visibility visibility;
|
||||
@Column(name = "feedback_requested")
|
||||
private Boolean feedbackRequested;
|
||||
private Boolean complete;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "org_id")
|
||||
private Organization organization;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "funder_id")
|
||||
private Organization funder;
|
||||
@Column(name = "start_date")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date startDate;
|
||||
@Column(name = "end_date")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date endDate;
|
||||
@Column(name = "grant_id")
|
||||
private Long grantId;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "api_client_id")
|
||||
private ApiClient apiClient;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "research_domain_id")
|
||||
private ResearchDomain researchDomain;
|
||||
@Column(name = "ethical_issues")
|
||||
private Boolean ethicalIssues;
|
||||
@Column(name = "ethical_issues_description")
|
||||
private String ethicalIssuesDescription;
|
||||
@Column(name = "ethical_issues_report")
|
||||
private String ethicalIssuesReport;
|
||||
@Column(name = "funding_status")
|
||||
private FundingStatus fundingStatus;
|
||||
|
||||
public enum Visibility {
|
||||
ORGANIZATION,
|
||||
PUBLIC,
|
||||
TEST,
|
||||
PRIVATE
|
||||
}
|
||||
|
||||
public enum FundingStatus {
|
||||
PLANNED,
|
||||
FUNDED,
|
||||
DENIED
|
||||
}
|
||||
|
||||
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 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 getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Visibility getVisibility() {
|
||||
return visibility;
|
||||
}
|
||||
|
||||
public void setVisibility(Visibility visibility) {
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
public Boolean getFeedbackRequested() {
|
||||
return feedbackRequested;
|
||||
}
|
||||
|
||||
public void setFeedbackRequested(Boolean feedbackRequested) {
|
||||
this.feedbackRequested = feedbackRequested;
|
||||
}
|
||||
|
||||
public Boolean getComplete() {
|
||||
return complete;
|
||||
}
|
||||
|
||||
public void setComplete(Boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
public Organization getOrganization() {
|
||||
return organization;
|
||||
}
|
||||
|
||||
public void setOrganization(Organization organization) {
|
||||
this.organization = organization;
|
||||
}
|
||||
|
||||
public Organization getFunder() {
|
||||
return funder;
|
||||
}
|
||||
|
||||
public void setFunder(Organization funder) {
|
||||
this.funder = funder;
|
||||
}
|
||||
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Date getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public Long getGrantId() {
|
||||
return grantId;
|
||||
}
|
||||
|
||||
public void setGrantId(Long grantId) {
|
||||
this.grantId = grantId;
|
||||
}
|
||||
|
||||
public ApiClient getApiClient() {
|
||||
return apiClient;
|
||||
}
|
||||
|
||||
public void setApiClient(ApiClient apiClient) {
|
||||
this.apiClient = apiClient;
|
||||
}
|
||||
|
||||
public ResearchDomain getResearchDomain() {
|
||||
return researchDomain;
|
||||
}
|
||||
|
||||
public void setResearchDomain(ResearchDomain researchDomain) {
|
||||
this.researchDomain = researchDomain;
|
||||
}
|
||||
|
||||
public Boolean getEthicalIssues() {
|
||||
return ethicalIssues;
|
||||
}
|
||||
|
||||
public void setEthicalIssues(Boolean ethicalIssues) {
|
||||
this.ethicalIssues = ethicalIssues;
|
||||
}
|
||||
|
||||
public String getEthicalIssuesDescription() {
|
||||
return ethicalIssuesDescription;
|
||||
}
|
||||
|
||||
public void setEthicalIssuesDescription(String ethicalIssuesDescription) {
|
||||
this.ethicalIssuesDescription = ethicalIssuesDescription;
|
||||
}
|
||||
|
||||
public String getEthicalIssuesReport() {
|
||||
return ethicalIssuesReport;
|
||||
}
|
||||
|
||||
public void setEthicalIssuesReport(String ethicalIssuesReport) {
|
||||
this.ethicalIssuesReport = ethicalIssuesReport;
|
||||
}
|
||||
|
||||
public FundingStatus getFundingStatus() {
|
||||
return fundingStatus;
|
||||
}
|
||||
|
||||
public void setFundingStatus(FundingStatus fundingStatus) {
|
||||
this.fundingStatus = fundingStatus;
|
||||
}
|
||||
}
|
|
@ -4,9 +4,7 @@ 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;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "questions")
|
||||
|
@ -42,6 +40,13 @@ public class Question {
|
|||
@OrderBy("number")
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private List<Condition> conditions = new ArrayList<>();
|
||||
@ManyToMany(cascade = CascadeType.ALL)
|
||||
@JoinTable(name = "questions_themes",
|
||||
joinColumns = {@JoinColumn(name = "question_id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "theme_id")}
|
||||
)
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private Set<Theme> themes = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -157,4 +162,12 @@ public class Question {
|
|||
public void setConditions(List<Condition> conditions) {
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
public Set<Theme> getThemes() {
|
||||
return themes;
|
||||
}
|
||||
|
||||
public void setThemes(Set<Theme> themes) {
|
||||
this.themes = themes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name = "research_domains")
|
||||
public class ResearchDomain {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String identifier;
|
||||
private String label;
|
||||
@OneToMany(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "parent_id")
|
||||
private Set<ResearchDomain> subFields = new HashSet<>();
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ResearchDomain{" +
|
||||
"id=" + id +
|
||||
", identifier='" + identifier + '\'' +
|
||||
", label='" + label + '\'' +
|
||||
", subFields=" + subFields +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public Set<ResearchDomain> getSubFields() {
|
||||
return subFields;
|
||||
}
|
||||
|
||||
public void setSubFields(Set<ResearchDomain> subFields) {
|
||||
this.subFields = subFields;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import eu.eudat.migration.utils.JsonTypeConverter;
|
||||
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;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "templates")
|
||||
@SuppressWarnings("JpaAttributeTypeInspection")
|
||||
public class Template {
|
||||
|
||||
@Id
|
||||
|
@ -29,19 +29,24 @@ public class Template {
|
|||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
private Long version;
|
||||
private Short version;
|
||||
private Visibility visibility;
|
||||
@Column(name = "customization_of")
|
||||
private Long customizationOf;
|
||||
@Column(name = "family_id")
|
||||
private Long familyId;
|
||||
private Boolean archived;
|
||||
private String links;
|
||||
@Convert(converter = JsonTypeConverter.class)
|
||||
private Map<String, Object> links;
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "template_id")
|
||||
@OrderBy("number")
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private List<Phase> phases = new ArrayList<>();
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "template_id")
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private Set<Plan> plans = new HashSet<>();
|
||||
|
||||
public enum Visibility {
|
||||
ORGANIZATION,
|
||||
|
@ -116,11 +121,11 @@ public class Template {
|
|||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
public Short getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
public void setVersion(Short version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
@ -161,11 +166,11 @@ public class Template {
|
|||
}
|
||||
|
||||
|
||||
public String getLinks() {
|
||||
public Map<String, Object> getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public void setLinks(String links) {
|
||||
public void setLinks(Map<String, Object> links) {
|
||||
this.links = links;
|
||||
}
|
||||
|
||||
|
@ -185,24 +190,34 @@ public class Template {
|
|||
this.phases = phases;
|
||||
}
|
||||
|
||||
public Set<Plan> getPlans() {
|
||||
return plans;
|
||||
}
|
||||
|
||||
public void setPlans(Set<Plan> plans) {
|
||||
this.plans = plans;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Template{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", published='" + published + '\'' +
|
||||
", published=" + published +
|
||||
", organization=" + organization +
|
||||
", locale='" + locale + '\'' +
|
||||
", isDefault='" + isDefault + '\'' +
|
||||
", isDefault=" + isDefault +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", version=" + version +
|
||||
", visibility=" + visibility +
|
||||
", customizationOf=" + customizationOf +
|
||||
", familyId=" + familyId +
|
||||
", archived='" + archived + '\'' +
|
||||
", links='" + links + '\'' +
|
||||
", archived=" + archived +
|
||||
", links=" + links +
|
||||
", phases=" + phases +
|
||||
", plans=" + plans +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
@Table(name = "themes")
|
||||
public class Theme {
|
||||
|
||||
@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;
|
||||
private String locale;
|
||||
@ManyToMany(cascade = CascadeType.ALL)
|
||||
@JoinTable(name = "themes_in_guidance",
|
||||
joinColumns = {@JoinColumn(name = "theme_id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "guidance_id")}
|
||||
)
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private Set<Guidance> guidances = new HashSet<>();
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Theme{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", locale='" + locale + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
||||
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 String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public Set<Guidance> getGuidances() {
|
||||
return guidances;
|
||||
}
|
||||
|
||||
public void setGuidances(Set<Guidance> guidances) {
|
||||
this.guidances = guidances;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue