no message

This commit is contained in:
annabakouli 2018-01-05 09:47:52 +02:00
parent 3a60d78c81
commit 2d2d718a3a
32 changed files with 549 additions and 131 deletions

View File

@ -72,7 +72,7 @@ public class DatasetWizardController extends BaseController{
return new ResponseItem<DatasetWizardModel>().status(HttpStatus.OK).payload(dataset);
} catch (Exception ex) {
ex.printStackTrace();
return new ResponseItem<DatasetWizardModel>().status(HttpStatus.OK).message(ex.getMessage());
return new ResponseItem<DatasetWizardModel>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
}
}

View File

@ -139,9 +139,5 @@ public class Services extends BaseController{
}
}
}

View File

@ -0,0 +1,46 @@
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.userinfo.UserInfoInvitationModel;
import eu.eudat.models.userinfo.UserInfoRequestItem;
import eu.eudat.services.ApiContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* Created by ikalyvas on 1/4/2018.
*/
@RequestMapping("invite/")
@RestController
@CrossOrigin
public class UserInvitationController extends BaseController{
@Autowired
public UserInvitationController(ApiContext apiContext) {
super(apiContext);
}
@RequestMapping(method = RequestMethod.POST, value = { "/users" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseItem<Invitation> users(@RequestBody Invitation invitation) {
try {
InvitationsManager.inviteUsers(this.getApiContext(),invitation);
return new ResponseItem<Invitation>().message("Users have beeen invited");
} catch (Exception e) {
return new ResponseItem<Invitation>().message(e.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/getUsers" }, consumes = "application/json", produces="application/json")
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);
} catch (Exception e) {
return new ResponseItem<List<UserInfoInvitationModel>>().message(e.getMessage());
}
}
}

View File

@ -73,12 +73,9 @@ public class Users extends BaseController{
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
UserInfo userInfo = this.getApiContext().getDatabaseRepository().getUserInfoDao().getUserInfo(userID);
if(userInfo==null) //this should normally never happer
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
UserInfo userInfo = this.getApiContext().getDatabaseRepository().getUserInfoDao().find(UUID.fromString(userID));
if(userInfo==null) return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
try {

View File

@ -0,0 +1,23 @@
package eu.eudat.dao.entities;
import eu.eudat.entities.Dataset;
import eu.eudat.entities.Invitation;
import eu.eudat.models.criteria.DatasetCriteria;
import eu.eudat.models.criteria.InvitationCriteria;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
/**
* Created by ikalyvas on 1/4/2018.
*/
public interface InvitationDao {
QueryableList<Invitation> getWithCriteria(InvitationCriteria criteria);
Invitation createOrUpdate(Invitation item);
Invitation find(UUID id);
Long count();
}

View File

@ -0,0 +1,41 @@
package eu.eudat.dao.entities;
import eu.eudat.dao.databaselayer.service.DatabaseService;
import eu.eudat.entities.DMP;
import eu.eudat.entities.Invitation;
import eu.eudat.models.criteria.InvitationCriteria;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.UUID;
/**
* Created by ikalyvas on 1/4/2018.
*/
@Service("invitationDao")
public class InvitationDaoImpl implements InvitationDao{
@Autowired
DatabaseService<Invitation> databaseService;
@Override
public QueryableList<Invitation> getWithCriteria(InvitationCriteria criteria) {
return null;
}
@Override
public Invitation createOrUpdate(Invitation item) {
return this.databaseService.createOrUpdate(item,Invitation.class);
}
@Override
public Invitation find(UUID id) {
return this.databaseService.getQueryable(Invitation.class).where((builder, root) -> builder.equal(root.get("id"),id)).toList().get(0);
}
@Override
public Long count() {
return null;
}
}

View File

@ -5,19 +5,21 @@ import java.util.UUID;
import eu.eudat.dao.Dao;
import eu.eudat.entities.DMP;
import eu.eudat.entities.Project;
import eu.eudat.entities.UserInfo;
import eu.eudat.models.criteria.ProjectCriteria;
import eu.eudat.models.criteria.UserInfoCriteria;
import eu.eudat.queryable.QueryableList;
import org.springframework.stereotype.Service;
public interface UserInfoDao extends Dao<UserInfo, UUID> {
public interface UserInfoDao {
public UserInfo getUserInfo(String userID);
QueryableList<UserInfo> getWithCriteria(UserInfoCriteria criteria);
public UserInfo getByIdAndMail(String id, String email);
UserInfo createOrUpdate(UserInfo item);
public UserInfo getByMail(String email);
UserInfo find(UUID id);
public UserInfo getByUsername(String username);
public List<DMP> getDmpsOfUser(String userID);
Long count();
}

View File

@ -7,98 +7,44 @@ import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import eu.eudat.dao.JpaDao;
import eu.eudat.dao.databaselayer.service.DatabaseService;
import eu.eudat.entities.DMP;
import eu.eudat.entities.Invitation;
import eu.eudat.entities.UserInfo;
import eu.eudat.models.criteria.ProjectCriteria;
import eu.eudat.models.criteria.UserInfoCriteria;
import eu.eudat.queryable.QueryableList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component("userInfoDao")
public class UserInfoDaoImpl extends JpaDao<UserInfo, UUID> implements UserInfoDao {
public UserInfo loadDetails(UserInfo t) {
// TODO Auto-generated method stub
return null;
}
public class UserInfoDaoImpl implements UserInfoDao {
@Autowired
private DatabaseService<UserInfo> databaseService;
@Override
public UserInfo getUserInfo(String userID) {
String queryString = "FROM UserInfo userInfo where userInfo.id = :userInfoID";
TypedQuery<UserInfo> typedQuery = entityManager.createQuery(queryString, UserInfo.class);
typedQuery.setParameter("userInfoID", UUID.fromString(userID));
try {
return typedQuery.getSingleResult();
}
catch(NoResultException ex) {
return null;
}
}
@Override
public UserInfo getByIdAndMail(String id, String email) {
String queryString = "FROM UserInfo userInfo where userInfo.id = :userInfoID and userInfo.email = :userInfoEmail";
TypedQuery<UserInfo> typedQuery = entityManager.createQuery(queryString, UserInfo.class);
typedQuery.setParameter("userInfoID", UUID.fromString(id));
typedQuery.setParameter("userInfoEmail", email);
try {
return typedQuery.getSingleResult();
}
catch(NoResultException ex) {
return null;
}
}
@Override
public UserInfo getByMail(String email) {
String queryString = "FROM UserInfo userInfo where userInfo.email = :email";
TypedQuery<UserInfo> typedQuery = entityManager.createQuery(queryString, UserInfo.class);
typedQuery.setParameter("email", email);
try {
return typedQuery.getSingleResult();
}
catch(Exception ex) { //no need to distinguish between eu.eudat.exceptions for the moment
return null;
}
}
@Override
public UserInfo getByUsername(String username) {
String queryString = "select ui from UserInfo ui join UserAuth ui.authentication ua where ua.username=:username";
TypedQuery<UserInfo> typedQuery = entityManager.createQuery(queryString, UserInfo.class);
typedQuery.setParameter("username", username);
try {
return typedQuery.getSingleResult();
}
catch(Exception ex) { //no need to distinguish between eu.eudat.exceptions for the moment
return null;
}
public QueryableList<UserInfo> getWithCriteria(UserInfoCriteria criteria) {
QueryableList<UserInfo> users = this.databaseService.getQueryable(UserInfo.class);
if (criteria.getLike() != null)
users.where((builder, root) -> builder.or(builder.like(root.get("name"), "%" + criteria.getLike() + "%"), builder.like(root.get("email"), "%" + criteria.getLike() + "%")));
if(criteria.getEmail()!=null)
users.where((builder, root) -> builder.equal(root.get("email"),criteria.getEmail()));
return users;
}
@Override
public List<DMP> getDmpsOfUser(String userID) {
String queryString = "select dmp from DMP dmp join dmp.users user where user.id=:userid and dmp.status >= 0";
TypedQuery<DMP> typedQuery = entityManager.createQuery(queryString, DMP.class);
typedQuery.setParameter("userid", UUID.fromString(userID));
try {
return typedQuery.getResultList();
public UserInfo createOrUpdate(UserInfo item) {
return this.databaseService.createOrUpdate(item,UserInfo.class);
}
catch(Exception ex) { //no need to distinguish between eu.eudat.exceptions for the moment
ex.printStackTrace();
@Override
public UserInfo find(UUID id) {
return this.databaseService.getQueryable(UserInfo.class).where((builder, root) -> builder.equal(root.get("id"),id)).toList().get(0);
}
@Override
public Long count() {
return null;
}
}
}

View File

@ -0,0 +1,95 @@
package eu.eudat.entities;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.Date;
import java.util.UUID;
/**
* Created by ikalyvas on 12/15/2017.
*/
@Entity
@Table(name="\"Invitation\"")
public class Invitation implements DataEntity<Invitation>{
@Id
@Column(name = "\"Id\"", updatable = false, nullable = false)
private UUID id;
@Column(name = "\"InvitationEmail\"", nullable = false)
private String invitationEmail;
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"CreationUser\"", nullable = false)
private UserInfo user;
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"Dmp\"", nullable = false)
private DMP dmp;
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID token;
@Type(type="eu.eudat.typedefinition.XMLType")
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
private String properties;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getInvitationEmail() {
return invitationEmail;
}
public void setInvitationEmail(String invitationEmail) {
this.invitationEmail = invitationEmail;
}
public UserInfo getUser() {
return user;
}
public void setUser(UserInfo user) {
this.user = user;
}
public DMP getDmp() {
return dmp;
}
public void setDmp(DMP dmp) {
this.dmp = dmp;
}
public UUID getToken() {
return token;
}
public void setToken(UUID token) {
this.token = token;
}
public String getProperties() {
return properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
@Override
public void update(Invitation entity) {
}
@Override
public Object[] getKeys() {
return new UUID[]{this.id == null ? null : this.id};
}
}

View File

@ -157,7 +157,10 @@ public class UserInfo implements Serializable,DataEntity<UserInfo>{
@Override
public void update(UserInfo entity) {
this.name = entity.getName();
this.email = entity.getEmail();
this.additionalinfo = entity.getAdditionalinfo();
this.lastloggedin = entity.getLastloggedin();
}
@Override

View File

@ -50,7 +50,7 @@ public class DataManagementPlanManager {
DMP newDmp = dataManagementPlan.toDataModel();
createOrganisationsIfTheyDontExist(newDmp,apiContext.getDatabaseRepository().getOrganisationDao());
createResearchersIfTheyDontExist(newDmp,apiContext.getDatabaseRepository().getResearcherDao());
UserInfo user = apiContext.getDatabaseRepository().getUserInfoDao().read(principal.getId());
UserInfo user = apiContext.getDatabaseRepository().getUserInfoDao().find(principal.getId());
createProjectIfItDoesntExist(newDmp,apiContext.getDatabaseRepository().getProjectDao(),user);
newDmp.setCreator(user);
apiContext.getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);

View File

@ -0,0 +1,34 @@
package eu.eudat.managers;
import eu.eudat.entities.DMP;
import eu.eudat.entities.UserInfo;
import eu.eudat.models.invitation.Invitation;
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.stream.Collectors;
/**
* Created by ikalyvas on 1/4/2018.
*/
public class InvitationsManager {
public static void inviteUsers(ApiContext apiContext, Invitation invitation) {
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().assignToDmp(apiContext.getDatabaseRepository().getDmpDao(), alreadySignedInUsersEntities, dataManagementPlan);
apiContext.getInvitationService().sendInvitations(invitation.getUsers());
}
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);
return userModels;
}
}

View File

@ -72,7 +72,7 @@ public class ProjectManager {
public static void createOrUpdate(ProjectDao projectRepository, UserInfoDao userInfoRepository, eu.eudat.models.project.Project project, Principal principal){
eu.eudat.entities.Project projectEntity = project.toDataModel();
projectEntity.setCreationUser(userInfoRepository.read(principal.getId()));
projectEntity.setCreationUser(userInfoRepository.find(principal.getId()));
projectRepository.createOrUpdate(projectEntity);
}
}

View File

@ -18,12 +18,14 @@ import java.util.stream.Collectors;
public class Field implements ViewStyleDefinition<eu.eudat.entities.xmlmodels.datasetprofiledefinition.Field>,Comparable{
public enum ValidationType {
REQUIRED((short) 1);
NONE((short)0),REQUIRED((short) 1);
private short value;
private ValidationType(short value) { this.value = value; }
public short getValue(){return value;}
public static ValidationType fromInteger(int value) {
switch (value) {
case 0:
return NONE;
case 1:
return REQUIRED;
default:

View File

@ -9,8 +9,9 @@ public class BooleanDecisionData extends FieldData<BooleanDecisionData>{
@Override
public BooleanDecisionData fromData(Object data) {
if(data!=null){
this.setLabel((String)((Map<String,Object>)data).get("label"));
}
return this;
}

View File

@ -0,0 +1,9 @@
package eu.eudat.models.criteria;
import eu.eudat.entities.Invitation;
/**
* Created by ikalyvas on 1/4/2018.
*/
public class InvitationCriteria extends Criteria<Invitation>{
}

View File

@ -0,0 +1,18 @@
package eu.eudat.models.criteria;
import eu.eudat.entities.UserInfo;
/**
* Created by ikalyvas on 1/4/2018.
*/
public class UserInfoCriteria extends Criteria<UserInfo> {
private String email;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}

View File

@ -2,7 +2,6 @@ package eu.eudat.models.dmp;
import eu.eudat.entities.*;
import eu.eudat.models.DataModel;
import eu.eudat.models.project.*;
import eu.eudat.models.project.Project;
import eu.eudat.utilities.builders.DomainModelConverter;
import eu.eudat.utilities.builders.XmlBuilder;
@ -12,7 +11,6 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import java.util.*;
import java.util.stream.Collector;
import java.util.stream.Collectors;
public class DataManagementPlan implements DataModel<DMP>{
@ -26,7 +24,7 @@ public class DataManagementPlan implements DataModel<DMP>{
private eu.eudat.models.project.Project project;
private List<Organisation> organisations;
private List<Researcher> researchers;
private UserInfo creator;
private eu.eudat.models.userinfo.UserInfo creator;
private Date created;
public UUID getId() {
return id;
@ -92,11 +90,11 @@ public class DataManagementPlan implements DataModel<DMP>{
this.project = project;
}
public UserInfo getCreator() {
public eu.eudat.models.userinfo.UserInfo getCreator() {
return creator;
}
public void setCreator(UserInfo creator) {
public void setCreator(eu.eudat.models.userinfo.UserInfo creator) {
this.creator = creator;
}
@ -134,7 +132,7 @@ public class DataManagementPlan implements DataModel<DMP>{
this.label = entity.getLabel();
this.project = new Project();
this.project.fromDataModel(entity.getProject());
this.creator = new eu.eudat.models.dmp.UserInfo();
this.creator = new eu.eudat.models.userinfo.UserInfo();
if(entity.getCreator()!=null)this.creator.fromDataModel(entity.getCreator());
if(entity.getAssociatedDmps()!=null&&!entity.getAssociatedDmps().isEmpty()){

View File

@ -0,0 +1,31 @@
package eu.eudat.models.invitation;
import eu.eudat.models.userinfo.UserInfo;
import eu.eudat.models.userinfo.UserInfoInvitationModel;
import java.util.List;
import java.util.UUID;
/**
* Created by ikalyvas on 1/4/2018.
*/
public class Invitation {
private UUID dataManagementPlan;
private List<UserInfoInvitationModel> users;
public UUID getDataManagementPlan() {
return dataManagementPlan;
}
public void setDataManagementPlan(UUID dataManagementPlan) {
this.dataManagementPlan = dataManagementPlan;
}
public List<UserInfoInvitationModel> getUsers() {
return users;
}
public void setUsers(List<UserInfoInvitationModel> users) {
this.users = users;
}
}

View File

@ -1,4 +1,4 @@
package eu.eudat.models.dmp;
package eu.eudat.models.userinfo;
import java.util.Date;
import java.util.UUID;

View File

@ -0,0 +1,56 @@
package eu.eudat.models.userinfo;
import eu.eudat.entities.*;
import eu.eudat.entities.UserInfo;
import eu.eudat.models.DataModel;
import java.util.UUID;
/**
* Created by ikalyvas on 1/4/2018.
*/
public class UserInfoInvitationModel implements DataModel<eu.eudat.entities.UserInfo>{
private UUID id;
private String email;
private String name;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public void fromDataModel(eu.eudat.entities.UserInfo entity) throws InstantiationException, IllegalAccessException {
this.id = entity.getId();
this.email = entity.getEmail();
this.name = entity.getName();
}
@Override
public eu.eudat.entities.UserInfo toDataModel() {
eu.eudat.entities.UserInfo userInfo = new UserInfo();
userInfo.setId(this.id);
userInfo.setEmail(this.email);
userInfo.setName(this.name);
return userInfo;
}
}

View File

@ -0,0 +1,10 @@
package eu.eudat.models.userinfo;
import eu.eudat.models.criteria.UserInfoCriteria;
import eu.eudat.models.helpers.requests.RequestItem;
/**
* Created by ikalyvas on 1/4/2018.
*/
public class UserInfoRequestItem extends RequestItem<UserInfoCriteria>{
}

View File

@ -13,6 +13,7 @@ import eu.eudat.dao.entities.security.CredentialDao;
import eu.eudat.dao.entities.security.UserTokenDao;
import eu.eudat.entities.Credential;
import eu.eudat.entities.UserToken;
import eu.eudat.models.criteria.UserInfoCriteria;
import eu.eudat.models.login.LoginInfo;
import eu.eudat.services.AuthenticationService;
import org.springframework.beans.factory.annotation.Autowired;
@ -62,7 +63,9 @@ public class GoogleTokenValidator implements TokenValidator {
GoogleIdToken idToken = this.verifyUserAndGetUser(token);
Payload payload = idToken.getPayload();
UserInfo userInfo = userInfoDao.getByMail(payload.getEmail());
UserInfoCriteria criteria = new UserInfoCriteria();
criteria.setEmail(payload.getEmail());
UserInfo userInfo = userInfoDao.getWithCriteria(criteria).toList().get(0);
final Credential credential = new Credential();
credential.setCreationTime(new Date());
@ -81,7 +84,7 @@ public class GoogleTokenValidator implements TokenValidator {
userInfo.setLastloggedin(new Date());
userInfo.setAuthorization_level(new Short("1"));
userInfo.setUsertype(new Short("1"));
userInfo = userInfoDao.create(userInfo);
userInfo = userInfoDao.createOrUpdate(userInfo);
credential.setUserInfo(userInfo);
credentialDao.createOrUpdate(credential);
}
@ -98,7 +101,7 @@ public class GoogleTokenValidator implements TokenValidator {
credentialDao.createOrUpdate(credential);
userInfo.getCredentials().add(credential);
}
userInfo = userInfoDao.update(userInfo);
userInfo = userInfoDao.createOrUpdate(userInfo);
}

View File

@ -9,5 +9,6 @@ import org.springframework.context.ApplicationContext;
public interface ApiContext {
DatabaseRepository getDatabaseRepository();
ApplicationContext getApplicationContext();
InvitationService getInvitationService();
RemoteFetcher getRemoteFetcher();
}

View File

@ -14,6 +14,7 @@ public class ApiContextImpl implements ApiContext{
private DatabaseRepository databaseRepository;
private ApplicationContext applicationContext;
private RemoteFetcher remoteFetcher;
private InvitationService invitationService;
@Autowired
public void setDatabaseRepository(DatabaseRepository databaseRepository) {
@ -44,4 +45,14 @@ public class ApiContextImpl implements ApiContext{
public void setRemoteFetcher(RemoteFetcher remoteFetcher) {
this.remoteFetcher = remoteFetcher;
}
@Override
public InvitationService getInvitationService() {
return invitationService;
}
@Autowired
public void setInvitationService(InvitationService invitationService) {
this.invitationService = invitationService;
}
}

View File

@ -43,7 +43,7 @@ public class AuthenticationService {
{
if (token == null || token.getExpiresAt().before(new Date())) return null;
UserInfo user = this.userInfoDao.read(token.getUser().getId());
UserInfo user = this.userInfoDao.find(token.getUser().getId());
if (user == null /*|| user.Status != ActivityStatus.Active*/) return null;
//List<UserRole> appRoles = this._unitOfWork.UserRoles.GetAll().Where(x => x.UserId == token.UserId /*&& x.Status == ActivityStatus.Active*/).ToList();

View File

@ -20,4 +20,7 @@ public interface DatabaseRepository {
ResearcherDao getResearcherDao();
ServiceDao getServiceDao();
UserInfoDao getUserInfoDao();
InvitationDao getInvitationDao();
DMPProfileDao getDmpProfileDao();
DMPResearcherDao getDmpResearcherDao();
}

View File

@ -24,6 +24,7 @@ public class DatabaseRepositoryImpl implements DatabaseRepository{
private ResearcherDao researcherDao;
private ServiceDao serviceDao;
private UserInfoDao userInfoDao;
private InvitationDao invitationDao;
@Autowired
private void setDataRepositoryDao(DataRepositoryDao dataRepositoryDao) {
@ -55,21 +56,11 @@ public class DatabaseRepositoryImpl implements DatabaseRepository{
this.dmpDao = dmpDao;
}
@Autowired
private DMPProfileDao getDmpProfileDao() {
return dmpProfileDao;
}
@Autowired
public void setDmpProfileDao(DMPProfileDao dmpProfileDao) {
this.dmpProfileDao = dmpProfileDao;
}
@Autowired
private DMPResearcherDao getDmpResearcherDao() {
return dmpResearcherDao;
}
@Autowired
private void setDmpResearcherDao(DMPResearcherDao dmpResearcherDao) {
this.dmpResearcherDao = dmpResearcherDao;
@ -174,4 +165,24 @@ public class DatabaseRepositoryImpl implements DatabaseRepository{
public UserInfoDao getUserInfoDao() {
return userInfoDao;
}
@Override
public DMPProfileDao getDmpProfileDao() {
return dmpProfileDao;
}
@Override
public DMPResearcherDao getDmpResearcherDao() {
return dmpResearcherDao;
}
@Override
public InvitationDao getInvitationDao() {
return invitationDao;
}
@Autowired
public void setInvitationDao(InvitationDao invitationDao) {
this.invitationDao = invitationDao;
}
}

View File

@ -0,0 +1,24 @@
package eu.eudat.services;
import eu.eudat.dao.entities.DMPDao;
import eu.eudat.dao.entities.InvitationDao;
import eu.eudat.entities.DMP;
import eu.eudat.entities.Invitation;
import eu.eudat.models.userinfo.UserInfo;
import eu.eudat.models.userinfo.UserInfoInvitationModel;
import java.util.List;
/**
* Created by ikalyvas on 1/4/2018.
*/
public interface InvitationService {
void assignToDmp(DMPDao dmpDao, List<eu.eudat.entities.UserInfo> users, DMP dmp);
void assignToDmp(DMPDao dmpDao, eu.eudat.entities.UserInfo user, DMP dmp);
void createInvitations(InvitationDao invitationDao, List<eu.eudat.entities.UserInfo> users, DMP dmp);
void sendInvitations(List<UserInfoInvitationModel> users);
}

View File

@ -0,0 +1,49 @@
package eu.eudat.services;
import eu.eudat.dao.entities.DMPDao;
import eu.eudat.dao.entities.InvitationDao;
import eu.eudat.entities.DMP;
import eu.eudat.entities.Invitation;
import eu.eudat.models.userinfo.UserInfo;
import eu.eudat.models.userinfo.UserInfoInvitationModel;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.UUID;
/**
* Created by ikalyvas on 1/4/2018.
*/
@Service("invitationService")
public class InvitationServiceImpl implements InvitationService {
@Override
public void assignToDmp(DMPDao dmpDao, List<eu.eudat.entities.UserInfo> users, DMP dmp) {
for(eu.eudat.entities.UserInfo user : users){
dmp.getUsers().add(user);
}
dmpDao.createOrUpdate(dmp);
}
@Override
public void assignToDmp(DMPDao dmpDao, eu.eudat.entities.UserInfo user, DMP dmp) {
dmp.getUsers().add(user);
dmpDao.createOrUpdate(dmp);
}
@Override
public void createInvitations(InvitationDao invitationDao, List<eu.eudat.entities.UserInfo> users, DMP dmp) {
for(eu.eudat.entities.UserInfo userInfo : users){
Invitation invitation = new Invitation();
invitation.setDmp(dmp);
invitation.setInvitationEmail(userInfo.getEmail());
invitation.setUser(userInfo);
invitation.setToken(UUID.randomUUID());
invitationDao.createOrUpdate(invitation);
}
}
@Override
public void sendInvitations(List<UserInfoInvitationModel> users) {
}
}

View File

@ -0,0 +1,8 @@
import { Component } from "@angular/core";
@Component({
selector: 'app-invitation-component',
templateUrl: 'invitation.component.html',
})
export class InvitationComponent {
}