Compare commits
1 Commits
master
...
edit-overv
Author | SHA1 | Date |
---|---|---|
Kristian Ntavidi | fd9d35aad3 |
11
.env
11
.env
|
@ -1,5 +1,6 @@
|
||||||
PROFILE=docker
|
TAG=6.3.0
|
||||||
|
ENV=prod
|
||||||
# Version of Elastic products
|
PROFILE=production
|
||||||
ELK_VERSION=7.17.4
|
AOT=aot
|
||||||
STACK_VERSION=7.17.4
|
ELASTIC_VERSION=6.3.0
|
||||||
|
ELASTIC_PASSWORD=changeme
|
||||||
|
|
|
@ -40,12 +40,3 @@ dmp-frontend/.vscode/
|
||||||
dmp-frontend/package-lock.json
|
dmp-frontend/package-lock.json
|
||||||
dmp-backend/logging/target/
|
dmp-backend/logging/target/
|
||||||
ELK.Docker/shared/data-elk/
|
ELK.Docker/shared/data-elk/
|
||||||
|
|
||||||
# Eclipse
|
|
||||||
.project
|
|
||||||
.settings/
|
|
||||||
bin/
|
|
||||||
*.classpath
|
|
||||||
openDMP/dmp-backend/uploads/
|
|
||||||
openDMP/dmp-backend/tmp/
|
|
||||||
dmp-frontend/.angular/
|
|
||||||
|
|
69
README.md
69
README.md
|
@ -1,69 +0,0 @@
|
||||||
|
|
||||||
**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.
|
|
||||||
|
|
||||||
## Before running the docker compose commands, configurations must be set
|
|
||||||
|
|
||||||
### Database
|
|
||||||
|
|
||||||
First of all, database must be configured
|
|
||||||
|
|
||||||
The only file that has to be changed is **/dmp-db-scema/Docker/dmp-db.env**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ADMIN_USER: Admin username (app)
|
|
||||||
ADMIN_PASSWORD: Admin password (app)
|
|
||||||
|
|
||||||
POSTGRES_DB: database name
|
|
||||||
POSTGRES_USER: Admin username (database)
|
|
||||||
POSTGRES_PASSWORD: Admin password (database)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Backend
|
|
||||||
|
|
||||||
Secondly, a few more options should be asigned
|
|
||||||
|
|
||||||
The file **/dmp-backend/web/src/main/resources/config/application-docker.properties** contains all the necessary properties
|
|
||||||
|
|
||||||
Values to be modified:
|
|
||||||
```bash
|
|
||||||
database.url: the url that is used to connect to database (JDBC based)
|
|
||||||
database.username: database admin username
|
|
||||||
database.password: database admin password
|
|
||||||
|
|
||||||
elasticsearch.*(optional): setup elastic, check Elasticsearch(optional) section below
|
|
||||||
|
|
||||||
google.login.clientId(optional): google as login provider
|
|
||||||
```
|
|
||||||
**NOTE:** if you want to configure and integrate other providers, check this reference [Setup configurable login](https://code-repo.d4science.org/MaDgiK-CITE/argos/wiki/Page-2A:-Setup-configurable-login)
|
|
||||||
|
|
||||||
If you provide google.login.clientId, then the same value should be set in the field named **loginProviders.googleConfiguration.clientId** which belongs to **/dmp-frontend/src/assets/config/config.json**
|
|
||||||
|
|
||||||
## You are ready to build and run the entire application using Docker-compose
|
|
||||||
|
|
||||||
1. Go to the project's root directory
|
|
||||||
2. Type in the **Terminal** `docker volume create --name=dmpdata`
|
|
||||||
3. Type in the **Terminal** `docker-compose up -d --build`
|
|
||||||
4. After it's complete your application is running on [http://localhost:8080](http://localhost:8080)
|
|
||||||
|
|
||||||
### Elasticsearch(optional)
|
|
||||||
If you want to set up elasticsearch, you will need the password for the **elastic** user
|
|
||||||
|
|
||||||
After your application is running, type in the **Terminal** `docker exec -it elasticsearch /bin/sh`
|
|
||||||
|
|
||||||
Run the command `cat data/passwords.txt` in the shell and save its output
|
|
||||||
|
|
||||||
Finally, run `exit` to get back to your terminal
|
|
||||||
|
|
||||||
The elastic's password that you get has to be set in the **elasticsearch.password** property in the backend configuration
|
|
||||||
|
|
||||||
Rerun the application
|
|
||||||
|
|
||||||
1. Type in the **Terminal** `docker-compose down`
|
|
||||||
2. Type in the **Terminal** `docker-compose up -d --build`
|
|
|
@ -1 +1 @@
|
||||||
PROFILE=docker
|
PROFILE=staging
|
|
@ -1,22 +1,22 @@
|
||||||
FROM maven:3-jdk-11 AS MAVEN_BUILD
|
FROM maven:3-jdk-8-alpine AS MAVEN_BUILD
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
COPY pom.xml /build/
|
COPY pom.xml /build/
|
||||||
COPY data /build/data/
|
COPY data /build/data/
|
||||||
COPY elastic /build/elastic/
|
COPY elastic /build/elastic/
|
||||||
#COPY logging /build/logging/
|
COPY logging /build/logging/
|
||||||
COPY queryable /build/queryable/
|
COPY queryable /build/queryable/
|
||||||
COPY web /build/web/
|
COPY web /build/web/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WORKDIR /build/
|
WORKDIR /build/
|
||||||
RUN mvn package -q
|
RUN mvn package
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FROM amazoncorretto:11
|
FROM openjdk:8-jre-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY --from=MAVEN_BUILD /build/web/target/web-1.0-SNAPSHOT.jar /app.jar
|
COPY --from=MAVEN_BUILD /build/web/target/web-1.0-SNAPSHOT.jar /app.jar
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM maven:3-openjdk-11 AS MAVEN_BUILD
|
FROM maven:3-jdk-8-alpine AS MAVEN_BUILD
|
||||||
|
|
||||||
COPY pom.xml /build/
|
COPY pom.xml /build/
|
||||||
COPY data /build/data/
|
COPY data /build/data/
|
||||||
|
@ -9,7 +9,7 @@ COPY web /build/web/
|
||||||
WORKDIR /build/
|
WORKDIR /build/
|
||||||
RUN mvn package
|
RUN mvn package
|
||||||
|
|
||||||
FROM adoptopenjdk/openjdk11:alpine-jre
|
FROM openjdk:8-jre-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=MAVEN_BUILD /build/web/target/web-1.0-SNAPSHOT.jar /app/app.jar
|
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.location=/files/config/", "-jar","/app/app.jar"]
|
||||||
|
|
|
@ -25,10 +25,5 @@
|
||||||
<artifactId>elastic</artifactId>
|
<artifactId>elastic</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>io.swagger</groupId>
|
|
||||||
<artifactId>swagger-annotations</artifactId>
|
|
||||||
<version>1.5.20</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -1,9 +1,9 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||||
|
|
||||||
public abstract class Criteria<T> {
|
public abstract class Criteria<T> {
|
||||||
@ApiModelProperty(value = "like", name = "like", dataType = "String", allowEmptyValue = true, example = "\"\"")
|
|
||||||
private String like;
|
private String like;
|
||||||
|
|
||||||
public String getLike() {
|
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;
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.entities.DMPProfile;
|
|
||||||
import eu.eudat.data.entities.Grant;
|
import eu.eudat.data.entities.Grant;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -11,7 +10,6 @@ import java.util.UUID;
|
||||||
public class DataManagementPlanCriteria extends Criteria<DMP> {
|
public class DataManagementPlanCriteria extends Criteria<DMP> {
|
||||||
private Date periodStart;
|
private Date periodStart;
|
||||||
private Date periodEnd;
|
private Date periodEnd;
|
||||||
private DMPProfile profile;
|
|
||||||
private List<eu.eudat.data.entities.Grant> grants;
|
private List<eu.eudat.data.entities.Grant> grants;
|
||||||
private boolean allVersions;
|
private boolean allVersions;
|
||||||
private List<UUID> groupIds;
|
private List<UUID> groupIds;
|
||||||
|
@ -39,13 +37,6 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
|
||||||
this.periodEnd = periodEnd;
|
this.periodEnd = periodEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DMPProfile getProfile() {
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
public void setProfile(DMPProfile profile) {
|
|
||||||
this.profile = profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Grant> getGrants() {
|
public List<Grant> getGrants() {
|
||||||
return grants;
|
return grants;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
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.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DatasetProfileCriteria extends Criteria<DescriptionTemplate> {
|
public class DatasetProfileCriteria extends Criteria<DatasetProfile> {
|
||||||
|
|
||||||
public enum DatasetProfileFilter {
|
public enum DatasetProfileFilter {
|
||||||
DMPs((short) 0), Datasets((short) 1);
|
DMPs((short) 0), Datasets((short) 1);
|
||||||
|
@ -25,7 +23,7 @@ public class DatasetProfileCriteria extends Criteria<DescriptionTemplate> {
|
||||||
case 1:
|
case 1:
|
||||||
return Datasets;
|
return Datasets;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unsupported DescriptionTemplate filter");
|
throw new RuntimeException("Unsupported DatasetProfile filter");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,8 +35,6 @@ public class DatasetProfileCriteria extends Criteria<DescriptionTemplate> {
|
||||||
private boolean finalized;
|
private boolean finalized;
|
||||||
private Integer status;
|
private Integer status;
|
||||||
private Integer role;
|
private Integer role;
|
||||||
private List<UUID> ids;
|
|
||||||
private Date periodStart;
|
|
||||||
|
|
||||||
public boolean getAllVersions() { return allVersions; }
|
public boolean getAllVersions() { return allVersions; }
|
||||||
public void setAllVersions(boolean allVersions) { this.allVersions = allVersions; }
|
public void setAllVersions(boolean allVersions) { this.allVersions = allVersions; }
|
||||||
|
@ -82,20 +78,4 @@ public class DatasetProfileCriteria extends Criteria<DescriptionTemplate> {
|
||||||
public void setRole(Integer role) {
|
public void setRole(Integer role) {
|
||||||
this.role = role;
|
this.role = role;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UUID> getIds() {
|
|
||||||
return ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIds(List<UUID> ids) {
|
|
||||||
this.ids = ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getPeriodStart() {
|
|
||||||
return periodStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPeriodStart(Date periodStart) {
|
|
||||||
this.periodStart = periodStart;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.entities.DescriptionTemplate;
|
import eu.eudat.data.entities.DatasetProfile;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
public class DatasetProfileWizardCriteria extends Criteria<DescriptionTemplate> {
|
public class DatasetProfileWizardCriteria extends Criteria<DatasetProfile> {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
|
|
|
@ -2,12 +2,9 @@ package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.entities.Funder;
|
import eu.eudat.data.entities.Funder;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class FunderCriteria extends Criteria<Funder> {
|
public class FunderCriteria extends Criteria<Funder> {
|
||||||
private String reference;
|
private String reference;
|
||||||
private String exactReference;
|
private String exactReference;
|
||||||
private Date periodStart;
|
|
||||||
|
|
||||||
public String getReference() {
|
public String getReference() {
|
||||||
return reference;
|
return reference;
|
||||||
|
@ -23,12 +20,4 @@ public class FunderCriteria extends Criteria<Funder> {
|
||||||
public void setExactReference(String exactReference) {
|
public void setExactReference(String exactReference) {
|
||||||
this.exactReference = exactReference;
|
this.exactReference = exactReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getPeriodStart() {
|
|
||||||
return periodStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPeriodStart(Date periodStart) {
|
|
||||||
this.periodStart = periodStart;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import eu.eudat.data.entities.Organisation;
|
||||||
public class OrganisationCriteria extends Criteria<Organisation> {
|
public class OrganisationCriteria extends Criteria<Organisation> {
|
||||||
private String labelLike;
|
private String labelLike;
|
||||||
private Boolean isPublic;
|
private Boolean isPublic;
|
||||||
private boolean isActive;
|
|
||||||
|
|
||||||
public String getLabelLike() {
|
public String getLabelLike() {
|
||||||
return labelLike;
|
return labelLike;
|
||||||
|
@ -20,12 +19,4 @@ public class OrganisationCriteria extends Criteria<Organisation> {
|
||||||
public void setPublic(Boolean aPublic) {
|
public void setPublic(Boolean aPublic) {
|
||||||
isPublic = aPublic;
|
isPublic = aPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive() {
|
|
||||||
return isActive;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActive(boolean active) {
|
|
||||||
isActive = active;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,9 @@ package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.entities.Project;
|
import eu.eudat.data.entities.Project;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class ProjectCriteria extends Criteria<Project> {
|
public class ProjectCriteria extends Criteria<Project> {
|
||||||
private String reference;
|
private String reference;
|
||||||
private String exactReference;
|
private String exactReference;
|
||||||
private Date periodStart;
|
|
||||||
|
|
||||||
public String getReference() {
|
public String getReference() {
|
||||||
return reference;
|
return reference;
|
||||||
|
@ -23,12 +20,4 @@ public class ProjectCriteria extends Criteria<Project> {
|
||||||
public void setExactReference(String exactReference) {
|
public void setExactReference(String exactReference) {
|
||||||
this.exactReference = exactReference;
|
this.exactReference = exactReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getPeriodStart() {
|
|
||||||
return periodStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPeriodStart(Date periodStart) {
|
|
||||||
this.periodStart = periodStart;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,9 @@ package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.entities.Researcher;
|
import eu.eudat.data.entities.Researcher;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
public class ResearcherCriteria extends Criteria<Researcher> {
|
public class ResearcherCriteria extends Criteria<Researcher> {
|
||||||
private String name;
|
private String name;
|
||||||
private String reference;
|
private String reference;
|
||||||
private Date periodStart;
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
|
@ -24,12 +21,4 @@ public class ResearcherCriteria extends Criteria<Researcher> {
|
||||||
public void setReference(String reference) {
|
public void setReference(String reference) {
|
||||||
this.reference = reference;
|
this.reference = reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getPeriodStart() {
|
|
||||||
return periodStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPeriodStart(Date periodStart) {
|
|
||||||
this.periodStart = periodStart;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,6 @@ import eu.eudat.queryable.queryableentity.DataEntity;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +28,6 @@ public class DatabaseService<T extends DataEntity> {
|
||||||
return this.databaseCtx.getQueryable(tClass);
|
return this.databaseCtx.getQueryable(tClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public T createOrUpdate(T item, Class<T> tClass) {
|
public T createOrUpdate(T item, Class<T> tClass) {
|
||||||
return this.databaseCtx.createOrUpdate(item, tClass);
|
return this.databaseCtx.createOrUpdate(item, tClass);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.persistence.criteria.Join;
|
import javax.persistence.criteria.Join;
|
||||||
import javax.persistence.criteria.JoinType;
|
import javax.persistence.criteria.JoinType;
|
||||||
import javax.transaction.Transactional;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -42,8 +41,6 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
query.where((builder, root) -> builder.lessThan(root.get("created"), criteria.getPeriodEnd()));
|
||||||
if (criteria.getPeriodStart() != null)
|
if (criteria.getPeriodStart() != null)
|
||||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
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())
|
if (criteria.getGrants() != null && !criteria.getGrants().isEmpty())
|
||||||
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
|
query.where(((builder, root) -> root.get("grant").in(criteria.getGrants())));
|
||||||
if (!criteria.getAllVersions())
|
if (!criteria.getAllVersions())
|
||||||
|
@ -77,7 +74,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()));
|
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()) {
|
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() != null) {
|
||||||
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
|
if (criteria.getGrantStatus().equals(GrantStateType.FINISHED.getValue().shortValue()))
|
||||||
|
@ -89,7 +86,7 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.hasDoi()) {
|
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()));
|
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
|
||||||
return query;
|
return query;
|
||||||
|
@ -109,7 +106,6 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
|
||||||
public DMP createOrUpdate(DMP item) {
|
public DMP createOrUpdate(DMP item) {
|
||||||
return this.getDatabaseService().createOrUpdate(item, DMP.class);
|
return this.getDatabaseService().createOrUpdate(item, DMP.class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.eudat.data.dao.entities;
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria;
|
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria;
|
||||||
import eu.eudat.data.entities.DMP;
|
import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.entities.DMPProfile;
|
import eu.eudat.data.entities.DMPProfile;
|
||||||
|
@ -16,6 +15,4 @@ public interface DMPProfileDao extends DatabaseAccessLayer<DMPProfile, UUID> {
|
||||||
|
|
||||||
QueryableList<DMPProfile> getWithCriteria(DataManagementPlanProfileCriteria criteria);
|
QueryableList<DMPProfile> getWithCriteria(DataManagementPlanProfileCriteria criteria);
|
||||||
|
|
||||||
QueryableList<DMPProfile> getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.eudat.data.dao.entities;
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
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.criteria.DataManagementPlanProfileCriteria;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.data.entities.DMPProfile;
|
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())));
|
query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue())));
|
||||||
return query;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,6 @@ public interface DatasetDao extends DatabaseAccessLayer<Dataset, UUID> {
|
||||||
|
|
||||||
QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria);
|
QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria);
|
||||||
|
|
||||||
QueryableList<Dataset> filterFromElastic(DatasetCriteria criteria, List<UUID> ids);
|
|
||||||
|
|
||||||
QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal, List<Integer> roles);
|
QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal, List<Integer> roles);
|
||||||
|
|
||||||
Dataset isPublicDataset(UUID id);
|
Dataset isPublicDataset(UUID id);
|
||||||
|
|
|
@ -35,9 +35,9 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
||||||
if (criteria.getIsPublic() != null && criteria.getIsPublic()) {
|
if (criteria.getIsPublic() != null && criteria.getIsPublic()) {
|
||||||
query.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true));
|
query.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true));
|
||||||
query.where((builder, root) -> builder.equal(root.get("status"), Dataset.Status.FINALISED.getValue()));
|
query.where((builder, root) -> builder.equal(root.get("status"), Dataset.Status.FINALISED.getValue()));
|
||||||
/*query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
|
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
|
||||||
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
|
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
|
||||||
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));*/
|
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
||||||
}
|
}
|
||||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||||
query.where((builder, root) -> builder.or(
|
query.where((builder, root) -> builder.or(
|
||||||
|
@ -80,23 +80,13 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
||||||
query.where((builder, root) -> root.get("profile").get("id").in(criteria.getDatasetTemplates()));
|
query.where((builder, root) -> root.get("profile").get("id").in(criteria.getDatasetTemplates()));
|
||||||
|
|
||||||
if (criteria.hasDoi()) {
|
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.DELETED.getValue()));
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.CANCELED.getValue()));
|
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.CANCELED.getValue()));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableList<Dataset> filterFromElastic(DatasetCriteria criteria, List<UUID> ids) {
|
|
||||||
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
|
|
||||||
|
|
||||||
query.where(((builder, root) -> root.get("id").in(ids)));
|
|
||||||
if (!criteria.getAllVersions())
|
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), builder1.notEqual(nestedRoot.get("dmp").get("status"), DMP.DMPStatus.DELETED.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
|
||||||
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dataset createOrUpdate(Dataset item) {
|
public Dataset createOrUpdate(Dataset item) {
|
||||||
return getDatabaseService().createOrUpdate(item, Dataset.class);
|
return getDatabaseService().createOrUpdate(item, Dataset.class);
|
||||||
|
@ -131,7 +121,6 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
query.where((builder, root) -> builder.equal(root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal.getId()));
|
query.where((builder, root) -> builder.equal(root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal.getId()));
|
||||||
|
|
||||||
}
|
}
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.data.dao.entities;
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
import eu.eudat.data.dao.DatabaseAccess;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.data.entities.DatasetExternalDataset;
|
import eu.eudat.data.entities.DatasetExternalDataset;
|
||||||
|
import eu.eudat.data.entities.DatasetProfile;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
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.DatabaseAccessLayer;
|
||||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||||
import eu.eudat.data.entities.DescriptionTemplate;
|
import eu.eudat.data.entities.DatasetProfile;
|
||||||
import eu.eudat.data.entities.DescriptionTemplateType;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
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);
|
QueryableList<DatasetProfile> getAuthenticated(QueryableList<DatasetProfile> query, UUID principal, List<Integer> roles);
|
||||||
|
|
||||||
List<DescriptionTemplate> getAllIds();
|
|
||||||
|
|
||||||
Long countWithType(DescriptionTemplateType type);
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,8 +3,8 @@ package eu.eudat.data.dao.entities;
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
import eu.eudat.data.dao.DatabaseAccess;
|
||||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.data.entities.DescriptionTemplate;
|
import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.entities.DescriptionTemplateType;
|
import eu.eudat.data.entities.DatasetProfile;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
import eu.eudat.queryable.types.FieldSelectionType;
|
||||||
import eu.eudat.queryable.types.SelectionField;
|
import eu.eudat.queryable.types.SelectionField;
|
||||||
|
@ -15,22 +15,21 @@ import org.springframework.stereotype.Component;
|
||||||
import javax.persistence.criteria.Join;
|
import javax.persistence.criteria.Join;
|
||||||
import javax.persistence.criteria.JoinType;
|
import javax.persistence.criteria.JoinType;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Component("datasetProfileDao")
|
@Component("datasetProfileDao")
|
||||||
public class DatasetProfileDaoImpl extends DatabaseAccess<DescriptionTemplate> implements DatasetProfileDao {
|
public class DatasetProfileDaoImpl extends DatabaseAccess<DatasetProfile> implements DatasetProfileDao {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DatasetProfileDaoImpl(DatabaseService<DescriptionTemplate> databaseService) {
|
public DatasetProfileDaoImpl(DatabaseService<DatasetProfile> databaseService) {
|
||||||
super(databaseService);
|
super(databaseService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DescriptionTemplate> getWithCriteria(DatasetProfileCriteria criteria) {
|
public QueryableList<DatasetProfile> getWithCriteria(DatasetProfileCriteria criteria) {
|
||||||
QueryableList<DescriptionTemplate> query = getDatabaseService().getQueryable(DescriptionTemplate.class);
|
QueryableList<DatasetProfile> query = getDatabaseService().getQueryable(DatasetProfile.class);
|
||||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
|
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"));
|
||||||
if (!criteria.getAllVersions())
|
if (!criteria.getAllVersions())
|
||||||
|
@ -59,62 +58,52 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DescriptionTemplate> i
|
||||||
if (criteria.getStatus() != null) {
|
if (criteria.getStatus() != null) {
|
||||||
query.where(((builder, root) -> builder.equal(root.get("status"), criteria.getStatus())));
|
query.where(((builder, root) -> builder.equal(root.get("status"), criteria.getStatus())));
|
||||||
}
|
}
|
||||||
if (criteria.getIds() != null) {
|
|
||||||
query.where(((builder, root) -> root.get("id").in(criteria.getIds())));
|
|
||||||
}
|
|
||||||
if (criteria.getFinalized()) {
|
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 {
|
} 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()));
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DescriptionTemplate createOrUpdate(DescriptionTemplate item) {
|
public DatasetProfile createOrUpdate(DatasetProfile item) {
|
||||||
return this.getDatabaseService().createOrUpdate(item, DescriptionTemplate.class);
|
return this.getDatabaseService().createOrUpdate(item, DatasetProfile.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DescriptionTemplate find(UUID id) {
|
public DatasetProfile find(UUID id) {
|
||||||
return getDatabaseService().getQueryable(DescriptionTemplate.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
return getDatabaseService().getQueryable(DatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DescriptionTemplate> getAll() {
|
public QueryableList<DatasetProfile> getAll() {
|
||||||
return getDatabaseService().getQueryable(DescriptionTemplate.class);
|
return getDatabaseService().getQueryable(DatasetProfile.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DescriptionTemplate> getAllIds(){
|
public void delete(DatasetProfile item) {
|
||||||
return getDatabaseService().getQueryable(DescriptionTemplate.class).withFields(Collections.singletonList("id")).toList();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(DescriptionTemplate item) {
|
|
||||||
this.getDatabaseService().delete(item);
|
this.getDatabaseService().delete(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DescriptionTemplate> asQueryable() {
|
public QueryableList<DatasetProfile> asQueryable() {
|
||||||
return this.getDatabaseService().getQueryable(DescriptionTemplate.class);
|
return this.getDatabaseService().getQueryable(DatasetProfile.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<DescriptionTemplate> createOrUpdateAsync(DescriptionTemplate item) {
|
public CompletableFuture<DatasetProfile> createOrUpdateAsync(DatasetProfile item) {
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DescriptionTemplate find(UUID id, String hint) {
|
public DatasetProfile find(UUID id, String hint) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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()) {
|
if (roles != null && !roles.isEmpty()) {
|
||||||
query.where((builder, root) -> {
|
query.where((builder, root) -> {
|
||||||
Join userJoin = root.join("users", JoinType.LEFT);
|
Join userJoin = root.join("users", JoinType.LEFT);
|
||||||
|
@ -126,9 +115,4 @@ public class DatasetProfileDaoImpl extends DatabaseAccess<DescriptionTemplate> i
|
||||||
|
|
||||||
return query;
|
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;
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
|
import eu.eudat.data.entities.DatasetProfile;
|
||||||
import eu.eudat.data.entities.DatasetService;
|
import eu.eudat.data.entities.DatasetService;
|
||||||
|
|
||||||
import java.util.UUID;
|
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.DatabaseAccess;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
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.data.entities.DatasetService;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
|
import eu.eudat.data.entities.DoiFunder;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface DoiFunderDao extends DatabaseAccessLayer<DoiFunder, UUID> {
|
||||||
|
|
||||||
|
DoiFunder findFunderByName(String name);
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
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.DoiFunder;
|
||||||
|
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("DoiFunderDao")
|
||||||
|
public class DoiFunderDaoImpl extends DatabaseAccess<DoiFunder> implements DoiFunderDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
public DoiFunderDaoImpl(DatabaseService<DoiFunder> databaseService) {
|
||||||
|
super(databaseService);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoiFunder findFunderByName(String name) {
|
||||||
|
return this.asQueryable().toList().stream().filter(doiFunder -> name.contains(doiFunder.getName()) || doiFunder.getName().contains(name)).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoiFunder createOrUpdate(DoiFunder item) {
|
||||||
|
return this.getDatabaseService().createOrUpdate(item, DoiFunder.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<DoiFunder> createOrUpdateAsync(DoiFunder item) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoiFunder find(UUID id) {
|
||||||
|
return this.getDatabaseService().getQueryable(DoiFunder.class).where(((builder, root) -> builder.equal(root.get("id"), id))).getSingle();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoiFunder find(UUID id, String hint) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(DoiFunder item) {
|
||||||
|
this.getDatabaseService().delete(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryableList<DoiFunder> asQueryable() {
|
||||||
|
return this.getDatabaseService().getQueryable(DoiFunder.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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
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);
|
|
||||||
}
|
|
|
@ -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.FileUpload;
|
|
||||||
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;
|
|
||||||
|
|
||||||
@Component("FileUploadDao")
|
|
||||||
public class FileUploadDaoImpl extends DatabaseAccess<FileUpload> implements FileUploadDao {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
public FileUploadDaoImpl(DatabaseService<FileUpload> databaseService) {
|
|
||||||
super(databaseService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FileUpload createOrUpdate(FileUpload item) {
|
|
||||||
return getDatabaseService().createOrUpdate(item, FileUpload.class);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<FileUpload> createOrUpdateAsync(FileUpload item) {
|
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FileUpload find(UUID id) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(FileUpload item) {
|
|
||||||
this.getDatabaseService().delete(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public QueryableList<FileUpload> asQueryable() {
|
|
||||||
return this.getDatabaseService().getQueryable(FileUpload.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -31,8 +31,6 @@ public class FunderDaoImpl extends DatabaseAccess<Funder> implements FunderDao {
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("reference")), "%" + criteria.getReference().toUpperCase() + "%"));
|
query.where((builder, root) -> builder.like(builder.upper(root.get("reference")), "%" + criteria.getReference().toUpperCase() + "%"));
|
||||||
if (criteria.getExactReference() != null)
|
if (criteria.getExactReference() != null)
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("reference")), criteria.getExactReference().toUpperCase()));
|
query.where((builder, root) -> builder.like(builder.upper(root.get("reference")), criteria.getExactReference().toUpperCase()));
|
||||||
if (criteria.getPeriodStart() != null)
|
|
||||||
query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("created"), criteria.getPeriodStart()));
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Funder.Status.DELETED.getValue()));
|
query.where((builder, root) -> builder.notEqual(root.get("status"), Funder.Status.DELETED.getValue()));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class GrantDaoImpl extends DatabaseAccess<Grant> implements GrantDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserInfo principal) {
|
public QueryableList<Grant> getAuthenticated(QueryableList<Grant> query, UserInfo principal) {
|
||||||
query.where((builder, root) -> builder.equal(root.get("creationUser").get("id"), principal.getId())).distinct();
|
query.where((builder, root) -> builder.or(builder.equal(root.get("creationUser"), principal), builder.equal(root.join("dmps", JoinType.LEFT).join("users", JoinType.LEFT).join("user", JoinType.LEFT).get("id"), principal.getId()))).distinct();
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,6 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
|
||||||
query.where((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).get("status"), DMP.DMPStatus.FINALISED.getValue()));
|
query.where((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).get("status"), DMP.DMPStatus.FINALISED.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.isActive()) {
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.join("dmps").get("status"), DMP.DMPStatus.DELETED.getValue())).distinct();
|
|
||||||
}
|
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,6 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
|
||||||
query.where((builder, root) -> builder.like(root.get("reference"), "%" + criteria.getReference() + "%"));
|
query.where((builder, root) -> builder.like(root.get("reference"), "%" + criteria.getReference() + "%"));
|
||||||
if (criteria.getExactReference() != null)
|
if (criteria.getExactReference() != null)
|
||||||
query.where((builder, root) -> builder.like(root.get("reference"), criteria.getExactReference()));
|
query.where((builder, root) -> builder.like(root.get("reference"), criteria.getExactReference()));
|
||||||
if (criteria.getPeriodStart() != null)
|
|
||||||
query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("startdate"), criteria.getPeriodStart()));
|
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
|
query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,6 @@ public class ResearcherDaoImpl extends DatabaseAccess<Researcher> implements Res
|
||||||
query.where((builder, root) ->builder.or(builder.like(builder.lower(root.get("label")), "%" + criteria.getName().toLowerCase() + "%")));
|
query.where((builder, root) ->builder.or(builder.like(builder.lower(root.get("label")), "%" + criteria.getName().toLowerCase() + "%")));
|
||||||
if (criteria.getReference() != null && !criteria.getReference().isEmpty())
|
if (criteria.getReference() != null && !criteria.getReference().isEmpty())
|
||||||
query.where((builder, root) ->builder.or(builder.like(root.get("reference"), criteria.getReference())));
|
query.where((builder, root) ->builder.or(builder.like(root.get("reference"), criteria.getReference())));
|
||||||
if (criteria.getPeriodStart() != null)
|
|
||||||
query.where((builder, root) -> builder.greaterThanOrEqualTo(root.get("created"), criteria.getPeriodStart()));
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class Credential implements DataEntity<Credential, UUID> {
|
||||||
private Integer provider;
|
private Integer provider;
|
||||||
@Column(name = "\"Public\"", nullable = false)
|
@Column(name = "\"Public\"", nullable = false)
|
||||||
private String publicValue;
|
private String publicValue;
|
||||||
@Column(name = "\"Email\"")
|
@Column(name = "\"Email\"", nullable = false)
|
||||||
private String email;
|
private String email;
|
||||||
@Column(name = "\"Secret\"", nullable = false)
|
@Column(name = "\"Secret\"", nullable = false)
|
||||||
private String secret;
|
private String secret;
|
||||||
|
|
|
@ -25,12 +25,7 @@ import java.util.stream.Collectors;
|
||||||
name = "fullyDetailed",
|
name = "fullyDetailed",
|
||||||
attributeNodes = {
|
attributeNodes = {
|
||||||
@NamedAttributeNode("grant"), @NamedAttributeNode("profile"),
|
@NamedAttributeNode("grant"), @NamedAttributeNode("profile"),
|
||||||
@NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")
|
@NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")}),
|
||||||
},
|
|
||||||
subgraphs = {
|
|
||||||
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")})
|
|
||||||
}
|
|
||||||
),
|
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(
|
||||||
name = "dmpRecentActivity",
|
name = "dmpRecentActivity",
|
||||||
attributeNodes = {
|
attributeNodes = {
|
||||||
|
@ -112,8 +107,12 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
/*@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
/*@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
|
||||||
private String associatedDmps;*/
|
private String associatedDmps;*/
|
||||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "dmp")
|
@OneToMany(fetch = FetchType.LAZY)
|
||||||
private Set<DMPDatasetProfile> associatedDmps;
|
@JoinTable(name = "\"DMPDatasetProfile\"",
|
||||||
|
joinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")},
|
||||||
|
inverseJoinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")}
|
||||||
|
)
|
||||||
|
private Set<DatasetProfile> associatedDmps;
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@ -182,8 +181,8 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
private Date publishedAt;
|
private Date publishedAt;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "entityId", fetch = FetchType.LAZY)
|
@Column(name = "\"DOI\"")
|
||||||
private Set<EntityDoi> dois;
|
private String doi;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "\"Project\"")
|
@JoinColumn(name = "\"Project\"")
|
||||||
|
@ -270,10 +269,10 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
this.grant = grant;
|
this.grant = grant;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<DMPDatasetProfile> getAssociatedDmps() {
|
public Set<DatasetProfile> getAssociatedDmps() {
|
||||||
return associatedDmps;
|
return associatedDmps;
|
||||||
}
|
}
|
||||||
public void setAssociatedDmps(Set<DMPDatasetProfile> associatedDmps) {
|
public void setAssociatedDmps(Set<DatasetProfile> associatedDmps) {
|
||||||
this.associatedDmps = associatedDmps;
|
this.associatedDmps = associatedDmps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,11 +339,11 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
this.publishedAt = publishedAt;
|
this.publishedAt = publishedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<EntityDoi> getDois() {
|
public String getDoi() {
|
||||||
return dois;
|
return doi;
|
||||||
}
|
}
|
||||||
public void setDois(Set<EntityDoi> dois) {
|
public void setDoi(String doi) {
|
||||||
this.dois = dois;
|
this.doi = doi;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Project getProject() {
|
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.getStatus().equals(DMPStatus.FINALISED.getValue())) this.setFinalizedAt(new Date());
|
||||||
if (entity.isPublic) this.setPublishedAt(new Date());
|
if (entity.isPublic) this.setPublishedAt(new Date());
|
||||||
if (entity.getUsers() != null) this.users = entity.getUsers();
|
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();
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,14 +26,14 @@ public class DataRepository implements Serializable, DataEntity<DataRepository,
|
||||||
@Column(name = "\"Abbreviation\"")
|
@Column(name = "\"Abbreviation\"")
|
||||||
private String abbreviation;
|
private String abbreviation;
|
||||||
|
|
||||||
@Column(name = "\"Reference\"")
|
@Column(name = "\"Reference\"", nullable = false)
|
||||||
private String reference;
|
private String reference;
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
@Column(name = "\"Uri\"")
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml")
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "dataRepository", cascade = CascadeType.ALL, orphanRemoval = true)
|
@OneToMany(mappedBy = "dataRepository", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||||
|
@ -42,14 +42,14 @@ public class DataRepository implements Serializable, DataEntity<DataRepository,
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
@Column(name = "\"Status\"", nullable = false)
|
||||||
private Short status;
|
private Short status;
|
||||||
|
|
||||||
@Column(name = "\"Created\"", nullable = false)
|
@Column(name = "\"Created\"")
|
||||||
private Date created = null;
|
private Date created = null;
|
||||||
|
|
||||||
@Column(name = "\"Modified\"", nullable = false)
|
@Column(name = "\"Modified\"")
|
||||||
private Date modified = new Date();
|
private Date modified = new Date();
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "\"CreationUser\"")
|
@JoinColumn(name = "\"CreationUser\"", nullable = true)
|
||||||
private UserInfo creationUser;
|
private UserInfo creationUser;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,13 @@ import java.util.stream.Collectors;
|
||||||
@NamedEntityGraphs({
|
@NamedEntityGraphs({
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(
|
||||||
name = "datasetListingModel",
|
name = "datasetListingModel",
|
||||||
attributeNodes = {/*@NamedAttributeNode("services"), @NamedAttributeNode(value = "datasetDataRepositories", subgraph = "datasetDataRepositories"),
|
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode(value = "datasetDataRepositories", subgraph = "datasetDataRepositories"),
|
||||||
@NamedAttributeNode(value = "datasetExternalDatasets", subgraph = "datasetExternalDatasets"), @NamedAttributeNode("registries"),*/
|
@NamedAttributeNode(value = "datasetExternalDatasets", subgraph = "datasetExternalDatasets"), @NamedAttributeNode("registries"),
|
||||||
@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode(value = "profile", subgraph = "profile"), @NamedAttributeNode("creator")},
|
@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")},
|
||||||
subgraphs = {
|
subgraphs = {
|
||||||
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("grant"), @NamedAttributeNode("organisations")}),
|
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("grant"), @NamedAttributeNode("organisations")}),
|
||||||
@NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")}),
|
@NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")}),
|
||||||
@NamedSubgraph(name = "datasetExternalDatasets", attributeNodes = {@NamedAttributeNode("externalDataset")}),
|
@NamedSubgraph(name = "datasetExternalDatasets", attributeNodes = {@NamedAttributeNode("externalDataset")})
|
||||||
@NamedSubgraph(name = "profile", attributeNodes = {@NamedAttributeNode("label")})
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@NamedEntityGraph(
|
@NamedEntityGraph(
|
||||||
|
@ -92,7 +91,7 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
@Column(name = "\"Label\"", nullable = false)
|
@Column(name = "\"Label\"")
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@ -100,23 +99,20 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
@JoinColumn(name = "\"DMP\"", nullable = false)
|
@JoinColumn(name = "\"DMP\"", nullable = false)
|
||||||
private DMP dmp;
|
private DMP dmp;
|
||||||
|
|
||||||
@Column(name = "\"DmpSectionIndex\"")
|
|
||||||
private Integer dmpSectionIndex;
|
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
@Column(name = "\"Uri\"")
|
||||||
private String uri;
|
private String uri;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Properties\"", columnDefinition = "xml")
|
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
|
||||||
private String properties;
|
private String properties;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
||||||
@JoinColumn(name = "\"Profile\"")
|
@JoinColumn(name = "\"Profile\"", nullable = true)
|
||||||
private DescriptionTemplate profile;
|
private DatasetProfile profile;
|
||||||
|
|
||||||
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
||||||
@Column(name = "\"Reference\"", columnDefinition = "xml")
|
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
|
||||||
private String reference;
|
private String reference;
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY)
|
@OneToMany(fetch = FetchType.LAZY)
|
||||||
|
@ -139,16 +135,16 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
private Short status;
|
private Short status;
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "\"Created\"", nullable = false)
|
@Column(name = "\"Created\"")
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
private Date created = null;
|
private Date created = null;
|
||||||
|
|
||||||
@Column(name = "\"Modified\"", nullable = false)
|
@Column(name = "\"Modified\"")
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
private Date modified = new Date();
|
private Date modified = new Date();
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "\"Creator\"")
|
@JoinColumn(name = "\"Creator\"", nullable = true)
|
||||||
private UserInfo creator;
|
private UserInfo creator;
|
||||||
|
|
||||||
@Column(name = "\"Description\"")
|
@Column(name = "\"Description\"")
|
||||||
|
@ -235,12 +231,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
this.dmp = dmp;
|
this.dmp = dmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getDmpSectionIndex() {
|
|
||||||
return dmpSectionIndex;
|
|
||||||
}
|
|
||||||
public void setDmpSectionIndex(Integer dmpSectionIndex) {
|
|
||||||
this.dmpSectionIndex = dmpSectionIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUri() {
|
public String getUri() {
|
||||||
return uri;
|
return uri;
|
||||||
|
@ -258,10 +248,10 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DescriptionTemplate getProfile() {
|
public DatasetProfile getProfile() {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
public void setProfile(DescriptionTemplate profile) {
|
public void setProfile(DatasetProfile profile) {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +327,6 @@ public class Dataset implements DataEntity<Dataset, UUID> {
|
||||||
this.setRegistries(entity.getRegistries());
|
this.setRegistries(entity.getRegistries());
|
||||||
|
|
||||||
this.setDmp(entity.getDmp());
|
this.setDmp(entity.getDmp());
|
||||||
this.setDmpSectionIndex(entity.getDmpSectionIndex());
|
|
||||||
this.setStatus(entity.getStatus());
|
this.setStatus(entity.getStatus());
|
||||||
this.setProfile(entity.getProfile());
|
this.setProfile(entity.getProfile());
|
||||||
this.setModified(new Date());
|
this.setModified(new Date());
|
||||||
|
|
|
@ -14,8 +14,8 @@ import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "\"DescriptionTemplate\"")
|
@Table(name = "\"DatasetProfile\"")
|
||||||
public class DescriptionTemplate implements DataEntity<DescriptionTemplate,UUID>{
|
public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
|
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
|
||||||
|
@ -49,7 +49,7 @@ public class DescriptionTemplate implements DataEntity<DescriptionTemplate,UUID>
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
@Column(name = "\"Label\"", nullable = false)
|
@Column(name = "\"Label\"")
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "profile")
|
@OneToMany(fetch = FetchType.LAZY, mappedBy = "profile")
|
||||||
|
@ -79,21 +79,19 @@ public class DescriptionTemplate implements DataEntity<DescriptionTemplate,UUID>
|
||||||
@Column(name = "\"Version\"", nullable = false)
|
@Column(name = "\"Version\"", nullable = false)
|
||||||
private Short version;
|
private Short version;
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY)
|
@ManyToMany(fetch = FetchType.LAZY)
|
||||||
private Set<DMP> dmps;
|
@JoinTable(name = "\"DMPDatasetProfile\"",
|
||||||
|
joinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")},
|
||||||
|
inverseJoinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")}
|
||||||
|
)
|
||||||
|
private List<DMP> dmps;
|
||||||
|
|
||||||
@Column(name = "\"Language\"", nullable = false)
|
@Column(name = "\"Language\"", nullable = false)
|
||||||
private String language;
|
private String language;
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.EAGER)
|
@OneToMany(mappedBy = "datasetProfile", fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "\"Type\"", nullable = false)
|
|
||||||
private DescriptionTemplateType type;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "descriptionTemplate", fetch = FetchType.LAZY)
|
|
||||||
private Set<UserDatasetProfile> users;
|
private Set<UserDatasetProfile> users;
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "datasetprofile")
|
|
||||||
private Set<DMPDatasetProfile> associatedDmps;
|
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return description;
|
return description;
|
||||||
|
@ -158,31 +156,26 @@ public class DescriptionTemplate implements DataEntity<DescriptionTemplate,UUID>
|
||||||
public String getLanguage() {
|
public String getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLanguage(String language) {
|
public void setLanguage(String language) {
|
||||||
this.language = language;
|
this.language = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptionTemplateType getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
public void setType(DescriptionTemplateType type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<UserDatasetProfile> getUsers() {
|
public Set<UserDatasetProfile> getUsers() {
|
||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsers(Set<UserDatasetProfile> users) {
|
public void setUsers(Set<UserDatasetProfile> users) {
|
||||||
this.users = users;
|
this.users = users;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
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
|
@Override
|
||||||
public void update(DescriptionTemplate entity) {
|
public void update(DatasetProfile entity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -191,7 +184,7 @@ public class DescriptionTemplate implements DataEntity<DescriptionTemplate,UUID>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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"));
|
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
|
||||||
return this;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
package eu.eudat.data.entities;
|
||||||
|
|
||||||
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "\"DoiFunder\"")
|
||||||
|
public class DoiFunder implements DataEntity<DoiFunder, UUID> {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
@Column(name = "name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column(name = "doi")
|
||||||
|
private String doi;
|
||||||
|
|
||||||
|
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 String getDoi() {
|
||||||
|
return doi;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDoi(String doi) {
|
||||||
|
this.doi = doi;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(DoiFunder entity) {
|
||||||
|
this.name = entity.name;
|
||||||
|
this.doi = entity.doi;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getKeys() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DoiFunder buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,7 +31,7 @@ public class EmailConfirmation implements DataEntity<EmailConfirmation, UUID> {
|
||||||
@Column(name = "\"userId\"", nullable = false)
|
@Column(name = "\"userId\"", nullable = false)
|
||||||
private UUID userId;
|
private UUID userId;
|
||||||
|
|
||||||
@Column(name = "\"data\"")
|
@Column(name = "\"data\"", nullable = false)
|
||||||
private String data;
|
private String data;
|
||||||
|
|
||||||
@Column(name = "\"expiresAt\"", nullable = false)
|
@Column(name = "\"expiresAt\"", nullable = false)
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,129 +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.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"FileUpload\"")
|
|
||||||
public class FileUpload implements DataEntity<FileUpload, UUID> {
|
|
||||||
public enum EntityType {
|
|
||||||
DATASET, DMP
|
|
||||||
}
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "\"Name\"", nullable = false)
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@Column(name = "\"FileType\"", nullable = false)
|
|
||||||
private String fileType;
|
|
||||||
|
|
||||||
@Column(name = "\"EntityId\"", nullable = false)
|
|
||||||
private UUID entityId;
|
|
||||||
|
|
||||||
@Enumerated(EnumType.STRING)
|
|
||||||
@Type(type = "eu.eudat.configurations.typedefinition.PostgreSQLEnumType")
|
|
||||||
@Column(name = "\"EntityType\"", nullable = false)
|
|
||||||
private EntityType entityType;
|
|
||||||
|
|
||||||
@Column(name = "\"CreatedAt\"", nullable = false)
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date createdAt;
|
|
||||||
|
|
||||||
@Column(name = "\"IsDeleted\"", nullable = false)
|
|
||||||
private Boolean isDeleted;
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"Creator\"")
|
|
||||||
private UserInfo creator;
|
|
||||||
|
|
||||||
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 String getFileType() {
|
|
||||||
return fileType;
|
|
||||||
}
|
|
||||||
public void setFileType(String fileType) {
|
|
||||||
this.fileType = fileType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getEntityId() {
|
|
||||||
return entityId;
|
|
||||||
}
|
|
||||||
public void setEntityId(UUID entityId) {
|
|
||||||
this.entityId = entityId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityType getEntityType() {
|
|
||||||
return entityType;
|
|
||||||
}
|
|
||||||
public void setEntityType(EntityType entityType) {
|
|
||||||
this.entityType = entityType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreatedAt() {
|
|
||||||
return createdAt;
|
|
||||||
}
|
|
||||||
public void setCreatedAt(Date createdAt) {
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getIsDeleted() {
|
|
||||||
return isDeleted;
|
|
||||||
}
|
|
||||||
public void setIsDeleted(Boolean isDeleted) {
|
|
||||||
this.isDeleted = isDeleted;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserInfo getCreator() {
|
|
||||||
return creator;
|
|
||||||
}
|
|
||||||
public void setCreator(UserInfo creator) {
|
|
||||||
this.creator = creator;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(FileUpload file) {
|
|
||||||
this.name = file.getName();
|
|
||||||
this.fileType = file.getFileType();
|
|
||||||
this.entityId = file.getEntityId();
|
|
||||||
this.entityType = file.getEntityType();
|
|
||||||
this.createdAt = file.getCreatedAt();
|
|
||||||
this.isDeleted = file.getIsDeleted();
|
|
||||||
this.creator = file.getCreator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FileUpload 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");
|
|
||||||
this.creator = tuple.stream().map(x -> new UserInfo().buildFromTuple(tuple, fields , base.isEmpty() ? "creator" : base + "." + "creator")).collect(Collectors.toList()).get(0);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -106,11 +106,11 @@ public class Grant implements DataEntity<Grant, UUID> {
|
||||||
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
@Column(name = "\"StartDate\"", nullable = true)
|
@Column(name = "\"StartDate\"", nullable = false)
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
private Date startdate = null;
|
private Date startdate = null;
|
||||||
|
|
||||||
@Column(name = "\"EndDate\"", nullable = true)
|
@Column(name = "\"EndDate\"", nullable = false)
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
private Date enddate = null;
|
private Date enddate = null;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class Researcher implements DataEntity<Researcher, UUID> {
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
@Column(name = "\"Label\"", nullable = false, length = 250)
|
@Column(name = "\"Label\"")
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
@Column(name = "\"Uri\"")
|
||||||
|
|
|
@ -22,8 +22,8 @@ public class UserDatasetProfile implements DataEntity<UserDatasetProfile, UUID>
|
||||||
private UserInfo user;
|
private UserInfo user;
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "\"descriptionTemplate\"")
|
@JoinColumn(name = "\"datasetProfile\"")
|
||||||
private DescriptionTemplate descriptionTemplate;
|
private DatasetProfile datasetProfile;
|
||||||
|
|
||||||
@Column(name = "role")
|
@Column(name = "role")
|
||||||
private Integer role;
|
private Integer role;
|
||||||
|
@ -44,12 +44,12 @@ public class UserDatasetProfile implements DataEntity<UserDatasetProfile, UUID>
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptionTemplate getDatasetProfile() {
|
public DatasetProfile getDatasetProfile() {
|
||||||
return descriptionTemplate;
|
return datasetProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDatasetProfile(DescriptionTemplate descriptionTemplate) {
|
public void setDatasetProfile(DatasetProfile datasetProfile) {
|
||||||
this.descriptionTemplate = descriptionTemplate;
|
this.datasetProfile = datasetProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getRole() {
|
public Integer getRole() {
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "email")
|
@Column(name = "email", nullable = false)
|
||||||
private String email = null;
|
private String email = null;
|
||||||
|
|
||||||
@Column(name = "authorization_level", nullable = false)
|
@Column(name = "authorization_level", nullable = false)
|
||||||
|
|
|
@ -3,14 +3,12 @@ package eu.eudat.data.query.definition;
|
||||||
import eu.eudat.data.dao.criteria.Criteria;
|
import eu.eudat.data.dao.criteria.Criteria;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public abstract class Query<C extends Criteria<T>, T extends DataEntity> implements CriteriaQuery<C, T> {
|
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 static final Logger logger = LoggerFactory.getLogger(Query.class);
|
||||||
private C criteria;
|
private C criteria;
|
||||||
@ApiModelProperty(value = "query", name = "query", dataType = "String", hidden = true)
|
|
||||||
private QueryableList<T> query;
|
private QueryableList<T> query;
|
||||||
|
|
||||||
public static class QueryBuilder<C extends Criteria<T>, T extends DataEntity, Q extends Query<C, T>> {
|
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.data.query.definition.helpers.SelectionFields;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
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> {
|
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;
|
private ColumnOrderings orderings;
|
||||||
@ApiModelProperty(hidden = true)
|
|
||||||
private SelectionFields selection;
|
private SelectionFields selection;
|
||||||
@ApiModelProperty(value = "length", name = "length", dataType = "Integer", example = "2")
|
|
||||||
private Integer length;
|
private Integer length;
|
||||||
@ApiModelProperty(value = "offset", name = "offset", dataType = "Integer", example = "0")
|
|
||||||
private Integer offset;
|
private Integer offset;
|
||||||
|
|
||||||
public Integer getLength() {
|
public Integer getLength() {
|
||||||
|
|
|
@ -1,30 +1,27 @@
|
||||||
package eu.eudat.data.query.definition.helpers;
|
package eu.eudat.data.query.definition.helpers;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public class ColumnOrderings {
|
public class ColumnOrderings {
|
||||||
|
|
||||||
@ApiModelProperty(value = "fields", name = "fields", dataType = "List<String>", example = "[]")
|
private String[] fields;
|
||||||
private List<String> fields;
|
|
||||||
|
|
||||||
public List<String> getFields() {
|
public String[] getFields() {
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFields(List<String> fields) {
|
public void setFields(String[] fields) {
|
||||||
this.fields = fields;
|
this.fields = fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Ordering> getFieldOrderings() {
|
public Ordering[] getFieldOrderings() {
|
||||||
List<Ordering> orderings = new LinkedList<>();
|
List<Ordering> orderings = new LinkedList<>();
|
||||||
for (String field : fields) {
|
for (String field : fields) {
|
||||||
orderings.add(this.orderingFromString(field));
|
orderings.add(this.orderingFromString(field));
|
||||||
}
|
}
|
||||||
return orderings;
|
return orderings.toArray(new Ordering[orderings.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Ordering orderingFromString(String field) {
|
private Ordering orderingFromString(String field) {
|
||||||
|
@ -37,10 +34,6 @@ public class ColumnOrderings {
|
||||||
ordering.fieldName(ordering.getFieldName().replace("|count|", "")).columnType(Ordering.ColumnType.COUNT);
|
ordering.fieldName(ordering.getFieldName().replace("|count|", "")).columnType(Ordering.ColumnType.COUNT);
|
||||||
else if (ordering.getFieldName().contains("|join|"))
|
else if (ordering.getFieldName().contains("|join|"))
|
||||||
ordering.fieldName(ordering.getFieldName().replace("|join|", "")).columnType(Ordering.ColumnType.JOIN_COLUMN);
|
ordering.fieldName(ordering.getFieldName().replace("|join|", "")).columnType(Ordering.ColumnType.JOIN_COLUMN);
|
||||||
else if (ordering.getFieldName().equals("asc"))
|
|
||||||
ordering.fieldName("label").orderByType(Ordering.OrderByType.ASC);
|
|
||||||
else if (ordering.getFieldName().equals("desc"))
|
|
||||||
ordering.fieldName("label").orderByType(Ordering.OrderByType.DESC);
|
|
||||||
return ordering;
|
return ordering;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package eu.eudat.data.query.definition.helpers;
|
package eu.eudat.data.query.definition.helpers;
|
||||||
|
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
|
|
||||||
public class SelectionFields {
|
public class SelectionFields {
|
||||||
|
|
||||||
@ApiModelProperty(value = "fields", name = "fields", dataType = "String[]", example = "[]")
|
|
||||||
private String[] fields;
|
private String[] fields;
|
||||||
|
|
||||||
public String[] getFields() {
|
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;
|
package eu.eudat.data.query.items.item.datasetprofile;
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
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.PaginationService;
|
||||||
|
import eu.eudat.data.query.definition.Query;
|
||||||
import eu.eudat.data.query.definition.TableQuery;
|
import eu.eudat.data.query.definition.TableQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DatasetProfileAutocompleteRequest extends TableQuery<DatasetProfileCriteria, DescriptionTemplate, UUID> {
|
public class DatasetProfileAutocompleteRequest extends TableQuery<DatasetProfileCriteria,DatasetProfile, UUID> {
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DescriptionTemplate> applyCriteria() {
|
public QueryableList<DatasetProfile> applyCriteria() {
|
||||||
QueryableList<DescriptionTemplate> query = this.getQuery();
|
QueryableList<DatasetProfile> query = this.getQuery();
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DescriptionTemplate> applyPaging(QueryableList<DescriptionTemplate> items) {
|
public QueryableList<DatasetProfile> applyPaging(QueryableList<DatasetProfile> items) {
|
||||||
return PaginationService.applyPaging(items, this);
|
return PaginationService.applyPaging(items, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
package eu.eudat.data.query.items.item.datasetprofile;
|
package eu.eudat.data.query.items.item.datasetprofile;
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.DatasetProfileWizardCriteria;
|
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.data.query.definition.Query;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
|
||||||
public class DatasetProfileWizardAutocompleteRequest extends Query<DatasetProfileWizardCriteria, DescriptionTemplate> {
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class DatasetProfileWizardAutocompleteRequest extends Query<DatasetProfileWizardCriteria,DatasetProfile> {
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DescriptionTemplate> applyCriteria() {
|
public QueryableList<DatasetProfile> applyCriteria() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
package eu.eudat.data.query.items.table.datasetprofile;
|
package eu.eudat.data.query.items.table.datasetprofile;
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
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.data.query.definition.TableQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DatasetProfileTableRequestItem extends TableQuery<DatasetProfileCriteria, DescriptionTemplate, UUID> {
|
public class DatasetProfileTableRequestItem extends TableQuery<DatasetProfileCriteria, DatasetProfile, UUID> {
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DescriptionTemplate> applyCriteria() {
|
public QueryableList<DatasetProfile> applyCriteria() {
|
||||||
QueryableList<DescriptionTemplate> query = this.getQuery();
|
QueryableList<DatasetProfile> query = this.getQuery();
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DescriptionTemplate> applyPaging(QueryableList<DescriptionTemplate> items) {
|
public QueryableList<DatasetProfile> applyPaging(QueryableList<DatasetProfile> items) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ public class DatasetCriteria extends Criteria {
|
||||||
private List<UUID> collaborators;
|
private List<UUID> collaborators;
|
||||||
private Boolean allowAllVersions;
|
private Boolean allowAllVersions;
|
||||||
private List<String> organiztions;
|
private List<String> organiztions;
|
||||||
private Boolean hasTags;
|
|
||||||
private List<Tag> tags;
|
private List<Tag> tags;
|
||||||
private boolean isPublic;
|
private boolean isPublic;
|
||||||
private Short grantStatus;
|
private Short grantStatus;
|
||||||
|
@ -145,12 +144,4 @@ public class DatasetCriteria extends Criteria {
|
||||||
public void setSortCriteria(List<SortCriteria> sortCriteria) {
|
public void setSortCriteria(List<SortCriteria> sortCriteria) {
|
||||||
this.sortCriteria = sortCriteria;
|
this.sortCriteria = sortCriteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getHasTags() {
|
|
||||||
return hasTags;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHasTags(Boolean hasTags) {
|
|
||||||
this.hasTags = hasTags;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ public class DmpCriteria extends Criteria {
|
||||||
private boolean allowAllVersions;
|
private boolean allowAllVersions;
|
||||||
private Short grantStatus;
|
private Short grantStatus;
|
||||||
private int offset;
|
private int offset;
|
||||||
private Integer size;
|
private int size;
|
||||||
private List<SortCriteria> sortCriteria;
|
private List<SortCriteria> sortCriteria;
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,11 +116,11 @@ public class DmpCriteria extends Criteria {
|
||||||
this.offset = offset;
|
this.offset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getSize() {
|
public int getSize() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSize(Integer size) {
|
public void setSize(int size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,9 +231,7 @@ public class Dataset implements ElasticEntity<Dataset> {
|
||||||
if (this.group != null) {
|
if (this.group != null) {
|
||||||
builder.field("group", this.group.toString());
|
builder.field("group", this.group.toString());
|
||||||
}
|
}
|
||||||
if (this.grant != null) {
|
|
||||||
builder.field("grant", this.grant.toString());
|
builder.field("grant", this.grant.toString());
|
||||||
}
|
|
||||||
if (collaborators != null) {
|
if (collaborators != null) {
|
||||||
builder.startArray("collaborators");
|
builder.startArray("collaborators");
|
||||||
this.collaborators.forEach(x -> {
|
this.collaborators.forEach(x -> {
|
||||||
|
@ -285,13 +283,6 @@ public class Dataset implements ElasticEntity<Dataset> {
|
||||||
@Override
|
@Override
|
||||||
public Dataset fromElasticEntity(Map<String, Object> fields) {
|
public Dataset fromElasticEntity(Map<String, Object> fields) {
|
||||||
if (fields != null) {
|
if (fields != null) {
|
||||||
if (fields.size() == 1) {
|
|
||||||
if (fields.containsKey("id")) {
|
|
||||||
this.id = (String) fields.get("id");
|
|
||||||
} else if (fields.containsKey("tags")) {
|
|
||||||
this.tags = ((List<HashMap>) fields.get("tags")).stream().map(hashMap -> new Tag().fromElasticEntity(hashMap)).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
}else if (fields.size() > 1) {
|
|
||||||
this.id = (String) fields.get("id");
|
this.id = (String) fields.get("id");
|
||||||
if (fields.get("tags") != null) {
|
if (fields.get("tags") != null) {
|
||||||
this.tags = ((List<HashMap>) fields.get("tags")).stream().map(hashMap -> new Tag().fromElasticEntity(hashMap)).collect(Collectors.toList());
|
this.tags = ((List<HashMap>) fields.get("tags")).stream().map(hashMap -> new Tag().fromElasticEntity(hashMap)).collect(Collectors.toList());
|
||||||
|
@ -302,9 +293,7 @@ public class Dataset implements ElasticEntity<Dataset> {
|
||||||
this.status = Short.valueOf((String) fields.get("status"));
|
this.status = Short.valueOf((String) fields.get("status"));
|
||||||
this.dmp = UUID.fromString((String) fields.get("dmp"));
|
this.dmp = UUID.fromString((String) fields.get("dmp"));
|
||||||
this.group = UUID.fromString((String) fields.get("group"));
|
this.group = UUID.fromString((String) fields.get("group"));
|
||||||
if (fields.get("grant") != null) {
|
|
||||||
this.grant = UUID.fromString((String) fields.get("grant"));
|
this.grant = UUID.fromString((String) fields.get("grant"));
|
||||||
}
|
|
||||||
if (fields.get("created") != null)
|
if (fields.get("created") != null)
|
||||||
this.created = Date.from(Instant.parse((String) fields.get("created")));
|
this.created = Date.from(Instant.parse((String) fields.get("created")));
|
||||||
if (fields.get("modified") != null)
|
if (fields.get("modified") != null)
|
||||||
|
@ -327,7 +316,6 @@ public class Dataset implements ElasticEntity<Dataset> {
|
||||||
}
|
}
|
||||||
this.formData = (String) fields.get("formData");
|
this.formData = (String) fields.get("formData");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
package eu.eudat.elastic.entities;
|
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 org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
|
public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String name;
|
private String name;
|
||||||
private Map<String, Object> data;
|
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -30,25 +26,11 @@ public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(Map<String, Object> data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
public XContentBuilder toElasticEntity(XContentBuilder builder) throws IOException {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field("id", this.id.toString());
|
builder.field("id", this.id.toString());
|
||||||
builder.field("name", this.name);
|
builder.field("name", this.name);
|
||||||
if(this.data != null) {
|
|
||||||
builder.field("data", new ObjectMapper().writeValueAsString(this.data));
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
builder.field("data", "");
|
|
||||||
}
|
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
@ -57,12 +39,6 @@ public class DatasetTempalate implements ElasticEntity<DatasetTempalate> {
|
||||||
public DatasetTempalate fromElasticEntity(Map<String, Object> fields) {
|
public DatasetTempalate fromElasticEntity(Map<String, Object> fields) {
|
||||||
this.id = UUID.fromString((String) fields.get("id"));
|
this.id = UUID.fromString((String) fields.get("id"));
|
||||||
this.name = (String) fields.get("name");
|
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;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -57,7 +56,7 @@ public class Dmp implements ElasticEntity<Dmp> {
|
||||||
private Date modified;
|
private Date modified;
|
||||||
private Date finalizedAt;
|
private Date finalizedAt;
|
||||||
private Date publishedAt;
|
private Date publishedAt;
|
||||||
private List<Doi> dois;
|
private String doi;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -203,12 +202,12 @@ public class Dmp implements ElasticEntity<Dmp> {
|
||||||
this.publishedAt = publishedAt;
|
this.publishedAt = publishedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Doi> getDois() {
|
public String getDoi() {
|
||||||
return dois;
|
return doi;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDois(List<Doi> dois) {
|
public void setDoi(String doi) {
|
||||||
this.dois = dois;
|
this.doi = doi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -280,28 +279,14 @@ public class Dmp implements ElasticEntity<Dmp> {
|
||||||
builder.field(MapKey.MODIFIED.getName(), this.modified);
|
builder.field(MapKey.MODIFIED.getName(), this.modified);
|
||||||
builder.field(MapKey.FINALIZEDAT.getName(), this.finalizedAt);
|
builder.field(MapKey.FINALIZEDAT.getName(), this.finalizedAt);
|
||||||
builder.field(MapKey.PUBLISHEDAT.getName(), this.publishedAt);
|
builder.field(MapKey.PUBLISHEDAT.getName(), this.publishedAt);
|
||||||
if (this.dois != null && !this.dois.isEmpty()) {
|
builder.field(MapKey.DOI.getName(), this.doi);
|
||||||
builder.startArray(MapKey.DOIS.getName());
|
|
||||||
this.dois.forEach(doi -> {
|
|
||||||
try {
|
|
||||||
doi.toElasticEntity(builder);
|
|
||||||
} catch (IOException e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.endArray();
|
|
||||||
}
|
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dmp fromElasticEntity(Map<String, Object> fields) {
|
public Dmp fromElasticEntity(Map<String, Object> fields) {
|
||||||
if (fields == null || fields.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
this.id = UUID.fromString((String) fields.get(MapKey.ID.getName()));
|
this.id = UUID.fromString((String) fields.get(MapKey.ID.getName()));
|
||||||
if (fields.size() > 1) {
|
|
||||||
this.label = (String) fields.get(MapKey.LABEL.getName());
|
this.label = (String) fields.get(MapKey.LABEL.getName());
|
||||||
this.description = (String) fields.get(MapKey.DESCRIPTION.getName());
|
this.description = (String) fields.get(MapKey.DESCRIPTION.getName());
|
||||||
if (fields.get(MapKey.GROUPID.getName()) != null) {
|
if (fields.get(MapKey.GROUPID.getName()) != null) {
|
||||||
|
@ -323,28 +308,10 @@ public class Dmp implements ElasticEntity<Dmp> {
|
||||||
if (fields.get(MapKey.DATASETS.getName()) != null) {
|
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());
|
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()));
|
this.grant = UUID.fromString((String) fields.get(MapKey.GRANT.getName()));
|
||||||
}
|
|
||||||
if (fields.get(MapKey.GRANTSTATUS.getName()) != null) {
|
if (fields.get(MapKey.GRANTSTATUS.getName()) != null) {
|
||||||
this.grantStatus = Short.valueOf(fields.get(MapKey.GRANTSTATUS.getName()).toString());
|
this.grantStatus = Short.valueOf(fields.get(MapKey.GRANTSTATUS.getName()).toString());
|
||||||
}
|
}
|
||||||
if (fields.containsKey(MapKey.CREATED.getName())) {
|
|
||||||
this.created = Date.from(Instant.parse(fields.get(MapKey.CREATED.getName()).toString()));
|
|
||||||
}
|
|
||||||
if (fields.containsKey(MapKey.MODIFIED.getName())) {
|
|
||||||
this.modified = Date.from(Instant.parse(fields.get(MapKey.MODIFIED.getName()).toString()));
|
|
||||||
}
|
|
||||||
if (fields.get(MapKey.FINALIZEDAT.getName()) != null) {
|
|
||||||
this.finalizedAt = Date.from(Instant.parse(fields.get(MapKey.FINALIZEDAT.getName()).toString()));
|
|
||||||
}
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,7 +334,7 @@ public class Dmp implements ElasticEntity<Dmp> {
|
||||||
MODIFIED ("modified"),
|
MODIFIED ("modified"),
|
||||||
FINALIZEDAT ("finalizedAt"),
|
FINALIZEDAT ("finalizedAt"),
|
||||||
PUBLISHEDAT ("publishedAt"),
|
PUBLISHEDAT ("publishedAt"),
|
||||||
DOIS ("dois");
|
DOI ("doi");
|
||||||
|
|
||||||
private final String name;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -24,7 +24,6 @@ import org.elasticsearch.search.aggregations.bucket.filter.ParsedFilters;
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.NestedAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.nested.NestedAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.ParsedNested;
|
import org.elasticsearch.search.aggregations.bucket.nested.ParsedNested;
|
||||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||||
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
|
|
||||||
import org.elasticsearch.search.sort.SortBuilder;
|
import org.elasticsearch.search.sort.SortBuilder;
|
||||||
import org.elasticsearch.search.sort.SortBuilders;
|
import org.elasticsearch.search.sort.SortBuilders;
|
||||||
import org.elasticsearch.search.sort.SortOrder;
|
import org.elasticsearch.search.sort.SortOrder;
|
||||||
|
@ -55,7 +54,6 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
if (this.getClient() != null) {
|
if (this.getClient() != null) {
|
||||||
XContentBuilder builder = XContentFactory.jsonBuilder();
|
XContentBuilder builder = XContentFactory.jsonBuilder();
|
||||||
Dmp dmp = this.dmpRepository.findDocument(entity.getDmp().toString());
|
Dmp dmp = this.dmpRepository.findDocument(entity.getDmp().toString());
|
||||||
if (dmp != null) {
|
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
if (dmp.getDatasets() != null && !dmp.getDatasets().isEmpty()) {
|
if (dmp.getDatasets() != null && !dmp.getDatasets().isEmpty()) {
|
||||||
for (int i = 0; i < dmp.getDatasets().size(); i++) {
|
for (int i = 0; i < dmp.getDatasets().size(); i++) {
|
||||||
|
@ -74,7 +72,6 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
}
|
}
|
||||||
IndexRequest request = new IndexRequest(this.environment.getProperty("elasticsearch.index")).id(dmp.getId().toString()).source(dmp.toElasticEntity(builder));//new IndexRequest("datasets", "doc", entity.getId()).source(entity.toElasticEntity(builder));
|
IndexRequest request = new IndexRequest(this.environment.getProperty("elasticsearch.index")).id(dmp.getId().toString()).source(dmp.toElasticEntity(builder));//new IndexRequest("datasets", "doc", entity.getId()).source(entity.toElasticEntity(builder));
|
||||||
this.getClient().index(request, RequestOptions.DEFAULT);
|
this.getClient().index(request, RequestOptions.DEFAULT);
|
||||||
}
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -125,128 +122,8 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
|
|
||||||
searchSourceBuilder.size(count.intValue());
|
searchSourceBuilder.size(count.intValue());
|
||||||
|
|
||||||
List<SortBuilder> sortBuilders = new ArrayList<>();
|
|
||||||
BoolQueryBuilder boolQuery = createBoolQuery(criteria);
|
|
||||||
|
|
||||||
|
|
||||||
if (criteria.getSortCriteria() != null && !criteria.getSortCriteria().isEmpty()) {
|
|
||||||
criteria.getSortCriteria().forEach(sortCriteria -> {
|
|
||||||
switch(sortCriteria.getColumnType()) {
|
|
||||||
case COLUMN:
|
|
||||||
sortBuilders.add(SortBuilders.fieldSort("datasets." + sortCriteria.getFieldName()).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
|
||||||
break;
|
|
||||||
case JOIN_COLUMN:
|
|
||||||
List<String> fields = Arrays.asList(sortCriteria.getFieldName().split(":"));
|
|
||||||
fields.stream().filter(name -> !name.startsWith("dmp")).forEach(field -> {
|
|
||||||
sortBuilders.add(SortBuilders.fieldSort(field).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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)));
|
|
||||||
searchSourceBuilder.query(nestedQueryBuilder)/*.from(criteria.getOffset())*/.fetchSource("datasets.tags", null);
|
|
||||||
/*if (criteria.getSize() > 0) {
|
|
||||||
searchSourceBuilder.size(criteria.getSize());
|
|
||||||
}*/
|
|
||||||
sortBuilders.forEach(searchSourceBuilder::sort);
|
|
||||||
searchRequest.source(searchSourceBuilder);
|
|
||||||
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
|
||||||
return ((Stream<Dataset>)Arrays.stream(response.getHits().getHits())
|
|
||||||
.map(hit -> hit.getInnerHits().values()).flatMap(Collection::stream)
|
|
||||||
.map(SearchHits::getHits).flatMap(Arrays::stream)
|
|
||||||
.map(x -> new Dataset().fromElasticEntity(this.transformFromString(x.getSourceAsString(), Map.class)))).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Dataset> queryIds(DatasetCriteria criteria) throws IOException {
|
|
||||||
if (this.getClient() != null) {
|
|
||||||
SearchRequest searchRequest = new SearchRequest(this.environment.getProperty("elasticsearch.index"));
|
|
||||||
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
|
||||||
|
|
||||||
/*CountRequest countRequest = new CountRequest("dmps").routing("datasets").routing("id");
|
|
||||||
countRequest.query(QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("datasets.status.keyword", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList()))));
|
|
||||||
CountResponse countResponse = getClient().count(countRequest, RequestOptions.DEFAULT);
|
|
||||||
Long count = countResponse.getCount();*/
|
|
||||||
|
|
||||||
SearchRequest countRequest = new SearchRequest(this.environment.getProperty("elasticsearch.index"));
|
|
||||||
NestedAggregationBuilder nestedAggregationBuilder = AggregationBuilders.nested("by_dataset", "datasets");
|
|
||||||
FiltersAggregationBuilder filtersAggregationBuilder = AggregationBuilders.filters("dataset_query", QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("datasets.status.keyword", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList()))));
|
|
||||||
nestedAggregationBuilder.subAggregation(filtersAggregationBuilder);
|
|
||||||
SearchSourceBuilder countSourceBuilder = new SearchSourceBuilder();
|
|
||||||
countSourceBuilder.aggregation(nestedAggregationBuilder);
|
|
||||||
countRequest.source(countSourceBuilder);
|
|
||||||
SearchResponse countResponse = getClient().search(countRequest, RequestOptions.DEFAULT);
|
|
||||||
Long count = ((ParsedFilters)((ParsedNested)countResponse.getAggregations().asMap().get("by_dataset")).getAggregations().get("dataset_query")).getBuckets().get(0).getDocCount();
|
|
||||||
|
|
||||||
|
|
||||||
searchSourceBuilder.size(count.intValue());
|
|
||||||
|
|
||||||
List<SortBuilder> sortBuilders = new ArrayList<>();
|
|
||||||
BoolQueryBuilder boolQuery = createBoolQuery(criteria);
|
|
||||||
|
|
||||||
|
|
||||||
if (criteria.getSortCriteria() != null && !criteria.getSortCriteria().isEmpty()) {
|
|
||||||
criteria.getSortCriteria().forEach(sortCriteria -> {
|
|
||||||
switch(sortCriteria.getColumnType()) {
|
|
||||||
case COLUMN:
|
|
||||||
sortBuilders.add(SortBuilders.fieldSort("datasets." + sortCriteria.getFieldName()).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
|
||||||
break;
|
|
||||||
case JOIN_COLUMN:
|
|
||||||
List<String> fields = Arrays.asList(sortCriteria.getFieldName().split(":"));
|
|
||||||
fields.stream().filter(name -> !name.startsWith("dmp")).forEach(field -> {
|
|
||||||
sortBuilders.add(SortBuilders.fieldSort(field).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
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)));
|
|
||||||
searchSourceBuilder.query(nestedQueryBuilder)/*.from(criteria.getOffset()).size(criteria.getSize())*/.fetchSource("datasets.id", null);
|
|
||||||
sortBuilders.forEach(searchSourceBuilder::sort);
|
|
||||||
searchRequest.source(searchSourceBuilder);
|
|
||||||
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
|
||||||
return ((Stream<Dataset>)Arrays.stream(response.getHits().getHits())
|
|
||||||
.map(hit -> hit.getInnerHits().values()).flatMap(Collection::stream)
|
|
||||||
.map(SearchHits::getHits).flatMap(Arrays::stream)
|
|
||||||
.map(x -> new Dataset().fromElasticEntity(this.transformFromString(x.getSourceAsString(), Map.class)))).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long count(DatasetCriteria criteria) throws IOException {
|
|
||||||
if (this.getClient() != null) {
|
|
||||||
//CountRequest countRequest = new CountRequest(this.environment.getProperty("elasticsearch.index"));
|
|
||||||
|
|
||||||
SearchRequest countRequest = new SearchRequest(this.environment.getProperty("elasticsearch.index"));
|
|
||||||
BoolQueryBuilder boolQuery = createBoolQuery(criteria);
|
|
||||||
NestedAggregationBuilder nestedAggregationBuilder = AggregationBuilders.nested("by_dataset", "datasets");
|
|
||||||
FiltersAggregationBuilder filtersAggregationBuilder = AggregationBuilders.filters("dataset_query", boolQuery);
|
|
||||||
nestedAggregationBuilder.subAggregation(filtersAggregationBuilder);
|
|
||||||
SearchSourceBuilder countSourceBuilder = new SearchSourceBuilder();
|
|
||||||
countSourceBuilder.aggregation(nestedAggregationBuilder);
|
|
||||||
countRequest.source(countSourceBuilder);
|
|
||||||
SearchResponse countResponse = getClient().search(countRequest, RequestOptions.DEFAULT);
|
|
||||||
return ((ParsedFilters)((ParsedNested)countResponse.getAggregations().asMap().get("by_dataset")).getAggregations().get("dataset_query")).getBuckets().get(0).getDocCount();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.None).innerHit(new InnerHitBuilder());
|
|
||||||
countRequest.query(nestedQueryBuilder);
|
|
||||||
CountResponse response = this.getClient().count(countRequest, RequestOptions.DEFAULT);
|
|
||||||
return response.getCount();*/
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BoolQueryBuilder createBoolQuery(DatasetCriteria criteria) {
|
|
||||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("datasets.status", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList())));
|
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery("datasets.status", Stream.of(Dataset.Status.DELETED.getValue(), Dataset.Status.CANCELED.getValue()).collect(Collectors.toList())));
|
||||||
|
List<SortBuilder> sortBuilders = new ArrayList<>();
|
||||||
if (criteria.isPublic()) {
|
if (criteria.isPublic()) {
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.public", "true"));
|
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.public", "true"));
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.status", Dataset.Status.FINALISED.getValue()));
|
boolQuery = boolQuery.should(QueryBuilders.termQuery("datasets.status", Dataset.Status.FINALISED.getValue()));
|
||||||
|
@ -261,7 +138,6 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getDatasetTemplates() != null && criteria.getDatasetTemplates().size() > 0) {
|
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())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.template", criteria.getDatasetTemplates().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,17 +146,14 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getDmps() != null && criteria.getDmps().size() > 0) {
|
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())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.dmp", criteria.getDmps().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getGroupIds() != null && criteria.getGroupIds().size() > 0) {
|
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())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.group", criteria.getGroupIds().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getGrants() != null && criteria.getGrants().size() > 0) {
|
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())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.grant", criteria.getGrants().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,8 +162,7 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
|
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", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.collaborators.id.keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!criteria.isPublic()) {
|
if (!criteria.isPublic()) {
|
||||||
|
@ -300,28 +172,47 @@ public class DatasetRepository extends ElasticRepository<Dataset, DatasetCriteri
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getOrganiztions() != null && criteria.getOrganiztions().size() > 0) {
|
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()));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.organizations.id", criteria.getOrganiztions()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getTags() != null && criteria.getTags().size() > 0) {
|
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())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery("datasets.tags.name", criteria.getTags().stream().map(Tag::getName).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getHasTags() != null) {
|
|
||||||
boolQuery = criteria.getHasTags() == true ? boolQuery.should(QueryBuilders.existsQuery("datasets.tags.id")) : boolQuery.mustNot(QueryBuilders.existsQuery("datasets.tags.id"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (boolQuery.should().isEmpty() && boolQuery.mustNot().isEmpty()) {
|
if (boolQuery.should().isEmpty() && boolQuery.mustNot().isEmpty()) {
|
||||||
boolQuery.should(QueryBuilders.matchAllQuery());
|
boolQuery.should(QueryBuilders.matchAllQuery());
|
||||||
} else {
|
} else {
|
||||||
boolQuery.minimumShouldMatch(boolQuery.should().size());
|
boolQuery.minimumShouldMatch(boolQuery.should().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (criteria.getSortCriteria() != null && !criteria.getSortCriteria().isEmpty()) {
|
||||||
|
criteria.getSortCriteria().forEach(sortCriteria -> {
|
||||||
|
switch(sortCriteria.getColumnType()) {
|
||||||
|
case COLUMN:
|
||||||
|
sortBuilders.add(SortBuilders.fieldSort(sortCriteria.getFieldName()).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
||||||
|
break;
|
||||||
|
case JOIN_COLUMN:
|
||||||
|
List<String> fields = Arrays.asList(sortCriteria.getFieldName().split(":"));
|
||||||
|
fields.stream().filter(name -> !name.startsWith("dmp")).forEach(field -> {
|
||||||
|
sortBuilders.add(SortBuilders.fieldSort(field).order(SortOrder.fromString(sortCriteria.getOrderByType().name())));
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return boolQuery;
|
NestedQueryBuilder nestedQueryBuilder = QueryBuilders.nestedQuery("datasets", boolQuery, ScoreMode.Avg).innerHit(new InnerHitBuilder());
|
||||||
|
searchSourceBuilder.query(nestedQueryBuilder).from(criteria.getOffset()).size(criteria.getSize());
|
||||||
|
sortBuilders.forEach(searchSourceBuilder::sort);
|
||||||
|
searchRequest.source(searchSourceBuilder);
|
||||||
|
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
||||||
|
return ((Stream<Dataset>)Arrays.stream(response.getHits().getHits())
|
||||||
|
.map(hit -> hit.getInnerHits().values()).flatMap(Collection::stream)
|
||||||
|
.map(SearchHits::getHits).flatMap(Arrays::stream)
|
||||||
|
.map(x -> new Dataset().fromElasticEntity(this.transformFromString(x.getSourceAsString(), Map.class)))).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -99,8 +99,60 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
|
||||||
|
|
||||||
searchSourceBuilder.size(count.intValue());
|
searchSourceBuilder.size(count.intValue());
|
||||||
|
|
||||||
|
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery(Dmp.MapKey.STATUS.getName(), Collections.singletonList(Dmp.DMPStatus.DELETED.getValue())));
|
||||||
List<SortBuilder> sortBuilders = new ArrayList<>();
|
List<SortBuilder> sortBuilders = new ArrayList<>();
|
||||||
BoolQueryBuilder boolQuery = createBoolQuery(criteria);
|
if (criteria.isPublic()) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.ISPUBLIC.getName(), true));
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.STATUS.getName(), Dmp.DMPStatus.FINALISED.getValue()));
|
||||||
|
}
|
||||||
|
if (criteria.getLike() != null && !criteria.getLike().isEmpty()) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.queryStringQuery(criteria.getLike()).fields(Stream.of(new Object[][]{
|
||||||
|
{Dmp.MapKey.LABEL.getName(), 1.0f},
|
||||||
|
{Dmp.MapKey.DESCRIPTION.getName(), 1.0f}
|
||||||
|
}).collect(Collectors.toMap(data -> (String) data[0], data -> (Float) data[1]))));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getTemplates() != null && criteria.getTemplates().size() > 0) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.TEMPLATES.getName() + ".id.keyword", criteria.getTemplates().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getStatus() != null) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.STATUS.getName(), criteria.getStatus().intValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getGroupIds() != null && criteria.getGroupIds().size() > 0) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.GROUPID.getName(), criteria.getGroupIds().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getGrants() != null && criteria.getGrants().size() > 0) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.GRANT.getName() + ".keyword", criteria.getGrants().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.COLLABORATORS.getName() + ".id.keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getRoles() != null && criteria.getRoles().size() > 0) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.COLLABORATORS.getName() + ".role.keyword", criteria.getRoles()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!criteria.isAllowAllVersions()) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(criteria.isPublic() ? Dmp.MapKey.LASTPUBLICVERSION.getName() : Dmp.MapKey.LASTVERSION.getName(), true));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getOrganizations() != null && criteria.getOrganizations().size() > 0) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.ORGANIZATIONS.getName() + ".id.keyword", criteria.getOrganizations().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getGrantStatus() != null) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.GRANTSTATUS.getName(), criteria.getGrantStatus()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (boolQuery.should().isEmpty() && boolQuery.mustNot().isEmpty()) {
|
||||||
|
boolQuery = boolQuery.should(QueryBuilders.matchAllQuery());
|
||||||
|
} else {
|
||||||
|
boolQuery.minimumShouldMatch(boolQuery.should().size());
|
||||||
|
}
|
||||||
|
|
||||||
if (criteria.getSortCriteria() != null && !criteria.getSortCriteria().isEmpty()) {
|
if (criteria.getSortCriteria() != null && !criteria.getSortCriteria().isEmpty()) {
|
||||||
criteria.getSortCriteria().forEach(sortCriteria -> {
|
criteria.getSortCriteria().forEach(sortCriteria -> {
|
||||||
|
@ -118,10 +170,8 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
searchSourceBuilder.query(boolQuery).from(criteria.getOffset()).fetchSource("id", null);
|
|
||||||
if (criteria.getSize() != null && criteria.getSize() > 0) {
|
searchSourceBuilder.query(boolQuery).from(criteria.getOffset()).size(criteria.getSize());
|
||||||
searchSourceBuilder.size(criteria.getSize());
|
|
||||||
}
|
|
||||||
sortBuilders.forEach(searchSourceBuilder::sort);
|
sortBuilders.forEach(searchSourceBuilder::sort);
|
||||||
searchRequest.source(searchSourceBuilder);
|
searchRequest.source(searchSourceBuilder);
|
||||||
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
SearchResponse response = this.getClient().search(searchRequest, RequestOptions.DEFAULT);
|
||||||
|
@ -130,21 +180,10 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Long count(DmpCriteria criteria) throws IOException {
|
public Long count(DmpCriteria criteria) throws IOException {
|
||||||
if (this.getClient() != null) {
|
if (this.getClient() != null) {
|
||||||
CountRequest countRequest = new CountRequest(this.environment.getProperty("elasticsearch.index"));
|
CountRequest countRequest = new CountRequest(this.environment.getProperty("elasticsearch.index"));
|
||||||
|
|
||||||
BoolQueryBuilder boolQuery = createBoolQuery(criteria);
|
|
||||||
|
|
||||||
countRequest.query(boolQuery);
|
|
||||||
CountResponse response = this.getClient().count(countRequest, RequestOptions.DEFAULT);
|
|
||||||
return response.getCount();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BoolQueryBuilder createBoolQuery(DmpCriteria criteria) {
|
|
||||||
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery(Dmp.MapKey.STATUS.getName(), Collections.singletonList(Dmp.DMPStatus.DELETED.getValue())));
|
BoolQueryBuilder boolQuery = QueryBuilders.boolQuery().mustNot(QueryBuilders.termsQuery(Dmp.MapKey.STATUS.getName(), Collections.singletonList(Dmp.DMPStatus.DELETED.getValue())));
|
||||||
if (criteria.isPublic()) {
|
if (criteria.isPublic()) {
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.ISPUBLIC.getName(), true));
|
boolQuery = boolQuery.should(QueryBuilders.termQuery(Dmp.MapKey.ISPUBLIC.getName(), true));
|
||||||
|
@ -174,7 +213,7 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
|
if (criteria.getCollaborators() != null && criteria.getCollaborators().size() > 0) {
|
||||||
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.COLLABORATORS.getName() + ".id.keyword", criteria.getCollaborators().stream().filter(Objects::nonNull).map(UUID::toString).collect(Collectors.toList())));
|
boolQuery = boolQuery.should(QueryBuilders.termsQuery(Dmp.MapKey.COLLABORATORS.getName() + ".id.keyword", criteria.getCollaborators().stream().map(UUID::toString).collect(Collectors.toList())));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!criteria.isAllowAllVersions()) {
|
if (!criteria.isAllowAllVersions()) {
|
||||||
|
@ -194,7 +233,12 @@ public class DmpRepository extends ElasticRepository<Dmp, DmpCriteria> {
|
||||||
} else {
|
} else {
|
||||||
boolQuery.minimumShouldMatch(boolQuery.should().size());
|
boolQuery.minimumShouldMatch(boolQuery.should().size());
|
||||||
}
|
}
|
||||||
return boolQuery;
|
|
||||||
|
countRequest.query(boolQuery);
|
||||||
|
CountResponse response = this.getClient().count(countRequest, RequestOptions.DEFAULT);
|
||||||
|
return response.getCount();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean createIndex() {
|
public boolean createIndex() {
|
||||||
|
|
|
@ -30,7 +30,6 @@ public abstract class ElasticRepository<T extends ElasticEntity,C extends Criter
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warn("Unable to connect to Elastic Services");
|
logger.warn("Unable to connect to Elastic Services");
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
this.client = null;
|
this.client = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ public interface Repository<ET extends ElasticEntity, C extends Criteria> {
|
||||||
|
|
||||||
List<ET> query(C criteria) throws ExecutionException, InterruptedException, IOException;
|
List<ET> query(C criteria) throws ExecutionException, InterruptedException, IOException;
|
||||||
|
|
||||||
Long count(C criteria) throws ExecutionException, InterruptedException, IOException;
|
|
||||||
|
|
||||||
boolean exists() throws IOException;
|
boolean exists() throws IOException;
|
||||||
|
|
||||||
void clear() throws IOException;
|
void clear() throws IOException;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<version>2.5.2</version>
|
<version>1.5.9.RELEASE</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
@ -27,27 +27,25 @@
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
|
||||||
<dmp-backend-commons.version>0.0.1-SNAPSHOT</dmp-backend-commons.version>
|
<dmp-backend-commons.version>0.0.1-SNAPSHOT</dmp-backend-commons.version>
|
||||||
<org.springframework.version>5.3.8</org.springframework.version>
|
<org.springframework.version>4.3.8.RELEASE</org.springframework.version>
|
||||||
<!-- <org.springframeweu.eudat.logic.securityrity.version>3.2.10.RELEASE</org.springframeweu.eudat.logic.securityrity.version> -->
|
<!-- <org.springframeweu.eudat.logic.securityrity.version>3.2.10.RELEASE</org.springframeweu.eudat.logic.securityrity.version> -->
|
||||||
<org.springframework.security.version>5.3.10.RELEASE</org.springframework.security.version>
|
<org.springframework.security.version>4.2.3.RELEASE</org.springframework.security.version>
|
||||||
<!--<com.sun.jersey.version>1.19.1</com.sun.jersey.version>-->
|
<com.sun.jersey.version>1.19.1</com.sun.jersey.version>
|
||||||
<!--
|
|
||||||
<org.apache.tomcat.tomcat-jdbc.version>7.0.35</org.apache.tomcat.tomcat-jdbc.version>
|
<org.apache.tomcat.tomcat-jdbc.version>7.0.35</org.apache.tomcat.tomcat-jdbc.version>
|
||||||
-->
|
<com.fasterxml.jackson>2.8.4</com.fasterxml.jackson>
|
||||||
<!--<com.fasterxml.jackson>2.9.0</com.fasterxml.jackson>-->
|
|
||||||
|
|
||||||
<hibernate.version>5.5.3.Final</hibernate.version>
|
<hibernate.version>5.2.11.Final</hibernate.version>
|
||||||
|
|
||||||
<commons-codec.version>1.9</commons-codec.version>
|
<commons-codec.version>1.9</commons-codec.version>
|
||||||
<org.junit.version>4.11</org.junit.version>
|
<org.junit.version>4.11</org.junit.version>
|
||||||
<log4j.version>1.2.17</log4j.version>
|
<log4j.version>1.2.17</log4j.version>
|
||||||
<log4j2.version>2.15.0</log4j2.version>
|
<slf4j.version>1.7.12</slf4j.version>
|
||||||
<slf4j.version>1.7.15</slf4j.version>
|
<jetty.version>9.0.7.v20131107
|
||||||
<!--<jetty.version>11.0.5
|
</jetty.version> <!-- Adapt this to a version found on http://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-maven-plugin/ -->
|
||||||
</jetty.version>--> <!-- Adapt this to a version found on http://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-maven-plugin/ -->
|
|
||||||
<logback.version>1.2.3</logback.version>
|
<logback.version>1.2.3</logback.version>
|
||||||
<!-- <javax.inject.version>1</javax.inject.version>-->
|
<javax.inject.version>1</javax.inject.version>
|
||||||
<!--<javax.servlet.servlet-api.version>3.0.1</javax.servlet.servlet-api.version>-->
|
<javax.servlet.servlet-api.version>3.0.1</javax.servlet.servlet-api.version>
|
||||||
|
<docker.image.prefix>ikalyvas</docker.image.prefix>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -60,7 +58,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context-support</artifactId>
|
<artifactId>spring-context-support</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>4.0.0.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -141,7 +139,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
<artifactId>jackson-dataformat-xml</artifactId>
|
<artifactId>jackson-dataformat-xml</artifactId>
|
||||||
<version>2.12.3</version>
|
<version>2.9.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
@ -149,13 +147,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-core</artifactId>
|
<artifactId>jackson-core</artifactId>
|
||||||
<version>2.12.3</version>
|
<version>2.9.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackeu.eudat.corecore/jackson-databind -->
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackeu.eudat.corecore/jackson-databind -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.12.3</version>
|
<version>2.9.4</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- g/a spring -->
|
<!-- g/a spring -->
|
||||||
|
@ -173,13 +171,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
<version>4.1.1</version>
|
<version>4.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi</artifactId>
|
<artifactId>poi</artifactId>
|
||||||
<version>4.1.1</version>
|
<version>4.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop -->
|
<!-- https://mvnrepository.com/artifact/org.apache.xmlgraphics/fop -->
|
||||||
|
@ -188,12 +186,6 @@
|
||||||
<artifactId>fop</artifactId>
|
<artifactId>fop</artifactId>
|
||||||
<version>2.3</version>
|
<version>2.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.jsoup</groupId>
|
|
||||||
<artifactId>jsoup</artifactId>
|
|
||||||
<version>1.14.3</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.pdf -->
|
<!-- https://mvnrepository.com/artifact/fr.opensagres.xdocreport/org.apache.poi.xwpf.converter.pdf -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.opensagres.xdocreport</groupId>
|
<groupId>fr.opensagres.xdocreport</groupId>
|
||||||
|
@ -219,10 +211,10 @@
|
||||||
<version>2.1</version>
|
<version>2.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--<dependency>
|
<dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||||
</dependency>-->
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.elasticsearch.client</groupId>
|
<groupId>org.elasticsearch.client</groupId>
|
||||||
|
@ -230,11 +222,11 @@
|
||||||
<version>7.6.0</version>
|
<version>7.6.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-to-slf4j</artifactId>
|
<artifactId>log4j-to-slf4j</artifactId>
|
||||||
<version>2.8.2</version>
|
<version>2.8.2</version>
|
||||||
</dependency>-->
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
|
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -265,53 +257,36 @@
|
||||||
<version>1.3.1</version>
|
<version>1.3.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/javax.validation/validation-api -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.validation</groupId>
|
|
||||||
<artifactId>validation-api</artifactId>
|
|
||||||
<version>2.0.1.Final</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- The client -->
|
<!-- The client -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.prometheus</groupId>
|
<groupId>io.prometheus</groupId>
|
||||||
<artifactId>simpleclient</artifactId>
|
<artifactId>simpleclient</artifactId>
|
||||||
<version>0.11.0</version>
|
<version>0.10.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Hotspot JVM metrics-->
|
<!-- Hotspot JVM metrics-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.prometheus</groupId>
|
<groupId>io.prometheus</groupId>
|
||||||
<artifactId>simpleclient_hotspot</artifactId>
|
<artifactId>simpleclient_hotspot</artifactId>
|
||||||
<version>0.11.0</version>
|
<version>0.10.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Exposition HTTPServer-->
|
<!-- Exposition HTTPServer-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.prometheus</groupId>
|
<groupId>io.prometheus</groupId>
|
||||||
<artifactId>simpleclient_httpserver</artifactId>
|
<artifactId>simpleclient_httpserver</artifactId>
|
||||||
<version>0.11.0</version>
|
<version>0.10.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Pushgateway exposition-->
|
<!-- Pushgateway exposition-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.prometheus</groupId>
|
<groupId>io.prometheus</groupId>
|
||||||
<artifactId>simpleclient_pushgateway</artifactId>
|
<artifactId>simpleclient_pushgateway</artifactId>
|
||||||
<version>0.11.0</version>
|
<version>0.10.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/io.micrometer/micrometer-registry-prometheus -->
|
<!-- Pushgateway exposition-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.micrometer</groupId>
|
<groupId>io.prometheus</groupId>
|
||||||
<artifactId>micrometer-registry-prometheus</artifactId>
|
<artifactId>simpleclient_spring_boot</artifactId>
|
||||||
<version>1.7.1</version>
|
<version>0.10.0</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<!-- Micormeter core dependecy -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.micrometer</groupId>
|
|
||||||
<artifactId>micrometer-core</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -327,18 +302,6 @@
|
||||||
<packaging.type>jar</packaging.type>
|
<packaging.type>jar</packaging.type>
|
||||||
</properties>
|
</properties>
|
||||||
</profile>
|
</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>
|
<profile>
|
||||||
<id>production</id>
|
<id>production</id>
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -4,8 +4,8 @@ import eu.eudat.queryable.jpa.predicates.*;
|
||||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||||
import eu.eudat.queryable.types.SelectionField;
|
import eu.eudat.queryable.types.SelectionField;
|
||||||
|
|
||||||
import javax.persistence.criteria.Join;
|
import javax.persistence.TypedQuery;
|
||||||
import javax.persistence.criteria.JoinType;
|
import javax.persistence.criteria.Expression;
|
||||||
import javax.persistence.criteria.Subquery;
|
import javax.persistence.criteria.Subquery;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -44,8 +44,6 @@ public interface QueryableList<T extends DataEntity> {
|
||||||
|
|
||||||
QueryableList<T> orderBy(OrderByPredicate<T> predicate);
|
QueryableList<T> orderBy(OrderByPredicate<T> predicate);
|
||||||
|
|
||||||
QueryableList<T> groupBy(GroupByPredicate<T> predicate);
|
|
||||||
|
|
||||||
QueryableList<T> withHint(String hint);
|
QueryableList<T> withHint(String hint);
|
||||||
|
|
||||||
Long count();
|
Long count();
|
||||||
|
@ -69,8 +67,4 @@ public interface QueryableList<T extends DataEntity> {
|
||||||
<U extends Comparable> Subquery<U> subQueryMax(SinglePredicate<T> predicate, List<SelectionField> fields, Class<U> uClass);
|
<U extends Comparable> Subquery<U> subQueryMax(SinglePredicate<T> predicate, List<SelectionField> fields, Class<U> uClass);
|
||||||
|
|
||||||
<U extends Comparable> Subquery<U> subQueryMax(NestedQuerySinglePredicate<T> predicate, List<SelectionField> fields, Class<U> uClass);
|
<U extends Comparable> Subquery<U> subQueryMax(NestedQuerySinglePredicate<T> predicate, List<SelectionField> fields, Class<U> uClass);
|
||||||
|
|
||||||
Join getJoin(String field, JoinType type);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package eu.eudat.queryable.collector;
|
package eu.eudat.queryable.collector;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
|
|
||||||
import javax.persistence.Tuple;
|
import javax.persistence.Tuple;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -12,13 +9,9 @@ import java.util.stream.Collectors;
|
||||||
public class Collector {
|
public class Collector {
|
||||||
|
|
||||||
public List<Map> buildFromTuple(List<Tuple> results, Map<Object, List<Tuple>> groupedResults, List<String> fields, String key) {
|
public List<Map> buildFromTuple(List<Tuple> results, Map<Object, List<Tuple>> groupedResults, List<String> fields, String key) {
|
||||||
return results.stream().map(tuple -> {
|
return groupedResults.keySet().stream()
|
||||||
Map<String, Object> parsedResult = new HashMap<>();
|
|
||||||
tuple.getElements().forEach(tupleElement -> parsedResult.put(tupleElement.getAlias(), tuple.get(tupleElement.getAlias())));
|
|
||||||
return parsedResult;
|
|
||||||
}).collect(Collectors.toList());/*groupedResults.keySet().stream()
|
|
||||||
.map(x -> buildOne(groupedResults.get(x), fields, key))
|
.map(x -> buildOne(groupedResults.get(x), fields, key))
|
||||||
.collect(Collectors.toList());*/
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map buildOne(List<Tuple> tuples, List<String> fields, String key) {
|
private Map buildOne(List<Tuple> tuples, List<String> fields, String key) {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package eu.eudat.queryable.jpa.hibernatequeryablelist;
|
package eu.eudat.queryable.jpa.hibernatequeryablelist;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.collector.Collector;
|
import eu.eudat.queryable.collector.Collector;
|
||||||
import eu.eudat.queryable.exceptions.NotSingleResultException;
|
import eu.eudat.queryable.exceptions.NotSingleResultException;
|
||||||
|
@ -34,7 +33,6 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
private List<NestedQuerySinglePredicate<T>> nestedPredicates = new LinkedList<>();
|
private List<NestedQuerySinglePredicate<T>> nestedPredicates = new LinkedList<>();
|
||||||
private boolean distinct = false;
|
private boolean distinct = false;
|
||||||
private List<OrderByPredicate<T>> orderings = new LinkedList<>();
|
private List<OrderByPredicate<T>> orderings = new LinkedList<>();
|
||||||
private List<GroupByPredicate<T>> groupings = new LinkedList<>();
|
|
||||||
private List<String> fields = new LinkedList<>();
|
private List<String> fields = new LinkedList<>();
|
||||||
private Integer length;
|
private Integer length;
|
||||||
private Integer offset;
|
private Integer offset;
|
||||||
|
@ -64,7 +62,7 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryableList<T> selectFields() {
|
private QueryableList<T> selectFields() {
|
||||||
List<Selection> rootFields = fields.stream().map(this::convertFieldToPath).filter(Objects::nonNull).collect(Collectors.toList());
|
List<Selection> rootFields = fields.stream().map(field -> this.convertFieldToPath(field)).filter(x -> x != null).collect(Collectors.toList());
|
||||||
this.query.select(this.manager.getCriteriaBuilder().tuple(rootFields.toArray(new Selection[rootFields.size()])));
|
this.query.select(this.manager.getCriteriaBuilder().tuple(rootFields.toArray(new Selection[rootFields.size()])));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +93,7 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
return join;
|
return join;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Join getJoin(String field, JoinType type) {
|
private Join getJoin(String field, JoinType type) {
|
||||||
if (this.joinsMap.containsKey(field)) return this.joinsMap.get(field);
|
if (this.joinsMap.containsKey(field)) return this.joinsMap.get(field);
|
||||||
Join join = this.root.join(field, type);
|
Join join = this.root.join(field, type);
|
||||||
this.joinsMap.put(field, join);
|
this.joinsMap.put(field, join);
|
||||||
|
@ -135,11 +133,11 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
}
|
}
|
||||||
|
|
||||||
public <R> List<R> select(SelectPredicate<T, R> predicate) {
|
public <R> List<R> select(SelectPredicate<T, R> predicate) {
|
||||||
return this.toList().stream().map(predicate::applySelection).collect(Collectors.toList());
|
return this.toList().stream().map(item -> predicate.applySelection(item)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public <R> CompletableFuture<List<R>> selectAsync(SelectPredicate<T, R> predicate) {
|
public <R> CompletableFuture<List<R>> selectAsync(SelectPredicate<T, R> predicate) {
|
||||||
return this.toListAsync().thenApplyAsync(items -> items.stream().map(predicate::applySelection).collect(Collectors.toList()));
|
return this.toListAsync().thenApplyAsync(items -> items.stream().map(item -> predicate.applySelection(item)).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableList<T> distinct() {
|
public QueryableList<T> distinct() {
|
||||||
|
@ -152,11 +150,6 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableList<T> groupBy(GroupByPredicate<T> predicate) {
|
|
||||||
this.groupings.add(predicate);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long count() {
|
public Long count() {
|
||||||
CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder();
|
CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder();
|
||||||
CriteriaQuery<Long> criteriaQuery = criteriaBuilder.createQuery(Long.class);
|
CriteriaQuery<Long> criteriaQuery = criteriaBuilder.createQuery(Long.class);
|
||||||
|
@ -164,16 +157,8 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
if (distinct) criteriaQuery.select(criteriaBuilder.countDistinct(this.root.get("id")));
|
if (distinct) criteriaQuery.select(criteriaBuilder.countDistinct(this.root.get("id")));
|
||||||
else criteriaQuery.select(criteriaBuilder.count(this.root));
|
else criteriaQuery.select(criteriaBuilder.count(this.root));
|
||||||
criteriaQuery.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
|
criteriaQuery.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
|
||||||
if (!this.groupings.isEmpty()) criteriaQuery.groupBy(this.generateGroupPredicates(this.groupings, this.root));
|
|
||||||
//if (distinct) criteriaQuery.distinct(true);
|
//if (distinct) criteriaQuery.distinct(true);
|
||||||
|
|
||||||
//GK: Group By special case. When group by is used, since it will result in a list of how many elements have the grouped field common
|
|
||||||
// then it will instead return the number of the distinct values of the grouped field
|
|
||||||
if (this.groupings.isEmpty()) {
|
|
||||||
return this.manager.createQuery(criteriaQuery).getSingleResult();
|
return this.manager.createQuery(criteriaQuery).getSingleResult();
|
||||||
} else {
|
|
||||||
return (long) this.manager.createQuery(criteriaQuery).getResultList().size();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
|
@ -184,15 +169,8 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
if (distinct) criteriaQuery.select(criteriaBuilder.countDistinct(this.root.get("id")));
|
if (distinct) criteriaQuery.select(criteriaBuilder.countDistinct(this.root.get("id")));
|
||||||
else criteriaQuery.select(criteriaBuilder.count(this.root));
|
else criteriaQuery.select(criteriaBuilder.count(this.root));
|
||||||
criteriaQuery.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
|
criteriaQuery.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
|
||||||
if (!this.groupings.isEmpty()) criteriaQuery.groupBy(this.generateGroupPredicates(this.groupings, this.root));
|
|
||||||
//if (distinct) criteriaQuery.distinct(true);
|
//if (distinct) criteriaQuery.distinct(true);
|
||||||
return CompletableFuture.supplyAsync(() -> {
|
return CompletableFuture.supplyAsync(() -> this.manager.createQuery(criteriaQuery).getSingleResult());
|
||||||
if (this.groupings.isEmpty()) {
|
|
||||||
return this.manager.createQuery(criteriaQuery).getSingleResult();
|
|
||||||
} else {
|
|
||||||
return (long) this.manager.createQuery(criteriaQuery).getResultList().size();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,14 +205,6 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
return predicates.toArray(new Order[predicates.size()]);
|
return predicates.toArray(new Order[predicates.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Expression[] generateGroupPredicates(List<GroupByPredicate<T>> groupByPredicates, Root<T> root) {
|
|
||||||
List<Expression> predicates = new LinkedList<>();
|
|
||||||
for (GroupByPredicate<T> groupPredicate : groupByPredicates) {
|
|
||||||
predicates.add(groupPredicate.applyPredicate(this.manager.getCriteriaBuilder(), root));
|
|
||||||
}
|
|
||||||
return predicates.toArray(new Expression[predicates.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<T> toList() {
|
public List<T> toList() {
|
||||||
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
|
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
|
||||||
if (!this.fields.isEmpty()) this.query = builder.createTupleQuery();
|
if (!this.fields.isEmpty()) this.query = builder.createTupleQuery();
|
||||||
|
@ -242,20 +212,22 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
this.root = this.query.from(this.tClass);
|
this.root = this.query.from(this.tClass);
|
||||||
this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
|
this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
|
||||||
if (!this.orderings.isEmpty()) this.query.orderBy(this.generateOrderPredicates(this.orderings, this.root));
|
if (!this.orderings.isEmpty()) this.query.orderBy(this.generateOrderPredicates(this.orderings, this.root));
|
||||||
if (!this.groupings.isEmpty()) this.query.groupBy(this.generateGroupPredicates(this.groupings, this.root));
|
|
||||||
if (!this.fields.isEmpty()) this.selectFields();
|
if (!this.fields.isEmpty()) this.selectFields();
|
||||||
if (distinct) this.query.distinct(true);
|
if (distinct) this.query.distinct(true);
|
||||||
//if (!this.fields.isEmpty()) this.query.multiselect(this.parseFields(this.fields));
|
//if (!this.fields.isEmpty()) return this.toListWithFields();
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
|
||||||
if (!this.fields.isEmpty()) return this.toListWithFields().stream().map(m -> mapper.convertValue(m, this.tClass)).collect(Collectors.toList());
|
|
||||||
return this.toListWithOutFields();
|
return this.toListWithOutFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map> toListWithFields() {
|
public List<Map> toListWithFields() {
|
||||||
TypedQuery<Tuple> typedQuery = this.manager.createQuery(this.query);
|
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
|
||||||
if (this.offset != null) typedQuery.setFirstResult(this.offset);
|
if (!this.fields.isEmpty()) this.query = builder.createTupleQuery();
|
||||||
if (this.length != null) typedQuery.setMaxResults(this.length);
|
else this.query = builder.createQuery(this.tClass);
|
||||||
List<Tuple> results = typedQuery.getResultList();
|
this.root = this.query.from(this.tClass);
|
||||||
|
this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
|
||||||
|
if (!this.orderings.isEmpty()) this.query.orderBy(this.generateOrderPredicates(this.orderings, this.root));
|
||||||
|
if (!this.fields.isEmpty()) this.selectFields();
|
||||||
|
if (distinct) this.query.distinct(true);
|
||||||
|
List<Tuple> results = this.manager.createQuery(query).getResultList();
|
||||||
Map<Object, List<Tuple>> groupedResults = results.stream()
|
Map<Object, List<Tuple>> groupedResults = results.stream()
|
||||||
.collect(Collectors.groupingBy(x -> x.get("id")));
|
.collect(Collectors.groupingBy(x -> x.get("id")));
|
||||||
return this.collector.buildFromTuple(results, groupedResults, this.fields, "id");
|
return this.collector.buildFromTuple(results, groupedResults, this.fields, "id");
|
||||||
|
@ -280,7 +252,6 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
this.root = this.query.from(this.tClass);
|
this.root = this.query.from(this.tClass);
|
||||||
this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
|
this.query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
|
||||||
if (!this.orderings.isEmpty()) this.query.orderBy(this.generateOrderPredicates(this.orderings, this.root));
|
if (!this.orderings.isEmpty()) this.query.orderBy(this.generateOrderPredicates(this.orderings, this.root));
|
||||||
if (!this.groupings.isEmpty()) this.query.groupBy(this.generateGroupPredicates(this.groupings, this.root));
|
|
||||||
if (!this.fields.isEmpty()) this.selectFields();
|
if (!this.fields.isEmpty()) this.selectFields();
|
||||||
if (distinct) this.query.distinct(true);
|
if (distinct) this.query.distinct(true);
|
||||||
if (!this.fields.isEmpty()) return this.toListAsyncWithFields();
|
if (!this.fields.isEmpty()) return this.toListAsyncWithFields();
|
||||||
|
@ -385,8 +356,6 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
if (!this.orderings.isEmpty())
|
if (!this.orderings.isEmpty())
|
||||||
criteriaQuery.orderBy(this.generateOrderPredicates(this.orderings, criteriaRoot));
|
criteriaQuery.orderBy(this.generateOrderPredicates(this.orderings, criteriaRoot));
|
||||||
|
|
||||||
if (!this.groupings.isEmpty()) criteriaQuery.groupBy(this.generateGroupPredicates(this.groupings, this.root));
|
|
||||||
|
|
||||||
TypedQuery<T> typedQuery = this.manager.createQuery(criteriaQuery);
|
TypedQuery<T> typedQuery = this.manager.createQuery(criteriaQuery);
|
||||||
typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint));
|
typedQuery.setHint("javax.persistence.fetchgraph", this.manager.getEntityGraph(this.hint));
|
||||||
return typedQuery;
|
return typedQuery;
|
||||||
|
@ -497,11 +466,4 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
|
||||||
.createQuery(update)
|
.createQuery(update)
|
||||||
.executeUpdate();
|
.executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path[] parseFields(List<String> selectedFields) {
|
|
||||||
List<Path> paths = new ArrayList<>();
|
|
||||||
selectedFields.forEach(s -> paths.add(root.get(s)));
|
|
||||||
|
|
||||||
return paths.toArray(new Path[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
package eu.eudat.queryable.jpa.predicates;
|
|
||||||
|
|
||||||
import javax.persistence.criteria.CriteriaBuilder;
|
|
||||||
import javax.persistence.criteria.Expression;
|
|
||||||
import javax.persistence.criteria.Root;
|
|
||||||
|
|
||||||
public interface GroupByPredicate<T> {
|
|
||||||
Expression<T> applyPredicate(CriteriaBuilder builder, Root<T> root);
|
|
||||||
|
|
||||||
}
|
|
|
@ -26,16 +26,13 @@
|
||||||
<artifactId>queryable</artifactId>
|
<artifactId>queryable</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>eu.eudat</groupId>
|
<groupId>eu.eudat</groupId>
|
||||||
<artifactId>elastic</artifactId>
|
<artifactId>elastic</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>gr.cite.opendmp</groupId>
|
|
||||||
<artifactId>repositorydepositbase</artifactId>
|
|
||||||
<version>1.0.4</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -46,10 +43,6 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-mail</artifactId>
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
</dependency>
|
</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.googlecode.json-simple/json-simple -->
|
||||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||||
|
|
||||||
|
@ -57,37 +50,31 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-annotations</artifactId>
|
<artifactId>jackson-annotations</artifactId>
|
||||||
<version>2.12.3</version>
|
<version>2.9.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
|
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
|
||||||
<!--<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context</artifactId>
|
<artifactId>spring-context</artifactId>
|
||||||
<version>5.3.8</version>
|
<version>4.3.10.RELEASE</version>
|
||||||
</dependency>-->
|
</dependency>
|
||||||
|
|
||||||
<!-- guava eu.eudat.cache -->
|
<!-- guava eu.eudat.cache -->
|
||||||
<!-- <dependency>
|
<dependency>
|
||||||
<groupId>com.google.guava</groupId>
|
<groupId>com.google.guava</groupId>
|
||||||
<artifactId>guava</artifactId>
|
<artifactId>guava</artifactId>
|
||||||
<version>30.1.1-jre</version>
|
<version>23.0</version>
|
||||||
</dependency>-->
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support -->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.ben-manes.caffeine</groupId>
|
|
||||||
<artifactId>caffeine</artifactId>
|
|
||||||
<version>2.9.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/junit/junit -->
|
<!-- https://mvnrepository.com/artifact/junit/junit -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit-jupiter-api</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>5.7.2</version>
|
<version>4.12</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -100,17 +87,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>2.7.0</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-swagger2</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.springfox</groupId>
|
|
||||||
<artifactId>springfox-boot-starter</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- facebook Login -->
|
<!-- facebook Login -->
|
||||||
|
@ -124,7 +101,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.social</groupId>
|
<groupId>org.springframework.social</groupId>
|
||||||
<artifactId>spring-social-linkedin</artifactId>
|
<artifactId>spring-social-linkedin</artifactId>
|
||||||
<version>1.0.2.RELEASE</version>
|
<version>1.0.0.RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- tweeter login-->
|
<!-- tweeter login-->
|
||||||
|
@ -137,66 +114,6 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.opensaml</groupId>
|
|
||||||
<artifactId>opensaml-core</artifactId>
|
|
||||||
<version>${opensaml.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.opensaml</groupId>
|
|
||||||
<artifactId>opensaml-saml-api</artifactId>
|
|
||||||
<version>${opensaml.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.opensaml</groupId>
|
|
||||||
<artifactId>opensaml-saml-impl</artifactId>
|
|
||||||
<version>${opensaml.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.opensaml</groupId>
|
|
||||||
<artifactId>opensaml-soap-api</artifactId>
|
|
||||||
<version>${opensaml.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.opensaml</groupId>
|
|
||||||
<artifactId>opensaml-xmlsec-api</artifactId>
|
|
||||||
<version>${opensaml.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.opensaml</groupId>
|
|
||||||
<artifactId>opensaml-security-api</artifactId>
|
|
||||||
<version>${opensaml.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.opensaml</groupId>
|
|
||||||
<artifactId>opensaml-security-impl</artifactId>
|
|
||||||
<version>${opensaml.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.opensaml</groupId>
|
|
||||||
<artifactId>opensaml-profile-api</artifactId>
|
|
||||||
<version>${opensaml.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.opensaml</groupId>
|
|
||||||
<artifactId>xmltooling</artifactId>
|
|
||||||
<version>1.4.4</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>jakarta.xml.soap</groupId>
|
|
||||||
<artifactId>jakarta.xml.soap-api</artifactId>
|
|
||||||
<version>3.0.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.sun.xml.messaging.saaj</groupId>
|
|
||||||
<artifactId>saaj-impl</artifactId>
|
|
||||||
<version>3.0.0-M2</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -228,44 +145,10 @@
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<version>1.5.9.RELEASE</version>
|
<version>1.5.9.RELEASE</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<version>2.4</version>
|
|
||||||
<configuration>
|
|
||||||
<archive>
|
|
||||||
<manifest>
|
|
||||||
<addClasspath>true</addClasspath>
|
|
||||||
<mainClass>eu.eudat.EuDatApplication</mainClass>
|
|
||||||
<classpathPrefix>dependency-jars/</classpathPrefix>
|
|
||||||
</manifest>
|
|
||||||
</archive>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<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>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>
|
|
||||||
${project.build.directory}/dependency-jars/
|
|
||||||
</outputDirectory>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<start-class>eu.eudat.EuDatApplication</start-class>
|
<start-class>eu.eudat.EuDatApplication</start-class>
|
||||||
<opensaml.version>4.0.1</opensaml.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
|
@ -5,10 +5,10 @@ import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
import org.springframework.boot.web.support.SpringBootServletInitializer;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
|
||||||
@SpringBootApplication(scanBasePackages = {"eu.eudat", "eu.eudat.depositinterface"})
|
@SpringBootApplication
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
public class EuDatApplication extends SpringBootServletInitializer {
|
public class EuDatApplication extends SpringBootServletInitializer {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(EuDatApplication.class);
|
private static final Logger logger = LoggerFactory.getLogger(EuDatApplication.class);
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
package eu.eudat.cache;
|
|
||||||
|
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
|
||||||
import org.springframework.cache.interceptor.KeyGenerator;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
public class ExternalUrlsKeyGenerator implements KeyGenerator {
|
|
||||||
@Override
|
|
||||||
public Object generate(Object o, Method method, Object... params) {
|
|
||||||
StringBuffer stringBuffer = new StringBuffer();
|
|
||||||
stringBuffer.append(o.getClass().getSimpleName()).append("_");
|
|
||||||
stringBuffer.append(method.getName()).append("_");
|
|
||||||
for (Object param: params) {
|
|
||||||
if (param instanceof ExternalUrlCriteria) {
|
|
||||||
ExternalUrlCriteria externalUrlCriteria = (ExternalUrlCriteria) param;
|
|
||||||
stringBuffer.append(externalUrlCriteria);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return stringBuffer.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +1,12 @@
|
||||||
package eu.eudat.cache;
|
package eu.eudat.cache;
|
||||||
|
|
||||||
|
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.cache.CacheManager;
|
import org.springframework.cache.CacheManager;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.cache.caffeine.CaffeineCache;
|
import org.springframework.cache.guava.GuavaCache;
|
||||||
import org.springframework.cache.interceptor.KeyGenerator;
|
|
||||||
import org.springframework.cache.support.SimpleCacheManager;
|
import org.springframework.cache.support.SimpleCacheManager;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -30,31 +29,22 @@ public class ResponsesCache {
|
||||||
public CacheManager cacheManager() {
|
public CacheManager cacheManager() {
|
||||||
logger.info("Loading ResponsesCache...");
|
logger.info("Loading ResponsesCache...");
|
||||||
SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
|
SimpleCacheManager simpleCacheManager = new SimpleCacheManager();
|
||||||
List<CaffeineCache> caches = new ArrayList<CaffeineCache>();
|
List<GuavaCache> caches = new ArrayList<GuavaCache>();
|
||||||
caches.add(new CaffeineCache("repositories", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("repositories", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new CaffeineCache("pubrepos", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("grants", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new CaffeineCache("journals", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("projects", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new CaffeineCache("taxonomies", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("funders", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new CaffeineCache("publications", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("organisations", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new CaffeineCache("grants", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("registries", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new CaffeineCache("projects", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("services", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new CaffeineCache("funders", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("tags", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new CaffeineCache("organisations", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("researchers", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new CaffeineCache("registries", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("externalDatasets", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new CaffeineCache("services", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("currencies", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new CaffeineCache("tags", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
caches.add(new GuavaCache("licenses", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
||||||
caches.add(new CaffeineCache("researchers", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
|
||||||
caches.add(new CaffeineCache("externalDatasets", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
|
||||||
caches.add(new CaffeineCache("currencies", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
|
||||||
caches.add(new CaffeineCache("licenses", Caffeine.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
|
|
||||||
simpleCacheManager.setCaches(caches);
|
simpleCacheManager.setCaches(caches);
|
||||||
logger.info("OK");
|
logger.info("OK");
|
||||||
return simpleCacheManager;
|
return simpleCacheManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "externalUrlsKeyGenerator")
|
|
||||||
private KeyGenerator externalUrlsKeyGenerator() {
|
|
||||||
return new ExternalUrlsKeyGenerator();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package eu.eudat.configurations;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
|
||||||
import org.springframework.context.annotation.*;
|
import org.springframework.context.annotation.*;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
|
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
|
||||||
|
|
|
@ -4,15 +4,11 @@ import org.apache.http.HttpHost;
|
||||||
import org.apache.http.auth.AuthScope;
|
import org.apache.http.auth.AuthScope;
|
||||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||||
import org.apache.http.client.CredentialsProvider;
|
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.client.BasicCredentialsProvider;
|
||||||
import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
|
import org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager;
|
||||||
import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
|
import org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor;
|
||||||
import org.apache.http.nio.reactor.IOReactorException;
|
import org.apache.http.nio.reactor.IOReactorException;
|
||||||
import org.apache.http.nio.reactor.IOReactorExceptionHandler;
|
import org.apache.http.nio.reactor.IOReactorExceptionHandler;
|
||||||
import org.apache.http.ssl.SSLContextBuilder;
|
|
||||||
import org.apache.http.ssl.SSLContexts;
|
|
||||||
import org.elasticsearch.client.RestClient;
|
import org.elasticsearch.client.RestClient;
|
||||||
import org.elasticsearch.client.RestHighLevelClient;
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -22,17 +18,7 @@ import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
import javax.net.ssl.SSLContext;
|
|
||||||
import javax.net.ssl.TrustManagerFactory;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.nio.file.Paths;
|
|
||||||
import java.security.KeyStore;
|
|
||||||
import java.security.cert.Certificate;
|
|
||||||
import java.security.cert.CertificateFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 7/5/2018.
|
* Created by ikalyvas on 7/5/2018.
|
||||||
|
@ -70,46 +56,12 @@ public class ElasticSearchConfiguration {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
RestHighLevelClient client;
|
RestHighLevelClient client = new RestHighLevelClient(
|
||||||
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);
|
|
||||||
|
|
||||||
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))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
client = new RestHighLevelClient(
|
|
||||||
RestClient.builder(
|
RestClient.builder(
|
||||||
new HttpHost(this.environment.getProperty("elasticsearch.host"),
|
new HttpHost(this.environment.getProperty("elasticsearch.host"),
|
||||||
Integer.parseInt(this.environment.getProperty("elasticsearch.port")), "http"))
|
Integer.parseInt(this.environment.getProperty("elasticsearch.port")), "http"))
|
||||||
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
|
.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder
|
||||||
.setDefaultCredentialsProvider(credentialsProvider).setConnectionManager(new PoolingNHttpClientConnectionManager(ioReactor))));
|
.setDefaultCredentialsProvider(credentialsProvider).setConnectionManager(new PoolingNHttpClientConnectionManager(ioReactor))));
|
||||||
}
|
|
||||||
return client;
|
return client;
|
||||||
}catch (IOReactorException ex) {
|
}catch (IOReactorException ex) {
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Properties;
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@Profile({ "production", "staging", "docker" })
|
@Profile({ "production", "staging" })
|
||||||
@ComponentScan(basePackages = {"eu.eudat.data.entities"})
|
@ComponentScan(basePackages = {"eu.eudat.data.entities"})
|
||||||
public class ProductionDatabaseConfiguration {
|
public class ProductionDatabaseConfiguration {
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.controllers.interceptors.RequestInterceptor;
|
||||||
import eu.eudat.logic.handlers.PrincipalArgumentResolver;
|
import eu.eudat.logic.handlers.PrincipalArgumentResolver;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
|
import eu.eudat.logic.services.operations.authentication.AuthenticationService;
|
||||||
|
import io.prometheus.client.spring.boot.EnablePrometheusEndpoint;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
@ -17,6 +18,7 @@ import java.util.List;
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
|
@EnablePrometheusEndpoint
|
||||||
public class WebMVCConfiguration extends WebMvcConfigurerAdapter {
|
public class WebMVCConfiguration extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
private ApiContext apiContext;
|
private ApiContext apiContext;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service("dynamicFunderConfiguration")
|
@Service("dynamicFunderConfiguration")
|
||||||
@Profile({ "production", "staging", "docker" })
|
@Profile({ "production", "staging" })
|
||||||
public class DynamicFunderConfigurationProdImpl implements DynamicFunderConfiguration {
|
public class DynamicFunderConfigurationProdImpl implements DynamicFunderConfiguration {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DynamicFunderConfigurationProdImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(DynamicFunderConfigurationProdImpl.class);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import java.util.List;
|
||||||
* Created by ikalyvas on 3/23/2018.
|
* Created by ikalyvas on 3/23/2018.
|
||||||
*/
|
*/
|
||||||
@Service("dynamicGrantConfiguration")
|
@Service("dynamicGrantConfiguration")
|
||||||
@Profile({ "production", "staging", "docker" })
|
@Profile({ "production", "staging" })
|
||||||
public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfiguration {
|
public class DynamicGrantConfigurationProdImpl implements DynamicGrantConfiguration {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DynamicGrantConfigurationProdImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(DynamicGrantConfigurationProdImpl.class);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service("dynamicProjectConfiguration")
|
@Service("dynamicProjectConfiguration")
|
||||||
@Profile({ "production", "staging", "docker" })
|
@Profile({ "production", "staging" })
|
||||||
public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfiguration{
|
public class DynamicProjectConfigurationProdImpl implements DynamicProjectConfiguration{
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DynamicProjectConfigurationProdImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(DynamicProjectConfigurationProdImpl.class);
|
||||||
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
package eu.eudat.configurations.typedefinition;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Types;
|
|
||||||
|
|
||||||
public class PostgreSQLEnumType extends org.hibernate.type.EnumType {
|
|
||||||
|
|
||||||
public void nullSafeSet(
|
|
||||||
PreparedStatement st,
|
|
||||||
Object value,
|
|
||||||
int index,
|
|
||||||
SharedSessionContractImplementor session)
|
|
||||||
throws HibernateException, SQLException {
|
|
||||||
st.setObject(
|
|
||||||
index,
|
|
||||||
value != null ?
|
|
||||||
((Enum) value).name() :
|
|
||||||
null,
|
|
||||||
Types.OTHER
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.data.entities.DescriptionTemplate;
|
|
||||||
import eu.eudat.data.entities.UserDatasetProfile;
|
import eu.eudat.data.entities.UserDatasetProfile;
|
||||||
import eu.eudat.data.entities.UserInfo;
|
import eu.eudat.data.entities.UserInfo;
|
||||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||||
|
@ -17,10 +16,10 @@ import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
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.security.Principal;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import eu.eudat.types.MetricNames;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -32,6 +31,7 @@ import javax.validation.Valid;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static eu.eudat.types.Authorities.ADMIN;
|
import static eu.eudat.types.Authorities.ADMIN;
|
||||||
import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER;
|
import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER;
|
||||||
|
@ -44,56 +44,52 @@ public class Admin extends BaseController {
|
||||||
private DatasetProfileManager datasetProfileManager;
|
private DatasetProfileManager datasetProfileManager;
|
||||||
private UserManager userManager;
|
private UserManager userManager;
|
||||||
private ConfigLoader configLoader;
|
private ConfigLoader configLoader;
|
||||||
private final MetricsManager metricsManager;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public Admin(ApiContext apiContext, DatasetProfileManager datasetProfileManager, UserManager userManager/*, Logger logger*/, ConfigLoader configLoader, MetricsManager metricsManager) {
|
public Admin(ApiContext apiContext, DatasetProfileManager datasetProfileManager, UserManager userManager/*, Logger logger*/, ConfigLoader configLoader) {
|
||||||
super(apiContext);
|
super(apiContext);
|
||||||
this.datasetProfileManager = datasetProfileManager;
|
this.datasetProfileManager = datasetProfileManager;
|
||||||
this.userManager = userManager;
|
this.userManager = userManager;
|
||||||
this.configLoader = configLoader;
|
this.configLoader = configLoader;
|
||||||
this.metricsManager = metricsManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp"}, consumes = "application/json", produces = "application/json")
|
@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 {
|
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN ,DATASET_PROFILE_MANAGER}) Principal principal) {
|
||||||
//this.getLoggerService().info(principal, "Admin Added Dataset Profile");
|
//this.getLoggerService().info(principal, "Admin Added Dataset Profile");
|
||||||
DatasetProfile shortenProfile = profile.toShort();
|
DatasetProfile shortenProfile = profile.toShort();
|
||||||
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
||||||
modelDefinition.setType(getApiContext().getOperationsContext().getDatabaseRepository().getDescriptionTemplateTypeDao().findFromName(profile.getType()));
|
|
||||||
modelDefinition.setGroupId(UUID.randomUUID());
|
modelDefinition.setGroupId(UUID.randomUUID());
|
||||||
modelDefinition.setVersion((short) 0);
|
modelDefinition.setVersion((short) 0);
|
||||||
|
|
||||||
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 userDatasetProfile = new UserDatasetProfile();
|
||||||
userDatasetProfile.setDatasetProfile(descriptionTemplate);
|
userDatasetProfile.setDatasetProfile(datasetProfile);
|
||||||
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||||
userDatasetProfile.setUser(userInfo);
|
userDatasetProfile.setUser(userInfo);
|
||||||
userDatasetProfile.setRole(0);
|
userDatasetProfile.setRole(0);
|
||||||
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||||
datasetProfileManager.storeDatasetProfileUsers(descriptionTemplate, profile);
|
datasetProfileManager.storeDatasetProfileUsers(datasetProfile, profile);
|
||||||
|
MetricsManager.increaseValue("argos_dataset_templates", 1, "total");
|
||||||
metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricsManager.datasetTemplateStatus.get(descriptionTemplate.getStatus()) );
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
|
@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 {
|
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
||||||
DatasetProfile shortenProfile = profile.toShort();
|
DatasetProfile shortenProfile = profile.toShort();
|
||||||
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
||||||
DescriptionTemplate datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||||
datasetprofile.setDefinition(modelDefinition.getDefinition());
|
datasetprofile.setDefinition(modelDefinition.getDefinition());
|
||||||
Short oldStatus = datasetprofile.getStatus();
|
Short oldStatus = datasetprofile.getStatus();
|
||||||
datasetprofile.setStatus(modelDefinition.getStatus());
|
datasetprofile.setStatus(modelDefinition.getStatus());
|
||||||
datasetprofile.setLabel(modelDefinition.getLabel());
|
datasetprofile.setLabel(modelDefinition.getLabel());
|
||||||
datasetprofile.setDescription(modelDefinition.getDescription());
|
datasetprofile.setDescription(modelDefinition.getDescription());
|
||||||
datasetprofile.setLanguage(modelDefinition.getLanguage());
|
datasetprofile.setLanguage(modelDefinition.getLanguage());
|
||||||
DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
|
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(datasetprofile);
|
||||||
datasetProfileManager.storeDatasetProfileUsers(descriptionTemplate, profile);
|
datasetProfileManager.storeDatasetProfileUsers(datasetProfile, profile);
|
||||||
if (descriptionTemplate.getStatus() == 1 && oldStatus == 0) {
|
if (datasetProfile.getStatus() == 1 && oldStatus == 0) {
|
||||||
metricsManager.increaseValue(MetricNames.DATASET_TEMPLATE, 1, MetricNames.ACTIVE);
|
MetricsManager.increaseValue("argos_dataset_templates", 1, "active");
|
||||||
}
|
}
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.NO_MESSAGE));
|
||||||
}
|
}
|
||||||
|
@ -102,7 +98,7 @@ public class Admin extends BaseController {
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/newVersion/{id}"}, produces = "application/json")
|
@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 {
|
public ResponseEntity newVersionDatasetProfile(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
|
||||||
try {
|
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());
|
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
||||||
} catch (DatasetProfileNewVersionException exception) {
|
} 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()));
|
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 +120,8 @@ public class Admin extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/preview"}, consumes = "application/json", produces = "application/json")
|
@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 {
|
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
||||||
DescriptionTemplate modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
||||||
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(modelDefinition);
|
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(modelDefinition);
|
||||||
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
||||||
pagedDatasetProfile.buildPagedDatasetProfile(datasetProfile);
|
pagedDatasetProfile.buildPagedDatasetProfile(datasetProfile);
|
||||||
|
@ -135,8 +131,12 @@ public class Admin extends BaseController {
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
@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, DATASET_PROFILE_MANAGER}) Principal principal) {
|
public ResponseEntity<ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
||||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = this.datasetProfileManager.getDatasetProfile(id);
|
eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(id);
|
||||||
datasetprofile.setLabel(datasetprofile.getLabel() + " new ");
|
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||||
|
datasetprofile.setLabel(profile.getLabel() + " new ");
|
||||||
|
datasetprofile.setLanguage(profile.getLanguage());
|
||||||
|
datasetprofile.setDescription(profile.getDescription());
|
||||||
|
//datasetProfileManager.retrieveUsers(profile, datasetprofile);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ public class Admin extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DatasetProfile>> inactivate(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
ResponseEntity<ResponseItem<DatasetProfile>> inactivate(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
||||||
try {
|
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));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
} catch (DatasetProfileWithDatasetsExeption exception) {
|
} 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()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.UNSUCCESS_DELETE).message(exception.getMessage()));
|
||||||
|
@ -156,45 +156,36 @@ public class Admin extends BaseController {
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
|
@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 {
|
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")) {
|
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);
|
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(profile);
|
||||||
datasetProfile.setStatus(profile.getStatus());
|
datasetProfile.setStatus(profile.getStatus());
|
||||||
datasetProfile.setDescription(profile.getDescription());
|
datasetProfile.setDescription(profile.getDescription());
|
||||||
datasetProfile.setLanguage(profile.getLanguage());
|
datasetProfile.setLanguage(profile.getLanguage());
|
||||||
datasetProfile.setType(profile.getType().getName());
|
|
||||||
return this.datasetProfileManager.getDocument(datasetProfile, profile.getLabel());
|
return this.datasetProfileManager.getDocument(datasetProfile, profile.getLabel());
|
||||||
} else {
|
} else {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/upload", "/upload/{id}"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||||
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
||||||
@PathVariable(value = "id", required = false) String id,
|
@ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws IllegalAccessException, IOException {
|
||||||
@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.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile datasetProfileModel = this.datasetProfileManager.createDatasetProfileFromXml(file);
|
||||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetProfileEntity = datasetProfileModel.toAdminCompositeModel(file.getOriginalFilename());
|
eu.eudat.models.data.admin.composite.DatasetProfile datasetProfileEntity = datasetProfileModel.toAdminCompositeModel(file.getOriginalFilename());
|
||||||
DescriptionTemplate modelDefinition;
|
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext());
|
||||||
if (id == null) {
|
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||||
modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext());
|
|
||||||
DescriptionTemplate descriptionTemplate = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
|
||||||
UserDatasetProfile userDatasetProfile = new UserDatasetProfile();
|
UserDatasetProfile userDatasetProfile = new UserDatasetProfile();
|
||||||
userDatasetProfile.setDatasetProfile(descriptionTemplate);
|
userDatasetProfile.setDatasetProfile(datasetProfile);
|
||||||
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||||
userDatasetProfile.setUser(userInfo);
|
userDatasetProfile.setUser(userInfo);
|
||||||
userDatasetProfile.setRole(0);
|
userDatasetProfile.setRole(0);
|
||||||
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||||
} else {
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>()
|
||||||
modelDefinition = datasetProfileManager.createNewVersionDatasetProfile(id, datasetProfileEntity);
|
|
||||||
}
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DescriptionTemplate>>()
|
|
||||||
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = {"/getRDACommonStandards"}, produces = "application/json")
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/getSemantics"}, produces = "application/json")
|
public ResponseEntity getRDACommonStandards(@ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) {
|
||||||
public ResponseEntity<ResponseItem<List<String>>> getSemantics(@RequestParam(value = "query", required = false) String query, @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()));
|
||||||
List<String> semantics = this.datasetProfileManager.getSemantics(query);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<String>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(semantics));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class ContactEmail {
|
||||||
@RequestMapping(method = RequestMethod.POST, path = "public", consumes = "application/x-www-form-urlencoded", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, path = "public", consumes = "application/x-www-form-urlencoded", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity sendContactEmailNoAuth(@ModelAttribute PublicContactEmailModel contactEmailModel) {
|
ResponseEntity sendContactEmailNoAuth(@ModelAttribute PublicContactEmailModel contactEmailModel) {
|
||||||
|
logger.info(contactEmailModel.toString());
|
||||||
try {
|
try {
|
||||||
this.contactEmailManager.sendContactEmailNoAuth(contactEmailModel);
|
this.contactEmailManager.sendContactEmailNoAuth(contactEmailModel);
|
||||||
return ResponseEntity.status(HttpStatus.NO_CONTENT).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
|
return ResponseEntity.status(HttpStatus.NO_CONTENT).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
|
|
|
@ -2,10 +2,7 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.RequestItem;
|
import eu.eudat.data.dao.criteria.RequestItem;
|
||||||
import eu.eudat.data.entities.DMPProfile;
|
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.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
||||||
import eu.eudat.exceptions.dmpblueprint.DmpBlueprintUsedException;
|
|
||||||
import eu.eudat.logic.managers.DataManagementProfileManager;
|
import eu.eudat.logic.managers.DataManagementProfileManager;
|
||||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
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.AutoCompleteLookupItem;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
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.listingmodels.DataManagementPlanProfileListingModel;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
|
@ -30,7 +26,6 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static eu.eudat.types.Authorities.ADMIN;
|
import static eu.eudat.types.Authorities.ADMIN;
|
||||||
import static eu.eudat.types.Authorities.DATASET_PROFILE_MANAGER;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 3/21/2018.
|
* 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"));
|
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")
|
@RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DataManagementPlanProfileListingModel>> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
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));
|
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")
|
@RequestMapping(method = RequestMethod.POST, value = {"/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest, Principal principal) throws Exception {
|
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));
|
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")
|
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
|
||||||
public @ResponseBody
|
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")) {
|
if (contentType.equals("application/xml")) {
|
||||||
DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = this.dataManagementProfileManager.getSingleBlueprint(id, principal);
|
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(id, principal);
|
||||||
return this.dataManagementProfileManager.getDocument(dataManagementPlanBlueprintListingModel);
|
return this.dataManagementProfileManager.getDocument(dataManagementPlanProfileListingModel,dataManagementPlanProfileListingModel.getLabel());
|
||||||
}else {
|
}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"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||||
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
||||||
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException,IOException,Exception{
|
||||||
eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel.DmpBlueprint dmpBlueprintModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
|
eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile dmpProfileModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
|
||||||
DataManagementPlanBlueprintListingModel dmpBlueprint = dmpBlueprintModel.toDmpProfileCompositeModel(file.getOriginalFilename());
|
DataManagementPlanProfileListingModel dataManagementPlan = dmpProfileModel.toDmpProfileCompositeModel(file.getOriginalFilename());
|
||||||
this.dataManagementProfileManager.createOrUpdateBlueprint(dmpBlueprint, principal);
|
this.dataManagementProfileManager.createOrUpdate(dataManagementPlan, principal);
|
||||||
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(""));
|
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,17 @@ import eu.eudat.data.entities.DMP;
|
||||||
import eu.eudat.data.entities.Dataset;
|
import eu.eudat.data.entities.Dataset;
|
||||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
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.DataManagementPlanTableRequest;
|
||||||
|
import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest;
|
||||||
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
|
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
|
||||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
|
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
|
||||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.logic.managers.DataManagementPlanManager;
|
import eu.eudat.logic.managers.DataManagementPlanManager;
|
||||||
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||||
import eu.eudat.logic.utilities.documents.pdf.PDFUtils;
|
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetsToBeFinalized;
|
import eu.eudat.models.data.datasetwizard.DatasetsToBeFinalized;
|
||||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||||
|
@ -68,15 +69,17 @@ public class DMPs extends BaseController {
|
||||||
private DynamicGrantConfiguration dynamicGrantConfiguration;
|
private DynamicGrantConfiguration dynamicGrantConfiguration;
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
private DataManagementPlanManager dataManagementPlanManager;
|
private DataManagementPlanManager dataManagementPlanManager;
|
||||||
|
private DatasetManager datasetManager;
|
||||||
private ConfigLoader configLoader;
|
private ConfigLoader configLoader;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DMPs(ApiContext apiContext, DynamicGrantConfiguration dynamicGrantConfiguration, Environment environment,
|
public DMPs(ApiContext apiContext, DynamicGrantConfiguration dynamicGrantConfiguration, Environment environment,
|
||||||
DataManagementPlanManager dataManagementPlanManager, ConfigLoader configLoader) {
|
DataManagementPlanManager dataManagementPlanManager, DatasetManager datasetManager, ConfigLoader configLoader) {
|
||||||
super(apiContext);
|
super(apiContext);
|
||||||
this.dynamicGrantConfiguration = dynamicGrantConfiguration;
|
this.dynamicGrantConfiguration = dynamicGrantConfiguration;
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.dataManagementPlanManager = dataManagementPlanManager;
|
this.dataManagementPlanManager = dataManagementPlanManager;
|
||||||
|
this.datasetManager = datasetManager;
|
||||||
this.configLoader = configLoader;
|
this.configLoader = configLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,21 +103,11 @@ public class DMPs extends BaseController {
|
||||||
if (contentType.equals("application/xml") || contentType.equals("application/msword")) {
|
if (contentType.equals("application/xml") || contentType.equals("application/msword")) {
|
||||||
return this.dataManagementPlanManager.getDocument(id, contentType, principal, this.configLoader);
|
return this.dataManagementPlanManager.getDocument(id, contentType, principal, this.configLoader);
|
||||||
} else {
|
} else {
|
||||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, false, true);
|
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, false);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/plain/{id}"})
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity getSingleNoDatasets(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
|
|
||||||
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
|
||||||
|
|
||||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, false, false);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetProfilesUsedByDmps/paged"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/datasetProfilesUsedByDmps/paged"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DataTableData<DatasetProfileListingModel>>> getUsingDatasetProfilesPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) {
|
ResponseEntity<ResponseItem<DataTableData<DatasetProfileListingModel>>> getUsingDatasetProfilesPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) {
|
||||||
|
@ -141,7 +134,7 @@ public class DMPs extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity getSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
ResponseEntity getSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||||
// try {
|
// try {
|
||||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, true, true);
|
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, true);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||||
// } catch (Exception ex) {
|
// } catch (Exception ex) {
|
||||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
||||||
|
@ -150,7 +143,7 @@ public class DMPs extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
|
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
|
||||||
public @ResponseBody
|
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 {
|
// try {
|
||||||
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal, true);
|
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal, true);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||||
|
@ -182,21 +175,7 @@ public class DMPs extends BaseController {
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
|
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
|
||||||
try {
|
try {
|
||||||
FileEnvelope rdaJsonDocument = this.dataManagementPlanManager.getRDAJsonDocument(id, principal);
|
return this.dataManagementPlanManager.getRDAJsonDocument(id, datasetManager, 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);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body(new ResponseItem<>().message(e.getMessage()).status(ApiMessageCode.ERROR_MESSAGE));
|
return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body(new ResponseItem<>().message(e.getMessage()).status(ApiMessageCode.ERROR_MESSAGE));
|
||||||
}
|
}
|
||||||
|
@ -207,8 +186,8 @@ public class DMPs extends BaseController {
|
||||||
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
|
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
|
||||||
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
|
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
|
||||||
FileEnvelope file = this.dataManagementPlanManager.getWordDocument(id, principal, configLoader);
|
FileEnvelope file = this.dataManagementPlanManager.getWordDocument(id, principal, configLoader);
|
||||||
String name = file.getFilename().substring(0, file.getFilename().length() - 5).replace(" ", "_").replace(",", "_");
|
String name = file.getFilename().substring(0, file.getFilename().length() - 5);
|
||||||
File pdffile = PDFUtils.convertToPDF(file, environment);
|
File pdffile = datasetManager.convertToPDF(file, environment);
|
||||||
InputStream resource = new FileInputStream(pdffile);
|
InputStream resource = new FileInputStream(pdffile);
|
||||||
logger.info("Mime Type of " + name + " is " +
|
logger.info("Mime Type of " + name + " is " +
|
||||||
new MimetypesFileTypeMap().getContentType(file.getFile()));
|
new MimetypesFileTypeMap().getContentType(file.getFile()));
|
||||||
|
@ -260,10 +239,11 @@ public class DMPs extends BaseController {
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<UUID>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
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));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(cloneId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DMP>> delete(@PathVariable UUID id, Principal principal) {
|
ResponseEntity<ResponseItem<DMP>> delete(@PathVariable UUID id, Principal principal) {
|
||||||
|
@ -280,7 +260,7 @@ public class DMPs extends BaseController {
|
||||||
if (files[0].getContentType().equals(APPLICATION_JSON.toString())) {
|
if (files[0].getContentType().equals(APPLICATION_JSON.toString())) {
|
||||||
this.dataManagementPlanManager.createFromRDA(files, principal, profiles);
|
this.dataManagementPlanManager.createFromRDA(files, principal, profiles);
|
||||||
} else if (files[0].getContentType().equals(APPLICATION_ATOM_XML.toString()) || files[0].getContentType().equals(TEXT_XML.toString())) {
|
} else if (files[0].getContentType().equals(APPLICATION_ATOM_XML.toString()) || files[0].getContentType().equals(TEXT_XML.toString())) {
|
||||||
this.dataManagementPlanManager.createDmpFromXml(files, principal, profiles);
|
this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal);
|
||||||
} else {
|
} else {
|
||||||
return ResponseEntity.badRequest().body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message("File format is not supported"));
|
return ResponseEntity.badRequest().body(new ResponseItem().status(ApiMessageCode.ERROR_MESSAGE).message("File format is not supported"));
|
||||||
}
|
}
|
||||||
|
@ -299,6 +279,7 @@ public class DMPs extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/finalize/{id}"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/finalize/{id}"})
|
||||||
public ResponseEntity<ResponseItem<DMP>> makeFinalize(@PathVariable String id, Principal principal, @RequestBody DatasetsToBeFinalized datasetsToBeFinalized) {
|
public ResponseEntity<ResponseItem<DMP>> makeFinalize(@PathVariable String id, Principal principal, @RequestBody DatasetsToBeFinalized datasetsToBeFinalized) {
|
||||||
try {
|
try {
|
||||||
|
@ -310,6 +291,7 @@ public class DMPs extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/unfinalize/{id}"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/unfinalize/{id}"})
|
||||||
public ResponseEntity<ResponseItem<DMP>> undoFinalize(@PathVariable String id, Principal principal) {
|
public ResponseEntity<ResponseItem<DMP>> undoFinalize(@PathVariable String id, Principal principal) {
|
||||||
try {
|
try {
|
||||||
|
@ -322,6 +304,7 @@ public class DMPs extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/updateusers/{id}"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/updateusers/{id}"})
|
||||||
public ResponseEntity<ResponseItem<DMP>> updateUsers(@PathVariable String id, @RequestBody List<UserInfoListingModel> users, Principal principal) {
|
public ResponseEntity<ResponseItem<DMP>> updateUsers(@PathVariable String id, @RequestBody List<UserInfoListingModel> users, Principal principal) {
|
||||||
try {
|
try {
|
||||||
|
@ -333,6 +316,22 @@ public class DMPs extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DOI Generation
|
||||||
|
* */
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@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, configLoader);
|
||||||
|
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."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Data Index
|
* Data Index
|
||||||
* */
|
* */
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
|
import eu.eudat.criteria.RecentActivityCriteria;
|
||||||
import eu.eudat.logic.managers.DashBoardManager;
|
import eu.eudat.logic.managers.DashBoardManager;
|
||||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
@ -48,12 +49,11 @@ public class DashBoardController extends BaseController {
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/dashboard/recentActivity"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/dashboard/recentActivity"}, produces = "application/json")
|
||||||
@Transactional
|
@Transactional
|
||||||
public ResponseEntity<ResponseItem<List<RecentActivityModel>>> getNewRecentActivity(@RequestBody RecentActivityTableRequest tableRequest,
|
public ResponseEntity<ResponseItem<List<RecentActivityModel>>> getNewRecentActivity(@RequestBody RecentActivityTableRequest tableRequest,
|
||||||
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
|
||||||
List<RecentActivityModel> statistics = dashBoardManager.getNewRecentActivity(tableRequest, principal);
|
List<RecentActivityModel> statistics = dashBoardManager.getNewRecentActivity(tableRequest, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<RecentActivityModel>>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<RecentActivityModel>>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/user/recentActivity"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/user/recentActivity"}, produces = "application/json")
|
||||||
public ResponseEntity<ResponseItem<RecentActivity>> getRecentActivity(@RequestParam(name = "numOfActivities", required = false, defaultValue = "5") Integer numberOfActivities, Principal principal) {
|
public ResponseEntity<ResponseItem<RecentActivity>> getRecentActivity(@RequestParam(name = "numOfActivities", required = false, defaultValue = "5") Integer numberOfActivities, Principal principal) {
|
||||||
RecentActivity statistics = dashBoardManager.getRecentActivity(principal, numberOfActivities);
|
RecentActivity statistics = dashBoardManager.getRecentActivity(principal, numberOfActivities);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.RequestItem;
|
import eu.eudat.data.dao.criteria.RequestItem;
|
||||||
import eu.eudat.data.entities.DescriptionTemplate;
|
|
||||||
import eu.eudat.logic.managers.AdminManager;
|
import eu.eudat.logic.managers.AdminManager;
|
||||||
import eu.eudat.logic.managers.DatasetProfileManager;
|
import eu.eudat.logic.managers.DatasetProfileManager;
|
||||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
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.components.commons.datafield.AutoCompleteData;
|
||||||
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
import eu.eudat.models.data.externaldataset.ExternalAutocompleteFieldModel;
|
||||||
import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem;
|
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.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.models.data.properties.PropertiesModel;
|
import eu.eudat.models.data.properties.PropertiesModel;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
|
@ -57,7 +55,7 @@ public class DatasetProfileController extends BaseController {
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
@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) {
|
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);
|
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||||
datasetprofile.setLabel(profile.getLabel() + " new ");
|
datasetprofile.setLabel(profile.getLabel() + " new ");
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
|
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")
|
@RequestMapping(method = RequestMethod.POST, value = {"/search/autocomplete"}, consumes = "application/json", produces = "application/json")
|
||||||
public ResponseEntity<Object> getDataForAutocomplete(@RequestBody RequestItem<AutoCompleteLookupItem> lookupItem) throws XPathExpressionException {
|
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.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(descriptionTemplate.getDefinition(), lookupItem.getCriteria().getFieldID());
|
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field modelfield = this.datasetProfileManager.queryForField(datasetProfile.getDefinition(), lookupItem.getCriteria().getFieldID());
|
||||||
AutoCompleteData data = (AutoCompleteData) modelfield.getData();
|
AutoCompleteData data = (AutoCompleteData) modelfield.getData();
|
||||||
List<ExternalAutocompleteFieldModel> items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike());
|
List<ExternalAutocompleteFieldModel> items = this.datasetProfileManager.getAutocomplete(data, lookupItem.getCriteria().getLike());
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(items);
|
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.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
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.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -43,12 +42,5 @@ public class DatasetProfiles extends BaseController {
|
||||||
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem);
|
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(tableRequestItem);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue