no message

This commit is contained in:
annampak 2018-01-19 15:59:48 +02:00
commit 62c4fb0547
66 changed files with 691 additions and 357 deletions

View File

@ -1,6 +1,6 @@
<div class="container"> <div class="container">
<div style="background-color: #f5f5f5;border: 1px solid #e3e3e3;padding: 24px;"> <div style="background-color: #f5f5f5;border: 1px solid #e3e3e3;padding: 24px;">
<form novalidate [formGroup]="form" (ngSubmit)="onSubmit()"> <form *ngIf="form" novalidate [formGroup]="form" (ngSubmit)="onSubmit()">
<div class="row"> <div class="row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label>Label</label> <label>Label</label>

View File

@ -25,28 +25,22 @@ export class FormComponent {
constructor(public restBase: RestBase, private datasetProfileService: DatasetProfileService, private route: ActivatedRoute) { constructor(public restBase: RestBase, private datasetProfileService: DatasetProfileService, private route: ActivatedRoute) {
this.profileID = route.snapshot.params['id']; this.profileID = route.snapshot.params['id'];
} }
ngOnInit() { ngOnInit() {
this.dataModel = new JsonSerializer<DatasetProfileModel>().fromJSONObject(new DatasetProfileModel(), DatasetProfileModel); this.dataModel = new JsonSerializer<DatasetProfileModel>().fromJSONObject(new DatasetProfileModel(), DatasetProfileModel);
this.form = this.dataModel.buildForm(); this.form = this.dataModel.buildForm();
if (this.profileID) { if (this.profileID) {
this.datasetProfileService.getDatasetProfileById(this.profileID).subscribe((data) => { this.datasetProfileService.getDatasetProfileById(this.profileID).subscribe((data) => {
this.dataModel = new JsonSerializer<DatasetProfileModel>().fromJSONObject(data, DatasetProfileModel); this.dataModel = new JsonSerializer<DatasetProfileModel>().fromJSONObject(data, DatasetProfileModel);
this.form = this.dataModel.buildForm(); this.form = this.dataModel.buildForm();
}); });
} }
else{ else {
this.addSection();
this.addSection(); this.addPage(0);
this.addPage(0);
} }
// this.dataModel = new JsonSerializer<DatasetProfileModel>().fromJSONObject(TestModel, DatasetProfileModel);
// this.form = this.dataModel.buildForm();
} }
onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) { onIsMultiplicityEnabledChange(isMultiplicityEnabled: boolean) {
@ -63,31 +57,31 @@ export class FormComponent {
} }
addPage(number) { addPage(number) {
let page: Page = new Page(this.dataModel.pages.length); let page: Page = new Page(this.dataModel.pages.length);
this.dataModel.pages.push(page); this.dataModel.pages.push(page);
(<FormArray>this.form.get("pages")).push(page.buildForm()); (<FormArray>this.form.get("pages")).push(page.buildForm());
} }
DeleteSection(index) { DeleteSection(index) {
this.dataModel.sections.splice(index,1); this.dataModel.sections.splice(index, 1);
(<FormArray>this.form.get("sections")).removeAt(index) (<FormArray>this.form.get("sections")).removeAt(index)
} }
DeletePage(index) { DeletePage(index) {
this.dataModel.pages.splice(index, 1); this.dataModel.pages.splice(index, 1);
(<FormArray>this.form.get("pages")).removeAt(index) (<FormArray>this.form.get("pages")).removeAt(index)
} }
createForm(data) { createForm(data) {
return this.restBase.post("/admin/addDmp", data); return this.restBase.post("/admin/addDmp", data);
} }
updateForm(id,data) { updateForm(id, data) {
return this.restBase.post("/admin/addDmp/"+id, data); return this.restBase.post("/admin/addDmp/" + id, data);
} }
onSubmit() { onSubmit() {
let data = this.form.value; let data = this.form.value;
if(this.profileID) this.updateForm(this.profileID, data).subscribe(); if (this.profileID) this.updateForm(this.profileID, data).subscribe();
else this.createForm(data).subscribe(); else this.createForm(data).subscribe();
} }

View File

@ -1,5 +1,5 @@
import { Component, OnInit, Input, ViewEncapsulation } from '@angular/core'; import { Component, OnInit, Input, ViewEncapsulation } from '@angular/core';
import { FormGroup } from '@angular/forms'; import { FormGroup } from '@angular/forms';
import { Section } from 'app/models/DataSetProfile/Section'; import { Section } from 'app/models/DataSetProfile/Section';
import { FieldGroup } from 'app/models/DataSetProfile/FieldGroup'; import { FieldGroup } from 'app/models/DataSetProfile/FieldGroup';
import { FormArray } from '@angular/forms/src/model'; import { FormArray } from '@angular/forms/src/model';
@ -24,36 +24,21 @@ export class SectionFormComponent {
constructor() { } constructor() { }
ngOnInit() { ngOnInit() {
var self = this; var self = this;
this.form.root.get("pages").valueChanges.subscribe(function (value) {
this.form.root.get("pages").valueChanges.subscribe(function(value) { self.keepPageSelectionValid(value);
self.keepPageSelectionValid(value); });
});
} }
// addGroupField() {
// let fieldGroup: FieldGroup = new FieldGroup();
// if (this.dataModel.fieldGroups)
// this.dataModel.fieldGroups.push(fieldGroup);
// (<FormArray>this.form.get("fieldGroups")).push(fieldGroup.buildForm());
// }
addField() { addField() {
let fieldSet: FieldSet = new FieldSet(); let fieldSet: FieldSet = new FieldSet();
let field: Field = new Field(); let field: Field = new Field();
//let fieldGroup: FieldGroup = new FieldGroup();
fieldSet.fields.push(field); fieldSet.fields.push(field);
//fieldGroup.compositeFields.push(fieldSet);
if (this.dataModel.fieldSets) if (this.dataModel.fieldSets)
this.dataModel.fieldSets.push(fieldSet); this.dataModel.fieldSets.push(fieldSet);
(<FormArray>this.form.get("fieldSets")).push(fieldSet.buildForm()); (<FormArray>this.form.get("fieldSets")).push(fieldSet.buildForm());
} }
// DeleteFieldGroup(index) {
// this.dataModel.fieldGroups.splice(index, 1);
// (<FormArray>this.form.get("fieldGroups")).removeAt(index)
// }
addSectioninSection() { addSectioninSection() {
let section: Section = new Section(); let section: Section = new Section();
this.dataModel.sections.push(section); this.dataModel.sections.push(section);
@ -65,15 +50,15 @@ export class SectionFormComponent {
(<FormArray>this.form.get("sections")).removeAt(index); (<FormArray>this.form.get("sections")).removeAt(index);
} }
DeleteFieldSet(index){ DeleteFieldSet(index) {
this.dataModel.fieldSets.splice(index, 1); this.dataModel.fieldSets.splice(index, 1);
(<FormArray>this.form.get("fieldSets")).removeAt(index); (<FormArray>this.form.get("fieldSets")).removeAt(index);
} }
keepPageSelectionValid(pagesJson: Array<any>) { keepPageSelectionValid(pagesJson: Array<any>) {
let selectedPage = this.form.get("page").value as number; let selectedPage = this.form.get("page").value as String;
let pages: Array<Page> = new JsonSerializer<Page>().fromJSONArray(pagesJson, Page); let pages: Array<Page> = new JsonSerializer<Page>().fromJSONArray(pagesJson, Page);
if (!isNaN(selectedPage) && pages.find(elem => elem.id === selectedPage) === undefined) if (pages.find(elem => elem.id === selectedPage) === undefined)
this.form.get("page").reset(); this.form.get("page").reset();
} }
} }

View File

@ -3,7 +3,7 @@
<div class="col-sm-6 col-md-4 col-md-offset-4"> <div class="col-sm-6 col-md-4 col-md-offset-4">
<h1 class="text-center login-title"></h1> <h1 class="text-center login-title"></h1>
<div class="account-wall"> <div class="account-wall">
<img class="profile-img" src="/admin-ui/assets/icons/user-icon.png"> <img class="profile-img" src="assets/icons/user-icon.png">
<form class="form-signin" [formGroup]="nativeLoginForm"> <form class="form-signin" [formGroup]="nativeLoginForm">
<input type="text" class="form-control" [(ngModel)]="creds.username" formControlName="username" placeholder="Username or Email" required autofocus> <input type="text" class="form-control" [(ngModel)]="creds.username" formControlName="username" placeholder="Username or Email" required autofocus>
<input type="password" class="form-control" [(ngModel)]="creds.password" formControlName="password" placeholder="Password" required> <input type="password" class="form-control" [(ngModel)]="creds.password" formControlName="password" placeholder="Password" required>

View File

@ -30,10 +30,10 @@ export class DatasetProfileModel extends BaseModel implements Serializable<Datas
formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray)); formGroup.addControl('sections', this.formBuilder.array(sectionsFormArray));
let pagesFormArray = new Array<FormGroup>(); let pagesFormArray = new Array<FormGroup>();
// this.pages.forEach(item => { this.pages.forEach(item => {
// let form: FormGroup = item.buildForm(); let form: FormGroup = item.buildForm();
// pagesFormArray.push(form) pagesFormArray.push(form)
// }) })
formGroup.addControl('pages', this.formBuilder.array(pagesFormArray)); formGroup.addControl('pages', this.formBuilder.array(pagesFormArray));
formGroup.addControl('label', new FormControl(this.label, Validators.required)); formGroup.addControl('label', new FormControl(this.label, Validators.required));

View File

@ -5,25 +5,28 @@ import { Serializable } from '../interfaces/Serializable';
export class Page extends BaseModel implements Serializable<Page>, FormGenerator<FormGroup>{ export class Page extends BaseModel implements Serializable<Page>, FormGenerator<FormGroup>{
public title: string; public title: string;
public id: number; public id: string;
public ordinal: number;
constructor(id?: number) { constructor(ordinal?: number) {
super(); super();
if (isNaN(id)) this.id = 0; if (isNaN(ordinal)) this.ordinal = 0;
else this.id = id; else this.ordinal = ordinal;
this.id = "page_" + this.ordinal;
} }
fromJSONObject(item: any): Page { fromJSONObject(item: any): Page {
this.title = item.title; this.title = item.title;
this.id = item.id; this.id = item.id;
this.ordinal = item.ordinal;
return this; return this;
} }
buildForm(): FormGroup { buildForm(): FormGroup {
let formGroup = this.formBuilder.group({ let formGroup = this.formBuilder.group({
title: [this.title], title: [this.title],
id: [this.id] id: [this.id],
ordinal: [this.ordinal]
}); });
return formGroup; return formGroup;
} }

View File

@ -18,7 +18,7 @@ export class RestBase {
/* /*
*/ */
protocol: string = "http"; protocol: string = "http";
hostname: string = "dl043.madgik.di.uoa.gr"; hostname: string = "localhost";
port: number = 8080; port: number = 8080;
webappname: string = ""; webappname: string = "";
restpath: string = ""; restpath: string = "";

View File

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>DmpAdmin</title> <title>DmpAdmin</title>
<base href="/admin-ui/"> <base href="/">
<meta name="csrf-token" content="2c64def7de30197c40276fe1a7ea874ca8871f70be7d7dc3305465a4d5c565e4"> <meta name="csrf-token" content="2c64def7de30197c40276fe1a7ea874ca8871f70be7d7dc3305465a4d5c565e4">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
@ -27,17 +27,17 @@
<!-- XML to json and vice versa lib --> <!-- XML to json and vice versa lib -->
<script src="/admin-ui/assets/xml2json.min.js"></script> <script src="assets/xml2json.min.js"></script>
<!-- Json formatter lib --> <!-- Json formatter lib -->
<link rel="stylesheet" type="text/css" href="/admin-ui/assets/jquery.json-viewer.css"> <link rel="stylesheet" type="text/css" href="assets/jquery.json-viewer.css">
<script src="/admin-ui/assets/jquery.json-viewer.js"></script> <script src="assets/jquery.json-viewer.js"></script>
<!-- lib 4 pretty-printing xml and json --> <!-- lib 4 pretty-printing xml and json -->
<script src="/admin-ui/assets/vkbeautify.0.99.00.js"></script> <script src="assets/vkbeautify.0.99.00.js"></script>
<!-- Nice BS notifications --> <!-- Nice BS notifications -->
<script src="/admin-ui/assets/bootstrap-notify.min.js"></script> <script src="assets/bootstrap-notify.min.js"></script>
<!-- that's google sign in library --> <!-- that's google sign in library -->
<script src="https://apis.google.com/js/platform.js"></script> <script src="https://apis.google.com/js/platform.js"></script>
@ -47,8 +47,8 @@
<!-- my custom global code and css --> <!-- my custom global code and css -->
<link rel="stylesheet" type="text/css" href="/admin-ui/assets/custom.css"> <link rel="stylesheet" type="text/css" href="assets/custom.css">
<script src="/admin-ui/assets/custom.js"></script> <script src="assets/custom.js"></script>
<link rel="icon" type="image/x-icon" href="favicon.ico"> <link rel="icon" type="image/x-icon" href="favicon.ico">

View File

@ -67,6 +67,7 @@ public class Admin extends BaseController{
try{ try{
eu.eudat.entities.DatasetProfile profile = this.getApiContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id)); eu.eudat.entities.DatasetProfile profile = this.getApiContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
eu.eudat.models.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile); eu.eudat.models.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
datasetprofile.setLabel(profile.getLabel());
return ResponseEntity.status(HttpStatus.OK).body(datasetprofile); return ResponseEntity.status(HttpStatus.OK).body(datasetprofile);
}catch(Exception ex){ }catch(Exception ex){
ex.printStackTrace(); ex.printStackTrace();

View File

@ -1,25 +0,0 @@
package eu.eudat.controllers;
import org.springframework.boot.autoconfigure.web.ErrorController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Created by ikalyvas on 1/16/2018.
*/
@Controller
public class CustomErrorController implements ErrorController{
@RequestMapping(value = "/error")
public String error(HttpServletRequest request, HttpServletResponse response) {
return "forward:/index.html";
}
@Override
public String getErrorPath() {
return "/error";
}
}

View File

@ -31,19 +31,19 @@ import java.util.Map;
@RestController @RestController
@CrossOrigin @CrossOrigin
@RequestMapping( value = { "/datasetwizard" }) @RequestMapping(value = {"/datasetwizard"})
public class DatasetWizardController extends BaseController{ public class DatasetWizardController extends BaseController {
@Autowired @Autowired
public DatasetWizardController(ApiContext apiContext) { public DatasetWizardController(ApiContext apiContext) {
super(apiContext); super(apiContext);
} }
@RequestMapping(method = RequestMethod.POST, value = { "/userDmps" }, produces="application/json") @RequestMapping(method = RequestMethod.POST, value = {"/userDmps"}, produces = "application/json")
public @ResponseBody public @ResponseBody
ResponseItem<List<DataManagentPlanListingModel>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) { ResponseItem<List<DataManagentPlanListingModel>> getUserDmps(@RequestBody DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, Principal principal) {
try { try {
List<DataManagentPlanListingModel> dataManagementPlans = DatasetWizardManager.getUserDmps(this.getApiContext().getDatabaseRepository().getDmpDao(),datasetWizardAutocompleteRequest,principal); List<DataManagentPlanListingModel> dataManagementPlans = DatasetWizardManager.getUserDmps(this.getApiContext().getDatabaseRepository().getDmpDao(), datasetWizardAutocompleteRequest, principal);
return new ResponseItem<List<DataManagentPlanListingModel>>().status(HttpStatus.OK).payload(dataManagementPlans); return new ResponseItem<List<DataManagentPlanListingModel>>().status(HttpStatus.OK).payload(dataManagementPlans);
} catch (Exception ex) { } catch (Exception ex) {
@ -52,10 +52,11 @@ public class DatasetWizardController extends BaseController{
} }
} }
@RequestMapping(method = RequestMethod.POST, value = { "/getAvailableProfiles" }, produces="application/json") @RequestMapping(method = RequestMethod.POST, value = {"/getAvailableProfiles"}, produces = "application/json")
public @ResponseBody ResponseItem<List<AssociatedProfile>> getAvailableProfiles(@RequestBody DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest, Principal principal) { public @ResponseBody
ResponseItem<List<AssociatedProfile>> getAvailableProfiles(@RequestBody DatasetProfileWizardAutocompleteRequest datasetProfileWizardAutocompleteRequest, Principal principal) {
try { try {
List<AssociatedProfile> dataManagementPlans = DatasetWizardManager.getAvailableProfiles(this.getApiContext().getDatabaseRepository().getDmpDao(),datasetProfileWizardAutocompleteRequest); List<AssociatedProfile> dataManagementPlans = DatasetWizardManager.getAvailableProfiles(this.getApiContext().getDatabaseRepository().getDmpDao(), datasetProfileWizardAutocompleteRequest);
return new ResponseItem<List<AssociatedProfile>>().status(HttpStatus.OK).payload(dataManagementPlans); return new ResponseItem<List<AssociatedProfile>>().status(HttpStatus.OK).payload(dataManagementPlans);
} catch (Exception ex) { } catch (Exception ex) {
@ -64,11 +65,11 @@ public class DatasetWizardController extends BaseController{
} }
} }
@RequestMapping(method = RequestMethod.GET, value = { "/getSingle/{id}" }, produces="application/json") @RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json")
public @ResponseBody ResponseItem<DatasetWizardModel> getPaged(@PathVariable String id,Principal principal) { public @ResponseBody
ResponseItem<DatasetWizardModel> getPaged(@PathVariable String id, Principal principal) {
try { try {
DatasetWizardModel dataset = new DatasetManager().getSingle(this.getApiContext().getDatabaseRepository().getDatasetDao(), id); DatasetWizardModel dataset = new DatasetManager().getSingle(this.getApiContext().getDatabaseRepository().getDatasetDao(), id);
return new ResponseItem<DatasetWizardModel>().status(HttpStatus.OK).payload(dataset); return new ResponseItem<DatasetWizardModel>().status(HttpStatus.OK).payload(dataset);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
@ -77,10 +78,11 @@ public class DatasetWizardController extends BaseController{
} }
@Transactional @Transactional
@RequestMapping(method = RequestMethod.POST, value = { "/createOrUpdate" }, consumes = "application/json",produces="application/json") @RequestMapping(method = RequestMethod.POST, value = {"/createOrUpdate"}, consumes = "application/json", produces = "application/json")
public @ResponseBody ResponseItem<eu.eudat.entities.Dataset> createOrUpdate(@RequestBody DatasetWizardModel profile,Principal principal) { public @ResponseBody
ResponseItem<eu.eudat.entities.Dataset> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) {
try { try {
eu.eudat.entities.Dataset dataset= DatasetManager.createOrUpdate(this.getApiContext(),profile); eu.eudat.entities.Dataset dataset = DatasetManager.createOrUpdate(this.getApiContext(), profile);
return new ResponseItem<eu.eudat.entities.Dataset>().status(HttpStatus.OK).payload(dataset); return new ResponseItem<eu.eudat.entities.Dataset>().status(HttpStatus.OK).payload(dataset);
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();

View File

@ -18,6 +18,7 @@ import eu.eudat.services.ApiContext;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -27,25 +28,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import eu.eudat.dao.entities.DMPDao;
import eu.eudat.dao.entities.DMPProfileDao;
import eu.eudat.dao.entities.DataRepositoryDao;
import eu.eudat.dao.entities.DatasetDao;
import eu.eudat.dao.entities.DatasetProfileDao;
import eu.eudat.dao.entities.DatasetProfileRulesetDao;
import eu.eudat.dao.entities.DatasetProfileViewstyleDao;
import eu.eudat.dao.entities.OrganisationDao;
import eu.eudat.dao.entities.ProjectDao;
import eu.eudat.dao.entities.RegistryDao;
import eu.eudat.dao.entities.ResearcherDao;
import eu.eudat.dao.entities.ServiceDao;
import eu.eudat.dao.entities.UserInfoDao;
import eu.eudat.models.criteria.DataRepositoryCriteria;
import eu.eudat.models.criteria.RegistryCriteria;
import eu.eudat.models.criteria.ServiceCriteria;
import javax.transaction.Transactional;
@RestController @RestController
@CrossOrigin @CrossOrigin
@ -69,5 +51,18 @@ public class Datasets extends BaseController {
} }
} }
@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"/datasets/makepublic/{id}"}, produces = "application/json")
public @ResponseBody ResponseItem<Dataset> makePublic(@PathVariable UUID id, Principal principal) {
try {
DatasetManager.makePublic(this.getApiContext().getDatabaseRepository().getDatasetDao(), id);
return new ResponseItem<Dataset>().status(HttpStatus.OK).message("Dataset Has Been Made Public");
} catch (Exception ex) {
ex.printStackTrace();
return new ResponseItem<Dataset>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
}
}
} }

View File

@ -1,7 +0,0 @@
package eu.eudat.controllers.controllerhandler;
/**
* Created by ikalyvas on 1/17/2018.
*/
public class ExternalDatasets {
}

View File

@ -56,7 +56,7 @@ public class DMPDaoImpl implements DMPDao {
@Override @Override
public DMP find(UUID id) { public DMP find(UUID id) {
return databaseService.getQueryable(DMP.class).where((builder, root) -> builder.equal((root.get("id")),id)).toList().get(0); return databaseService.getQueryable(DMP.class).where((builder, root) -> builder.equal((root.get("id")),id)).getSingle();
} }
public Long count(){ public Long count(){

View File

@ -33,11 +33,16 @@ public class DatasetDaoImpl implements DatasetDao {
@Override @Override
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) { public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) {
QueryableList<Dataset> query = databaseService.getQueryable(Dataset.class, Dataset.getHints()); QueryableList<Dataset> query = databaseService.getQueryable(Dataset.class, Dataset.getHints());
if (criteria.getLike() != null && !criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"), "%" + criteria.getLike() + "%")); if (criteria.getLike() != null && !criteria.getLike().isEmpty())
if (criteria.getStatus() != null)query.where((builder, root) -> builder.equal(root.get("status"), criteria.getStatus())); 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.getStatus() != null)
if (criteria.getPeriodStart() != null) query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart())); query.where((builder, root) -> builder.equal(root.get("status"), criteria.getStatus()));
if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty()) query.where((builder, root) -> root.get("dmp").get("id").in( criteria.getDmpIds())); 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.getDmpIds() != null && !criteria.getDmpIds().isEmpty())
query.where((builder, root) -> root.get("dmp").get("id").in(criteria.getDmpIds()));
return query; return query;
} }
@ -48,7 +53,7 @@ public class DatasetDaoImpl implements DatasetDao {
@Override @Override
public Dataset find(UUID id) { public Dataset find(UUID id) {
return databaseService.getQueryable(Dataset.class).where((builder, root) -> builder.equal((root.get("id")), id)).toList().get(0); return databaseService.getQueryable(Dataset.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
} }
public Long count() { public Long count() {
@ -57,7 +62,8 @@ public class DatasetDaoImpl implements DatasetDao {
@Override @Override
public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal) { public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal) {
query.where((builder, root) -> builder.or(builder.equal(root.get("dmp").get("creator"), principal), builder.isMember(principal, root.get("dmp").get("users")))); query.where((builder, root) -> builder.or(builder.equal(root.get("dmp").get("creator"), principal), builder.isMember(principal, root.get("dmp").get("users"))
, builder.equal(root.get("isPublic"), true)));
return query; return query;
} }
} }

View File

@ -39,7 +39,7 @@ public class DatasetProfileDaoImpl implements DatasetProfileDao {
@Override @Override
public DatasetProfile find(UUID id) { public DatasetProfile find(UUID id) {
return databaseService.getQueryable(DatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"),id)).toList().get(0); return databaseService.getQueryable(DatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"),id)).getSingle();
} }
@Override @Override

View File

@ -33,7 +33,7 @@ public class ExternalDatasetDaoImpl implements ExternalDatasetDao {
@Override @Override
public ExternalDataset find(UUID id) { public ExternalDataset find(UUID id) {
return this.databaseService.getQueryable(ExternalDataset.class).where((builder, root) -> builder.equal(root.get("id"),id)).toList().get(0); return this.databaseService.getQueryable(ExternalDataset.class).where((builder, root) -> builder.equal(root.get("id"),id)).getSingle();
} }
@Override @Override

View File

@ -31,7 +31,7 @@ public class InvitationDaoImpl implements InvitationDao{
@Override @Override
public Invitation find(UUID id) { public Invitation find(UUID id) {
return this.databaseService.getQueryable(Invitation.class).where((builder, root) -> builder.equal(root.get("id"),id)).toList().get(0); return this.databaseService.getQueryable(Invitation.class).where((builder, root) -> builder.equal(root.get("id"),id)).getSingle();
} }
@Override @Override

View File

@ -33,7 +33,7 @@ public class ProjectDaoImpl implements ProjectDao {
if(criteria.getLike()!=null&&!criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"),"%"+criteria.getLike()+"%")); 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("enddate"),criteria.getPeriodEnd())); if(criteria.getPeriodEnd()!=null)query.where((builder, root) -> builder.lessThan(root.get("enddate"),criteria.getPeriodEnd()));
if(criteria.getPeriodStart()!=null)query.where((builder, root) -> builder.greaterThan(root.get("startdate"),criteria.getPeriodStart())); if(criteria.getPeriodStart()!=null)query.where((builder, root) -> builder.greaterThan(root.get("startdate"),criteria.getPeriodStart()));
query.where((builder, root) -> builder.notEqual(root.get("status"), eu.eudat.models.project.Project.Status.DELETED.getValue())); query.where((builder, root) -> builder.notEqual(root.get("status"), Project.Status.DELETED.getValue()));
return query; return query;
} }
@ -44,7 +44,7 @@ public class ProjectDaoImpl implements ProjectDao {
@Override @Override
public Project find(UUID id) { public Project find(UUID id) {
return databaseService.getQueryable(Project.class).where((builder, root) -> builder.equal((root.get("id")),id)).toList().get(0); return databaseService.getQueryable(Project.class).where((builder, root) -> builder.equal((root.get("id")),id)).getSingle();
} }
public Long count(){ public Long count(){

View File

@ -40,7 +40,7 @@ public class UserInfoDaoImpl implements UserInfoDao {
@Override @Override
public UserInfo find(UUID id) { public UserInfo find(UUID id) {
return this.databaseService.getQueryable(UserInfo.class).where((builder, root) -> builder.equal(root.get("id"),id)).toList().get(0); return this.databaseService.getQueryable(UserInfo.class).where((builder, root) -> builder.equal(root.get("id"),id)).getSingle();
} }
@Override @Override

View File

@ -17,8 +17,10 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Table(name = "\"DMP\"") @Table(name = "\"DMP\"")
@NamedEntityGraphs({ @NamedEntityGraphs({
@NamedEntityGraph( @NamedEntityGraph(
name = "organisationsAndResearchers", name = "dataManagementPlanListingModel",
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")}), attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"),
@NamedAttributeNode("project"), @NamedAttributeNode("profile")}
),
@NamedEntityGraph( @NamedEntityGraph(
name = "fullyDetailed", name = "fullyDetailed",
attributeNodes = { attributeNodes = {
@ -31,7 +33,7 @@ public class DMP implements Serializable, DataEntity<DMP> {
return hints; return hints;
} }
private static final Set<String> hints = new HashSet<>(Arrays.asList("organisationsAndResearchers", "fullyDetailed")); private static final Set<String> hints = new HashSet<>(Arrays.asList("dataManagementPlanListingModel", "fullyDetailed"));
private static final long serialVersionUID = -8263056535208547615L; private static final long serialVersionUID = -8263056535208547615L;
@ -272,7 +274,7 @@ public class DMP implements Serializable, DataEntity<DMP> {
/* /*
public String toString() { public String toString() {
try { try {
return new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(this); return new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(this);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {

View File

@ -6,6 +6,8 @@ import java.util.*;
import javax.persistence.*; import javax.persistence.*;
import eu.eudat.models.project.*;
import eu.eudat.models.project.Project;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
@ -16,23 +18,44 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
@Table(name="\"Dataset\"") @Table(name="\"Dataset\"")
@NamedEntityGraphs({ @NamedEntityGraphs({
@NamedEntityGraph( @NamedEntityGraph(
name = "datasetreferences", name = "datasetListingModel",
attributeNodes = {@NamedAttributeNode("services"),@NamedAttributeNode("dataRepositories"),@NamedAttributeNode("registries")}), attributeNodes = {@NamedAttributeNode("services"),@NamedAttributeNode("dataRepositories"),@NamedAttributeNode("registries"),
@NamedEntityGraph( @NamedAttributeNode("dmp"),@NamedAttributeNode("profile")})
name = "datasetFullyDetailed",
attributeNodes = {
@NamedAttributeNode("dmp"),@NamedAttributeNode("profile"),@NamedAttributeNode("creator"),
@NamedAttributeNode("services"),@NamedAttributeNode("dataRepositories"),@NamedAttributeNode("registries")})
}) })
public class Dataset implements DataEntity<Dataset> { public class Dataset implements DataEntity<Dataset> {
public static Set<String> getHints() { public static Set<String> getHints() {
return hints; return hints;
} }
private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetreferences", "datasetFullyDetailed")); private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel"));
private static final long serialVersionUID = 3575723814399553259L; private static final long serialVersionUID = 3575723814399553259L;
public enum Status {
SAVED((short) 0), FINALISED((short) 1), DELETED((short) 99);
private short value;
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public static Dataset.Status fromInteger(int value) {
switch (value) {
case 0:
return SAVED;
case 1:
return FINALISED;
default:
throw new RuntimeException("Unsupported Project Status");
}
}
}
public Dataset () {} public Dataset () {}
@ -101,9 +124,11 @@ public class Dataset implements DataEntity<Dataset> {
@Column(name = "\"Status\"", nullable = false) @Column(name = "\"Status\"", nullable = false)
private Short status; private Short status;
@Column(name = "\"IsPublic\"", nullable = false)
private boolean isPublic;
@Column(name = "\"Created\"") @Column(name = "\"Created\"")
private Date created = null; private Date created = null;
@ -272,6 +297,14 @@ public class Dataset implements DataEntity<Dataset> {
this.externalDatasets = externalDatasets; this.externalDatasets = externalDatasets;
} }
public boolean isPublic() {
return isPublic;
}
public void setPublic(boolean aPublic) {
isPublic = aPublic;
}
@Override @Override
public void update(Dataset entity) { public void update(Dataset entity) {
this.setRegistries(entity.getRegistries()); this.setRegistries(entity.getRegistries());
@ -280,6 +313,7 @@ public class Dataset implements DataEntity<Dataset> {
this.setLabel(entity.getLabel()); this.setLabel(entity.getLabel());
this.setProperties(entity.getProperties()); this.setProperties(entity.getProperties());
this.setExternalDatasets(entity.getExternalDatasets()); this.setExternalDatasets(entity.getExternalDatasets());
this.setStatus(entity.getStatus());
} }
@Override @Override

View File

@ -31,6 +31,32 @@ import com.fasterxml.jackson.databind.SerializationFeature;
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id") @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
public class Project implements DataEntity<Project> { public class Project implements DataEntity<Project> {
public enum Status {
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
private short value;
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return ACTIVE;
case 1:
return INACTIVE;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Project Status");
}
}
}
public Project () {} public Project () {}

View File

@ -0,0 +1,55 @@
package eu.eudat.entities.xmlmodels.datasetprofiledefinition;
import eu.eudat.utilities.XmlSerializable;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* Created by ikalyvas on 1/19/2018.
*/
public class Page implements DatabaseViewStyleDefinition,XmlSerializable<Page> {
private String id;
private int ordinal;
private String title;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("page");
root.setAttribute("title",this.title);
root.setAttribute("ordinal",""+this.ordinal);
root.setAttribute("id",this.id);
return root;
}
@Override
public Page fromXml(Element item) {
this.ordinal = Integer.parseInt(item.getAttribute("ordinal"));
this.id = item.getAttribute("id");
this.title = item.getAttribute("title");
return this;
}
}

View File

@ -15,7 +15,7 @@ public class Section implements DatabaseViewStyleDefinition,XmlSerializable<Sect
private String id; private String id;
private int ordinal; private int ordinal;
private boolean defaultVisibility; private boolean defaultVisibility;
private int page; private String page;
private String title; private String title;
private String description; private String description;
private String extendedDescription; private String extendedDescription;
@ -39,10 +39,10 @@ public class Section implements DatabaseViewStyleDefinition,XmlSerializable<Sect
public void setDefaultVisibility(boolean defaultVisibility) { public void setDefaultVisibility(boolean defaultVisibility) {
this.defaultVisibility = defaultVisibility; this.defaultVisibility = defaultVisibility;
} }
public int getPage() { public String getPage() {
return page; return page;
} }
public void setPage(int page) { public void setPage(String page) {
this.page = page; this.page = page;
} }
public String getTitle() { public String getTitle() {
@ -124,7 +124,7 @@ public class Section implements DatabaseViewStyleDefinition,XmlSerializable<Sect
this.id = element.getAttribute("id"); this.id = element.getAttribute("id");
this.ordinal = Integer.parseInt(element.getAttribute("ordinal")); this.ordinal = Integer.parseInt(element.getAttribute("ordinal"));
this.defaultVisibility = Boolean.getBoolean(element.getAttribute("defaultVisibility")); this.defaultVisibility = Boolean.getBoolean(element.getAttribute("defaultVisibility"));
this.page = Integer.parseInt(element.getAttribute("page")); this.page = element.getAttribute("page");
Element description = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(),"description"); Element description = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(),"description");
if(description!=null) this.description = description.getTextContent(); if(description!=null) this.description = description.getTextContent();

View File

@ -2,7 +2,6 @@ package eu.eudat.entities.xmlmodels.datasetprofiledefinition;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node; import org.w3c.dom.Node;
@ -11,46 +10,71 @@ import org.w3c.dom.NodeList;
import eu.eudat.utilities.XmlSerializable; import eu.eudat.utilities.XmlSerializable;
import eu.eudat.utilities.builders.XmlBuilder; import eu.eudat.utilities.builders.XmlBuilder;
public class ViewStyleModel implements XmlSerializable<ViewStyleModel>{ public class ViewStyleModel implements XmlSerializable<ViewStyleModel> {
private List<Section> sections; private List<Section> sections;
private List<Page> pages;
public List<Section> getSections() { public List<Section> getSections() {
return sections; return sections;
} }
public void setSections(List<Section> sections) { public void setSections(List<Section> sections) {
this.sections = sections; this.sections = sections;
} }
public List<Page> getPages() {
return pages;
}
public void setPages(List<Page> pages) {
this.pages = pages;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("root");
Element sections = doc.createElement("sections");
Element pages = doc.createElement("pages");
for (Section section : this.sections) {
sections.appendChild(section.toXml(doc));
}
for (Page page : this.pages) {
pages.appendChild(page.toXml(doc));
}
root.appendChild(pages);
root.appendChild(sections);
return root;
}
@Override
public ViewStyleModel fromXml(Element element) {
this.sections = new LinkedList();
Element sections = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "sections");
if (sections != null) {
NodeList sectionElements = sections.getChildNodes();
for (int temp = 0; temp < sectionElements.getLength(); temp++) {
Node sectionElement = sectionElements.item(temp);
if (sectionElement.getNodeType() == Node.ELEMENT_NODE) {
this.sections.add(new Section().fromXml((Element) sectionElement));
}
}
}
this.pages = new LinkedList<>();
Element pages = (Element) XmlBuilder.getNodeFromListByTagName(element.getChildNodes(),"pages");
if(pages!=null){
NodeList pagesElements = pages.getChildNodes();
for (int temp = 0; temp < pagesElements.getLength(); temp++) {
Node pageElement = pagesElements.item(temp);
if (pageElement.getNodeType() == Node.ELEMENT_NODE) {
this.pages.add(new Page().fromXml((Element) pageElement));
}
}
}
return this;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("root");
Element sections = doc.createElement("sections");
for(Section section: this.sections){
sections.appendChild(section.toXml(doc));
}
root.appendChild(sections);
return root;
}
@Override
public ViewStyleModel fromXml(Element element) {
this.sections = new LinkedList();
Element sections = (Element)XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "sections");
if(sections!=null){
NodeList sectionElements = sections.getChildNodes();
for (int temp = 0; temp < sectionElements.getLength(); temp++) {
Node sectionElement = sectionElements.item(temp);
if (sectionElement.getNodeType() == Node.ELEMENT_NODE) {
this.sections.add(new Section().fromXml((Element)sectionElement));
}
}
}
return this;
}
} }

View File

@ -23,6 +23,7 @@ public class AdminManager {
public static eu.eudat.entities.DatasetProfile generateViewStyleDefinition(DatasetProfile profile){ public static eu.eudat.entities.DatasetProfile generateViewStyleDefinition(DatasetProfile profile){
ViewStyleModel viewStyleModel = new ViewStyleModel(); ViewStyleModel viewStyleModel = new ViewStyleModel();
viewStyleModel.setSections(new ModelBuilder().toViewStyleDefinition(profile.getSections(), eu.eudat.entities.xmlmodels.datasetprofiledefinition.Section.class)); viewStyleModel.setSections(new ModelBuilder().toViewStyleDefinition(profile.getSections(), eu.eudat.entities.xmlmodels.datasetprofiledefinition.Section.class));
viewStyleModel.setPages(new ModelBuilder().toViewStyleDefinition(profile.getPages(), eu.eudat.entities.xmlmodels.datasetprofiledefinition.Page.class));
Document viewStyleDoc = XmlBuilder.getDocument(); Document viewStyleDoc = XmlBuilder.getDocument();
Element elementViewStyle = viewStyleModel.toXml(viewStyleDoc); Element elementViewStyle = viewStyleModel.toXml(viewStyleDoc);
viewStyleDoc.appendChild(elementViewStyle); viewStyleDoc.appendChild(elementViewStyle);
@ -40,9 +41,6 @@ public class AdminManager {
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition()); Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
Element root = (Element)viewStyleDoc.getDocumentElement(); Element root = (Element)viewStyleDoc.getDocumentElement();
eu.eudat.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle= new eu.eudat.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root); eu.eudat.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle= new eu.eudat.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root);
Document profileDoc = XmlBuilder.fromXml(profile.getDefinition());
root = (Element)profileDoc.getDocumentElement();
eu.eudat.models.admin.composite.DatasetProfile datasetprofile = new eu.eudat.models.admin.composite.DatasetProfile(); eu.eudat.models.admin.composite.DatasetProfile datasetprofile = new eu.eudat.models.admin.composite.DatasetProfile();
datasetprofile.buildProfile(viewstyle); datasetprofile.buildProfile(viewstyle);

View File

@ -10,6 +10,7 @@ import eu.eudat.entities.DMP;
import eu.eudat.entities.Project; import eu.eudat.entities.Project;
import eu.eudat.entities.UserInfo; import eu.eudat.entities.UserInfo;
import eu.eudat.exceptions.UnauthorisedException; import eu.eudat.exceptions.UnauthorisedException;
import eu.eudat.models.HintedModelFactory;
import eu.eudat.models.criteria.DataManagementPlanCriteria; import eu.eudat.models.criteria.DataManagementPlanCriteria;
import eu.eudat.models.criteria.OrganisationCriteria; import eu.eudat.models.criteria.OrganisationCriteria;
import eu.eudat.models.criteria.ProjectCriteria; import eu.eudat.models.criteria.ProjectCriteria;
@ -33,8 +34,7 @@ public class DataManagementPlanManager {
QueryableList<DMP> authItems = apiContext.getDatabaseRepository().getDmpDao().getAuthenticated(items, userInfo); QueryableList<DMP> authItems = apiContext.getDatabaseRepository().getDmpDao().getAuthenticated(items, userInfo);
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest); QueryableList<DMP> pagedItems = PaginationManager.applyPaging(authItems, dataManagementPlanTableRequest);
if (dataManagementPlanTableRequest.getWithHint()) pagedItems.withHint("fullyDetailed"); List<DataManagementPlanListingModel> datamanagementPlans = new DomainModelConverter<eu.eudat.entities.DMP, DataManagementPlanListingModel>().fromDataModel(pagedItems.withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class)).toList(), DataManagementPlanListingModel.class);
List<DataManagementPlanListingModel> datamanagementPlans = new DomainModelConverter<eu.eudat.entities.DMP, DataManagementPlanListingModel>().fromDataModel(pagedItems.toList(), DataManagementPlanListingModel.class);
DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<DataManagementPlanListingModel>(); DataTableData<DataManagementPlanListingModel> dataTable = new DataTableData<DataManagementPlanListingModel>();
dataTable.setData(datamanagementPlans); dataTable.setData(datamanagementPlans);
dataTable.setTotalCount(items.count()); dataTable.setTotalCount(items.count());
@ -43,7 +43,7 @@ public class DataManagementPlanManager {
public eu.eudat.models.dmp.DataManagementPlan getSingle(DMPDao dmpsRepository, String id, Principal principal) throws InstantiationException, IllegalAccessException { public eu.eudat.models.dmp.DataManagementPlan getSingle(DMPDao dmpsRepository, String id, Principal principal) throws InstantiationException, IllegalAccessException {
DMP dataManagementPlanEntity = dmpsRepository.find(UUID.fromString(id)); DMP dataManagementPlanEntity = dmpsRepository.find(UUID.fromString(id));
if (dataManagementPlanEntity.getCreator().getId()!=principal.getId()&&dataManagementPlanEntity.getUsers().stream().filter(userInfo -> userInfo.getId() == principal.getId()).collect(Collectors.toList()).size() == 0) if (dataManagementPlanEntity.getCreator().getId() != principal.getId() && dataManagementPlanEntity.getUsers().stream().filter(userInfo -> userInfo.getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
throw new UnauthorisedException(); throw new UnauthorisedException();
eu.eudat.models.dmp.DataManagementPlan datamanagementPlan = new eu.eudat.models.dmp.DataManagementPlan(); eu.eudat.models.dmp.DataManagementPlan datamanagementPlan = new eu.eudat.models.dmp.DataManagementPlan();
datamanagementPlan.fromDataModel(dataManagementPlanEntity); datamanagementPlan.fromDataModel(dataManagementPlanEntity);

View File

@ -2,6 +2,7 @@ package eu.eudat.managers;
import eu.eudat.dao.entities.*; import eu.eudat.dao.entities.*;
import eu.eudat.entities.UserInfo; import eu.eudat.entities.UserInfo;
import eu.eudat.models.HintedModelFactory;
import eu.eudat.models.criteria.DataRepositoryCriteria; import eu.eudat.models.criteria.DataRepositoryCriteria;
import eu.eudat.models.criteria.RegistryCriteria; import eu.eudat.models.criteria.RegistryCriteria;
import eu.eudat.models.criteria.ServiceCriteria; import eu.eudat.models.criteria.ServiceCriteria;
@ -13,6 +14,7 @@ import eu.eudat.models.listingmodels.DatasetListingModel;
import eu.eudat.models.project.Project; import eu.eudat.models.project.Project;
import eu.eudat.models.project.ProjectTableRequest; import eu.eudat.models.project.ProjectTableRequest;
import eu.eudat.models.security.Principal; import eu.eudat.models.security.Principal;
import eu.eudat.models.user.composite.PagedDatasetProfile;
import eu.eudat.queryable.QueryableList; import eu.eudat.queryable.QueryableList;
import eu.eudat.services.ApiContext; import eu.eudat.services.ApiContext;
import eu.eudat.utilities.builders.DomainModelConverter; import eu.eudat.utilities.builders.DomainModelConverter;
@ -28,79 +30,87 @@ import java.util.UUID;
*/ */
public class DatasetManager { public class DatasetManager {
public DataTableData<DatasetListingModel> getPaged(ApiContext apiContext, DatasetTableRequest datasetTableRequest, Principal principal) throws IllegalAccessException, InstantiationException{ public DataTableData<DatasetListingModel> getPaged(ApiContext apiContext, DatasetTableRequest datasetTableRequest, Principal principal) throws IllegalAccessException, InstantiationException {
UserInfo userInfo = new UserInfo(); UserInfo userInfo = new UserInfo();
userInfo.setId(principal.getId()); userInfo.setId(principal.getId());
QueryableList<eu.eudat.entities.Dataset> items = apiContext.getDatabaseRepository().getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()); QueryableList<eu.eudat.entities.Dataset> items = apiContext.getDatabaseRepository().getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria());
QueryableList<eu.eudat.entities.Dataset> authItems = apiContext.getDatabaseRepository().getDatasetDao().getAuthenticated(items,userInfo); QueryableList<eu.eudat.entities.Dataset> authItems = apiContext.getDatabaseRepository().getDatasetDao().getAuthenticated(items, userInfo);
QueryableList<eu.eudat.entities.Dataset> pagedItems = PaginationManager.applyPaging( authItems ,datasetTableRequest); QueryableList<eu.eudat.entities.Dataset> pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest);
if(datasetTableRequest.getWithHint())pagedItems.withHint("datasetFullyDetailed"); List<DatasetListingModel> datasets = new DomainModelConverter<eu.eudat.entities.Dataset, DatasetListingModel>().fromDataModel(pagedItems.withHint(HintedModelFactory.getHint(DatasetListingModel.class)).toList(), DatasetListingModel.class);
List<DatasetListingModel> datasets = new DomainModelConverter<eu.eudat.entities.Dataset, DatasetListingModel>().fromDataModel( pagedItems.toList(), DatasetListingModel.class);
DataTableData<DatasetListingModel> dataTable = new DataTableData<DatasetListingModel>(); DataTableData<DatasetListingModel> dataTable = new DataTableData<DatasetListingModel>();
dataTable.setData(datasets); dataTable.setData(datasets);
dataTable.setTotalCount(items.count()); dataTable.setTotalCount(items.count());
return dataTable; return dataTable;
} }
public DatasetWizardModel getSingle(DatasetDao datatasetRepository, String id) throws InstantiationException, IllegalAccessException{ public DatasetWizardModel getSingle(DatasetDao datatasetRepository, String id) throws InstantiationException, IllegalAccessException {
DatasetWizardModel dataset = new DatasetWizardModel(); DatasetWizardModel dataset = new DatasetWizardModel();
eu.eudat.entities.Dataset datasetEntity = datatasetRepository.find(UUID.fromString(id)); eu.eudat.entities.Dataset datasetEntity = datatasetRepository.find(UUID.fromString(id));
eu.eudat.models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(datasetEntity.getProfile()); eu.eudat.models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(datasetEntity.getProfile());
datasetprofile.setStatus(dataset.getStatus()); datasetprofile.setStatus(dataset.getStatus());
if(datasetEntity.getProperties()!=null){ if (datasetEntity.getProperties() != null) {
JSONObject jobject = new JSONObject(datasetEntity.getProperties()); JSONObject jobject = new JSONObject(datasetEntity.getProperties());
Map<String,Object> properties = (Map<String, Object>)jobject.toMap(); Map<String, Object> properties = (Map<String, Object>) jobject.toMap();
datasetprofile.fromJsonObject(properties); datasetprofile.fromJsonObject(properties);
} }
dataset.setDatasetProfileDefinition(datasetprofile); PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
dataset.setDatasetProfileDefinition(pagedDatasetProfile);
dataset.fromDataModel(datasetEntity); dataset.fromDataModel(datasetEntity);
return dataset; return dataset;
} }
public static eu.eudat.entities.Dataset createOrUpdate(ApiContext apiContext, DatasetWizardModel profile) throws Exception { public static eu.eudat.entities.Dataset createOrUpdate(ApiContext apiContext, DatasetWizardModel profile) throws Exception {
eu.eudat.entities.Dataset dataset = profile.toDataModel(); eu.eudat.entities.Dataset dataset = profile.toDataModel();
createRegistriesIfTheyDontExist(apiContext.getDatabaseRepository().getRegistryDao(),dataset); createRegistriesIfTheyDontExist(apiContext.getDatabaseRepository().getRegistryDao(), dataset);
createDataRepositoriesIfTheyDontExist(apiContext.getDatabaseRepository().getDataRepositoryDao(),dataset); createDataRepositoriesIfTheyDontExist(apiContext.getDatabaseRepository().getDataRepositoryDao(), dataset);
createServicesIfTheyDontExist(apiContext.getDatabaseRepository().getServiceDao(),dataset); createServicesIfTheyDontExist(apiContext.getDatabaseRepository().getServiceDao(), dataset);
return apiContext.getDatabaseRepository().getDatasetDao().createOrUpdate(dataset); return apiContext.getDatabaseRepository().getDatasetDao().createOrUpdate(dataset);
} }
private static void createRegistriesIfTheyDontExist(RegistryDao registryDao, eu.eudat.entities.Dataset dataset){ private static void createRegistriesIfTheyDontExist(RegistryDao registryDao, eu.eudat.entities.Dataset dataset) {
if(dataset.getRegistries()!=null&&!dataset.getRegistries().isEmpty()){ if (dataset.getRegistries() != null && !dataset.getRegistries().isEmpty()) {
for(eu.eudat.entities.Registry registry : dataset.getRegistries()){ for (eu.eudat.entities.Registry registry : dataset.getRegistries()) {
RegistryCriteria criteria = new RegistryCriteria(); RegistryCriteria criteria = new RegistryCriteria();
criteria.setLike(registry.getReference()); criteria.setLike(registry.getReference());
List<eu.eudat.entities.Registry> entries = registryDao.listBy(criteria); List<eu.eudat.entities.Registry> entries = registryDao.listBy(criteria);
if(entries!=null&&!entries.isEmpty())registry.setId( entries.get(0).getId()); if (entries != null && !entries.isEmpty()) registry.setId(entries.get(0).getId());
else registry = registryDao.create(registry); else registry = registryDao.create(registry);
} }
} }
} }
private static void createServicesIfTheyDontExist(ServiceDao serviceDao,eu.eudat.entities.Dataset dataset){ private static void createServicesIfTheyDontExist(ServiceDao serviceDao, eu.eudat.entities.Dataset dataset) {
if(dataset.getServices()!=null&&!dataset.getServices().isEmpty()){ if (dataset.getServices() != null && !dataset.getServices().isEmpty()) {
for(eu.eudat.entities.Service service : dataset.getServices()){ for (eu.eudat.entities.Service service : dataset.getServices()) {
ServiceCriteria criteria = new ServiceCriteria(); ServiceCriteria criteria = new ServiceCriteria();
criteria.setLike(service.getReference()); criteria.setLike(service.getReference());
List<eu.eudat.entities.Service> entries = serviceDao.listBy(criteria); List<eu.eudat.entities.Service> entries = serviceDao.listBy(criteria);
if(entries!=null&&!entries.isEmpty())service.setId(entries.get(0).getId()); if (entries != null && !entries.isEmpty()) service.setId(entries.get(0).getId());
else service = serviceDao.create(service); else service = serviceDao.create(service);
} }
} }
} }
private static void createDataRepositoriesIfTheyDontExist(DataRepositoryDao dataRepositoryDao,eu.eudat.entities.Dataset dataset){ private static void createDataRepositoriesIfTheyDontExist(DataRepositoryDao dataRepositoryDao, eu.eudat.entities.Dataset dataset) {
if(dataset.getDataRepositories()!=null&&!dataset.getDataRepositories().isEmpty()){ if (dataset.getDataRepositories() != null && !dataset.getDataRepositories().isEmpty()) {
for(eu.eudat.entities.DataRepository dataRepo : dataset.getDataRepositories()){ for (eu.eudat.entities.DataRepository dataRepo : dataset.getDataRepositories()) {
DataRepositoryCriteria criteria = new DataRepositoryCriteria(); DataRepositoryCriteria criteria = new DataRepositoryCriteria();
criteria.setLike(dataRepo.getReference()); criteria.setLike(dataRepo.getReference());
List<eu.eudat.entities.DataRepository> entries = dataRepositoryDao.listBy(criteria); List<eu.eudat.entities.DataRepository> entries = dataRepositoryDao.listBy(criteria);
if(entries!=null&&!entries.isEmpty())dataRepo.setId(entries.get(0).getId()); if (entries != null && !entries.isEmpty()) dataRepo.setId(entries.get(0).getId());
else dataRepo = dataRepositoryDao.createOrUpdate(dataRepo); else dataRepo = dataRepositoryDao.createOrUpdate(dataRepo);
} }
} }
} }
public static void makePublic(DatasetDao datasetDao, UUID id) throws Exception {
eu.eudat.entities.Dataset dataset = datasetDao.find(id);
if (dataset.getStatus() != eu.eudat.entities.Dataset.Status.FINALISED.getValue())
throw new Exception("You cannot make public a Dataset That Has not Been Finalised");
dataset.setPublic(true);
datasetDao.createOrUpdate(dataset);
}
} }

View File

@ -43,7 +43,7 @@ public class ProjectManager {
public eu.eudat.entities.Project inactivate(ProjectDao projectRepository, String id) throws InstantiationException, IllegalAccessException { public eu.eudat.entities.Project inactivate(ProjectDao projectRepository, String id) throws InstantiationException, IllegalAccessException {
eu.eudat.entities.Project project = projectRepository.find(UUID.fromString(id)); eu.eudat.entities.Project project = projectRepository.find(UUID.fromString(id));
project.setStatus(Project.Status.DELETED.getValue()); project.setStatus(eu.eudat.entities.Project.Status.DELETED.getValue());
project = projectRepository.createOrUpdate(project); project = projectRepository.createOrUpdate(project);
return project; return project;
} }

View File

@ -5,4 +5,5 @@ import eu.eudat.entities.DataEntity;
public interface DataModel<T extends DataEntity> { public interface DataModel<T extends DataEntity> {
void fromDataModel(T entity) throws InstantiationException, IllegalAccessException; void fromDataModel(T entity) throws InstantiationException, IllegalAccessException;
T toDataModel() throws Exception; T toDataModel() throws Exception;
String getHint();
} }

View File

@ -0,0 +1,19 @@
package eu.eudat.models;
/**
* Created by ikalyvas on 1/18/2018.
*/
public class HintedModelFactory {
public static <T extends DataModel> String getHint(Class<T> clazz) {
try {
return clazz.newInstance().getHint();
} catch (InstantiationException e) {
e.printStackTrace();
return null;
} catch (IllegalAccessException e) {
e.printStackTrace();
return null;
}
}
}

View File

@ -0,0 +1,57 @@
package eu.eudat.models.admin.components.datasetprofile;
import eu.eudat.entities.xmlmodels.datasetprofiledefinition.*;
import eu.eudat.utilities.ViewStyleDefinition;
/**
* Created by ikalyvas on 1/19/2018.
*/
public class Page implements Comparable,ViewStyleDefinition<eu.eudat.entities.xmlmodels.datasetprofiledefinition.Page> {
private String id;
private Integer ordinal;
private String title;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getOrdinal() {
return ordinal;
}
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public eu.eudat.entities.xmlmodels.datasetprofiledefinition.Page toDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Page item) {
item.setId(this.id);
item.setOrdinal(this.ordinal);
item.setTitle(this.title);
return item;
}
@Override
public void fromDatabaseDefinition(eu.eudat.entities.xmlmodels.datasetprofiledefinition.Page item) {
this.title = item.getTitle();
this.ordinal = item.getOrdinal();
this.id = item.getId();
}
@Override
public int compareTo(Object o) {
return this.ordinal.compareTo((Integer)o);
}
}

View File

@ -11,7 +11,7 @@ public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities
private List<Section> sections; private List<Section> sections;
private List<FieldSet> fieldSets; private List<FieldSet> fieldSets;
private Boolean defaultVisibility; private Boolean defaultVisibility;
private int page; private String page;
private Integer ordinal; private Integer ordinal;
private String id; private String id;
private String title; private String title;
@ -37,10 +37,10 @@ public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities
public void setDefaultVisibility(Boolean defaultVisibility) { public void setDefaultVisibility(Boolean defaultVisibility) {
this.defaultVisibility = defaultVisibility; this.defaultVisibility = defaultVisibility;
} }
public int getPage() { public String getPage() {
return page; return page;
} }
public void setPage(int page) { public void setPage(String page) {
this.page = page; this.page = page;
} }
public String getId() { public String getId() {

View File

@ -10,7 +10,7 @@ import eu.eudat.models.admin.components.datasetprofile.*;
public class DatasetProfile { public class DatasetProfile {
private String label; private String label;
private List<Section> sections; private List<Section> sections;
private List<Page> pages;
public List<Section> getSections() { public List<Section> getSections() {
return sections; return sections;
} }
@ -27,9 +27,16 @@ public class DatasetProfile {
this.label = label; this.label = label;
} }
public List<Page> getPages() {
return pages;
}
public void setPages(List<Page> pages) {
this.pages = pages;
}
public void buildProfile(eu.eudat.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle){ public void buildProfile(eu.eudat.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle){
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class); this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
} }
} }

View File

@ -55,4 +55,9 @@ public class DataRepository implements DataModel<eu.eudat.entities.DataRepositor
public String generateLabel() { public String generateLabel() {
return this.getName(); return this.getName();
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -163,5 +163,9 @@ public class Dataset implements DataModel<eu.eudat.entities.Dataset>{
} }
return entity; return entity;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -81,4 +81,9 @@ public class Registry implements DataModel<eu.eudat.entities.Registry>,LabelGene
eu.eudat.entities.Registry entity = new eu.eudat.entities.Registry(); eu.eudat.entities.Registry entity = new eu.eudat.entities.Registry();
return entity; return entity;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -85,4 +85,9 @@ public class Service implements DataModel<eu.eudat.entities.Service>,LabelGenera
public String generateLabel() { public String generateLabel() {
return this.label; return this.label;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -42,4 +42,9 @@ public class DatasetProfileAutocompleteItem implements DataModel<DatasetProfile>
profile.setId(this.id); profile.setId(this.id);
return profile; return profile;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -94,4 +94,9 @@ public class DatasetProfileListingModel implements DataModel<DatasetProfile> {
profile.setId(this.id); profile.setId(this.id);
return profile; return profile;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -37,4 +37,9 @@ public class DataManagentPlanListingModel implements DataModel<DMP>{
public DMP toDataModel() { public DMP toDataModel() {
return null; return null;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -12,6 +12,7 @@ import eu.eudat.models.dmp.DataManagementPlan;
import eu.eudat.models.externaldataset.ExternalDatasetListingModel; import eu.eudat.models.externaldataset.ExternalDatasetListingModel;
import eu.eudat.models.listingmodels.DatasetListingModel; import eu.eudat.models.listingmodels.DatasetListingModel;
import eu.eudat.models.user.composite.DatasetProfile; import eu.eudat.models.user.composite.DatasetProfile;
import eu.eudat.models.user.composite.PagedDatasetProfile;
import eu.eudat.utilities.builders.DomainModelConverter; import eu.eudat.utilities.builders.DomainModelConverter;
import java.util.*; import java.util.*;
@ -31,7 +32,7 @@ public class DatasetWizardModel implements DataModel<Dataset> {
private String properties; private String properties;
private Date created; private Date created;
private DataManagementPlan dmp; private DataManagementPlan dmp;
private eu.eudat.models.user.composite.DatasetProfile datasetProfileDefinition; private PagedDatasetProfile datasetProfileDefinition;
private List<Registry> registries; private List<Registry> registries;
private List<Service> services; private List<Service> services;
private List<DataRepository> dataRepositories; private List<DataRepository> dataRepositories;
@ -110,11 +111,11 @@ public class DatasetWizardModel implements DataModel<Dataset> {
this.dmp = dmp; this.dmp = dmp;
} }
public DatasetProfile getDatasetProfileDefinition() { public PagedDatasetProfile getDatasetProfileDefinition() {
return datasetProfileDefinition; return datasetProfileDefinition;
} }
public void setDatasetProfileDefinition(DatasetProfile datasetProfileDefinition) { public void setDatasetProfileDefinition(PagedDatasetProfile datasetProfileDefinition) {
this.datasetProfileDefinition = datasetProfileDefinition; this.datasetProfileDefinition = datasetProfileDefinition;
} }
@ -163,6 +164,7 @@ public class DatasetWizardModel implements DataModel<Dataset> {
this.id = entity.getId(); this.id = entity.getId();
this.label = entity.getLabel(); this.label = entity.getLabel();
this.properties = entity.getProperties(); this.properties = entity.getProperties();
this.status = entity.getStatus();
this.reference = entity.getReference(); this.reference = entity.getReference();
this.description = entity.getDescription(); this.description = entity.getDescription();
this.profile = new DatasetProfileListingModel(); this.profile = new DatasetProfileListingModel();
@ -218,4 +220,9 @@ public class DatasetWizardModel implements DataModel<Dataset> {
} }
return entity; return entity;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -178,4 +178,9 @@ public class DataManagementPlan implements DataModel<DMP>{
dataManagementPlanEntity.setCreated(this.created!=null?this.created:new Date()); dataManagementPlanEntity.setCreated(this.created!=null?this.created:new Date());
return dataManagementPlanEntity; return dataManagementPlanEntity;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -65,4 +65,9 @@ public class Organisation implements DataModel<eu.eudat.entities.Organisation>,L
public String generateLabel() { public String generateLabel() {
return this.getName(); return this.getName();
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -66,4 +66,9 @@ public class Researcher implements DataModel<eu.eudat.entities.Researcher>,Label
public String generateLabel() { public String generateLabel() {
return this.getName(); return this.getName();
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -88,4 +88,9 @@ public class ExternalDatasetListingModel implements DataModel<ExternalDataset> {
externalDataset.setReference(this.reference); externalDataset.setReference(this.reference);
return externalDataset; return externalDataset;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -96,5 +96,8 @@ public class DataManagementPlanListingModel implements DataModel<DMP> {
return null; return null;
} }
@Override
public String getHint() {
return "dataManagementPlanListingModel";
}
} }

View File

@ -134,4 +134,9 @@ public class DatasetListingModel implements DataModel<Dataset> {
public Dataset toDataModel() { public Dataset toDataModel() {
return null; return null;
} }
@Override
public String getHint() {
return "datasetListingModel";
}
} }

View File

@ -12,32 +12,7 @@ import eu.eudat.models.dmp.DataManagementPlan;
public class Project implements DataModel<eu.eudat.entities.Project> { public class Project implements DataModel<eu.eudat.entities.Project> {
public enum Status {
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
private short value;
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return ACTIVE;
case 1:
return INACTIVE;
case 99:
return INACTIVE;
default:
throw new RuntimeException("Unsupported Project Status");
}
}
}
private UUID id; private UUID id;
@ -58,7 +33,7 @@ public class Project implements DataModel<eu.eudat.entities.Project> {
private Date endDate; private Date endDate;
private Status status; private eu.eudat.entities.Project.Status status;
private UserInfo creationUser; private UserInfo creationUser;
@ -146,7 +121,7 @@ public class Project implements DataModel<eu.eudat.entities.Project> {
} }
public void setStatus(Short status) { public void setStatus(Short status) {
this.status = Status.fromInteger(status); this.status = eu.eudat.entities.Project.Status.fromInteger(status);
} }
public UserInfo getCreationUser() { public UserInfo getCreationUser() {
@ -210,9 +185,14 @@ public class Project implements DataModel<eu.eudat.entities.Project> {
entity.setStartdate(this.startDate); entity.setStartdate(this.startDate);
entity.setCreated(this.created == null ? new Date() : this.created); entity.setCreated(this.created == null ? new Date() : this.created);
entity.setEnddate(this.endDate); entity.setEnddate(this.endDate);
entity.setStatus(this.status != null ? this.getStatus() : Status.ACTIVE.getValue()); entity.setStatus(this.status != null ? this.getStatus() : eu.eudat.entities.Project.Status.ACTIVE.getValue());
entity.setModified(new Date()); entity.setModified(new Date());
entity.setDescription(this.description); entity.setDescription(this.description);
return entity; return entity;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -31,4 +31,9 @@ public class ProjectCriteriaModel implements DataModel<eu.eudat.entities.Project
project.setId(this.id); project.setId(this.id);
return project; return project;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -5,41 +5,14 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import eu.eudat.entities.UserInfo; import eu.eudat.entities.*;
import eu.eudat.entities.Project;
import eu.eudat.models.DataModel; import eu.eudat.models.DataModel;
import eu.eudat.models.dmp.DataManagementPlan; import eu.eudat.models.dmp.DataManagementPlan;
public class ProjectListingModel implements DataModel<eu.eudat.entities.Project> { public class ProjectListingModel implements DataModel<eu.eudat.entities.Project> {
public enum Status {
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
private short value;
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return ACTIVE;
case 1:
return INACTIVE;
case 99:
return INACTIVE;
default:
throw new RuntimeException("Unsupported Project Status");
}
}
}
private UUID id; private UUID id;
private List<DataManagementPlan> dmps; private List<DataManagementPlan> dmps;
@ -58,7 +31,7 @@ public class ProjectListingModel implements DataModel<eu.eudat.entities.Project>
private String endDate; private String endDate;
private Status status; private Project.Status status;
private UserInfo creationUser; private UserInfo creationUser;
@ -130,7 +103,7 @@ public class ProjectListingModel implements DataModel<eu.eudat.entities.Project>
} }
public void setStatus(Short status) { public void setStatus(Short status) {
this.status = Status.fromInteger(status); this.status = Project.Status.fromInteger(status);
} }
public UserInfo getCreationUser() { public UserInfo getCreationUser() {
@ -202,4 +175,9 @@ public class ProjectListingModel implements DataModel<eu.eudat.entities.Project>
public eu.eudat.entities.Project toDataModel() throws Exception { public eu.eudat.entities.Project toDataModel() throws Exception {
throw new Exception("Not Implemented"); throw new Exception("Not Implemented");
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -12,7 +12,7 @@ public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities
private List<Section> sections; private List<Section> sections;
private List<FieldSet> fieldSets; private List<FieldSet> fieldSets;
private Boolean defaultVisibility; private Boolean defaultVisibility;
private int page; private String page;
private Integer ordinal; private Integer ordinal;
private String id; private String id;
private String title; private String title;
@ -39,10 +39,10 @@ public class Section implements Comparable,ViewStyleDefinition<eu.eudat.entities
public void setDefaultVisibility(Boolean defaultVisibility) { public void setDefaultVisibility(Boolean defaultVisibility) {
this.defaultVisibility = defaultVisibility; this.defaultVisibility = defaultVisibility;
} }
public int getPage() { public String getPage() {
return page; return page;
} }
public void setPage(int page) { public void setPage(String page) {
this.page = page; this.page = page;
} }
public String getId() { public String getId() {

View File

@ -1,5 +1,6 @@
package eu.eudat.models.user.composite; package eu.eudat.models.user.composite;
import eu.eudat.models.admin.components.datasetprofile.Page;
import eu.eudat.utilities.builders.ModelBuilder; import eu.eudat.utilities.builders.ModelBuilder;
import eu.eudat.utilities.helpers.ModelBuilderCollector; import eu.eudat.utilities.helpers.ModelBuilderCollector;
@ -12,6 +13,7 @@ import eu.eudat.models.user.components.commons.Rule;
public class DatasetProfile implements PropertiesModelBuilder{ public class DatasetProfile implements PropertiesModelBuilder{
private List<Section> sections; private List<Section> sections;
private List<Rule> rules; private List<Rule> rules;
private List<Page> pages;
private int status; private int status;
public List<Section> getSections() { public List<Section> getSections() {
return sections; return sections;
@ -38,8 +40,17 @@ public class DatasetProfile implements PropertiesModelBuilder{
this.status = status; this.status = status;
} }
public void buildProfile( eu.eudat.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle){ public List<Page> getPages() {
return pages;
}
public void setPages(List<Page> pages) {
this.pages = pages;
}
public void buildProfile(eu.eudat.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewStyle){
this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class); this.sections = new ModelBuilder().fromViewStyleDefinition(viewStyle.getSections(), Section.class);
this.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
this.rules = ModelBuilderCollector.collectRules(viewStyle.getSections()); this.rules = ModelBuilderCollector.collectRules(viewStyle.getSections());
} }

View File

@ -0,0 +1,37 @@
package eu.eudat.models.user.composite;
import eu.eudat.models.user.components.datasetprofile.Section;
import java.util.List;
/**
* Created by ikalyvas on 1/19/2018.
*/
public class DatasetProfilePage {
private Integer ordinal;
private String title;
private List<Section> sections;
public Integer getOrdinal() {
return ordinal;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public List<Section> getSections() {
return sections;
}
public void setSections(List<Section> sections) {
this.sections = sections;
}
}

View File

@ -0,0 +1,57 @@
package eu.eudat.models.user.composite;
import eu.eudat.models.admin.components.datasetprofile.Page;
import eu.eudat.models.user.components.commons.Rule;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
/**
* Created by ikalyvas on 1/19/2018.
*/
public class PagedDatasetProfile {
private List<DatasetProfilePage> pages;
private List<Rule> rules;
private int status;
public List<DatasetProfilePage> getPages() {
return pages;
}
public void setPages(List<DatasetProfilePage> pages) {
this.pages = pages;
}
public List<Rule> getRules() {
return rules;
}
public void setRules(List<Rule> rules) {
this.rules = rules;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public PagedDatasetProfile buildPagedDatasetProfile(DatasetProfile profile) {
this.status = profile.getStatus();
this.rules = profile.getRules();
this.pages = new LinkedList<>();
List<Page> pages = profile.getPages();
for (Page page : pages) {
DatasetProfilePage datasetProfilePage = new DatasetProfilePage();
datasetProfilePage.setOrdinal(page.getOrdinal());
datasetProfilePage.setTitle(page.getTitle());
datasetProfilePage.setSections(profile.getSections().stream().filter(item -> item.getPage().equals(page.getId())).collect(Collectors.toList()));
this.pages.add(datasetProfilePage);
}
return this;
}
}

View File

@ -109,6 +109,9 @@ public class UserInfo implements DataModel<eu.eudat.entities.UserInfo>{
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -53,4 +53,9 @@ public class UserInfoInvitationModel implements DataModel<eu.eudat.entities.User
userInfo.setName(this.name); userInfo.setName(this.name);
return userInfo; return userInfo;
} }
@Override
public String getHint() {
return null;
}
} }

View File

@ -17,6 +17,8 @@ public interface QueryableList<T extends DataEntity<T>> {
List<T> toList(); List<T> toList();
T getSingle();
QueryableList<T> skip(Integer offset); QueryableList<T> skip(Integer offset);
QueryableList<T> take(Integer length); QueryableList<T> take(Integer length);
@ -26,6 +28,6 @@ public interface QueryableList<T extends DataEntity<T>> {
QueryableList<T> orderByAsc(OrderByPredicate<T> predicate); QueryableList<T> orderByAsc(OrderByPredicate<T> predicate);
QueryableList<T> orderByDesc(OrderByPredicate<T> predicate); QueryableList<T> orderByDesc(OrderByPredicate<T> predicate);
QueryableList<T> setHints(Set<String> hints); QueryableList<T> setHints(Set<String> hints);
void withHint(String hint); QueryableList<T> withHint(String hint);
Long count(); Long count();
} }

View File

@ -40,8 +40,9 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
return this; return this;
} }
public void withHint(String hint) { public QueryableList<T> withHint(String hint) {
this.hint = hint; this.hint = hint;
return this;
} }
public QueryableList<T> setHints(Set<String> hints) { public QueryableList<T> setHints(Set<String> hints) {
@ -122,11 +123,20 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
if (this.length != null) typedQuery.setMaxResults(this.length); if (this.length != null) typedQuery.setMaxResults(this.length);
if (this.hint != null && this.hints.contains(hint)) { if (this.hint != null && this.hints.contains(hint)) {
List ids = typedQuery.getResultList().stream().map(item -> item.getKeys()[0]).collect(Collectors.toList()); List ids = typedQuery.getResultList().stream().map(item -> item.getKeys()[0]).collect(Collectors.toList());
typedQuery = queryWithHint(ids); if (ids != null && !ids.isEmpty()) typedQuery = queryWithHint(ids);
} }
return typedQuery.getResultList(); return typedQuery.getResultList();
} }
public T getSingle() {
Predicate[] array = new Predicate[this.predicates.size()];
this.predicates.toArray(array);
this.query.where(array);
TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
return typedQuery.getSingleResult();
}
private TypedQuery<T> queryWithHint(List ids) { private TypedQuery<T> queryWithHint(List ids) {
CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder(); CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder();
CriteriaQuery<T> criteriaQuery = criteriaBuilder.createQuery(tClass); CriteriaQuery<T> criteriaQuery = criteriaBuilder.createQuery(tClass);

View File

@ -14,7 +14,6 @@ database.password=dmpt00lu$r
eu.eudat.proxy.allowed.host=https://eestore.paas2.uninett.no eu.eudat.proxy.allowed.host=https://eestore.paas2.uninett.no
configuration.externalUrls=/classes/ExternalUrls.xml configuration.externalUrls=/classes/ExternalUrls.xml
####################################################### #######################################################
spring.resources.add-mappings=true
########################/Email############################# ########################/Email#############################
spring.mail.default-encoding=UTF-8 spring.mail.default-encoding=UTF-8
spring.mail.host=smtp.gmail.com spring.mail.host=smtp.gmail.com

View File

@ -1,6 +1,6 @@
export const HostConfiguration = { export const HostConfiguration = {
Server: 'http://dl043.madgik.di.uoa.gr:8080/', Server: 'http://localhost:8080/',
App: 'http://dl043.madgik.di.uoa.gr:8080/' App: 'http://localhost:8080/'
//CASHost: 'https://login-devel.uoa.gr/login', //CASHost: 'https://login-devel.uoa.gr/login',
//Service: 'http://elkefinman/login' //Service: 'http://elkefinman/login'
} }

View File

@ -5,15 +5,9 @@
<mat-step [stepControl]="formGroup"> <mat-step [stepControl]="formGroup">
<form *ngIf="formGroup" [formGroup]="formGroup"> <form *ngIf="formGroup" [formGroup]="formGroup">
<ng-template matStepLabel>{{'DATASET-WIZARD.FIRST-STEP.TITLE' | translate}}</ng-template> <ng-template matStepLabel>{{'DATASET-WIZARD.FIRST-STEP.TITLE' | translate}}</ng-template>
<!-- <auto-complete class="mat-form-field-full-width" placeholder="{{'DATASET-WIZARD.FIRST-STEP.DMP' | translate}}" [configuration]="dmpAutoCompleteConfiguration" <mat-form-field formGroupName="profile">
titleKey="label" [control]="formGroup.get('dmp')" [required]="true"> <mat-select placeholder=" {{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" formControlName="id">
</auto-complete> --> <mat-option *ngFor="let profile of availableProfiles" [value]="profile.id">
<!-- <auto-complete class="mat-form-field-full-width" placeholder="{{'DATASET-WIZARD.FIRST-STEP.PROFILE' | translate}}" [configuration]="datasetProfileAutoCompleteConfiguration"
titleKey="label" [control]="formGroup.get('profile')" [required]="true" [disabled]="!formGroup.get('dmp').value">
</auto-complete> -->
<mat-form-field>
<mat-select placeholder=" {{'DATASET-WIZARD.FIRST-STEP.PROFILE'| translate}}" formControlName="profile">
<mat-option *ngFor="let profile of availableProfiles" [value]="profile">
{{profile.label}} {{profile.label}}
</mat-option> </mat-option>
</mat-select> </mat-select>
@ -98,6 +92,4 @@
</div> </div>
</mat-step> </mat-step>
</mat-horizontal-stepper> </mat-horizontal-stepper>
<!-- <div *ngIf="formGroup"> {{ formGroup.value | json }}</div> -->
</div> </div>

View File

@ -107,7 +107,7 @@ export class DatasetWizardComponent implements AfterViewInit {
datasetProfileRequestItem.criteria = new DatasetProfileCriteria(); datasetProfileRequestItem.criteria = new DatasetProfileCriteria();
datasetProfileRequestItem.criteria.id = this.datasetWizardModel.dmp.id; datasetProfileRequestItem.criteria.id = this.datasetWizardModel.dmp.id;
this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem).subscribe(items => { this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem).subscribe(items => {
this.availableProfiles = items; this.availableProfiles = JsonSerializer.fromJSONArray(items, DatasetProfileModel);
}); });
} }
ngAfterViewInit() { ngAfterViewInit() {

View File

@ -7,19 +7,18 @@ import { Serializable } from "../Serializable";
export class DatasetProfileModel implements Serializable<DatasetProfileModel> { export class DatasetProfileModel implements Serializable<DatasetProfileModel> {
public id: String; public id: String;
public label: String; public label: String;
public errorModel: BaseErrorModel = new BaseErrorModel();
fromJSONObject(item: any): DatasetProfileModel { fromJSONObject(item: any): DatasetProfileModel {
this.id = item.id; this.id = item.id;
this.label = item.label; this.label = item.label;
return this; return this;
} }
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup { buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
if (context == null) { context = this.createValidationContext(); } if (context == null) { context = this.createValidationContext(); }
const formGroup = new FormBuilder().group({ const formGroup = new FormBuilder().group({
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators] id: [{ value: this.id, disabled: disabled }],
}); });
return formGroup; return formGroup;
@ -27,7 +26,7 @@ export class DatasetProfileModel implements Serializable<DatasetProfileModel> {
createValidationContext(): ValidationContext { createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext(); const baseContext: ValidationContext = new ValidationContext();
baseContext.validation.push({ key: 'id', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'id')] }); //baseContext.validation.push({ key: 'id', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'id')] });
return baseContext; return baseContext;
} }
} }

View File

@ -16,7 +16,7 @@ import { ExternalDatasetModel } from '@app/models/external-dataset/ExternalDatas
export class DatasetWizardModel implements Serializable<DatasetWizardModel> { export class DatasetWizardModel implements Serializable<DatasetWizardModel> {
public id: String; public id: String;
public label: String; public label: String;
public profile: DatasetProfileModel = new DatasetProfileModel; public profile: DatasetProfileModel = new DatasetProfileModel();
public uri: String; public uri: String;
public status: String; public status: String;
public description: String; public description: String;
@ -39,7 +39,7 @@ export class DatasetWizardModel implements Serializable<DatasetWizardModel> {
this.registries = JsonSerializer.fromJSONArray(item.registries, RegisterModel); this.registries = JsonSerializer.fromJSONArray(item.registries, RegisterModel);
this.dataRepositories = JsonSerializer.fromJSONArray(item.dataRepositories, DataRepositoryModel); this.dataRepositories = JsonSerializer.fromJSONArray(item.dataRepositories, DataRepositoryModel);
this.dmp = JsonSerializer.fromJSONObject(item.dmp, DataManagementPlanModel); this.dmp = JsonSerializer.fromJSONObject(item.dmp, DataManagementPlanModel);
this.profile = JsonSerializer.fromJSONObject(item.profile, DatasetWizardModel); this.profile = JsonSerializer.fromJSONObject(item.profile, DatasetProfileModel);
this.datasetProfileDefinition = JsonSerializer.fromJSONObject(item.datasetProfileDefinition, DatasetProfileDefinitionModel); this.datasetProfileDefinition = JsonSerializer.fromJSONObject(item.datasetProfileDefinition, DatasetProfileDefinitionModel);
return this; return this;
} }
@ -57,9 +57,9 @@ export class DatasetWizardModel implements Serializable<DatasetWizardModel> {
dataRepositories: [{ value: this.dataRepositories, disabled: disabled }, context.getValidation('dataRepositories').validators], dataRepositories: [{ value: this.dataRepositories, disabled: disabled }, context.getValidation('dataRepositories').validators],
externalDatasets: [{ value: this.externalDatasets, disabled: disabled }, context.getValidation('externalDatasets').validators], externalDatasets: [{ value: this.externalDatasets, disabled: disabled }, context.getValidation('externalDatasets').validators],
dmp: [{ value: this.dmp, disabled: disabled }, context.getValidation('dmp').validators], dmp: [{ value: this.dmp, disabled: disabled }, context.getValidation('dmp').validators],
profile: [{ value: this.profile, disabled: disabled }, context.getValidation('profile').validators],
}); });
formGroup.addControl("profile",this.profile.buildForm())
return formGroup; return formGroup;
} }