Commit changes before create a new module
parent
9cb9cdb030
commit
6072708d8a
@ -0,0 +1,51 @@
|
||||
package eu.eudat.migration.controllers;
|
||||
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.migration.dao.TemplateRepository;
|
||||
import eu.eudat.migration.entities.Template;
|
||||
import eu.eudat.migration.entities.User;
|
||||
import eu.eudat.migration.services.DMPRoadmapService;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
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;
|
||||
import java.util.UUID;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/")
|
||||
@ConditionalOnProperty(prefix = "roadmap", name="database.url")
|
||||
public class MigrateController {
|
||||
private final DMPRoadmapService roadmapMigration;
|
||||
|
||||
@Autowired
|
||||
public MigrateController(DMPRoadmapService roadmapMigration) {
|
||||
this.roadmapMigration = roadmapMigration;
|
||||
}
|
||||
|
||||
@GetMapping(path = "template/all", produces = "application/json")
|
||||
public ResponseEntity<List<Template>> getAllTemplates() {
|
||||
return ResponseEntity.ok(this.roadmapMigration.getTemplates());
|
||||
}
|
||||
|
||||
@GetMapping(path = "template/argos/memory", produces = "application/json")
|
||||
public ResponseEntity<List<eu.eudat.models.data.admin.composite.DatasetProfile>> getDatasetProfiles() {
|
||||
return ResponseEntity.ok(this.roadmapMigration.getDatesetProfiles());
|
||||
}
|
||||
|
||||
@GetMapping(path = "user/all", produces = "application/json")
|
||||
public ResponseEntity<List<User>> getAllUsers() {
|
||||
return ResponseEntity.ok(this.roadmapMigration.getUsers());
|
||||
}
|
||||
|
||||
@GetMapping(path = "migration/execute", produces = "application/json")
|
||||
public ResponseEntity<Object> migrate() {
|
||||
this.roadmapMigration.migrate();
|
||||
return ResponseEntity.ok(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
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;
|
||||
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;
|
||||
private final DMPRoadmapMigration roadmapMigration;
|
||||
|
||||
@Autowired
|
||||
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,9 @@
|
||||
package eu.eudat.migration.dao;
|
||||
|
||||
import eu.eudat.migration.entities.User;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
@ConditionalOnProperty(prefix = "roadmap", name="database.url")
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
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 = "answers")
|
||||
public class Answer {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String text;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "user_id")
|
||||
private User user;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "question_id")
|
||||
private Question question;
|
||||
@Column(name = "created_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date createdAt;
|
||||
@Column(name = "updated_at")
|
||||
@Temporal(TemporalType.TIMESTAMP)
|
||||
private Date updatedAt;
|
||||
@ManyToMany(cascade = CascadeType.ALL)
|
||||
@JoinTable(name = "answers_question_options",
|
||||
joinColumns = {@JoinColumn(name = "answer_id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "question_option_id")}
|
||||
)
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private Set<QuestionOption> questionOptions = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Answer{" +
|
||||
"id=" + id +
|
||||
", text='" + text + '\'' +
|
||||
", user=" + user +
|
||||
", question=" + question +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", questionOptions=" + questionOptions +
|
||||
'}';
|
||||
}
|
||||
|
||||
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 User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public Question getQuestion() {
|
||||
return question;
|
||||
}
|
||||
|
||||
public void setQuestion(Question question) {
|
||||
this.question = question;
|
||||
}
|
||||
|
||||
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 Set<QuestionOption> getQuestionOptions() {
|
||||
return questionOptions;
|
||||
}
|
||||
|
||||
public void setQuestionOptions(Set<QuestionOption> questionOptions) {
|
||||
this.questionOptions = questionOptions;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package eu.eudat.migration.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Entity
|
||||
@Table(name = "perms")
|
||||
public class Perm {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String name;
|
||||
@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 "Perm{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
'}';
|
||||
}
|
||||
|
||||
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 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,126 @@
|
||||
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 = "users")
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String firstname;
|
||||
private String surname;
|
||||
private String email;
|
||||
@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;
|
||||
@ManyToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "language_id")
|
||||
private Language language;
|
||||
@ManyToMany(cascade = CascadeType.ALL)
|
||||
@JoinTable(name = "users_perms",
|
||||
joinColumns = {@JoinColumn(name = "user_id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "perm_id")}
|
||||
)
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private Set<Perm> perms = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"id=" + id +
|
||||
", firstname='" + firstname + '\'' +
|
||||
", surname='" + surname + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", organization=" + organization +
|
||||
", language=" + language +
|
||||
", perms=" + perms +
|
||||
'}';
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getSurname() {
|
||||
return surname;
|
||||
}
|
||||
|
||||
public void setSurname(String surname) {
|
||||
this.surname = surname;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Language getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(Language language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public Set<Perm> getPerms() {
|
||||
return perms;
|
||||
}
|
||||
|
||||
public void setPerms(Set<Perm> perms) {
|
||||
this.perms = perms;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue