Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring
This commit is contained in:
commit
f6cc76a360
|
@ -2,13 +2,12 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.core.logger.Logger;
|
import eu.eudat.core.logger.Logger;
|
||||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||||
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
|
import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption;
|
||||||
import eu.eudat.logic.managers.AdminManager;
|
import eu.eudat.logic.managers.AdminManager;
|
||||||
import eu.eudat.logic.managers.DatasetProfileManager;
|
import eu.eudat.logic.managers.DatasetProfileManager;
|
||||||
import eu.eudat.logic.managers.UserManager;
|
import eu.eudat.logic.managers.UserManager;
|
||||||
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.helpers.LoggerService;
|
|
||||||
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
|
@ -20,9 +19,12 @@ 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.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static eu.eudat.types.Authorities.ADMIN;
|
import static eu.eudat.types.Authorities.ADMIN;
|
||||||
|
@ -35,7 +37,7 @@ public class Admin extends BaseController {
|
||||||
DatasetProfileManager datasetProfileManager;
|
DatasetProfileManager datasetProfileManager;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public Admin(ApiContext apiContext,DatasetProfileManager datasetProfileManager, Logger logger) {
|
public Admin(ApiContext apiContext, DatasetProfileManager datasetProfileManager, Logger logger) {
|
||||||
super(apiContext);
|
super(apiContext);
|
||||||
this.datasetProfileManager = datasetProfileManager;
|
this.datasetProfileManager = datasetProfileManager;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +46,8 @@ public class Admin extends BaseController {
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp"}, consumes = "application/json", produces = "application/json")
|
||||||
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
public ResponseEntity<Object> addDmp(@Valid @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||||
//this.getLoggerService().info(principal, "Admin Added Dataset Profile");
|
//this.getLoggerService().info(principal, "Admin Added Dataset Profile");
|
||||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
DatasetProfile shortenProfile = profile.toShort();
|
||||||
|
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
||||||
this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
||||||
}
|
}
|
||||||
|
@ -52,7 +55,8 @@ public class Admin extends BaseController {
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/addDmp/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
public ResponseEntity<ResponseItem<UUID>> updateDmp(@PathVariable String id, @RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
DatasetProfile shortenProfile = profile.toShort();
|
||||||
|
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(shortenProfile, getApiContext());
|
||||||
eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
eu.eudat.data.entities.DatasetProfile datasetprofile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||||
datasetprofile.setDefinition(modelDefinition.getDefinition());
|
datasetprofile.setDefinition(modelDefinition.getDefinition());
|
||||||
datasetprofile.setStatus(modelDefinition.getStatus());
|
datasetprofile.setStatus(modelDefinition.getStatus());
|
||||||
|
@ -77,7 +81,7 @@ public class Admin extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/preview"}, consumes = "application/json",produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/preview"}, consumes = "application/json", produces = "application/json")
|
||||||
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
||||||
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = UserManager.generateDatasetProfileModel(modelDefinition);
|
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = UserManager.generateDatasetProfileModel(modelDefinition);
|
||||||
|
@ -88,22 +92,48 @@ public class Admin extends BaseController {
|
||||||
|
|
||||||
@org.springframework.transaction.annotation.Transactional
|
@org.springframework.transaction.annotation.Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public ResponseEntity<ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN})Principal principal) {
|
public ResponseEntity<ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||||
eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(this.getApiContext(), id);
|
eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(this.getApiContext(), id);
|
||||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||||
datasetprofile.setLabel(profile.getLabel() + " new ");
|
datasetprofile.setLabel(profile.getLabel() + " new ");
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DatasetProfile>> inactivate(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
ResponseEntity<ResponseItem<DatasetProfile>> inactivate(@PathVariable String id, Principal principal){
|
||||||
try{
|
try {
|
||||||
eu.eudat.data.entities.DatasetProfile ret= AdminManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(),this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao() , id);
|
eu.eudat.data.entities.DatasetProfile ret = AdminManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
}catch (DMPWithDatasetsDeleteException exception) {
|
} catch (DatasetProfileWithDatasetsExeption exception) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.UNSUCCESS_DELETE).message(exception.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
|
||||||
|
public ResponseEntity getDatasetProfileXml(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException, IOException, InstantiationException {
|
||||||
|
if (contentType.equals("application/xml")) {
|
||||||
|
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||||
|
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = UserManager.generateDatasetProfileModel(profile);
|
||||||
|
datasetProfile.setStatus(profile.getStatus());
|
||||||
|
return this.datasetProfileManager.getDocument(datasetProfile, profile.getLabel());
|
||||||
|
} else {
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||||
|
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
||||||
|
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException, IOException {
|
||||||
|
eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile datasetProfileModel = this.datasetProfileManager.createDatasetProfileFromXml(file);
|
||||||
|
eu.eudat.models.data.admin.composite.DatasetProfile datasetProfileEntity = datasetProfileModel.toAdminCompositeModel(file.getOriginalFilename());
|
||||||
|
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext());
|
||||||
|
this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>()
|
||||||
|
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,9 @@ package eu.eudat.controllers;
|
||||||
import eu.eudat.data.entities.DMPProfile;
|
import eu.eudat.data.entities.DMPProfile;
|
||||||
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
|
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
|
||||||
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
||||||
|
import eu.eudat.logic.managers.AdminManager;
|
||||||
import eu.eudat.logic.managers.DataManagementProfileManager;
|
import eu.eudat.logic.managers.DataManagementProfileManager;
|
||||||
|
import eu.eudat.logic.security.claims.ClaimedAuthorities;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
|
@ -15,10 +17,14 @@ import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static eu.eudat.types.Authorities.ADMIN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 3/21/2018.
|
* Created by ikalyvas on 3/21/2018.
|
||||||
*/
|
*/
|
||||||
|
@ -56,4 +62,26 @@ public class DMPProfileController extends BaseController {
|
||||||
DataTableData<DataManagementPlanProfileListingModel> dataTable = this.dataManagementProfileManager.getPaged(this.getApiContext(), dataManagementPlanProfileTableRequest, principal);
|
DataTableData<DataManagementPlanProfileListingModel> dataTable = this.dataManagementProfileManager.getPaged(this.getApiContext(), dataManagementPlanProfileTableRequest, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = {"/getXml/{id}"}, produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity getXml( @RequestHeader("Content-Type") String contentType, @PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException, IOException {
|
||||||
|
if (contentType.equals("application/xml")) {
|
||||||
|
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpProfileDao(), id, principal);
|
||||||
|
return this.dataManagementProfileManager.getDocument(dataManagementPlanProfileListingModel,dataManagementPlanProfileListingModel.getLabel());
|
||||||
|
}else {
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||||
|
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
||||||
|
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException,IOException,Exception{
|
||||||
|
eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile dmpProfileModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
|
||||||
|
DataManagementPlanProfileListingModel dataManagementPlan = dmpProfileModel.toDmpProfileCompositeModel(file.getOriginalFilename());
|
||||||
|
this.dataManagementProfileManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>()
|
||||||
|
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package eu.eudat.exceptions.datasetprofile;
|
||||||
|
|
||||||
|
public class DatasetProfileWithDatasetsExeption extends RuntimeException {
|
||||||
|
|
||||||
|
public DatasetProfileWithDatasetsExeption() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatasetProfileWithDatasetsExeption(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatasetProfileWithDatasetsExeption(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatasetProfileWithDatasetsExeption(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import eu.eudat.data.dao.entities.DatasetDao;
|
import eu.eudat.data.dao.entities.DatasetDao;
|
||||||
import eu.eudat.data.dao.entities.DatasetProfileDao;
|
import eu.eudat.data.dao.entities.DatasetProfileDao;
|
||||||
|
import eu.eudat.exceptions.datasetprofile.DatasetProfileWithDatasetsExeption;
|
||||||
import eu.eudat.logic.builders.entity.DatasetProfileBuilder;
|
import eu.eudat.logic.builders.entity.DatasetProfileBuilder;
|
||||||
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel;
|
import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel;
|
||||||
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
import eu.eudat.models.data.admin.composite.DatasetProfile;
|
||||||
|
@ -46,13 +47,13 @@ public class AdminManager {
|
||||||
public static eu.eudat.data.entities.DatasetProfile inactivate(DatasetProfileDao datasetProfileRepository, DatasetDao datasetDao, String id) {
|
public static eu.eudat.data.entities.DatasetProfile inactivate(DatasetProfileDao datasetProfileRepository, DatasetDao datasetDao, String id) {
|
||||||
eu.eudat.data.dao.criteria.DatasetCriteria datasetsForThatDatasetProfile = new eu.eudat.data.dao.criteria.DatasetCriteria();
|
eu.eudat.data.dao.criteria.DatasetCriteria datasetsForThatDatasetProfile = new eu.eudat.data.dao.criteria.DatasetCriteria();
|
||||||
datasetsForThatDatasetProfile.setProfileDatasetId(UUID.fromString(id));
|
datasetsForThatDatasetProfile.setProfileDatasetId(UUID.fromString(id));
|
||||||
if ((datasetDao.getWithCriteria(datasetsForThatDatasetProfile).toList()).size() == 0) {
|
if (datasetDao.getWithCriteria(datasetsForThatDatasetProfile).count() == 0) {
|
||||||
eu.eudat.data.entities.DatasetProfile detasetProfile = datasetProfileRepository.find(UUID.fromString(id));
|
eu.eudat.data.entities.DatasetProfile detasetProfile = datasetProfileRepository.find(UUID.fromString(id));
|
||||||
detasetProfile.setStatus(eu.eudat.data.entities.DatasetProfile.Status.DELETED.getValue());
|
detasetProfile.setStatus(eu.eudat.data.entities.DatasetProfile.Status.DELETED.getValue());
|
||||||
detasetProfile = datasetProfileRepository.createOrUpdate(detasetProfile);
|
detasetProfile = datasetProfileRepository.createOrUpdate(detasetProfile);
|
||||||
return detasetProfile;
|
return detasetProfile;
|
||||||
|
} else {
|
||||||
|
throw new DatasetProfileWithDatasetsExeption("This profile can not deleted, because Datasets are associated with it");
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
|
@ -4,17 +4,27 @@ import eu.eudat.data.dao.entities.DMPProfileDao;
|
||||||
import eu.eudat.data.entities.DMPProfile;
|
import eu.eudat.data.entities.DMPProfile;
|
||||||
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
|
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
|
||||||
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
||||||
|
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||||
|
import eu.eudat.logic.utilities.documents.xml.dmpXml.ExportXmlBuilderDmpProfile;
|
||||||
|
import eu.eudat.logic.utilities.documents.xml.dmpXml.ImportXmlBuilderDmpProfile;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
|
import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
|
||||||
import eu.eudat.models.data.security.Principal;
|
import eu.eudat.models.data.security.Principal;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.activation.MimetypesFileTypeMap;
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import org.springframework.http.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 3/21/2018.
|
* Created by ikalyvas on 3/21/2018.
|
||||||
*/
|
*/
|
||||||
|
@ -57,4 +67,57 @@ public class DataManagementProfileManager {
|
||||||
DMPProfile dmpProfile = dataManagementPlanProfileListingModel.toDataModel();
|
DMPProfile dmpProfile = dataManagementPlanProfileListingModel.toDataModel();
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
|
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public ResponseEntity<byte[]> getDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
|
||||||
|
|
||||||
|
|
||||||
|
FileEnvelope envelope = getXmlDocument(dmpProfile, label);
|
||||||
|
InputStream resource = new FileInputStream(envelope.getFile());
|
||||||
|
System.out.println("Mime Type of " + envelope.getFilename() + " is " +
|
||||||
|
new MimetypesFileTypeMap().getContentType(envelope.getFile()));
|
||||||
|
HttpHeaders responseHeaders = new HttpHeaders();
|
||||||
|
responseHeaders.setContentLength(envelope.getFile().length());
|
||||||
|
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
responseHeaders.set("Content-Disposition", "attachment;filename=" + envelope.getFilename() + ".xml");
|
||||||
|
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
|
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
|
||||||
|
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
|
||||||
|
resource.close();
|
||||||
|
Files.deleteIfExists(envelope.getFile().toPath());
|
||||||
|
return new ResponseEntity<>(content,
|
||||||
|
responseHeaders,
|
||||||
|
HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileEnvelope getXmlDocument(DataManagementPlanProfileListingModel dmpProfile, String label) throws InstantiationException, IllegalAccessException, IOException {
|
||||||
|
ExportXmlBuilderDmpProfile xmlBuilder = new ExportXmlBuilderDmpProfile();
|
||||||
|
File file = xmlBuilder.build(dmpProfile);
|
||||||
|
FileEnvelope fileEnvelope = new FileEnvelope();
|
||||||
|
fileEnvelope.setFile(file);
|
||||||
|
fileEnvelope.setFilename(label);
|
||||||
|
return fileEnvelope;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile createDmpProfileFromXml(MultipartFile multiPartFile) {
|
||||||
|
ImportXmlBuilderDmpProfile xmlBuilder = new ImportXmlBuilderDmpProfile();
|
||||||
|
try {
|
||||||
|
return xmlBuilder.build(convert(multiPartFile));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File convert(MultipartFile file) throws IOException {
|
||||||
|
File convFile = new File(file.getOriginalFilename());
|
||||||
|
convFile.createNewFile();
|
||||||
|
FileOutputStream fos = new FileOutputStream(convFile);
|
||||||
|
fos.write(file.getBytes());
|
||||||
|
fos.close();
|
||||||
|
return convFile;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@ import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequest
|
||||||
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
|
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||||
|
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile;
|
||||||
|
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ImportXmlBuilderDatasetProfile;
|
||||||
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
import eu.eudat.models.data.components.commons.datafield.AutoCompleteData;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileAutocompleteItem;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileListingModel;
|
||||||
|
@ -20,12 +23,19 @@ import eu.eudat.queryable.QueryableList;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import javax.activation.MimetypesFileTypeMap;
|
||||||
import javax.xml.xpath.*;
|
import javax.xml.xpath.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DatasetProfileManager {
|
public class DatasetProfileManager {
|
||||||
|
|
||||||
|
@ -36,7 +46,7 @@ public class DatasetProfileManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetProfile clone(ApiContext apiContext, String id) {
|
public DatasetProfile clone(ApiContext apiContext, String id) {
|
||||||
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(profile);
|
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(profile);
|
||||||
profile.setId(null);
|
profile.setId(null);
|
||||||
return profile;
|
return profile;
|
||||||
|
@ -83,4 +93,57 @@ public class DatasetProfileManager {
|
||||||
jsonItems.forEach(item -> result.add(new Tuple<>(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()))));
|
jsonItems.forEach(item -> result.add(new Tuple<>(item.get(data.getAutoCompleteOptions().getValue()), item.get(data.getAutoCompleteOptions().getLabel()))));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ResponseEntity<byte[]> getDocument(eu.eudat.models.data.user.composite.DatasetProfile datasetProfile, String label) throws IllegalAccessException, IOException, InstantiationException {
|
||||||
|
|
||||||
|
|
||||||
|
FileEnvelope envelope = getXmlDocument(datasetProfile, label);
|
||||||
|
InputStream resource = new FileInputStream(envelope.getFile());
|
||||||
|
System.out.println("Mime Type of " + envelope.getFilename() + " is " +
|
||||||
|
new MimetypesFileTypeMap().getContentType(envelope.getFile()));
|
||||||
|
HttpHeaders responseHeaders = new HttpHeaders();
|
||||||
|
responseHeaders.setContentLength(envelope.getFile().length());
|
||||||
|
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
responseHeaders.set("Content-Disposition", "attachment;filename=" + envelope.getFilename() + ".xml");
|
||||||
|
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
|
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
|
||||||
|
|
||||||
|
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
|
||||||
|
resource.close();
|
||||||
|
Files.deleteIfExists(envelope.getFile().toPath());
|
||||||
|
|
||||||
|
return new ResponseEntity<>(content,
|
||||||
|
responseHeaders,
|
||||||
|
HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileEnvelope getXmlDocument(eu.eudat.models.data.user.composite.DatasetProfile datatasetProfile, String label) throws InstantiationException, IllegalAccessException, IOException {
|
||||||
|
ExportXmlBuilderDatasetProfile xmlBuilder = new ExportXmlBuilderDatasetProfile();
|
||||||
|
File file = xmlBuilder.build(datatasetProfile);
|
||||||
|
FileEnvelope fileEnvelope = new FileEnvelope();
|
||||||
|
fileEnvelope.setFile(file);
|
||||||
|
fileEnvelope.setFilename(label);
|
||||||
|
return fileEnvelope;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile createDatasetProfileFromXml(MultipartFile multiPartFile) {
|
||||||
|
ImportXmlBuilderDatasetProfile xmlBuilder = new ImportXmlBuilderDatasetProfile();
|
||||||
|
try {
|
||||||
|
return xmlBuilder.build(convert(multiPartFile));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File convert(MultipartFile file) throws IOException {
|
||||||
|
File convFile = new File(file.getOriginalFilename());
|
||||||
|
convFile.createNewFile();
|
||||||
|
FileOutputStream fos = new FileOutputStream(convFile);
|
||||||
|
fos.write(file.getBytes());
|
||||||
|
fos.close();
|
||||||
|
return convFile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class ModelBuilder {
|
||||||
if (type.equals("checkBox")) return (FieldData<U>) new CheckBoxData().fromData(data);
|
if (type.equals("checkBox")) return (FieldData<U>) new CheckBoxData().fromData(data);
|
||||||
if (type.equals("freetext")) return (FieldData<U>) new FreeTextData().fromData(data);
|
if (type.equals("freetext")) return (FieldData<U>) new FreeTextData().fromData(data);
|
||||||
if (type.equals("textarea")) return (FieldData<U>) new TextAreaData().fromData(data);
|
if (type.equals("textarea")) return (FieldData<U>) new TextAreaData().fromData(data);
|
||||||
if (type.equals("datePicker")) return (FieldData<U>) new DataPickerData().fromData(data);
|
if (type.equals("datePicker")) return (FieldData<U>) new DatePickerData().fromData(data);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class ModelBuilder {
|
||||||
if (type.equals("checkBox")) return (FieldData<U>) new CheckBoxData().fromData(data);
|
if (type.equals("checkBox")) return (FieldData<U>) new CheckBoxData().fromData(data);
|
||||||
if (type.equals("freetext")) return (FieldData<U>) new FreeTextData().fromData(data);
|
if (type.equals("freetext")) return (FieldData<U>) new FreeTextData().fromData(data);
|
||||||
if (type.equals("textarea")) return (FieldData<U>) new TextAreaData().fromData(data);
|
if (type.equals("textarea")) return (FieldData<U>) new TextAreaData().fromData(data);
|
||||||
if (type.equals("datePicker")) return (FieldData<U>) new DataPickerData().fromData(data);
|
if (type.equals("datePicker")) return (FieldData<U>) new DatePickerData().fromData(data);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,259 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.models.data.admin.components.datasetprofile.Page;
|
||||||
|
import eu.eudat.models.data.components.commons.datafield.*;
|
||||||
|
import eu.eudat.models.data.user.components.datasetprofile.Field;
|
||||||
|
import eu.eudat.models.data.user.components.datasetprofile.FieldSet;
|
||||||
|
import eu.eudat.models.data.user.components.datasetprofile.Section;
|
||||||
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
|
public class ExportXmlBuilderDatasetProfile {
|
||||||
|
|
||||||
|
|
||||||
|
public File build(eu.eudat.models.data.user.composite.DatasetProfile datasetProfile) throws IOException {
|
||||||
|
|
||||||
|
File xmlFile = new File(UUID.randomUUID() + ".xml");
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile, true));
|
||||||
|
Document xmlDoc = XmlBuilder.getDocument();
|
||||||
|
// Element root = xmlDoc.createElement("root");
|
||||||
|
// root.appendChild(createPages(datasetProfile.getPages(), datasetProfile.getSections(), xmlDoc));
|
||||||
|
|
||||||
|
xmlDoc.appendChild(createPages(datasetProfile.getPages(), datasetProfile.getSections(), xmlDoc));
|
||||||
|
String xml = XmlBuilder.generateXml(xmlDoc);
|
||||||
|
writer.write(xml);
|
||||||
|
writer.close();
|
||||||
|
return xmlFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Element createPages(List<Page> datasetProfilePages, List<Section> sections, Document element) {
|
||||||
|
Element pages = element.createElement("pages");
|
||||||
|
datasetProfilePages.forEach(item -> {
|
||||||
|
Element page = element.createElement("page");
|
||||||
|
page.setAttribute("id", "" + item.getId());
|
||||||
|
page.setAttribute("ordinal", "" + item.getOrdinal());
|
||||||
|
page.setAttribute("title", "" + item.getTitle());
|
||||||
|
sections.forEach(sectionFromLis -> {
|
||||||
|
if (sectionFromLis.getPage().equals(item.getId())) {
|
||||||
|
Element elementSections = element.createElement("sections");
|
||||||
|
page.appendChild(createSections(sectionFromLis, element, elementSections));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pages.appendChild(page);
|
||||||
|
});
|
||||||
|
return pages;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Element createSections(Section sections, Document element, Element elementSections) {
|
||||||
|
// if (sections.getSections() != null) {
|
||||||
|
sections.getSections().forEach(sectionFor -> {
|
||||||
|
Element elementSectionsChild = element.createElement("section");
|
||||||
|
elementSections.appendChild(createSections(sectionFor, element, elementSectionsChild));
|
||||||
|
});
|
||||||
|
// }
|
||||||
|
|
||||||
|
elementSections.setAttribute("defaultVisibility", "" + sections.getDefaultVisibility());
|
||||||
|
elementSections.setAttribute("id", "" + sections.getId());
|
||||||
|
elementSections.setAttribute("ordinal", "" + sections.getOrdinal());
|
||||||
|
elementSections.setAttribute("page", "" + sections.getPage());
|
||||||
|
elementSections.setAttribute("page", "" + sections.getPage());
|
||||||
|
|
||||||
|
if (sections.getCompositeFields() != null) {
|
||||||
|
elementSections.appendChild(createFieldSet(sections.getCompositeFields(), element));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sections.getNumbering() != null) {
|
||||||
|
Element numbering = element.createElement("numbering");
|
||||||
|
numbering.setTextContent(sections.getNumbering());
|
||||||
|
elementSections.appendChild(numbering);
|
||||||
|
}
|
||||||
|
if (sections.getDescription() != null) {
|
||||||
|
Element description = element.createElement("description");
|
||||||
|
description.setTextContent(sections.getDescription());
|
||||||
|
elementSections.appendChild(description);
|
||||||
|
}
|
||||||
|
if (sections.getTitle() != null) {
|
||||||
|
Element title = element.createElement("title");
|
||||||
|
title.setTextContent(sections.getTitle());
|
||||||
|
elementSections.appendChild(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
return elementSections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Element createFieldSet(List<FieldSet> fieldSet, Document element) {
|
||||||
|
Element elementFieldSets = element.createElement("field-Sets");
|
||||||
|
fieldSet.forEach(field -> {
|
||||||
|
Element composite = element.createElement("field-Set");
|
||||||
|
composite.setAttribute("id", field.getId());
|
||||||
|
composite.setAttribute("ordinal", "" + field.getOrdinal());
|
||||||
|
|
||||||
|
if (field.getNumbering() != null) {
|
||||||
|
Element numbering = element.createElement("numbering");
|
||||||
|
numbering.setTextContent(field.getNumbering());
|
||||||
|
composite.appendChild(numbering);
|
||||||
|
}
|
||||||
|
Element commentField = element.createElement("CommentField");
|
||||||
|
commentField.setTextContent("" + field.getHasCommentField());
|
||||||
|
composite.appendChild(commentField);
|
||||||
|
|
||||||
|
composite.appendChild(createFields(field.getFields(), element));
|
||||||
|
|
||||||
|
if (field.getMultiplicity() != null) {
|
||||||
|
Element multiplicity = element.createElement("multiplicity");
|
||||||
|
multiplicity.setAttribute("max", "" + field.getMultiplicity().getMax());
|
||||||
|
multiplicity.setAttribute("min", "" + field.getMultiplicity().getMin());
|
||||||
|
composite.appendChild(multiplicity);
|
||||||
|
}
|
||||||
|
if (field.getTitle() != null && !field.getTitle().isEmpty()) {
|
||||||
|
Element title = element.createElement("title");
|
||||||
|
title.setTextContent(field.getTitle());
|
||||||
|
composite.appendChild(title);
|
||||||
|
}
|
||||||
|
if (field.getDescription() != null && !field.getDescription().isEmpty()) {
|
||||||
|
Element title = element.createElement("description");
|
||||||
|
title.setTextContent(field.getDescription());
|
||||||
|
composite.appendChild(title);
|
||||||
|
}
|
||||||
|
if (field.getExtendedDescription() != null && !field.getExtendedDescription().isEmpty()) {
|
||||||
|
Element extendedDescription = element.createElement("extendedDescription");
|
||||||
|
extendedDescription.setTextContent(field.getExtendedDescription());
|
||||||
|
composite.appendChild(extendedDescription);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
elementFieldSets.appendChild(composite);
|
||||||
|
});
|
||||||
|
return elementFieldSets;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Element createFields(List<Field> fields, Document element) {
|
||||||
|
Element elementFields = element.createElement("fields");
|
||||||
|
fields.forEach(field -> {
|
||||||
|
Element elementField = element.createElement("field");
|
||||||
|
elementField.setAttribute("id", field.getId());
|
||||||
|
elementField.setAttribute("ordinal", "" + field.getOrdinal());
|
||||||
|
|
||||||
|
if (field.getNumbering() != null) {
|
||||||
|
Element numbering = element.createElement("numbering");
|
||||||
|
numbering.setTextContent(field.getNumbering());
|
||||||
|
elementField.appendChild(numbering);
|
||||||
|
}
|
||||||
|
if (field.getValidations() != null) {
|
||||||
|
Element validations = element.createElement("validations");
|
||||||
|
field.getValidations().forEach(validation -> {
|
||||||
|
Element validationChild = element.createElement("validation");
|
||||||
|
validationChild.setAttribute("type", "" + validation);
|
||||||
|
validations.appendChild(validationChild);
|
||||||
|
});
|
||||||
|
elementField.appendChild(validations);
|
||||||
|
}
|
||||||
|
if (field.getDefaultValue() != null) {
|
||||||
|
Element defaultValue = element.createElement("defaultValue");
|
||||||
|
defaultValue.setAttribute("type", field.getDefaultValue().getType());
|
||||||
|
defaultValue.setAttribute("value", field.getDefaultValue().getValue());
|
||||||
|
elementField.appendChild(defaultValue);
|
||||||
|
}
|
||||||
|
if (field.getVisible() != null) {
|
||||||
|
Element visible = element.createElement("visible");
|
||||||
|
visible.setAttribute("style", "" + field.getVisible().getStyle());
|
||||||
|
field.getVisible().getRules().forEach(rule -> {
|
||||||
|
Element ruleChild = element.createElement("rule");
|
||||||
|
ruleChild.setAttribute("ruleStyle", "" + rule.getRuleStyle());
|
||||||
|
ruleChild.setAttribute("target", "" + rule.getTarget());
|
||||||
|
ruleChild.setAttribute("type", "" + rule.getRuleType());
|
||||||
|
Element ruleChildValue = element.createElement("value");
|
||||||
|
ruleChildValue.setAttribute("type", "" + rule.getValueType());
|
||||||
|
ruleChildValue.setTextContent(rule.getValue());
|
||||||
|
ruleChild.appendChild(ruleChildValue);
|
||||||
|
visible.appendChild(ruleChild);
|
||||||
|
|
||||||
|
});
|
||||||
|
elementField.appendChild(visible);
|
||||||
|
}
|
||||||
|
if (field.getViewStyle() != null) {
|
||||||
|
Element viewStyle = element.createElement("viewStyle");
|
||||||
|
viewStyle.setAttribute("cssClass", field.getViewStyle().getCssClass());
|
||||||
|
viewStyle.setAttribute("renderStyle", field.getViewStyle().getRenderStyle());
|
||||||
|
elementField.appendChild(viewStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (field.getData() != null) {
|
||||||
|
Element dataOut = element.createElement("data");
|
||||||
|
if (field.getViewStyle().getRenderStyle().equals("combobox")) {
|
||||||
|
ComboBoxData comboBoxDataObject = (ComboBoxData) field.getData();
|
||||||
|
if (comboBoxDataObject.getType().equals("wordlist")) {
|
||||||
|
WordListData wordListDataObject = (WordListData) field.getData();
|
||||||
|
dataOut.setAttribute("label", wordListDataObject.getLabel());
|
||||||
|
dataOut.setAttribute("type", wordListDataObject.getType());
|
||||||
|
Element options = element.createElement("options");
|
||||||
|
wordListDataObject.getOptions().forEach(optionChildFor -> {
|
||||||
|
Element optionChild = element.createElement("option");
|
||||||
|
optionChild.setAttribute("label", optionChildFor.getLabel());
|
||||||
|
optionChild.setAttribute("value", optionChildFor.getValue());
|
||||||
|
options.appendChild(optionChild);
|
||||||
|
});
|
||||||
|
dataOut.appendChild(options);
|
||||||
|
} else if (comboBoxDataObject.getType().equals("autocomplete")) {
|
||||||
|
AutoCompleteData autoCompleteDataObject = (AutoCompleteData) field.getData();
|
||||||
|
dataOut.setAttribute("label", autoCompleteDataObject.getLabel());
|
||||||
|
dataOut.setAttribute("type", autoCompleteDataObject.getType());
|
||||||
|
dataOut.setAttribute("optionsRoot", autoCompleteDataObject.getOptionsRoot());
|
||||||
|
dataOut.setAttribute("url", autoCompleteDataObject.getUrl());
|
||||||
|
if (autoCompleteDataObject.getAutoCompleteOptions() != null) {
|
||||||
|
Element optionChild = element.createElement("option");
|
||||||
|
optionChild.setAttribute("label", autoCompleteDataObject.getAutoCompleteOptions().getLabel());
|
||||||
|
optionChild.setAttribute("value", autoCompleteDataObject.getAutoCompleteOptions().getValue());
|
||||||
|
dataOut.appendChild(optionChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (field.getViewStyle().getRenderStyle().equals("booleanDecision")) {
|
||||||
|
BooleanDecisionData booleanDecisionDataObject = (BooleanDecisionData) field.getData();
|
||||||
|
dataOut.setAttribute("label", booleanDecisionDataObject.getLabel());
|
||||||
|
} else if (field.getViewStyle().getRenderStyle().equals("radiobox")) {
|
||||||
|
RadioBoxData radioBoxDataObject = (RadioBoxData) field.getData();
|
||||||
|
dataOut.setAttribute("label", radioBoxDataObject.getLabel());
|
||||||
|
|
||||||
|
Element options = element.createElement("options");
|
||||||
|
radioBoxDataObject.getOptions().forEach(optionChildFor -> {
|
||||||
|
Element optionChild = element.createElement("option");
|
||||||
|
optionChild.setAttribute("label", optionChildFor.getLabel());
|
||||||
|
optionChild.setAttribute("value", optionChildFor.getValue());
|
||||||
|
options.appendChild(optionChild);
|
||||||
|
});
|
||||||
|
dataOut.appendChild(options);
|
||||||
|
} else if (field.getViewStyle().getRenderStyle().equals("checkBox")) {
|
||||||
|
CheckBoxData checkBoxDataObject = (CheckBoxData) field.getData();
|
||||||
|
dataOut.setAttribute("label", checkBoxDataObject.getLabel());
|
||||||
|
} else if (field.getViewStyle().getRenderStyle().equals("freetext")) {
|
||||||
|
FreeTextData freeTextDataObject = (FreeTextData) field.getData();
|
||||||
|
dataOut.setAttribute("label", freeTextDataObject.getLabel());
|
||||||
|
} else if (field.getViewStyle().getRenderStyle().equals("textarea")) {
|
||||||
|
TextAreaData textAreaDataObject = (TextAreaData) field.getData();
|
||||||
|
dataOut.setAttribute("label", textAreaDataObject.getLabel());
|
||||||
|
} else if (field.getViewStyle().getRenderStyle().equals("datePicker")) {
|
||||||
|
DatePickerData datePickerDataObject = (DatePickerData) field.getData();
|
||||||
|
dataOut.setAttribute("label", datePickerDataObject.getLabel());
|
||||||
|
}
|
||||||
|
elementField.appendChild(dataOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
elementFields.appendChild(elementField);
|
||||||
|
});
|
||||||
|
return elementFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml;
|
||||||
|
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBContext;
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
public class ImportXmlBuilderDatasetProfile {
|
||||||
|
|
||||||
|
public DatasetProfile build(File xmlFile) throws IOException {
|
||||||
|
DatasetProfile datasetProfile = new DatasetProfile();
|
||||||
|
JAXBContext jaxbContext = null;
|
||||||
|
try {
|
||||||
|
jaxbContext = JAXBContext.newInstance(DatasetProfile.class);
|
||||||
|
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||||
|
datasetProfile = (DatasetProfile) unmarshaller.unmarshal(xmlFile);
|
||||||
|
} catch (JAXBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return datasetProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,39 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "pages")
|
||||||
|
public class DatasetProfile {
|
||||||
|
|
||||||
|
private List<Page> page;
|
||||||
|
|
||||||
|
@XmlElement(name = "page")
|
||||||
|
public List<Page> getPage() {
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPage(List<Page> page) {
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.admin.composite.DatasetProfile toAdminCompositeModel(String label){
|
||||||
|
eu.eudat.models.data.admin.composite.DatasetProfile newDatasetEntityProfile = new eu.eudat.models.data.admin.composite.DatasetProfile();
|
||||||
|
newDatasetEntityProfile.setLabel(label);
|
||||||
|
newDatasetEntityProfile.setStatus(eu.eudat.data.entities.DatasetProfile.Status.SAVED.getValue());
|
||||||
|
|
||||||
|
List<eu.eudat.models.data.admin.components.datasetprofile.Page> pagesDatasetEntity = new LinkedList<>();
|
||||||
|
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionDatasetEntity = new LinkedList<>();
|
||||||
|
for (Page xmlPage: page) {
|
||||||
|
pagesDatasetEntity.add(xmlPage.toAdminCompositeModelPage());
|
||||||
|
sectionDatasetEntity.add(xmlPage.toAdminCompositeModelSection());
|
||||||
|
}
|
||||||
|
newDatasetEntityProfile.setPages(pagesDatasetEntity);
|
||||||
|
newDatasetEntityProfile.setSections(sectionDatasetEntity);
|
||||||
|
|
||||||
|
return newDatasetEntityProfile;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||||
|
|
||||||
|
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields.Fields;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "field-Set")
|
||||||
|
public class FieldSet {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private int ordinal;
|
||||||
|
private Fields fields;
|
||||||
|
private String numbering;
|
||||||
|
private Boolean commentField;
|
||||||
|
private Multiplicity multiplicity;
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "id")
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "ordinal")
|
||||||
|
public int getOrdinal() {
|
||||||
|
return ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrdinal(int ordinal) {
|
||||||
|
this.ordinal = ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "fields")
|
||||||
|
public Fields getFields() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFields(Fields fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "numbering")
|
||||||
|
public String getNumbering() {
|
||||||
|
return numbering;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumbering(String numbering) {
|
||||||
|
this.numbering = numbering;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "CommentField")
|
||||||
|
public Boolean getCommentField() {
|
||||||
|
return commentField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommentField(Boolean commentField) {
|
||||||
|
this.commentField = commentField;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "multiplicity")
|
||||||
|
public Multiplicity getMultiplicity() {
|
||||||
|
return multiplicity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMultiplicity(Multiplicity multiplicity) {
|
||||||
|
this.multiplicity = multiplicity;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "title")
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.admin.components.datasetprofile.FieldSet toAdminCompositeModelSection() {
|
||||||
|
eu.eudat.models.data.admin.components.datasetprofile.FieldSet fieldSet1Entity = new eu.eudat.models.data.admin.components.datasetprofile.FieldSet();
|
||||||
|
fieldSet1Entity.setId(this.id);
|
||||||
|
fieldSet1Entity.setOrdinal(this.ordinal);
|
||||||
|
fieldSet1Entity.setHasCommentField(this.commentField != null ? this.commentField : false);
|
||||||
|
fieldSet1Entity.setMultiplicity(this.multiplicity != null ? this.multiplicity.toAdminCompositeModelSection() : null);
|
||||||
|
fieldSet1Entity.setTitle(this.title);
|
||||||
|
// List<eu.eudat.models.data.admin.components.datasetprofile.Field> fieldsEntity = new LinkedList<>();
|
||||||
|
//
|
||||||
|
// for (Fields xmlField:this.fields) {
|
||||||
|
// fieldsEntity.add(xmlField.toAdminCompositeModelSection());
|
||||||
|
// }
|
||||||
|
fieldSet1Entity.setFields(this.fields.toAdminCompositeModelSection());
|
||||||
|
return fieldSet1Entity;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "field-Sets")
|
||||||
|
public class FieldSets {
|
||||||
|
|
||||||
|
List<FieldSet> fieldSet;
|
||||||
|
|
||||||
|
@XmlElement(name = "field-Set")
|
||||||
|
public List<FieldSet> getFieldSet() {
|
||||||
|
return fieldSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldSet(List<FieldSet> fieldSet) {
|
||||||
|
this.fieldSet = fieldSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<eu.eudat.models.data.admin.components.datasetprofile.FieldSet> toAdminCompositeModelSection(){
|
||||||
|
List<eu.eudat.models.data.admin.components.datasetprofile.FieldSet> fieldSetEntity = new LinkedList<>();
|
||||||
|
if(this.fieldSet!=null)
|
||||||
|
for (FieldSet xmlFieldSet:this.fieldSet){
|
||||||
|
fieldSetEntity.add(xmlFieldSet.toAdminCompositeModelSection());
|
||||||
|
}
|
||||||
|
return fieldSetEntity;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "defaultValue")
|
||||||
|
public class DefaultValue {
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "type")
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "value")
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.components.commons.DefaultValue toAdminCompositeModelSection(){
|
||||||
|
eu.eudat.models.data.components.commons.DefaultValue defaultValueEntity =new eu.eudat.models.data.components.commons.DefaultValue();
|
||||||
|
defaultValueEntity.setValue(value);
|
||||||
|
defaultValueEntity.setType(type);
|
||||||
|
return defaultValueEntity;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,123 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||||
|
|
||||||
|
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
||||||
|
import eu.eudat.models.data.components.commons.datafield.FieldData;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "field")
|
||||||
|
public class Field {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private int ordinal;
|
||||||
|
|
||||||
|
private String numbering;
|
||||||
|
|
||||||
|
private List<validations> validations;
|
||||||
|
|
||||||
|
private DefaultValue defaultValue;
|
||||||
|
|
||||||
|
private Visible visible;
|
||||||
|
|
||||||
|
private ViewStyle viewStyle;
|
||||||
|
|
||||||
|
private Object data;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "id")
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "ordinal")
|
||||||
|
public int getOrdinal() {
|
||||||
|
return ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrdinal(int ordinal) {
|
||||||
|
this.ordinal = ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "numbering")
|
||||||
|
public String getNumbering() {
|
||||||
|
return numbering;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumbering(String numbering) {
|
||||||
|
this.numbering = numbering;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "validations")
|
||||||
|
public List<eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields.validations> getValidations() {
|
||||||
|
return validations;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValidations(List<eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields.validations> validations) {
|
||||||
|
this.validations = validations;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "defaultValue")
|
||||||
|
public DefaultValue getDefaultValue() {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultValue(DefaultValue defaultValue) {
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "visible")
|
||||||
|
public Visible getVisible() {
|
||||||
|
return visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVisible(Visible visible) {
|
||||||
|
this.visible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "viewStyle")
|
||||||
|
public ViewStyle getViewStyle() {
|
||||||
|
return viewStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setViewStyle(ViewStyle viewStyle) {
|
||||||
|
this.viewStyle = viewStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "data")
|
||||||
|
public Object getData() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(Object data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public eu.eudat.models.data.admin.components.datasetprofile.Field toAdminCompositeModelSection() {
|
||||||
|
eu.eudat.models.data.admin.components.datasetprofile.Field fieldEntity =new eu.eudat.models.data.admin.components.datasetprofile.Field();
|
||||||
|
fieldEntity.setId(this.id);
|
||||||
|
fieldEntity.setOrdinal(this.ordinal);
|
||||||
|
List<Integer> validationList = new LinkedList<>();
|
||||||
|
for(validations validation:this.validations){
|
||||||
|
if(validation.getValidation()!=null)
|
||||||
|
validationList.add(validation.toAdminCompositeModelSection());
|
||||||
|
}
|
||||||
|
fieldEntity.setValidations(validationList);
|
||||||
|
fieldEntity.setDefaultValue(this.defaultValue.toAdminCompositeModelSection());
|
||||||
|
fieldEntity.setVisible(this.visible.toAdminCompositeModelSection());
|
||||||
|
fieldEntity.setViewStyle(this.viewStyle.toAdminCompositeModelSection());
|
||||||
|
FieldData data = new ModelBuilder().toFieldData(null, this.viewStyle.getRenderStyle(), (Element) this.data);
|
||||||
|
// fieldEntity.setData( data.fromXml((Element) this.data));
|
||||||
|
fieldEntity.setData( data.toMap((Element)this.data));
|
||||||
|
return fieldEntity;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "fields")
|
||||||
|
public class Fields {
|
||||||
|
|
||||||
|
private List<Field> field;
|
||||||
|
|
||||||
|
@XmlElement(name = "field")
|
||||||
|
public List<Field> getField() {
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField(List<Field> field) {
|
||||||
|
this.field = field;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<eu.eudat.models.data.admin.components.datasetprofile.Field> toAdminCompositeModelSection() {
|
||||||
|
List<eu.eudat.models.data.admin.components.datasetprofile.Field> fieldsEntity = new LinkedList<>();
|
||||||
|
if (this.field != null)
|
||||||
|
for (Field xmlField : this.field) {
|
||||||
|
fieldsEntity.add(xmlField.toAdminCompositeModelSection());
|
||||||
|
}
|
||||||
|
return fieldsEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "rule")
|
||||||
|
public class Rule{
|
||||||
|
|
||||||
|
private String ruleStyle;
|
||||||
|
private String target;
|
||||||
|
private String type;
|
||||||
|
private Value value;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "ruleStyle")
|
||||||
|
public String getRuleStyle() {
|
||||||
|
return ruleStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRuleStyle(String ruleStyle) {
|
||||||
|
this.ruleStyle = ruleStyle;
|
||||||
|
}
|
||||||
|
@XmlAttribute(name = "target")
|
||||||
|
public String getTarget() {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget(String target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
@XmlAttribute(name = "type")
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
@XmlElement(name = "value")
|
||||||
|
public Value getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(Value value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.components.commons.Rule toAdminCompositeModelSection(){
|
||||||
|
eu.eudat.models.data.components.commons.Rule ruleEntity = new eu.eudat.models.data.components.commons.Rule();
|
||||||
|
ruleEntity.setRuleStyle(ruleStyle);
|
||||||
|
ruleEntity.setTarget(target);
|
||||||
|
ruleEntity.setRuleType(type);
|
||||||
|
ruleEntity.setValueType(value.getType());
|
||||||
|
ruleEntity.setValue(value.getValue());
|
||||||
|
return ruleEntity;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "validation")
|
||||||
|
public class Validation {
|
||||||
|
|
||||||
|
private int type;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "type")
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlValue;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "value")
|
||||||
|
public class Value {
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "type")
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlValue
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "viewStyle")
|
||||||
|
public class ViewStyle {
|
||||||
|
|
||||||
|
private String cssClass;
|
||||||
|
private String renderStyle;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "cssClass")
|
||||||
|
public String getCssClass() {
|
||||||
|
return cssClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCssClass(String cssClass) {
|
||||||
|
this.cssClass = cssClass;
|
||||||
|
}
|
||||||
|
@XmlAttribute(name = "renderStyle")
|
||||||
|
public String getRenderStyle() {
|
||||||
|
return renderStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRenderStyle(String renderStyle) {
|
||||||
|
this.renderStyle = renderStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.components.commons.ViewStyle toAdminCompositeModelSection(){
|
||||||
|
eu.eudat.models.data.components.commons.ViewStyle viewStyleEntity = new eu.eudat.models.data.components.commons.ViewStyle();
|
||||||
|
viewStyleEntity.setCssClass(this.cssClass);
|
||||||
|
viewStyleEntity.setRenderStyle(this.renderStyle);
|
||||||
|
return viewStyleEntity;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "visible")
|
||||||
|
public class Visible {
|
||||||
|
|
||||||
|
private String style;
|
||||||
|
private List<Rule> rule;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "style")
|
||||||
|
public String getStyle() {
|
||||||
|
return style;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStyle(String style) {
|
||||||
|
this.style = style;
|
||||||
|
}
|
||||||
|
@XmlElement(name = "rule")
|
||||||
|
public List<Rule> getRule() {
|
||||||
|
return rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRule(List<Rule> rule) {
|
||||||
|
this.rule = rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.components.commons.Visibility toAdminCompositeModelSection(){
|
||||||
|
eu.eudat.models.data.components.commons.Visibility visibilityEntity = new eu.eudat.models.data.components.commons.Visibility();
|
||||||
|
visibilityEntity.setStyle(this.style);
|
||||||
|
if(this.rule!=null) {
|
||||||
|
List<eu.eudat.models.data.components.commons.Rule> ruleListEntity = new LinkedList<>();
|
||||||
|
for (Rule xmlRule : this.rule) {
|
||||||
|
ruleListEntity.add(xmlRule.toAdminCompositeModelSection());
|
||||||
|
}
|
||||||
|
visibilityEntity.setRules(ruleListEntity);
|
||||||
|
}
|
||||||
|
return visibilityEntity;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.Fields;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "validations")
|
||||||
|
public class validations {
|
||||||
|
|
||||||
|
Validation validation;
|
||||||
|
|
||||||
|
@XmlElement(name = "validation")
|
||||||
|
public Validation getValidation() {
|
||||||
|
return validation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValidation(Validation validation) {
|
||||||
|
this.validation = validation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int toAdminCompositeModelSection() {
|
||||||
|
return validation.getType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
|
||||||
|
@XmlRootElement(name = "multiplicity")
|
||||||
|
public class Multiplicity {
|
||||||
|
private int max;
|
||||||
|
private int min;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "max")
|
||||||
|
public int getMax() {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMax(int max) {
|
||||||
|
this.max = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "min")
|
||||||
|
public int getMin() {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMin(int min) {
|
||||||
|
this.min = min;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.components.commons.Multiplicity toAdminCompositeModelSection() {
|
||||||
|
eu.eudat.models.data.components.commons.Multiplicity multiplicityEntity = new eu.eudat.models.data.components.commons.Multiplicity();
|
||||||
|
multiplicityEntity.setMax(max);
|
||||||
|
multiplicityEntity.setMin(min);
|
||||||
|
return multiplicityEntity;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,73 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "page")
|
||||||
|
public class Page {
|
||||||
|
private String id;
|
||||||
|
private int ordinal;
|
||||||
|
private String title;
|
||||||
|
private Sections sections;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "id")
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "ordinal")
|
||||||
|
public int getOrdinal() {
|
||||||
|
return ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrdinal(int ordinal) {
|
||||||
|
this.ordinal = ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "title")
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "sections")
|
||||||
|
public Sections getSections() {
|
||||||
|
return sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSections(Sections sections) {
|
||||||
|
this.sections = sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.admin.components.datasetprofile.Page toAdminCompositeModelPage(){
|
||||||
|
eu.eudat.models.data.admin.components.datasetprofile.Page pageEntity = new eu.eudat.models.data.admin.components.datasetprofile.Page();
|
||||||
|
pageEntity.setId(this.id);
|
||||||
|
pageEntity.setOrdinal(this.ordinal);
|
||||||
|
pageEntity.setTitle(this.title);
|
||||||
|
return pageEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.admin.components.datasetprofile.Section toAdminCompositeModelSection(){
|
||||||
|
/* eu.eudat.models.data.admin.components.datasetprofile.Section sectionEntity =new eu.eudat.models.data.admin.components.datasetprofile.Section();
|
||||||
|
// List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionsListEntity = new LinkedList<>();
|
||||||
|
// for (Section xmlsection:this.sections.section) {
|
||||||
|
// sectionsListEntity.add(xmlsection.toAdminCompositeModelSection());
|
||||||
|
// }
|
||||||
|
if(this.sections.section!=null)
|
||||||
|
sectionEntity.setSections(this.sections.toAdminCompositeModelSection());
|
||||||
|
if(this.sections.fieldSets.fieldSet!=null)
|
||||||
|
sectionEntity.setFieldSets(this.sections.toAdminCompositeModelSectionFieldSets());
|
||||||
|
sectionEntity.setId(this.id);
|
||||||
|
sectionEntity.setOrdinal(this.ordinal);
|
||||||
|
sectionEntity.setTitle(this.title);*/
|
||||||
|
return sections.toAdminCompositeModelSection();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "section")
|
||||||
|
public class Section {
|
||||||
|
private String id;
|
||||||
|
private int ordinal;
|
||||||
|
private String page;
|
||||||
|
private Boolean defaultVisibility;
|
||||||
|
private FieldSets fieldSets;
|
||||||
|
private String numbering;
|
||||||
|
private String description;
|
||||||
|
private String extendedDescription;
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "id")
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "ordinal")
|
||||||
|
public int getOrdinal() {
|
||||||
|
return ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrdinal(int ordinal) {
|
||||||
|
this.ordinal = ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "page")
|
||||||
|
public String getPage() {
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPage(String page) {
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "defaultVisibility")
|
||||||
|
public Boolean getDefaultVisibility() {
|
||||||
|
return defaultVisibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultVisibility(Boolean defaultVisibility) {
|
||||||
|
this.defaultVisibility = defaultVisibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "field-Sets")
|
||||||
|
public FieldSets getFieldSets() {
|
||||||
|
return fieldSets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldSets(FieldSets fieldSets) {
|
||||||
|
this.fieldSets = fieldSets;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "numbering")
|
||||||
|
public String getNumbering() {
|
||||||
|
return numbering;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumbering(String numbering) {
|
||||||
|
this.numbering = numbering;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "description")
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "extendedDescription")
|
||||||
|
public String getExtendedDescription() {
|
||||||
|
return extendedDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExtendedDescription(String extendedDescription) {
|
||||||
|
this.extendedDescription = extendedDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "title")
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.admin.components.datasetprofile.Section toAdminCompositeModelSection() {
|
||||||
|
eu.eudat.models.data.admin.components.datasetprofile.Section sectionEntity = new eu.eudat.models.data.admin.components.datasetprofile.Section();
|
||||||
|
sectionEntity.setId(this.id);
|
||||||
|
sectionEntity.setOrdinal(this.ordinal);
|
||||||
|
sectionEntity.setTitle(this.title);
|
||||||
|
sectionEntity.setPage(this.page);
|
||||||
|
sectionEntity.setDescription(this.description);
|
||||||
|
// List<eu.eudat.models.data.admin.components.datasetprofile.FieldSet> fieldSetsEntity =new LinkedList<>();
|
||||||
|
//
|
||||||
|
// for (FieldSets xmpFieldSets: this.fieldSets) {
|
||||||
|
// fieldSetsEntity.add(xmpFieldSets.toAdminCompositeModelSection());
|
||||||
|
// }
|
||||||
|
sectionEntity.setFieldSets(this.fieldSets.toAdminCompositeModelSection());
|
||||||
|
sectionEntity.setDefaultVisibility(this.defaultVisibility);
|
||||||
|
return sectionEntity;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,131 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "sections")
|
||||||
|
public class Sections {
|
||||||
|
private String id;
|
||||||
|
private int ordinal;
|
||||||
|
private String page;
|
||||||
|
private Boolean defaultVisibility;
|
||||||
|
private String numbering;
|
||||||
|
private String description;
|
||||||
|
private String title;
|
||||||
|
private List<Section> section;
|
||||||
|
private FieldSets fieldSets;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "id")
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "ordinal")
|
||||||
|
public int getOrdinal() {
|
||||||
|
return ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrdinal(int ordinal) {
|
||||||
|
this.ordinal = ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "page")
|
||||||
|
public String getPage() {
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPage(String page) {
|
||||||
|
this.page = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "defaultVisibility")
|
||||||
|
public Boolean getDefaultVisibility() {
|
||||||
|
return defaultVisibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefaultVisibility(Boolean defaultVisibility) {
|
||||||
|
this.defaultVisibility = defaultVisibility;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "numbering")
|
||||||
|
public String getNumbering() {
|
||||||
|
return numbering;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumbering(String numbering) {
|
||||||
|
this.numbering = numbering;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "description")
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "title")
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "section")
|
||||||
|
public List<Section> getSection() {
|
||||||
|
return section;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSection(List<Section> section) {
|
||||||
|
this.section = section;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "field-Sets")
|
||||||
|
public FieldSets getFieldSets() {
|
||||||
|
return fieldSets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldSets(FieldSets fieldSets) {
|
||||||
|
this.fieldSets = fieldSets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.admin.components.datasetprofile.Section toAdminCompositeModelSection() {
|
||||||
|
eu.eudat.models.data.admin.components.datasetprofile.Section sectionEntity = new eu.eudat.models.data.admin.components.datasetprofile.Section();
|
||||||
|
List<eu.eudat.models.data.admin.components.datasetprofile.Section> sectionsListEntity = new LinkedList<>();
|
||||||
|
|
||||||
|
if (this.section != null) {
|
||||||
|
for (Section xmlsection : this.section) {
|
||||||
|
sectionsListEntity.add(xmlsection.toAdminCompositeModelSection());
|
||||||
|
}
|
||||||
|
} /*else {
|
||||||
|
sectionsListEntity.add(new eu.eudat.models.data.admin.components.datasetprofile.Section());
|
||||||
|
}*/
|
||||||
|
sectionEntity.setId(this.id);
|
||||||
|
sectionEntity.setOrdinal(this.ordinal);
|
||||||
|
sectionEntity.setTitle(this.title);
|
||||||
|
sectionEntity.setDefaultVisibility(this.defaultVisibility);
|
||||||
|
sectionEntity.setDescription(description);
|
||||||
|
sectionEntity.setPage(this.page);
|
||||||
|
sectionEntity.setFieldSets(toAdminCompositeModelSectionFieldSets());
|
||||||
|
|
||||||
|
|
||||||
|
sectionEntity.setSections(sectionsListEntity);
|
||||||
|
return sectionEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<eu.eudat.models.data.admin.components.datasetprofile.FieldSet> toAdminCompositeModelSectionFieldSets() {
|
||||||
|
return fieldSets.toAdminCompositeModelSection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.dmpXml;
|
||||||
|
|
||||||
|
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||||
|
|
||||||
|
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile;
|
||||||
|
import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class ExportXmlBuilderDmpProfile {
|
||||||
|
|
||||||
|
|
||||||
|
public File build(DataManagementPlanProfileListingModel dmpProfile) throws IOException {
|
||||||
|
|
||||||
|
File xmlFile = new File(UUID.randomUUID() + ".xml");
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile, true));
|
||||||
|
Document xmlDoc = XmlBuilder.getDocument();
|
||||||
|
Element root = xmlDoc.createElement("root");
|
||||||
|
Element definition = xmlDoc.createElement("definition");
|
||||||
|
// Element root = xmlDoc.createElement(dmpProfile.getLabel());
|
||||||
|
definition.appendChild(createDefinition(dmpProfile.getDefinition(), xmlDoc));
|
||||||
|
root.appendChild(definition);
|
||||||
|
xmlDoc.appendChild(root);
|
||||||
|
String xml = XmlBuilder.generateXml(xmlDoc);
|
||||||
|
writer.write(xml);
|
||||||
|
writer.close();
|
||||||
|
return xmlFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Element createDefinition(DataManagementPlanProfile dmpDefinition, Document element) {
|
||||||
|
Element fields = element.createElement("fieldSets");
|
||||||
|
dmpDefinition.getFields().forEach(item -> {
|
||||||
|
Element field = element.createElement("field");
|
||||||
|
field.setAttribute("id", "" + item.getId());
|
||||||
|
field.setAttribute("type", "" + item.getType());
|
||||||
|
field.setAttribute("dataType", "" + item.getDataType());
|
||||||
|
field.setAttribute("required", "" + item.getRequired());
|
||||||
|
field.setAttribute("label", "" + item.getLabel());
|
||||||
|
if(item.getValue()!=null) {
|
||||||
|
Element value = element.createElement("value");
|
||||||
|
value.setAttribute("value", ""+item.getValue());
|
||||||
|
field.appendChild(value);
|
||||||
|
}
|
||||||
|
fields.appendChild(field);
|
||||||
|
});
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.dmpXml;
|
||||||
|
|
||||||
|
import eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBContext;
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ImportXmlBuilderDmpProfile {
|
||||||
|
|
||||||
|
public DmpProfile build(File xmlFile) throws IOException {
|
||||||
|
DmpProfile dmpProfile = new DmpProfile();
|
||||||
|
JAXBContext jaxbContext = null;
|
||||||
|
try {
|
||||||
|
jaxbContext = JAXBContext.newInstance(DmpProfile.class);
|
||||||
|
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
|
||||||
|
dmpProfile = (DmpProfile) unmarshaller.unmarshal(xmlFile);
|
||||||
|
} catch (JAXBException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return dmpProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "datatype")
|
||||||
|
public class DMPProfileFieldDataType {
|
||||||
|
|
||||||
|
private int datatype;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "datatype")
|
||||||
|
public int getDatatype() {
|
||||||
|
return datatype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatatype(int datatype) {
|
||||||
|
this.datatype = datatype;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileFieldDataType toDmpProfileCompositeModel() {
|
||||||
|
return eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileFieldDataType.fromInteger(datatype);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel;
|
||||||
|
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "type")
|
||||||
|
public class DMPProfileType {
|
||||||
|
|
||||||
|
private int type;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "type")
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileType toDmpProfileCompositeModel() {
|
||||||
|
return eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileType.fromInteger(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel;
|
||||||
|
|
||||||
|
import eu.eudat.data.entities.DMPProfile;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "root")
|
||||||
|
public class DmpProfile {
|
||||||
|
|
||||||
|
private DmpProfileDefinition dmpProfileDefinition;
|
||||||
|
|
||||||
|
@XmlElement(name = "definition")
|
||||||
|
public DmpProfileDefinition getDmpProfileDefinition() {
|
||||||
|
return dmpProfileDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDmpProfileDefinition(DmpProfileDefinition dmpProfileDefinition) {
|
||||||
|
this.dmpProfileDefinition = dmpProfileDefinition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel toDmpProfileCompositeModel(String label) {
|
||||||
|
eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel dmpProfileModel = new eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel();
|
||||||
|
dmpProfileModel.setLabel(label);
|
||||||
|
dmpProfileModel.setStatus(DMPProfile.Status.SAVED.getValue());
|
||||||
|
dmpProfileModel.setCreated(new Date());
|
||||||
|
dmpProfileModel.setModified(new Date());
|
||||||
|
dmpProfileModel.setDefinition(this.dmpProfileDefinition.toDmpProfileCompositeModel());
|
||||||
|
return dmpProfileModel;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.FieldSets;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "definition")
|
||||||
|
public class DmpProfileDefinition {
|
||||||
|
|
||||||
|
private FieldSets fieldSets;
|
||||||
|
|
||||||
|
@XmlElement(name = "fieldSets")
|
||||||
|
public FieldSets getFieldSets() {
|
||||||
|
return fieldSets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFieldSets(FieldSets fieldSets) {
|
||||||
|
this.fieldSets = fieldSets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile toDmpProfileCompositeModel() {
|
||||||
|
eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile dmpProfileDefinitionModel = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile();
|
||||||
|
List<eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field> dmpProfileDefinitionFields = new LinkedList<>();
|
||||||
|
for (Field field:this.fieldSets.fields) {
|
||||||
|
dmpProfileDefinitionFields.add(field.toDmpProfileCompositeModel());
|
||||||
|
}
|
||||||
|
dmpProfileDefinitionModel.setFields(dmpProfileDefinitionFields);
|
||||||
|
return dmpProfileDefinitionModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,90 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.XmlValue;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "field")
|
||||||
|
public class Field {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
private String label;
|
||||||
|
|
||||||
|
private int dataType;
|
||||||
|
|
||||||
|
private boolean required;
|
||||||
|
|
||||||
|
private int type;
|
||||||
|
|
||||||
|
// private Object value;
|
||||||
|
|
||||||
|
@XmlAttribute(name = "id")
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "label")
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "dataType")
|
||||||
|
public int getDataType() {
|
||||||
|
return dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataType(int dataType) {
|
||||||
|
this.dataType = dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "required")
|
||||||
|
public boolean isRequired() {
|
||||||
|
return required;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequired(boolean required) {
|
||||||
|
this.required = required;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlAttribute(name = "type")
|
||||||
|
public int getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(int type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @XmlValue
|
||||||
|
// public Object getValue() {
|
||||||
|
// return value;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void setValue(Object value) {
|
||||||
|
// this.value = value;
|
||||||
|
// }
|
||||||
|
|
||||||
|
public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field toDmpProfileCompositeModel() {
|
||||||
|
eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field field = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field();
|
||||||
|
field.setId(UUID.fromString(this.id));
|
||||||
|
field.setDataType(eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileFieldDataType.fromInteger(this.dataType));
|
||||||
|
field.setLabel(this.label);
|
||||||
|
field.setRequired(this.required);
|
||||||
|
field.setType(eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileType.fromInteger(this.type));
|
||||||
|
// field.setValue(this.value);
|
||||||
|
return field;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "fieldSets")
|
||||||
|
public class FieldSets {
|
||||||
|
|
||||||
|
List<Field> fields;
|
||||||
|
|
||||||
|
@XmlElement(name = "field")
|
||||||
|
public List<Field> getField() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setField(List<Field> fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -164,5 +164,4 @@ public class Field implements ViewStyleDefinition<eu.eudat.models.data.entities.
|
||||||
return this.ordinal.compareTo(((Field) o).ordinal);
|
return this.ordinal.compareTo(((Field) o).ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
|
||||||
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class FieldSet implements Comparable, ViewStyleDefinition<eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.FieldSet> {
|
public class FieldSet implements Comparable, ViewStyleDefinition<eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.FieldSet> {
|
||||||
|
@ -33,7 +34,7 @@ public class FieldSet implements Comparable, ViewStyleDefinition<eu.eudat.models
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getOrdinal() {
|
public Integer getOrdinal() {
|
||||||
return ordinal;
|
return ordinal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,4 +119,19 @@ public class FieldSet implements Comparable, ViewStyleDefinition<eu.eudat.models
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public FieldSet toShort(){
|
||||||
|
FieldSet shortenFieldSet = new FieldSet();
|
||||||
|
shortenFieldSet.setId(this.id);
|
||||||
|
shortenFieldSet.setMultiplicity(this.multiplicity);
|
||||||
|
shortenFieldSet.setTitle(this.title);
|
||||||
|
shortenFieldSet.setDescription(this.description);
|
||||||
|
shortenFieldSet.setExtendedDescription(this.extendedDescription);
|
||||||
|
shortenFieldSet.setHasCommentField(this.hasCommentField);
|
||||||
|
|
||||||
|
List<Field> fieldToShort = this.fields;
|
||||||
|
Collections.sort(fieldToShort);
|
||||||
|
shortenFieldSet.setFields(fieldToShort);
|
||||||
|
return shortenFieldSet;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.logic.utilities.interfaces.ViewStyleDefinition;
|
||||||
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
import org.apache.commons.lang3.RandomStringUtils;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section> {
|
public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Section> {
|
||||||
|
@ -114,5 +115,26 @@ public class Section implements Comparable, ViewStyleDefinition<eu.eudat.models.
|
||||||
return this.ordinal.compareTo(((Section) o).getOrdinal());
|
return this.ordinal.compareTo(((Section) o).getOrdinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Section toShort(){
|
||||||
|
Section shortenSection = new Section();
|
||||||
|
|
||||||
|
List<Section> toShortsections = this.sections;
|
||||||
|
List<FieldSet> toShortFieldSets = this.fieldSets;
|
||||||
|
Collections.sort(toShortsections);
|
||||||
|
Collections.sort(toShortFieldSets);
|
||||||
|
for (Section shortsections : toShortsections ) { shortsections.toShort(); }
|
||||||
|
for (FieldSet shortFieldSets : toShortFieldSets ) { shortFieldSets.toShort(); }
|
||||||
|
|
||||||
|
shortenSection.setSections(toShortsections);
|
||||||
|
shortenSection.setFieldSets(toShortFieldSets);
|
||||||
|
|
||||||
|
shortenSection.setDefaultVisibility(this.defaultVisibility);
|
||||||
|
shortenSection.setPage(this.page);
|
||||||
|
shortenSection.setOrdinal(this.ordinal);
|
||||||
|
shortenSection.setId(this.id);
|
||||||
|
shortenSection.setTitle(this.title);
|
||||||
|
shortenSection.setDescription(this.description);
|
||||||
|
return shortenSection;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ import eu.eudat.models.data.admin.components.datasetprofile.Page;
|
||||||
import eu.eudat.models.data.admin.components.datasetprofile.Section;
|
import eu.eudat.models.data.admin.components.datasetprofile.Section;
|
||||||
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
import eu.eudat.logic.utilities.builders.ModelBuilder;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DatasetProfile {
|
public class DatasetProfile {
|
||||||
|
@ -48,4 +50,18 @@ public class DatasetProfile {
|
||||||
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.pages = new ModelBuilder().fromViewStyleDefinition(viewStyle.getPages(), Page.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DatasetProfile toShort() {
|
||||||
|
DatasetProfile shortProfile = new DatasetProfile();
|
||||||
|
shortProfile.setLabel(this.label);
|
||||||
|
List<Section> shortSection = new LinkedList<>();
|
||||||
|
for (Section toshortSection : this.getSections()) {
|
||||||
|
shortSection.add(toshortSection.toShort());
|
||||||
|
}
|
||||||
|
Collections.sort(shortSection);
|
||||||
|
shortProfile.setSections(shortSection);
|
||||||
|
shortProfile.setPages(this.pages);
|
||||||
|
shortProfile.setStatus(this.status);
|
||||||
|
return shortProfile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.components.commons.datafield;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
|
@ -85,5 +86,27 @@ public class AutoCompleteData extends ComboBoxData<AutoCompleteData> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> toMap(Element item) {
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||||
|
dataMap.put("url", item != null ? item.getAttribute("url") : "");
|
||||||
|
dataMap.put("type", item != null ? item.getAttribute("type") : "autocomplete");
|
||||||
|
dataMap.put("optionsRoot", item != null ? item.getAttribute("optionsRoot") : "");
|
||||||
|
Element optionElement = (Element) item.getElementsByTagName("option").item(0);
|
||||||
|
// if (optionElement != null) {
|
||||||
|
// this.autoCompleteOptions = new Option();
|
||||||
|
// this.autoCompleteOptions.setLabel(optionElement.getAttribute("label"));
|
||||||
|
// this.autoCompleteOptions.setValue(optionElement.getAttribute("value"));
|
||||||
|
// }
|
||||||
|
dataMap.put("autoCompleteOptions", item != null ? optionToMap(optionElement) : null);
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> optionToMap(Element item){
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||||
|
dataMap.put("value", item != null ? item.getAttribute("value") : "");
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.components.commons.datafield;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class BooleanDecisionData extends FieldData<BooleanDecisionData> {
|
public class BooleanDecisionData extends FieldData<BooleanDecisionData> {
|
||||||
|
@ -33,4 +34,11 @@ public class BooleanDecisionData extends FieldData<BooleanDecisionData> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> toMap(Element item) {
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.components.commons.datafield;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class CheckBoxData extends FieldData<CheckBoxData> {
|
public class CheckBoxData extends FieldData<CheckBoxData> {
|
||||||
|
@ -34,4 +35,10 @@ public class CheckBoxData extends FieldData<CheckBoxData> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> toMap(Element item) {
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.logic.utilities.interfaces.XmlSerializable;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class ComboBoxData<T> extends FieldData<T> {
|
public abstract class ComboBoxData<T> extends FieldData<T> {
|
||||||
|
@ -86,5 +87,11 @@ public abstract class ComboBoxData<T> extends FieldData<T> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> toMap(Element item) {
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||||
|
dataMap.put("type", item != null ? item.getAttribute("type") : "");
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,12 @@ package eu.eudat.models.data.components.commons.datafield;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class DataPickerData extends FieldData<DataPickerData> {
|
public class DatePickerData extends FieldData<DatePickerData> {
|
||||||
@Override
|
@Override
|
||||||
public DataPickerData fromData(Object data) {
|
public DatePickerData fromData(Object data) {
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
this.setLabel((String) ((Map<String, Object>) data).get("label"));
|
||||||
}
|
}
|
||||||
|
@ -27,8 +28,15 @@ public class DataPickerData extends FieldData<DataPickerData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataPickerData fromXml(Element item) {
|
public DatePickerData fromXml(Element item) {
|
||||||
this.setLabel(item != null ? item.getAttribute("label") : "");
|
this.setLabel(item != null ? item.getAttribute("label") : "");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> toMap(Element item) {
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -4,6 +4,8 @@ import eu.eudat.logic.utilities.interfaces.XmlSerializable;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class FieldData<T> implements XmlSerializable<T> {
|
public abstract class FieldData<T> implements XmlSerializable<T> {
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
|
@ -30,4 +32,6 @@ public abstract class FieldData<T> implements XmlSerializable<T> {
|
||||||
public T fromXml(Element item) {
|
public T fromXml(Element item) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract Map<String, Object> toMap(Element item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.components.commons.datafield;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,4 +34,11 @@ public class FreeTextData extends FieldData<FreeTextData> {
|
||||||
this.setLabel(item.getAttribute("label"));
|
this.setLabel(item.getAttribute("label"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> toMap(Element item) {
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,14 @@ import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class RadioBoxData extends FieldData<RadioBoxData> {
|
public class RadioBoxData extends FieldData<RadioBoxData> {
|
||||||
|
|
||||||
private class Option implements XmlSerializable<Option> {
|
public class Option implements XmlSerializable<Option> {
|
||||||
private String label;
|
private String label;
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
|
@ -47,6 +48,7 @@ public class RadioBoxData extends FieldData<RadioBoxData> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Option> options;
|
private List<Option> options;
|
||||||
|
@ -111,4 +113,12 @@ public class RadioBoxData extends FieldData<RadioBoxData> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> toMap(Element item) {
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||||
|
dataMap.put("options", item != null ? item.getAttribute("options") : "");
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.components.commons.datafield;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,4 +33,11 @@ public class TextAreaData extends FieldData<TextAreaData> {
|
||||||
this.setLabel(item.getAttribute("label"));
|
this.setLabel(item.getAttribute("label"));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> toMap(Element item) {
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -78,5 +79,33 @@ public class WordListData extends ComboBoxData<WordListData> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> toMap(Element item) {
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("label", item != null ? item.getAttribute("label") : "");
|
||||||
|
dataMap.put("type", item != null ? item.getAttribute("type") : "wordlist");
|
||||||
|
Element optionsElement = (Element) item.getElementsByTagName("options").item(0);
|
||||||
|
List<Map<String,String>> option =new LinkedList<>();
|
||||||
|
|
||||||
|
if (optionsElement != null) {
|
||||||
|
NodeList optionElements = optionsElement.getChildNodes();
|
||||||
|
for (int temp = 0; temp < optionElements.getLength(); temp++) {
|
||||||
|
Node optionElement = optionElements.item(temp);
|
||||||
|
if (optionElement.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
|
option.add(optionToMap((Element) optionElement));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataMap.put("options", option != null ? option : null);
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, String> optionToMap(Element item){
|
||||||
|
HashMap dataMap = new HashMap();
|
||||||
|
dataMap.put("label",item.getAttribute("label"));
|
||||||
|
dataMap.put("value",item.getAttribute("value"));
|
||||||
|
|
||||||
|
return dataMap;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,7 +153,7 @@ public class Section implements DatabaseViewStyleDefinition, XmlSerializable<Sec
|
||||||
|
|
||||||
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.valueOf(element.getAttribute("defaultVisibility"));
|
||||||
this.page = element.getAttribute("page");
|
this.page = element.getAttribute("page");
|
||||||
|
|
||||||
Element description = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "description");
|
Element description = XmlBuilder.getNodeFromListByTagName(element.getChildNodes(), "description");
|
||||||
|
|
|
@ -81,6 +81,7 @@ public class DataManagementPlanProfileListingModel implements DataModel<DMPProfi
|
||||||
this.definition = new DataManagementPlanProfile().fromXml(XmlBuilder.fromXml(entity.getDefinition()).getDocumentElement());
|
this.definition = new DataManagementPlanProfile().fromXml(XmlBuilder.fromXml(entity.getDefinition()).getDocumentElement());
|
||||||
this.modified = entity.getModified();
|
this.modified = entity.getModified();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
|
this.status = entity.getStatus();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.eudat.types;
|
package eu.eudat.types;
|
||||||
|
|
||||||
public enum ApiMessageCode {
|
public enum ApiMessageCode {
|
||||||
NO_MESSAGE(0), SUCCESS_MESSAGE(200), WARN_MESSAGE(300), ERROR_MESSAGE(400), DEFAULT_ERROR_MESSAGE(444),VALIDATION_MESSAGE(445);;
|
NO_MESSAGE(0), SUCCESS_MESSAGE(200), WARN_MESSAGE(300), ERROR_MESSAGE(400),
|
||||||
|
DEFAULT_ERROR_MESSAGE(444), VALIDATION_MESSAGE(445), UNSUCCESS_DELETE(674);
|
||||||
|
|
||||||
private Integer value;
|
private Integer value;
|
||||||
|
|
||||||
|
@ -25,6 +26,8 @@ public enum ApiMessageCode {
|
||||||
return ERROR_MESSAGE;
|
return ERROR_MESSAGE;
|
||||||
case 444:
|
case 444:
|
||||||
return DEFAULT_ERROR_MESSAGE;
|
return DEFAULT_ERROR_MESSAGE;
|
||||||
|
case 674:
|
||||||
|
return UNSUCCESS_DELETE;
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unsupported Api Message Code");
|
throw new RuntimeException("Unsupported Api Message Code");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,25 @@
|
||||||
|
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { environment } from '../../../../environments/environment';
|
import { environment } from '../../../../environments/environment';
|
||||||
import { DataTableData } from '../../model/data-table/data-table-data';
|
import { BaseHttpParams } from '../../../common/http/base-http-params';
|
||||||
import { DataTableRequest } from '../../model/data-table/data-table-request';
|
import { InterceptorType } from '../../../common/http/interceptors/interceptor-type';
|
||||||
import { DatasetProfileEditorModel } from '../../../ui/admin/dataset-profile/editor/dataset-profile-editor-model';
|
import { DatasetProfileEditorModel } from '../../../ui/admin/dataset-profile/editor/dataset-profile-editor-model';
|
||||||
import { DatasetProfile } from '../../model/admin/dataset-profile/dataset-profile';
|
import { DatasetProfile } from '../../model/admin/dataset-profile/dataset-profile';
|
||||||
|
import { DataTableData } from '../../model/data-table/data-table-data';
|
||||||
|
import { DataTableRequest } from '../../model/data-table/data-table-request';
|
||||||
|
import { DatasetProfileDefinitionModel } from '../../model/dataset-profile-definition/dataset-profile-definition';
|
||||||
import { DatasetListingModel } from '../../model/dataset/dataset-listing';
|
import { DatasetListingModel } from '../../model/dataset/dataset-listing';
|
||||||
import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria';
|
import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-profile-criteria';
|
||||||
import { BaseHttpService } from '../http/base-http.service';
|
import { BaseHttpService } from '../http/base-http.service';
|
||||||
import { DatasetProfileDefinitionModel } from '../../model/dataset-profile-definition/dataset-profile-definition';
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DatasetProfileService {
|
export class DatasetProfileService {
|
||||||
|
|
||||||
private actionUrl: string;
|
private actionUrl: string;
|
||||||
|
private headers = new HttpHeaders();
|
||||||
|
|
||||||
constructor(private http: BaseHttpService) {
|
constructor(private http: BaseHttpService, private httpClient: HttpClient) {
|
||||||
this.actionUrl = environment.Server + 'admin/';
|
this.actionUrl = environment.Server + 'admin/';
|
||||||
}
|
}
|
||||||
createForm(data) {
|
createForm(data) {
|
||||||
|
@ -43,8 +47,24 @@ export class DatasetProfileService {
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(id: string, data): Observable<DatasetProfile> {
|
delete(id: string, data): Observable<DatasetProfile> {
|
||||||
return this.http.post<DatasetProfile>(this.actionUrl + 'addDmp/' + id, data);
|
//return this.http.post<DatasetProfile>(this.actionUrl + 'addDmp/' + id, data);
|
||||||
//return this.http.delete<DatasetProfile>(this.actionUrl + id, {});
|
return this.http.delete<DatasetProfile>(this.actionUrl + id, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public downloadXML(id: string): Observable<HttpResponse<Blob>> {
|
||||||
|
let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml')
|
||||||
|
return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response', headers: headerXml });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uploadFile(file: FileList, labelSent: string): Observable<DataTableData<DatasetListingModel>> {
|
||||||
|
const params = new BaseHttpParams();
|
||||||
|
params.interceptorContext = {
|
||||||
|
excludedInterceptors: [InterceptorType.JSONContentType]
|
||||||
|
};
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', file[0], labelSent);
|
||||||
|
return this.http.post(this.actionUrl + "upload", formData, { params: params });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { environment } from '../../../../environments/environment';
|
import { environment } from '../../../../environments/environment';
|
||||||
|
@ -9,14 +9,17 @@ import { DmpProfileListing } from '../../model/dmp-profile/dmp-profile-listing';
|
||||||
import { RequestItem } from '../../query/request-item';
|
import { RequestItem } from '../../query/request-item';
|
||||||
import { DataTableData } from '../../model/data-table/data-table-data';
|
import { DataTableData } from '../../model/data-table/data-table-data';
|
||||||
import { DmpProfileCriteria } from '../../query/dmp/dmp-profile-criteria';
|
import { DmpProfileCriteria } from '../../query/dmp/dmp-profile-criteria';
|
||||||
|
import { DatasetListingModel } from '../../model/dataset/dataset-listing';
|
||||||
|
import { BaseHttpParams } from '../../../common/http/base-http-params';
|
||||||
|
import { InterceptorType } from '../../../common/http/interceptors/interceptor-type';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DmpProfileService {
|
export class DmpProfileService {
|
||||||
|
|
||||||
private actionUrl: string;
|
private actionUrl: string;
|
||||||
private headers: HttpHeaders;
|
private headers = new HttpHeaders();
|
||||||
|
|
||||||
constructor(private http: BaseHttpService) {
|
constructor(private http: BaseHttpService, private httpClient: HttpClient) {
|
||||||
this.actionUrl = environment.Server + 'dmpprofile/';
|
this.actionUrl = environment.Server + 'dmpprofile/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,4 +34,19 @@ export class DmpProfileService {
|
||||||
createDmp(dataManagementPlanModel: DmpProfile): Observable<DmpProfile> {
|
createDmp(dataManagementPlanModel: DmpProfile): Observable<DmpProfile> {
|
||||||
return this.http.post<DmpProfile>(this.actionUrl, dataManagementPlanModel, { headers: this.headers });
|
return this.http.post<DmpProfile>(this.actionUrl, dataManagementPlanModel, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public downloadXML(id: string): Observable<HttpResponse<Blob>> {
|
||||||
|
let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml')
|
||||||
|
return this.httpClient.get(this.actionUrl + 'getXml/' + id, { responseType: 'blob', observe: 'response', headers: headerXml });
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadFile(file: FileList, labelSent: string): Observable<DataTableData<DatasetListingModel>> {
|
||||||
|
const params = new BaseHttpParams();
|
||||||
|
params.interceptorContext = {
|
||||||
|
excludedInterceptors: [InterceptorType.JSONContentType]
|
||||||
|
};
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', file[0], labelSent);
|
||||||
|
return this.http.post(this.actionUrl + "upload", formData, { params: params });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,11 @@ import { HttpHeaders } from '@angular/common/http';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { environment } from '../../../../environments/environment';
|
import { environment } from '../../../../environments/environment';
|
||||||
import { RequestItem } from '../../query/request-item';
|
|
||||||
import { DataTableData } from '../../model/data-table/data-table-data';
|
import { DataTableData } from '../../model/data-table/data-table-data';
|
||||||
import { DataTableRequest } from '../../model/data-table/data-table-request';
|
import { DataTableRequest } from '../../model/data-table/data-table-request';
|
||||||
import { ProjectListingModel } from '../../model/project/project-listing';
|
import { ProjectListingModel } from '../../model/project/project-listing';
|
||||||
import { ProjectCriteria } from '../../query/project/project-criteria';
|
import { ProjectCriteria } from '../../query/project/project-criteria';
|
||||||
|
import { RequestItem } from '../../query/request-item';
|
||||||
import { BaseHttpService } from '../http/base-http.service';
|
import { BaseHttpService } from '../http/base-http.service';
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import { DatasetProfileCriteriaComponent } from './listing/criteria/dataset-prof
|
||||||
import { DatasetProfileListingComponent } from './listing/dataset-profile-listing.component';
|
import { DatasetProfileListingComponent } from './listing/dataset-profile-listing.component';
|
||||||
import { ConfirmationDialogModule } from '../../../library/confirmation-dialog/confirmation-dialog.module';
|
import { ConfirmationDialogModule } from '../../../library/confirmation-dialog/confirmation-dialog.module';
|
||||||
import { DatasetProfileEditorDatePickerFieldComponent } from './editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component';
|
import { DatasetProfileEditorDatePickerFieldComponent } from './editor/components/field-type/datepicker/dataset-profile-editor-date-picker-field.component';
|
||||||
|
import { DialodConfirmationUploadDatasetProfiles } from './listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -49,10 +50,12 @@ import { DatasetProfileEditorDatePickerFieldComponent } from './editor/component
|
||||||
DatasetProfileEditorTextAreaFieldComponent,
|
DatasetProfileEditorTextAreaFieldComponent,
|
||||||
DatasetProfileEditorDatePickerFieldComponent,
|
DatasetProfileEditorDatePickerFieldComponent,
|
||||||
DatasetProfileEditorWordListFieldComponent,
|
DatasetProfileEditorWordListFieldComponent,
|
||||||
DatasetProfileEditorDefaultValueComponent
|
DatasetProfileEditorDefaultValueComponent,
|
||||||
|
DialodConfirmationUploadDatasetProfiles
|
||||||
|
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
|
DialodConfirmationUploadDatasetProfiles
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class DatasetProfileModule { }
|
export class DatasetProfileModule { }
|
||||||
|
|
|
@ -1,16 +1,24 @@
|
||||||
<div class="container" *ngIf="form" [formGroup]='form' class="dataset-profile-editor">
|
<div class="container" *ngIf="form" [formGroup]='form' class="dataset-profile-editor">
|
||||||
<mat-form-field class="full-width">
|
<mat-form-field class="full-width">
|
||||||
<input matInput formControlName="label" placeholder="{{'DATASET-PROFILE-EDITOR.FIELDS.DATASET-TITLE' | translate}}" required>
|
<input matInput formControlName="label"
|
||||||
<mat-error *ngIf="form.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
placeholder="{{'DATASET-PROFILE-EDITOR.FIELDS.DATASET-TITLE' | translate}}" required>
|
||||||
|
<mat-error *ngIf="form.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}
|
||||||
|
</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<div class="row" *ngIf="form.get('status').value==1">
|
||||||
|
<div class="col"></div>
|
||||||
|
<button mat-raised-button class="col-auto" color="primary" (click)="downloadXML();"
|
||||||
|
type="button">{{ 'DATASET-WIZARD.ACTIONS.DOWNLOAD-XML' | translate }}</button>
|
||||||
|
</div>
|
||||||
<mat-horizontal-stepper [linear]="true" #stepper>
|
<mat-horizontal-stepper [linear]="true" #stepper>
|
||||||
<mat-step>
|
<mat-step>
|
||||||
<ng-template matStepLabel>{{'DATASET-PROFILE-EDITOR.STEPS.PAGES.TITLE' | translate}}</ng-template>
|
<ng-template matStepLabel>{{'DATASET-PROFILE-EDITOR.STEPS.PAGES.TITLE' | translate}}</ng-template>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<app-dataset-profile-editor-page-component class="col-12" [form]="form.get('pages')" [viewOnly]="viewOnly"></app-dataset-profile-editor-page-component>
|
<app-dataset-profile-editor-page-component class="col-12" [form]="form.get('pages')"
|
||||||
|
[viewOnly]="viewOnly"></app-dataset-profile-editor-page-component>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<button mat-button class="full-width" (click)="addPage()" [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.ADD-PAGE' | translate}}</button>
|
<button mat-button class="full-width" (click)="addPage()"
|
||||||
|
[disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.ADD-PAGE' | translate}}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
|
@ -20,19 +28,22 @@
|
||||||
<mat-accordion class="col-12" [multi]="true">
|
<mat-accordion class="col-12" [multi]="true">
|
||||||
<mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;" #panel>
|
<mat-expansion-panel *ngFor="let section of dataModel.sections; let i=index;" #panel>
|
||||||
<mat-expansion-panel-header>
|
<mat-expansion-panel-header>
|
||||||
<mat-panel-title>{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}</mat-panel-title>
|
<mat-panel-title>{{i + 1}}. {{form.get('sections').get(''+i).get('title').value}}
|
||||||
|
</mat-panel-title>
|
||||||
<button mat-icon-button type="button" (click)="DeleteSection(i);" [disabled]="viewOnly">
|
<button mat-icon-button type="button" (click)="DeleteSection(i);" [disabled]="viewOnly">
|
||||||
<mat-icon>delete</mat-icon>
|
<mat-icon>delete</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</mat-expansion-panel-header>
|
</mat-expansion-panel-header>
|
||||||
<div id="{{'s' + i}}" class="row" *ngIf="panel.expanded">
|
<div id="{{'s' + i}}" class="row" *ngIf="panel.expanded">
|
||||||
<app-dataset-profile-editor-section-component class="col-12" [form]="form.get('sections').get(''+i)" [dataModel]="section"
|
<app-dataset-profile-editor-section-component class="col-12"
|
||||||
[indexPath]="'s' + i" [viewOnly]="viewOnly"></app-dataset-profile-editor-section-component>
|
[form]="form.get('sections').get(''+i)" [dataModel]="section" [indexPath]="'s' + i"
|
||||||
|
[viewOnly]="viewOnly"></app-dataset-profile-editor-section-component>
|
||||||
</div>
|
</div>
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
</mat-accordion>
|
</mat-accordion>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<button mat-button (click)="addSection()" class="full-width" [disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.ADD-SECTION' | translate}}</button>
|
<button mat-button (click)="addSection()" class="full-width"
|
||||||
|
[disabled]="viewOnly">{{'DATASET-PROFILE-EDITOR.ACTIONS.ADD-SECTION' | translate}}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
|
@ -47,9 +58,11 @@
|
||||||
<!-- SAVE BUTTON -->
|
<!-- SAVE BUTTON -->
|
||||||
<div class="col-auto" *ngIf="!viewOnly">
|
<div class="col-auto" *ngIf="!viewOnly">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<button mat-raised-button color="primary" type="button col-auto" (click)='onSubmit()' [disabled]="!form.valid">Save</button>
|
<button mat-raised-button color="primary" type="button col-auto" (click)='onSubmit()'
|
||||||
|
[disabled]="!form.valid">Save</button>
|
||||||
<div class="col-1"></div>
|
<div class="col-1"></div>
|
||||||
<button mat-raised-button color="primary" type="button col-auto" (click)='finalize()' [disabled]="!form.valid">Finalize</button>
|
<button mat-raised-button color="primary" type="button col-auto" (click)='finalize()'
|
||||||
|
[disabled]="!form.valid">Finalize</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col"></div>
|
<div class="col"></div>
|
||||||
|
@ -60,4 +73,4 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -16,6 +16,7 @@ import { SectionEditorModel } from '../admin/section-editor-model';
|
||||||
import { DatasetProfileEditorModel } from './dataset-profile-editor-model';
|
import { DatasetProfileEditorModel } from './dataset-profile-editor-model';
|
||||||
import { ConfirmationDialogComponent } from '../../../../library/confirmation-dialog/confirmation-dialog.component';
|
import { ConfirmationDialogComponent } from '../../../../library/confirmation-dialog/confirmation-dialog.component';
|
||||||
import { DatasetProfileEnum } from '../../../../core/common/enum/dataset-profile';
|
import { DatasetProfileEnum } from '../../../../core/common/enum/dataset-profile';
|
||||||
|
import * as FileSaver from 'file-saver';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-profile-editor-component',
|
selector: 'app-dataset-profile-editor-component',
|
||||||
|
@ -58,40 +59,40 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
|
||||||
this.datasetProfileService.getDatasetProfileById(this.datasetProfileId)
|
this.datasetProfileService.getDatasetProfileById(this.datasetProfileId)
|
||||||
.pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed))
|
.pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
data => {
|
data => {
|
||||||
try {
|
try {
|
||||||
this.dataModel = new DatasetProfileEditorModel().fromModel(data);
|
this.dataModel = new DatasetProfileEditorModel().fromModel(data);
|
||||||
// this.isDeleted = this.masterItem.isActive === IsActive.Inactive;
|
// this.isDeleted = this.masterItem.isActive === IsActive.Inactive;
|
||||||
this.form = this.dataModel.buildForm();
|
this.form = this.dataModel.buildForm();
|
||||||
if (this.dataModel.status === DatasetProfileEnum.FINALIZED) {
|
if (this.dataModel.status === DatasetProfileEnum.FINALIZED) {
|
||||||
this.form.disable();
|
this.form.disable();
|
||||||
this.viewOnly = true;
|
this.viewOnly = true;
|
||||||
|
}
|
||||||
|
this.prepareForm();
|
||||||
|
} catch {
|
||||||
|
this.logger.error('Could not parse MasterItem: ' + data);
|
||||||
|
this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error);
|
||||||
}
|
}
|
||||||
this.prepareForm();
|
},
|
||||||
} catch {
|
error => this.onCallbackError(error)
|
||||||
this.logger.error('Could not parse MasterItem: ' + data);
|
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error => this.onCallbackError(error)
|
|
||||||
);
|
);
|
||||||
} else if (cloneId != null) {
|
} else if (cloneId != null) {
|
||||||
this.datasetProfileService.clone(cloneId)
|
this.datasetProfileService.clone(cloneId)
|
||||||
.pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed))
|
.pipe(map(data => data as DatasetProfile), takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
data => {
|
data => {
|
||||||
try {
|
try {
|
||||||
this.dataModel = new DatasetProfileEditorModel().fromModel(data);
|
this.dataModel = new DatasetProfileEditorModel().fromModel(data);
|
||||||
// this.isDeleted = this.masterItem.isActive === IsActive.Inactive;
|
// this.isDeleted = this.masterItem.isActive === IsActive.Inactive;
|
||||||
this.dataModel.status = DatasetProfileEnum.SAVED;
|
this.dataModel.status = DatasetProfileEnum.SAVED;
|
||||||
this.form = this.dataModel.buildForm();
|
this.form = this.dataModel.buildForm();
|
||||||
this.prepareForm();
|
this.prepareForm();
|
||||||
} catch {
|
} catch {
|
||||||
this.logger.error('Could not parse MasterItem: ' + data);
|
this.logger.error('Could not parse MasterItem: ' + data);
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error);
|
this.uiNotificationService.snackBarNotification(this.language.instant('NOTIFICATIONS.DEFAULT.ERROR'), SnackBarNotificationLevel.Error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.dataModel = new DatasetProfileEditorModel();
|
this.dataModel = new DatasetProfileEditorModel();
|
||||||
|
@ -148,7 +149,6 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
|
||||||
|
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
let data = this.form.value;
|
let data = this.form.value;
|
||||||
|
|
||||||
if (this.datasetProfileId) {
|
if (this.datasetProfileId) {
|
||||||
this.datasetProfileService.updateForm(this.datasetProfileId, data)
|
this.datasetProfileService.updateForm(this.datasetProfileId, data)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
@ -204,21 +204,58 @@ export class DatasetProfileEditorComponent extends BaseComponent implements OnIn
|
||||||
});
|
});
|
||||||
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
this.form.get('status').setValue(DatasetProfileEnum.DELETED);
|
//this.form.get('status').setValue(DatasetProfileEnum.DELETED);
|
||||||
this.datasetProfileService.delete(this.datasetProfileId,this.form.value)
|
this.datasetProfileService.delete(this.datasetProfileId, this.form.value)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
complete => {
|
complete => {
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success);
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success);
|
||||||
this.router.navigate(['/dataset-profiles']);
|
this.router.navigate(['/dataset-profiles']);
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
this.onCallbackError(error);
|
this.onCallbackError(error);
|
||||||
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success);
|
if (error.error.statusCode == 674) {
|
||||||
}
|
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Error);
|
||||||
|
} else {
|
||||||
|
this.uiNotificationService.snackBarNotification(this.language.instant(error.message), SnackBarNotificationLevel.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
downloadXML(): void {
|
||||||
|
this.datasetProfileService.downloadXML(this.datasetProfileId)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(response => {
|
||||||
|
const blob = new Blob([response.body], { type: 'application/xml' });
|
||||||
|
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
||||||
|
|
||||||
|
FileSaver.saveAs(blob, filename);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getFilenameFromContentDispositionHeader(header: string): string {
|
||||||
|
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
|
||||||
|
|
||||||
|
const matches = header.match(regex);
|
||||||
|
let filename: string;
|
||||||
|
for (let i = 0; i < matches.length; i++) {
|
||||||
|
const match = matches[i];
|
||||||
|
if (match.includes('filename="')) {
|
||||||
|
filename = match.substring(10, match.length - 1);
|
||||||
|
break;
|
||||||
|
} else if (match.includes('filename=')) {
|
||||||
|
filename = match.substring(9);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
<div class="dmp-criteria">
|
<div class="dmp-criteria">
|
||||||
<mat-card class="mat-card">
|
<mat-card class="mat-card">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6">
|
<mat-form-field class="col-md-6">
|
||||||
<mat-form-field>
|
<input matInput placeholder=" {{'CRITERIA.DATASET-PROFILE.LIKE'| translate}}" name="datasetProfileLike"
|
||||||
<input matInput placeholder=" {{'CRITERIA.DATASET-PROFILE.LIKE'| translate}}" name="datasetProfileLike"
|
[(ngModel)]="criteria.like" (ngModelChange)="controlModified()">
|
||||||
[(ngModel)]="criteria.like" (ngModelChange)="controlModified()">
|
</mat-form-field>
|
||||||
</mat-form-field>
|
<div class="col"></div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<!-- imgFileInput.click() && -->
|
||||||
|
<button mat-raised-button class="col-auto" color="primary" (click)="openDialog()"
|
||||||
|
type="button">{{ 'DATASET-WIZARD.UPLOAD.UPLOAD-XML' | translate }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</div>
|
</div>
|
|
@ -1,7 +1,12 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { MatDialog } from '@angular/material';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
import { ValidationErrorModel } from '../../../../../common/forms/validation/error-model/validation-error-model';
|
import { ValidationErrorModel } from '../../../../../common/forms/validation/error-model/validation-error-model';
|
||||||
import { DatasetProfileCriteria } from '../../../../../core/query/dataset-profile/dataset-profile-criteria';
|
import { DatasetProfileCriteria } from '../../../../../core/query/dataset-profile/dataset-profile-criteria';
|
||||||
|
import { DatasetProfileService } from '../../../../../core/services/dataset-profile/dataset-profile.service';
|
||||||
import { BaseCriteriaComponent } from '../../../../misc/criteria/base-criteria.component';
|
import { BaseCriteriaComponent } from '../../../../misc/criteria/base-criteria.component';
|
||||||
|
import { DialodConfirmationUploadDatasetProfiles } from './dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dataset-profile-criteria-component',
|
selector: 'app-dataset-profile-criteria-component',
|
||||||
|
@ -13,6 +18,9 @@ export class DatasetProfileCriteriaComponent extends BaseCriteriaComponent imple
|
||||||
public criteria: DatasetProfileCriteria = new DatasetProfileCriteria();
|
public criteria: DatasetProfileCriteria = new DatasetProfileCriteria();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private datasetService: DatasetProfileService,
|
||||||
|
private dialog: MatDialog,
|
||||||
|
private language: TranslateService,
|
||||||
) {
|
) {
|
||||||
super(new ValidationErrorModel());
|
super(new ValidationErrorModel());
|
||||||
}
|
}
|
||||||
|
@ -38,4 +46,27 @@ export class DatasetProfileCriteriaComponent extends BaseCriteriaComponent imple
|
||||||
this.refreshCallback();
|
this.refreshCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
openDialog(): void {
|
||||||
|
const dialogRef = this.dialog.open(DialodConfirmationUploadDatasetProfiles, {
|
||||||
|
data: {
|
||||||
|
message: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML-FILE-TITLE'),
|
||||||
|
confirmButton: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML'),
|
||||||
|
cancelButton: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML-FILE-CANCEL'),
|
||||||
|
name: this.language.instant('DATASET-WIZARD.UPLOAD.UPLOAD-XML-NAME'),
|
||||||
|
file: FileList,
|
||||||
|
sucsess: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => {
|
||||||
|
if (data.sucsess && data.name != null && data.file != null) {
|
||||||
|
this.datasetService.uploadFile(data.file, data.name)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<div class="confirmation-dialog">
|
||||||
|
<div class="row">
|
||||||
|
<div class="confirmation-message col">
|
||||||
|
<h4>{{ data.message }}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<input class="hidden" type="file" #imgFileInput (change)="selectXML($event)" accept="text/xml" />
|
||||||
|
<button mat-raised-button class="col-auto" color="{{btnColore}}" (click)="imgFileInput.click()"
|
||||||
|
type="button">{{ 'DATASET-WIZARD.UPLOAD.UPLOAD-XML-IMPORT' | translate }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<mat-form-field class="col-12">
|
||||||
|
<input matInput placeholder="{{'DATASET-WIZARD.UPLOAD.UPLOAD-XML-NAME'| translate}}"
|
||||||
|
name="datasetProfileName" [(ngModel)]="data.name">
|
||||||
|
</mat-form-field>
|
||||||
|
<div class="col-auto"><button mat-raised-button color="primary" type="button"
|
||||||
|
(click)="cancel()">{{ data.cancelButton }}</button></div>
|
||||||
|
<div class="col"></div>
|
||||||
|
<div class="col-auto"><button mat-raised-button color="primary" type="button"
|
||||||
|
(click)="confirm()" [disabled]="!hasProfile()">{{ data.confirmButton }}</button></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,3 @@
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||||
|
import { Inject, Component } from '@angular/core';
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-dialog-confirmation-upload',
|
||||||
|
templateUrl: './dialog-confirmation-upload-profiles.component.html',
|
||||||
|
styleUrls: ['./dialog-confirmation-upload-profiles.component.scss']
|
||||||
|
})
|
||||||
|
export class DialodConfirmationUploadDatasetProfiles {
|
||||||
|
|
||||||
|
sizeError = false;
|
||||||
|
btnColore:String="primary";
|
||||||
|
selectFile =false;
|
||||||
|
maxFileSize: number = 1048576;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public dialogRef: MatDialogRef<DialodConfirmationUploadDatasetProfiles>,
|
||||||
|
@Inject(MAT_DIALOG_DATA) public data: any
|
||||||
|
) { }
|
||||||
|
|
||||||
|
|
||||||
|
selectXML(event) {
|
||||||
|
const file: FileList = event.target.files;
|
||||||
|
const size: number = file[0].size; // Get file size.
|
||||||
|
this.sizeError = size > this.maxFileSize; // Checks if file size is valid.
|
||||||
|
const formdata: FormData = new FormData();
|
||||||
|
if (!this.sizeError) {
|
||||||
|
this.data.file = file;
|
||||||
|
this.selectFile=true;
|
||||||
|
this.btnColore="primary";
|
||||||
|
}else{
|
||||||
|
this.btnColore="warn";
|
||||||
|
}
|
||||||
|
this.data.name = file[0].name;
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel() {
|
||||||
|
this.data.sucsess = false;
|
||||||
|
this.dialogRef.close(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
confirm() {
|
||||||
|
this.data.name = this.data.name;
|
||||||
|
this.data.sucsess = true;
|
||||||
|
this.dialogRef.close(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
hasProfile():boolean{
|
||||||
|
return (this.selectFile && !this.sizeError);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<h3>{{titlePrefix}} {{'DATASET-PROFILE-LISTING.TITLE' | translate}}</h3>
|
<h3>{{titlePrefix}} {{'DATASET-PROFILE-LISTING.TITLE' | translate}}</h3>
|
||||||
|
|
||||||
|
|
||||||
<app-dataset-profile-criteria-component></app-dataset-profile-criteria-component>
|
<app-dataset-profile-criteria-component></app-dataset-profile-criteria-component>
|
||||||
<mat-card class="mat-card">
|
<mat-card class="mat-card">
|
||||||
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
|
<mat-table [dataSource]="dataSource" matSort (matSortChange)="refresh()">
|
||||||
|
|
|
@ -33,4 +33,6 @@ mat-row:hover {
|
||||||
|
|
||||||
mat-row:nth-child(odd){
|
mat-row:nth-child(odd){
|
||||||
background-color:#eef0fb;
|
background-color:#eef0fb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { DmpProfileRoutingModule } from "./dmp-profile.routing";
|
||||||
import { DmpProfileEditorComponent } from "./editor/dmp-profile-editor.component";
|
import { DmpProfileEditorComponent } from "./editor/dmp-profile-editor.component";
|
||||||
import { DmpProfileCriteriaComponent } from "./listing/criteria/dmp-profile-criteria.component";
|
import { DmpProfileCriteriaComponent } from "./listing/criteria/dmp-profile-criteria.component";
|
||||||
import { DmpProfileListingComponent } from "./listing/dmp-profile-listing.component";
|
import { DmpProfileListingComponent } from "./listing/dmp-profile-listing.component";
|
||||||
|
import { DialodConfirmationUploadDmpProfiles } from "./listing/criteria/dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -19,7 +20,11 @@ import { DmpProfileListingComponent } from "./listing/dmp-profile-listing.compon
|
||||||
declarations: [
|
declarations: [
|
||||||
DmpProfileEditorComponent,
|
DmpProfileEditorComponent,
|
||||||
DmpProfileListingComponent,
|
DmpProfileListingComponent,
|
||||||
DmpProfileCriteriaComponent
|
DmpProfileCriteriaComponent,
|
||||||
|
DialodConfirmationUploadDmpProfiles
|
||||||
|
],
|
||||||
|
entryComponents: [
|
||||||
|
DialodConfirmationUploadDmpProfiles
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class DmpProfileModule { }
|
export class DmpProfileModule { }
|
|
@ -12,57 +12,84 @@
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<mat-form-field class="col-12">
|
<mat-form-field class="col-12">
|
||||||
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label" formControlName="label" required>
|
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text"
|
||||||
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">{{formGroup.get('label').getError('backendError').message}}</mat-error>
|
name="label" formControlName="label" required>
|
||||||
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="formGroup.get('label').hasError('backendError')">
|
||||||
|
{{formGroup.get('label').getError('backendError').message}}</mat-error>
|
||||||
|
<mat-error *ngIf="formGroup.get('label').hasError('required')">
|
||||||
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<h4 class="col-12">{{'DMP-PROFILE-EDITOR.FIELDS.TITLE' | translate}}</h4>
|
<h4 class="col-12">{{'DMP-PROFILE-EDITOR.FIELDS.TITLE' | translate}}</h4>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="row" *ngFor="let fieldFormGroup of formGroup.get('definition').get('fields')['controls'];let i=index">
|
<div class="row"
|
||||||
|
*ngFor="let fieldFormGroup of formGroup.get('definition').get('fields')['controls'];let i=index">
|
||||||
<mat-form-field class="col">
|
<mat-form-field class="col">
|
||||||
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}" type="text" name="label" [formControl]="fieldFormGroup.get('label')" required>
|
<input matInput placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.LABEL' | translate}}"
|
||||||
<mat-error *ngIf="fieldFormGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
type="text" name="label" [formControl]="fieldFormGroup.get('label')" required>
|
||||||
<mat-error *ngIf="fieldFormGroup.get('label').hasError('backendError')">{{fieldFormGroup.get('label').getError('backendError').message}}</mat-error>
|
<mat-error *ngIf="fieldFormGroup.get('label').hasError('required')">
|
||||||
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
<mat-error *ngIf="fieldFormGroup.get('label').hasError('backendError')">
|
||||||
|
{{fieldFormGroup.get('label').getError('backendError').message}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field class="col">
|
<mat-form-field class="col">
|
||||||
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.TYPE' | translate}}" [formControl]="fieldFormGroup.get('type')" required>
|
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.TYPE' | translate}}"
|
||||||
<mat-option *ngFor="let fieldType of getDMPProfileFieldTypeValues()" [value]="fieldType">{{
|
[formControl]="fieldFormGroup.get('type')" required>
|
||||||
|
<mat-option *ngFor="let fieldType of getDMPProfileFieldTypeValues()"
|
||||||
|
[value]="fieldType">{{
|
||||||
getDMPProfileFieldTypeWithLanguage(fieldType) | translate}}</mat-option>
|
getDMPProfileFieldTypeWithLanguage(fieldType) | translate}}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="fieldFormGroup.get('type').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="fieldFormGroup.get('type').hasError('required')">
|
||||||
<mat-error *ngIf="fieldFormGroup.get('type').hasError('backendError')">{{fieldFormGroup.get('type').getError('backendError').message}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
<mat-error *ngIf="fieldFormGroup.get('type').hasError('backendError')">
|
||||||
|
{{fieldFormGroup.get('type').getError('backendError').message}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field class="col">
|
<mat-form-field class="col">
|
||||||
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.DATATYPE' | translate}}" [formControl]="fieldFormGroup.get('dataType')" required>
|
<mat-select placeholder="{{'DMP-PROFILE-EDITOR.FIELDS.DATATYPE' | translate}}"
|
||||||
<mat-option *ngFor="let fieldDataType of getDMPProfileFieldDataTypeValues()" [value]="fieldDataType">{{
|
[formControl]="fieldFormGroup.get('dataType')" required>
|
||||||
|
<mat-option *ngFor="let fieldDataType of getDMPProfileFieldDataTypeValues()"
|
||||||
|
[value]="fieldDataType">{{
|
||||||
getDMPProfileFieldDataTypeWithLanguage(fieldDataType) | translate}}</mat-option>
|
getDMPProfileFieldDataTypeWithLanguage(fieldDataType) | translate}}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="fieldFormGroup.get('dataType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="fieldFormGroup.get('dataType').hasError('required')">
|
||||||
<mat-error *ngIf="fieldFormGroup.get('dataType').hasError('backendError')">{{fieldFormGroup.get('dataType').getError('backendError').message}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
<mat-error *ngIf="fieldFormGroup.get('dataType').hasError('backendError')">
|
||||||
|
{{fieldFormGroup.get('dataType').getError('backendError').message}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<div class="centered-row-item col-auto">
|
<div class="centered-row-item col-auto">
|
||||||
<mat-checkbox [formControl]="fieldFormGroup.get('required')">{{'DMP-PROFILE-EDITOR.FIELDS.REQUIRED' | translate}}</mat-checkbox>
|
<mat-checkbox [formControl]="fieldFormGroup.get('required')">
|
||||||
|
{{'DMP-PROFILE-EDITOR.FIELDS.REQUIRED' | translate}}</mat-checkbox>
|
||||||
</div>
|
</div>
|
||||||
<div class="centered-row-item col-auto"><button mat-icon-button type="button" (click)="removeField(i)">
|
<div class="centered-row-item col-auto"><button mat-icon-button type="button"
|
||||||
|
(click)="removeField(i)" [disabled]="viewOnly">
|
||||||
<mat-icon class="mat-24">delete</mat-icon>
|
<mat-icon class="mat-24">delete</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button mat-icon-button class="col-auto" color="primary" type="button" (click)="addField()">
|
<button mat-icon-button class="col-auto" color="primary" type="button" (click)="addField()"
|
||||||
|
[disabled]="viewOnly">
|
||||||
<mat-icon class="mat-24">add</mat-icon>
|
<mat-icon class="mat-24">add</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="col-auto"><button mat-raised-button color="primary" (click)="cancel()"
|
||||||
|
type="button">{{'DMP-PROFILE-EDITOR.ACTIONS.CANCEL' | translate}}</button></div>
|
||||||
<div class="col"></div>
|
<div class="col"></div>
|
||||||
<div class="col-auto" *ngIf="!isNew"><button mat-raised-button color="primary" type="button" (click)="delete()">{{'DMP-PROFILE-EDITOR.ACTIONS.DELETE' | translate}}</button></div>
|
<div class="col-auto" *ngIf="!isNew"><button mat-raised-button color="primary" type="button"
|
||||||
<div class="col-auto"><button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-PROFILE-EDITOR.ACTIONS.CANCEL' | translate}}</button></div>
|
(click)="delete()">{{'DMP-PROFILE-EDITOR.ACTIONS.DELETE' | translate}}</button></div>
|
||||||
<div class="col-auto"><button mat-raised-button color="primary" type="submit">{{'DMP-PROFILE-EDITOR.ACTIONS.SAVE' | translate}}</button></div>
|
<button mat-raised-button *ngIf="formGroup.get('status').value!=1" class="col-auto"
|
||||||
|
color="primary" (click)="finalize()" [disabled]="!formGroup.valid"
|
||||||
|
type="button">{{'DMP-PROFILE-EDITOR.ACTIONS.FINALIZE' | translate }}</button>
|
||||||
|
<button mat-raised-button *ngIf="formGroup.get('status').value==1" class="col-auto"
|
||||||
|
color="primary" (click)="downloadXML()"
|
||||||
|
type="button">{{'DMP-PROFILE-EDITOR.ACTIONS.DOWNLOAD-XML' | translate }}</button>
|
||||||
|
<div class="col-auto" *ngIf="!viewOnly"><button mat-raised-button color="primary"
|
||||||
|
type="submit">{{'DMP-PROFILE-EDITOR.ACTIONS.SAVE' | translate}}</button></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
|
@ -2,18 +2,19 @@ import { AfterViewInit, Component } from '@angular/core';
|
||||||
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
|
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
|
||||||
import { ActivatedRoute, Params, Router } from '@angular/router';
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import * as FileSaver from 'file-saver';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
import { environment } from '../../../../../environments/environment';
|
import { environment } from '../../../../../environments/environment';
|
||||||
import { ValidationErrorModel } from '../../../../common/forms/validation/error-model/validation-error-model';
|
import { ValidationErrorModel } from '../../../../common/forms/validation/error-model/validation-error-model';
|
||||||
import { BaseComponent } from '../../../../core/common/base/base.component';
|
import { BaseComponent } from '../../../../core/common/base/base.component';
|
||||||
import { DmpProfileFieldDataType } from '../../../../core/common/enum/dmp-profile-field-type';
|
import { DmpProfileFieldDataType } from '../../../../core/common/enum/dmp-profile-field-type';
|
||||||
|
import { DmpProfileStatus } from '../../../../core/common/enum/dmp-profile-status';
|
||||||
import { DmpProfileType } from '../../../../core/common/enum/dmp-profile-type';
|
import { DmpProfileType } from '../../../../core/common/enum/dmp-profile-type';
|
||||||
import { DmpProfile } from '../../../../core/model/dmp-profile/dmp-profile';
|
import { DmpProfile } from '../../../../core/model/dmp-profile/dmp-profile';
|
||||||
import { DmpProfileService } from '../../../../core/services/dmp/dmp-profile.service';
|
import { DmpProfileService } from '../../../../core/services/dmp/dmp-profile.service';
|
||||||
import { SnackBarNotificationLevel, UiNotificationService } from '../../../../core/services/notification/ui-notification-service';
|
import { SnackBarNotificationLevel, UiNotificationService } from '../../../../core/services/notification/ui-notification-service';
|
||||||
import { EnumUtils } from '../../../../core/services/utilities/enum-utils.service';
|
import { EnumUtils } from '../../../../core/services/utilities/enum-utils.service';
|
||||||
import { DmpProfileEditorModel, DmpProfileFieldEditorModel } from './dmp-profile-editor.model';
|
import { DmpProfileEditorModel, DmpProfileFieldEditorModel } from './dmp-profile-editor.model';
|
||||||
import { DmpProfileStatus } from '../../../../core/common/enum/dmp-profile-status';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-profile-editor-component',
|
selector: 'app-dmp-profile-editor-component',
|
||||||
|
@ -23,9 +24,11 @@ import { DmpProfileStatus } from '../../../../core/common/enum/dmp-profile-statu
|
||||||
export class DmpProfileEditorComponent extends BaseComponent implements AfterViewInit {
|
export class DmpProfileEditorComponent extends BaseComponent implements AfterViewInit {
|
||||||
|
|
||||||
isNew = true;
|
isNew = true;
|
||||||
|
viewOnly = false;
|
||||||
dmpProfileModel: DmpProfileEditorModel;
|
dmpProfileModel: DmpProfileEditorModel;
|
||||||
formGroup: FormGroup = null;
|
formGroup: FormGroup = null;
|
||||||
host = environment.Server;
|
host = environment.Server;
|
||||||
|
dmpProfileId: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dmpProfileService: DmpProfileService,
|
private dmpProfileService: DmpProfileService,
|
||||||
|
@ -42,15 +45,19 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
this.route.params
|
this.route.params
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe((params: Params) => {
|
.subscribe((params: Params) => {
|
||||||
const itemId = params['id'];
|
this.dmpProfileId = params['id'];
|
||||||
|
|
||||||
if (itemId != null) {
|
if (this.dmpProfileId != null) {
|
||||||
this.isNew = false;
|
this.isNew = false;
|
||||||
this.dmpProfileService.getSingle(itemId).map(data => data as DmpProfile)
|
this.dmpProfileService.getSingle(this.dmpProfileId).map(data => data as DmpProfile)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(data => {
|
.subscribe(data => {
|
||||||
this.dmpProfileModel = new DmpProfileEditorModel().fromModel(data);
|
this.dmpProfileModel = new DmpProfileEditorModel().fromModel(data);
|
||||||
this.formGroup = this.dmpProfileModel.buildForm();
|
this.formGroup = this.dmpProfileModel.buildForm();
|
||||||
|
if (this.dmpProfileModel.status == DmpProfileStatus.Finalized) {
|
||||||
|
this.formGroup.disable();
|
||||||
|
this.viewOnly = true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.dmpProfileModel = new DmpProfileEditorModel();
|
this.dmpProfileModel = new DmpProfileEditorModel();
|
||||||
|
@ -176,10 +183,47 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
|
||||||
delete() {
|
delete() {
|
||||||
this.formGroup.get('status').setValue(DmpProfileStatus.Deleted);
|
this.formGroup.get('status').setValue(DmpProfileStatus.Deleted);
|
||||||
this.dmpProfileService.createDmp(this.formGroup.value)
|
this.dmpProfileService.createDmp(this.formGroup.value)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
complete => this.onCallbackSuccess(),
|
complete => this.onCallbackSuccess(),
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
finalize() {
|
||||||
|
//const data = this.form.value;
|
||||||
|
this.formGroup.get('status').setValue(DmpProfileStatus.Finalized);
|
||||||
|
|
||||||
|
this.onSubmit();
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadXML(): void {
|
||||||
|
this.dmpProfileService.downloadXML(this.dmpProfileId)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(response => {
|
||||||
|
const blob = new Blob([response.body], { type: 'application/xml' });
|
||||||
|
const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition'));
|
||||||
|
|
||||||
|
FileSaver.saveAs(blob, filename);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getFilenameFromContentDispositionHeader(header: string): string {
|
||||||
|
const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g);
|
||||||
|
|
||||||
|
const matches = header.match(regex);
|
||||||
|
let filename: string;
|
||||||
|
for (let i = 0; i < matches.length; i++) {
|
||||||
|
const match = matches[i];
|
||||||
|
if (match.includes('filename="')) {
|
||||||
|
filename = match.substring(10, match.length - 1);
|
||||||
|
break;
|
||||||
|
} else if (match.includes('filename=')) {
|
||||||
|
filename = match.substring(9);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filename;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
<div class="confirmation-dialog">
|
||||||
|
<div class="row">
|
||||||
|
<div class="confirmation-message col">
|
||||||
|
<h4>{{ data.message }}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<input class="hidden" type="file" #imgFileInput (change)="selectXML($event)" accept="text/xml" />
|
||||||
|
<button mat-raised-button class="col-auto" color="{{btnColore}}" (click)="imgFileInput.click()"
|
||||||
|
type="button">{{ 'DMP-PROFILE-LISTING.UPLOAD.UPLOAD-XML-IMPORT' | translate }}</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<mat-form-field class="col-12">
|
||||||
|
<input matInput placeholder="{{'DMP-PROFILE-LISTING.UPLOAD.UPLOAD-XML-NAME'| translate}}"
|
||||||
|
name="datasetProfileName" [(ngModel)]="data.name">
|
||||||
|
</mat-form-field>
|
||||||
|
<div class="col-auto"><button mat-raised-button color="primary" type="button"
|
||||||
|
(click)="cancel()">{{ data.cancelButton }}</button></div>
|
||||||
|
<div class="col"></div>
|
||||||
|
<div class="col-auto"><button mat-raised-button color="primary" type="button"
|
||||||
|
(click)="confirm()" [disabled]="!hasProfile()">{{ data.confirmButton }}</button></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,3 @@
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||||||
|
import { Inject, Component } from '@angular/core';
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-dialog-confirmation-upload',
|
||||||
|
templateUrl: './dialog-confirmation-upload-profiles.component.html',
|
||||||
|
styleUrls: ['./dialog-confirmation-upload-profiles.component.scss']
|
||||||
|
})
|
||||||
|
export class DialodConfirmationUploadDmpProfiles {
|
||||||
|
|
||||||
|
sizeError = false;
|
||||||
|
btnColore:String="primary";
|
||||||
|
selectFile =false;
|
||||||
|
maxFileSize: number = 1048576;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public dialogRef: MatDialogRef<DialodConfirmationUploadDmpProfiles>,
|
||||||
|
@Inject(MAT_DIALOG_DATA) public data: any
|
||||||
|
) { }
|
||||||
|
|
||||||
|
|
||||||
|
selectXML(event) {
|
||||||
|
const file: FileList = event.target.files;
|
||||||
|
const size: number = file[0].size; // Get file size.
|
||||||
|
this.sizeError = size > this.maxFileSize; // Checks if file size is valid.
|
||||||
|
const formdata: FormData = new FormData();
|
||||||
|
if (!this.sizeError) {
|
||||||
|
this.data.file = file;
|
||||||
|
this.selectFile=true;
|
||||||
|
this.btnColore="primary";
|
||||||
|
}else{
|
||||||
|
this.btnColore="warn";
|
||||||
|
}
|
||||||
|
this.data.name = file[0].name;
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel() {
|
||||||
|
this.data.sucsess = false;
|
||||||
|
this.dialogRef.close(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
confirm() {
|
||||||
|
this.data.name = this.data.name;
|
||||||
|
this.data.sucsess = true;
|
||||||
|
this.dialogRef.close(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
hasProfile():boolean{
|
||||||
|
return (this.selectFile && !this.sizeError);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,9 +1,18 @@
|
||||||
<div class="dmp-criteria">
|
<div class="dmp-criteria">
|
||||||
<mat-card class="mat-card">
|
<mat-card class="mat-card">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
<mat-form-field class="col-md-6">
|
<mat-form-field class="col-md-6">
|
||||||
<input matInput placeholder=" {{'CRITERIA.DMP.LIKE'| translate}}" name="projectCriteriaLike" [(ngModel)]="criteria.like" (ngModelChange)="controlModified()">
|
<input matInput placeholder=" {{'CRITERIA.DMP.LIKE'| translate}}" name="projectCriteriaLike"
|
||||||
|
[(ngModel)]="criteria.like" (ngModelChange)="controlModified()">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
|
<div class="col"></div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<!-- imgFileInput.click() && -->
|
||||||
|
<button mat-raised-button class="col-auto" color="primary" (click)="openDialog()"
|
||||||
|
type="button">{{ 'DMP-PROFILE-LISTING.UPLOAD.UPLOAD-XML' | translate }}</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</div>
|
</div>
|
|
@ -4,6 +4,11 @@ import { ProjectListingModel } from '../../../../../core/model/project/project-l
|
||||||
import { DmpCriteria } from '../../../../../core/query/dmp/dmp-criteria';
|
import { DmpCriteria } from '../../../../../core/query/dmp/dmp-criteria';
|
||||||
import { DmpProfileCriteria } from '../../../../../core/query/dmp/dmp-profile-criteria';
|
import { DmpProfileCriteria } from '../../../../../core/query/dmp/dmp-profile-criteria';
|
||||||
import { BaseCriteriaComponent } from '../../../../misc/criteria/base-criteria.component';
|
import { BaseCriteriaComponent } from '../../../../misc/criteria/base-criteria.component';
|
||||||
|
import { DialodConfirmationUploadDmpProfiles } from './dialog-confirmation-upload-profile/dialog-confirmation-upload-profiles.component';
|
||||||
|
import { MatDialog } from '@angular/material';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
import { DmpProfileService } from '../../../../../core/services/dmp/dmp-profile.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-profile-criteria-component',
|
selector: 'app-dmp-profile-criteria-component',
|
||||||
|
@ -17,8 +22,10 @@ export class DmpProfileCriteriaComponent extends BaseCriteriaComponent implement
|
||||||
public criteria: DmpProfileCriteria = new DmpProfileCriteria();
|
public criteria: DmpProfileCriteria = new DmpProfileCriteria();
|
||||||
filteringProjectsAsync = false;
|
filteringProjectsAsync = false;
|
||||||
filteredProjects: ProjectListingModel[];
|
filteredProjects: ProjectListingModel[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
private dmpProfileService: DmpProfileService,
|
||||||
|
private dialog: MatDialog,
|
||||||
|
private language: TranslateService
|
||||||
) {
|
) {
|
||||||
super(new ValidationErrorModel());
|
super(new ValidationErrorModel());
|
||||||
}
|
}
|
||||||
|
@ -44,4 +51,25 @@ export class DmpProfileCriteriaComponent extends BaseCriteriaComponent implement
|
||||||
this.refreshCallback();
|
this.refreshCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
openDialog(): void {
|
||||||
|
const dialogRef = this.dialog.open(DialodConfirmationUploadDmpProfiles, {
|
||||||
|
data: {
|
||||||
|
message: this.language.instant('DMP-PROFILE-LISTING.UPLOAD.UPLOAD-XML-FILE-TITLE'),
|
||||||
|
confirmButton: this.language.instant('DMP-PROFILE-LISTING.UPLOAD.UPLOAD-XML'),
|
||||||
|
cancelButton: this.language.instant('DMP-PROFILE-LISTING.UPLOAD.UPLOAD-XML-FILE-CANCEL'),
|
||||||
|
name: this.language.instant('DMP-PROFILE-LISTING.UPLOAD.UPLOAD-XML-NAME'),
|
||||||
|
file: FileList,
|
||||||
|
sucsess: false
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(data => {
|
||||||
|
if (data.sucsess && data.name != null && data.file != null) {
|
||||||
|
this.dmpProfileService.uploadFile(data.file, data.name)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,6 +245,13 @@
|
||||||
"SAVE-AND-FINALISE": "Save and Finalise",
|
"SAVE-AND-FINALISE": "Save and Finalise",
|
||||||
"DOWNLOAD-PDF": "Download PDF",
|
"DOWNLOAD-PDF": "Download PDF",
|
||||||
"DOWNLOAD-XML": "Download XML"
|
"DOWNLOAD-XML": "Download XML"
|
||||||
|
},
|
||||||
|
"UPLOAD":{
|
||||||
|
"UPLOAD-XML": "Import",
|
||||||
|
"UPLOAD-XML-FILE-TITLE":"Select Xml file with Dataset Profile to Upload",
|
||||||
|
"UPLOAD-XML-NAME":"Name Of Dataset Profile",
|
||||||
|
"UPLOAD-XML-IMPORT":"File",
|
||||||
|
"UPLOAD-XML-FILE-CANCEL":"Cansel"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DATASET-LISTING": {
|
"DATASET-LISTING": {
|
||||||
|
@ -312,7 +319,9 @@
|
||||||
"ACTIONS": {
|
"ACTIONS": {
|
||||||
"SAVE": "Save",
|
"SAVE": "Save",
|
||||||
"CANCEL": "Cancel",
|
"CANCEL": "Cancel",
|
||||||
"DELETE": "Delete"
|
"DELETE": "Delete",
|
||||||
|
"FINALIZE":"Finalise",
|
||||||
|
"DOWNLOAD-XML": "Download XML"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"PROJECT-EDITOR": {
|
"PROJECT-EDITOR": {
|
||||||
|
@ -367,6 +376,13 @@
|
||||||
"NAME": "Name",
|
"NAME": "Name",
|
||||||
"STATUS": "Status",
|
"STATUS": "Status",
|
||||||
"CREATED": "Created"
|
"CREATED": "Created"
|
||||||
|
},
|
||||||
|
"UPLOAD":{
|
||||||
|
"UPLOAD-XML": "Import",
|
||||||
|
"UPLOAD-XML-FILE-TITLE":"Select Xml file with Dmp Profile to Upload",
|
||||||
|
"UPLOAD-XML-NAME":"Name Of Dmp Profile",
|
||||||
|
"UPLOAD-XML-IMPORT":"File",
|
||||||
|
"UPLOAD-XML-FILE-CANCEL":"Cansel"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DYNAMIC-FORM": {
|
"DYNAMIC-FORM": {
|
||||||
|
|
Loading…
Reference in New Issue