Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into Development
This commit is contained in:
commit
3e5e550cee
|
@ -9,9 +9,11 @@ import javax.transaction.Transactional;
|
|||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.entities.UserInfo;
|
||||
import eu.eudat.models.criteria.DataManagementPlanCriteria;
|
||||
import eu.eudat.models.criteria.OrganisationCriteria;
|
||||
import eu.eudat.models.criteria.ResearcherCriteria;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.dmp.DataManagementPlanCriteriaRequest;
|
||||
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
||||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.models.helpers.responses.*;
|
||||
|
@ -98,7 +100,20 @@ public class DMPs {
|
|||
eu.eudat.entities.DMP createdProject = dMPDao.createOrUpdate(dataManagementPlan.toDataModel());
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/get" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<DataManagementPlan>> getWithCriteria(@RequestBody DataManagementPlanCriteriaRequest dataManagementPlanCriteria) {
|
||||
try {
|
||||
List<DataManagementPlan> dataTable = new DataManagementPlanManager().getWithCriteria(dMPDao, dataManagementPlanCriteria);
|
||||
|
||||
return new ResponseItem<List<DataManagementPlan>>().status(HttpStatus.OK).payload(dataTable);
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<List<DataManagementPlan>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public class DashBoardController {
|
|||
@Autowired private ProjectDao projectDao;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dashboard/getStatistics" }, produces="application/json")
|
||||
public ResponseItem<DashBoardStatistics> getStatistics(Principal principal){
|
||||
public ResponseItem<DashBoardStatistics> getStatistics(){
|
||||
try {
|
||||
DashBoardStatistics statistics = new DashBoardManager().getStatistics(datasetDao, dMPDao, projectDao);
|
||||
return new ResponseItem<DashBoardStatistics>().status(HttpStatus.OK).payload(statistics);
|
||||
|
|
|
@ -8,7 +8,9 @@ import java.util.UUID;
|
|||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import eu.eudat.models.criteria.ProjectCriteria;
|
||||
import eu.eudat.models.helpers.responses.*;
|
||||
import eu.eudat.models.project.ProjectCriteriaRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -106,8 +108,32 @@ public class Projects {
|
|||
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = { "/projects/inactivate/{id}" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<eu.eudat.entities.Project> inactivate(@PathVariable String id) {
|
||||
try {
|
||||
Project inactivate = new ProjectManager().inactivate(projectDao,id);
|
||||
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.OK);
|
||||
}catch (Exception ex){
|
||||
return new ResponseItem<eu.eudat.entities.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/get" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<eu.eudat.models.project.Project>> getPaged(@RequestBody ProjectCriteriaRequest projectCriteria) {
|
||||
try {
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteria(projectDao, projectCriteria);
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/projects" }, produces="application/json")
|
||||
|
|
|
@ -36,6 +36,7 @@ public class DMPDaoImpl implements DMPDao {
|
|||
if(criteria.getLike()!=null&&!criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"),"%"+criteria.getLike()+"%"));
|
||||
if(criteria.getPeriodEnd()!=null)query.where((builder, root) -> builder.lessThan(root.get("created"),criteria.getPeriodEnd()));
|
||||
if(criteria.getPeriodStart()!=null)query.where((builder, root) -> builder.greaterThan(root.get("created"),criteria.getPeriodStart()));
|
||||
if(criteria.getProjects()!=null&&!criteria.getProjects().isEmpty())query.where(((builder, root) -> root.get("project").in(criteria.getProjectEntities())));
|
||||
return query;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,9 @@ import java.util.UUID;
|
|||
|
||||
import eu.eudat.dao.entities.DMPDao;
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.models.criteria.DataManagementPlanCriteria;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.dmp.DataManagementPlanCriteriaRequest;
|
||||
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
||||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
@ -27,4 +30,10 @@ public class DataManagementPlanManager {
|
|||
datamanagementPlan.fromDataModel(dmpsRepository.find(UUID.fromString(id)));
|
||||
return datamanagementPlan;
|
||||
}
|
||||
|
||||
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);
|
||||
return datamanagementPlans;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,10 @@ import java.util.List;
|
|||
import java.util.UUID;
|
||||
|
||||
import eu.eudat.dao.entities.ProjectDao;
|
||||
import eu.eudat.models.criteria.ProjectCriteria;
|
||||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.models.project.Project;
|
||||
import eu.eudat.models.project.ProjectCriteriaRequest;
|
||||
import eu.eudat.models.project.ProjectTableRequest;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
@ -27,4 +29,17 @@ public class ProjectManager {
|
|||
project.fromDataModel(projectRepository.find(UUID.fromString(id)));
|
||||
return project;
|
||||
}
|
||||
|
||||
public eu.eudat.entities.Project inactivate(ProjectDao projectRepository,String id) throws InstantiationException, IllegalAccessException{
|
||||
eu.eudat.entities.Project project = projectRepository.find(UUID.fromString(id));
|
||||
project.setStatus(Project.Status.DELETED.getValue());
|
||||
project = projectRepository.createOrUpdate(project);
|
||||
return project;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.project.Project> getCriteria(ProjectDao projectRepository, ProjectCriteriaRequest projectCriteria) throws IllegalAccessException, InstantiationException{
|
||||
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);
|
||||
return projects;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
package eu.eudat.models.criteria;
|
||||
|
||||
import eu.eudat.entities.DMP;
|
||||
import eu.eudat.models.project.Project;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DataManagementPlanCriteria extends Criteria<DMP>{
|
||||
private Date periodStart;
|
||||
private Date periodEnd;
|
||||
|
||||
private List<Project> projects;
|
||||
public Date getPeriodStart() {
|
||||
return periodStart;
|
||||
}
|
||||
|
@ -23,4 +28,16 @@ public class DataManagementPlanCriteria extends Criteria<DMP>{
|
|||
public void setPeriodEnd(Date periodEnd) {
|
||||
this.periodEnd = periodEnd;
|
||||
}
|
||||
|
||||
public List<Project> getProjects() {
|
||||
return projects;
|
||||
}
|
||||
|
||||
public void setProjects(List<Project> projects) {
|
||||
this.projects = projects;
|
||||
}
|
||||
|
||||
public List<eu.eudat.entities.Project> getProjectEntities(){
|
||||
return new DomainModelConverter<eu.eudat.entities.Project,Project>().toDataModel(this.projects);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package eu.eudat.models.dmp;
|
||||
|
||||
import eu.eudat.models.criteria.DataManagementPlanCriteria;
|
||||
import eu.eudat.models.helpers.requests.RequestItem;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/19/2017.
|
||||
*/
|
||||
public class DataManagementPlanCriteriaRequest extends RequestItem<DataManagementPlanCriteria>{
|
||||
}
|
|
@ -13,7 +13,7 @@ import eu.eudat.models.dmp.DataManagementPlan;
|
|||
public class Project implements DataModel<eu.eudat.entities.Project>{
|
||||
|
||||
public enum Status {
|
||||
ACTIVE((short) 0), INACTIVE((short) 1);
|
||||
ACTIVE((short) 1), INACTIVE((short) 0),DELETED((short)99);
|
||||
|
||||
private short value;
|
||||
private Status(short value) { this.value = value; }
|
||||
|
@ -24,6 +24,8 @@ public class Project implements DataModel<eu.eudat.entities.Project>{
|
|||
return ACTIVE;
|
||||
case 1:
|
||||
return INACTIVE;
|
||||
case 99:
|
||||
return INACTIVE;
|
||||
default:
|
||||
throw new RuntimeException("Unsupported Project Status");
|
||||
}
|
||||
|
@ -201,7 +203,7 @@ public class Project implements DataModel<eu.eudat.entities.Project>{
|
|||
entity.setStartdate(this.startDate);
|
||||
entity.setCreated(this.created == null? new Date():this.created);
|
||||
entity.setEnddate(this.endDate);
|
||||
entity.setStatus(this.status!=null?this.getStatus():1);
|
||||
entity.setStatus(this.status!=null?this.getStatus():Status.ACTIVE.getValue());
|
||||
entity.setModified(new Date());
|
||||
entity.setDescription(this.description);
|
||||
return entity;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package eu.eudat.models.project;
|
||||
|
||||
import eu.eudat.models.criteria.ProjectCriteria;
|
||||
import eu.eudat.models.helpers.requests.RequestItem;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/18/2017.
|
||||
*/
|
||||
public class ProjectCriteriaRequest extends RequestItem<ProjectCriteria>{
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
import { UnauthorizedComponent } from './unauthorized/unauthorized.component';
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { PageNotFoundComponent } from './not-found.component';
|
||||
|
@ -19,35 +20,16 @@ const appRoutes: Routes = [
|
|||
|
||||
{ path: 'dynamic-form/:id', component: DynamicFormComponent, canActivate: [AuthGuard] },
|
||||
//{ path: 'dataset', component: DatasetsComponent },
|
||||
{ path: 'login', component: MainSignInComponent},
|
||||
{ path: 'projects', component: ProjectListingComponent},
|
||||
{ path: 'project/:id', component: ProjectEditorComponent},
|
||||
{ path: 'projects/new', component: ProjectEditorComponent},
|
||||
{ path: 'dmps', component: DataManagementPlanListingComponent},
|
||||
{ path: 'dmp/:id', component: DataManagementPlanEditorComponent},
|
||||
{ path: 'dmps/new', component: DataManagementPlanEditorComponent},
|
||||
// { path: 'dmps',
|
||||
// component: DataManagementPlanListingComponent,
|
||||
// children: [
|
||||
// {
|
||||
// path: "dmp",
|
||||
// component: DmpDetailedComponent,
|
||||
// data: {
|
||||
// //breadcrumb: "Sign In"
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// path: "project",
|
||||
// component: ProjectDetailedComponent,
|
||||
// data: {
|
||||
// //breadcrumb: "Sign Up"
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
{ path: 'welcome', component: HomepageComponent},
|
||||
{ path: '', redirectTo: '/login', pathMatch: 'full' },
|
||||
{ path: '**', component: PageNotFoundComponent }
|
||||
{ path: 'projects', component: ProjectListingComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'project/:id', component: ProjectEditorComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'projects/new', component: ProjectEditorComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'dmps', component: DataManagementPlanListingComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'dmp/:id', component: DataManagementPlanEditorComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'dmps/new', component: DataManagementPlanEditorComponent, canActivate: [AuthGuard]},
|
||||
{ path: 'login', component: MainSignInComponent},
|
||||
{ path: "unauthorized", loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule' },
|
||||
{ path: 'welcome', component: HomepageComponent, canActivate: [AuthGuard]},
|
||||
{ path: '', redirectTo: '/welcome', pathMatch: 'full' },
|
||||
|
||||
];
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { UnauthorizedComponent } from './unauthorized/unauthorized.component';
|
||||
import { PaginationService } from './form/pagination/pagination-service';
|
||||
import {
|
||||
TableOfContentsFieldComponent,
|
||||
|
|
|
@ -24,7 +24,7 @@ export class AuthService {
|
|||
public router: Router
|
||||
) {
|
||||
|
||||
this.actionUrl = HostConfiguration.Server + 'api/auth/';
|
||||
this.actionUrl = HostConfiguration.Server + 'login/';
|
||||
|
||||
this.headers = new HttpHeaders();
|
||||
this.headers = this.headers.set('Content-Type', 'application/json');
|
||||
|
@ -62,11 +62,11 @@ export class AuthService {
|
|||
//}
|
||||
|
||||
public login(loginInfo: LoginInfo): Observable<Principal> {
|
||||
const url = this.actionUrl + 'login';
|
||||
const url = this.actionUrl + 'externallogin';
|
||||
|
||||
return this.http.post(url, loginInfo, { headers: this.headers })
|
||||
.map((res: Response) => {
|
||||
const principal = this.current(new JsonSerializer<Principal>().fromJSONObject(res, Principal));
|
||||
.map((res: any) => {
|
||||
const principal = this.current(new JsonSerializer<Principal>().fromJSONObject(res.payload, Principal));
|
||||
//this.loginContextSubject.next(true);
|
||||
return principal;
|
||||
})
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
<span class="navbar-spacer"></span>
|
||||
<div *ngIf="isAuthenticated()">
|
||||
<a mat-button class="navbar-button" routerLink="/forms">Forms</a>
|
||||
<a mat-button *ngIf="isAdmin()" class="navbar-button" routerLink="/configuration">Configuration</a>
|
||||
<!-- <a mat-button *ngIf="isAdmin()" class="navbar-button" routerLink="/configuration">Configuration</a>
|
||||
<a mat-button *ngIf="isAdmin()" class="navbar-button" routerLink="/users">Users</a>
|
||||
<button mat-icon-button class="navbar-icon" (click)="logout()"><mat-icon class="navbar-icon">exit_to_app</mat-icon></button>
|
||||
--><button mat-icon-button class="navbar-icon" (click)="logout()"><mat-icon class="navbar-icon">exit_to_app</mat-icon></button>
|
||||
</div>
|
||||
</mat-toolbar>
|
||||
|
|
Loading…
Reference in New Issue