Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring

# Conflicts:
#	dmp-backend/web/src/main/java/eu/eudat/controllers/QuickWizardController.java
#	dmp-backend/web/src/main/java/eu/eudat/logic/managers/QuickWizardManager.java
This commit is contained in:
ikalyvas 2019-03-05 17:46:18 +02:00
commit 5ae18beb5d
43 changed files with 1045 additions and 382 deletions

View File

@ -11,10 +11,12 @@ import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
import eu.eudat.logic.managers.DataManagementPlanManager;
import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.managers.FileManager;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.files.ContentFile;
import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.helpers.responses.ResponseItem;
@ -30,9 +32,11 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.activation.MimetypesFileTypeMap;
import javax.validation.Valid;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@ -172,5 +176,12 @@ public class DMPs extends BaseController {
responseHeaders,
HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
public ResponseEntity<ResponseItem> dmpXmlUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws IOException, JAXBException, Exception {
this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List>()
.status(ApiMessageCode.SUCCESS_MESSAGE).message("Bravo Giorgo"));
}
}

View File

@ -49,5 +49,4 @@ public class FileController extends BaseController {
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "." + type + "\"")
.body(resource);
}
}

View File

@ -16,21 +16,24 @@ import eu.eudat.models.data.quickwizard.DatasetCreateWizardModel;
import javax.transaction.Transactional;
import javax.validation.Valid;
@RestController
@CrossOrigin
@RequestMapping(value = {"/api/quick-wizard/"})
public class QuickWizardController extends BaseController {
private QuickWizardManager quickWizardManager;
private ProjectManager projectManager;
private DatasetManager datasetManager;
@Autowired
public QuickWizardController(ApiContext apiContext, QuickWizardManager quickWizardManager,DatasetManager datasetManager) {
public QuickWizardController(ApiContext apiContext, QuickWizardManager quickWizardManager, DatasetManager datasetManager, ProjectManager projectManager) {
super(apiContext);
this.quickWizardManager = quickWizardManager;
this.datasetManager = datasetManager;
this.projectManager = projectManager;
}
@ -38,7 +41,33 @@ public class QuickWizardController extends BaseController {
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<QuickWizardModel>> addQuickWizardModel(@Valid @RequestBody QuickWizardModel quickWizard, Principal principal) throws Exception {
this.quickWizardManager.createOrUpdate(quickWizard, principal);
eu.eudat.data.entities.Project projectEntity;
//Create Project
if (quickWizard.getProject().getExistProject() == null) {
projectEntity = this.quickWizardManager.createOrUpdate(quickWizard.getProject().toDataProject(), principal);
} else {
projectEntity = quickWizard.getProject().getExistProject().toDataModel();
}
//Create Dmp
eu.eudat.data.entities.DMP dmpEntity = this.quickWizardManager.createOrUpdate(
quickWizard.getDmp().toDataDmp(
this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(),
projectEntity,
principal),
principal);
//Create Datasets
quickWizard.getDmp().setId(dmpEntity.getId());
for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) {
this.datasetManager.createOrUpdate(dataset.toDataModel(quickWizard.getDmp().toDataDmp(
this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(),
projectEntity,
principal),
quickWizard.getDmp().getDatasetProfile().getId()),
principal);
}
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<QuickWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
}

View File

@ -5,6 +5,8 @@ import eu.eudat.configurations.dynamicproject.entities.Property;
import eu.eudat.data.dao.criteria.*;
import eu.eudat.data.dao.entities.*;
import eu.eudat.data.entities.*;
import eu.eudat.data.entities.Organisation;
import eu.eudat.data.entities.Researcher;
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
@ -21,8 +23,7 @@ import eu.eudat.logic.utilities.documents.word.WordBuilder;
import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder;
import eu.eudat.models.HintedModelFactory;
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel;
import eu.eudat.models.data.dmp.*;
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.helpers.common.DataTableData;
@ -38,10 +39,16 @@ import org.springframework.core.env.Environment;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.activation.MimetypesFileTypeMap;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.*;
import java.math.BigInteger;
import java.net.URL;
@ -126,12 +133,21 @@ public class DataManagementPlanManager {
wordBuilder.addParagraphContent(dmpEntity.getDescription(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
wordBuilder.addParagraphContent("Organisations", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
wordBuilder.addParagraphContent(dmpEntity.getOrganisations().stream().map(x -> x.getLabel()).collect(Collectors.joining(","))
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
if (dmpEntity.getOrganisations().size() > 0) {
wordBuilder.addParagraphContent(dmpEntity.getOrganisations().stream().map(x -> x.getLabel()).collect(Collectors.joining(", "))
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
}
wordBuilder.addParagraphContent("Researchers", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
wordBuilder.addParagraphContent(dmpEntity.getResearchers().stream().map(x -> x.getLabel()).collect(Collectors.joining(","))
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
if (dmpEntity.getResearchers().size() > 0) {
wordBuilder.addParagraphContent(dmpEntity.getResearchers().stream().map(x -> x.getLabel()).collect(Collectors.joining(", "))
, document, ParagraphStyle.TEXT, BigInteger.ZERO);
}
/*wordBuilder.addParagraphContent("DMP Profile", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
if (dmpEntity.getProfile() != null){
wordBuilder.addParagraphContent(dmpEntity.getProfile().getLabel(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
}*/
wordBuilder.addParagraphContent("Datasets", document, ParagraphStyle.TITLE, BigInteger.ZERO);
dmpEntity.getDataset().stream().forEach(datasetEntity -> {
@ -152,7 +168,9 @@ public class DataManagementPlanManager {
e.printStackTrace();
}
});
File exportFile = new File(dmpEntity.getLabel() + ".docx");
String fileName = dmpEntity.getLabel();
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");
File exportFile = new File( fileName + ".docx");
FileOutputStream out = new FileOutputStream(exportFile);
document.write(out);
out.close();
@ -341,7 +359,6 @@ public class DataManagementPlanManager {
}
}
private void copyDatasets(DMP newDmp, DatasetDao datasetDao) {
List<CompletableFuture<Dataset>> futures = new LinkedList<>();
for (Dataset dataset : newDmp.getDataset()) {
@ -407,32 +424,62 @@ public class DataManagementPlanManager {
VisibilityRuleService visibilityRuleService = utilitiesService.getVisibilityRuleService();
eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id));
List<Dataset> datasets = dmp.getDataset().stream().collect(Collectors.toList());
File xmlFile = new File(dmp.getLabel() + ".xml");
String fileName = dmp.getLabel();
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");
File xmlFile = new File(fileName + ".xml");
BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile, true));
Document xmlDoc = XmlBuilder.getDocument();
Element root = xmlDoc.createElement("root");
Element dmpElement = xmlDoc.createElement("dmp");
Element dmpDescription = xmlDoc.createElement("description");
dmpDescription.setTextContent(dmp.getDescription());
dmpElement.appendChild(dmpDescription);
Element dmpName = xmlDoc.createElement("dmpName");
dmpName.setTextContent(dmp.getLabel());
dmpElement.appendChild(dmpName);
Element projectName = xmlDoc.createElement("projectName");
projectName.setTextContent(dmp.getProject().getLabel());
dmpElement.appendChild(projectName);
DMPProfile dmpProfile = dmp.getProfile();
Element dmpProfileElement = xmlDoc.createElement("dmpProfile");
Element dmpProfileName = xmlDoc.createElement("dmpProfileName");
if (!(dmpProfile == null)){
dmpProfileName.setTextContent(dmpProfile.getLabel());
dmpProfileElement.appendChild(dmpProfileName);
Element dmpProfileId = xmlDoc.createElement("dmpProfileId");
dmpProfileId.setTextContent(dmpProfile.getId().toString());
dmpProfileElement.appendChild(dmpProfileId);
}
dmpElement.appendChild(dmpProfileElement);
Element project = xmlDoc.createElement("project");
Element label = xmlDoc.createElement("label");
label.setTextContent(dmp.getProject().getLabel());
project.appendChild(label);
Element projectId = xmlDoc.createElement("id");
projectId.setTextContent(dmp.getProject().getId().toString());
project.appendChild(projectId);
dmpElement.appendChild(project);
Element organisationsElement = xmlDoc.createElement("organisations");
for (Organisation organisation : dmp.getOrganisations()) {
Element organisationElement = xmlDoc.createElement("organisation");
organisationElement.setAttribute("name", organisation.getLabel());
organisationElement.setAttribute("reference", organisation.getReference());
Element organisationNameElement = xmlDoc.createElement("name");
organisationNameElement.setTextContent(organisation.getLabel());
Element organisationReferenceElement = xmlDoc.createElement("reference");
organisationReferenceElement.setTextContent(organisation.getReference());
organisationElement.appendChild(organisationNameElement);
organisationElement.appendChild(organisationReferenceElement);
organisationsElement.appendChild(organisationElement);
}
dmpElement.appendChild(organisationsElement);
Element researchersElement = xmlDoc.createElement("researchers");
for (Researcher researcher : dmp.getResearchers()) {
Element researcherElement = xmlDoc.createElement("organisation");
researcherElement.setAttribute("name", researcher.getLabel());
researcherElement.setAttribute("reference", researcher.getReference());
organisationsElement.appendChild(researcherElement);
Element researcherElement = xmlDoc.createElement("researcher");
Element researcherNameElement = xmlDoc.createElement("name");
researcherNameElement.setTextContent(researcher.getLabel());
Element researcherReferenceElement = xmlDoc.createElement("reference");
researcherReferenceElement.setTextContent(researcher.getReference());
researcherElement.appendChild(researcherNameElement);
researcherElement.appendChild(researcherReferenceElement);
researchersElement.appendChild(researcherElement);
}
dmpElement.appendChild(researchersElement);
Element datasetsElement = xmlDoc.createElement("datasets");
@ -452,9 +499,33 @@ public class DataManagementPlanManager {
datasetElement.appendChild(xmlBuilder.createPages(pagedDatasetProfile.getPages(), visibilityRuleService, xmlDoc));
datasetsElement.appendChild(datasetElement);
}
Element profiles = xmlDoc.createElement("profiles");
// Get DatasetProfiles from dmp to add to XML.
if (dmp.getAssociatedDmps() != null && !dmp.getAssociatedDmps().isEmpty()) {
Document viewStyleDoc = XmlBuilder.fromXml(dmp.getAssociatedDmps());
Element item = (Element) viewStyleDoc.getElementsByTagName("profiles").item(0);
if (item != null) {
NodeList associatedProfilesElement = item.getChildNodes();
for (int temp = 0; temp < associatedProfilesElement.getLength(); temp++) {
Node associatedProfileElement = associatedProfilesElement.item(temp);
if (associatedProfileElement.getNodeType() == Node.ELEMENT_NODE) {
Element profile = xmlDoc.createElement("profile");
Element profileLabel = xmlDoc.createElement("profilelabel");
Node labelNode = associatedProfileElement.getAttributes().item(0);
profileLabel.setTextContent(labelNode.getNodeValue());
profile.appendChild(profileLabel);
Element profileId = xmlDoc.createElement("profileId");
Node idNode = associatedProfileElement.getAttributes().item(1);
profileId.setTextContent(idNode.getNodeValue());
profile.appendChild(profileId);
profiles.appendChild(profile);
}
}
}
}
dmpElement.appendChild(profiles);
dmpElement.appendChild(datasetsElement);
root.appendChild(dmpElement);
xmlDoc.appendChild(root);
xmlDoc.appendChild(dmpElement);
String xml = XmlBuilder.generateXml(xmlDoc);
writer.write(xml);
writer.close();
@ -496,4 +567,65 @@ public class DataManagementPlanManager {
responseHeaders,
HttpStatus.OK);
}
public List<DmpImportModel> createDmpFromXml( ApiContext apiContext, MultipartFile[] files, Principal principal) throws IOException, JAXBException, Exception {
List<DmpImportModel> dataManagementPlans = new ArrayList<>();
// Jaxb approach.
JAXBContext jaxbContext;
for (MultipartFile multipartFile : Arrays.asList(files)){ // Gets one item from the array.
try{
InputStream in = multipartFile.getInputStream(); // Transforms item to InputStream.
jaxbContext = JAXBContext.newInstance(DmpImportModel.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
DmpImportModel dmpImportModel = (DmpImportModel)jaxbUnmarshaller.unmarshal(in);
System.out.println(dmpImportModel.getDmpNameImport());
dataManagementPlans.add(dmpImportModel);
}
catch (IOException | JAXBException ex){
ex.printStackTrace();
}
// TODO Iterate through the list of dataManagmentPlans.
// Creates new dataManagmentPlan to fill it with the data model that was parsed from the xml.
// Creates properties.
DataManagementPlan dm = new DataManagementPlan();
Tuple tuple = new Tuple();
tuple.setId(dataManagementPlans.get(0).getDmpProfile().getDmpProfileId());
tuple.setLabel(dataManagementPlans.get(0).getDmpProfile().getDmpProfileName());
eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
ProjectImportModels projectImport = dataManagementPlans.get(0).getProjectImport();
project.setId(projectImport.getId());
project.setLabel(projectImport.getLabel());
project.setAbbreviation(projectImport.getAbbreviation());
project.setDescription(projectImport.getDescription());
List<eu.eudat.models.data.dmp.AssociatedProfile> associatedProfiles = new LinkedList<>();
for(AssociatedProfileImportModels a : dataManagementPlans.get(0).getProfilesImportModels()) {
AssociatedProfile associatedProfile = new AssociatedProfile();
associatedProfile.setId(a.getId());
associatedProfile.setLabel(a.getLabel());
associatedProfiles.add(associatedProfile);
}
List< eu.eudat.models.data.dmp.Organisation > organisations = new ArrayList<>();
List<eu.eudat.models.data.dmp.Researcher> researchers = new LinkedList<>();
List<eu.eudat.models.data.userinfo.UserInfo> associatedUsers = new LinkedList<>();
List<DynamicFieldWithValue> dynamicFields = new LinkedList<>();
// Sets properties.
dm.setLabel(files[0].getOriginalFilename()); // Sets label.
dm.setProject(project); //Sets project property.
dm.setDescription(dataManagementPlans.get(0).getDescriptionImport()); // Sets description property.
dm.setProfiles(associatedProfiles);
dm.setOrganisations(organisations); // Sets organisations property.
dm.setResearchers(researchers); // Sets researchers property.
dm.setAssociatedUsers(associatedUsers); // Sets associatedUsers property.
dm.setDynamicFields(dynamicFields); // Sets dynamicFields property.
dm.setProfile(tuple);
createOrUpdate(apiContext, dm, principal);
System.out.println(dm);
}
return dataManagementPlans;
}
}

View File

@ -1,8 +1,10 @@
package eu.eudat.logic.managers;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Project;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.data.dao.criteria.ProjectCriteria;
import eu.eudat.data.dao.entities.ContentDao;
import eu.eudat.data.dao.entities.ProjectDao;
import eu.eudat.data.dao.entities.UserInfoDao;
import eu.eudat.data.entities.*;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.helpers.FileStorageService;
import eu.eudat.logic.services.operations.DatabaseRepository;
@ -19,45 +21,46 @@ import java.text.ParseException;
@Component
public class QuickWizardManager {
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
private FileStorageService fileStorageService;
private DatasetManager datasetManager;
private ApiContext apiContext;
private DatabaseRepository databaseRepository;
@Autowired
public QuickWizardManager(ApiContext apiContext, DatasetManager datasetManager) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.fileStorageService = apiContext.getOperationsContext().getFileStorageService();
}
@Autowired
public QuickWizardManager(ApiContext apiContext) {
this.apiContext = apiContext;
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
}
public void createOrUpdate(QuickWizardModel quickWizard, Principal principal) throws Exception {
//Create Project
eu.eudat.data.entities.Project projectEntity = createOrUpdate(quickWizard.getProject().toDataProject(), principal);
public Project createOrUpdate(eu.eudat.models.data.project.Project project, Principal principal) throws ParseException, IOException {
eu.eudat.data.entities.Project projectEntity = project.toDataModel();
projectEntity.setType(eu.eudat.data.entities.Project.ProjectType.INTERNAL.getValue());
projectEntity.setCreationUser(databaseRepository.getUserInfoDao().find(principal.getId()));
Project projectEntityRet = databaseRepository.getProjectDao().createOrUpdate(projectEntity);
return projectEntityRet;
}
//Create Dmp
eu.eudat.data.entities.DMP dmpEntity = createOrUpdate(quickWizard.getDmp().toDataDmp(projectEntity), principal);
public DMP createOrUpdate(DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
DMP newDmp = dataManagementPlan.toDataModel();
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
createProjectIfItDoesntExist(newDmp, user);
newDmp.setCreator(user);
DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
return dmpret;
}
//Create Datasets
quickWizard.getDmp().setId(dmpEntity.getId());
for(DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()){
this.datasetManager.createOrUpdate(dataset.toDataModel(quickWizard.getDmp().toDataDmp(projectEntity),quickWizard.getDmp().getDatasetProfile().getId()), principal);
}
}
private Project createOrUpdate(eu.eudat.models.data.project.Project project, Principal principal) throws ParseException, IOException {
eu.eudat.data.entities.Project projectEntity = project.toDataModel();
projectEntity.setType(eu.eudat.data.entities.Project.ProjectType.INTERNAL.getValue());
projectEntity.setCreationUser(databaseRepository.getUserInfoDao().find(principal.getId()));
Project projectEntityRet = databaseRepository.getProjectDao().createOrUpdate(projectEntity);
return projectEntityRet;
}
private void createProjectIfItDoesntExist(DMP newDmp, UserInfo userInfo) {
if (newDmp.getProject() != null) {
Project project = newDmp.getProject();
ProjectCriteria criteria = new ProjectCriteria();
criteria.setReference(project.getReference());
eu.eudat.data.entities.Project projectEntity = databaseRepository.getProjectDao().getWithCriteria(criteria).getSingleOrDefault();
if (projectEntity != null) project.setId(projectEntity.getId());
else {
project.setType(Project.ProjectType.EXTERNAL.getValue());
databaseRepository.getProjectDao().createOrUpdate(project);
}
}
}
private DMP createOrUpdate(DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
DMP newDmp = dataManagementPlan.toDataModel();
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
newDmp.setCreator(user);
DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
return dmpret;
}
}

View File

@ -0,0 +1,19 @@
package eu.eudat.models.data.dmp;
import java.util.UUID;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "profile")
public class AssociatedProfileImportModels {
private UUID id;
private String label;
@XmlElement(name = "profileId")
public UUID getId() { return id; }
public void setId(UUID id) { this.id = id; }
@XmlElement(name = "profilelabel")
public String getLabel() { return label; }
public void setLabel(String label) { this.label = label; }
}

View File

@ -0,0 +1,9 @@
package eu.eudat.models.data.dmp;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "dataset")
public class DatasetImportModels {
private String name;
}

View File

@ -0,0 +1,98 @@
package eu.eudat.models.data.dmp;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "dmp")
public class DmpImportModel {
private String description;
private String dmpName;
private DmpProfileImportModel profile;
private ProjectImportModels projectImportModels;
private List<AssociatedProfileImportModels> profilesImportModels;
private List<OrganisationImportModel> organisationImportModels;
private List<ResearcherImportModels> researchersImportModels;
private List<UserInfoImportModels> associatedUsersImportModels;
private List<DynamicFieldWithValueImportModels> dynamicFieldsImportModels;
private List<DatasetImportModels> datasetImportModels;
@XmlElement(name = "description")
public String getDescriptionImport() {
return description;
}
public void setDescriptionImport(String description) {
this.description = description;
}
@XmlElement(name = "dmpName")
public String getDmpNameImport() {
return dmpName;
}
public void setDmpNameImport(String dmpName) {
this.dmpName = dmpName;
}
@XmlElement(name = "dmpProfile")
public DmpProfileImportModel getDmpProfile() { return profile; }
public void setDmpProfile(DmpProfileImportModel profile) { this.profile = profile; }
@XmlElement(name = "project")
public ProjectImportModels getProjectImport() {
return projectImportModels;
}
public void setProjectImport(ProjectImportModels projectImportModels) {
this.projectImportModels = projectImportModels;
}
@XmlElementWrapper(name="organisations")
@XmlElement(name = "organisation")
public List<OrganisationImportModel> getOrganisationImportModels() {
return organisationImportModels;
}
public void setOrganisationImportModels(List<OrganisationImportModel> organisationImportModels) {
this.organisationImportModels = organisationImportModels;
}
@XmlElementWrapper(name="profiles")
@XmlElement(name = "profile")
public List<AssociatedProfileImportModels> getProfilesImportModels() {
return profilesImportModels;
}
public void setProfilesImportModels(List<AssociatedProfileImportModels> profilesImportModels) {
this.profilesImportModels = profilesImportModels;
}
@XmlElementWrapper(name="researchers")
@XmlElement(name = "researcher")
public List<ResearcherImportModels> getResearchersImportModels() {
return researchersImportModels;
}
public void setResearchersImportModels(List<ResearcherImportModels> researchersImportModels) {
this.researchersImportModels = researchersImportModels;
}
@XmlElementWrapper(name="UserInfos")
@XmlElement(name = "UserInfo")
public List<UserInfoImportModels> getAssociatedUsersImportModels() {
return associatedUsersImportModels;
}
public void setAssociatedUsersImportModels(List<UserInfoImportModels> associatedUsersImportModels) {
this.associatedUsersImportModels = associatedUsersImportModels;
}
@XmlElementWrapper(name="dynamicFieldWithValues")
@XmlElement(name = "dynamicFieldWithValue")
public List<DynamicFieldWithValueImportModels> getDynamicFieldsImportModels() {
return dynamicFieldsImportModels;
}
public void setDynamicFieldsImportModels(List<DynamicFieldWithValueImportModels> dynamicFieldsImportModels) {
this.dynamicFieldsImportModels = dynamicFieldsImportModels;
}
@XmlElementWrapper(name="datasets")
@XmlElement(name = "dataset")
public List<DatasetImportModels> getDatasetImportModels() { return datasetImportModels; }
public void setDatasetImportModels(List<DatasetImportModels> datasetImportModels) { this.datasetImportModels = datasetImportModels; }
}

View File

@ -0,0 +1,21 @@
package eu.eudat.models.data.dmp;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.UUID;
@XmlRootElement(name = "dmpProfile")
public class DmpProfileImportModel {
private String dmpProfileName;
private UUID dmpProfileId;
@XmlElement(name = "dmpProfileName")
public String getDmpProfileName() { return dmpProfileName; }
public void setDmpProfileName(String dmpProfileName) { this.dmpProfileName = dmpProfileName; }
@XmlElement(name = "dmpProfileId")
public UUID getDmpProfileId() { return dmpProfileId; }
public void setDmpProfileId(UUID dmpProfileId) { this.dmpProfileId = dmpProfileId; }
}

View File

@ -0,0 +1,7 @@
package eu.eudat.models.data.dmp;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "dynamicFieldWithValue")
public class DynamicFieldWithValueImportModels {
}

View File

@ -0,0 +1,35 @@
package eu.eudat.models.data.dmp;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "organisation")
public class OrganisationImportModel {
private String source;
private String name;
private String id;
@XmlElement(name = "source")
public String getOrganaisationSourceImport() {
return source;
}
public void setOrganaisationSourceImport(String source) {
this.source = source;
}
@XmlElement(name = "name")
public String getOrganaisationNameImport() {
return name;
}
public void setOrganaisationNameImport(String name) {
this.name = name;
}
@XmlElement(name = "id")
public String getOrganaisationIdImport() {
return id;
}
public void setOrganaisationIdImport(String id) {
this.id = id;
}
}

View File

@ -0,0 +1,40 @@
package eu.eudat.models.data.dmp;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.UUID;
@XmlRootElement(name = "project")
public class ProjectImportModels {
private UUID id;
private String label;
private String abbreviation;
private String description;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}

View File

@ -0,0 +1,44 @@
package eu.eudat.models.data.dmp;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "researcher")
public class ResearcherImportModels {
private String label;
private String name;
private String id;
private int status;
@XmlElement(name = "label")
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@XmlElement(name = "name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlElement(name = "id")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@XmlElement(name = "status")
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}

View File

@ -0,0 +1,7 @@
package eu.eudat.models.data.dmp;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "userInfo")
public class UserInfoImportModels {
}

View File

@ -1,7 +1,9 @@
package eu.eudat.models.data.quickwizard;
import eu.eudat.data.dao.entities.UserInfoDao;
import eu.eudat.data.entities.Project;
import eu.eudat.models.data.dmp.AssociatedProfile;
import eu.eudat.models.data.security.Principal;
import eu.eudat.models.data.userinfo.UserInfo;
import java.util.Date;
@ -67,7 +69,7 @@ public class DmpQuickWizardModel {
this.project = project;
}
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(Project project) {
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(UserInfoDao userInfoRepository ,Project project, Principal principal) {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlanEntity = new eu.eudat.models.data.dmp.DataManagementPlan();
dataManagementPlanEntity.setId(this.id);
@ -89,7 +91,7 @@ public class DmpQuickWizardModel {
dataManagementPlanEntity.setCreated(new Date());
List<UserInfo> user = new LinkedList<UserInfo>();
eu.eudat.models.data.userinfo.UserInfo usetInfo = new eu.eudat.models.data.userinfo.UserInfo();
usetInfo.fromDataModel(project.getCreationUser());
usetInfo.fromDataModel(userInfoRepository.find(principal.getId()));
user.add(usetInfo);
dataManagementPlanEntity.setAssociatedUsers(user);
return dataManagementPlanEntity;

View File

@ -1,24 +1,18 @@
package eu.eudat.models.data.quickwizard;
import eu.eudat.models.data.project.Project;
import java.util.Date;
import java.util.UUID;
public class ProjectQuickWizardModel {
private UUID id;
private String label;
private eu.eudat.data.entities.Project.Status status;
private String description;
private Project existProject;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
@ -28,15 +22,6 @@ public class ProjectQuickWizardModel {
this.label = label;
}
public short getStatus() {
return status.getValue();
}
public void setStatus(Short status) {
this.status = eu.eudat.data.entities.Project.Status.fromInteger(status);
}
public String getDescription() {
return description;
}
@ -46,19 +31,23 @@ public class ProjectQuickWizardModel {
}
public Project getExistProject() {
return existProject;
}
public void setExistProject(Project existProject) {
this.existProject = existProject;
}
public eu.eudat.models.data.project.Project toDataProject(){
eu.eudat.models.data.project.Project toProject = new eu.eudat.models.data.project.Project();
toProject.setId(this.id);
toProject.setAbbreviation("");
toProject.setLabel(this.label);
toProject.setReference("dmp:" + this.label);
toProject.setUri("");
toProject.setDefinition("");
toProject.setCreated(new Date());
toProject.setStatus(this.status != null ? this.getStatus() : eu.eudat.data.entities.Project.Status.ACTIVE.getValue());
toProject.setModified(new Date());
toProject.setDescription(this.description);
return toProject;
eu.eudat.models.data.project.Project toProject = new eu.eudat.models.data.project.Project();
toProject.setAbbreviation("");
toProject.setLabel(this.label);
toProject.setReference("dmp:" + this.label);
toProject.setUri("");
toProject.setDefinition("");
toProject.setDescription(this.description);
return toProject;
}
}

View File

@ -32,7 +32,6 @@ import { UserService } from './services/user/user.service';
import { CollectionUtils } from './services/utilities/collection-utils.service';
import { TypeUtils } from './services/utilities/type-utils.service';
import { QuickWizardService } from './services/quick-wizard/quick-wizard.service';
import { QuickDatasetCreateWizardService } from './services/dataset-create-wizard/quick-dataset-create-wizard.service';
//
//
// This is shared module that provides all the services. Its imported only once on the AppModule.
@ -85,7 +84,6 @@ export class CoreServiceModule {
DmpInvitationService,
DatasetExternalAutocompleteService,
QuickWizardService,
QuickDatasetCreateWizardService
],
};
}

View File

@ -12,6 +12,9 @@ import { DatasetProfileCriteria } from '../../query/dataset-profile/dataset-prof
import { DmpCriteria } from '../../query/dmp/dmp-criteria';
import { RequestItem } from '../../query/request-item';
import { BaseHttpService } from '../http/base-http.service';
import { ContentType } from '@angular/http/src/enums';
import { BaseHttpParams } from '../../../common/http/base-http-params';
import { InterceptorType } from '../../../common/http/interceptors/interceptor-type';
@Injectable()
export class DmpService {
@ -31,7 +34,6 @@ export class DmpService {
else {
return this.http.post<DataTableData<DmpListingModel>>(this.actionUrl + 'paged?fieldsGroup=' + fieldsGroup, dataTableRequest, { headers: this.headers });
}
}
getSingle(id: String): Observable<DmpModel> {
@ -41,6 +43,7 @@ export class DmpService {
unlock(id: String): Observable<DmpModel> {
return this.http.get<DmpModel>(this.actionUrl + id + '/unlock', { headers: this.headers });
}
createDmp(dataManagementPlanModel: DmpModel): Observable<DmpModel> {
return this.http.post<DmpModel>(this.actionUrl, dataManagementPlanModel, { headers: this.headers });
}
@ -83,4 +86,21 @@ export class DmpService {
let headerPdf: HttpHeaders = this.headers.set('Content-Type', 'application/pdf')
return this.httpClient.get(this.actionUrl + 'getPDF/' + id, { responseType: 'blob', observe: 'response', headers: headerPdf });
}
public uploadXml(fileList: FileList, dmpTitle: string): Observable<ContentType> {
const formData: FormData = new FormData();
//formData.append('file', fileList[0], dmpTitle);
if (fileList instanceof FileList) {
for (let i = 0; i < fileList.length; i++) {
formData.append('file', fileList[i], dmpTitle);
}
} else {
formData.append('file', fileList);
}
const params = new BaseHttpParams();
params.interceptorContext = {
excludedInterceptors: [InterceptorType.JSONContentType]
};
return this.http.post(this.actionUrl + 'upload', formData, { params: params });
}
}

View File

@ -33,7 +33,7 @@ export class QuickWizardCreateAdd extends BaseComponent implements OnInit {
navigateToAdd(){
this.router.navigate(["/quick-wizard-add"]);
this.router.navigate(["/datasetcreatewizard"]);
}

View File

@ -3,13 +3,15 @@
<mat-step class="step-container" [stepControl]="formGroup.get('dmpMeta')">
<ng-template matStepLabel>{{'DATASET-CREATE-WIZARD.FIRST-STEP.TITLE'| translate}}</ng-template>
<form [formGroup]="formGroup.get('dmpMeta')">
<dataset-dmp-selector-component class="col-12" [formGroup]="formGroup.get('dmpMeta')"></dataset-dmp-selector-component>
<dataset-dmp-selector-component class="col-12" [formGroup]="formGroup.get('dmpMeta')">
</dataset-dmp-selector-component>
</form>
<div class="col-12">
<div class="row">
<div class="col"></div>
<div>
<button matStepperNext mat-raised-button color="primary">{{'DATASET-CREATE-WIZARD.ACTIONS.NEXT'| translate}}</button>
<button matStepperNext mat-raised-button
color="primary">{{'DATASET-CREATE-WIZARD.ACTIONS.NEXT'| translate}}</button>
</div>
</div>
</div>
@ -18,16 +20,18 @@
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}}
</ng-template>
<div *ngIf="formGroup.get('datasets')">
<app-dataset-editor-wizard-component class="col-12" [formGroup]="formGroup" [datasetProfile]="formGroup.get('dmpMeta').get('datasetProfile')"
[datasetLabel]="formGroup.get('dmpMeta').get('dmp')">
<div *ngIf="formGroup.get('dmpMeta').valid && isAvtive('step2')">
<app-dataset-editor-wizard-component class="col-12" [formGroup]="formGroup"
[datasetProfile]="formGroup.get('dmpMeta').get('datasetProfile')"
[datasetLabel]="formGroup.get('dmpMeta').get('dmp').value['label']">
</app-dataset-editor-wizard-component>
<!-- [profile]="formGroup.get('dmpMeta').get('profile')" [datasetLabel]="formGroup.get('dmpMeta').get('label')" -->
</div>
<div class="navigation-buttons-container">
<button matStepperPrevious mat-raised-button color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.BACK' | translate}}</button>
<button style="float:right;" matStepperNext mat-raised-button (click)='save()' color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE' | translate}}</button>
<button matStepperPrevious mat-raised-button
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.BACK' | translate}}</button>
<button style="float:right;" matStepperNext mat-raised-button (click)='save()'
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.SAVE' | translate}}</button>
</div>
</mat-step>
</mat-horizontal-stepper>
</div>
</div>

View File

@ -1,12 +1,10 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { Observable } from 'rxjs';
import { FormBuilder, FormGroup } from '@angular/forms';
import { MatStepper } from '@angular/material';
import { BaseComponent } from '../../core/common/base/base.component';
import { TranslateService } from '@ngx-translate/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { DatasetCreateWizardModel } from './dataset-create-wizard.model';
import { Router } from '@angular/router/src/router';
import { BaseComponent } from '../../core/common/base/base.component';
import { QuickWizardService } from '../../core/services/quick-wizard/quick-wizard.service';
import { DatasetCreateWizardModel } from './dataset-create-wizard.model';
@Component({
selector: 'dataset-create-wizard.component',
@ -40,7 +38,16 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit {
submit() {
this.quickWizardService.createQuickDatasetWizard(this.formGroup.value)
.subscribe(data => {
this.router.navigateByUrl('');
this.router.navigateByUrl('/create-add');
})
}
isAvtive(step: string): boolean {
switch (step) {
case 'step1':
return this.stepper.selectedIndex==0;
case 'step2':
return this.stepper.selectedIndex==1;
}
}
}

View File

@ -1,19 +1,15 @@
import { DatasetDmpSelectorModel } from "./dmp-selector/dataset-dmp-selector.model";
import { DmpModel } from "../../core/model/dmp/dmp";
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
import { DatasetProfileModel } from "../../core/model/dataset/dataset-profile";
import { ValidationContext } from "../../common/forms/validation/validation-context";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { BackendErrorValidator } from "../../common/forms/validation/custom-validator";
import { ValidationErrorModel } from "../../common/forms/validation/error-model/validation-error-model";
import { ValidationContext } from "../../common/forms/validation/validation-context";
import { DmpCreateWizardFormModel } from "../../core/model/dmp/dmp-create-wizard/dmp-create-wizard-form.model";
import { DatasetEditorWizardModel } from "../quick-wizard/dataset-editor/dataset-editor-wizard-model";
import { DatasetWizardEditorModel } from "../dataset/dataset-wizard/dataset-wizard-editor.model";
import { DatasetEditorWizardModel } from "../quick-wizard/dataset-editor/dataset-editor-wizard-model";
import { DmpEditorWizardModel } from "../quick-wizard/dmp-editor/dmp-editor-wizard-model";
export class DatasetCreateWizardModel {
public dmpMeta: DmpCreateWizardFormModel;
public datasets: DatasetEditorWizardModel;
public dmpMeta: DmpCreateWizardFormModel;
public datasets: DatasetEditorWizardModel;
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
fromModelDmp(item: DmpCreateWizardFormModel): DatasetCreateWizardModel {
@ -31,7 +27,7 @@ export class DatasetCreateWizardModel {
const formBuilder = new FormBuilder();
const formGroup = formBuilder.group({
dmpMeta: new DmpCreateWizardFormModel().buildForm(),
datasets: new DatasetEditorWizardModel().buildForm()
datasets: new DatasetEditorWizardModel().buildForm()
});
return formGroup;

View File

@ -1,20 +1,16 @@
import { NgModule } from '@angular/core';
import { CommonFormsModule } from '../../common/forms/common-forms.module';
import { CommonUiModule } from '../../common/ui/common-ui.module';
import { FormattingModule } from '../../core/formatting.module';
import { AutoCompleteModule } from '../../library/auto-complete/auto-complete.module';
import { ConfirmationDialogModule } from '../../library/confirmation-dialog/confirmation-dialog.module';
import { UrlListingModule } from '../../library/url-listing/url-listing.module';
import { DatasetDescriptionFormModule } from '../misc/dataset-description-form/dataset-description-form.module';
import { OuickWizardModule } from '../quick-wizard/quick-wizard.module';
import { QuickWizardRoutingModule } from '../quick-wizard/quick-wizard.rooting';
import { DatasetCreateWizard } from './dataset-create-wizard.component';
import { DatasetCreateWizardRoutingModule } from './dataset-create-wizard.routing';
import { CommonUiModule } from '../../common/ui/common-ui.module';
import { CommonFormsModule } from '../../common/forms/common-forms.module';
import { AutoCompleteModule } from '../../library/auto-complete/auto-complete.module';
import { DatasetDmpSelector } from './dmp-selector/dataset-dmp-selector.component';
import { FormattingModule } from '../../core/formatting.module';
import { DatasetEditorWizardComponent } from '../quick-wizard/dataset-editor/dataset-editor-wizard.component';
//import { DatasetDescriptionFormComponent } from '../misc/dataset-description-form/dataset-description-form.component';
//import { FormProgressIndicationComponent } from '../misc/dataset-description-form/components/form-progress-indication/form-progress-indication.component';
import { UrlListingModule } from '../../library/url-listing/url-listing.module';
import { ConfirmationDialogModule } from '../../library/confirmation-dialog/confirmation-dialog.module';
import { DatasetDescriptionFormModule } from '../misc/dataset-description-form/dataset-description-form.module';
import { QuickWizardRoutingModule } from '../quick-wizard/quick-wizard.rooting';
import { OuickWizardModule } from '../quick-wizard/quick-wizard.module';
import { CoreServiceModule } from '../../core/core-service.module';
@NgModule({

View File

@ -392,7 +392,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
openConfirm(dmpLabel, id): void {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px',
//maxWidth: '300px',
data: {
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'),
@ -404,7 +404,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.datasetWizardService.delete(id)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => { this.onCallbackSuccess(); this.router.navigateByUrl('/datasets/dmp/' + this.formGroup.get('dmp').value.id);},
complete => { this.onCallbackSuccess(); this.router.navigateByUrl('/datasets')},
error => this.onCallbackError(error)
);
}

View File

@ -39,7 +39,6 @@ import { AddResearcherComponent } from './add-researcher/add-researcher.componen
import { AvailableProfilesComponent } from './available-profiles/available-profiles.component';
import { DmpEditorModel } from './dmp-editor.model';
import { DmpFinalizeDialogComponent } from './dmp-finalize-dialog/dmp-finalize-dialog.component';
import { DmpProfileStatus } from '../../../core/common/enum/dmp-profile-status';
@Component({
selector: 'app-dmp-editor-component',
@ -193,7 +192,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
.pipe(takeUntil(this._destroyed))
.subscribe(Option => {
if (Option instanceof Object) {
this.selectedDmpProfileDefinition=null;
this.selectedDmpProfileDefinition = null;
this.dmpProfileService.getSingle(Option.id)
.pipe(takeUntil(this._destroyed))
.subscribe(result => {
@ -344,8 +343,8 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
}
});
}
onDeleteCallbackError(error){
this.uiNotificationService.snackBarNotification(error.error.message? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
onDeleteCallbackError(error) {
this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error);
}
// selectOption(option: any) {

View File

@ -1,17 +1,23 @@
<div class="dmp-criteria">
<mat-card class="mat-card">
<mat-card-header>
<mat-card-header class="row">
<mat-card-title>
<h4>{{'CRITERIA.FILTERS'| translate}}</h4>
</mat-card-title>
<div class="col"></div>
<button class="uploadButton" mat-raised-button color="primary" (click)="fileSave($event)" type="button col-auto">
{{'DMP-UPLOAD.UPLOAD-BUTTON' | translate}}
</button>
</mat-card-header>
<div class="row">
<mat-form-field class="col-md-6">
<input matInput placeholder="{{'CRITERIA.DMP.LIKE'| translate}}" name="projectCriteriaLike" [formControl]="formGroup.get('like')" (ngModelChange)="controlModified()">
<input matInput placeholder="{{'CRITERIA.DMP.LIKE'| translate}}" name="projectCriteriaLike" [formControl]="formGroup.get('like')"
(ngModelChange)="controlModified()">
<mat-error *ngIf="formGroup.get('like').hasError('backendError')">{{formGroup.get('like').getError('backendError').message}}</mat-error>
</mat-form-field>
<mat-form-field *ngIf="showProject" class="col-md-6">
<app-multiple-auto-complete [formControl]="formGroup.get('projects')" placeholder="{{'CRITERIA.DMP.PROJECTS' | translate}}" [configuration]="projectAutoCompleteConfiguration">
<app-multiple-auto-complete [formControl]="formGroup.get('projects')" placeholder="{{'CRITERIA.DMP.PROJECTS' | translate}}"
[configuration]="projectAutoCompleteConfiguration">
</app-multiple-auto-complete>
</mat-form-field>
</div>

View File

@ -7,4 +7,12 @@
mat-card {
padding-bottom: 0px;
}
.hidden {
display: none;
}
.uploadButton {
float: right;
}
}

View File

@ -11,6 +11,9 @@ import { MultipleAutoCompleteConfiguration } from '../../../../library/auto-comp
import { RequestItem } from '../../../../core/query/request-item';
import { BaseCriteriaComponent } from '../../../misc/criteria/base-criteria.component';
import { DataTableRequest } from '../../../../core/model/data-table/data-table-request';
import { DmpService } from '../../../../core/services/dmp/dmp.service';
import { MatDialog } from '@angular/material';
import { DmpUploadDialogue } from './upload-dialogue/dmp-upload-dialogue.component';
@Component({
selector: 'app-dmp-criteria-component',
@ -21,6 +24,9 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
@Input() showProject: boolean;
filteringProjectsAsync = false;
sizeError = false;
maxFileSize: number = 1048576;
filteredProjects: ProjectListingModel[];
public formGroup = new FormBuilder().group({
like: new FormControl(),
@ -36,7 +42,9 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
constructor(
public language: TranslateService,
public projectService: ProjectService,
public formBuilder: FormBuilder
private dmpService: DmpService,
public formBuilder: FormBuilder,
private dialog: MatDialog
) {
super(new ValidationErrorModel());
}
@ -79,4 +87,22 @@ export class DmpCriteriaComponent extends BaseCriteriaComponent implements OnIni
projectRequestItem.criteria.like = query;
return this.projectService.getPaged(projectRequestItem, "autocomplete").map(x => x.data);
}
fileSave(event) {
const dialogRef = this.dialog.open(DmpUploadDialogue, {
data: {
fileList: FileList,
success: Boolean,
dmpTitle: String
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result && result.success) {
console.log(result.fileList[0]);
this.dmpService.uploadXml(result.fileList, result.dmpTitle)
.pipe(takeUntil(this._destroyed))
.subscribe();
}
});
}
}

View File

@ -0,0 +1,27 @@
<div class="confirmation-dialog">
<div class="confirmation-message">
<div class="row">
<div class="col-auto">
{{'DMP-UPLOAD.TITLE' | translate}}
</div>
<div class="uploadButton">
<button mat-raised-button color="primary" (click)="fileInput.click()" type="button col-auto">
{{'DMP-UPLOAD.UPLOAD-BUTTON' | translate}}
</button>
<input class="hidden" #fileInput type="file" (change)="uploadFile($event)">
</div>
</div>
</div>
<mat-form-field class="col">
<input class="uploadInput" [(ngModel)]="dmpTitle" matInput placeholder="DMP Name" name="uploadFileInput">
</mat-form-field>
<div class="row">
<div class="col-auto">
<button mat-raised-button color="primary" type="button" (click)="cancel()">{{'DMP-UPLOAD.ACTIONS.CANCEL' | translate}}</button>
</div>
<div class="col"></div>
<div class="col-auto">
<button mat-raised-button color="primary" type="button" (click)="confirm()" [disabled]="data.fileList.length === 0">{{'DMP-UPLOAD.ACTIONS.IMPORT' | translate}}</button>
</div>
</div>
</div>

View File

@ -0,0 +1,21 @@
.confirmation-dialog {
.confirmation-message {
padding-bottom: 20px;
}
.hidden {
display: none;
}
.uploadButton {
float: right;
}
.col-md-6 {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
margin: -4px;
}
}

View File

@ -0,0 +1,37 @@
import { Component, Inject } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { DmpService } from '../../../../../core/services/dmp/dmp.service';
@Component({
selector: 'dmp-upload-dialogue',
templateUrl: './dmp-upload-dialogue.component.html',
styleUrls: ['./dmp-upload-dialogue.component.scss']
})
export class DmpUploadDialogue {
dmpTitle: string;
constructor(
public dialogRef: MatDialogRef<DmpUploadDialogue>,
@Inject(MAT_DIALOG_DATA) public data: any,
) {}
cancel() {
this.data.success = false;
this.dialogRef.close(this.data);
}
confirm() {
this.data.success = true;
this.data.dmpTitle = this.dmpTitle;
this.dialogRef.close(this.data);
}
uploadFile(event) {
const fileList: FileList = event.target.files
this.data.fileList = fileList;
if (this.data.fileList.length > 0) {
this.dmpTitle = fileList.item(0).name;
}
}
}

View File

@ -1,4 +1,4 @@
import { FormBuilder, FormGroup } from "@angular/forms";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { BackendErrorValidator } from "../../../common/forms/validation/custom-validator";
import { ValidationErrorModel } from "../../../common/forms/validation/error-model/validation-error-model";
import { ValidationContext } from "../../../common/forms/validation/validation-context";
@ -17,9 +17,9 @@ export class DatasetEditorWizardModel extends BaseFormModel {
return this;
}
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
buildForm(context: ValidationContext = null): FormGroup {
if (context == null) { context = this.createValidationContext(); }
const formGroup = new FormBuilder().group({});
const formGroup = new FormBuilder().group({},context.getValidation('datasetsList').validators);
const formArray = new Array<FormGroup>();
this.datasetsList.forEach(item => {
const form: FormGroup = item.buildForm();
@ -31,7 +31,7 @@ export class DatasetEditorWizardModel extends BaseFormModel {
createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext();
baseContext.validation.push({ key: 'datasetsList', validators: [BackendErrorValidator(this.validationErrorModel, 'datasetsList')] });
baseContext.validation.push({ key: 'datasetsList', validators:[BackendErrorValidator(this.validationErrorModel, 'datasetsList')] });
return baseContext;
}

View File

@ -35,7 +35,6 @@
</button>
</div>
</div>
<!-- {{this.formGroup.get('datasets').get('datasetsList').value | json }} -->
</mat-card-content>
</mat-card>
</div>
@ -51,7 +50,7 @@
</mat-form-field>
<app-dataset-description-form class="col-12"
[form]="this.formGroup.get('datasets').get('datasetsList')['controls'][lastIndexOfDataset]"
[visibilityRules]="this.datasetProfileDefinition.rules" [datasetProfileId]="profile.value">
[visibilityRules]="this.datasetProfileDefinition.rules" [datasetProfileId]="datasetProfile.value">
</app-dataset-description-form>
</div>
</div>

View File

@ -11,6 +11,7 @@ import { IBreadCrumbComponent } from "../../misc/breadcrumb/definition/IBreadCru
import { DatasetDescriptionFormEditorModel } from "../../misc/dataset-description-form/dataset-description-form.model";
import { QuickWizardDatasetDescriptionModel } from "./quick-wizard-dataset-description-model";
import { IfStmt } from "@angular/compiler";
import { TranslateService } from "@ngx-translate/core";
@ -27,70 +28,81 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni
breadCrumbs: Observable<BreadcrumbItem[]>;
@Input() formGroup: FormGroup;
@Input() profile: FormGroup;// DatasetProfileModel;
@Input() datasetLabel:FormGroup;
@Input() datasetProfile: FormGroup;// DatasetProfileModel;
@Input() datasetLabel: string;
editedDataset: boolean = false;
dataset: DatasetDescriptionFormEditorModel;
public datasetProfileDefinition: DatasetDescriptionFormEditorModel;
public lastIndexOfDataset = 0;
public toggleButton=0;
public toggleButton = 0;
public _inputValue: string;
constructor(
private datasetWizardService: DatasetWizardService
private datasetWizardService: DatasetWizardService,
public language: TranslateService,
) {
super();
}
ngOnInit(): void {
}
onValChange(event: any){
if(event=="list"){
this.toggleButton=0;
this.editedDataset=false;
this._inputValue="list";
}else if (event=="add"){
this.addDataset();
this.toggleButton=2;
this._inputValue="dataset";
}else if (event=="dataset"){
this.toggleButton=2;
this._inputValue="dataset";
}
}
editDataset(index:number){
this.lastIndexOfDataset = index;
this.toggleButton=2;
this.editedDataset=true;
this._inputValue="dataset"
}
deleteDataset(index:number){//TODO: delete Dataset From List
this.lastIndexOfDataset = index;
this.toggleButton=0;
this.editedDataset=false;
this._inputValue="list";
(this.formGroup.get('datasets').get('datasetsList') as FormArray).removeAt(index);
}
addDataset() {
this.datasetWizardService.getDefinition(this.profile.value["id"])
this.datasetWizardService.getDefinition(this.datasetProfile.value["id"])
.pipe(takeUntil(this._destroyed))
.subscribe(item => {
this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item);
const formArray: FormArray = (this.formGroup.get('datasets').get('datasetsList') as FormArray);
this.lastIndexOfDataset = formArray.length;
let dataset = new QuickWizardDatasetDescriptionModel().fromModel(this.datasetProfileDefinition);
let formGroup = dataset.buildForm();
formGroup.get('datasetLabel').setValue("Dataset :"+this.profile.value["label"]+" For Dmp : "+this.datasetLabel.value);
formArray.push(formGroup);
this.editedDataset=true;
this.onValChange("list");
const length = (this.formGroup.get('datasets').get('datasetsList') as FormArray).length;
if (length == 0) {
this.lastIndexOfDataset = length;
this.addDataset();
this.onValChange("dataset");
}
});
}
onValChange(event: any) {
if (event == "list") {
this.toggleButton = 0;
this.editedDataset = false;
this._inputValue = "list";
} else if (event == "add") {
this.addDataset();
this.toggleButton = 2;
this._inputValue = "dataset";
} else if (event == "dataset") {
this.toggleButton = 2;
this._inputValue = "dataset";
}
}
editDataset(index: number) {
this.lastIndexOfDataset = index;
this.toggleButton = 2;
this.editedDataset = true;
this._inputValue = "dataset"
}
deleteDataset(index: number) {//TODO: delete Dataset From List
this.lastIndexOfDataset = index;
this.toggleButton = 0;
this.editedDataset = false;
this._inputValue = "list";
(this.formGroup.get('datasets').get('datasetsList') as FormArray).removeAt(index);
}
addDataset() {
const formArray: FormArray = (this.formGroup.get('datasets').get('datasetsList') as FormArray);
let dataset = new QuickWizardDatasetDescriptionModel().fromModel(this.datasetProfileDefinition);
let formGroup = dataset.buildForm();
formGroup.get('datasetLabel').setValue(
this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-NAME') +
this.datasetProfile.value["label"] +
this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-NAME-FOR') +
this.datasetLabel);
formArray.push(formGroup);
this.lastIndexOfDataset = formArray.length - 1;
this.editedDataset = true;
}

View File

@ -29,7 +29,7 @@
<mat-form-field class="col-12">
<app-single-auto-complete [required]='true' [formControl]="formGroup.get('datasetProfile')"
placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.FIELDS.PROFILE' | translate}}"
[configuration]="profilesAutoCompleteConfiguration">
[configuration]="profilesAutoCompleteConfiguration" [disabled]="dataseteIsEmpty()">
</app-single-auto-complete>
<mat-error *ngIf="formGroup.get('datasetProfile').hasError('backendError')">
{{formGroup.get('datasetProfile').getError('backendError').message}}</mat-error>

View File

@ -1,20 +1,20 @@
import { Component, OnInit, Input } from '@angular/core';
import { BaseComponent } from "../../../core/common/base/base.component";
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { Observable } from 'rxjs';
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { Component, Input, OnInit } from '@angular/core';
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
import { MatSnackBar } from '@angular/material';
import { Router, ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { FormGroup, AbstractControl, FormControl, FormArray } from '@angular/forms';
import { DmpEditorWizardModel } from './dmp-editor-wizard-model';
import { UiNotificationService, SnackBarNotificationLevel } from '../../../core/services/notification/ui-notification-service';
import { Observable } from 'rxjs';
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
import { SingleAutoCompleteConfiguration } from '../../../library/auto-complete/single/single-auto-complete-configuration';
import { BaseComponent } from "../../../core/common/base/base.component";
import { DatasetProfileModel } from '../../../core/model/dataset/dataset-profile';
import { RequestItem } from '../../../core/query/request-item';
import { DatasetProfileCriteria } from '../../../core/query/dataset-profile/dataset-profile-criteria';
import { RequestItem } from '../../../core/query/request-item';
import { DmpService } from '../../../core/services/dmp/dmp.service';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
import { SingleAutoCompleteConfiguration } from '../../../library/auto-complete/single/single-auto-complete-configuration';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { DmpEditorWizardModel } from './dmp-editor-wizard-model';
@Component({
@ -23,33 +23,34 @@ import { DmpService } from '../../../core/services/dmp/dmp.service';
styleUrls: ['./dmp-editor-wizard.component.scss']
})
export class DmpEditorWizardComponent extends BaseComponent implements OnInit, IBreadCrumbComponent {
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
isNew = true;
dmp: DmpEditorWizardModel;
@Input() formGroup: FormGroup;
@Input() dmpLabel: FormGroup;
@Input() dmpLabel: string;
@Input() datasetFormGroup: FormGroup;
//formGroup: FormGroup = null;
private uiNotificationService: UiNotificationService
profilesAutoCompleteConfiguration:SingleAutoCompleteConfiguration;
profilesAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
filteredProfiles: DatasetProfileModel[];
filteredProfilesAsync = false;
filteredProfilesAsync = false;
constructor(
public snackBar: MatSnackBar,
public router: Router,
private route: ActivatedRoute,
private _service: DmpService,
public language: TranslateService,
public language: TranslateService
) {
super();
}
ngOnInit(): void {
this.profilesAutoCompleteConfiguration = {
filterFn: this.filterProfiles.bind(this),
initialItems: (extraData) => this.filterProfiles(''),
@ -62,15 +63,16 @@ export class DmpEditorWizardComponent extends BaseComponent implements OnInit, I
this.dmp = new DmpEditorWizardModel();
this.formGroup = this.dmp.buildForm();
}
this.formGroup.get('label').setValue("Dmp From Project : "+ this.dmpLabel.value);
this.formGroup.get('label').setValue(this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.DMP-NAME') + this.dmpLabel);
this.formGroup.get('label').setValue(this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.DMP-NAME') + this.dmpLabel);
this.breadCrumbs = Observable.of([
{
parentComponentName: 'project',
label: 'Dmp',
url: '/quick-wizard/dmp'
parentComponentName: 'project',
label: 'Dmp',
url: '/quick-wizard/dmp'
}]
);
);
}
@ -142,17 +144,22 @@ export class DmpEditorWizardComponent extends BaseComponent implements OnInit, I
filterProfiles(value: string): Observable<DatasetProfileModel[]> {
this.filteredProfiles = undefined;
this.filteredProfilesAsync = true;
const request = new RequestItem<DatasetProfileCriteria>();
const criteria = new DatasetProfileCriteria();
criteria.like = value;
request.criteria = criteria;
return this._service.searchDMPProfiles(request);
}
this.filteredProfiles = undefined;
this.filteredProfilesAsync = true;
const request = new RequestItem<DatasetProfileCriteria>();
const criteria = new DatasetProfileCriteria();
criteria.like = value;
request.criteria = criteria;
return this._service.searchDMPProfiles(request);
}
dataseteIsEmpty() {
if (this.datasetFormGroup && this.datasetFormGroup.get('datasetsList') && (this.datasetFormGroup.get('datasetsList') as FormArray).length != 0) {
return true;
}
return false;
}
}

View File

@ -4,12 +4,14 @@ import { ValidationContext } from "../../../common/forms/validation/validation-c
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
import { BackendErrorValidator } from "../../../common/forms/validation/custom-validator";
import { ValidationErrorModel } from "../../../common/forms/validation/error-model/validation-error-model";
import { ValidJsonValidator } from "../../../library/auto-complete/auto-complete-custom-validator";
export class ProjectEditorWizardModel {
public id: string;
public label: string;
public status: Status = Status.Active;
public description: String;
public existProject: ProjectListingModel;
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
@ -29,6 +31,7 @@ export class ProjectEditorWizardModel {
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
existProject: [{ value: this.existProject, disabled: disabled }, context.getValidation('existProject').validators],
});
return formGroup;
}
@ -39,6 +42,10 @@ export class ProjectEditorWizardModel {
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
baseContext.validation.push({ key: 'status', validators: [] });
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
baseContext.validation.push({ key: 'existProject', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'existProject')] });
return baseContext;
}
}

View File

@ -1,42 +1,68 @@
<div class="project-editor">
<mat-card-title *ngIf="isNew">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.NEW-TITLE' | translate}}</mat-card-title>
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
<form *ngIf="formGroup" [formGroup]="formGroup">
<mat-card>
<mat-card-header>
</mat-card-header>
<mat-card-content>
<div class="row">
<div class="row" *ngIf="!isNew">
<mat-form-field class="col-md-12">
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.LABEL' | translate}}" type="text" name="label" formControlName="label" required>
<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 class="col-md-6">
<input matInput (focus)="startDate.open()" (click)="startDate.open()" placeholder="{{'PROJECT-EDITOR.FIELDS.START' | translate}}" class="table-input" [matDatepicker]="startDate" formControlName="startDate">
<mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
<mat-datepicker #startDate></mat-datepicker>
<mat-error *ngIf="formGroup.get('startDate').hasError('backendError')">{{formGroup.get('startDate').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('startDate').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-form-field class="col-md-6">
<input matInput (focus)="endDate.open()" (click)="endDate.open()" placeholder="{{'PROJECT-EDITOR.FIELDS.END' | translate}}" class="table-input" [matDatepicker]="endDate" formControlName="endDate">
<mat-datepicker-toggle matSuffix [for]="endDate"></mat-datepicker-toggle>
<mat-datepicker #endDate></mat-datepicker>
<mat-error *ngIf="formGroup.get('endDate').hasError('backendError')">{{formGroup.get('endDate').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('endDate').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<mat-error *ngIf="formGroup.hasError('startAfterEndError')"class="col-md-12">{{'GENERAL.VALIDATION.PROJECT-START-AFTER-END' | translate}}</mat-error> -->
<mat-form-field class="col-md-12">
<textarea matInput class="description-area" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.DESCRIPTION' | translate}}" formControlName="description" required></textarea>
<mat-error *ngIf="formGroup.get('description').hasError('backendError')">{{formGroup.get('description').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('description').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<app-single-auto-complete required='true' [formControl]="formGroup.get('existProject')"
placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.SELECT-PROJECT' | translate}}"
[configuration]="projectAutoCompleteConfiguration">
</app-single-auto-complete>
<mat-error *ngIf="formGroup.hasError('backendError')">
{{formGroup.get('project').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="row" *ngIf="isNew">
<mat-form-field class="col-md-12">
<input matInput
placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.LABEL' | translate}}"
type="text" name="label" [formControl]="formGroup.get('label')" required>
<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 class="col-md-12">
<textarea matInput class="description-area"
placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.DESCRIPTION' | translate}}"
[formControl]="formGroup.get('description')" required></textarea>
<mat-error *ngIf="formGroup.get('description').hasError('backendError')">
{{formGroup.get('description').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('description').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="row">
<div class="col">
<hr>
</div>
<h3 class="col-auto">
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.OR' | translate}}
</h3>
<div class="col">
<hr>
</div>
</div>
<div class="row">
<div class="col"></div>
<button mat-raised-button class="col-auto" color="primary" type="button" *ngIf="!isNew"
(click)="create()">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.CREATE-NEW' | translate}}</button>
<button mat-raised-button class="col-auto" color="primary" type="button" *ngIf="isNew"
(click)="create()">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST' | translate}}</button>
<div class="col"></div>
</div>
</mat-card-content>
</mat-card>
</form>
</div>
</div>

View File

@ -1,16 +1,20 @@
import { Component, OnInit, Input } from '@angular/core';
import { BaseComponent } from "../../../core/common/base/base.component";
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { Component, Input, OnInit } from '@angular/core';
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
import { MatSnackBar } from '@angular/material';
import { ActivatedRoute, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
import { BaseComponent } from "../../../core/common/base/base.component";
import { ProjectCriteria } from '../../../core/query/project/project-criteria';
import { RequestItem } from '../../../core/query/request-item';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
import { ProjectService } from '../../../core/services/project/project.service';
import { SingleAutoCompleteConfiguration } from '../../../library/auto-complete/single/single-auto-complete-configuration';
import { LanguageResolverService } from '../../../services/language-resolver/language-resolver.service';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { ProjectEditorWizardModel } from './project-editor-wizard-model';
import { MatSnackBar } from '@angular/material';
import { Router, ActivatedRoute, Params } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
import { FormGroup, AbstractControl, FormControl, FormArray } from '@angular/forms';
import { takeUntil } from 'rxjs/operators';
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
@Component({
selector: 'app-quick-wizard-project-editor-component',
@ -20,27 +24,26 @@ import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/
export class ProjectEditorWizardComponent extends BaseComponent implements OnInit, IBreadCrumbComponent {
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]);
isNew = true;
isNew = false;
project: ProjectEditorWizardModel;
@Input() formGroup: FormGroup;
//formGroup: FormGroup = null;
private uiNotificationService: UiNotificationService
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
constructor(
public snackBar: MatSnackBar,
private route: ActivatedRoute,
public router: Router,
public language: TranslateService,
private projectService: ProjectService,
public languageResolverService: LanguageResolverService,
) {
super();
}
ngOnInit() {
if (this.formGroup == null) {
this.project = new ProjectEditorWizardModel();
this.formGroup = this.project.buildForm();
}
this.breadCrumbs = Observable.of([
{
parentComponentName: 'QuickCreate',
@ -48,6 +51,29 @@ export class ProjectEditorWizardComponent extends BaseComponent implements OnIni
url: '/quick-wizard/project'
}]
);
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
this.projectAutoCompleteConfiguration = {
filterFn: this.searchProject.bind(this),
initialItems: (extraData) => this.searchProject(''),
displayFn: (item) => item['label'],
titleFn: (item) => item['label']
};
if (!this.formGroup) {
this.project = new ProjectEditorWizardModel();
this.formGroup = this.project.buildForm();
}
this.formGroup.get('existProject').enable();
this.formGroup.get('label').disable();
this.formGroup.get('description').disable();
// this.route.params
// .pipe(takeUntil(this._destroyed))
// .subscribe((params: Params) => {
@ -76,11 +102,6 @@ export class ProjectEditorWizardComponent extends BaseComponent implements OnIni
// });
}
formSubmit(): void {
this.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) { return; }
this.onSubmit();
}
public isFormValid() {
return this.formGroup.valid;
@ -101,16 +122,6 @@ export class ProjectEditorWizardComponent extends BaseComponent implements OnIni
}
}
onSubmit(): void {
// this.projectService.createProject(this.formGroup.value)
// .pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => this.onCallbackSuccess(),
// error => this.onCallbackError(error)
// );
}
onCallbackSuccess(): void {
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/project']);
@ -143,4 +154,27 @@ export class ProjectEditorWizardComponent extends BaseComponent implements OnIni
}
searchProject(query: string) {
const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new ProjectCriteria();
projectRequestItem.criteria.like = query;
return this.projectService.getWithExternal(projectRequestItem);
}
create() {
this.isNew = !this.isNew;
if (this.isNew) {
this.formGroup.get('existProject').disable();
this.formGroup.get('existProject').reset();
this.formGroup.get('label').enable();
this.formGroup.get('description').enable();
} else {
this.formGroup.get('existProject').enable();
this.formGroup.get('label').disable();
this.formGroup.get('label').reset();
this.formGroup.get('description').disable();
this.formGroup.get('description').reset();
}
}
}

View File

@ -4,29 +4,28 @@
<div class="row">
<mat-horizontal-stepper linear class="col-12" #stepper>
<mat-step [stepControl]="formGroup.get('project')">
<ng-container *ngIf="isAvtive('step1')">
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.TITLE' | translate}}
</ng-template>
<div *ngIf="formGroup.get('project')">
<app-quick-wizard-project-editor-component class="col-12"
[formGroup]="formGroup.get('project')">
</app-quick-wizard-project-editor-component>
</div>
<div class="navigation-buttons-container">
<button style="float:right;" matStepperNext mat-raised-button
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.NEXT' | translate}}</button>
</div>
</ng-container>
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.TITLE' | translate}}
</ng-template>
<div *ngIf="formGroup.get('project')">
<app-quick-wizard-project-editor-component class="col-12"
[formGroup]="formGroup.get('project')">
</app-quick-wizard-project-editor-component>
</div>
<div class="navigation-buttons-container">
<button style="float:right;" matStepperNext mat-raised-button
color="primary">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.NEXT' | translate}}</button>
</div>
</mat-step>
<mat-step [stepControl]="formGroup.get('dmp')">
<ng-container *ngIf="isAvtive('step2')">
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.TITLE' | translate}}
</ng-template>
<div *ngIf="formGroup.get('dmp')">
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.SECOND-STEP.TITLE' | translate}}
</ng-template>
<ng-container *ngIf="formGroup.get('project').valid">
<div>
<app-quick-wizard-dmp-editor-component class="col-12" [formGroup]="formGroup.get('dmp')"
[dmpLabel]="formGroup.get('project').get('label')">
[datasetFormGroup]="formGroup.get('datasets')"
[dmpLabel]=" getProjectLabel()">
</app-quick-wizard-dmp-editor-component>
</div>
<div class="navigation-buttons-container">
@ -38,15 +37,16 @@
</ng-container>
</mat-step>
<mat-step [stepControl]="formGroup.get('datasets')">
<ng-container *ngIf="isAvtive('step3')">
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}}
</ng-template>
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.TITLE' | translate}}
</ng-template>
<!-- <ng-container *ngIf="isAvtive('step3')"> -->
<ng-container *ngIf="formGroup.get('dmp').valid && isActive('step3')">
<div *ngIf="formGroup.get('datasets')">
<!-- <div *ngIf="this.isActiveStep(3)" class="row"> -->
<app-dataset-editor-wizard-component class="col-12" [formGroup]="formGroup"
[datasetProfile]="formGroup.get('dmp').get('datasetProfile')"
[datasetLabel]="formGroup.get('dmp').get('label')">
[datasetLabel]="formGroup.get('dmp').get('label').value">
</app-dataset-editor-wizard-component>
<!-- <app-dataset-description-form class="col-12" *ngIf="formGroup && datasetWizardModel && datasetWizardModel.datasetProfileDefinition"
[form]="this.formGroup.get('datasetProfileDefinition')" [visibilityRules]="datasetWizardModel.datasetProfileDefinition.rules"
@ -67,4 +67,4 @@
</mat-horizontal-stepper>
</div>
</form>
</div>
</div>

View File

@ -8,13 +8,11 @@ import { takeUntil } from 'rxjs/operators';
import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model';
import { BaseComponent } from "../../../core/common/base/base.component";
import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service';
import { QuickWizardService } from '../../../core/services/quick-wizard/quick-wizard.service';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCrumbComponent';
import { DmpEditorWizardModel } from '../dmp-editor/dmp-editor-wizard-model';
import { ProjectEditorWizardModel } from '../project-editor/project-editor-wizard-model';
import { QuickWizardEditorWizardModel } from './quick-wizard-editor.model';
import { QuickWizardService } from '../../../core/services/quick-wizard/quick-wizard.service';
import { DatasetEditorWizardModel } from '../dataset-editor/dataset-editor-wizard-model';
@ -34,7 +32,6 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
formGroup: FormGroup = null;
firstStepFormGroup: FormGroup;
secondFormGroup: FormGroup;
uiNotificationService: any;
constructor(
@ -42,16 +39,15 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
private route: ActivatedRoute,
public router: Router,
public language: TranslateService,
public quickWizardService: QuickWizardService
public quickWizardService: QuickWizardService,
private uiNotificationService: UiNotificationService
) {
super();
}
ngOnInit(): void {
this.quickWizard = new QuickWizardEditorWizardModel();
// this.quickWizard.project = new ProjectEditorWizardModel();
// this.quickWizard.dmp = new DmpEditorWizardModel();
// this.quickWizard.datasets = new DatasetEditorWizardModel();
this.quickWizard.project = new ProjectEditorWizardModel();
this.formGroup = this.quickWizard.buildForm();
this.breadCrumbs = Observable.of([
{
@ -60,48 +56,28 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
url: '/quick-wizard'
}]
);
// this.route.params
// .pipe(takeUntil(this._destroyed))
// .subscribe((params: Params) => {
// const itemId = params['id'];
// if (itemId != null) {
// this.isNew = false;
// this.projectService.getSingle(itemId).map(data => data as ProjectListingModel)
// .pipe(takeUntil(this._destroyed))
// .subscribe(data => {
// this.project = new ProjectEditorModel().fromModel(data);
// this.formGroup = this.project.buildForm(null, this.project.type === ProjectType.External || !this.editMode);
// this.breadCrumbs = Observable.of([
// { parentComponentName: 'ProjectListingComponent', label: 'Projects', url: '/projects' },
// ]);
// });
// } else {
// this.breadCrumbs = Observable.of([
// { parentComponentName: '/', label: 'QuickWizard', url: '/quickwizard' },
// ]);
// setTimeout(() => {
// this.formGroup = this.quickWizard.buildForm();
// });
// }
// });
}
isAvtive(step: string): boolean {
isActive(step: string): boolean {
switch (step) {
case 'step1':
return this.stepper.selectedIndex==0;
return this.stepper.selectedIndex == 0;
case 'step2':
return this.stepper.selectedIndex==1;
return this.stepper.selectedIndex == 1;
case 'step3':
return this.stepper.selectedIndex==2;
return this.stepper.selectedIndex == 2;
}
}
formSubmit(): void {
this.touchAllFormFields(this.formGroup);
if (!this.isFormValid()) { return; }
this.onSubmit();
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
this.onSubmit();
} else {
return;
}
}
public isFormValid() {
@ -125,7 +101,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
onSubmit(): void {
if (!this.isFormValid()) { return; }
this.quickWizardService.createQuickWizard(this.formGroup.value)
this.quickWizardService.createQuickWizard(this.formGroup.getRawValue())
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess(),
@ -136,19 +112,19 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
onCallbackSuccess(): void {
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.router.navigate(['/quickwizard']);
this.router.navigate(['/home/create-add']);
}
onCallbackError(errorResponse: any) {
// this.setErrorModel(errorResponse.error.payload);
this.setErrorModel(errorResponse.error.payload);
this.validateAllFormFields(this.formGroup);
}
// public setErrorModel(validationErrorModel: ValidationErrorModel) {
// Object.keys(validationErrorModel).forEach(item => {
// (<any>this.quickWizard.validationErrorModel)[item] = (<any>validationErrorModel)[item];
// });
// }
public setErrorModel(validationErrorModel: ValidationErrorModel) {
Object.keys(validationErrorModel).forEach(item => {
(<any>this.quickWizard.validationErrorModel)[item] = (<any>validationErrorModel)[item];
});
}
public validateAllFormFields(formControl: AbstractControl) {
if (formControl instanceof FormControl) {
@ -165,9 +141,16 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
}
}
isActiveStep(index: number) {
return this.stepper.selectedIndex === index;
getProjectLabel(): string {
if (this.formGroup.get('project').get('existProject').value) {
return this.formGroup.get('project').get('existProject').value['label'];
} else {
return this.formGroup.get('project').get('label').value;
}
}
}

View File

@ -34,10 +34,9 @@ export class QuickWizardEditorWizardModel {
return this;
}
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
if (context == null) { context = this.createValidationContext(); }
buildForm(context: ValidationContext = null): FormGroup {
// if (context == null) { context = this.createValidationContext(); }
const formGroup = new FormBuilder().group({
project: new ProjectEditorWizardModel().buildForm(),
dmp: new DmpEditorWizardModel().buildForm(),
datasets: new DatasetEditorWizardModel().buildForm()
@ -46,12 +45,12 @@ export class QuickWizardEditorWizardModel {
return formGroup;
}
createValidationContext(): ValidationContext {
const baseContext: ValidationContext = new ValidationContext();
baseContext.validation.push({ key: 'project', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'project')] });
baseContext.validation.push({ key: 'dmp', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'dmp')] });
baseContext.validation.push({ key: 'datasets', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'datasets')] });
return baseContext;
}
// createValidationContext(): ValidationContext {
// const baseContext: ValidationContext = new ValidationContext();
// baseContext.validation.push({ key: 'project', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'project')] });
// baseContext.validation.push({ key: 'dmp', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'dmp')] });
// baseContext.validation.push({ key: 'datasets', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'datasets')] });
// return baseContext;
// }
}

View File

@ -677,12 +677,15 @@
"DELETE": "Delete",
"SAVE": "Save",
"NEXT": "Next",
"BACK": "Back"
"BACK": "Back",
"CREATE-NEW":"Create new",
"EXIST":"Existing Project"
},
"FIRST-STEP": {
"TITLE": "Create Project",
"NEW-TITLE": "New Project",
"TITLE": "Select Project",
"OR": "or",
"FIELDS": {
"SELECT-PROJECT":"Select Project",
"LABEL": "Label",
"DESCRIPTION": "Description"
}
@ -690,6 +693,7 @@
"SECOND-STEP": {
"TITLE": "Create Dmp",
"NEW-TITLE": "New Data Management Plan",
"DMP-NAME":"Dmp For Project : ",
"FIELDS": {
"NAME": "Name of the Dmp",
"DESCRIPTION": "Description",
@ -699,7 +703,9 @@
"THIRD-STEP": {
"TITLE": "Create Dataset",
"NEW-TITLE":"New Dataset",
"DATASET-LABEL":"Dataset Name"
"DATASET-LABEL":"Dataset Name",
"DATASET-NAME":"Dataset : ",
"DATASET-NAME-FOR":" For Dmp : "
}
}
},