no message
This commit is contained in:
parent
eb62c65272
commit
8892c62791
|
@ -14,6 +14,7 @@
|
|||
<properties>
|
||||
<project.http.version>1.19.0</project.http.version>
|
||||
<project.oauth.version>1.19.0</project.oauth.version>
|
||||
<project.version>0.2.0</project.version>
|
||||
|
||||
<dmp-backend-commons.version>0.0.1-SNAPSHOT</dmp-backend-commons.version>
|
||||
<org.springframework.version>4.3.8.RELEASE</org.springframework.version>
|
||||
|
@ -34,10 +35,9 @@
|
|||
<logback.version>1.1.1</logback.version>
|
||||
<javax.inject.version>1</javax.inject.version>
|
||||
<javax.servlet.servlet-api.version>3.0.1</javax.servlet.servlet-api.version>
|
||||
<!-- <jcloverslf4j.version>1.7.6</jcloverslf4j.version> -->
|
||||
<docker.image.prefix>ikalyvas</docker.image.prefix>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
|
@ -189,6 +189,7 @@
|
|||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/ui-resources</directory>
|
||||
|
@ -206,8 +207,22 @@
|
|||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>dockerfile-maven-plugin</artifactId>
|
||||
<version>1.3.6</version>
|
||||
<configuration>
|
||||
<repository>${docker.image.prefix}/${project.artifactId}</repository>
|
||||
<buildArgs>
|
||||
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
|
||||
</buildArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package eu.eudat.builders;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public abstract class Builder<T> {
|
||||
public abstract T build();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package eu.eudat.builders;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public interface BuilderFactory {
|
||||
<T extends Builder> T getBuilder(Class<T> tClass);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package eu.eudat.builders;
|
||||
|
||||
import eu.eudat.builders.entity.*;
|
||||
import eu.eudat.builders.model.criteria.DataRepositoryCriteriaBuilder;
|
||||
import eu.eudat.builders.model.criteria.RegistryCriteriaBuilder;
|
||||
import eu.eudat.builders.model.models.DataTableDataBuilder;
|
||||
import eu.eudat.builders.model.models.PrincipalBuilder;
|
||||
import eu.eudat.builders.model.models.ProjectBuilder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
@Service("builderFactory")
|
||||
public class BuilderFactoryImpl implements BuilderFactory {
|
||||
|
||||
public <T extends Builder> T getBuilder(Class<T> tClass) {
|
||||
if (tClass.equals(CredentialBuilder.class)) return (T) new CredentialBuilder();
|
||||
if (tClass.equals(DataRepositoryCriteriaBuilder.class)) return (T) new DataRepositoryCriteriaBuilder();
|
||||
if (tClass.equals(DatasetProfileBuilder.class)) return (T) new DatasetProfileBuilder();
|
||||
if (tClass.equals(DataTableDataBuilder.class)) return (T) new DataTableDataBuilder<>();
|
||||
if (tClass.equals(PrincipalBuilder.class)) return (T) new PrincipalBuilder();
|
||||
if (tClass.equals(ProjectBuilder.class)) return (T) new ProjectBuilder();
|
||||
if (tClass.equals(RegistryCriteriaBuilder.class)) return (T) new RegistryCriteriaBuilder();
|
||||
if (tClass.equals(UserInfoBuilder.class)) return (T) new UserInfoBuilder();
|
||||
if (tClass.equals(UserRoleBuilder.class)) return (T) new UserRoleBuilder();
|
||||
if (tClass.equals(UserTokenBuilder.class)) return (T) new UserTokenBuilder();
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package eu.eudat.builders.entity;
|
||||
|
||||
import eu.eudat.builders.Builder;
|
||||
import eu.eudat.entities.Credential;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class CredentialBuilder extends Builder<Credential> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private UserInfo userInfo;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Integer provider;
|
||||
|
||||
private String publicValue;
|
||||
|
||||
private String secret;
|
||||
|
||||
private Date creationTime;
|
||||
|
||||
private Date lastUpdateTime;
|
||||
|
||||
public CredentialBuilder id(UUID id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialBuilder userInfo(UserInfo userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialBuilder status(Integer status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialBuilder provider(Integer provider) {
|
||||
this.provider = provider;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialBuilder publicValue(String publicValue) {
|
||||
this.publicValue = publicValue;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialBuilder secret(String secret) {
|
||||
this.secret = secret;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialBuilder creationTime(Date creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CredentialBuilder lastUpdateTime(Date lastUpdateTime) {
|
||||
this.lastUpdateTime = lastUpdateTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Credential build(){
|
||||
Credential credential = new Credential();
|
||||
credential.setStatus(status);
|
||||
credential.setLastUpdateTime(lastUpdateTime);
|
||||
credential.setCreationTime(creationTime);
|
||||
credential.setProvider(provider);
|
||||
credential.setSecret(secret);
|
||||
credential.setPublicValue(publicValue);
|
||||
credential.setUserInfo(userInfo);
|
||||
credential.setId(id);
|
||||
return credential;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package eu.eudat.builders.entity;
|
||||
|
||||
import eu.eudat.builders.Builder;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.DatasetProfile;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.OneToMany;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class DatasetProfileBuilder extends Builder<DatasetProfile> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private String label;
|
||||
|
||||
private Set<Dataset> dataset;
|
||||
|
||||
private String definition;
|
||||
|
||||
private Short status;
|
||||
|
||||
private Date created;
|
||||
|
||||
private Date modified = new Date();
|
||||
|
||||
private String description;
|
||||
|
||||
public DatasetProfileBuilder id(UUID id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DatasetProfileBuilder label(String label) {
|
||||
this.label = label;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DatasetProfileBuilder dataset(Set<Dataset> dataset) {
|
||||
this.dataset = dataset;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DatasetProfileBuilder definition(String definition) {
|
||||
this.definition = definition;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DatasetProfileBuilder status(Short status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DatasetProfileBuilder created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DatasetProfileBuilder modified(Date modified) {
|
||||
this.modified = modified;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DatasetProfileBuilder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DatasetProfile build() {
|
||||
DatasetProfile datasetProfile = new DatasetProfile();
|
||||
datasetProfile.setCreated(created);
|
||||
datasetProfile.setStatus(status);
|
||||
datasetProfile.setId(id);
|
||||
datasetProfile.setDataset(dataset);
|
||||
datasetProfile.setDefinition(definition);
|
||||
datasetProfile.setDescription(description);
|
||||
datasetProfile.setModified(modified);
|
||||
datasetProfile.setLabel(label);
|
||||
return datasetProfile;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package eu.eudat.builders.entity;
|
||||
|
||||
import eu.eudat.builders.Builder;
|
||||
import eu.eudat.entities.Credential;
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.entities.UserRole;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class UserInfoBuilder extends Builder<UserInfo> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private String email = null;
|
||||
|
||||
private Short authorization_level; //0 admin, 1 user
|
||||
|
||||
private Short usertype; // 0 internal, 1 external
|
||||
|
||||
private Boolean verified_email = null;
|
||||
|
||||
private String name = null;
|
||||
|
||||
private Date created = null;
|
||||
|
||||
private Date lastloggedin = null;
|
||||
|
||||
private String additionalinfo;
|
||||
|
||||
private Set<DMP> dmps;
|
||||
|
||||
private Set<Credential> credentials = new HashSet<>();
|
||||
|
||||
private Set<UserRole> userRoles = new HashSet<>();
|
||||
|
||||
public UserInfoBuilder id(UUID id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserInfoBuilder email(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserInfoBuilder authorization_level(Short authorization_level) {
|
||||
this.authorization_level = authorization_level;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserInfoBuilder usertype(Short usertype) {
|
||||
this.usertype = usertype;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserInfoBuilder verified_email(Boolean verified_email) {
|
||||
this.verified_email = verified_email;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserInfoBuilder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserInfoBuilder created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserInfoBuilder lastloggedin(Date lastloggedin) {
|
||||
this.lastloggedin = lastloggedin;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserInfoBuilder additionalinfo(String additionalinfo) {
|
||||
this.additionalinfo = additionalinfo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserInfoBuilder dmps(Set<DMP> dmps) {
|
||||
this.dmps = dmps;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserInfoBuilder credentials(Set<Credential> credentials) {
|
||||
this.credentials = credentials;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserInfoBuilder userRoles(Set<UserRole> userRoles) {
|
||||
this.userRoles = userRoles;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfo build() {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setId(id);
|
||||
userInfo.setUsertype(usertype);
|
||||
userInfo.setAuthorization_level(authorization_level);
|
||||
userInfo.setLastloggedin(lastloggedin);
|
||||
userInfo.setCreated(created);
|
||||
userInfo.setEmail(email);
|
||||
userInfo.setName(name);
|
||||
userInfo.setAdditionalinfo(additionalinfo);
|
||||
userInfo.setUserRoles(userRoles);
|
||||
userInfo.setCredentials(credentials);
|
||||
userInfo.setDmps(dmps);
|
||||
userInfo.setVerified_email(verified_email);
|
||||
return userInfo;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package eu.eudat.builders.entity;
|
||||
|
||||
import eu.eudat.builders.Builder;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.entities.UserRole;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class UserRoleBuilder extends Builder<UserRole> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private int role;
|
||||
|
||||
private UserInfo userInfo;
|
||||
|
||||
public UserRoleBuilder id(UUID id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleBuilder role(int role) {
|
||||
this.role = role;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserRoleBuilder userInfo(UserInfo userInfo) {
|
||||
this.userInfo = userInfo;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserRole build() {
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setUserInfo(userInfo);
|
||||
userRole.setRole(role);
|
||||
userRole.setId(id);
|
||||
return userRole;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package eu.eudat.builders.entity;
|
||||
|
||||
import eu.eudat.builders.Builder;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.entities.UserToken;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.OneToOne;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class UserTokenBuilder extends Builder<UserToken> {
|
||||
|
||||
private UUID token;
|
||||
|
||||
private UserInfo user;
|
||||
|
||||
private Date issuedAt;
|
||||
|
||||
private Date expiresAt;
|
||||
|
||||
public UserTokenBuilder token(UUID token) {
|
||||
this.token = token;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserTokenBuilder user(UserInfo user) {
|
||||
this.user = user;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserTokenBuilder issuedAt(Date issuedAt) {
|
||||
this.issuedAt = issuedAt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserTokenBuilder expiresAt(Date expiresAt) {
|
||||
this.expiresAt = expiresAt;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserToken build() {
|
||||
UserToken userToken = new UserToken();
|
||||
userToken.setExpiresAt(expiresAt);
|
||||
userToken.setToken(token);
|
||||
userToken.setUser(user);
|
||||
userToken.setIssuedAt(issuedAt);
|
||||
return userToken;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package eu.eudat.builders.model.criteria;
|
||||
|
||||
import eu.eudat.builders.Builder;
|
||||
import eu.eudat.models.criteria.DataRepositoryCriteria;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class DataRepositoryCriteriaBuilder extends Builder<DataRepositoryCriteria> {
|
||||
private String like;
|
||||
|
||||
public DataRepositoryCriteriaBuilder like(String like) {
|
||||
this.like = like;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataRepositoryCriteria build() {
|
||||
DataRepositoryCriteria dataRepositoryCriteria = new DataRepositoryCriteria();
|
||||
dataRepositoryCriteria.setLike(like);
|
||||
return dataRepositoryCriteria;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package eu.eudat.builders.model.criteria;
|
||||
|
||||
import eu.eudat.builders.Builder;
|
||||
import eu.eudat.models.criteria.ExternalDatasetCriteria;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class ExternalDatasetCriteriaBuilder extends Builder<ExternalDatasetCriteria> {
|
||||
private String like;
|
||||
|
||||
public ExternalDatasetCriteriaBuilder like(String like) {
|
||||
this.like = like;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExternalDatasetCriteria build() {
|
||||
ExternalDatasetCriteria externalDatasetCriteria = new ExternalDatasetCriteria();
|
||||
externalDatasetCriteria.setLike(like);
|
||||
return externalDatasetCriteria;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package eu.eudat.builders.model.criteria;
|
||||
|
||||
import eu.eudat.builders.Builder;
|
||||
import eu.eudat.entities.Registry;
|
||||
import eu.eudat.models.criteria.RegistryCriteria;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class RegistryCriteriaBuilder extends Builder<RegistryCriteria> {
|
||||
private String like;
|
||||
|
||||
public RegistryCriteriaBuilder like(String like) {
|
||||
this.like = like;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegistryCriteria build() {
|
||||
RegistryCriteria registryCriteria = new RegistryCriteria();
|
||||
registryCriteria.setLike(like);
|
||||
return registryCriteria;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package eu.eudat.builders.model.criteria;
|
||||
|
||||
import eu.eudat.builders.Builder;
|
||||
import eu.eudat.models.criteria.ServiceCriteria;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class ServiceCriteriaBuilder extends Builder<ServiceCriteria> {
|
||||
private String like;
|
||||
|
||||
public ServiceCriteriaBuilder setLike(String like) {
|
||||
this.like = like;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceCriteria build() {
|
||||
ServiceCriteria serviceCriteria = new ServiceCriteria();
|
||||
serviceCriteria.setLike(like);
|
||||
return serviceCriteria;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package eu.eudat.builders.model.models;
|
||||
|
||||
import eu.eudat.builders.Builder;
|
||||
import eu.eudat.models.helpers.common.DataTableData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class DataTableDataBuilder<T> extends Builder<DataTableData<T>> {
|
||||
|
||||
private Long totalCount;
|
||||
private List<T> data;
|
||||
|
||||
public DataTableDataBuilder<T> totalCount(Long totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DataTableDataBuilder<T> data(List<T> data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataTableData<T> build() {
|
||||
DataTableData<T> dataTableData = new DataTableData<>();
|
||||
dataTableData.setTotalCount(totalCount);
|
||||
dataTableData.setData(data);
|
||||
return dataTableData;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package eu.eudat.builders.model.models;
|
||||
|
||||
import eu.eudat.builders.Builder;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.types.Authorities;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class PrincipalBuilder extends Builder<Principal> {
|
||||
|
||||
private UUID id;
|
||||
private UUID token;
|
||||
private String name;
|
||||
private Date expiresAt;
|
||||
private Set<Authorities> authorities;
|
||||
|
||||
public PrincipalBuilder id(UUID id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PrincipalBuilder token(UUID token) {
|
||||
this.token = token;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PrincipalBuilder name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PrincipalBuilder expiresAt(Date expiresAt) {
|
||||
this.expiresAt = expiresAt;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PrincipalBuilder authorities(Set<Authorities> authorities) {
|
||||
this.authorities = authorities;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Principal build() {
|
||||
Principal principal = new Principal();
|
||||
principal.setAuthorities(authorities);
|
||||
principal.setName(name);
|
||||
principal.setExpiresAt(expiresAt);
|
||||
principal.setToken(token);
|
||||
principal.setId(id);
|
||||
return principal;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
package eu.eudat.builders.model.models;
|
||||
|
||||
import eu.eudat.builders.Builder;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.project.Project;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/15/2018.
|
||||
*/
|
||||
public class ProjectBuilder extends Builder<Project> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
private List<DataManagementPlan> dmps;
|
||||
|
||||
private String label;
|
||||
|
||||
private String abbreviation;
|
||||
|
||||
private String reference;
|
||||
|
||||
private String uri;
|
||||
|
||||
private String definition;
|
||||
|
||||
private Date startDate;
|
||||
|
||||
private Date endDate;
|
||||
|
||||
private eu.eudat.entities.Project.Status status;
|
||||
|
||||
private UserInfo creationUser;
|
||||
|
||||
private Date created;
|
||||
|
||||
private Date modified;
|
||||
|
||||
private String description;
|
||||
|
||||
public ProjectBuilder id(UUID id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder dmps(List<DataManagementPlan> dmps) {
|
||||
this.dmps = dmps;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder label(String label) {
|
||||
this.label = label;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder abbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder reference(String reference) {
|
||||
this.reference = reference;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder uri(String uri) {
|
||||
this.uri = uri;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder definition(String definition) {
|
||||
this.definition = definition;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder startDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder endDate(Date endDate) {
|
||||
this.endDate = endDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder status(eu.eudat.entities.Project.Status status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder creationUser(UserInfo creationUser) {
|
||||
this.creationUser = creationUser;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder created(Date created) {
|
||||
this.created = created;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder modified(Date modified) {
|
||||
this.modified = modified;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProjectBuilder description(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project build() {
|
||||
Project project = new Project();
|
||||
project.setStatus(status.getValue());
|
||||
project.setAbbreviation(abbreviation);
|
||||
project.setCreated(created);
|
||||
project.setCreationUser(creationUser);
|
||||
project.setDefinition(definition);
|
||||
project.setDescription(description);
|
||||
project.setDmps(dmps);
|
||||
project.setEndDate(endDate);
|
||||
project.setId(id);
|
||||
project.setLabel(label);
|
||||
project.setModified(modified);
|
||||
project.setReference(reference);
|
||||
project.setCreationUser(creationUser);
|
||||
project.setStartDate(startDate);
|
||||
return project;
|
||||
}
|
||||
}
|
|
@ -44,7 +44,7 @@ public class Admin extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/admin/addDmp"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
try {
|
||||
eu.eudat.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile);
|
||||
eu.eudat.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile,getApiContext());
|
||||
this.getApiContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
||||
} catch (Exception ex) {
|
||||
|
@ -57,7 +57,7 @@ public class Admin extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/admin/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
try {
|
||||
eu.eudat.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile);
|
||||
eu.eudat.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile,getApiContext());
|
||||
|
||||
eu.eudat.entities.DatasetProfile datasetprofile = this.getApiContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
datasetprofile.setDefinition(modelDefinition.getDefinition());
|
||||
|
|
|
@ -73,8 +73,6 @@ public class DMPs extends BaseController {
|
|||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE).message(ex.getMessage()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/new/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
|
|
|
@ -47,7 +47,7 @@ public class DatasetProfiles extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DatasetProfileListingModel>>> getPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem) {
|
||||
try {
|
||||
DataTableData<DatasetProfileListingModel> datasetProfileTableData = DatasetProfileManager.getPaged(this.getApiContext().getDatabaseRepository().getDatasetProfileDao(), datasetProfileTableRequestItem);
|
||||
DataTableData<DatasetProfileListingModel> datasetProfileTableData = DatasetProfileManager.getPaged(this.getApiContext(), datasetProfileTableRequestItem);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||
} catch (Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.DEFAULT_ERROR_MESSAGE));
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ExternalDatasets extends BaseController{
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody ResponseEntity<ResponseItem<DataTableData<ExternalDatasetListingModel>>> getPaged(@RequestBody ExternalDatasetTableRequest datasetTableRequest, Principal principal) {
|
||||
try {
|
||||
DataTableData<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getPaged(this.getApiContext().getDatabaseRepository().getExternalDatasetDao(), datasetTableRequest);
|
||||
DataTableData<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getPaged(this.getApiContext(), datasetTableRequest);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<ExternalDatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
|
||||
} catch (Exception ex) {
|
||||
|
@ -42,7 +42,7 @@ public class ExternalDatasets extends BaseController{
|
|||
@RequestMapping(method = RequestMethod.GET, value = {"/external/datasets"}, produces = "application/json")
|
||||
public @ResponseBody ResponseEntity<ResponseItem<List<ExternalDatasetListingModel>>> getWithExternal(@RequestParam(value = "query", required = false) String query, Principal principal) {
|
||||
try {
|
||||
List<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getWithExternal(this.getApiContext().getDatabaseRepository().getExternalDatasetDao(), query, this.getApiContext().getRemoteFetcher());
|
||||
List<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getWithExternal(this.getApiContext(), query, this.getApiContext().getRemoteFetcher());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalDatasetListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
|
|
@ -104,7 +104,7 @@ public class Projects extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<eu.eudat.models.project.Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) {
|
||||
try {
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteriaWithExternal(this.getApiContext().getDatabaseRepository().getProjectDao(), projectCriteria, this.getApiContext().getRemoteFetcher());
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteriaWithExternal(this.getApiContext(), projectCriteria, this.getApiContext().getRemoteFetcher());
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
|
|
@ -38,7 +38,7 @@ public class Users extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<UserListingModel>>> getPaged(@Valid @RequestBody UserInfoTableRequestItem userInfoTableRequestItem, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
try {
|
||||
DataTableData<UserListingModel> dataTable = UserManager.getPaged(this.getApiContext().getDatabaseRepository().getUserInfoDao(), userInfoTableRequestItem);
|
||||
DataTableData<UserListingModel> dataTable = UserManager.getPaged(this.getApiContext(), userInfoTableRequestItem);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<UserListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
|
|
@ -3,6 +3,8 @@ package eu.eudat.managers;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import eu.eudat.builders.entity.DatasetProfileBuilder;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
|
@ -19,32 +21,31 @@ import eu.eudat.utilities.helpers.ModelBuilderCollector;
|
|||
|
||||
public class AdminManager {
|
||||
|
||||
|
||||
public static eu.eudat.entities.DatasetProfile generateViewStyleDefinition(DatasetProfile profile){
|
||||
ViewStyleModel viewStyleModel = new ViewStyleModel();
|
||||
viewStyleModel.setSections(new ModelBuilder().toViewStyleDefinition(profile.getSections(), eu.eudat.entities.xmlmodels.datasetprofiledefinition.Section.class));
|
||||
viewStyleModel.setPages(new ModelBuilder().toViewStyleDefinition(profile.getPages(), eu.eudat.entities.xmlmodels.datasetprofiledefinition.Page.class));
|
||||
Document viewStyleDoc = XmlBuilder.getDocument();
|
||||
Element elementViewStyle = viewStyleModel.toXml(viewStyleDoc);
|
||||
viewStyleDoc.appendChild(elementViewStyle);
|
||||
String xml = XmlBuilder.generateXml(viewStyleDoc);
|
||||
|
||||
eu.eudat.entities.DatasetProfile datasetProfile = new eu.eudat.entities.DatasetProfile();
|
||||
datasetProfile.setDefinition(xml);
|
||||
datasetProfile.setLabel(profile.getLabel());
|
||||
datasetProfile.setStatus((short)1);
|
||||
datasetProfile.setCreated(new Date());
|
||||
return datasetProfile;
|
||||
}
|
||||
|
||||
public static eu.eudat.models.admin.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.entities.DatasetProfile profile){
|
||||
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
|
||||
Element root = (Element)viewStyleDoc.getDocumentElement();
|
||||
eu.eudat.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle= new eu.eudat.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root);
|
||||
|
||||
eu.eudat.models.admin.composite.DatasetProfile datasetprofile = new eu.eudat.models.admin.composite.DatasetProfile();
|
||||
datasetprofile.buildProfile(viewstyle);
|
||||
|
||||
return datasetprofile;
|
||||
}
|
||||
public static eu.eudat.entities.DatasetProfile generateViewStyleDefinition(DatasetProfile profile, ApiContext apiContext) {
|
||||
ViewStyleModel viewStyleModel = new ViewStyleModel();
|
||||
viewStyleModel.setSections(new ModelBuilder().toViewStyleDefinition(profile.getSections(), eu.eudat.entities.xmlmodels.datasetprofiledefinition.Section.class));
|
||||
viewStyleModel.setPages(new ModelBuilder().toViewStyleDefinition(profile.getPages(), eu.eudat.entities.xmlmodels.datasetprofiledefinition.Page.class));
|
||||
Document viewStyleDoc = XmlBuilder.getDocument();
|
||||
Element elementViewStyle = viewStyleModel.toXml(viewStyleDoc);
|
||||
viewStyleDoc.appendChild(elementViewStyle);
|
||||
String xml = XmlBuilder.generateXml(viewStyleDoc);
|
||||
|
||||
eu.eudat.entities.DatasetProfile datasetProfile = apiContext.getBuilderFactory().getBuilder(DatasetProfileBuilder.class).definition(xml).label(profile.getLabel())
|
||||
.status((short) 1).created(new Date())
|
||||
.build();
|
||||
|
||||
return datasetProfile;
|
||||
}
|
||||
|
||||
public static eu.eudat.models.admin.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.entities.DatasetProfile profile) {
|
||||
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
|
||||
Element root = (Element) viewStyleDoc.getDocumentElement();
|
||||
eu.eudat.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root);
|
||||
|
||||
eu.eudat.models.admin.composite.DatasetProfile datasetprofile = new eu.eudat.models.admin.composite.DatasetProfile();
|
||||
datasetprofile.buildProfile(viewstyle);
|
||||
|
||||
return datasetprofile;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.*;
|
|||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import eu.eudat.builders.entity.UserInfoBuilder;
|
||||
import eu.eudat.dao.entities.*;
|
||||
import eu.eudat.entities.*;
|
||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsException;
|
||||
|
@ -22,7 +23,6 @@ import eu.eudat.models.listingmodels.DatasetListingModel;
|
|||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
public class DataManagementPlanManager {
|
||||
|
@ -37,7 +37,7 @@ public class DataManagementPlanManager {
|
|||
DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<DataManagementPlanListingModel>();
|
||||
|
||||
CompletableFuture itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)).toListAsync().whenComplete((resultList, throwable) -> {
|
||||
List<DataManagementPlanListingModel> datamanagementPlans = new DomainModelConverter<DMP, DataManagementPlanListingModel>().fromDataModel(resultList, DataManagementPlanListingModel.class);
|
||||
List<DataManagementPlanListingModel> datamanagementPlans = resultList.stream().map(item -> new DataManagementPlanListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
dataTable.setData(datamanagementPlans);
|
||||
});
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class DataManagementPlanManager {
|
|||
|
||||
public List<DataManagementPlan> getWithCriteria(DMPDao dmpsRepository, DataManagementPlanCriteriaRequest dataManagementPlanCriteria) throws IllegalAccessException, InstantiationException {
|
||||
QueryableList<DMP> items = dmpsRepository.getWithCriteria(dataManagementPlanCriteria.getCriteria());
|
||||
List<eu.eudat.models.dmp.DataManagementPlan> datamanagementPlans = new DomainModelConverter<eu.eudat.entities.DMP, eu.eudat.models.dmp.DataManagementPlan>().fromDataModel(items.toList(), eu.eudat.models.dmp.DataManagementPlan.class);
|
||||
List<eu.eudat.models.dmp.DataManagementPlan> datamanagementPlans = items.toList().stream().map(item -> new DataManagementPlan().fromDataModel(item)).collect(Collectors.toList());
|
||||
return datamanagementPlans;
|
||||
}
|
||||
|
||||
|
@ -88,8 +88,7 @@ public class DataManagementPlanManager {
|
|||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getDatabaseRepository().getOrganisationDao());
|
||||
createResearchersIfTheyDontExist(newDmp, apiContext.getDatabaseRepository().getResearcherDao());
|
||||
UserInfo user = new UserInfo();
|
||||
user.setId(principal.getId());
|
||||
UserInfo user = apiContext.getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
||||
createProjectIfItDoesntExist(newDmp, apiContext.getDatabaseRepository().getProjectDao(), user);
|
||||
newDmp.setCreator(user);
|
||||
newDmp.setGroupId(oldDmp.getGroupId());
|
||||
|
@ -103,8 +102,7 @@ public class DataManagementPlanManager {
|
|||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getDatabaseRepository().getOrganisationDao());
|
||||
createResearchersIfTheyDontExist(newDmp, apiContext.getDatabaseRepository().getResearcherDao());
|
||||
UserInfo user = new UserInfo();
|
||||
user.setId(principal.getId());
|
||||
UserInfo user = apiContext.getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
||||
createProjectIfItDoesntExist(newDmp, apiContext.getDatabaseRepository().getProjectDao(), user);
|
||||
newDmp.setCreator(user);
|
||||
newDmp.setGroupId(UUID.randomUUID());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.builders.entity.UserInfoBuilder;
|
||||
import eu.eudat.dao.entities.*;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
|
@ -12,12 +13,10 @@ import eu.eudat.models.dataset.DatasetTableRequest;
|
|||
import eu.eudat.models.datasetwizard.DatasetWizardModel;
|
||||
import eu.eudat.models.helpers.common.DataTableData;
|
||||
import eu.eudat.models.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.properties.PropertiesModel;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.models.user.composite.PagedDatasetProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -25,20 +24,20 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class DatasetManager {
|
||||
|
||||
public DataTableData<DatasetListingModel> getPaged(ApiContext apiContext, DatasetTableRequest datasetTableRequest, Principal principal) throws Exception {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
UserInfo userInfo = apiContext.getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
||||
QueryableList<eu.eudat.entities.Dataset> items = apiContext.getDatabaseRepository().getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria());
|
||||
QueryableList<eu.eudat.entities.Dataset> authItems = apiContext.getDatabaseRepository().getDatasetDao().getAuthenticated(items, userInfo);
|
||||
QueryableList<eu.eudat.entities.Dataset> pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest);
|
||||
DataTableData<DatasetListingModel> dataTable = new DataTableData<DatasetListingModel>();
|
||||
|
||||
CompletableFuture<List<Dataset>> itemsFuture = pagedItems.withHint(HintedModelFactory.getHint(DatasetListingModel.class)).toListAsync().whenComplete((resultList, throwable) -> {
|
||||
List<DatasetListingModel> datasets = new DomainModelConverter<eu.eudat.entities.Dataset, DatasetListingModel>().fromDataModel(resultList, DatasetListingModel.class);
|
||||
List<DatasetListingModel> datasets = resultList.stream().map(item-> new DatasetListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
dataTable.setData(datasets);
|
||||
});
|
||||
|
||||
|
@ -70,8 +69,7 @@ public class DatasetManager {
|
|||
public static eu.eudat.entities.Dataset createOrUpdate(ApiContext apiContext, DatasetWizardModel profile, Principal principal) throws Exception {
|
||||
eu.eudat.entities.Dataset dataset = profile.toDataModel();
|
||||
propertiesModelToString(profile, dataset);
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
UserInfo userInfo = apiContext.getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
||||
dataset.setCreator(userInfo);
|
||||
createRegistriesIfTheyDontExist(apiContext.getDatabaseRepository().getRegistryDao(), dataset);
|
||||
createDataRepositoriesIfTheyDontExist(apiContext.getDatabaseRepository().getDataRepositoryDao(), dataset);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.builders.model.models.DataTableDataBuilder;
|
||||
import eu.eudat.dao.entities.DatasetProfileDao;
|
||||
import eu.eudat.entities.DatasetProfile;
|
||||
import eu.eudat.models.datasetprofile.DatasetProfileAutocompleteItem;
|
||||
|
@ -8,32 +9,30 @@ import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
|
|||
import eu.eudat.models.datasetprofile.DatasetProfileTableRequestItem;
|
||||
import eu.eudat.models.helpers.common.DataTableData;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import eu.eudat.services.ApiContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class DatasetProfileManager {
|
||||
|
||||
public static List<DatasetProfileAutocompleteItem> getWithCriteria(DatasetProfileDao datasetProfileRepository, DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException{
|
||||
public static List<DatasetProfileAutocompleteItem> getWithCriteria(DatasetProfileDao datasetProfileRepository, DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException {
|
||||
QueryableList<DatasetProfile> items = datasetProfileRepository.getWithCriteria(datasetProfileAutocompleteRequest.getCriteria());
|
||||
List<DatasetProfileAutocompleteItem> datasetProfiles = new DomainModelConverter<DatasetProfile, DatasetProfileAutocompleteItem>().fromDataModel( items.toList(), DatasetProfileAutocompleteItem.class);
|
||||
List<DatasetProfileAutocompleteItem> datasetProfiles = items.toList().stream().map(item -> new DatasetProfileAutocompleteItem().fromDataModel(item)).collect(Collectors.toList());
|
||||
return datasetProfiles;
|
||||
}
|
||||
|
||||
public static DataTableData<DatasetProfileListingModel> getPaged(DatasetProfileDao datasetProfileRepository, DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws Exception {
|
||||
QueryableList<DatasetProfile> items = datasetProfileRepository.getWithCriteria(datasetProfileTableRequestItem.getCriteria());
|
||||
QueryableList<DatasetProfile> pagedItems = PaginationManager.applyPaging(items,datasetProfileTableRequestItem);
|
||||
List<DatasetProfileListingModel> datasetProfiles = new DomainModelConverter<DatasetProfile, DatasetProfileListingModel>().fromDataModel( pagedItems.toList(), DatasetProfileListingModel.class);
|
||||
DataTableData<DatasetProfileListingModel> dataTable = new DataTableData<>();
|
||||
dataTable.setData(datasetProfiles);
|
||||
dataTable.setTotalCount(items.count());
|
||||
return dataTable;
|
||||
public static DataTableData<DatasetProfileListingModel> getPaged(ApiContext apiContext, DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws Exception {
|
||||
QueryableList<DatasetProfile> items = apiContext.getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
|
||||
QueryableList<DatasetProfile> pagedItems = PaginationManager.applyPaging(items, datasetProfileTableRequestItem);
|
||||
List<DatasetProfileListingModel> datasetProfiles = pagedItems.toList().stream().map(item -> new DatasetProfileListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
return apiContext.getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(datasetProfiles).totalCount(items.count()).build();
|
||||
}
|
||||
|
||||
public static List<DatasetProfileListingModel> getAll(DatasetProfileDao datasetProfileRepository) throws IllegalAccessException, InstantiationException{
|
||||
public static List<DatasetProfileListingModel> getAll(DatasetProfileDao datasetProfileRepository) throws IllegalAccessException, InstantiationException {
|
||||
QueryableList<DatasetProfile> items = datasetProfileRepository.getAll();
|
||||
List<DatasetProfileListingModel> datasetProfiles = new DomainModelConverter<DatasetProfile, DatasetProfileListingModel>().fromDataModel( items.toList(), DatasetProfileListingModel.class);
|
||||
List<DatasetProfileListingModel> datasetProfiles = items.toList().stream().map(item -> new DatasetProfileListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
return datasetProfiles;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,19 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.dao.entities.DMPDao;
|
||||
import eu.eudat.dao.entities.DatasetDao;
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.models.datasetwizard.DataManagentPlanListingModel;
|
||||
import eu.eudat.models.datasetwizard.DatasetProfileWizardAutocompleteRequest;
|
||||
import eu.eudat.models.datasetwizard.DatasetWizardAutocompleteRequest;
|
||||
import eu.eudat.models.dmp.AssociatedProfile;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
|
@ -27,14 +22,14 @@ public class DatasetWizardManager {
|
|||
public static List<DataManagentPlanListingModel> getUserDmps(DMPDao dmpRepository, DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) throws InstantiationException, IllegalAccessException {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
QueryableList<DMP> items = dmpRepository.getUserDmps(datasetWizardAutocompleteRequest,userInfo);
|
||||
List<DataManagentPlanListingModel> dataManagementPlans = new DomainModelConverter<DMP, DataManagentPlanListingModel>().fromDataModel( items.toList(), DataManagentPlanListingModel.class);
|
||||
QueryableList<DMP> items = dmpRepository.getUserDmps(datasetWizardAutocompleteRequest, userInfo);
|
||||
List<DataManagentPlanListingModel> dataManagementPlans = items.toList().stream().map(item -> new DataManagentPlanListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
return dataManagementPlans;
|
||||
}
|
||||
|
||||
public static List<AssociatedProfile> getAvailableProfiles(DMPDao dmpRepository, DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest) throws InstantiationException, IllegalAccessException {
|
||||
DataManagementPlan dataManagementPlan = new DomainModelConverter<eu.eudat.entities.DMP,DataManagementPlan>().fromDataModel(new LinkedList<DMP>(Arrays.asList(dmpRepository.find(datasetProfileWizardAutocompleteRequest.getCriteria().getId()))),DataManagementPlan.class).get(0);
|
||||
if(dataManagementPlan.getProfiles()==null||dataManagementPlan.getProfiles().isEmpty()){
|
||||
DataManagementPlan dataManagementPlan = new DataManagementPlan().fromDataModel(dmpRepository.find(datasetProfileWizardAutocompleteRequest.getCriteria().getId()));
|
||||
if (dataManagementPlan.getProfiles() == null || dataManagementPlan.getProfiles().isEmpty()) {
|
||||
return new LinkedList<>();
|
||||
}
|
||||
List<AssociatedProfile> profiles = dataManagementPlan.getProfiles();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.builders.model.criteria.ExternalDatasetCriteriaBuilder;
|
||||
import eu.eudat.builders.model.models.DataTableDataBuilder;
|
||||
import eu.eudat.dao.entities.ExternalDatasetDao;
|
||||
import eu.eudat.entities.ExternalDataset;
|
||||
import eu.eudat.models.criteria.ExternalDatasetCriteria;
|
||||
|
@ -10,33 +12,30 @@ import eu.eudat.proxy.config.exceptions.HugeResultSet;
|
|||
import eu.eudat.proxy.config.exceptions.NoURLFound;
|
||||
import eu.eudat.proxy.fetching.RemoteFetcher;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import eu.eudat.services.ApiContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class ExternalDatasetManager {
|
||||
|
||||
public DataTableData<ExternalDatasetListingModel> getPaged(ExternalDatasetDao externalDatasetDao, ExternalDatasetTableRequest externalDatasetTableRequest) throws Exception {
|
||||
QueryableList<ExternalDataset> items = externalDatasetDao.getWithCriteria(externalDatasetTableRequest.getCriteria());
|
||||
public DataTableData<ExternalDatasetListingModel> getPaged(ApiContext apiContext, ExternalDatasetTableRequest externalDatasetTableRequest) throws Exception {
|
||||
QueryableList<ExternalDataset> items = apiContext.getDatabaseRepository().getExternalDatasetDao().getWithCriteria(externalDatasetTableRequest.getCriteria());
|
||||
QueryableList<ExternalDataset> pagedItems = PaginationManager.applyPaging(items, externalDatasetTableRequest);
|
||||
List<ExternalDatasetListingModel> externalDatasetListingmodels = new DomainModelConverter<ExternalDataset, ExternalDatasetListingModel>().fromDataModel(pagedItems.toList(), ExternalDatasetListingModel.class);
|
||||
DataTableData<ExternalDatasetListingModel> externalDatasetDataTableData = new DataTableData<>();
|
||||
externalDatasetDataTableData.setData(externalDatasetListingmodels);
|
||||
externalDatasetDataTableData.setTotalCount(items.count());
|
||||
return externalDatasetDataTableData;
|
||||
List<ExternalDatasetListingModel> externalDatasetListingmodels = pagedItems.toList().stream().map(item -> new ExternalDatasetListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
return apiContext.getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(externalDatasetListingmodels).totalCount(items.count()).build();
|
||||
}
|
||||
|
||||
public List<ExternalDatasetListingModel> getWithExternal(ExternalDatasetDao externalDatasetDao , String query, RemoteFetcher remoteFetcher) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException {
|
||||
ExternalDatasetCriteria criteria = new ExternalDatasetCriteria();
|
||||
criteria.setLike(query);
|
||||
QueryableList<eu.eudat.entities.ExternalDataset> items = externalDatasetDao.getWithCriteria(criteria);
|
||||
List<ExternalDatasetListingModel> externalDatasets = new DomainModelConverter<eu.eudat.entities.ExternalDataset, ExternalDatasetListingModel>().fromDataModel(items.toList(), ExternalDatasetListingModel.class);
|
||||
public List<ExternalDatasetListingModel> getWithExternal(ApiContext apiContext, String query, RemoteFetcher remoteFetcher) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException {
|
||||
ExternalDatasetCriteria criteria = apiContext.getBuilderFactory().getBuilder(ExternalDatasetCriteriaBuilder.class).like(query).build();
|
||||
QueryableList<eu.eudat.entities.ExternalDataset> items = apiContext.getDatabaseRepository().getExternalDatasetDao().getWithCriteria(criteria);
|
||||
List<ExternalDatasetListingModel> externalDatasets = items.toList().stream().map(item-> new ExternalDatasetListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
return externalDatasets;
|
||||
}
|
||||
|
||||
public ExternalDatasetListingModel getSingle(ExternalDatasetDao externalDatasetDao , UUID id) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException {
|
||||
public ExternalDatasetListingModel getSingle(ExternalDatasetDao externalDatasetDao, UUID id) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException {
|
||||
ExternalDataset externalDataset = externalDatasetDao.find(id);
|
||||
ExternalDatasetListingModel externalDatasetModel = new ExternalDatasetListingModel();
|
||||
externalDatasetModel.fromDataModel(externalDataset);
|
||||
|
|
|
@ -9,7 +9,6 @@ import eu.eudat.models.userinfo.UserInfoInvitationModel;
|
|||
import eu.eudat.models.userinfo.UserInfoRequestItem;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
@ -22,21 +21,22 @@ public class InvitationsManager {
|
|||
UserInfo principalUser = new UserInfo();
|
||||
principalUser.setId(principal.getId());
|
||||
List<UserInfoInvitationModel> alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList());
|
||||
List<UserInfo> alreadySignedInUsersEntities = new DomainModelConverter<UserInfo, UserInfoInvitationModel>().toDataModel(alreadySignedInUsers);
|
||||
List<UserInfo> alreadySignedInUsersEntities = alreadySignedInUsers.stream().map(item -> item.toDataModel()).collect(Collectors.toList());
|
||||
DMP dataManagementPlan = apiContext.getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan());
|
||||
apiContext.getInvitationService().createInvitations(apiContext.getDatabaseRepository().getInvitationDao(), apiContext.getMailService(), new DomainModelConverter<UserInfo, UserInfoInvitationModel>().toDataModel(invitation.getUsers()), dataManagementPlan, principalUser);
|
||||
apiContext.getInvitationService().createInvitations(apiContext.getDatabaseRepository().getInvitationDao(), apiContext.getMailService(), invitation.getUsers().stream().map(item -> item.toDataModel()).collect(Collectors.toList()), dataManagementPlan, principalUser);
|
||||
apiContext.getInvitationService().assignToDmp(apiContext.getDatabaseRepository().getDmpDao(), alreadySignedInUsersEntities, dataManagementPlan);
|
||||
}
|
||||
|
||||
public static List<UserInfoInvitationModel> getUsers(ApiContext apiContext, UserInfoRequestItem userInfoRequestItem) throws InstantiationException, IllegalAccessException {
|
||||
QueryableList<UserInfo> users = apiContext.getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoRequestItem.getCriteria());
|
||||
List<UserInfoInvitationModel> userModels = new DomainModelConverter<UserInfo, UserInfoInvitationModel>().fromDataModel(users.toList(), UserInfoInvitationModel.class);
|
||||
List<UserInfoInvitationModel> userModels = users.toList().stream().map(item -> new UserInfoInvitationModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
return userModels;
|
||||
}
|
||||
|
||||
public static UUID assignUserAcceptedInvitation(ApiContext apiContext, UUID invitationID, Principal principal) throws UnauthorisedException {
|
||||
eu.eudat.entities.Invitation invitation = apiContext.getDatabaseRepository().getInvitationDao().find(invitationID);
|
||||
if (invitation == null) throw new UnauthorisedException("There is no Data Management Plan assigned to this Link");
|
||||
if (invitation == null)
|
||||
throw new UnauthorisedException("There is no Data Management Plan assigned to this Link");
|
||||
if (invitation.getAcceptedInvitation()) throw new UnauthorisedException("This Url Has Expired");
|
||||
UserInfo invitedUser = apiContext.getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||
DMP datamanagementPlan = invitation.getDmp();
|
||||
|
|
|
@ -5,14 +5,15 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import eu.eudat.builders.model.models.ProjectBuilder;
|
||||
import eu.eudat.dao.entities.ProjectDao;
|
||||
import eu.eudat.dao.entities.UserInfoDao;
|
||||
import eu.eudat.models.HintedModelFactory;
|
||||
import eu.eudat.models.external.ExternalSourcesItemModel;
|
||||
import eu.eudat.models.external.ProjectsExternalSourcesModel;
|
||||
import eu.eudat.models.helpers.common.DataTableData;
|
||||
import eu.eudat.models.listingmodels.DataManagementPlanListingModel;
|
||||
import eu.eudat.models.project.Project;
|
||||
import eu.eudat.models.project.ProjectCriteriaRequest;
|
||||
import eu.eudat.models.project.ProjectListingModel;
|
||||
|
@ -22,7 +23,7 @@ import eu.eudat.proxy.config.exceptions.HugeResultSet;
|
|||
import eu.eudat.proxy.config.exceptions.NoURLFound;
|
||||
import eu.eudat.proxy.fetching.RemoteFetcher;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import eu.eudat.services.ApiContext;
|
||||
|
||||
public class ProjectManager {
|
||||
|
||||
|
@ -32,13 +33,13 @@ public class ProjectManager {
|
|||
DataTableData<eu.eudat.models.project.ProjectListingModel> dataTable = new DataTableData<eu.eudat.models.project.ProjectListingModel>();
|
||||
|
||||
CompletableFuture projectsFuture = pagedItems.withHint(HintedModelFactory.getHint(ProjectListingModel.class)).toListAsync().whenComplete((results, throwable) -> {
|
||||
List<eu.eudat.models.project.ProjectListingModel> projects = new DomainModelConverter<eu.eudat.entities.Project, ProjectListingModel>().fromDataModel(results, eu.eudat.models.project.ProjectListingModel.class);
|
||||
List<eu.eudat.models.project.ProjectListingModel> projects = results.stream().map(item -> new ProjectListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
dataTable.setData(projects);
|
||||
});
|
||||
|
||||
CompletableFuture countFuture = pagedItems.countAsync().whenComplete((count, throwable) -> dataTable.setTotalCount(count));
|
||||
|
||||
CompletableFuture.allOf(projectsFuture,countFuture).join();
|
||||
CompletableFuture.allOf(projectsFuture, countFuture).join();
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
|
@ -55,19 +56,18 @@ public class ProjectManager {
|
|||
return project;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.project.Project> getCriteriaWithExternal(ProjectDao projectRepository, ProjectCriteriaRequest projectCriteria, RemoteFetcher remoteFetcher) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
QueryableList<eu.eudat.entities.Project> items = projectRepository.getWithCriteria(projectCriteria.getCriteria());
|
||||
List<eu.eudat.models.project.Project> projects = new DomainModelConverter<eu.eudat.entities.Project, Project>().fromDataModel(items.toList(), eu.eudat.models.project.Project.class);
|
||||
public List<eu.eudat.models.project.Project> getCriteriaWithExternal(ApiContext apiContext, ProjectCriteriaRequest projectCriteria, RemoteFetcher remoteFetcher) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
QueryableList<eu.eudat.entities.Project> items = apiContext.getDatabaseRepository().getProjectDao().getWithCriteria(projectCriteria.getCriteria());
|
||||
List<eu.eudat.models.project.Project> projects = items.toList().stream().map(item -> new Project().fromDataModel(item)).collect(Collectors.toList());
|
||||
List<Map<String, String>> remoteRepos = remoteFetcher.getProjects(projectCriteria.getCriteria().getLike());
|
||||
ProjectsExternalSourcesModel projectsExternalSourcesModel = new ProjectsExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
for (ExternalSourcesItemModel externalListingItem : projectsExternalSourcesModel) {
|
||||
eu.eudat.models.project.Project project = new eu.eudat.models.project.Project();
|
||||
project.setReference(externalListingItem.getRemoteId());
|
||||
project.setLabel(externalListingItem.getName());
|
||||
project.setDescription(externalListingItem.getDescription());
|
||||
project.setUri(externalListingItem.getUri());
|
||||
project.setAbbreviation(externalListingItem.getAbbreviation());
|
||||
project.setStatus((short) 0);
|
||||
eu.eudat.models.project.Project project = apiContext.getBuilderFactory().getBuilder(ProjectBuilder.class)
|
||||
.reference(externalListingItem.getRemoteId()).label(externalListingItem.getName())
|
||||
.description(externalListingItem.getDescription()).uri(externalListingItem.getUri())
|
||||
.abbreviation(externalListingItem.getAbbreviation()).status(eu.eudat.entities.Project.Status.fromInteger(0))
|
||||
.build();
|
||||
|
||||
projects.add(project);
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class ProjectManager {
|
|||
|
||||
public List<eu.eudat.models.project.Project> getCriteria(ProjectDao projectRepository, ProjectCriteriaRequest projectCriteria, RemoteFetcher remoteFetcher) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
QueryableList<eu.eudat.entities.Project> items = projectRepository.getWithCriteria(projectCriteria.getCriteria());
|
||||
List<eu.eudat.models.project.Project> projects = new DomainModelConverter<eu.eudat.entities.Project, Project>().fromDataModel(items.toList(), eu.eudat.models.project.Project.class);
|
||||
List<eu.eudat.models.project.Project> projects = items.toList().stream().map(item -> new Project().fromDataModel(item)).collect(Collectors.toList());
|
||||
return projects;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,7 @@ package eu.eudat.managers;
|
|||
|
||||
import eu.eudat.entities.Researcher;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
|
@ -13,7 +11,7 @@ import java.util.Arrays;
|
|||
public class ResearcherManager {
|
||||
|
||||
public static Researcher create(ApiContext apiContext, eu.eudat.models.researcher.Researcher researcher) throws Exception {
|
||||
Researcher researcherEntity = new DomainModelConverter<Researcher, eu.eudat.models.researcher.Researcher>().toDataModel(Arrays.asList(researcher)).get(0);
|
||||
Researcher researcherEntity = researcher.toDataModel();
|
||||
return apiContext.getDatabaseRepository().getResearcherDao().createOrUpdate(researcherEntity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.managers;
|
||||
|
||||
import eu.eudat.dao.entities.UserInfoDao;
|
||||
import eu.eudat.builders.entity.UserRoleBuilder;
|
||||
import eu.eudat.builders.model.models.DataTableDataBuilder;
|
||||
import eu.eudat.entities.UserRole;
|
||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||
import eu.eudat.models.helpers.common.DataTableData;
|
||||
|
@ -11,13 +12,13 @@ import eu.eudat.models.userinfo.UserListingModel;
|
|||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import eu.eudat.services.AuthenticationService;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import eu.eudat.utilities.builders.XmlBuilder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class UserManager {
|
||||
public static eu.eudat.models.user.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.entities.DatasetProfile profile) {
|
||||
|
@ -31,24 +32,19 @@ public class UserManager {
|
|||
return datasetprofile;
|
||||
}
|
||||
|
||||
public static DataTableData<UserListingModel> getPaged(UserInfoDao userInfoDao, UserInfoTableRequestItem userInfoTableRequestItem) throws Exception {
|
||||
QueryableList<eu.eudat.entities.UserInfo> users = userInfoDao.getWithCriteria(userInfoTableRequestItem.getCriteria());
|
||||
public static DataTableData<UserListingModel> getPaged(ApiContext apiContext, UserInfoTableRequestItem userInfoTableRequestItem) throws Exception {
|
||||
QueryableList<eu.eudat.entities.UserInfo> users = apiContext.getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoTableRequestItem.getCriteria());
|
||||
QueryableList<eu.eudat.entities.UserInfo> pagedUsers = PaginationManager.applyPaging(users, userInfoTableRequestItem);
|
||||
|
||||
List<UserListingModel> modelUsers = new DomainModelConverter<eu.eudat.entities.UserInfo, UserListingModel>().fromDataModel(pagedUsers.toList(), UserListingModel.class);
|
||||
DataTableData<UserListingModel> dataTableData = new DataTableData<>();
|
||||
dataTableData.setData(modelUsers);
|
||||
dataTableData.setTotalCount(users.count());
|
||||
return dataTableData;
|
||||
List<UserListingModel> modelUsers = pagedUsers.toList().stream().map(item -> new UserListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
return apiContext.getBuilderFactory().getBuilder(DataTableDataBuilder.class).totalCount(users.count()).data(modelUsers).build();
|
||||
}
|
||||
|
||||
public static void editRoles(ApiContext apiContext, UserListingModel user) {
|
||||
eu.eudat.entities.UserInfo userInfo = apiContext.getDatabaseRepository().getUserInfoDao().find(user.getId());
|
||||
userInfo.getUserRoles().stream().forEach(item -> apiContext.getDatabaseRepository().getUserRoleDao().delete(item));
|
||||
for (Integer role : user.getAppRoles()) {
|
||||
UserRole userRole = new UserRole();
|
||||
userRole.setRole(role);
|
||||
userRole.setUserInfo(userInfo);
|
||||
UserRole userRole = apiContext.getBuilderFactory().getBuilder(UserRoleBuilder.class).role(role).userInfo(userInfo).build();
|
||||
apiContext.getDatabaseRepository().getUserRoleDao().createOrUpdate(userRole);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package eu.eudat.models;
|
|||
|
||||
import eu.eudat.entities.DataEntity;
|
||||
|
||||
public interface DataModel<T extends DataEntity> {
|
||||
void fromDataModel(T entity) throws InstantiationException, IllegalAccessException;
|
||||
public interface DataModel<T extends DataEntity,M extends DataModel> {
|
||||
M fromDataModel(T entity);
|
||||
T toDataModel() throws Exception;
|
||||
String getHint();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package eu.eudat.models.criteria;
|
||||
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.models.project.Project;
|
||||
import eu.eudat.models.project.ProjectCriteriaModel;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
|
@ -61,7 +59,7 @@ public class DataManagementPlanCriteria extends Criteria<DMP> {
|
|||
|
||||
public List<eu.eudat.entities.Project> getProjectEntities() {
|
||||
try {
|
||||
return new DomainModelConverter<eu.eudat.entities.Project, ProjectCriteriaModel>().toDataModel(this.projects);
|
||||
return this.projects.stream().map(item-> item.toDataModel()).collect(Collectors.toList());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new LinkedList<>();
|
||||
|
|
|
@ -5,7 +5,7 @@ import eu.eudat.utilities.helpers.LabelGenerator;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
public class DataRepository implements DataModel<eu.eudat.entities.DataRepository>,LabelGenerator{
|
||||
public class DataRepository implements DataModel<eu.eudat.entities.DataRepository,DataRepository>,LabelGenerator{
|
||||
private String pid;
|
||||
private String name;
|
||||
private String uri;
|
||||
|
@ -34,10 +34,11 @@ public class DataRepository implements DataModel<eu.eudat.entities.DataRepositor
|
|||
this.uri = uri;
|
||||
}
|
||||
|
||||
public void fromDataModel(eu.eudat.entities.DataRepository entity){
|
||||
public DataRepository fromDataModel(eu.eudat.entities.DataRepository entity){
|
||||
this.pid = entity.getReference();
|
||||
this.name = entity.getLabel();
|
||||
this.uri = entity.getUri();
|
||||
return this;
|
||||
}
|
||||
|
||||
public eu.eudat.entities.DataRepository toDataModel(){
|
||||
|
|
|
@ -3,16 +3,14 @@ package eu.eudat.models.dataset;
|
|||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Dataset implements DataModel<eu.eudat.entities.Dataset>{
|
||||
public class Dataset implements DataModel<eu.eudat.entities.Dataset,Dataset>{
|
||||
private UUID id;
|
||||
private String label;
|
||||
private String reference;
|
||||
|
@ -114,7 +112,7 @@ public class Dataset implements DataModel<eu.eudat.entities.Dataset>{
|
|||
this.profile = profile;
|
||||
}
|
||||
|
||||
public void fromDataModel(eu.eudat.entities.Dataset entity) throws IllegalAccessException, InstantiationException{
|
||||
public Dataset fromDataModel(eu.eudat.entities.Dataset entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.properties = entity.getProperties();
|
||||
|
@ -122,10 +120,11 @@ public class Dataset implements DataModel<eu.eudat.entities.Dataset>{
|
|||
this.description = entity.getDescription();
|
||||
this.profile = new DatasetProfileListingModel();
|
||||
this.profile.fromDataModel(entity.getProfile());
|
||||
this.registries = new DomainModelConverter<eu.eudat.entities.Registry,Registry>().fromDataModel(entity.getRegistries().stream().collect(Collectors.toList()), Registry.class);
|
||||
this.dataRepositories = new DomainModelConverter<eu.eudat.entities.DataRepository,DataRepository>().fromDataModel(entity.getDataRepositories().stream().collect(Collectors.toList()), DataRepository.class);
|
||||
this.services = new DomainModelConverter<eu.eudat.entities.Service,Service>().fromDataModel(entity.getServices().stream().collect(Collectors.toList()), Service.class);
|
||||
this.registries = entity.getRegistries().stream().map(item-> new Registry().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.dataRepositories = entity.getDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.services = entity.getServices().stream().map(item -> new Service().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.created = entity.getCreated();
|
||||
return this;
|
||||
}
|
||||
|
||||
public eu.eudat.entities.Dataset toDataModel() throws Exception {
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.hibernate.annotations.Type;
|
|||
import javax.persistence.Column;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Registry implements DataModel<eu.eudat.entities.Registry>,LabelGenerator {
|
||||
public class Registry implements DataModel<eu.eudat.entities.Registry,Registry>,LabelGenerator {
|
||||
private UUID id;
|
||||
private String label;
|
||||
private String abbreviation;
|
||||
|
@ -68,13 +68,14 @@ public class Registry implements DataModel<eu.eudat.entities.Registry>,LabelGene
|
|||
this.definition = definition;
|
||||
}
|
||||
|
||||
public void fromDataModel(eu.eudat.entities.Registry entity){
|
||||
public Registry fromDataModel(eu.eudat.entities.Registry entity){
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
this.reference = entity.getReference();
|
||||
this.uri = entity.getUri();
|
||||
this.definition = entity.getDefinition();
|
||||
return this;
|
||||
}
|
||||
|
||||
public eu.eudat.entities.Registry toDataModel(){
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.hibernate.annotations.Type;
|
|||
import javax.persistence.Column;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Service implements DataModel<eu.eudat.entities.Service>,LabelGenerator{
|
||||
public class Service implements DataModel<eu.eudat.entities.Service,Service>,LabelGenerator{
|
||||
private UUID id;
|
||||
private String label;
|
||||
|
||||
|
@ -67,13 +67,14 @@ public class Service implements DataModel<eu.eudat.entities.Service>,LabelGenera
|
|||
this.definition = definition;
|
||||
}
|
||||
|
||||
public void fromDataModel(eu.eudat.entities.Service entity){
|
||||
public Service fromDataModel(eu.eudat.entities.Service entity){
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
this.reference = entity.getReference();
|
||||
this.uri = entity.getUri();
|
||||
this.definition = entity.getDefinition();
|
||||
return this;
|
||||
}
|
||||
|
||||
public eu.eudat.entities.Service toDataModel(){
|
||||
|
|
|
@ -6,7 +6,7 @@ import eu.eudat.models.DataModel;
|
|||
import java.util.UUID;
|
||||
|
||||
|
||||
public class DatasetProfileAutocompleteItem implements DataModel<DatasetProfile> {
|
||||
public class DatasetProfileAutocompleteItem implements DataModel<DatasetProfile,DatasetProfileAutocompleteItem> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
|
@ -29,9 +29,10 @@ public class DatasetProfileAutocompleteItem implements DataModel<DatasetProfile>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(DatasetProfile entity) throws InstantiationException, IllegalAccessException {
|
||||
public DatasetProfileAutocompleteItem fromDataModel(DatasetProfile entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Set;
|
|||
import java.util.UUID;
|
||||
|
||||
|
||||
public class DatasetProfileListingModel implements DataModel<DatasetProfile> {
|
||||
public class DatasetProfileListingModel implements DataModel<DatasetProfile,DatasetProfileListingModel> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
|
@ -77,13 +77,14 @@ public class DatasetProfileListingModel implements DataModel<DatasetProfile> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(DatasetProfile entity) throws InstantiationException, IllegalAccessException {
|
||||
public DatasetProfileListingModel fromDataModel(DatasetProfile entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.status = entity.getStatus();
|
||||
this.created = entity.getCreated();
|
||||
this.modified = entity.getModified();
|
||||
this.description = entity.getDescription();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,7 +4,7 @@ import eu.eudat.entities.DMP;
|
|||
import eu.eudat.models.DataModel;
|
||||
|
||||
|
||||
public class DataManagentPlanListingModel implements DataModel<DMP>{
|
||||
public class DataManagentPlanListingModel implements DataModel<DMP,DataManagentPlanListingModel>{
|
||||
|
||||
private String id;
|
||||
private String label;
|
||||
|
@ -26,9 +26,10 @@ public class DataManagentPlanListingModel implements DataModel<DMP>{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(DMP entity) throws InstantiationException, IllegalAccessException {
|
||||
public DataManagentPlanListingModel fromDataModel(DMP entity) {
|
||||
this.id = entity.getId().toString();
|
||||
this.label = entity.getLabel();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.eudat.models.datasetwizard;
|
||||
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.ExternalDataset;
|
||||
import eu.eudat.models.DataModel;
|
||||
|
@ -10,17 +9,13 @@ import eu.eudat.models.dataset.Service;
|
|||
import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.externaldataset.ExternalDatasetListingModel;
|
||||
import eu.eudat.models.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.properties.PropertiesModel;
|
||||
import eu.eudat.models.user.composite.DatasetProfile;
|
||||
import eu.eudat.models.user.composite.PagedDatasetProfile;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class DatasetWizardModel implements DataModel<Dataset> {
|
||||
public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel> {
|
||||
|
||||
private UUID id;
|
||||
private String label;
|
||||
|
@ -150,7 +145,7 @@ public class DatasetWizardModel implements DataModel<Dataset> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(Dataset entity) throws InstantiationException, IllegalAccessException {
|
||||
public DatasetWizardModel fromDataModel(Dataset entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.status = entity.getStatus();
|
||||
|
@ -159,12 +154,13 @@ public class DatasetWizardModel implements DataModel<Dataset> {
|
|||
this.profile = new DatasetProfileListingModel();
|
||||
this.uri = entity.getUri();
|
||||
this.profile.fromDataModel(entity.getProfile());
|
||||
this.registries = new DomainModelConverter<eu.eudat.entities.Registry, Registry>().fromDataModel(entity.getRegistries().stream().collect(Collectors.toList()), Registry.class);
|
||||
this.dataRepositories = new DomainModelConverter<eu.eudat.entities.DataRepository, DataRepository>().fromDataModel(entity.getDataRepositories().stream().collect(Collectors.toList()), DataRepository.class);
|
||||
this.services = new DomainModelConverter<eu.eudat.entities.Service, Service>().fromDataModel(entity.getServices().stream().collect(Collectors.toList()), Service.class);
|
||||
this.registries = entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.dataRepositories = entity.getDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.services = entity.getServices().stream().map(item -> new Service().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.created = entity.getCreated();
|
||||
this.dmp = new DomainModelConverter<eu.eudat.entities.DMP, DataManagementPlan>().fromDataModel(Arrays.asList(entity.getDmp()), DataManagementPlan.class).get(0);
|
||||
this.externalDatasets = new DomainModelConverter<ExternalDataset, ExternalDatasetListingModel>().fromDataModel(entity.getExternalDatasets().stream().collect(Collectors.toList()), ExternalDatasetListingModel.class);
|
||||
this.dmp = new DataManagementPlan().fromDataModel(entity.getDmp());
|
||||
this.externalDatasets = entity.getExternalDatasets().stream().map(item -> new ExternalDatasetListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -4,18 +4,16 @@ import eu.eudat.entities.*;
|
|||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.project.Project;
|
||||
import eu.eudat.models.userinfo.UserInfo;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import eu.eudat.utilities.builders.XmlBuilder;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DataManagementPlan implements DataModel<DMP> {
|
||||
public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
||||
private UUID id;
|
||||
private String label;
|
||||
private UUID groupId;
|
||||
|
@ -135,10 +133,10 @@ public class DataManagementPlan implements DataModel<DMP> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(DMP entity) throws InstantiationException, IllegalAccessException {
|
||||
public DataManagementPlan fromDataModel(DMP entity) {
|
||||
this.id = entity.getId();
|
||||
this.organisations = new DomainModelConverter<eu.eudat.entities.Organisation, Organisation>().fromDataModel(entity.getOrganisations().stream().collect(Collectors.toList()), Organisation.class);
|
||||
this.researchers = new DomainModelConverter<eu.eudat.entities.Researcher, Researcher>().fromDataModel(entity.getResearchers().stream().collect(Collectors.toList()), Researcher.class);
|
||||
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.version = entity.getVersion();
|
||||
this.groupId = this.groupId == null ? null : this.groupId;
|
||||
this.label = entity.getLabel();
|
||||
|
@ -164,7 +162,8 @@ public class DataManagementPlan implements DataModel<DMP> {
|
|||
}
|
||||
this.created = entity.getCreated();
|
||||
this.description = entity.getDescription();
|
||||
this.associatedUsers = new DomainModelConverter<eu.eudat.entities.UserInfo, UserInfo>().fromDataModel(entity.getUsers().stream().collect(Collectors.toList()), UserInfo.class);
|
||||
this.associatedUsers = entity.getUsers().stream().map(item -> new UserInfo().fromDataModel(item)).collect(Collectors.toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -172,9 +171,9 @@ public class DataManagementPlan implements DataModel<DMP> {
|
|||
DMP dataManagementPlanEntity = new DMP();
|
||||
dataManagementPlanEntity.setId(this.id);
|
||||
if (this.organisations != null && !this.organisations.isEmpty())
|
||||
dataManagementPlanEntity.setOrganisations(new HashSet<eu.eudat.entities.Organisation>(new DomainModelConverter<eu.eudat.entities.Organisation, Organisation>().toDataModel(this.organisations)));
|
||||
dataManagementPlanEntity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
if (this.researchers != null && !this.researchers.isEmpty())
|
||||
dataManagementPlanEntity.setResearchers(new HashSet<eu.eudat.entities.Researcher>(new DomainModelConverter<eu.eudat.entities.Researcher, Researcher>().toDataModel(this.researchers)));
|
||||
dataManagementPlanEntity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
dataManagementPlanEntity.setVersion(this.version);
|
||||
|
||||
dataManagementPlanEntity.setLabel(this.label);
|
||||
|
@ -192,7 +191,7 @@ public class DataManagementPlan implements DataModel<DMP> {
|
|||
}
|
||||
dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());
|
||||
dataManagementPlanEntity.setCreated(this.created != null ? this.created : new Date());
|
||||
dataManagementPlanEntity.setUsers(new HashSet<>(new DomainModelConverter<eu.eudat.entities.UserInfo,UserInfo>().toDataModel(this.associatedUsers)));
|
||||
dataManagementPlanEntity.setUsers(new HashSet<>(this.associatedUsers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
return dataManagementPlanEntity;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,18 +5,17 @@ import eu.eudat.models.DataModel;
|
|||
import eu.eudat.models.dataset.Dataset;
|
||||
import eu.eudat.models.project.Project;
|
||||
import eu.eudat.models.userinfo.UserInfo;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import eu.eudat.utilities.builders.XmlBuilder;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 2/5/2018.
|
||||
*/
|
||||
public class DataManagementPlanNewVersionModel implements DataModel<DMP> {
|
||||
public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataManagementPlanNewVersionModel> {
|
||||
private UUID id;
|
||||
private String label;
|
||||
private UUID groupId;
|
||||
|
@ -145,15 +144,15 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(DMP entity) throws InstantiationException, IllegalAccessException {
|
||||
|
||||
public DataManagementPlanNewVersionModel fromDataModel(DMP entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DMP toDataModel() throws Exception {
|
||||
DMP entity = new DMP();
|
||||
entity.setId(this.id);
|
||||
entity.setUsers(new HashSet<>(new DomainModelConverter<eu.eudat.entities.UserInfo, UserInfo>().toDataModel(this.associatedUsers)));
|
||||
entity.setUsers(new HashSet<>(this.associatedUsers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
entity.setDescription(this.description);
|
||||
entity.setStatus((short) this.status);
|
||||
entity.setGroupId(this.groupId == null ? UUID.randomUUID() : this.groupId);
|
||||
|
@ -170,9 +169,9 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP> {
|
|||
entity.setDataset(new HashSet<>(datasets));
|
||||
}
|
||||
if (this.organisations != null && !this.organisations.isEmpty())
|
||||
entity.setOrganisations(new HashSet<eu.eudat.entities.Organisation>(new DomainModelConverter<eu.eudat.entities.Organisation, Organisation>().toDataModel(this.organisations)));
|
||||
entity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
if (this.researchers != null && !this.researchers.isEmpty())
|
||||
entity.setResearchers(new HashSet<eu.eudat.entities.Researcher>(new DomainModelConverter<eu.eudat.entities.Researcher, Researcher>().toDataModel(this.researchers)));
|
||||
entity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||
if (this.project != null) entity.setProject(this.project.toDataModel());
|
||||
if (this.profiles != null) {
|
||||
Document associatedProfileDoc = XmlBuilder.getDocument();
|
||||
|
|
|
@ -5,7 +5,7 @@ import eu.eudat.utilities.helpers.LabelGenerator;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
public class Organisation implements DataModel<eu.eudat.entities.Organisation>,LabelGenerator {
|
||||
public class Organisation implements DataModel<eu.eudat.entities.Organisation,Organisation>,LabelGenerator {
|
||||
private String label;
|
||||
private String name;
|
||||
private String id;
|
||||
|
@ -44,10 +44,11 @@ public class Organisation implements DataModel<eu.eudat.entities.Organisation>,L
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(eu.eudat.entities.Organisation entity) {
|
||||
public Organisation fromDataModel(eu.eudat.entities.Organisation entity) {
|
||||
this.id = entity.getReference();
|
||||
this.name = entity.getLabel();
|
||||
this.label = entity.getUri();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,7 +5,7 @@ import eu.eudat.utilities.helpers.LabelGenerator;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
public class Researcher implements DataModel<eu.eudat.entities.Researcher>,LabelGenerator {
|
||||
public class Researcher implements DataModel<eu.eudat.entities.Researcher,Researcher>,LabelGenerator {
|
||||
private String label;
|
||||
private String name;
|
||||
private String id;
|
||||
|
@ -44,11 +44,12 @@ public class Researcher implements DataModel<eu.eudat.entities.Researcher>,Label
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(eu.eudat.entities.Researcher entity) {
|
||||
public Researcher fromDataModel(eu.eudat.entities.Researcher entity) {
|
||||
this.id = entity.getReference();
|
||||
this.label = entity.getUri();
|
||||
this.name = entity.getLabel();
|
||||
this.status = entity.getStatus();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.Date;
|
|||
import java.util.UUID;
|
||||
|
||||
|
||||
public class ExternalDatasetListingModel implements DataModel<ExternalDataset> {
|
||||
public class ExternalDatasetListingModel implements DataModel<ExternalDataset,ExternalDatasetListingModel> {
|
||||
|
||||
private UUID id;
|
||||
private String label;
|
||||
|
@ -66,13 +66,14 @@ public class ExternalDatasetListingModel implements DataModel<ExternalDataset> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(ExternalDataset entity) throws InstantiationException, IllegalAccessException {
|
||||
public ExternalDatasetListingModel fromDataModel(ExternalDataset entity) {
|
||||
this.id = entity.getId();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
this.label = entity.getLabel();
|
||||
this.modified = entity.getModified();
|
||||
this.created = entity.getCreated();
|
||||
this.reference = entity.getReference();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
package eu.eudat.models.listingmodels;
|
||||
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.DataRepository;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.dmp.Organisation;
|
||||
import eu.eudat.models.dmp.Researcher;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import eu.eudat.utilities.helpers.LabelBuilder;
|
||||
import eu.eudat.utilities.helpers.LabelGenerator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class DataManagementPlanListingModel implements DataModel<DMP> {
|
||||
public class DataManagementPlanListingModel implements DataModel<DMP,DataManagementPlanListingModel> {
|
||||
private String id;
|
||||
private String label;
|
||||
private String project;
|
||||
|
@ -98,16 +93,17 @@ public class DataManagementPlanListingModel implements DataModel<DMP> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(DMP entity) throws InstantiationException, IllegalAccessException {
|
||||
public DataManagementPlanListingModel fromDataModel(DMP entity) {
|
||||
this.id = entity.getId().toString();
|
||||
this.label = entity.getLabel();
|
||||
this.project = entity.getProject().getLabel();
|
||||
if(entity.getProfile()!=null)this.profile = entity.getProfile().getLabel();
|
||||
this.organisations =LabelBuilder.getLabel(new DomainModelConverter<eu.eudat.entities.Organisation,Organisation>().fromDataModel(entity.getOrganisations().stream().collect(Collectors.toList()),Organisation.class));
|
||||
this.organisations =LabelBuilder.getLabel(entity.getOrganisations().stream().map(item-> new Organisation().fromDataModel(item)).collect(Collectors.toList()));
|
||||
this.creationTime = entity.getCreated().toString();
|
||||
this.version = ""+entity.getVersion();
|
||||
this.groupId = entity.getGroupId();
|
||||
this.numOfDatasets = entity.getDataset().size();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,28 +1,16 @@
|
|||
package eu.eudat.models.listingmodels;
|
||||
|
||||
import eu.eudat.entities.*;
|
||||
import eu.eudat.entities.DataRepository;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.Organisation;
|
||||
import eu.eudat.entities.Registry;
|
||||
import eu.eudat.entities.Researcher;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.dataset.*;
|
||||
import eu.eudat.models.dataset.DataRepository;
|
||||
import eu.eudat.models.dataset.Service;
|
||||
import eu.eudat.models.dmp.*;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import eu.eudat.utilities.helpers.LabelBuilder;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class DatasetListingModel implements DataModel<Dataset> {
|
||||
public class DatasetListingModel implements DataModel<Dataset, DatasetListingModel> {
|
||||
private String id;
|
||||
private String label;
|
||||
private String dmp;
|
||||
|
@ -115,17 +103,18 @@ public class DatasetListingModel implements DataModel<Dataset> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(Dataset entity) throws InstantiationException, IllegalAccessException {
|
||||
public DatasetListingModel fromDataModel(Dataset entity) {
|
||||
this.id = entity.getId().toString();
|
||||
this.label = entity.getLabel();
|
||||
this.created = entity.getCreated().toString();
|
||||
this.dmp = entity.getDmp()!=null? entity.getDmp().getLabel():"";
|
||||
this.profile = entity.getProfile()!=null? entity.getProfile().getLabel():"";
|
||||
this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
|
||||
this.profile = entity.getProfile() != null ? entity.getProfile().getLabel() : "";
|
||||
this.description = entity.getDescription();
|
||||
this.status = ""+entity.getStatus();
|
||||
this.registries = LabelBuilder.getLabel(new DomainModelConverter<Registry, eu.eudat.models.dataset.Registry>().fromDataModel(entity.getRegistries().stream().collect(Collectors.toList()), eu.eudat.models.dataset.Registry.class));
|
||||
this.dataRepositories = LabelBuilder.getLabel(new DomainModelConverter<eu.eudat.entities.DataRepository, eu.eudat.models.dataset.DataRepository>().fromDataModel(entity.getDataRepositories().stream().collect(Collectors.toList()), eu.eudat.models.dataset.DataRepository.class));
|
||||
this.services = LabelBuilder.getLabel(new DomainModelConverter<eu.eudat.entities.Service, eu.eudat.models.dataset.Service>().fromDataModel(entity.getServices().stream().collect(Collectors.toList()), Service.class));
|
||||
this.status = "" + entity.getStatus();
|
||||
this.registries = LabelBuilder.getLabel(entity.getRegistries().stream().map(item -> new eu.eudat.models.dataset.Registry().fromDataModel(item)).collect(Collectors.toList()));
|
||||
this.dataRepositories = LabelBuilder.getLabel(entity.getDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item)).collect(Collectors.toList()));
|
||||
this.services = LabelBuilder.getLabel(entity.getServices().stream().map(item -> new Service().fromDataModel(item)).collect(Collectors.toList()));
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,7 +10,7 @@ import eu.eudat.models.DataModel;
|
|||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
|
||||
|
||||
public class Project implements DataModel<eu.eudat.entities.Project> {
|
||||
public class Project implements DataModel<eu.eudat.entities.Project,Project> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
|
@ -154,7 +154,7 @@ public class Project implements DataModel<eu.eudat.entities.Project> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(eu.eudat.entities.Project entity) throws InstantiationException, IllegalAccessException {
|
||||
public Project fromDataModel(eu.eudat.entities.Project entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
|
@ -167,6 +167,7 @@ public class Project implements DataModel<eu.eudat.entities.Project> {
|
|||
this.created = entity.getCreated();
|
||||
this.modified = entity.getModified();
|
||||
this.description = entity.getDescription();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,7 +7,7 @@ import eu.eudat.models.DataModel;
|
|||
import java.util.UUID;
|
||||
|
||||
|
||||
public class ProjectCriteriaModel implements DataModel<eu.eudat.entities.Project> {
|
||||
public class ProjectCriteriaModel implements DataModel<eu.eudat.entities.Project,ProjectCriteriaModel> {
|
||||
private UUID id;
|
||||
|
||||
public UUID getId() {
|
||||
|
@ -19,8 +19,9 @@ public class ProjectCriteriaModel implements DataModel<eu.eudat.entities.Project
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(Project entity) throws InstantiationException, IllegalAccessException {
|
||||
public ProjectCriteriaModel fromDataModel(Project entity) {
|
||||
this.id = entity.getId();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,7 +11,7 @@ import eu.eudat.models.DataModel;
|
|||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
|
||||
|
||||
public class ProjectListingModel implements DataModel<eu.eudat.entities.Project> {
|
||||
public class ProjectListingModel implements DataModel<eu.eudat.entities.Project,ProjectListingModel> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
|
@ -155,7 +155,7 @@ public class ProjectListingModel implements DataModel<eu.eudat.entities.Project>
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(eu.eudat.entities.Project entity) throws InstantiationException, IllegalAccessException {
|
||||
public ProjectListingModel fromDataModel(eu.eudat.entities.Project entity) {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
|
@ -168,7 +168,7 @@ public class ProjectListingModel implements DataModel<eu.eudat.entities.Project>
|
|||
this.created = entity.getCreated().toString();
|
||||
this.modified = entity.getModified().toString();
|
||||
this.description = entity.getDescription();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.UUID;
|
|||
/**
|
||||
* Created by ikalyvas on 2/5/2018.
|
||||
*/
|
||||
public class Researcher implements DataModel<eu.eudat.entities.Researcher> {
|
||||
public class Researcher implements DataModel<eu.eudat.entities.Researcher,Researcher> {
|
||||
|
||||
private String firstName;
|
||||
|
||||
|
@ -33,8 +33,8 @@ public class Researcher implements DataModel<eu.eudat.entities.Researcher> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(eu.eudat.entities.Researcher entity) throws InstantiationException, IllegalAccessException {
|
||||
|
||||
public Researcher fromDataModel(eu.eudat.entities.Researcher entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.util.UUID;
|
|||
|
||||
import eu.eudat.models.DataModel;
|
||||
|
||||
public class UserInfo implements DataModel<eu.eudat.entities.UserInfo>{
|
||||
public class UserInfo implements DataModel<eu.eudat.entities.UserInfo,UserInfo>{
|
||||
private UUID id;
|
||||
|
||||
private String email = null;
|
||||
|
@ -97,11 +97,12 @@ public class UserInfo implements DataModel<eu.eudat.entities.UserInfo>{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(eu.eudat.entities.UserInfo entity) throws InstantiationException, IllegalAccessException {
|
||||
public UserInfo fromDataModel(eu.eudat.entities.UserInfo entity) {
|
||||
this.name = entity.getName();
|
||||
this.email = entity.getEmail();
|
||||
this.usertype = entity.getUsertype();
|
||||
this.id = entity.getId();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,7 +7,7 @@ import eu.eudat.models.DataModel;
|
|||
import java.util.UUID;
|
||||
|
||||
|
||||
public class UserInfoInvitationModel implements DataModel<eu.eudat.entities.UserInfo>{
|
||||
public class UserInfoInvitationModel implements DataModel<eu.eudat.entities.UserInfo,UserInfoInvitationModel>{
|
||||
private UUID id;
|
||||
private String email;
|
||||
private String name;
|
||||
|
@ -37,10 +37,11 @@ public class UserInfoInvitationModel implements DataModel<eu.eudat.entities.User
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(eu.eudat.entities.UserInfo entity) throws InstantiationException, IllegalAccessException {
|
||||
public UserInfoInvitationModel fromDataModel(eu.eudat.entities.UserInfo entity) {
|
||||
this.id = entity.getId();
|
||||
this.email = entity.getEmail();
|
||||
this.name = entity.getName();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.UUID;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
public class UserListingModel implements DataModel<eu.eudat.entities.UserInfo> {
|
||||
public class UserListingModel implements DataModel<eu.eudat.entities.UserInfo,UserListingModel> {
|
||||
|
||||
private UUID id;
|
||||
|
||||
|
@ -103,7 +103,7 @@ public class UserListingModel implements DataModel<eu.eudat.entities.UserInfo> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(UserInfo entity) throws InstantiationException, IllegalAccessException {
|
||||
public UserListingModel fromDataModel(UserInfo entity) {
|
||||
this.id = entity.getId();
|
||||
this.email = entity.getEmail();
|
||||
this.usertype = entity.getUsertype();
|
||||
|
@ -113,6 +113,7 @@ public class UserListingModel implements DataModel<eu.eudat.entities.UserInfo> {
|
|||
this.lastloggedin = entity.getLastloggedin();
|
||||
this.additionalinfo = entity.getAdditionalinfo();
|
||||
this.appRoles = entity.getUserRoles().stream().map(item -> item.getRole()).collect(Collectors.toList());
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.services;
|
||||
|
||||
import eu.eudat.builders.BuilderFactory;
|
||||
import eu.eudat.proxy.fetching.RemoteFetcher;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.MessageSource;
|
||||
|
@ -12,4 +13,5 @@ public interface ApiContext {
|
|||
RemoteFetcher getRemoteFetcher();
|
||||
MailService getMailService();
|
||||
MessageSource getMessageSource();
|
||||
BuilderFactory getBuilderFactory();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.services;
|
||||
|
||||
import eu.eudat.builders.BuilderFactory;
|
||||
import eu.eudat.proxy.fetching.RemoteFetcher;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
@ -16,6 +17,7 @@ public class ApiContextImpl implements ApiContext{
|
|||
private InvitationService invitationService;
|
||||
private MailService mailService;
|
||||
private MessageSource messageSource;
|
||||
private BuilderFactory builderFactory;
|
||||
|
||||
@Autowired
|
||||
public void setDatabaseRepository(DatabaseRepository databaseRepository) {
|
||||
|
@ -76,4 +78,14 @@ public class ApiContextImpl implements ApiContext{
|
|||
public void setMessageSource(MessageSource messageSource) {
|
||||
this.messageSource = messageSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuilderFactory getBuilderFactory() {
|
||||
return builderFactory;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setBuilderFactory(BuilderFactory builderFactory) {
|
||||
this.builderFactory = builderFactory;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package eu.eudat.services;
|
||||
|
||||
import eu.eudat.dao.entities.UserInfoDao;
|
||||
import eu.eudat.dao.entities.security.UserTokenDao;
|
||||
import eu.eudat.builders.entity.CredentialBuilder;
|
||||
import eu.eudat.builders.entity.UserInfoBuilder;
|
||||
import eu.eudat.builders.entity.UserTokenBuilder;
|
||||
import eu.eudat.builders.model.models.PrincipalBuilder;
|
||||
import eu.eudat.entities.Credential;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.entities.UserRole;
|
||||
|
@ -17,9 +19,7 @@ import org.springframework.core.env.Environment;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.xml.ws.ServiceMode;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Service("authenticationService ")
|
||||
|
@ -51,11 +51,10 @@ public class AuthenticationService {
|
|||
UserInfo user = this.apiContext.getDatabaseRepository().getUserInfoDao().find(token.getUser().getId());
|
||||
if (user == null) return null;
|
||||
|
||||
Principal principal = new Principal();
|
||||
principal.setId(user.getId());
|
||||
principal.setToken(token.getToken());
|
||||
principal.setExpiresAt(token.getExpiresAt());
|
||||
principal.setName(user.getName());
|
||||
Principal principal = this.apiContext.getBuilderFactory().getBuilder(PrincipalBuilder.class)
|
||||
.id(user.getId()).token(token.getToken())
|
||||
.expiresAt(token.getExpiresAt()).name(user.getName())
|
||||
.build();
|
||||
|
||||
List<UserRole> userRoles = apiContext.getDatabaseRepository().getUserRoleDao().getUserRoles(user);
|
||||
for (UserRole item : userRoles) {
|
||||
|
@ -68,16 +67,21 @@ public class AuthenticationService {
|
|||
public Principal Touch(Credentials credentials) {
|
||||
Credential credential = this.apiContext.getDatabaseRepository().getCredentialDao().getLoggedInCredentials(credentials);
|
||||
|
||||
if (credential == null && credentials.getUsername().equals(environment.getProperty("autouser.root.username")))
|
||||
credential = this.autoCreateUser(credentials.getUsername(), credentials.getSecret());
|
||||
|
||||
if (credential == null && credentials.getUsername().equals(environment.getProperty("autouser.root.username"))) {
|
||||
try {
|
||||
credential = this.autoCreateUser(credentials.getUsername(), credentials.getSecret());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (credential == null) return null;
|
||||
|
||||
UserToken userToken = new UserToken();
|
||||
userToken.setUser(credential.getUserInfo());
|
||||
userToken.setIssuedAt(new Date());
|
||||
userToken.setToken(UUID.randomUUID());
|
||||
userToken.setExpiresAt(addADay(new Date()));
|
||||
UserToken userToken = this.apiContext.getBuilderFactory().getBuilder(UserTokenBuilder.class)
|
||||
.issuedAt(new Date()).user(credential.getUserInfo())
|
||||
.token(UUID.randomUUID()).expiresAt(addADay(new Date()))
|
||||
.build();
|
||||
|
||||
userToken = apiContext.getDatabaseRepository().getUserTokenDao().createOrUpdate(userToken);
|
||||
|
||||
return this.Touch(userToken);
|
||||
|
@ -89,22 +93,19 @@ public class AuthenticationService {
|
|||
criteria.setEmail(profile.getEmail());
|
||||
UserInfo userInfo = apiContext.getDatabaseRepository().getUserInfoDao().asQueryable().withHint("userInfo").where((builder, root) -> builder.equal(root.get("email"), profile.getEmail())).getSingleOrDefault();
|
||||
|
||||
final Credential credential = new Credential();
|
||||
credential.setId(UUID.randomUUID());
|
||||
credential.setCreationTime(new Date());
|
||||
credential.setStatus(1);
|
||||
credential.setLastUpdateTime(new Date());
|
||||
credential.setProvider((int) profile.getProvider().getValue());
|
||||
credential.setSecret(profile.getSecret());
|
||||
final Credential credential = this.apiContext.getBuilderFactory().getBuilder(CredentialBuilder.class)
|
||||
.id(UUID.randomUUID()).creationTime(new Date()).status(1)
|
||||
.lastUpdateTime(new Date()).provider((int) profile.getProvider().getValue())
|
||||
.secret(profile.getSecret())
|
||||
.build();
|
||||
|
||||
if (userInfo == null) {
|
||||
userInfo = new UserInfo();
|
||||
userInfo.setName(profile.getName());
|
||||
userInfo.setVerified_email(profile.getIsVerified());
|
||||
userInfo.setEmail(profile.getEmail());
|
||||
userInfo.setCreated(new Date());
|
||||
userInfo.setLastloggedin(new Date());
|
||||
userInfo.setAuthorization_level(new Short("1"));
|
||||
userInfo.setUsertype(new Short("1"));
|
||||
userInfo = this.apiContext.getBuilderFactory().getBuilder(UserInfoBuilder.class)
|
||||
.name(profile.getName()).verified_email(profile.getIsVerified())
|
||||
.email(profile.getEmail()).created(new Date()).lastloggedin(new Date())
|
||||
.authorization_level((short) 1).usertype((short) 1)
|
||||
.build();
|
||||
|
||||
userInfo = apiContext.getDatabaseRepository().getUserInfoDao().createOrUpdate(userInfo);
|
||||
credential.setPublicValue(userInfo.getName());
|
||||
credential.setUserInfo(userInfo);
|
||||
|
@ -131,11 +132,11 @@ public class AuthenticationService {
|
|||
userInfo = apiContext.getDatabaseRepository().getUserInfoDao().createOrUpdate(userInfo);
|
||||
}
|
||||
|
||||
UserToken userToken = new UserToken();
|
||||
userToken.setUser(userInfo);
|
||||
userToken.setIssuedAt(new Date());
|
||||
userToken.setToken(UUID.randomUUID());
|
||||
userToken.setExpiresAt(addADay(new Date()));
|
||||
UserToken userToken = this.apiContext.getBuilderFactory().getBuilder(UserTokenBuilder.class)
|
||||
.token(UUID.randomUUID()).user(userInfo)
|
||||
.expiresAt(addADay(new Date())).issuedAt(new Date())
|
||||
.build();
|
||||
|
||||
apiContext.getDatabaseRepository().getUserTokenDao().createOrUpdate(userToken);
|
||||
return Touch(userToken.getToken());
|
||||
}
|
||||
|
@ -155,13 +156,11 @@ public class AuthenticationService {
|
|||
if (!environment.getProperty("autouser.root.username").equals(username) || !environment.getProperty("autouser.root.password").equals(password))
|
||||
return null;
|
||||
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setName(username);
|
||||
userInfo.setEmail(environment.getProperty("autouser.root.email"));
|
||||
userInfo.setCreated(new Date());
|
||||
userInfo.setLastloggedin(new Date());
|
||||
userInfo.setAuthorization_level((short) 1);
|
||||
userInfo.setUsertype((short) 1);
|
||||
UserInfo userInfo = this.apiContext.getBuilderFactory().getBuilder(UserInfoBuilder.class)
|
||||
.name(username).email(environment.getProperty("autouser.root.email")).created(new Date())
|
||||
.lastloggedin(new Date()).authorization_level((short) 1).usertype((short) 1)
|
||||
.build();
|
||||
|
||||
userInfo = this.apiContext.getDatabaseRepository().getUserInfoDao().createOrUpdate(userInfo);
|
||||
|
||||
UserRole role = new UserRole();
|
||||
|
@ -169,14 +168,12 @@ public class AuthenticationService {
|
|||
role.setUserInfo(userInfo);
|
||||
this.apiContext.getDatabaseRepository().getUserRoleDao().createOrUpdate(role);
|
||||
|
||||
Credential credential = new Credential();
|
||||
credential.setUserInfo(userInfo);
|
||||
credential.setPublicValue(username);
|
||||
credential.setSecret(password);
|
||||
credential.setProvider((int) TokenValidatorFactoryImpl.LoginProvider.NATIVELOGIN.getValue());
|
||||
credential.setCreationTime(new Date());
|
||||
credential.setLastUpdateTime(new Date());
|
||||
credential.setStatus(0);
|
||||
Credential credential = this.apiContext.getBuilderFactory().getBuilder(CredentialBuilder.class)
|
||||
.userInfo(userInfo).publicValue(username).secret(password)
|
||||
.provider((int) TokenValidatorFactoryImpl.LoginProvider.NATIVELOGIN.getValue())
|
||||
.creationTime(new Date()).lastUpdateTime(new Date()).status(0)
|
||||
.build();
|
||||
|
||||
return this.apiContext.getDatabaseRepository().getCredentialDao().createOrUpdate(credential);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
package eu.eudat.utilities.builders;
|
||||
|
||||
|
||||
import eu.eudat.entities.DataEntity;
|
||||
import eu.eudat.models.DataModel;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class DomainModelConverter<T extends DataEntity,U extends DataModel<T>> {
|
||||
|
||||
public List<T> toDataModel(List<U> models) throws Exception {
|
||||
List<T> entities = new LinkedList<>();
|
||||
for(U model : models){
|
||||
entities.add(model.toDataModel());
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
|
||||
public List<U> fromDataModel(List<T> entities,Class<U> clazz) {
|
||||
List<U> models = new LinkedList<>();
|
||||
for(T entity:entities){
|
||||
U model = null;
|
||||
try {
|
||||
model = clazz.newInstance();
|
||||
model.fromDataModel(entity);
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
models.add(model);
|
||||
}
|
||||
return models;
|
||||
}
|
||||
}
|
|
@ -45,7 +45,7 @@ twitter.login.clientId=HiR4hQH9HNubKC5iKQy0l4mAZ
|
|||
twitter.login.clientSecret=9KZHgkqUO2QFnELSL14jeUvfUacWX23rqD8OW8X0xoRDXOSfKH
|
||||
twitter.login.redirect_uri=http://dl043.madgik.di.uoa.gr:8080/login/twitter
|
||||
########################Persistence/Hibernate/Batch##############################
|
||||
spring.profiles.active=production
|
||||
spring.profiles.active=devel
|
||||
########################Persistence/Hibernate/Connection pool####################
|
||||
autouser.root.email = root@dmp.com
|
||||
autouser.root.password = root
|
||||
|
|
|
@ -1,4 +1,21 @@
|
|||
<app-navigation></app-navigation>
|
||||
<div class="container">
|
||||
<router-outlet></router-outlet>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<help-content position="top"></help-content>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<help-content position="left"></help-content>
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<help-content position="right"></help-content>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<help-content position="bottom"></help-content>
|
||||
</div>
|
||||
</div>
|
|
@ -1,4 +1,4 @@
|
|||
import { environment } from '../environments/environment.prod';
|
||||
import { environment } from '../environments/environment';
|
||||
export const HostConfiguration = {
|
||||
Server: environment.Server,
|
||||
App: environment.App
|
||||
|
|
|
@ -31,13 +31,16 @@ import { AppComponent } from './app.component';
|
|||
import { NgModule } from "@angular/core";
|
||||
import { DatasetProfileModule } from './dataset-profile-form/dataset-profile.module';
|
||||
import { WelcomepageComponent } from '@app/welcomepage/welcomepage.component';
|
||||
import { HelpContentService } from './services/help-content/help-content.service';
|
||||
import { HelpContentComponent } from './help-content/help-content.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
PageNotFoundComponent,
|
||||
HomepageComponent,
|
||||
WelcomepageComponent
|
||||
WelcomepageComponent,
|
||||
HelpContentComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
@ -81,7 +84,8 @@ import { WelcomepageComponent } from '@app/welcomepage/welcomepage.component';
|
|||
providers: [
|
||||
AuthService,
|
||||
DashboardService,
|
||||
BaseHttpService
|
||||
BaseHttpService,
|
||||
HelpContentService
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/**
|
||||
* Created by stefania on 7/17/17.
|
||||
*/
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { ActivatedRoute, Router, NavigationStart } from "@angular/router";
|
||||
import { PageHelpContent } from '../models/help-content/page-help-content';
|
||||
import { HelpContentService } from '../services/help-content/help-content.service';
|
||||
@Component({
|
||||
selector: 'help-content',
|
||||
template: `
|
||||
<ng-template [ngIf]="contents && contents.length>0">
|
||||
<ng-template ngFor let-content [ngForOf]="contents">
|
||||
<div [innerHTML]="content.content" class="uk-margin-medium-bottom"></div>
|
||||
</ng-template>
|
||||
</ng-template>
|
||||
`,
|
||||
})
|
||||
export class HelpContentComponent implements OnInit {
|
||||
@Input('position')
|
||||
position: string;
|
||||
contents: any[];
|
||||
errorMessage: string = null;
|
||||
constructor(private _helpContentService: HelpContentService, private route: ActivatedRoute, private router: Router) {
|
||||
}
|
||||
ngOnInit() {
|
||||
this.errorMessage = null;
|
||||
this.router.events.subscribe(event => {
|
||||
if (event instanceof NavigationStart) {
|
||||
this._helpContentService.getActivePageContent(event["url"]).subscribe(
|
||||
pageContent => this.shiftThroughContent(pageContent),
|
||||
error => this.handleError(<any>error))
|
||||
}
|
||||
})
|
||||
}
|
||||
shiftThroughContent(pageContent: PageHelpContent) {
|
||||
this.contents = pageContent.content[this.position];
|
||||
}
|
||||
isPresent() {
|
||||
return (this.contents && this.contents.length > 0);
|
||||
}
|
||||
handleError(error) {
|
||||
this.errorMessage = 'System error retrieving page content (Server responded: ' + error + ')';
|
||||
}
|
||||
}
|
||||
@Component({
|
||||
selector: 'aside-help-content',
|
||||
template: `
|
||||
<ng-template [ngIf]="contents && contents.length>0">
|
||||
<ng-template ngFor let-content [ngForOf]="contents">
|
||||
<div [innerHTML]="content.content" class="uk-card uk-card-body uk-card-default sidemenu uk-margin-bottom"></div>
|
||||
</ng-template>
|
||||
</ng-template>
|
||||
`,
|
||||
})
|
||||
export class AsideHelpContentComponent extends HelpContentComponent {
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
/**
|
||||
* Created by stefania on 4/26/17.
|
||||
*/
|
||||
import { Topic } from "./topic";
|
||||
import { Question } from "./question";
|
||||
|
||||
export interface ActiveTopicQuestions {
|
||||
topic: Topic;
|
||||
questionList: Question[];
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Created by stefania on 7/13/17.
|
||||
*/
|
||||
import { Page } from "./page";
|
||||
|
||||
export interface PageHelpContent {
|
||||
_id: string;
|
||||
page: Page | string;
|
||||
placement : string;
|
||||
order: number;
|
||||
content: string;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
export interface CheckPageHelpContent {
|
||||
pageHelpContent : PageHelpContent;
|
||||
checked : boolean;
|
||||
}
|
||||
|
||||
export interface PageHelpContentFilterOptions {
|
||||
id : string;
|
||||
active : Boolean;
|
||||
text : RegExp;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* Created by stefania on 7/13/17.
|
||||
*/
|
||||
export interface Page {
|
||||
_id: string;
|
||||
route: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface CheckPage {
|
||||
page : Page;
|
||||
checked : boolean;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
/**
|
||||
* Created by stefania on 4/26/17.
|
||||
*/
|
||||
import { Topic } from "./topic";
|
||||
|
||||
export interface Question {
|
||||
_id: string;
|
||||
question: string;
|
||||
answer: string;
|
||||
date : Date;
|
||||
isActive: boolean;
|
||||
weight: number;
|
||||
hitCount: number;
|
||||
topics: Topic[] | string[];
|
||||
}
|
||||
|
||||
export interface CheckQuestion {
|
||||
question : Question;
|
||||
checked : boolean;
|
||||
}
|
||||
|
||||
export interface QuestionFilterOptions {
|
||||
id : string;
|
||||
active : Boolean;
|
||||
text : RegExp;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Created by stefania on 4/26/17.
|
||||
*/
|
||||
export interface Topic {
|
||||
_id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
date : Date;
|
||||
weight: number;
|
||||
questionOrder: string;
|
||||
}
|
||||
|
||||
export interface CheckTopic {
|
||||
topic : Topic;
|
||||
checked : boolean;
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* Created by stefania on 7/17/17.
|
||||
*/
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Http, Response } from '@angular/http';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
import { PageHelpContent } from '../../models/help-content/page-help-content';
|
||||
@Injectable()
|
||||
export class HelpContentService {
|
||||
private _helpServiceUrl = "http://localhost:5000";
|
||||
constructor (private http: Http) {
|
||||
}
|
||||
cache : any = {};
|
||||
getActivePageContent(route: string) {
|
||||
if (!this.cache[route]) {
|
||||
this.cache[route] = this.http.get(this._helpServiceUrl + "/page/route?q=" + route)
|
||||
.map(res => <PageHelpContent> res.json())
|
||||
.catch(this.handleError)
|
||||
.share();
|
||||
}
|
||||
return this.cache[route];
|
||||
}
|
||||
private extractData(res: Response) {
|
||||
let body = res.json();
|
||||
return body.data || { };
|
||||
}
|
||||
private handleError (error: Response | any) {
|
||||
// In a real world app, we might use a remote logging infrastructure
|
||||
// We'd also dig deeper into the error to get a better message
|
||||
let errMsg = "";
|
||||
console.log(error);
|
||||
if (error instanceof Response) {
|
||||
const body = error.text() || '';
|
||||
//const err = body.error || JSON.stringify(body);
|
||||
errMsg = `${error.status} - ${error.statusText || ''} ${body}`;
|
||||
} else {
|
||||
errMsg = (error.message) ? error.message :
|
||||
error.status ? `${error.status} - ${error.statusText}` : 'Server error';
|
||||
console.error(errMsg); // log to console instead
|
||||
}
|
||||
return Observable.throw(errMsg);
|
||||
}
|
||||
}
|
|
@ -4,8 +4,9 @@
|
|||
{{item.label}}
|
||||
<mat-icon matChipRemove>cancel</mat-icon>
|
||||
</mat-chip>
|
||||
<input matInput [matAutocomplete]="auto" [matChipInputFor]="chipList" [formControl]="control" placeholder="{{placeholder}}" [required]="required">
|
||||
</mat-chip-list>
|
||||
</mat-chip-list>
|
||||
<input matInput [matAutocomplete]="auto" [matChipInputFor]="chipList" [formControl]="term" placeholder="{{placeholder}}" [required]="required">
|
||||
|
||||
<mat-error *ngIf="control.errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||
<mat-error *ngIf="validationErrorString">{{errorString}}</mat-error>
|
||||
<mat-progress-spinner matSuffix mode="indeterminate" *ngIf="loading" [diameter]="22"></mat-progress-spinner>
|
||||
|
|
|
@ -37,6 +37,8 @@ export class AutocompleteChipComponent implements OnInit {
|
|||
@Input()
|
||||
disabled: boolean = false;
|
||||
|
||||
@Input()
|
||||
multiChips: boolean = false;
|
||||
// @Input() selectedDropdownItem: AutoCompleteItem;
|
||||
// @Output() selectedDropdownItemChange = new EventEmitter<AutoCompleteItem>();
|
||||
|
||||
|
@ -45,8 +47,9 @@ export class AutocompleteChipComponent implements OnInit {
|
|||
|
||||
@Input() control: FormControl;
|
||||
|
||||
|
||||
// @Input() createNew = false;
|
||||
// //term = new FormControl();
|
||||
term = new FormControl();
|
||||
// @Input()
|
||||
// ClickFunctionCall: Function;
|
||||
|
||||
|
@ -61,11 +64,9 @@ export class AutocompleteChipComponent implements OnInit {
|
|||
|
||||
ngOnInit() {
|
||||
|
||||
const valueChanges = this.control.valueChanges.share();
|
||||
const valueChanges = this.term.valueChanges.share();
|
||||
valueChanges.subscribe(searchTerm => {
|
||||
if (this.hasSelectedItem) { //proswrina epeidh ta projects den eixan ids...gia test!!!
|
||||
this.resetFormControlValue();
|
||||
} else {
|
||||
if (!this.hasSelectedItem) { //proswrina epeidh ta projects den eixan ids...gia test!!!
|
||||
this.loading = true;
|
||||
}
|
||||
});
|
||||
|
@ -75,8 +76,9 @@ export class AutocompleteChipComponent implements OnInit {
|
|||
.switchMap(val => {
|
||||
if (this.hasSelectedItem) {
|
||||
this.loading = false;
|
||||
this.resetFormControlValue();
|
||||
return [];
|
||||
} else if (typeof(val)== "string") {
|
||||
} else {
|
||||
this.configuration.requestItem.criteria.like = val;
|
||||
return this.configuration.callback(this.configuration.requestItem).map(result => {
|
||||
this.filteredItems = (<any[]>result)
|
||||
|
@ -89,7 +91,7 @@ export class AutocompleteChipComponent implements OnInit {
|
|||
|
||||
resetFormControlValue() {
|
||||
this.hasSelectedItem = false;
|
||||
//this.control.setValue(null, { emitEvent: false });
|
||||
this.term.setValue(null);
|
||||
}
|
||||
|
||||
// // listingItemToDropDown(item: DropdownListingItem): AutoCompleteItem {
|
||||
|
@ -99,7 +101,10 @@ export class AutocompleteChipComponent implements OnInit {
|
|||
optionSelected(event: any) {
|
||||
this.hasSelectedItem = true;
|
||||
this.selectedItems.push(event.option.value)
|
||||
this.control.setValue(this.selectedItems, { emitEvent: false });
|
||||
let value = this.control.value;
|
||||
if (this.multiChips) value.push(event.option.value)
|
||||
else value = event.option.value
|
||||
this.control.setValue(value, { emitEvent: false });
|
||||
this.filteredItems = this.selectedItems;
|
||||
|
||||
//this.selectedDropdownItemChange.emit(event.option.value);
|
||||
|
@ -107,17 +112,17 @@ export class AutocompleteChipComponent implements OnInit {
|
|||
//this.options = [event.option.value];
|
||||
//this.loading = false;
|
||||
}
|
||||
remove(item:any){
|
||||
remove(item: any) {
|
||||
// this.selectedItems.filter(function(selitem){
|
||||
// return selitem.id != item.id;
|
||||
// });
|
||||
const index: number = this.selectedItems.indexOf(item);
|
||||
if (index !== -1) {
|
||||
this.selectedItems.splice(index, 1);
|
||||
}
|
||||
}
|
||||
this.control.setValue(this.selectedItems);
|
||||
|
||||
if(this.selectedItems.length == 0) this.hasSelectedItem = false;
|
||||
if (this.selectedItems.length == 0) this.hasSelectedItem = false;
|
||||
}
|
||||
// inputOnChange(term: string) {
|
||||
// //this.form.patchValue({ value: null, description: '', text: '' });
|
||||
|
|
Loading…
Reference in New Issue