Merge remote-tracking branch 'origin/Development' into Development

This commit is contained in:
George Kalampokis 2020-05-13 10:57:36 +03:00
commit c003c6468e
2 changed files with 1261 additions and 26 deletions

View File

@ -4,6 +4,8 @@ import eu.eudat.data.dao.criteria.FunderCriteria;
import eu.eudat.data.dao.criteria.GrantCriteria;
import eu.eudat.data.dao.criteria.ProjectCriteria;
import eu.eudat.data.entities.*;
import eu.eudat.elastic.entities.Dmp;
import eu.eudat.logic.mapper.elastic.DmpMapper;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.models.data.dmp.DataManagementPlan;
@ -20,11 +22,13 @@ public class QuickWizardManager {
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
private DatasetManager datasetManager;
@Autowired
public QuickWizardManager(ApiContext apiContext) {
public QuickWizardManager(ApiContext apiContext, DatasetManager datasetManager) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.datasetManager = datasetManager;
}
public Funder createOrUpdate(eu.eudat.models.data.funder.Funder funder, Principal principal) {
@ -63,9 +67,18 @@ public class QuickWizardManager {
DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
if (dataManagementPlan.getAssociatedUsers().size() == 0)
assignUser(newDmp, user, apiContext);
this.updateIndex(dmpret);
return dmpret;
}
private void updateIndex(DMP dmp) throws IOException {
DmpMapper mapper = new DmpMapper(apiContext, datasetManager);
Dmp elastic = mapper.toElastic(dmp);
apiContext.getOperationsContext().getElasticRepository().getDmpRepository().createOrUpdate(elastic);
}
private void assignUser(DMP dmp, UserInfo userInfo, ApiContext apiContext) {
UserDMP userDMP = new UserDMP();
userDMP.setDmp(dmp);

File diff suppressed because it is too large Load Diff