Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into Development
This commit is contained in:
commit
693dfc5bb0
|
@ -1,202 +1,207 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>dmp-backend</groupId>
|
||||
<artifactId>dmp-backend</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>dmp-backend</groupId>
|
||||
<artifactId>dmp-backend</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.9.RELEASE</version>
|
||||
</parent>
|
||||
<properties>
|
||||
<project.http.version>1.19.0</project.http.version>
|
||||
<project.oauth.version>1.19.0</project.oauth.version>
|
||||
|
||||
<dmp-backend-commons.version>0.0.1-SNAPSHOT</dmp-backend-commons.version>
|
||||
<org.springframework.version>4.3.8.RELEASE</org.springframework.version>
|
||||
<!-- <org.springframework.eu.eudat.security.version>3.2.10.RELEASE</org.springframework.eu.eudat.security.version> -->
|
||||
<org.springframework.security.version>4.2.3.RELEASE</org.springframework.security.version>
|
||||
<com.sun.jersey.version>1.19.1</com.sun.jersey.version>
|
||||
<org.apache.tomcat.tomcat-jdbc.version>7.0.35</org.apache.tomcat.tomcat-jdbc.version>
|
||||
<com.fasterxml.jackson>2.8.4</com.fasterxml.jackson>
|
||||
|
||||
<hibernate.version>5.2.11.Final</hibernate.version>
|
||||
|
||||
<commons-codec.version>1.9</commons-codec.version>
|
||||
<org.junit.version>4.11</org.junit.version>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<slf4j.version>1.7.12</slf4j.version>
|
||||
<jetty.version>9.0.7.v20131107</jetty.version> <!-- Adapt this to a version found on http://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-maven-plugin/ -->
|
||||
<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> -->
|
||||
</properties>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.9.RELEASE</version>
|
||||
</parent>
|
||||
<properties>
|
||||
<project.http.version>1.19.0</project.http.version>
|
||||
<project.oauth.version>1.19.0</project.oauth.version>
|
||||
|
||||
<dmp-backend-commons.version>0.0.1-SNAPSHOT</dmp-backend-commons.version>
|
||||
<org.springframework.version>4.3.8.RELEASE</org.springframework.version>
|
||||
<!-- <org.springframework.eu.eudat.security.version>3.2.10.RELEASE</org.springframework.eu.eudat.security.version> -->
|
||||
<org.springframework.security.version>4.2.3.RELEASE</org.springframework.security.version>
|
||||
<com.sun.jersey.version>1.19.1</com.sun.jersey.version>
|
||||
<org.apache.tomcat.tomcat-jdbc.version>7.0.35</org.apache.tomcat.tomcat-jdbc.version>
|
||||
<com.fasterxml.jackson>2.8.4</com.fasterxml.jackson>
|
||||
|
||||
<hibernate.version>5.2.11.Final</hibernate.version>
|
||||
|
||||
<commons-codec.version>1.9</commons-codec.version>
|
||||
<org.junit.version>4.11</org.junit.version>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<slf4j.version>1.7.12</slf4j.version>
|
||||
<jetty.version>9.0.7.v20131107
|
||||
</jetty.version> <!-- Adapt this to a version found on http://repo.maven.apache.org/maven2/org/eclipse/jetty/jetty-maven-plugin/ -->
|
||||
<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> -->
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependencies>
|
||||
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>dmp-backend</groupId> -->
|
||||
<!-- <artifactId>dmp-backend-commons</artifactId> -->
|
||||
<!-- <version>${dmp-backend-commons.version}</version> -->
|
||||
<!-- </dependency> -->
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>dmp-backend</groupId> -->
|
||||
<!-- <artifactId>dmp-backend-commons</artifactId> -->
|
||||
<!-- <version>${dmp-backend-commons.version}</version> -->
|
||||
<!-- </dependency> -->
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20160810</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20160810</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-c3p0</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-core</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.google.api-client/google-api-client -->
|
||||
<dependency>
|
||||
<groupId>com.google.api-client</groupId>
|
||||
<artifactId>google-api-client</artifactId>
|
||||
<version>1.23.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path -->
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-c3p0</artifactId>
|
||||
<version>${hibernate.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.google.api-client/google-api-client -->
|
||||
<dependency>
|
||||
<groupId>com.google.api-client</groupId>
|
||||
<artifactId>google-api-client</artifactId>
|
||||
<version>1.23.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path -->
|
||||
<dependency>
|
||||
<groupId>com.jayway.jsonpath</groupId>
|
||||
<artifactId>json-path</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
<version>2.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-web</artifactId>
|
||||
<version>4.2.3.RELEASE</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
<version>2.9.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-web</artifactId>
|
||||
<version>4.2.3.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- g/a spring -->
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||
<!-- g/a spring -->
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-mail</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.9.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>4.3.10.RELEASE</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>4.3.10.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<!-- guava eu.eudat.cache -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>23.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>4.0.0.RELEASE</version>
|
||||
</dependency>
|
||||
<!-- guava eu.eudat.cache -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>23.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context-support</artifactId>
|
||||
<version>4.0.0.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/junit/junit -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/junit/junit -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>9.1-901.jdbc4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Various libs -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
<dependency>
|
||||
<groupId>postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>9.1-901.jdbc4</version>
|
||||
</dependency>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
|
||||
</build>
|
||||
<!-- Various libs -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
|
||||
</build>
|
||||
</project>
|
|
@ -3,10 +3,13 @@ package eu.eudat.controllers;
|
|||
import eu.eudat.managers.InvitationsManager;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.invitation.Invitation;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.models.userinfo.UserInfoInvitationModel;
|
||||
import eu.eudat.models.userinfo.UserInfoRequestItem;
|
||||
import eu.eudat.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -24,12 +27,14 @@ public class UserInvitationController extends BaseController{
|
|||
super(apiContext);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/users" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<Invitation> users(@RequestBody Invitation invitation) {
|
||||
public @ResponseBody ResponseItem<Invitation> users(@RequestBody Invitation invitation, Principal principal) {
|
||||
try {
|
||||
InvitationsManager.inviteUsers(this.getApiContext(),invitation);
|
||||
return new ResponseItem<Invitation>().message("Users have beeen invited");
|
||||
InvitationsManager.inviteUsers(this.getApiContext(),invitation,principal);
|
||||
return new ResponseItem<Invitation>().status(HttpStatus.OK).message("Users have beeen invited");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseItem<Invitation>().message(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -38,9 +43,10 @@ public class UserInvitationController extends BaseController{
|
|||
public @ResponseBody ResponseItem<List<UserInfoInvitationModel>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) {
|
||||
try {
|
||||
List<UserInfoInvitationModel> users = InvitationsManager.getUsers(this.getApiContext(),userInfoRequestItem);
|
||||
return new ResponseItem<List<UserInfoInvitationModel>>().payload(users);
|
||||
return new ResponseItem<List<UserInfoInvitationModel>>().status(HttpStatus.OK).payload(users);
|
||||
} catch (Exception e) {
|
||||
return new ResponseItem<List<UserInfoInvitationModel>>().message(e.getMessage());
|
||||
e.printStackTrace();
|
||||
return new ResponseItem<List<UserInfoInvitationModel>>().status(HttpStatus.BAD_REQUEST).message(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package eu.eudat.entities;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
@ -14,6 +15,8 @@ import java.util.UUID;
|
|||
public class Invitation implements DataEntity<Invitation>{
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
||||
@Column(name = "\"Id\"", updatable = false, nullable = false)
|
||||
private UUID id;
|
||||
|
||||
|
@ -31,6 +34,9 @@ public class Invitation implements DataEntity<Invitation>{
|
|||
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
private UUID token;
|
||||
|
||||
@Column(name = "\"AcceptedInvitation\"", nullable = false)
|
||||
private boolean acceptedInvitation;
|
||||
|
||||
@Type(type="eu.eudat.typedefinition.XMLType")
|
||||
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
|
||||
private String properties;
|
||||
|
@ -83,6 +89,14 @@ public class Invitation implements DataEntity<Invitation>{
|
|||
this.properties = properties;
|
||||
}
|
||||
|
||||
public boolean getAcceptedInvitation() {
|
||||
return acceptedInvitation;
|
||||
}
|
||||
|
||||
public void setAcceptedInvitation(boolean acceptedInvitation) {
|
||||
this.acceptedInvitation = acceptedInvitation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Invitation entity) {
|
||||
|
||||
|
|
|
@ -165,6 +165,6 @@ public class UserInfo implements Serializable,DataEntity<UserInfo>{
|
|||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new Object[0];
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class FieldSet implements DatabaseViewStyleDefinition,XmlSerializable<Fie
|
|||
private String description;
|
||||
private String extendedDescription;
|
||||
private Multiplicity multiplicity;
|
||||
private boolean hasCommentField;
|
||||
public List<Field> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
@ -76,12 +77,20 @@ public class FieldSet implements DatabaseViewStyleDefinition,XmlSerializable<Fie
|
|||
this.multiplicity = multiplicity;
|
||||
}
|
||||
|
||||
public boolean getHasCommentField() {
|
||||
return hasCommentField;
|
||||
}
|
||||
|
||||
public void setHasCommentField(boolean hasCommentField) {
|
||||
this.hasCommentField = hasCommentField;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Element toXml(Document doc) {
|
||||
Element fieldSet = doc.createElement("fieldSet");
|
||||
fieldSet.setAttribute("id", this.id);
|
||||
fieldSet.setAttribute("ordinal", ""+this.ordinal);
|
||||
|
||||
fieldSet.setAttribute("hasCommentField",""+this.hasCommentField);
|
||||
Element title = doc.createElement("title");
|
||||
title.setTextContent(this.title);
|
||||
|
||||
|
@ -114,6 +123,7 @@ public class FieldSet implements DatabaseViewStyleDefinition,XmlSerializable<Fie
|
|||
this.id = element.getAttribute("id");
|
||||
this.ordinal = Integer.parseInt(element.getAttribute("ordinal"));
|
||||
this.fields = new LinkedList();
|
||||
this.hasCommentField = Boolean.parseBoolean(element.getAttribute("hasCommentField"));
|
||||
Element title = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "title");
|
||||
this.title = title.getTextContent();
|
||||
Element description = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "description");
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.managers;
|
|||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.models.invitation.Invitation;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import eu.eudat.models.userinfo.UserInfoInvitationModel;
|
||||
import eu.eudat.models.userinfo.UserInfoRequestItem;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
@ -17,11 +18,13 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public class InvitationsManager {
|
||||
|
||||
public static void inviteUsers(ApiContext apiContext, Invitation invitation) {
|
||||
public static void inviteUsers(ApiContext apiContext, Invitation invitation, Principal principal) {
|
||||
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);
|
||||
DMP dataManagementPlan = apiContext.getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan());
|
||||
apiContext.getInvitationService().createInvitations(apiContext.getDatabaseRepository().getInvitationDao(),new DomainModelConverter<UserInfo, UserInfoInvitationModel>().toDataModel(invitation.getUsers()),dataManagementPlan);
|
||||
apiContext.getInvitationService().createInvitations(apiContext.getDatabaseRepository().getInvitationDao(),new DomainModelConverter<UserInfo, UserInfoInvitationModel>().toDataModel(invitation.getUsers()),dataManagementPlan,principalUser);
|
||||
apiContext.getInvitationService().assignToDmp(apiContext.getDatabaseRepository().getDmpDao(), alreadySignedInUsersEntities, dataManagementPlan);
|
||||
apiContext.getInvitationService().sendInvitations(invitation.getUsers());
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class FieldSet implements Comparable, ViewStyleDefinition<eu.eudat.entiti
|
|||
private String title;
|
||||
private String description;
|
||||
private String extendedDescription;
|
||||
|
||||
private boolean hasCommentField;
|
||||
private List<Field> fields;
|
||||
|
||||
public List<Field> getFields() {
|
||||
|
@ -79,6 +79,14 @@ public class FieldSet implements Comparable, ViewStyleDefinition<eu.eudat.entiti
|
|||
this.extendedDescription = extendedDescription;
|
||||
}
|
||||
|
||||
public boolean getHasCommentField() {
|
||||
return hasCommentField;
|
||||
}
|
||||
|
||||
public void setHasCommentField(boolean hasCommentField) {
|
||||
this.hasCommentField = hasCommentField;
|
||||
}
|
||||
|
||||
@Override
|
||||
public eu.eudat.entities.xmlmodels.datasetprofiledefinition.FieldSet toDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.FieldSet item) {
|
||||
if(this.id == null||this.id.isEmpty())this.id = "fieldSet_"+RandomStringUtils.random(5, true, true);
|
||||
|
@ -91,6 +99,7 @@ public class FieldSet implements Comparable, ViewStyleDefinition<eu.eudat.entiti
|
|||
item.setExtendedDescription(this.extendedDescription);
|
||||
item.setOrdinal(this.ordinal);
|
||||
item.setMultiplicity(this.multiplicity);
|
||||
item.setHasCommentField(this.hasCommentField);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -103,6 +112,7 @@ public class FieldSet implements Comparable, ViewStyleDefinition<eu.eudat.entiti
|
|||
this.extendedDescription = item.getExtendedDescription();
|
||||
this.title = item.getTitle();
|
||||
this.multiplicity = item.getMultiplicity();
|
||||
this.hasCommentField = item.getHasCommentField();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package eu.eudat.models.mail;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/5/2018.
|
||||
*/
|
||||
public class SimpleMail {
|
||||
private String from;
|
||||
private String to;
|
||||
private String subject;
|
||||
private String content;
|
||||
|
||||
public SimpleMail() {
|
||||
}
|
||||
|
||||
public SimpleMail(String from, String to, String subject, String content) {
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
this.subject = subject;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
public String getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public void setTo(String to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ public class FieldSet implements Comparable,PropertiesModelBuilder, ViewStyleDef
|
|||
private Multiplicity multiplicity;
|
||||
private List<Field> fields;
|
||||
private List<FieldSet> multiplicityItems;
|
||||
private boolean hasCommentField;
|
||||
public List<Field> getFields() {
|
||||
Collections.sort(this.fields);
|
||||
return fields;
|
||||
|
@ -92,6 +93,13 @@ public class FieldSet implements Comparable,PropertiesModelBuilder, ViewStyleDef
|
|||
this.ordinal = ordinal;
|
||||
}
|
||||
|
||||
public boolean getHasCommentField() {
|
||||
return hasCommentField;
|
||||
}
|
||||
|
||||
public void setHasCommentField(boolean hasCommentField) {
|
||||
this.hasCommentField = hasCommentField;
|
||||
}
|
||||
|
||||
@Override
|
||||
public eu.eudat.entities.xmlmodels.datasetprofiledefinition.FieldSet toDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.FieldSet item) {
|
||||
|
@ -99,6 +107,8 @@ public class FieldSet implements Comparable,PropertiesModelBuilder, ViewStyleDef
|
|||
item.setFields(viewStylefields);
|
||||
item.setId(this.id);
|
||||
item.setOrdinal(this.ordinal);
|
||||
item.setHasCommentField(this.hasCommentField);
|
||||
item.setMultiplicity(this.multiplicity);
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -110,6 +120,8 @@ public class FieldSet implements Comparable,PropertiesModelBuilder, ViewStyleDef
|
|||
this.title = item.getTitle();
|
||||
this.description = item.getDescription();
|
||||
this.extendedDescription = item.getExtendedDescription();
|
||||
this.hasCommentField = item.getHasCommentField();
|
||||
this.multiplicity = item.getMultiplicity();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,4 +11,5 @@ public interface ApiContext {
|
|||
ApplicationContext getApplicationContext();
|
||||
InvitationService getInvitationService();
|
||||
RemoteFetcher getRemoteFetcher();
|
||||
MailService getMailService();
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ public class ApiContextImpl implements ApiContext{
|
|||
private ApplicationContext applicationContext;
|
||||
private RemoteFetcher remoteFetcher;
|
||||
private InvitationService invitationService;
|
||||
private MailService mailService;
|
||||
|
||||
@Autowired
|
||||
public void setDatabaseRepository(DatabaseRepository databaseRepository) {
|
||||
|
@ -55,4 +56,14 @@ public class ApiContextImpl implements ApiContext{
|
|||
public void setInvitationService(InvitationService invitationService) {
|
||||
this.invitationService = invitationService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MailService getMailService() {
|
||||
return mailService;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setMailService(MailService mailService) {
|
||||
this.mailService = mailService;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ public interface InvitationService {
|
|||
|
||||
void assignToDmp(DMPDao dmpDao, eu.eudat.entities.UserInfo user, DMP dmp);
|
||||
|
||||
void createInvitations(InvitationDao invitationDao, List<eu.eudat.entities.UserInfo> users, DMP dmp);
|
||||
void createInvitations(InvitationDao invitationDao, List<eu.eudat.entities.UserInfo> users, DMP dmp, eu.eudat.entities.UserInfo creator);
|
||||
|
||||
void sendInvitations(List<UserInfoInvitationModel> users);
|
||||
}
|
||||
|
|
|
@ -31,13 +31,14 @@ public class InvitationServiceImpl implements InvitationService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void createInvitations(InvitationDao invitationDao, List<eu.eudat.entities.UserInfo> users, DMP dmp) {
|
||||
public void createInvitations(InvitationDao invitationDao, List<eu.eudat.entities.UserInfo> users, DMP dmp, eu.eudat.entities.UserInfo creator) {
|
||||
for(eu.eudat.entities.UserInfo userInfo : users){
|
||||
Invitation invitation = new Invitation();
|
||||
invitation.setDmp(dmp);
|
||||
invitation.setInvitationEmail(userInfo.getEmail());
|
||||
invitation.setUser(userInfo);
|
||||
invitation.setUser(creator);
|
||||
invitation.setToken(UUID.randomUUID());
|
||||
invitation.setAcceptedInvitation(userInfo.getId()!=null);
|
||||
invitationDao.createOrUpdate(invitation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package eu.eudat.services;
|
||||
|
||||
import eu.eudat.models.mail.SimpleMail;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/5/2018.
|
||||
*/
|
||||
public interface MailService {
|
||||
void sendSimpleMail(SimpleMail mail);
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package eu.eudat.services;
|
||||
|
||||
import eu.eudat.models.mail.SimpleMail;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/5/2018.
|
||||
*/
|
||||
@Service("mailService")
|
||||
public class MailServiceImpl implements MailService{
|
||||
|
||||
@Autowired
|
||||
private JavaMailSender emailSender;
|
||||
|
||||
@Override
|
||||
public void sendSimpleMail(SimpleMail mail) {
|
||||
SimpleMailMessage message = new SimpleMailMessage();
|
||||
message.setSubject(mail.getSubject());
|
||||
message.setText(mail.getContent());
|
||||
message.setTo(mail.getTo());
|
||||
message.setFrom(mail.getFrom());
|
||||
this.emailSender.send(message);
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
import { InvitationComponent } from './invitation/invitation.component';
|
||||
import { UnauthorizedComponent } from './unauthorized/unauthorized.component';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
@ -29,7 +30,7 @@ const appRoutes: Routes = [
|
|||
{ path: 'dataset/new', component: DatasetWizardComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'dataset/:id', component: DatasetWizardComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'datasets/new', component: DatasetWizardComponent, canActivate: [AuthGuard] },
|
||||
|
||||
{ path: 'invite/:id', component: InvitationComponent, canActivate: [AuthGuard] },
|
||||
{ path: 'login', component: LoginComponent },
|
||||
{ path: "unauthorized", loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule' },
|
||||
{ path: 'welcome', component: HomepageComponent, canActivate: [AuthGuard] },
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { InvitationComponent } from './invitation/invitation.component';
|
||||
import { UnauthorizedComponent } from './unauthorized/unauthorized.component';
|
||||
import { PaginationService } from './form/pagination/pagination-service';
|
||||
import { TableOfContentsFieldComponent } from './form/tableOfContents/table-of-content-field/table-of-content-field.component';
|
||||
|
@ -81,6 +82,7 @@ import { AutocompleteComponent } from './shared/components/autocomplete/autocomp
|
|||
DynamicFieldCheckBoxComponent,
|
||||
ProjectEditorComponent,
|
||||
DataManagementPlanEditorComponent,
|
||||
InvitationComponent,
|
||||
DatasetWizardComponent,
|
||||
FigurecardComponent,
|
||||
DatasetEditorComponent,
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
<mat-table [dataSource]="dataSource" matSort>
|
||||
|
||||
|
||||
<!-- Column Definition: Name -->
|
||||
<ng-container cdkColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell>
|
||||
|
@ -43,8 +44,21 @@
|
|||
<mat-cell *matCellDef="let row"> {{row.version}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<ng-container cdkColumnDef="actions">
|
||||
<mat-header-cell *matHeaderCellDef>{{'DMP-LISTING.COLUMNS.ACTIONS' | translate}}</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">
|
||||
<mat-menu #actionsMenu="matMenu">
|
||||
<button mat-menu-item (click)="rowClick(row.id)"><mat-icon>mode_edit</mat-icon>{{'DMP-LISTING.ACTIONS.EDIT' | translate}}</button>
|
||||
<button mat-menu-item (click)="openShareDialog(row.id)"><mat-icon>insert_invitation</mat-icon>{{'DMP-LISTING.ACTIONS.INVITE' | translate}}</button>
|
||||
</mat-menu>
|
||||
<button mat-icon-button [matMenuTriggerFor]="actionsMenu">
|
||||
<mat-icon>more_vert</mat-icon>
|
||||
</button>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
|
||||
|
||||
</mat-table>
|
||||
<mat-paginator #paginator [length]="dataSource?.totalCount" [pageSizeOptions]="[10, 25, 100]">
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
import { InvitationComponent } from '../invitation/invitation.component';
|
||||
import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core";
|
||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
||||
import { MatPaginator, MatSort, MatSnackBar, MatDialog } from "@angular/material";
|
||||
import { Router } from "@angular/router";
|
||||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { DataSource } from "@angular/cdk/table";
|
||||
import { Observable } from "rxjs/Observable";
|
||||
import { DataTableRequest } from "@app/models/data-table/DataTableRequest";
|
||||
import { SnackBarNotificationComponent } from "../shared/components/notificaiton/snack-bar-notification.component";
|
||||
import { DataManagementPlanService } from "../services/data-management-plan/data-management-plan.service";
|
||||
import { DataManagementPlanCriteriaComponent } from "../shared/components/criteria/data-management-plan/dmp-criteria.component";
|
||||
import { DataManagementPlanCriteria } from "../models/criteria/data-management-plan/DataManagementPlanCriteria";
|
||||
import { DataManagementPlanListingModel } from "../models/data-managemnt-plans/DataManagementPlanListingModel";
|
||||
import { DataTableRequest } from '../models/data-table/DataTableRequest';
|
||||
|
||||
|
||||
|
||||
|
@ -26,13 +27,14 @@ export class DataManagementPlanListingComponent implements OnInit {
|
|||
@ViewChild(DataManagementPlanCriteriaComponent) criteria: DataManagementPlanCriteriaComponent;
|
||||
|
||||
dataSource: DataManagementPlanDataSource | null;
|
||||
displayedColumns: String[] = ['name', 'project', 'profile', 'researchers', 'organisations', 'version'];
|
||||
displayedColumns: String[] = ['name', 'project', 'profile', 'researchers', 'organisations', 'version','actions'];
|
||||
|
||||
constructor(
|
||||
private dataManagementPlanService: DataManagementPlanService,
|
||||
private router: Router,
|
||||
private languageService: TranslateService,
|
||||
public snackBar: MatSnackBar,
|
||||
public dialog: MatDialog
|
||||
) {
|
||||
|
||||
}
|
||||
|
@ -55,6 +57,16 @@ export class DataManagementPlanListingComponent implements OnInit {
|
|||
const defaultCriteria = new DataManagementPlanCriteria();
|
||||
return defaultCriteria;
|
||||
}
|
||||
|
||||
openShareDialog(rowId: any) {
|
||||
let dialogRef = this.dialog.open(InvitationComponent, {
|
||||
height: '200px',
|
||||
width: '700px',
|
||||
data: {
|
||||
dmpId: rowId
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class DataManagementPlanDataSource extends DataSource<DataManagementPlanListingModel> {
|
||||
|
@ -71,23 +83,13 @@ export class DataManagementPlanDataSource extends DataSource<DataManagementPlanL
|
|||
private _criteria: DataManagementPlanCriteriaComponent
|
||||
) {
|
||||
super();
|
||||
|
||||
//this._paginator.page.subscribe((pageEvent: PageEvent) => {
|
||||
// this.store.dispatch(new LoadPhotosRequestAction(pageEvent.pageIndex, pageEvent.pageSize))
|
||||
//})
|
||||
}
|
||||
|
||||
connect(): Observable<DataManagementPlanListingModel[]> {
|
||||
const displayDataChanges = [
|
||||
this._paginator.page
|
||||
//this._sort.matSortChange
|
||||
];
|
||||
|
||||
// If the user changes the sort order, reset back to the first page.
|
||||
//this._sort.matSortChange.subscribe(() => {
|
||||
// this._paginator.pageIndex = 0;
|
||||
//})
|
||||
|
||||
return Observable.merge(...displayDataChanges)
|
||||
.startWith(null)
|
||||
.switchMap(() => {
|
||||
|
@ -105,7 +107,6 @@ export class DataManagementPlanDataSource extends DataSource<DataManagementPlanL
|
|||
duration: 3000,
|
||||
extraClasses: ['snackbar-warning']
|
||||
});
|
||||
//this._criteria.onCallbackError(error);
|
||||
return Observable.of(null);
|
||||
})
|
||||
.map(result => {
|
||||
|
@ -122,6 +123,5 @@ export class DataManagementPlanDataSource extends DataSource<DataManagementPlanL
|
|||
}
|
||||
|
||||
disconnect() {
|
||||
// No-op
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@
|
|||
|
||||
<div layout="row" class="full-width text-right" align="end">
|
||||
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-EDITOR.ACTIONS.CANCEL' | translate}}</button>
|
||||
<button mat-raised-button color="primary" (click)="invite()" type="button">{{'DMP-EDITOR.ACTIONS.INVITE' | translate}}</button>
|
||||
<button mat-raised-button color="primary" type="submit">{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}</button>
|
||||
<button *ngIf="!isNew" mat-raised-button color="primary" type="submit" (click)="delete()">{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}</button>
|
||||
</div>
|
||||
|
|
|
@ -123,6 +123,10 @@ export class DataManagementPlanEditorComponent implements AfterViewInit {
|
|||
this.router.navigate(['/dmps']);
|
||||
}
|
||||
|
||||
public invite(): void {
|
||||
this.router.navigate(['/invite/'+this.dataManagementPlan.id]);
|
||||
}
|
||||
|
||||
filterOrganisations(value: string): void {
|
||||
|
||||
this.filteredOrganisations = undefined;
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
<div>
|
||||
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
||||
<td-chips color="accent" [items]="filteredUsers" formControlName="users" placeholder="{{'INVITATION-EDITOR.TITLE' | translate}}"
|
||||
(inputChange)="filterUsers($event)" [requireMatch]="false">
|
||||
<ng-template td-chip let-chip="chip">
|
||||
<div class="tc-grey-100 bgc-teal-700" td-chip-avatar>{{chip.name.substring(0, 1).toUpperCase()}}</div>
|
||||
{{chip.name}}
|
||||
</ng-template>
|
||||
<ng-template td-autocomplete-option let-option="option">
|
||||
<div layout="row" layout-align="start center">
|
||||
{{option.name}}
|
||||
</div>
|
||||
</ng-template>
|
||||
<mat-progress-bar [style.height.px]="2" *ngIf="filteredUsersAsync" mode="indeterminate"></mat-progress-bar>
|
||||
</td-chips>
|
||||
<button mat-raised-button color="primary" (click)="send()" type="button">{{'INVITATION-EDITOR.ACTIONS.SEND-INVITATION' | translate}}</button>
|
||||
</form>
|
||||
</div>
|
|
@ -1,8 +1,62 @@
|
|||
import { Component } from "@angular/core";
|
||||
import { JsonSerializer } from '../utilities/JsonSerializer';
|
||||
import { UserInvitationCriteria } from '../models/criteria/invitation/UserInvitationCriteria';
|
||||
import { RequestItem } from '../models/criteria/RequestItem';
|
||||
import { Invitation } from '../models/invitation/Invitation';
|
||||
import { InvitationService } from '../services/invitation/invitation.service';
|
||||
import { User } from '../models/invitation/User';
|
||||
import { Component, OnInit, Inject } from "@angular/core";
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { Params, ActivatedRoute, Router } from '@angular/router';
|
||||
import { MAT_DIALOG_DATA } from '@angular/material';
|
||||
|
||||
@Component({
|
||||
selector: 'app-invitation-component',
|
||||
templateUrl: 'invitation.component.html',
|
||||
})
|
||||
export class InvitationComponent {
|
||||
}
|
||||
providers: [InvitationService]
|
||||
|
||||
})
|
||||
export class InvitationComponent implements OnInit {
|
||||
|
||||
private formGroup: FormGroup;
|
||||
|
||||
private filteredUsersAsync: boolean = false;
|
||||
|
||||
private filteredUsers: User[];
|
||||
|
||||
constructor(
|
||||
private invitationService: InvitationService,
|
||||
private route: ActivatedRoute,
|
||||
public router: Router,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
let invitation = new Invitation();
|
||||
invitation.dataManagementPlan = this.data.dmpId;
|
||||
this.formGroup = invitation.buildForm();
|
||||
}
|
||||
|
||||
|
||||
send(value: any) {
|
||||
this.invitationService.inviteUsers(this.formGroup.value).subscribe();
|
||||
}
|
||||
|
||||
filterUsers(value: string): void {
|
||||
this.filteredUsers = undefined;
|
||||
if (value) {
|
||||
this.filteredUsersAsync = true;
|
||||
let request = new RequestItem<UserInvitationCriteria>();
|
||||
request.criteria = { like: value }
|
||||
this.invitationService.getUsers(request).subscribe(items => {
|
||||
this.filteredUsers = JsonSerializer.fromJSONArray(items, User);
|
||||
if (!this.filteredUsers || this.filteredUsers.length == 0) {
|
||||
let user = new User();
|
||||
user.email = value;
|
||||
user.name = value;
|
||||
this.filteredUsers.push(user)
|
||||
}
|
||||
this.filteredUsersAsync = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
import { BaseCriteria } from '../BaseCriteria';
|
||||
export class UserInvitationCriteria extends BaseCriteria{
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
import { FormGenerator } from '../interfaces/FormGenerator';
|
||||
import { User } from './User';
|
||||
import { FormGroup, FormBuilder } from '@angular/forms';
|
||||
export class Invitation implements FormGenerator<FormGroup>{
|
||||
|
||||
public dataManagementPlan: string;
|
||||
public users = new Array<User>();
|
||||
|
||||
buildForm(): FormGroup {
|
||||
let formGroup = new FormBuilder().group({
|
||||
dataManagementPlan:[this.dataManagementPlan],
|
||||
users:[this.users]
|
||||
})
|
||||
|
||||
return formGroup;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
import { FormGenerator } from '../interfaces/FormGenerator';
|
||||
import { Serializable } from '../interfaces/Serializable';
|
||||
import { FormGroup, FormBuilder } from '@angular/forms';
|
||||
export class User implements Serializable<User>, FormGenerator<FormGroup>{
|
||||
|
||||
public id: string;
|
||||
public email:string;
|
||||
public name:string;
|
||||
|
||||
fromJSONObject(item: any): User {
|
||||
this.id = item.id;
|
||||
this.email = item.email;
|
||||
this.name = item.name;
|
||||
return this;
|
||||
}
|
||||
|
||||
buildForm(): FormGroup {
|
||||
return new FormBuilder().group({
|
||||
id:[this.id],
|
||||
email:[this.email],
|
||||
name:[this.name]
|
||||
})
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
import { Invitation } from '../../models/invitation/Invitation';
|
||||
import { UserInvitationCriteria } from '../../models/criteria/invitation/UserInvitationCriteria';
|
||||
import { User } from '../../models/invitation/User';
|
||||
import { HostConfiguration } from '../../app.constants';
|
||||
import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service';
|
||||
import { Injectable } from "@angular/core";
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { RequestItem } from '../../models/criteria/RequestItem';
|
||||
|
||||
@Injectable()
|
||||
export class InvitationService {
|
||||
|
||||
private actionUrl: string;
|
||||
private headers: HttpHeaders;
|
||||
|
||||
constructor(private http: BaseHttpService) {
|
||||
|
||||
this.actionUrl = HostConfiguration.Server + 'invite/';
|
||||
|
||||
this.headers = new HttpHeaders();
|
||||
this.headers = this.headers.set('Content-Type', 'application/json');
|
||||
this.headers = this.headers.set('Accept', 'application/json');
|
||||
}
|
||||
|
||||
public inviteUsers(invitation: Invitation): Observable<User[]> {
|
||||
return this.http.post<User[]>(this.actionUrl + "users", invitation, { headers: this.headers });
|
||||
}
|
||||
|
||||
public getUsers(usersInvitationRequestItem: RequestItem<UserInvitationCriteria>): Observable<User[]> {
|
||||
return this.http.post<User[]>(this.actionUrl + "getUsers", usersInvitationRequestItem, { headers: this.headers });
|
||||
}
|
||||
}
|
|
@ -25,7 +25,8 @@ import {
|
|||
MatCheckboxModule,
|
||||
MatTabsModule,
|
||||
MatStepperModule,
|
||||
MatRadioModule
|
||||
MatRadioModule,
|
||||
MatMenuModule
|
||||
} from '@angular/material';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { SnackBarNotificationComponent } from '../components/notificaiton/snack-bar-notification.component';
|
||||
|
@ -64,7 +65,8 @@ import { CovalentLayoutModule, CovalentChipsModule, CovalentDialogsModule } from
|
|||
CovalentChipsModule,
|
||||
CovalentDialogsModule,
|
||||
MatStepperModule,
|
||||
MatRadioModule
|
||||
MatRadioModule,
|
||||
MatMenuModule
|
||||
],
|
||||
|
||||
providers: [
|
||||
|
|
|
@ -41,7 +41,12 @@
|
|||
"PROFILE": "Profile",
|
||||
"RESEARCHERS": "Researchers",
|
||||
"ORGANISATIONS": "Organisations",
|
||||
"VERSION": "Version"
|
||||
"VERSION": "Version",
|
||||
"ACTIONS":"Actions"
|
||||
},
|
||||
"ACTIONS":{
|
||||
"EDIT":"Edit",
|
||||
"INVITE":"Invite"
|
||||
}
|
||||
},
|
||||
"DATASET-WIZARD": {
|
||||
|
@ -152,5 +157,12 @@
|
|||
"CANCEL": "Cancel",
|
||||
"DELETE": "Delete"
|
||||
}
|
||||
},
|
||||
"INVITATION-EDITOR": {
|
||||
"TITLE": "User/Email",
|
||||
"ACTIONS": {
|
||||
"SEND-INVITATION": "Send Invitations",
|
||||
"CANCEL": "Cancel"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue