Compare commits
23 Commits
|
@ -27,6 +27,7 @@ dmp-backend/data/target/
|
|||
dmp-backend/queryable/target/
|
||||
dmp-backend/elastic/target/
|
||||
dmp-backend/queryengine/target/
|
||||
dmp-backend/roadmap/target/
|
||||
*.tar
|
||||
*.gz
|
||||
final/
|
||||
|
@ -48,4 +49,3 @@ bin/
|
|||
*.classpath
|
||||
openDMP/dmp-backend/uploads/
|
||||
openDMP/dmp-backend/tmp/
|
||||
dmp-frontend/.angular/
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
|
||||
**Important note: The deployment, troubleshooting, maintenance and operation of on-premises / self-served OpenDMP instances for development, testing or production use, shall be the sole responsibility of the adopter. No support is guaranteed by OpenDMP implentation team for issues that may be encountered during deployment, extension or operation of such installations.**
|
||||
|
||||
**Documentation is provided on a best-effort basis for the code and processes around the development, deployment and operation of OpenDMP. If you find any misalignment of the actual processes with the related documentation, please let us know so that the misalignment is addressed for the benefit of future adopters.**
|
||||
|
||||
|
||||
# Using Docker Compose with Argos
|
||||
|
||||
ARGOS is an open extensible service that simplifies the management, validation, monitoring and maintenance and of Data Management Plans. It allows actors (researchers, managers, supervisors etc) to create actionable DMPs that may be freely exchanged among infrastructures for carrying out specific aspects of the Data management process in accordance with the intentions and commitment of Data owners.
|
||||
|
|
|
@ -12,4 +12,4 @@ RUN mvn package
|
|||
FROM adoptopenjdk/openjdk11:alpine-jre
|
||||
WORKDIR /app
|
||||
COPY --from=MAVEN_BUILD /build/web/target/web-1.0-SNAPSHOT.jar /app/app.jar
|
||||
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-Dspring.profiles.active=${PROF}", "-Dspring.config.additional-location=/files/config/", "-cp", "/app/app.jar", "-Dloader.path=/files/repo-jars", "org.springframework.boot.loader.PropertiesLauncher"]
|
||||
ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-Dspring.profiles.active=${PROF}", "-Dspring.config.additional-location=/files/config/", "-jar","/app/app.jar"]
|
||||
|
|
|
@ -25,10 +25,5 @@
|
|||
<artifactId>elastic</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.5.20</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,9 +1,9 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
|
||||
public abstract class Criteria<T> {
|
||||
@ApiModelProperty(value = "like", name = "like", dataType = "String", allowEmptyValue = true, example = "\"\"")
|
||||
private String like;
|
||||
|
||||
public String getLike() {
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
|
||||
public class DataManagementPlanBlueprintCriteria extends Criteria<DMPProfile> {
|
||||
|
||||
private Integer status;
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.data.entities.Grant;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -11,7 +10,6 @@ import java.util.UUID;
|
|||
public class DataManagementPlanCriteria extends Criteria<DMP> {
|
||||
private Date periodStart;
|
||||
private Date periodEnd;
|
||||
private DMPProfile profile;
|
||||
private List<eu.eudat.data.entities.Grant> grants;
|
||||
private boolean allVersions;
|
||||
private List<UUID> groupIds;
|
||||
|
@ -39,13 +37,6 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
|
|||
this.periodEnd = periodEnd;
|
||||
}
|
||||
|
||||
public DMPProfile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
public void setProfile(DMPProfile profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
public List<Grant> getGrants() {
|
||||
return grants;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DatasetProfileCriteria extends Criteria<DescriptionTemplate> {
|
||||
public class DatasetProfileCriteria extends Criteria<DatasetProfile> {
|
||||
|
||||
public enum DatasetProfileFilter {
|
||||
DMPs((short) 0), Datasets((short) 1);
|
||||
|
@ -25,7 +25,7 @@ public class DatasetProfileCriteria extends Criteria<DescriptionTemplate> {
|
|||
case 1:
|
||||
return Datasets;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported DescriptionTemplate filter");
|
||||
throw new RuntimeException("Unsupported DatasetProfile filter");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package eu.eudat.data.dao.criteria;
|
||||
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class DatasetProfileWizardCriteria extends Criteria<DescriptionTemplate> {
|
||||
public class DatasetProfileWizardCriteria extends Criteria<DatasetProfile> {
|
||||
private UUID id;
|
||||
|
||||
public UUID getId() {
|
||||
|
|
|
@ -16,7 +16,7 @@ import javax.persistence.PersistenceContext;
|
|||
@Repository("databaseCtx")
|
||||
public class DatabaseContext<T extends DataEntity> {
|
||||
|
||||
@PersistenceContext
|
||||
@PersistenceContext(unitName = "entityManager")
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -42,8 +42,6 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
||||
if (criteria.getPeriodStart() != null)
|
||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||
if (criteria.getProfile() != null)
|
||||
query.where((builder, root) -> builder.equal(root.get("profile"), criteria.getProfile()));
|
||||
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
||||
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
|
||||
if (!criteria.getAllVersions())
|
||||
|
@ -77,7 +75,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
query.where((builder, root) -> root.join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id").in(criteria.getCollaborators()));
|
||||
}
|
||||
if (criteria.getDatasetTemplates() != null && !criteria.getDatasetTemplates().isEmpty()) {
|
||||
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("datasetprofile").get("id").in(criteria.getDatasetTemplates()));
|
||||
query.where((builder, root) -> root.join("associatedDmps", JoinType.LEFT).get("id").in(criteria.getDatasetTemplates()));
|
||||
}
|
||||
if (criteria.getGrantStatus() != null) {
|
||||
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
|
||||
|
@ -89,7 +87,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
}
|
||||
|
||||
if (criteria.hasDoi()) {
|
||||
query.where((builder, root) -> builder.not(builder.isNull(root.join("dois").get("id"))));
|
||||
query.where((builder, root) -> builder.not(builder.isNull(root.get("doi"))));
|
||||
}
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
|
||||
return query;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
|
@ -16,6 +15,4 @@ public interface DMPProfileDao extends DatabaseAccessLayer<DMPProfile, UUID> {
|
|||
|
||||
QueryableList<DMPProfile> getWithCriteria(DataManagementPlanProfileCriteria criteria);
|
||||
|
||||
QueryableList<DMPProfile> getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
|
@ -66,20 +65,4 @@ public class DMPProfileDaoImpl extends DatabaseAccess<DMPProfile> implements DMP
|
|||
query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria){
|
||||
QueryableList<DMPProfile> query = getDatabaseService().getQueryable(DMPProfile.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
|
||||
if (criteria.getStatus() != null) {
|
||||
if (criteria.getStatus() == DMPProfile.Status.FINALIZED.getValue()) {
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.FINALIZED.getValue()));
|
||||
} else if (criteria.getStatus() == DMPProfile.Status.SAVED.getValue()) {
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.SAVED.getValue()));
|
||||
}
|
||||
}
|
||||
query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
|
||||
return query;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
|||
query.where((builder, root) -> root.get("profile").get("id").in(criteria.getDatasetTemplates()));
|
||||
|
||||
if (criteria.hasDoi()) {
|
||||
query.where((builder, root) -> builder.not(builder.isNull(root.join("dmp").join("dois").get("id"))));
|
||||
query.where((builder, root) -> builder.not(builder.isNull(root.get("dmp").get("doi"))));
|
||||
}
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue()));
|
||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.CANCELED.getValue()));
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.data.dao.entities;
|
|||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DatasetExternalDataset;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
|
|
@ -2,23 +2,18 @@ package eu.eudat.data.dao.entities;
|
|||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface DatasetProfileDao extends DatabaseAccessLayer<DescriptionTemplate, UUID> {
|
||||
public interface DatasetProfileDao extends DatabaseAccessLayer<DatasetProfile, UUID> {
|
||||
|
||||
QueryableList<DescriptionTemplate> getWithCriteria(DatasetProfileCriteria criteria);
|
||||
QueryableList<DatasetProfile> getWithCriteria(DatasetProfileCriteria criteria);
|
||||
|
||||
QueryableList<DescriptionTemplate> getAll();
|
||||
QueryableList<DatasetProfile> getAll();
|
||||
|
||||
QueryableList<DescriptionTemplate> getAuthenticated(QueryableList<DescriptionTemplate> query, UUID principal, List<Integer> roles);
|
||||
|
||||
List<DescriptionTemplate> getAllIds();
|
||||
|
||||
Long countWithType(DescriptionTemplateType type);
|
||||
QueryableList<DatasetProfile> getAuthenticated(QueryableList<DatasetProfile> query, UUID principal, List<Integer> roles);
|
||||
|
||||
}
|
|
@ -3,8 +3,8 @@ package eu.eudat.data.dao.entities;
|
|||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.types.FieldSelectionType;
|
||||
import eu.eudat.queryable.types.SelectionField;
|
||||
|
@ -15,22 +15,21 @@ import org.springframework.stereotype.Component;
|
|||
import javax.persistence.criteria.Join;
|
||||
import javax.persistence.criteria.JoinType;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("datasetProfileDao")
|
||||
public class DatasetProfileDaoImpl extends DatabaseAccess<DescriptionTemplate> implements DatasetProfileDao {
|
||||
public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implements DatasetProfileDao {
|
||||
|
||||
@Autowired
|
||||
public DatasetProfileDaoImpl(DatabaseService<DescriptionTemplate> databaseService) {
|
||||
public DatasetProfileDaoImpl(DatabaseService<DatasetProfile> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> getWithCriteria(DatasetProfileCriteria criteria) {
|
||||
QueryableList<DescriptionTemplate> query = getDatabaseService().getQueryable(DescriptionTemplate.class);
|
||||
public QueryableList<DatasetProfile> getWithCriteria(DatasetProfileCriteria criteria) {
|
||||
QueryableList<DatasetProfile> query = getDatabaseService().getQueryable(DatasetProfile.class);
|
||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
|
||||
if (!criteria.getAllVersions())
|
||||
|
@ -63,9 +62,9 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DescriptionTemplate> i
|
|||
query.where(((builder, root) -> root.get("id").in(criteria.getIds())));
|
||||
}
|
||||
if (criteria.getFinalized()) {
|
||||
query.where(((builder, root) -> builder.equal(root.get("status"), DescriptionTemplate.Status.FINALIZED.getValue())));
|
||||
query.where(((builder, root) -> builder.equal(root.get("status"), DatasetProfile.Status.FINALIZED.getValue())));
|
||||
} else {
|
||||
query.where(((builder, root) -> builder.notEqual(root.get("status"), DescriptionTemplate.Status.DELETED.getValue())));
|
||||
query.where(((builder, root) -> builder.notEqual(root.get("status"), DatasetProfile.Status.DELETED.getValue())));
|
||||
}
|
||||
if (criteria.getPeriodStart() != null)
|
||||
query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("created"), criteria.getPeriodStart()));
|
||||
|
@ -73,48 +72,43 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DescriptionTemplate> i
|
|||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplate createOrUpdate(DescriptionTemplate item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DescriptionTemplate.class);
|
||||
public DatasetProfile createOrUpdate(DatasetProfile item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DatasetProfile.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplate find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
public DatasetProfile find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> getAll() {
|
||||
return getDatabaseService().getQueryable(DescriptionTemplate.class);
|
||||
public QueryableList<DatasetProfile> getAll() {
|
||||
return getDatabaseService().getQueryable(DatasetProfile.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DescriptionTemplate> getAllIds(){
|
||||
return getDatabaseService().getQueryable(DescriptionTemplate.class).withFields(Collections.singletonList("id")).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DescriptionTemplate item) {
|
||||
public void delete(DatasetProfile item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DescriptionTemplate.class);
|
||||
public QueryableList<DatasetProfile> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DatasetProfile.class);
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<DescriptionTemplate> createOrUpdateAsync(DescriptionTemplate item) {
|
||||
public CompletableFuture<DatasetProfile> createOrUpdateAsync(DatasetProfile item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplate find(UUID id, String hint) {
|
||||
public DatasetProfile find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> getAuthenticated(QueryableList<DescriptionTemplate> query, UUID principal, List<Integer> roles) {
|
||||
public QueryableList<DatasetProfile> getAuthenticated(QueryableList<DatasetProfile> query, UUID principal, List<Integer> roles) {
|
||||
if (roles != null && !roles.isEmpty()) {
|
||||
query.where((builder, root) -> {
|
||||
Join userJoin = root.join("users", JoinType.LEFT);
|
||||
|
@ -126,9 +120,4 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DescriptionTemplate> i
|
|||
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long countWithType(DescriptionTemplateType type) {
|
||||
return this.getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("type"), type)).count();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.entities.DatasetService;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
|
@ -2,6 +2,8 @@ package eu.eudat.data.dao.entities;
|
|||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DatasetExternalDataset;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.entities.DatasetService;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface DescriptionTemplateTypeDao extends DatabaseAccessLayer<DescriptionTemplateType, UUID> {
|
||||
DescriptionTemplateType findFromName(String name);
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.DescriptionTemplateType;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("descriptionTemplateTypeDao")
|
||||
public class DescriptionTemplateTypeDaoImpl extends DatabaseAccess<DescriptionTemplateType> implements DescriptionTemplateTypeDao {
|
||||
|
||||
@Autowired
|
||||
public DescriptionTemplateTypeDaoImpl(DatabaseService<DescriptionTemplateType> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateType findFromName(String name){
|
||||
try {
|
||||
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.and(builder.equal(root.get("name"), name), builder.notEqual(root.get("status"), DescriptionTemplateType.Status.DELETED.getValue()))).getSingle();
|
||||
}
|
||||
catch(Exception e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public DescriptionTemplateType createOrUpdate(DescriptionTemplateType item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DescriptionTemplateType.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateType find(UUID id) {
|
||||
return getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DescriptionTemplateType item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplateType> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DescriptionTemplateType.class).where((builder, root) -> builder.notEqual((root.get("status")), DescriptionTemplateType.Status.DELETED.getValue()));
|
||||
}
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public CompletableFuture<DescriptionTemplateType> createOrUpdateAsync(DescriptionTemplateType item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateType find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.DMPDatasetProfile;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface DmpDatasetProfileDao extends DatabaseAccessLayer<DMPDatasetProfile, UUID> {
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.Content;
|
||||
import eu.eudat.data.entities.DMPDatasetProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Service("dmpDatasetProfileDao")
|
||||
public class DmpDatasetProfileDaoImpl extends DatabaseAccess<DMPDatasetProfile> implements DmpDatasetProfileDao {
|
||||
@Autowired
|
||||
public DmpDatasetProfileDaoImpl(DatabaseService<DMPDatasetProfile> databaseService) {
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPDatasetProfile createOrUpdate(DMPDatasetProfile item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, DMPDatasetProfile.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Async
|
||||
public CompletableFuture<DMPDatasetProfile> createOrUpdateAsync(DMPDatasetProfile item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPDatasetProfile find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(DMPDatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPDatasetProfile find(UUID id, String hint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(DMPDatasetProfile item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPDatasetProfile> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(DMPDatasetProfile.class);
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.EntityDoi;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface EntityDoiDao extends DatabaseAccessLayer<EntityDoi, UUID> {
|
||||
EntityDoi findFromDoi(String doi);
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package eu.eudat.data.dao.entities;
|
||||
|
||||
import eu.eudat.data.dao.DatabaseAccess;
|
||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||
import eu.eudat.data.entities.EntityDoi;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component("EntityDoiDao")
|
||||
public class EntityDoiDaoImpl extends DatabaseAccess<EntityDoi> implements EntityDoiDao {
|
||||
|
||||
@Autowired
|
||||
public EntityDoiDaoImpl(DatabaseService<EntityDoi> databaseService){
|
||||
super(databaseService);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EntityDoi createOrUpdate(EntityDoi item) {
|
||||
return this.getDatabaseService().createOrUpdate(item, EntityDoi.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<EntityDoi> createOrUpdateAsync(EntityDoi item) {
|
||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDoi find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(EntityDoi.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDoi findFromDoi(String doi) {
|
||||
return this.getDatabaseService().getQueryable(EntityDoi.class).where((builder, root) -> builder.equal(root.get("doi"), doi)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDoi find(UUID id, String hint) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(EntityDoi item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<EntityDoi> asQueryable() {
|
||||
return this.getDatabaseService().getQueryable(EntityDoi.class);
|
||||
}
|
||||
}
|
|
@ -3,9 +3,7 @@ package eu.eudat.data.dao.entities;
|
|||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||
import eu.eudat.data.entities.FileUpload;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface FileUploadDao extends DatabaseAccessLayer<FileUpload, UUID> {
|
||||
List<FileUpload> getFileUploads(UUID entityId);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import eu.eudat.queryable.QueryableList;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
@ -34,11 +33,6 @@ public class FileUploadDaoImpl extends DatabaseAccess<FileUpload> implements Fil
|
|||
return getDatabaseService().getQueryable(FileUpload.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileUpload> getFileUploads(UUID entityId) {
|
||||
return this.getDatabaseService().getQueryable(FileUpload.class).where((builder, root) -> builder.equal(root.get("entityId"), entityId)).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileUpload find(UUID id, String hint) {
|
||||
return null;
|
||||
|
|
|
@ -25,12 +25,7 @@ import java.util.stream.Collectors;
|
|||
name = "fullyDetailed",
|
||||
attributeNodes = {
|
||||
@NamedAttributeNode("grant"), @NamedAttributeNode("profile"),
|
||||
@NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")
|
||||
},
|
||||
subgraphs = {
|
||||
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")})
|
||||
}
|
||||
),
|
||||
@NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")}),
|
||||
@NamedEntityGraph(
|
||||
name = "dmpRecentActivity",
|
||||
attributeNodes = {
|
||||
|
@ -112,8 +107,12 @@ public class DMP implements DataEntity<DMP, UUID> {
|
|||
/*@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
|
||||
private String associatedDmps;*/
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "dmp")
|
||||
private Set<DMPDatasetProfile> associatedDmps;
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DMPDatasetProfile\"",
|
||||
joinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private Set<DatasetProfile> associatedDmps;
|
||||
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
|
@ -182,8 +181,8 @@ public class DMP implements DataEntity<DMP, UUID> {
|
|||
@Convert(converter = DateToUTCConverter.class)
|
||||
private Date publishedAt;
|
||||
|
||||
@OneToMany(mappedBy = "entityId", fetch = FetchType.LAZY)
|
||||
private Set<EntityDoi> dois;
|
||||
@Column(name = "\"DOI\"")
|
||||
private String doi;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"Project\"")
|
||||
|
@ -270,10 +269,10 @@ public class DMP implements DataEntity<DMP, UUID> {
|
|||
this.grant = grant;
|
||||
}
|
||||
|
||||
public Set<DMPDatasetProfile> getAssociatedDmps() {
|
||||
public Set<DatasetProfile> getAssociatedDmps() {
|
||||
return associatedDmps;
|
||||
}
|
||||
public void setAssociatedDmps(Set<DMPDatasetProfile> associatedDmps) {
|
||||
public void setAssociatedDmps(Set<DatasetProfile> associatedDmps) {
|
||||
this.associatedDmps = associatedDmps;
|
||||
}
|
||||
|
||||
|
@ -340,11 +339,11 @@ public class DMP implements DataEntity<DMP, UUID> {
|
|||
this.publishedAt = publishedAt;
|
||||
}
|
||||
|
||||
public Set<EntityDoi> getDois() {
|
||||
return dois;
|
||||
public String getDoi() {
|
||||
return doi;
|
||||
}
|
||||
public void setDois(Set<EntityDoi> dois) {
|
||||
this.dois = dois;
|
||||
public void setDoi(String doi) {
|
||||
this.doi = doi;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
|
@ -381,7 +380,7 @@ public class DMP implements DataEntity<DMP, UUID> {
|
|||
if (entity.getStatus().equals(DMPStatus.FINALISED.getValue())) this.setFinalizedAt(new Date());
|
||||
if (entity.isPublic) this.setPublishedAt(new Date());
|
||||
if (entity.getUsers() != null) this.users = entity.getUsers();
|
||||
this.dois = entity.getDois();
|
||||
if (entity.getDoi() != null && entity.getDoi().trim().isEmpty()) this.doi = entity.doi;
|
||||
this.extraProperties = entity.getExtraProperties();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
package eu.eudat.data.entities;
|
||||
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"DMPDatasetProfile\"")
|
||||
public class DMPDatasetProfile implements DataEntity<DMPDatasetProfile, UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "\"dmp\"")
|
||||
private DMP dmp;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "\"datasetprofile\"")
|
||||
private DescriptionTemplate datasetprofile;
|
||||
|
||||
@Column(name = "\"data\"")
|
||||
private String data;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public DMP getDmp() {
|
||||
return dmp;
|
||||
}
|
||||
public void setDmp(DMP dmp) {
|
||||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
public DescriptionTemplate getDatasetprofile() {
|
||||
return datasetprofile;
|
||||
}
|
||||
public void setDatasetprofile(DescriptionTemplate datasetprofile) {
|
||||
this.datasetprofile = datasetprofile;
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DMPDatasetProfile entity) {
|
||||
this.dmp = entity.getDmp();
|
||||
this.datasetprofile = entity.getDatasetprofile();
|
||||
this.data = entity.getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMPDatasetProfile buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -100,9 +100,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
|||
@JoinColumn(name = "\"DMP\"", nullable = false)
|
||||
private DMP dmp;
|
||||
|
||||
@Column(name = "\"DmpSectionIndex\"")
|
||||
private Integer dmpSectionIndex;
|
||||
|
||||
@Column(name = "\"Uri\"")
|
||||
private String uri;
|
||||
|
||||
|
@ -113,7 +110,7 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
|||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
||||
@JoinColumn(name = "\"Profile\"")
|
||||
private DescriptionTemplate profile;
|
||||
private DatasetProfile profile;
|
||||
|
||||
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||
@Column(name = "\"Reference\"", columnDefinition = "xml")
|
||||
|
@ -235,12 +232,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
|||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
public Integer getDmpSectionIndex() {
|
||||
return dmpSectionIndex;
|
||||
}
|
||||
public void setDmpSectionIndex(Integer dmpSectionIndex) {
|
||||
this.dmpSectionIndex = dmpSectionIndex;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
|
@ -258,10 +249,10 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
|||
}
|
||||
|
||||
|
||||
public DescriptionTemplate getProfile() {
|
||||
public DatasetProfile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
public void setProfile(DescriptionTemplate profile) {
|
||||
public void setProfile(DatasetProfile profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
|
@ -337,7 +328,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
|||
this.setRegistries(entity.getRegistries());
|
||||
|
||||
this.setDmp(entity.getDmp());
|
||||
this.setDmpSectionIndex(entity.getDmpSectionIndex());
|
||||
this.setStatus(entity.getStatus());
|
||||
this.setProfile(entity.getProfile());
|
||||
this.setModified(new Date());
|
||||
|
|
|
@ -14,8 +14,8 @@ import java.util.UUID;
|
|||
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"DescriptionTemplate\"")
|
||||
public class DescriptionTemplate implements DataEntity<DescriptionTemplate,UUID>{
|
||||
@Table(name = "\"DatasetProfile\"")
|
||||
public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
|
||||
|
||||
public enum Status {
|
||||
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
|
||||
|
@ -79,21 +79,19 @@ public class DescriptionTemplate implements DataEntity<DescriptionTemplate,UUID>
|
|||
@Column(name = "\"Version\"", nullable = false)
|
||||
private Short version;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
private Set<DMP> dmps;
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
@JoinTable(name = "\"DMPDatasetProfile\"",
|
||||
joinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")}
|
||||
)
|
||||
private List<DMP> dmps;
|
||||
|
||||
@Column(name = "\"Language\"", nullable = false)
|
||||
private String language;
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "\"Type\"", nullable = false)
|
||||
private DescriptionTemplateType type;
|
||||
|
||||
@OneToMany(mappedBy = "descriptionTemplate", fetch = FetchType.LAZY)
|
||||
@OneToMany(mappedBy = "datasetProfile", fetch = FetchType.LAZY)
|
||||
private Set<UserDatasetProfile> users;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "datasetprofile")
|
||||
private Set<DMPDatasetProfile> associatedDmps;
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
|
@ -158,31 +156,26 @@ public class DescriptionTemplate implements DataEntity<DescriptionTemplate,UUID>
|
|||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
|
||||
public DescriptionTemplateType getType() {
|
||||
return type;
|
||||
}
|
||||
public void setType(DescriptionTemplateType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Set<UserDatasetProfile> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(Set<UserDatasetProfile> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + ", language=" + language + ", type=" + type +"]";
|
||||
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + ", language=" + language + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DescriptionTemplate entity) {
|
||||
public void update(DatasetProfile entity) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -191,7 +184,7 @@ public class DescriptionTemplate implements DataEntity<DescriptionTemplate,UUID>
|
|||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplate buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||
public DatasetProfile buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
|
||||
return this;
|
||||
}
|
|
@ -1,89 +0,0 @@
|
|||
package eu.eudat.data.entities;
|
||||
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"DescriptionTemplateType\"")
|
||||
public class DescriptionTemplateType implements DataEntity<DescriptionTemplateType, UUID> {
|
||||
|
||||
public enum Status {
|
||||
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
|
||||
|
||||
private short value;
|
||||
|
||||
private Status(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
public short getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static Status fromInteger(int value) {
|
||||
switch (value) {
|
||||
case 0:
|
||||
return SAVED;
|
||||
case 1:
|
||||
return FINALIZED;
|
||||
case 99:
|
||||
return DELETED;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Description Template Type Status");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
|
||||
@Column(name = "\"Name\"", nullable = false)
|
||||
private String name;
|
||||
|
||||
@Column(name = "\"Status\"", nullable = false)
|
||||
private Short status;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(DescriptionTemplateType entity) {
|
||||
this.name = entity.name;
|
||||
this.status = entity.status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DescriptionTemplateType buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||
this.id = UUID.fromString((String) tuple.get(0).get(!base.isEmpty() ? base + "." + "id" : "id"));
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
package eu.eudat.data.entities;
|
||||
|
||||
import eu.eudat.data.converters.DateToUTCConverter;
|
||||
import eu.eudat.data.entities.helpers.EntityBinder;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Entity
|
||||
@Table(name = "\"EntityDoi\"")
|
||||
public class EntityDoi implements DataEntity<EntityDoi, UUID> {
|
||||
public enum EntityType {
|
||||
DMP
|
||||
}
|
||||
|
||||
@Id
|
||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID id;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Type(type = "eu.eudat.configurations.typedefinition.PostgreSQLEnumType")
|
||||
@Column(name = "\"EntityType\"", nullable = false)
|
||||
private EntityType entityType;
|
||||
|
||||
@Column(name = "\"RepositoryId\"", nullable = false)
|
||||
private String repositoryId;
|
||||
|
||||
@Column(name = "\"Doi\"", nullable = false)
|
||||
private String doi;
|
||||
|
||||
@Column(name = "\"CreatedAt\"", nullable = false)
|
||||
@Convert(converter = DateToUTCConverter.class)
|
||||
private Date createdAt;
|
||||
|
||||
@Column(name = "\"UpdatedAt\"", nullable = false)
|
||||
@Convert(converter = DateToUTCConverter.class)
|
||||
private Date updatedAt;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"EntityId\"", nullable = false)
|
||||
private DMP entityId;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public EntityType getEntityType() {
|
||||
return entityType;
|
||||
}
|
||||
public void setEntityType(EntityType entityType) {
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
public String getRepositoryId() {
|
||||
return repositoryId;
|
||||
}
|
||||
public void setRepositoryId(String repositoryId) {
|
||||
this.repositoryId = repositoryId;
|
||||
}
|
||||
|
||||
public String getDoi() {
|
||||
return doi;
|
||||
}
|
||||
public void setDoi(String doi) {
|
||||
this.doi = doi;
|
||||
}
|
||||
|
||||
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 DMP getEntityId() {
|
||||
return entityId;
|
||||
}
|
||||
public void setEntityId(DMP entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(EntityDoi doi) {
|
||||
this.entityType = doi.getEntityType();
|
||||
this.repositoryId = doi.getRepositoryId();
|
||||
this.doi = doi.getDoi();
|
||||
this.createdAt = doi.getCreatedAt();
|
||||
this.updatedAt = doi.getUpdatedAt();
|
||||
this.entityId = doi.getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityDoi buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||
String currentBase = base.isEmpty() ? "" : base + ".";
|
||||
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
|
||||
if (fields.contains(currentBase + "entityId"))
|
||||
this.entityId = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields , base.isEmpty() ? "entityId" : base + "." + "entityId")).collect(Collectors.toList()).get(0);
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -22,8 +22,8 @@ public class UserDatasetProfile implements DataEntity<UserDatasetProfile, UUID>
|
|||
private UserInfo user;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "\"descriptionTemplate\"")
|
||||
private DescriptionTemplate descriptionTemplate;
|
||||
@JoinColumn(name = "\"datasetProfile\"")
|
||||
private DatasetProfile datasetProfile;
|
||||
|
||||
@Column(name = "role")
|
||||
private Integer role;
|
||||
|
@ -44,12 +44,12 @@ public class UserDatasetProfile implements DataEntity<UserDatasetProfile, UUID>
|
|||
this.user = user;
|
||||
}
|
||||
|
||||
public DescriptionTemplate getDatasetProfile() {
|
||||
return descriptionTemplate;
|
||||
public DatasetProfile getDatasetProfile() {
|
||||
return datasetProfile;
|
||||
}
|
||||
|
||||
public void setDatasetProfile(DescriptionTemplate descriptionTemplate) {
|
||||
this.descriptionTemplate = descriptionTemplate;
|
||||
public void setDatasetProfile(DatasetProfile datasetProfile) {
|
||||
this.datasetProfile = datasetProfile;
|
||||
}
|
||||
|
||||
public Integer getRole() {
|
||||
|
|
|
@ -3,14 +3,12 @@ package eu.eudat.data.query.definition;
|
|||
import eu.eudat.data.dao.criteria.Criteria;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public abstract class Query<C extends Criteria<T>, T extends DataEntity> implements CriteriaQuery<C, T> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Query.class);
|
||||
private C criteria;
|
||||
@ApiModelProperty(value = "query", name = "query", dataType = "String", hidden = true)
|
||||
private QueryableList<T> query;
|
||||
|
||||
public static class QueryBuilder<C extends Criteria<T>, T extends DataEntity, Q extends Query<C, T>> {
|
||||
|
|
|
@ -6,16 +6,12 @@ import eu.eudat.data.query.definition.helpers.ColumnOrderings;
|
|||
import eu.eudat.data.query.definition.helpers.SelectionFields;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
|
||||
public abstract class TableQuery<C extends Criteria<T>, T extends DataEntity<T, K>, K> extends Query<C, T> implements TableCriteriaQuery<C, T> {
|
||||
private ColumnOrderings orderings;
|
||||
@ApiModelProperty(hidden = true)
|
||||
private SelectionFields selection;
|
||||
@ApiModelProperty(value = "length", name = "length", dataType = "Integer", example = "2")
|
||||
private Integer length;
|
||||
@ApiModelProperty(value = "offset", name = "offset", dataType = "Integer", example = "0")
|
||||
private Integer offset;
|
||||
|
||||
public Integer getLength() {
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package eu.eudat.data.query.definition.helpers;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ColumnOrderings {
|
||||
|
||||
@ApiModelProperty(value = "fields", name = "fields", dataType = "List<String>", example = "[]")
|
||||
private List<String> fields;
|
||||
|
||||
public List<String> getFields() {
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package eu.eudat.data.query.definition.helpers;
|
||||
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
public class SelectionFields {
|
||||
|
||||
@ApiModelProperty(value = "fields", name = "fields", dataType = "String[]", example = "[]")
|
||||
private String[] fields;
|
||||
|
||||
public String[] getFields() {
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package eu.eudat.data.query.items.dmpblueprint;
|
||||
|
||||
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.data.query.PaginationService;
|
||||
import eu.eudat.data.query.definition.TableQuery;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DataManagementPlanBlueprintTableRequest extends TableQuery<DataManagementPlanBlueprintCriteria, DMPProfile, UUID> {
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> applyCriteria() {
|
||||
QueryableList<DMPProfile> query = this.getQuery();
|
||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%"));
|
||||
if (this.getCriteria().getStatus() != null)
|
||||
query.where((builder, root) -> builder.equal(root.get("status"), this.getCriteria().getStatus()));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DMPProfile> applyPaging(QueryableList<DMPProfile> items) {
|
||||
return PaginationService.applyPaging(items, this);
|
||||
}
|
||||
}
|
|
@ -1,24 +1,25 @@
|
|||
package eu.eudat.data.query.items.item.datasetprofile;
|
||||
|
||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.query.PaginationService;
|
||||
import eu.eudat.data.query.definition.Query;
|
||||
import eu.eudat.data.query.definition.TableQuery;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DatasetProfileAutocompleteRequest extends TableQuery<DatasetProfileCriteria, DescriptionTemplate, UUID> {
|
||||
public class DatasetProfileAutocompleteRequest extends TableQuery<DatasetProfileCriteria,DatasetProfile, UUID> {
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> applyCriteria() {
|
||||
QueryableList<DescriptionTemplate> query = this.getQuery();
|
||||
public QueryableList<DatasetProfile> applyCriteria() {
|
||||
QueryableList<DatasetProfile> query = this.getQuery();
|
||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> applyPaging(QueryableList<DescriptionTemplate> items) {
|
||||
public QueryableList<DatasetProfile> applyPaging(QueryableList<DatasetProfile> items) {
|
||||
return PaginationService.applyPaging(items, this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
package eu.eudat.data.query.items.item.datasetprofile;
|
||||
|
||||
import eu.eudat.data.dao.criteria.DatasetProfileWizardCriteria;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.query.definition.Query;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
public class DatasetProfileWizardAutocompleteRequest extends Query<DatasetProfileWizardCriteria, DescriptionTemplate> {
|
||||
import java.util.UUID;
|
||||
|
||||
public class DatasetProfileWizardAutocompleteRequest extends Query<DatasetProfileWizardCriteria,DatasetProfile> {
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> applyCriteria() {
|
||||
public QueryableList<DatasetProfile> applyCriteria() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
package eu.eudat.data.query.items.table.datasetprofile;
|
||||
|
||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.entities.DatasetProfile;
|
||||
import eu.eudat.data.query.definition.TableQuery;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class DatasetProfileTableRequestItem extends TableQuery<DatasetProfileCriteria, DescriptionTemplate, UUID> {
|
||||
public class DatasetProfileTableRequestItem extends TableQuery<DatasetProfileCriteria, DatasetProfile, UUID> {
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> applyCriteria() {
|
||||
QueryableList<DescriptionTemplate> query = this.getQuery();
|
||||
public QueryableList<DatasetProfile> applyCriteria() {
|
||||
QueryableList<DatasetProfile> query = this.getQuery();
|
||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryableList<DescriptionTemplate> applyPaging(QueryableList<DescriptionTemplate> items) {
|
||||
public QueryableList<DatasetProfile> applyPaging(QueryableList<DatasetProfile> items) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,9 +231,7 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
if (this.group != null) {
|
||||
builder.field("group", this.group.toString());
|
||||
}
|
||||
if (this.grant != null) {
|
||||
builder.field("grant", this.grant.toString());
|
||||
}
|
||||
if (collaborators != null) {
|
||||
builder.startArray("collaborators");
|
||||
this.collaborators.forEach(x -> {
|
||||
|
@ -302,9 +300,7 @@ public class Dataset implements ElasticEntity<Dataset> {
|
|||
this.status = Short.valueOf((String) fields.get("status"));
|
||||
this.dmp = UUID.fromString((String) fields.get("dmp"));
|
||||
this.group = UUID.fromString((String) fields.get("group"));
|
||||
if (fields.get("grant") != null) {
|
||||
this.grant = UUID.fromString((String) fields.get("grant"));
|
||||
}
|
||||
if (fields.get("created") != null)
|
||||
this.created = Date.from(Instant.parse((String) fields.get("created")));
|
||||
if (fields.get("modified") != null)
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
package eu.eudat.elastic.entities;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
|
||||
private UUID id;
|
||||
private String name;
|
||||
private Map<String, Object> data;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
@ -30,25 +26,11 @@ public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
public Map<String, Object> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Map<String, Object> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
||||
builder.startObject();
|
||||
builder.field("id", this.id.toString());
|
||||
builder.field("name", this.name);
|
||||
if(this.data != null) {
|
||||
builder.field("data", new ObjectMapper().writeValueAsString(this.data));
|
||||
}
|
||||
else{
|
||||
builder.field("data", "");
|
||||
}
|
||||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
@ -57,12 +39,6 @@ public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
|
|||
public DatasetTempalate fromElasticEntity(Map<String, Object> fields) {
|
||||
this.id = UUID.fromString((String) fields.get("id"));
|
||||
this.name = (String) fields.get("name");
|
||||
try {
|
||||
this.data = new ObjectMapper().readValue((String) fields.get("data"), new TypeReference<Map<String, Object>>() {});
|
||||
}
|
||||
catch (Exception e){
|
||||
this.data = new HashMap<>();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class Dmp implements ElasticEntity<Dmp> {
|
|||
private Date modified;
|
||||
private Date finalizedAt;
|
||||
private Date publishedAt;
|
||||
private List<Doi> dois;
|
||||
private String doi;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
@ -203,12 +203,12 @@ public class Dmp implements ElasticEntity<Dmp> {
|
|||
this.publishedAt = publishedAt;
|
||||
}
|
||||
|
||||
public List<Doi> getDois() {
|
||||
return dois;
|
||||
public String getDoi() {
|
||||
return doi;
|
||||
}
|
||||
|
||||
public void setDois(List<Doi> dois) {
|
||||
this.dois = dois;
|
||||
public void setDoi(String doi) {
|
||||
this.doi = doi;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -280,17 +280,7 @@ public class Dmp implements ElasticEntity<Dmp> {
|
|||
builder.field(MapKey.MODIFIED.getName(), this.modified);
|
||||
builder.field(MapKey.FINALIZEDAT.getName(), this.finalizedAt);
|
||||
builder.field(MapKey.PUBLISHEDAT.getName(), this.publishedAt);
|
||||
if (this.dois != null && !this.dois.isEmpty()) {
|
||||
builder.startArray(MapKey.DOIS.getName());
|
||||
this.dois.forEach(doi -> {
|
||||
try {
|
||||
doi.toElasticEntity(builder);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
});
|
||||
builder.endArray();
|
||||
}
|
||||
builder.field(MapKey.DOI.getName(), this.doi);
|
||||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
@ -323,9 +313,7 @@ public class Dmp implements ElasticEntity<Dmp> {
|
|||
if (fields.get(MapKey.DATASETS.getName()) != null) {
|
||||
this.datasets = ((List<HashMap<String, Object>>) fields.get(MapKey.DATASETS.getName())).stream().map(map -> new Dataset().fromElasticEntity(map)).collect(Collectors.toList());
|
||||
}
|
||||
if (fields.containsKey(MapKey.GRANT.getName()) && fields.get(MapKey.GRANT.getName()) != null) {
|
||||
this.grant = UUID.fromString((String) fields.get(MapKey.GRANT.getName()));
|
||||
}
|
||||
if (fields.get(MapKey.GRANTSTATUS.getName()) != null) {
|
||||
this.grantStatus = Short.valueOf(fields.get(MapKey.GRANTSTATUS.getName()).toString());
|
||||
}
|
||||
|
@ -341,8 +329,8 @@ public class Dmp implements ElasticEntity<Dmp> {
|
|||
if (fields.get(MapKey.PUBLISHEDAT.getName()) != null) {
|
||||
this.publishedAt = Date.from(Instant.parse(fields.get(MapKey.PUBLISHEDAT.getName()).toString()));
|
||||
}
|
||||
if (fields.get(MapKey.DOIS.getName()) != null) {
|
||||
this.dois = ((List<HashMap<String, Object>>) fields.get(MapKey.DOIS.getName())).stream().map(map -> new Doi().fromElasticEntity(map)).collect(Collectors.toList());
|
||||
if (fields.get(MapKey.DOI.getName()) != null) {
|
||||
this.doi = fields.get(MapKey.DOI.getName()).toString();
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
@ -367,7 +355,7 @@ public class Dmp implements ElasticEntity<Dmp> {
|
|||
MODIFIED ("modified"),
|
||||
FINALIZEDAT ("finalizedAt"),
|
||||
PUBLISHEDAT ("publishedAt"),
|
||||
DOIS ("dois");
|
||||
DOI ("doi");
|
||||
|
||||
private final String name;
|
||||
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
package eu.eudat.elastic.entities;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Doi implements ElasticEntity<Doi>{
|
||||
private UUID id;
|
||||
private String repositoryId;
|
||||
private String doi;
|
||||
private UUID dmp;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getRepositoryId() {
|
||||
return repositoryId;
|
||||
}
|
||||
public void setRepositoryId(String repositoryId) {
|
||||
this.repositoryId = repositoryId;
|
||||
}
|
||||
|
||||
public String getDoi() {
|
||||
return doi;
|
||||
}
|
||||
public void setDoi(String doi) {
|
||||
this.doi = doi;
|
||||
}
|
||||
|
||||
public UUID getDmp() {
|
||||
return dmp;
|
||||
}
|
||||
public void setDmp(UUID dmp) {
|
||||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
||||
builder.startObject();
|
||||
builder.field("id", this.id.toString());
|
||||
builder.field("repositoryId", this.repositoryId);
|
||||
builder.field("doi", this.doi);
|
||||
builder.field("dmp", this.dmp.toString());
|
||||
builder.endObject();
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Doi fromElasticEntity(Map<String, Object> fields) {
|
||||
if (fields == null || fields.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
this.id = UUID.fromString((String) fields.get("id"));
|
||||
this.repositoryId = (String) fields.get("repositoryId");
|
||||
this.doi = (String) fields.get("doi");
|
||||
this.dmp = UUID.fromString((String) fields.get("dmp"));
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -146,7 +146,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
|||
|
||||
}
|
||||
|
||||
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.tags"}, null)).setSize(this.environment.getProperty("elasticsearch.innerHitsSize", Integer.class)));
|
||||
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.tags"}, null)));
|
||||
searchSourceBuilder.query(nestedQueryBuilder)/*.from(criteria.getOffset())*/.fetchSource("datasets.tags", null);
|
||||
/*if (criteria.getSize() > 0) {
|
||||
searchSourceBuilder.size(criteria.getSize());
|
||||
|
@ -206,7 +206,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
|||
|
||||
}
|
||||
|
||||
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.None).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.id"}, null)).setSize(this.environment.getProperty("elasticsearch.innerHitsSize", Integer.class)));
|
||||
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.None).innerHit(new InnerHitBuilder().setFetchSourceContext(new FetchSourceContext(true, new String[]{"datasets.id"}, null)));
|
||||
searchSourceBuilder.query(nestedQueryBuilder)/*.from(criteria.getOffset()).size(criteria.getSize())*/.fetchSource("datasets.id", null);
|
||||
sortBuilders.forEach(searchSourceBuilder::sort);
|
||||
searchRequest.source(searchSourceBuilder);
|
||||
|
@ -261,7 +261,6 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
|||
}
|
||||
|
||||
if (criteria.getDatasetTemplates() != null && criteria.getDatasetTemplates().size() > 0) {
|
||||
criteria.setDatasetTemplates(criteria.getDatasetTemplates().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.template", criteria.getDatasetTemplates().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
|
@ -270,17 +269,14 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
|||
}
|
||||
|
||||
if (criteria.getDmps() != null && criteria.getDmps().size() > 0) {
|
||||
criteria.setDmps(criteria.getDmps().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.dmp", criteria.getDmps().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
if (criteria.getGroupIds() != null && criteria.getGroupIds().size() > 0) {
|
||||
criteria.setGroupIds(criteria.getGroupIds().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.group", criteria.getGroupIds().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
if (criteria.getGrants() != null && criteria.getGrants().size() > 0) {
|
||||
criteria.setGrants(criteria.getGrants().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.grant", criteria.getGrants().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
|
@ -289,7 +285,6 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
|||
}
|
||||
|
||||
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
|
||||
criteria.setCollaborators(criteria.getCollaborators().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.collaborators.id.keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
|
@ -300,12 +295,10 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
|||
}
|
||||
|
||||
if (criteria.getOrganiztions() != null && criteria.getOrganiztions().size() > 0) {
|
||||
criteria.setOrganiztions(criteria.getOrganiztions().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.organizations.id", criteria.getOrganiztions()));
|
||||
}
|
||||
|
||||
if (criteria.getTags() != null && criteria.getTags().size() > 0) {
|
||||
criteria.setTags(criteria.getTags().stream().filter(Objects::nonNull).collect(Collectors.toList()));
|
||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.tags.name", criteria.getTags().stream().map(Tag::getName).collect(Collectors.toList())));
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ public abstract class ElasticRepository<T extends ElasticEntity,C extends Criter
|
|||
}
|
||||
} catch (IOException e) {
|
||||
logger.warn("Unable to connect to Elastic Services");
|
||||
logger.error(e.getMessage(), e);
|
||||
this.client = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<module>web</module>
|
||||
<module>data</module>
|
||||
<module>elastic</module>
|
||||
<module>roadmap</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
@ -327,18 +328,6 @@
|
|||
<packaging.type>jar</packaging.type>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>intellij-properties-launcher</id>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-loader</artifactId>
|
||||
<version>2.5.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</profile>
|
||||
<profile>
|
||||
<id>production</id>
|
||||
<properties>
|
||||
|
@ -358,6 +347,12 @@
|
|||
</property>
|
||||
</activation>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>roadmap</id>
|
||||
<properties>
|
||||
<packaging.type>jar</packaging.type>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>dmp-backend</artifactId>
|
||||
<groupId>eu.eudat</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>roadmap</artifactId>
|
||||
|
||||
<properties>
|
||||
<start-class>eu.eudat.migration.DMPRoadmapMigration</start-class>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>dmp-backend</groupId>
|
||||
<artifactId>web</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.29</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,35 @@
|
|||
package eu.eudat.migration;
|
||||
|
||||
import eu.eudat.migration.services.DMPRoadmapService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
@SpringBootApplication(
|
||||
scanBasePackages = "eu.eudat"
|
||||
)
|
||||
@ConfigurationPropertiesScan("eu.eudat.migration.properties")
|
||||
public class DMPRoadmapMigration implements CommandLineRunner {
|
||||
|
||||
private final DMPRoadmapService service;
|
||||
private static ConfigurableApplicationContext context;
|
||||
|
||||
@Autowired
|
||||
public DMPRoadmapMigration(DMPRoadmapService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
context = new SpringApplicationBuilder(DMPRoadmapMigration.class).run(args);
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
this.service.migrateUsers();
|
||||
this.service.migrate();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package eu.eudat.migration.configuration;
|
||||
|
||||
import eu.eudat.migration.properties.ConfigProperties;
|
||||
import eu.eudat.migration.properties.Database;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
@Configuration
|
||||
@EnableJpaRepositories(
|
||||
basePackages = "eu.eudat.migration.dao",
|
||||
entityManagerFactoryRef = "roadmapEntityManagerFactory",
|
||||
transactionManagerRef = "roadmapTransactionManager"
|
||||
)
|
||||
public class DMPRoadmapConfiguration {
|
||||
|
||||
private final Database database;
|
||||
|
||||
@Autowired
|
||||
public DMPRoadmapConfiguration(ConfigProperties properties) {
|
||||
this.database = properties.getDatabase();
|
||||
}
|
||||
|
||||
@Bean(name = "roadmapDataSource")
|
||||
public DataSource roadmapDataSource() {
|
||||
DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||
dataSource.setDriverClassName(Objects.requireNonNull(database.getDriver()));
|
||||
dataSource.setUrl(database.getUrl());
|
||||
dataSource.setUsername(database.getUsername());
|
||||
dataSource.setPassword(database.getPassword());
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
@Bean(name = "roadmapEntityManagerFactory")
|
||||
public LocalContainerEntityManagerFactoryBean roadmapEntityManagerFactory(@Qualifier("roadmapDataSource") DataSource roadmapDataSource) {
|
||||
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
||||
em.setDataSource(roadmapDataSource);
|
||||
em.setPackagesToScan("eu.eudat.migration.entities");
|
||||
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
|
||||
em.setJpaVendorAdapter(vendorAdapter);
|
||||
HashMap<String, Object> properties = new HashMap<>();
|
||||
properties.put("hibernate.dialect", database.getDialect());
|
||||
properties.put("hibernate.hbm2ddl.auto", "none");
|
||||
em.setJpaPropertyMap(properties);
|
||||
return em;
|
||||
}
|
||||
|
||||
@Bean(name = "roadmapTransactionManager")
|
||||
public PlatformTransactionManager roadmapTransactionManager(@Qualifier("roadmapEntityManagerFactory") LocalContainerEntityManagerFactoryBean roadmapEntityManagerFactory) {
|
||||
JpaTransactionManager transactionManager = new JpaTransactionManager();
|
||||
transactionManager.setEntityManagerFactory(roadmapEntityManagerFactory.getObject());
|
||||
return transactionManager;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package eu.eudat.migration.dao;
|
||||
|
||||
import eu.eudat.migration.entities.Template;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ConditionalOnProperty(prefix = "roadmap", name="database.url")
|
||||
public interface TemplateRepository extends JpaRepository<Template, Long> {
|
||||
|
||||
@Query(value = "SELECT DISTINCT (t.familyId) from Template t")
|
||||
List<Long> findAllGroups();
|
||||
|
||||
List<Template> findAllByFamilyId(Long familyId, Sort sort);
|
||||
}
|
|
@ -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,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,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,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;
|
||||
}
|
||||
}
|
|
@ -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,274 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
|
||||
import eu.eudat.migration.utils.JsonTypeConverter;
|
||||
import eu.eudat.migration.utils.OrganizationTypeConverter;
|
||||
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.Map;
|
||||
|
||||
@Entity
|
||||
@Table(name = "orgs")
|
||||
@SuppressWarnings("JpaAttributeTypeInspection")
|
||||
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;
|
||||
@Convert(converter = JsonTypeConverter.class)
|
||||
private Map<String, Object> 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;
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "org_id")
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private List<User> users = new ArrayList<>();
|
||||
|
||||
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 Map<String, Object> getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public void setLinks(Map<String, Object> 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;
|
||||
}
|
||||
|
||||
public List<User> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(List<User> users) {
|
||||
this.users = users;
|
||||
}
|
||||
}
|
|
@ -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,147 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import eu.eudat.models.data.admin.components.datasetprofile.Section;
|
||||
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.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@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<RoadmapSection> 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<RoadmapSection> getSections() {
|
||||
return sections;
|
||||
}
|
||||
|
||||
public void setSections(List<RoadmapSection> sections) {
|
||||
this.sections = sections;
|
||||
}
|
||||
|
||||
public List<Section> buildSections(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(s.buildFieldSets(s.getQuestions()));
|
||||
return section;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,417 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.data.dmp.DataManagementPlanEditorModel;
|
||||
import eu.eudat.models.data.dmp.Organisation;
|
||||
import eu.eudat.models.data.funder.FunderDMPEditorModel;
|
||||
import eu.eudat.models.data.grant.GrantDMPEditorModel;
|
||||
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "plans")
|
||||
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;
|
||||
@ManyToMany(cascade = CascadeType.ALL)
|
||||
@JoinTable(name = "roles",
|
||||
joinColumns = {@JoinColumn(name = "plan_id")},
|
||||
inverseJoinColumns = {@JoinColumn(name = "user_id")}
|
||||
)
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private Set<User> users = new HashSet<>();
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@JoinColumn(name = "plan_id")
|
||||
@LazyCollection(LazyCollectionOption.FALSE)
|
||||
private Set<Answer> answers = new HashSet<>();
|
||||
|
||||
public enum Visibility {
|
||||
ORGANIZATION,
|
||||
PUBLIC,
|
||||
TEST,
|
||||
PRIVATE
|
||||
}
|
||||
|
||||
public enum FundingStatus {
|
||||
PLANNED,
|
||||
FUNDED,
|
||||
DENIED
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Plan{" +
|
||||
"id=" + id +
|
||||
", title='" + title + '\'' +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", identifier='" + identifier + '\'' +
|
||||
", description='" + description + '\'' +
|
||||
", visibility=" + visibility +
|
||||
", feedbackRequested=" + feedbackRequested +
|
||||
", complete=" + complete +
|
||||
", organization=" + organization +
|
||||
", funder=" + funder +
|
||||
", startDate=" + startDate +
|
||||
", endDate=" + endDate +
|
||||
", grantId=" + grantId +
|
||||
", apiClient=" + apiClient +
|
||||
", researchDomain=" + researchDomain +
|
||||
", ethicalIssues=" + ethicalIssues +
|
||||
", ethicalIssuesDescription='" + ethicalIssuesDescription + '\'' +
|
||||
", ethicalIssuesReport='" + ethicalIssuesReport + '\'' +
|
||||
", fundingStatus=" + fundingStatus +
|
||||
", users=" + users +
|
||||
", answers=" + answers +
|
||||
'}';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Set<User> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
public void setUsers(Set<User> users) {
|
||||
this.users = users;
|
||||
}
|
||||
|
||||
public Set<Answer> getAnswers() {
|
||||
return answers;
|
||||
}
|
||||
|
||||
public void setAnswers(Set<Answer> answers) {
|
||||
this.answers = answers;
|
||||
}
|
||||
|
||||
public DataManagementPlanEditorModel buildDMP(UUID profileId, String profileLabel,
|
||||
eu.eudat.migration.properties.Entity funder,
|
||||
eu.eudat.migration.properties.Entity grant) {
|
||||
DataManagementPlanEditorModel dmpModel = new DataManagementPlanEditorModel();
|
||||
dmpModel.setAssociatedUsers(new ArrayList<>());
|
||||
dmpModel.setDatasets(new ArrayList<>());
|
||||
dmpModel.setDatasetsToBeFinalized(new ArrayList<>());
|
||||
dmpModel.setDescription(getDescription());
|
||||
dmpModel.setDynamicFields(new ArrayList<>());
|
||||
dmpModel.setExtraProperties(buildExtraProperties());
|
||||
dmpModel.setFunder(buildFunder(funder));
|
||||
dmpModel.setGrant(buildGrant(grant));
|
||||
dmpModel.setLabel(getTitle());
|
||||
dmpModel.setOrganisations(buildOrganizations());
|
||||
dmpModel.setProfiles(buildProfiles(profileId, profileLabel));
|
||||
dmpModel.setProject(buildProject());
|
||||
dmpModel.setResearchers(new ArrayList<>());
|
||||
dmpModel.setStatus(0);
|
||||
return dmpModel;
|
||||
}
|
||||
|
||||
public Map<String, Object> buildExtraProperties() {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("costs", new ArrayList<>());
|
||||
properties.put("language", "en");
|
||||
properties.put("publicDate", getCreatedAt());
|
||||
properties.put("visible", getVisibility() == Visibility.PUBLIC);
|
||||
return properties;
|
||||
}
|
||||
|
||||
public FunderDMPEditorModel buildFunder(eu.eudat.migration.properties.Entity defaultFunder) {
|
||||
FunderDMPEditorModel funder = new FunderDMPEditorModel();
|
||||
if(getFunder() != null) {
|
||||
funder.setLabel(getFunder().getName());
|
||||
funder.setReference(getFunder().getAbbreviation());
|
||||
} else {
|
||||
funder.setLabel(defaultFunder.getLabel());
|
||||
funder.setReference(defaultFunder.getReference());
|
||||
}
|
||||
return funder;
|
||||
}
|
||||
|
||||
public GrantDMPEditorModel buildGrant(eu.eudat.migration.properties.Entity defaultGrant) {
|
||||
GrantDMPEditorModel grant = new GrantDMPEditorModel();
|
||||
if(getGrantId() != null) {
|
||||
grant.setLabel(getGrantId().toString());
|
||||
grant.setReference(getGrantId().toString());
|
||||
grant.setDescription(getGrantId().toString());
|
||||
} else {
|
||||
grant.setLabel(defaultGrant.getLabel());
|
||||
grant.setReference(defaultGrant.getReference());
|
||||
grant.setDescription(defaultGrant.getDescription());
|
||||
}
|
||||
return grant;
|
||||
}
|
||||
|
||||
public List<Organisation> buildOrganizations() {
|
||||
if(getOrganization() != null) {
|
||||
Organisation organisation = new Organisation();
|
||||
organisation.setLabel(getOrganization().getName());
|
||||
organisation.setReference("Internal:" + getOrganization().getAbbreviation());
|
||||
organisation.setKey("Internal");
|
||||
return Collections.singletonList(organisation);
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public List<AssociatedProfile> buildProfiles(UUID id, String label) {
|
||||
AssociatedProfile profile = new AssociatedProfile();
|
||||
profile.setId(id);
|
||||
profile.setLabel(label);
|
||||
return Collections.singletonList(profile);
|
||||
}
|
||||
|
||||
public ProjectDMPEditorModel buildProject() {
|
||||
return new ProjectDMPEditorModel();
|
||||
}
|
||||
|
||||
public DatasetWizardModel buildDataset(UUID profileId, String profileLabel, DataManagementPlan dmp, PagedDatasetProfile pagedDatasetProfile) {
|
||||
DatasetWizardModel datasetModel = new DatasetWizardModel();
|
||||
datasetModel.setDataRepositories(new ArrayList<>());
|
||||
buildPagedDatasetProfile(pagedDatasetProfile);
|
||||
datasetModel.setDatasetProfileDefinition(pagedDatasetProfile);
|
||||
datasetModel.setDescription(this.getDescription());
|
||||
datasetModel.setDmp(dmp);
|
||||
datasetModel.setExternalDatasets(new ArrayList<>());
|
||||
datasetModel.setLabel(this.getTitle());
|
||||
DatasetProfileOverviewModel profile = new DatasetProfileOverviewModel();
|
||||
profile.setId(profileId);
|
||||
profile.setLabel(profileLabel);
|
||||
datasetModel.setProfile(profile);
|
||||
datasetModel.setRegistries(new ArrayList<>());
|
||||
datasetModel.setServices(new ArrayList<>());
|
||||
datasetModel.setTags(new ArrayList<>());
|
||||
return datasetModel;
|
||||
}
|
||||
|
||||
public void buildPagedDatasetProfile(PagedDatasetProfile pagedDatasetProfile) {
|
||||
pagedDatasetProfile.getPages().forEach(page -> {
|
||||
page.getSections().forEach(section -> {
|
||||
section.getCompositeFields().forEach(compositeField -> {
|
||||
compositeField.getFields().forEach(field -> {
|
||||
Long questionId = Question.fieldsQuestionsMap.get(field.getId());
|
||||
if( questionId != null) {
|
||||
Optional<Answer> optionalAnswer = answers.stream().filter(answer -> answer.getQuestion().getId().equals(questionId)).findFirst();
|
||||
optionalAnswer.ifPresent(answer -> {
|
||||
if(answer.getQuestion().getQuestionFormat().getOptionBased()) {
|
||||
/* TODO check with real data */
|
||||
field.setValue(answer.getText());
|
||||
} else {
|
||||
field.setValue(answer.getText());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,248 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import eu.eudat.models.data.admin.components.datasetprofile.Field;
|
||||
import eu.eudat.models.data.components.commons.DefaultValue;
|
||||
import eu.eudat.models.data.components.commons.Visibility;
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Entity
|
||||
@Table(name = "questions")
|
||||
public class Question {
|
||||
|
||||
public static Map<String, Long> fieldsQuestionsMap = new HashMap<>();
|
||||
|
||||
@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<>();
|
||||
@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() {
|
||||
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;
|
||||
}
|
||||
|
||||
public Set<Theme> getThemes() {
|
||||
return themes;
|
||||
}
|
||||
|
||||
public void setThemes(Set<Theme> themes) {
|
||||
this.themes = themes;
|
||||
}
|
||||
|
||||
public String buildDescription() {
|
||||
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();
|
||||
}
|
||||
|
||||
public List<Field> buildFields() {
|
||||
Field field = new Field();
|
||||
field.setId(String.valueOf(UUID.randomUUID()));
|
||||
field.setOrdinal(0);
|
||||
field.setDefaultValue(this.buildDefaultValue());
|
||||
field.setValue(field.getDefaultValue().getValue());
|
||||
field.setValidations(this.buildValidators());
|
||||
field.setVisible(this.buildVisibility());
|
||||
field.setViewStyle(this.getQuestionFormat().buildViewStyle());
|
||||
field.setData(this.buildData());
|
||||
fieldsQuestionsMap.put(field.getId(), getId());
|
||||
return Collections.singletonList(field);
|
||||
}
|
||||
|
||||
private DefaultValue buildDefaultValue() {
|
||||
DefaultValue defaultValue = new DefaultValue();
|
||||
defaultValue.setType("String");
|
||||
defaultValue.setValue((this.defaultValue != null)?this.defaultValue :"");
|
||||
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 Map<String, Object> buildData() {
|
||||
Map<String, Object> object = new HashMap<>();
|
||||
object.put("label", "");
|
||||
if(this.getQuestionFormat().getOptionBased()) {
|
||||
object.put("options", this.getOptions().stream().map(questionOption -> {
|
||||
Map<String, Object> option = new HashMap<>();
|
||||
option.put(questionOption.getText(), questionOption.getText());
|
||||
return option;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
if(this.getQuestionFormat().getFormattype() == QuestionFormat.FormatType.DROPDOWN ||
|
||||
this.getQuestionFormat().getFormattype() == QuestionFormat.FormatType.MULTI_SELECT) {
|
||||
object.put("type", "wordlist");
|
||||
object.put("multiList", this.getQuestionFormat().getFormattype() == QuestionFormat.FormatType.MULTI_SELECT);
|
||||
}
|
||||
return object;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import eu.eudat.models.data.components.commons.ViewStyle;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public ViewStyle buildViewStyle() {
|
||||
ViewStyle viewStyle = new ViewStyle();
|
||||
viewStyle.setCssClass("");
|
||||
switch (formattype) {
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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,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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,148 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import eu.eudat.models.data.admin.components.datasetprofile.FieldSet;
|
||||
import eu.eudat.models.data.components.commons.Multiplicity;
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Entity
|
||||
@Table(name = "sections")
|
||||
public class RoadmapSection {
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
public 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(question.buildDescription());
|
||||
fieldSet.setOrdinal(Math.toIntExact(question.getNumber()) - 1);
|
||||
fieldSet.setMultiplicity(this.buildMultiplicity());
|
||||
fieldSet.setHasCommentField(question.getOptionCommentDisplay());
|
||||
fieldSet.setFields(question.buildFields());
|
||||
return fieldSet;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Multiplicity buildMultiplicity() {
|
||||
Multiplicity multiplicity = new Multiplicity();
|
||||
multiplicity.setPlaceholder("");
|
||||
return multiplicity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,254 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import eu.eudat.migration.utils.JsonTypeConverter;
|
||||
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 org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "templates")
|
||||
@SuppressWarnings("JpaAttributeTypeInspection")
|
||||
public class Template {
|
||||
|
||||
@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 Short version;
|
||||
private Visibility visibility;
|
||||
@Column(name = "customization_of")
|
||||
private Long customizationOf;
|
||||
@Column(name = "family_id")
|
||||
private Long familyId;
|
||||
private Boolean archived;
|
||||
@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,
|
||||
PUBLIC
|
||||
}
|
||||
|
||||
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 Boolean getPublished() {
|
||||
return published;
|
||||
}
|
||||
|
||||
public void setPublished(Boolean published) {
|
||||
this.published = published;
|
||||
}
|
||||
|
||||
|
||||
public Organization getOrganization() {
|
||||
return organization;
|
||||
}
|
||||
|
||||
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 Short getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(Short version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
||||
public Visibility getVisibility() {
|
||||
return visibility;
|
||||
}
|
||||
|
||||
public void setVisibility(Visibility visibility) {
|
||||
this.visibility = visibility;
|
||||
}
|
||||
|
||||
|
||||
public Long getCustomizationOf() {
|
||||
return customizationOf;
|
||||
}
|
||||
|
||||
public void setCustomizationOf(Long customizationOf) {
|
||||
this.customizationOf = customizationOf;
|
||||
}
|
||||
|
||||
|
||||
public Long getFamilyId() {
|
||||
return familyId;
|
||||
}
|
||||
|
||||
public void setFamilyId(Long familyId) {
|
||||
this.familyId = familyId;
|
||||
}
|
||||
|
||||
|
||||
public Boolean getArchived() {
|
||||
return archived;
|
||||
}
|
||||
|
||||
public void setArchived(Boolean archived) {
|
||||
this.archived = archived;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Object> getLinks() {
|
||||
return links;
|
||||
}
|
||||
|
||||
public void setLinks(Map<String, Object> links) {
|
||||
this.links = links;
|
||||
}
|
||||
|
||||
public Boolean getDefault() {
|
||||
return isDefault;
|
||||
}
|
||||
|
||||
public void setDefault(Boolean aDefault) {
|
||||
isDefault = aDefault;
|
||||
}
|
||||
|
||||
public List<Phase> getPhases() {
|
||||
return phases;
|
||||
}
|
||||
|
||||
public void setPhases(List<Phase> phases) {
|
||||
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 +
|
||||
", organization=" + organization +
|
||||
", locale='" + locale + '\'' +
|
||||
", isDefault=" + isDefault +
|
||||
", createdAt=" + createdAt +
|
||||
", updatedAt=" + updatedAt +
|
||||
", version=" + version +
|
||||
", visibility=" + visibility +
|
||||
", customizationOf=" + customizationOf +
|
||||
", familyId=" + familyId +
|
||||
", archived=" + archived +
|
||||
", links=" + links +
|
||||
", phases=" + phases +
|
||||
", plans=" + plans +
|
||||
'}';
|
||||
}
|
||||
|
||||
public DatasetProfile buildDatasetProfile() {
|
||||
DatasetProfile datasetProfile = new DatasetProfile();
|
||||
datasetProfile.setLabel(this.getTitle());
|
||||
datasetProfile.setDescription(this.getDescription());
|
||||
datasetProfile.setLanguage(this.getLocale());
|
||||
datasetProfile.setStatus((short) 1);
|
||||
datasetProfile.setVersion(getVersion());
|
||||
datasetProfile.setUsers(new ArrayList<>());
|
||||
this.buildPages(datasetProfile);
|
||||
return datasetProfile;
|
||||
}
|
||||
|
||||
public void buildPages(DatasetProfile datasetProfile) {
|
||||
List<Page> pages = new ArrayList<>();
|
||||
List<Section> sections = new ArrayList<>();
|
||||
this.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(phase.buildSections(page.getId()));
|
||||
});
|
||||
datasetProfile.setPages(pages);
|
||||
datasetProfile.setSections(sections);
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
package eu.eudat.migration.entities;
|
||||
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.data.entities.UserToken;
|
||||
import eu.eudat.logic.builders.entity.UserTokenBuilder;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import org.hibernate.annotations.LazyCollection;
|
||||
import org.hibernate.annotations.LazyCollectionOption;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
public UserInfo buildUserInfo() {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setEmail(getEmail());
|
||||
userInfo.setName(getFirstname() + " " + getSurname());
|
||||
userInfo.setUsertype((short) 0);
|
||||
userInfo.setUserStatus((short) 0);
|
||||
userInfo.setAuthorization_level((short) 1);
|
||||
userInfo.setVerified_email(true);
|
||||
userInfo.setCreated(getCreatedAt());
|
||||
return userInfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package eu.eudat.migration.properties;
|
||||
|
||||
public class Argos {
|
||||
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package eu.eudat.migration.properties;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "roadmap")
|
||||
public class ConfigProperties {
|
||||
private Database database;
|
||||
private DefaultEntities entities;
|
||||
|
||||
public Database getDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public void setDatabase(Database database) {
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
public DefaultEntities getEntities() {
|
||||
return entities;
|
||||
}
|
||||
|
||||
public void setEntities(DefaultEntities entities) {
|
||||
this.entities = entities;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package eu.eudat.migration.properties;
|
||||
|
||||
public class Database {
|
||||
private String driver;
|
||||
private String url;
|
||||
private String username;
|
||||
private String password;
|
||||
private String dialect;
|
||||
|
||||
public String getDriver() {
|
||||
return driver;
|
||||
}
|
||||
|
||||
public void setDriver(String driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getDialect() {
|
||||
return dialect;
|
||||
}
|
||||
|
||||
public void setDialect(String dialect) {
|
||||
this.dialect = dialect;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package eu.eudat.migration.properties;
|
||||
|
||||
public class DefaultEntities {
|
||||
private Entity funder;
|
||||
private Entity grant;
|
||||
private User user;
|
||||
|
||||
public Entity getFunder() {
|
||||
return funder;
|
||||
}
|
||||
|
||||
public void setFunder(Entity funder) {
|
||||
this.funder = funder;
|
||||
}
|
||||
|
||||
public Entity getGrant() {
|
||||
return grant;
|
||||
}
|
||||
|
||||
public void setGrant(Entity grant) {
|
||||
this.grant = grant;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package eu.eudat.migration.properties;
|
||||
|
||||
public class Entity {
|
||||
public String reference;
|
||||
public String label;
|
||||
public String description;
|
||||
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package eu.eudat.migration.properties;
|
||||
|
||||
public class User {
|
||||
private String email;
|
||||
private String name;
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,156 @@
|
|||
package eu.eudat.migration.services;
|
||||
|
||||
import eu.eudat.controllers.Datasets;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.data.entities.UserRole;
|
||||
import eu.eudat.data.entities.UserToken;
|
||||
import eu.eudat.logic.builders.entity.UserTokenBuilder;
|
||||
import eu.eudat.logic.managers.AdminManager;
|
||||
import eu.eudat.logic.managers.DataManagementPlanManager;
|
||||
import eu.eudat.logic.managers.DatasetProfileManager;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.operations.authentication.NonVerifiedUserEmailAuthenticationService;
|
||||
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.data.dmp.DataManagementPlanEditorModel;
|
||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.types.Authorities;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class ArgosService {
|
||||
|
||||
private final ApiContext context;
|
||||
private final NonVerifiedUserEmailAuthenticationService authenticationService;
|
||||
private final DataManagementPlanManager dataManagementPlanManager;
|
||||
private final DatasetProfileManager datasetProfileManager;
|
||||
private final Datasets datasets;
|
||||
|
||||
@Autowired
|
||||
public ArgosService(ApiContext context,
|
||||
NonVerifiedUserEmailAuthenticationService authenticationService,
|
||||
DatasetProfileManager datasetProfileManager,
|
||||
DataManagementPlanManager dataManagementPlanManager,
|
||||
Datasets datasets) {
|
||||
this.context = context;
|
||||
this.authenticationService = authenticationService;
|
||||
this.datasetProfileManager = datasetProfileManager;
|
||||
this.dataManagementPlanManager = dataManagementPlanManager;
|
||||
this.datasets = datasets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auth methods
|
||||
*/
|
||||
@Transactional
|
||||
public UserInfo getUserInfo(String email) {
|
||||
QueryableList<UserInfo> query = context.getOperationsContext().getDatabaseRepository().getUserInfoDao().asQueryable();
|
||||
query.where((builder, root) -> builder.equal(root.get("email"), email));
|
||||
return query.getSingleOrDefault();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void createUserInfo(UserInfo userInfo) {
|
||||
if (getUserInfo(userInfo.getEmail()) == null) {
|
||||
context.getOperationsContext().getDatabaseRepository().getUserInfoDao().createOrUpdate(userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public Principal login(UserInfo userInfo) {
|
||||
Principal principal = new Principal();
|
||||
principal.setId(userInfo.getId());
|
||||
return principal;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void assignRole(UserInfo userInfo, Authorities authority) {
|
||||
QueryableList<UserRole> query = context.getOperationsContext().getDatabaseRepository().getUserRoleDao().asQueryable();
|
||||
query.where((builder, root) -> builder.equal(root.get("userInfo").get("id"), userInfo.getId()));
|
||||
if(query.getSingleOrDefault() == null) {
|
||||
UserRole role = new UserRole();
|
||||
role.setUserInfo(userInfo);
|
||||
role.setRole(authority.getValue());
|
||||
context.getOperationsContext().getDatabaseRepository().getUserRoleDao().createOrUpdate(role);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Dataset Profiles
|
||||
*/
|
||||
@Transactional
|
||||
public UUID createDatasetProfile(DatasetProfile datasetProfile, Principal principal) {
|
||||
return this.datasetProfileManager.addDmp(datasetProfile, principal, false).getId();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public UUID createNewVersionDatasetProfile(UUID id, DatasetProfile datasetProfile) throws Exception {
|
||||
return this.datasetProfileManager.createNewVersionDatasetProfile(id.toString(), datasetProfile, false).getId();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteDatasetProfile(UUID id) {
|
||||
AdminManager.inactivate(context.getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), context.getOperationsContext().getDatabaseRepository().getDatasetDao(), id.toString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DMP methods
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
public DataManagementPlan createDMP(DataManagementPlanEditorModel model, Principal principal) throws Exception {
|
||||
return new eu.eudat.models.data.dmp.DataManagementPlan().
|
||||
fromDataModel(this.dataManagementPlanManager.createOrUpdate(model, principal));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void updateUsers(UUID id, List<UserInfoListingModel> users, Principal principal) throws Exception {
|
||||
this.dataManagementPlanManager.updateUsers(id, users, principal);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteDMP(UUID id) {
|
||||
try {
|
||||
this.dataManagementPlanManager.delete(id);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dataset Methods
|
||||
*/
|
||||
@Transactional
|
||||
public PagedDatasetProfile getDataset(UUID id) {
|
||||
return Objects.requireNonNull(this.datasets.getSingle(id.toString()).getBody()).getPayload();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public DatasetWizardModel createDataset(DatasetWizardModel model, Principal principal) throws Exception {
|
||||
return Objects.requireNonNull(this.datasets.createOrUpdate(model, principal).getBody()).getPayload();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteDataset(UUID id, Principal principal) {
|
||||
try {
|
||||
this.datasets.delete(id, principal);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,168 @@
|
|||
package eu.eudat.migration.services;
|
||||
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.migration.dao.TemplateRepository;
|
||||
import eu.eudat.migration.dao.UserRepository;
|
||||
import eu.eudat.migration.entities.Perm;
|
||||
import eu.eudat.migration.entities.Plan;
|
||||
import eu.eudat.migration.entities.Template;
|
||||
import eu.eudat.migration.entities.User;
|
||||
import eu.eudat.migration.properties.ConfigProperties;
|
||||
import eu.eudat.migration.properties.DefaultEntities;
|
||||
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.data.dmp.DataManagementPlanEditorModel;
|
||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.types.Authorities;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Service
|
||||
public class DMPRoadmapService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DMPRoadmapService.class);
|
||||
|
||||
/**
|
||||
* DMPRoadmap Repositories
|
||||
*/
|
||||
private final TemplateRepository templateRepository;
|
||||
private final UserRepository userRepository;
|
||||
/**
|
||||
* Default Entities
|
||||
*/
|
||||
private final DefaultEntities defaultEntities;
|
||||
/**
|
||||
* Services
|
||||
*/
|
||||
private final ArgosService argosService;
|
||||
/**
|
||||
* Metadata
|
||||
*/
|
||||
private final List<UUID> datasetProfiles = new ArrayList<>();
|
||||
private final List<UUID> dmps = new ArrayList<>();
|
||||
private final List<UUID> datasets = new ArrayList<>();
|
||||
private Principal principal;
|
||||
|
||||
@Autowired
|
||||
public DMPRoadmapService(TemplateRepository templateRepository, UserRepository userRepository, ArgosService argosService, ConfigProperties properties) {
|
||||
this.templateRepository = templateRepository;
|
||||
this.userRepository = userRepository;
|
||||
this.defaultEntities = properties.getEntities();
|
||||
this.argosService = argosService;
|
||||
}
|
||||
|
||||
public void migrateUsers() {
|
||||
this.argosService.createUserInfo(Objects.requireNonNull(defaultUser()));
|
||||
List<User> users = this.userRepository.findAll();
|
||||
users.forEach(user -> {
|
||||
logger.info("Create user with email: " + user.getEmail());
|
||||
this.argosService.createUserInfo(user.buildUserInfo());
|
||||
});
|
||||
}
|
||||
|
||||
public void migrate() {
|
||||
try {
|
||||
List<UserInfo> users = this.userRepository.findAll().stream().filter(user ->
|
||||
user.getPerms().stream().map(Perm::getName).collect(Collectors.toList()).contains("modify_templates")).map(user ->
|
||||
this.argosService.getUserInfo(user.getEmail())
|
||||
).collect(Collectors.toList());
|
||||
UserInfo userInfo = this.argosService.getUserInfo(users.size() > 0 ? users.get(0).getEmail() : defaultEntities.getUser().getEmail());
|
||||
for (Long group : templateRepository.findAllGroups()) {
|
||||
List<Template> templates = templateRepository.findAllByFamilyId(group, Sort.by(Sort.Direction.ASC, "version"));
|
||||
UUID id = null;
|
||||
for (Template template : templates) {
|
||||
this.argosService.assignRole(userInfo, Authorities.DATASET_PROFILE_MANAGER);
|
||||
this.principal = this.argosService.login(userInfo);
|
||||
DatasetProfile datasetProfile = template.buildDatasetProfile();
|
||||
if (id == null) {
|
||||
if (users.size() > 1) {
|
||||
datasetProfile.setUsers(users.subList(1, users.size()).stream().map(info -> {
|
||||
UserInfoListingModel model = new UserInfoListingModel();
|
||||
model.setId(info.getId());
|
||||
return model;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
logger.info("Create Dataset Profile with label: " + datasetProfile.getLabel());
|
||||
id = this.argosService.createDatasetProfile(datasetProfile, principal);
|
||||
} else {
|
||||
if (users.size() > 0) {
|
||||
datasetProfile.setUsers(users.stream().map(info -> {
|
||||
UserInfoListingModel model = new UserInfoListingModel();
|
||||
model.setId(info.getId());
|
||||
return model;
|
||||
}).collect(Collectors.toList()));
|
||||
} else {
|
||||
datasetProfile.setUsers(Stream.of(userInfo).map(info -> {
|
||||
UserInfoListingModel model = new UserInfoListingModel();
|
||||
model.setId(info.getId());
|
||||
return model;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
logger.info("Create a new version of Dataset Profiles with label: " + datasetProfile.getLabel());
|
||||
id = this.argosService.createNewVersionDatasetProfile(id, datasetProfile);
|
||||
}
|
||||
this.datasetProfiles.add(id);
|
||||
for (Plan plan : template.getPlans()) {
|
||||
DataManagementPlanEditorModel dataManagementPlanEditorModel = plan.buildDMP(id, datasetProfile.getLabel(), defaultEntities.getFunder(), defaultEntities.getGrant());
|
||||
List<UserInfo> collaborators = plan.getUsers().stream().map(user -> this.argosService.getUserInfo(user.getEmail())).collect(Collectors.toList());
|
||||
Principal principal = this.principal;
|
||||
if (collaborators.size() > 0) {
|
||||
principal = this.argosService.login(collaborators.get(0));
|
||||
}
|
||||
logger.info("Create DMP and its Dataset with label: " + dataManagementPlanEditorModel.getLabel());
|
||||
DataManagementPlan dmp = this.argosService.createDMP(dataManagementPlanEditorModel, principal);
|
||||
this.dmps.add(dmp.getId());
|
||||
if (collaborators.size() > 1) {
|
||||
List<UserInfoListingModel> modelList = collaborators.subList(1, collaborators.size()).stream().map(user -> {
|
||||
UserInfoListingModel model = new UserInfoListingModel();
|
||||
model.setId(user.getId());
|
||||
return model;
|
||||
}).collect(Collectors.toList());
|
||||
this.argosService.updateUsers(dmp.getId(), modelList, principal);
|
||||
}
|
||||
DatasetWizardModel dataset = plan.buildDataset(id, datasetProfile.getLabel(), dmp, this.argosService.getDataset(id));
|
||||
dataset = this.argosService.createDataset(dataset, principal);
|
||||
this.datasets.add(dataset.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("Migration Failed. All data will be deleted.");
|
||||
this.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
logger.info("Deleting Datasets");
|
||||
this.datasets.forEach(id -> this.argosService.deleteDataset(id, this.principal));
|
||||
logger.info("Deleting DMPs");
|
||||
this.dmps.forEach(this.argosService::deleteDMP);
|
||||
logger.info("Deleting Dataset Profiles");
|
||||
this.datasetProfiles.forEach(this.argosService::deleteDatasetProfile);
|
||||
}
|
||||
|
||||
private UserInfo defaultUser() {
|
||||
eu.eudat.migration.properties.User user = defaultEntities.getUser();
|
||||
if (user != null && user.getEmail() != null && user.getName() != null) {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setEmail(user.getEmail());
|
||||
userInfo.setName(user.getName());
|
||||
userInfo.setUsertype((short) 0);
|
||||
userInfo.setUserStatus((short) 0);
|
||||
userInfo.setAuthorization_level((short) 1);
|
||||
userInfo.setVerified_email(false);
|
||||
userInfo.setCreated(new Date());
|
||||
return userInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
#################### DMP ROADMAP DATABASE CONFIGURATION (Postgres or MySQL) Last Database Migration: 15-03-2022 ##########
|
||||
#roadmap.database.driver=org.postgresql.Driver
|
||||
roadmap.database.driver=com.mysql.jdbc.Driver
|
||||
roadmap.database.url=jdbc:mysql://localhost:3306/dmp
|
||||
roadmap.database.username=dmp
|
||||
roadmap.database.password=dmp
|
||||
roadmap.database.dialect=org.hibernate.dialect.MySQL5Dialect
|
||||
#roadmap.database.dialect=org.hibernate.dialect.PostgreSQL92Dialect
|
||||
|
||||
## Default entities ##
|
||||
roadmap.entities.funder.reference=no_funder
|
||||
roadmap.entities.funder.label=No funder
|
||||
roadmap.entities.grant.reference=no_grant
|
||||
roadmap.entities.grant.label=No grant
|
||||
roadmap.entities.grant.description=No grant available
|
||||
roadmap.entities.user.email=dmp@roadmap.com
|
||||
roadmap.entities.user.name=DMP Roadmap
|
|
@ -26,16 +26,13 @@
|
|||
<artifactId>queryable</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>eu.eudat</groupId>
|
||||
<artifactId>elastic</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gr.cite.opendmp</groupId>
|
||||
<artifactId>repositorydepositbase</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
|
@ -46,10 +43,6 @@
|
|||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||
|
||||
|
@ -198,7 +191,9 @@
|
|||
<version>3.0.0-M2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>devel</id>
|
||||
<build>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<resources>
|
||||
|
@ -226,40 +221,79 @@
|
|||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>1.5.9.RELEASE</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<start-class>eu.eudat.EuDatApplication</start-class>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>production</id>
|
||||
<build>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/ui-resources</directory>
|
||||
<excludes>
|
||||
<exclude>node_modules/**</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>true</addClasspath>
|
||||
<mainClass>eu.eudat.EuDatApplication</mainClass>
|
||||
<classpathPrefix>dependency-jars/</classpathPrefix>
|
||||
</manifest>
|
||||
</archive>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<start-class>eu.eudat.EuDatApplication</start-class>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
<build>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/ui-resources</directory>
|
||||
<excludes>
|
||||
<exclude>node_modules/**</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<outputDirectory>
|
||||
${project.build.directory}/dependency-jars/
|
||||
</outputDirectory>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
|
|
@ -8,7 +8,7 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
|
|||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
|
||||
@SpringBootApplication(scanBasePackages = {"eu.eudat", "eu.eudat.depositinterface"})
|
||||
@SpringBootApplication
|
||||
@EnableAsync
|
||||
public class EuDatApplication extends SpringBootServletInitializer {
|
||||
private static final Logger logger = LoggerFactory.getLogger(EuDatApplication.class);
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.springframework.boot.jdbc.DataSourceBuilder;
|
|||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.JpaVendorAdapter;
|
||||
|
@ -29,12 +30,14 @@ public class DevelDatabaseConfiguration {
|
|||
private Environment env;
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
||||
em.setDataSource(dataSource());
|
||||
em.setPackagesToScan(new String[]{"eu.eudat.data.entities"});
|
||||
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
|
||||
em.setJpaVendorAdapter(vendorAdapter);
|
||||
em.setPersistenceUnitName("entityManager");
|
||||
em.setJpaProperties(additionalProperties());
|
||||
return em;
|
||||
}
|
||||
|
@ -53,6 +56,7 @@ public class DevelDatabaseConfiguration {
|
|||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
|
||||
JpaTransactionManager transactionManager = new JpaTransactionManager();
|
||||
transactionManager.setEntityManagerFactory(emf);
|
||||
|
|
|
@ -4,7 +4,6 @@ import org.apache.http.HttpHost;
|
|||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.http.client.CredentialsProvider;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
|
||||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
|
||||
|
@ -73,34 +72,29 @@ public class ElasticSearchConfiguration {
|
|||
RestHighLevelClient client;
|
||||
if(this.environment.getProperty("elasticsearch.usingssl", Boolean.class)){
|
||||
|
||||
// Path caCertificatePath = Paths.get(this.environment.getProperty("elasticsearch.certPath"));
|
||||
// CertificateFactory factory =
|
||||
// CertificateFactory.getInstance("X.509");
|
||||
// Certificate trustedCa;
|
||||
// try (InputStream is = Files.newInputStream(caCertificatePath)) {
|
||||
// trustedCa = factory.generateCertificate(is);
|
||||
// }
|
||||
// KeyStore trustStore = KeyStore.getInstance("pkcs12");
|
||||
// trustStore.load(null, null);
|
||||
// trustStore.setCertificateEntry("ca", trustedCa);
|
||||
//
|
||||
// TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
// tmf.init(trustStore);
|
||||
//
|
||||
// SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
// sslContext.init(null, tmf.getTrustManagers(), null);
|
||||
Path caCertificatePath = Paths.get(this.environment.getProperty("elasticsearch.certPath"));
|
||||
CertificateFactory factory =
|
||||
CertificateFactory.getInstance("X.509");
|
||||
Certificate trustedCa;
|
||||
try (InputStream is = Files.newInputStream(caCertificatePath)) {
|
||||
trustedCa = factory.generateCertificate(is);
|
||||
}
|
||||
KeyStore trustStore = KeyStore.getInstance("pkcs12");
|
||||
trustStore.load(null, null);
|
||||
trustStore.setCertificateEntry("ca", trustedCa);
|
||||
|
||||
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||
tmf.init(trustStore);
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, tmf.getTrustManagers(), null);
|
||||
|
||||
SSLContextBuilder sslBuilder = SSLContexts.custom()
|
||||
.loadTrustMaterial(null, (x509Certificates, s) -> true);
|
||||
final SSLContext sslContext = sslBuilder.build();
|
||||
client = new RestHighLevelClient(
|
||||
RestClient.builder(
|
||||
new HttpHost(this.environment.getProperty("elasticsearch.host"),
|
||||
Integer.parseInt(this.environment.getProperty("elasticsearch.port")), "https"))
|
||||
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
|
||||
.setDefaultCredentialsProvider(credentialsProvider).setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).setSSLContext(sslContext))
|
||||
.setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(5000).setSocketTimeout(120000))
|
||||
);
|
||||
.setDefaultCredentialsProvider(credentialsProvider).setSSLContext(sslContext)));
|
||||
}
|
||||
else {
|
||||
client = new RestHighLevelClient(
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package eu.eudat.configurations;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.context.annotation.*;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
|
||||
import org.springframework.jdbc.datasource.DriverManagerDataSource;
|
||||
|
@ -32,18 +29,20 @@ public class ProductionDatabaseConfiguration {
|
|||
private Environment env;
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
|
||||
em.setDataSource(dataSource());
|
||||
em.setPackagesToScan(new String[]{"eu.eudat.data.entities"});
|
||||
JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
|
||||
em.setJpaVendorAdapter(vendorAdapter);
|
||||
em.setPersistenceUnitName("entityManager");
|
||||
em.setJpaProperties(additionalProperties());
|
||||
|
||||
return em;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public DataSource dataSource() {
|
||||
DriverManagerDataSource dataSource = new DriverManagerDataSource();
|
||||
dataSource.setDriverClassName(env.getProperty("database.driver-class-name"));
|
||||
|
@ -54,6 +53,7 @@ public class ProductionDatabaseConfiguration {
|
|||
}
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
|
||||
JpaTransactionManager transactionManager = new JpaTransactionManager();
|
||||
transactionManager.setEntityManagerFactory(emf);
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.logic.managers.MaterialManager;
|
||||
import eu.eudat.logic.managers.MetricsManager;
|
||||
import eu.eudat.types.MetricNames;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/material/about/"})
|
||||
public class AboutController {
|
||||
|
||||
private Environment environment;
|
||||
private MaterialManager materialManager;
|
||||
|
||||
@Autowired
|
||||
public AboutController(Environment environment, MaterialManager materialManager, MetricsManager metricsManager) {
|
||||
this.environment = environment;
|
||||
this.materialManager = materialManager;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "{lang}", method = RequestMethod.GET )
|
||||
public ResponseEntity<byte[]> getAbout(@PathVariable(name = "lang") String lang) throws IOException {
|
||||
try (Stream<Path> paths = Files.walk(Paths.get(Objects.requireNonNull(this.environment.getProperty("about.path"))))) {
|
||||
return this.materialManager.getResponseEntity(lang, paths);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.entities.UserDatasetProfile;
|
||||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||
|
@ -17,6 +16,7 @@ import eu.eudat.models.data.admin.composite.DatasetProfile;
|
|||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
|
@ -57,44 +57,15 @@ public class Admin extends BaseController {
|
|||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN ,DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
|
||||
//this.getLoggerService().info(principal, "Admin Added Dataset Profile");
|
||||
DatasetProfile shortenProfile = profile.toShort();
|
||||
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
||||
modelDefinition.setType(getApiContext().getOperationsContext().getDatabaseRepository().getDescriptionTemplateTypeDao().findFromName(profile.getType()));
|
||||
modelDefinition.setGroupId(UUID.randomUUID());
|
||||
modelDefinition.setVersion((short) 0);
|
||||
|
||||
DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
UserDatasetProfile userDatasetProfile = new UserDatasetProfile();
|
||||
userDatasetProfile.setDatasetProfile(descriptionTemplate);
|
||||
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||
userDatasetProfile.setUser(userInfo);
|
||||
userDatasetProfile.setRole(0);
|
||||
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||
datasetProfileManager.storeDatasetProfileUsers(descriptionTemplate, profile);
|
||||
|
||||
metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricsManager.datasetTemplateStatus.get(descriptionTemplate.getStatus()) );
|
||||
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
||||
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN ,DATASET_PROFILE_MANAGER}) Principal principal) {
|
||||
eu.eudat.data.entities.DatasetProfile datasetProfile = this.datasetProfileManager.addDmp(profile, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(datasetProfile.getId());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
|
||||
DatasetProfile shortenProfile = profile.toShort();
|
||||
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
||||
DescriptionTemplate datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
datasetprofile.setDefinition(modelDefinition.getDefinition());
|
||||
Short oldStatus = datasetprofile.getStatus();
|
||||
datasetprofile.setStatus(modelDefinition.getStatus());
|
||||
datasetprofile.setLabel(modelDefinition.getLabel());
|
||||
datasetprofile.setDescription(modelDefinition.getDescription());
|
||||
datasetprofile.setLanguage(modelDefinition.getLanguage());
|
||||
DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
|
||||
datasetProfileManager.storeDatasetProfileUsers(descriptionTemplate, profile);
|
||||
if (descriptionTemplate.getStatus() == 1 && oldStatus == 0) {
|
||||
metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricNames.ACTIVE);
|
||||
}
|
||||
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
||||
this.datasetProfileManager.updateDmp(id, profile);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
|
@ -102,7 +73,7 @@ public class Admin extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/newVersion/{id}"}, produces = "application/json")
|
||||
public ResponseEntity newVersionDatasetProfile(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
|
||||
try {
|
||||
DescriptionTemplate modelDefinition = this.datasetProfileManager.createNewVersionDatasetProfile(id, profile);
|
||||
eu.eudat.data.entities.DatasetProfile modelDefinition = this.datasetProfileManager.createNewVersionDatasetProfile(id, profile);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
||||
} catch (DatasetProfileNewVersionException exception) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
||||
|
@ -124,8 +95,8 @@ public class Admin extends BaseController {
|
|||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/preview"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
|
||||
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
||||
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(modelDefinition);
|
||||
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
||||
pagedDatasetProfile.buildPagedDatasetProfile(datasetProfile);
|
||||
|
@ -145,7 +116,7 @@ public class Admin extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DatasetProfile>> inactivate(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
||||
try {
|
||||
DescriptionTemplate ret = AdminManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id);
|
||||
eu.eudat.data.entities.DatasetProfile ret = AdminManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
} catch (DatasetProfileWithDatasetsExeption exception) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.UNSUCCESS_DELETE).message(exception.getMessage()));
|
||||
|
@ -156,12 +127,11 @@ public class Admin extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
|
||||
public ResponseEntity getDatasetProfileXml(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws IllegalAccessException, IOException, InstantiationException {
|
||||
if (contentType.equals("application/xml")) {
|
||||
DescriptionTemplate profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(profile);
|
||||
datasetProfile.setStatus(profile.getStatus());
|
||||
datasetProfile.setDescription(profile.getDescription());
|
||||
datasetProfile.setLanguage(profile.getLanguage());
|
||||
datasetProfile.setType(profile.getType().getName());
|
||||
return this.datasetProfileManager.getDocument(datasetProfile, profile.getLabel());
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
||||
|
@ -174,12 +144,12 @@ public class Admin extends BaseController {
|
|||
@ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
|
||||
eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile datasetProfileModel = this.datasetProfileManager.createDatasetProfileFromXml(file);
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetProfileEntity = datasetProfileModel.toAdminCompositeModel(file.getOriginalFilename());
|
||||
DescriptionTemplate modelDefinition;
|
||||
eu.eudat.data.entities.DatasetProfile modelDefinition;
|
||||
if (id == null) {
|
||||
modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext());
|
||||
DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
UserDatasetProfile userDatasetProfile = new UserDatasetProfile();
|
||||
userDatasetProfile.setDatasetProfile(descriptionTemplate);
|
||||
userDatasetProfile.setDatasetProfile(datasetProfile);
|
||||
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||
userDatasetProfile.setUser(userInfo);
|
||||
userDatasetProfile.setRole(0);
|
||||
|
@ -187,14 +157,12 @@ public class Admin extends BaseController {
|
|||
} else {
|
||||
modelDefinition = datasetProfileManager.createNewVersionDatasetProfile(id, datasetProfileEntity);
|
||||
}
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DescriptionTemplate>>()
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>()
|
||||
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getSemantics"}, produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<List<String>>> getSemantics(@RequestParam(value = "query", required = false) String query, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
||||
List<String> semantics = this.datasetProfileManager.getSemantics(query);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<String>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(semantics));
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getRDACommonStandards"}, produces = "application/json")
|
||||
public ResponseEntity getRDACommonStandards(@ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<String>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(configLoader.getRdaProperties()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,7 @@ package eu.eudat.controllers;
|
|||
|
||||
import eu.eudat.data.dao.criteria.RequestItem;
|
||||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest;
|
||||
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
||||
import eu.eudat.exceptions.dmpblueprint.DmpBlueprintUsedException;
|
||||
import eu.eudat.logic.managers.DataManagementProfileManager;
|
||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
|
@ -13,7 +10,6 @@ import eu.eudat.models.data.helpermodels.Tuple;
|
|||
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
|
||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel;
|
||||
import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
|
@ -30,7 +26,6 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
|
||||
import static eu.eudat.types.Authorities.ADMIN;
|
||||
import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 3/21/2018.
|
||||
|
@ -56,14 +51,6 @@ public class DMPProfileController extends BaseController {
|
|||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMPProfile>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/blueprint"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMPProfile>> createOrUpdateBlueprint(@RequestBody DataManagementPlanBlueprintListingModel dataManagementPlan, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||
this.dataManagementProfileManager.createOrUpdateBlueprint(dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMPProfile>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataManagementPlanProfileListingModel>> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||
|
@ -71,13 +58,6 @@ public class DMPProfileController extends BaseController {
|
|||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanProfileListingModel));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getSingleBlueprint/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataManagementPlanBlueprintListingModel>> getSingleBlueprint(@PathVariable String id, Principal principal) {
|
||||
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanBlueprintListingModel));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest, Principal principal) throws Exception {
|
||||
|
@ -85,51 +65,24 @@ public class DMPProfileController extends BaseController {
|
|||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/getPagedBlueprint"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanBlueprintListingModel>>> getPagedBlueprint(@Valid @RequestBody DataManagementPlanBlueprintTableRequest dataManagementPlanBlueprintTableRequest, Principal principal) throws Exception {
|
||||
DataTableData<DataManagementPlanBlueprintListingModel> dataTable = this.dataManagementProfileManager.getPagedBlueprint(dataManagementPlanBlueprintTableRequest, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanBlueprintListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<DataManagementPlanBlueprintListingModel>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
DataManagementPlanBlueprintListingModel dmpBlueprint = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
|
||||
dmpBlueprint.setLabel(dmpBlueprint.getLabel() + " new ");
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().payload(dmpBlueprint));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Void>> inactivate(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
try {
|
||||
this.dataManagementProfileManager.inactivate(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
} catch (DmpBlueprintUsedException exception) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.UNSUCCESS_DELETE).message(exception.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity getXml( @RequestHeader("Content-Type") String contentType, @PathVariable String id, Principal principal) throws IOException {
|
||||
ResponseEntity getXml( @RequestHeader("Content-Type") String contentType, @PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException, IOException {
|
||||
if (contentType.equals("application/xml")) {
|
||||
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
|
||||
return this.dataManagementProfileManager.getDocument(dataManagementPlanBlueprintListingModel);
|
||||
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(id, principal);
|
||||
return this.dataManagementProfileManager.getDocument(dataManagementPlanProfileListingModel,dataManagementPlanProfileListingModel.getLabel());
|
||||
}else {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanBlueprintListingModel>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
||||
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||
eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint dmpBlueprintModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
|
||||
DataManagementPlanBlueprintListingModel dmpBlueprint = dmpBlueprintModel.toDmpProfileCompositeModel(file.getOriginalFilename());
|
||||
this.dataManagementProfileManager.createOrUpdateBlueprint(dmpBlueprint, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DescriptionTemplate>>()
|
||||
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException,IOException,Exception{
|
||||
eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile dmpProfileModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
|
||||
DataManagementPlanProfileListingModel dataManagementPlan = dmpProfileModel.toDmpProfileCompositeModel(file.getOriginalFilename());
|
||||
this.dataManagementProfileManager.createOrUpdate(dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>()
|
||||
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
||||
}
|
||||
|
||||
|
|
|
@ -9,10 +9,12 @@ import eu.eudat.data.entities.DMP;
|
|||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
||||
import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.logic.managers.DataManagementPlanManager;
|
||||
import eu.eudat.logic.managers.DatasetManager;
|
||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
|
@ -150,7 +152,7 @@ public class DMPs extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataManagementPlanOverviewModel>> getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||
ResponseEntity getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||
// try {
|
||||
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal, true);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||
|
@ -182,21 +184,7 @@ public class DMPs extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
|
||||
try {
|
||||
FileEnvelope rdaJsonDocument = this.dataManagementPlanManager.getRDAJsonDocument(id, principal);
|
||||
|
||||
HttpHeaders responseHeaders = new HttpHeaders();
|
||||
responseHeaders.setContentLength(rdaJsonDocument.getFile().length());
|
||||
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
responseHeaders.set("Content-Disposition", "attachment;filename=" + rdaJsonDocument.getFilename());
|
||||
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
|
||||
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
|
||||
|
||||
InputStream resource = new FileInputStream(rdaJsonDocument.getFile());
|
||||
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
|
||||
resource.close();
|
||||
Files.deleteIfExists(rdaJsonDocument.getFile().toPath());
|
||||
|
||||
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
|
||||
return this.dataManagementPlanManager.getRDAJsonDocument(id, principal);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body(new ResponseItem<>().message(e.getMessage()).status(ApiMessageCode.ERROR_MESSAGE));
|
||||
}
|
||||
|
@ -260,7 +248,7 @@ public class DMPs extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<UUID>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
UUID cloneId = this.dataManagementPlanManager.clone(id, dataManagementPlan, principal);
|
||||
UUID cloneId = this.dataManagementPlanManager.clone(dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(cloneId));
|
||||
}
|
||||
|
||||
|
@ -333,6 +321,21 @@ public class DMPs extends BaseController {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* DOI Generation
|
||||
* */
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/createZenodoDoi/{id}"})
|
||||
public ResponseEntity<ResponseItem<String>> createZenodoDoi(@PathVariable String id, Principal principal) {
|
||||
try {
|
||||
String zenodoDOI = this.dataManagementPlanManager.createZenodoDoi(UUID.fromString(id), principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully created DOI for Data Datamanagement Plan in question.").payload(zenodoDOI));
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create DOI for the Data Management Plan: " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Data Index
|
||||
* */
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.data.dao.criteria.RequestItem;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.logic.managers.AdminManager;
|
||||
import eu.eudat.logic.managers.DatasetProfileManager;
|
||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||
|
@ -9,7 +8,6 @@ import eu.eudat.logic.services.ApiContext;
|
|||
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
|
||||
import eu.eudat.models.data.helpers.common.AutoCompleteOptionsLookupItem;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.data.properties.PropertiesModel;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
|
@ -57,7 +55,7 @@ public class DatasetProfileController extends BaseController {
|
|||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN})Principal principal) {
|
||||
DescriptionTemplate profile = this.datasetProfileManager.clone(id);
|
||||
eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(id);
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||
datasetprofile.setLabel(profile.getLabel() + " new ");
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
|
||||
|
@ -65,19 +63,11 @@ public class DatasetProfileController extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/search/autocomplete"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<Object> getDataForAutocomplete(@RequestBody RequestItem<AutoCompleteLookupItem> lookupItem) throws XPathExpressionException {
|
||||
DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(lookupItem.getCriteria().getProfileID()));
|
||||
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field modelfield = this.datasetProfileManager.queryForField(descriptionTemplate.getDefinition(), lookupItem.getCriteria().getFieldID());
|
||||
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(lookupItem.getCriteria().getProfileID()));
|
||||
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field modelfield = this.datasetProfileManager.queryForField(datasetProfile.getDefinition(), lookupItem.getCriteria().getFieldID());
|
||||
AutoCompleteData data = (AutoCompleteData) modelfield.getData();
|
||||
List<ExternalAutocompleteFieldModel> items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(items);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/search/autocompleteOptions"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<Object> getDataForAutocompleteOptions(@RequestBody RequestItem<AutoCompleteOptionsLookupItem> lookupItem) {
|
||||
AutoCompleteData data = new AutoCompleteData();
|
||||
data.setAutoCompleteSingleDataList(lookupItem.getCriteria().getAutoCompleteSingleDataList());
|
||||
List<ExternalAutocompleteFieldModel> items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(items);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import eu.eudat.logic.managers.DatasetProfileManager;
|
|||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||
import eu.eudat.models.data.datasetprofile.DatasetProfileWithPrefillingPropertyModel;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -43,12 +42,5 @@ public class DatasetProfiles extends BaseController {
|
|||
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofiles/getAllWithPrefilling"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<DatasetProfileWithPrefillingPropertyModel>>> getAllWithPrefilling(@RequestBody DatasetProfileTableRequestItem tableRequestItem) {
|
||||
List<DatasetProfileWithPrefillingPropertyModel> datasetProfileTableData = this.datasetProfileManager.getAllWithPrefilling(tableRequestItem);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileWithPrefillingPropertyModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.data.entities.Dataset;
|
||||
import eu.eudat.data.entities.DescriptionTemplate;
|
||||
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
|
||||
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
||||
import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
|
||||
|
@ -118,7 +117,7 @@ public class Datasets extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DatasetOverviewModel>> getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||
ResponseEntity getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||
// try {
|
||||
DatasetOverviewModel dataset = this.datasetManager.getOverviewSingle(id, principal, true);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||
|
@ -203,7 +202,7 @@ public class Datasets extends BaseController {
|
|||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getSingle(@PathVariable String id) {
|
||||
DescriptionTemplate profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
|
||||
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
||||
pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
|
||||
|
@ -257,7 +256,6 @@ public class Datasets extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DatasetWizardModel>> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) throws Exception {
|
||||
DatasetWizardModel dataset = new DatasetWizardModel().fromDataModel(this.datasetManager.createOrUpdate(profile, principal));
|
||||
dataset.setTags(profile.getTags());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(dataset));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,84 +0,0 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.logic.managers.DepositManager;
|
||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.doi.DepositCode;
|
||||
import eu.eudat.models.data.doi.DepositRequest;
|
||||
import eu.eudat.models.data.doi.Doi;
|
||||
import eu.eudat.models.data.doi.RepositoryConfig;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import eu.eudat.types.Authorities;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/deposit/"})
|
||||
public class DepositController extends BaseController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(DepositController.class);
|
||||
|
||||
private DepositManager depositManager;
|
||||
|
||||
@Autowired
|
||||
public DepositController(ApiContext apiContext, DepositManager depositManager){
|
||||
super(apiContext);
|
||||
this.depositManager = depositManager;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/repos"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<RepositoryConfig>>> getAvailableRepos(@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
|
||||
List<RepositoryConfig> ids = this.depositManager.getAvailableRepos();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<RepositoryConfig>>().status(ApiMessageCode.NO_MESSAGE).payload(ids));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/getAccessToken"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<String>> getAccessToken(@RequestBody DepositCode depositCode, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||
String accessToken = this.depositManager.authenticate(depositCode.getRepositoryId(), depositCode.getCode());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.NO_MESSAGE).payload(accessToken));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/createDoi"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Doi>> createDoi(@RequestBody DepositRequest depositRequest, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
|
||||
try {
|
||||
Doi doi = this.depositManager.deposit(depositRequest, principal);
|
||||
if(doi != null){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Doi>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully created DOI for Data Datamanagement Plan in question.").payload(doi));
|
||||
}
|
||||
else{
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Doi>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create DOI for the Data Management Plan"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Doi>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to create DOI for the Data Management Plan: " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/logo/{repositoryId}"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<String>> getLogo(@PathVariable("repositoryId") String repositoryId, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
|
||||
try {
|
||||
String encodedLogo = this.depositManager.getRepositoryLogo(repositoryId);
|
||||
if(encodedLogo != null){
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully loaded " + repositoryId + "'s logo.").payload(encodedLogo));
|
||||
}
|
||||
else{
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message(repositoryId + " has no logo").payload(null));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to load " + repositoryId + "'s logo: " + e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.exceptions.descriptiontemplate.DescriptionTemplatesWithTypeException;
|
||||
import eu.eudat.logic.managers.DescriptionTemplateTypeManager;
|
||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.descriptiontemplatetype.DescriptionTemplateTypeModel;
|
||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.types.ApiMessageCode;
|
||||
import eu.eudat.types.Authorities;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static eu.eudat.types.Authorities.ADMIN;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
@RequestMapping(value = {"/api/descriptionTemplateType/"})
|
||||
public class DescriptionTemplateTypeController extends BaseController {
|
||||
|
||||
private DescriptionTemplateTypeManager descriptionTemplateTypeManager;
|
||||
|
||||
@Autowired
|
||||
public DescriptionTemplateTypeController(ApiContext apiContext, DescriptionTemplateTypeManager descriptionTemplateTypeManager){
|
||||
super(apiContext);
|
||||
this.descriptionTemplateTypeManager = descriptionTemplateTypeManager;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"create"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> create(@RequestBody DescriptionTemplateTypeModel type, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||
try {
|
||||
this.descriptionTemplateTypeManager.create(type);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||
}
|
||||
catch(DescriptionTemplatesWithTypeException e){
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"update"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> update(@RequestBody DescriptionTemplateTypeModel type, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||
try {
|
||||
this.descriptionTemplateTypeManager.update(type);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Updated"));
|
||||
}
|
||||
catch(DescriptionTemplatesWithTypeException e){
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"get"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DescriptionTemplateTypeModel>>> get(@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||
DataTableData<DescriptionTemplateTypeModel> dataTable = this.descriptionTemplateTypeManager.get();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DescriptionTemplateTypeModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"get/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> getSingle(@PathVariable(value = "id") UUID id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||
try {
|
||||
DescriptionTemplateTypeModel typeModel = this.descriptionTemplateTypeManager.getSingle(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.NO_MESSAGE).payload(typeModel));
|
||||
}
|
||||
catch(DescriptionTemplatesWithTypeException e){
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.ERROR_MESSAGE).message(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = {"/delete/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DescriptionTemplateTypeModel>> delete(@PathVariable(value = "id") UUID id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||
try{
|
||||
this.descriptionTemplateTypeManager.delete(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Deleted"));
|
||||
}
|
||||
catch(DescriptionTemplatesWithTypeException e){
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionTemplateTypeModel>().status(ApiMessageCode.UNSUCCESS_DELETE).message(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -32,16 +32,16 @@ public class EmailMergeConfirmation {
|
|||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/{emailToken}"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<String>> emailConfirmation(@PathVariable(value = "emailToken") String token) {
|
||||
ResponseEntity<ResponseItem> emailConfirmation(@PathVariable(value = "emailToken") String token) {
|
||||
try {
|
||||
String emailToBeMerged = this.emailConfirmationManager.confirmEmail(token);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<String>().payload(emailToBeMerged).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
this.emailConfirmationManager.confirmEmail(token);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
} catch
|
||||
(HasConfirmedEmailException | TokenExpiredException ex) {
|
||||
if (ex instanceof TokenExpiredException) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<String>().status(ApiMessageCode.NO_MESSAGE));
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE));
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem<String>().status(ApiMessageCode.WARN_MESSAGE));
|
||||
return ResponseEntity.status(HttpStatus.FOUND).body(new ResponseItem().status(ApiMessageCode.WARN_MESSAGE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue