Merge branch 'Development' of code-repo.d4science.org:MaDgiK-CITE/argos into Development

 Conflicts:
	dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/field/dataset-profile-editor-field.component.ts
This commit is contained in:
argirok 2022-02-18 17:09:34 +02:00
commit cc926970ca
33 changed files with 331 additions and 204 deletions

View File

@ -15,6 +15,7 @@ import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.logic.utilities.documents.pdf.PDFUtils;
import eu.eudat.models.data.dataset.DatasetOverviewModel;
@ -126,11 +127,11 @@ public class Datasets extends BaseController {
public @ResponseBody
ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException {
try {
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
if (contentType.equals("application/xml")) {
VisibilityRuleService visibilityRuleService = this.getApiContext().getUtilitiesService().getVisibilityRuleService();
return this.datasetManager.getDocument(id, visibilityRuleService, contentType, principal);
} else if (contentType.equals("application/msword")) {
FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService(), principal);
FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, visibilityRuleService, principal);
InputStream resource = new FileInputStream(file.getFile());
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(file.getFile().length());
@ -218,7 +219,7 @@ public class Datasets extends BaseController {
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
public @ResponseBody
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService(), principal);
FileEnvelope file = datasetManager.getWordDocumentFile(this.configLoader, id, new VisibilityRuleServiceImpl(), principal);
String fileName = file.getFilename().replace(" ", "_").replace(",", "_");
if (fileName.endsWith(".docx")){
fileName = fileName.substring(0, fileName.length() - 5);

View File

@ -1,7 +1,5 @@
package eu.eudat.logic.managers;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
import eu.eudat.configurations.dynamicgrant.entities.Property;
@ -33,6 +31,7 @@ import eu.eudat.logic.mapper.elastic.criteria.DmpCriteriaMapper;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.logic.services.utilities.UtilitiesService;
import eu.eudat.logic.utilities.builders.XmlBuilder;
@ -106,7 +105,6 @@ public class DataManagementPlanManager {
private ApiContext apiContext;
private DatasetManager datasetManager;
private UtilitiesService utilitiesService;
private DatabaseRepository databaseRepository;
private Environment environment;
private RDAManager rdaManager;
@ -117,7 +115,6 @@ public class DataManagementPlanManager {
public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment, RDAManager rdaManager, UserManager userManager, MetricsManager metricsManager) {
this.apiContext = apiContext;
this.datasetManager = datasetManager;
this.utilitiesService = apiContext.getUtilitiesService();
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
this.environment = environment;
this.rdaManager = rdaManager;
@ -1172,7 +1169,7 @@ public class DataManagementPlanManager {
public FileEnvelope getWordDocument(String id, Principal principal, ConfigLoader configLoader, Boolean versioned) throws IOException {
WordBuilder wordBuilder = new WordBuilder();
VisibilityRuleService visibilityRuleService = this.utilitiesService.getVisibilityRuleService();
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
DatasetWizardModel dataset = new DatasetWizardModel();
XWPFDocument document = configLoader.getDocument();
@ -1341,7 +1338,7 @@ public class DataManagementPlanManager {
private FileEnvelope getXmlDocument(String id, Principal principal) throws InstantiationException, IllegalAccessException, IOException {
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
VisibilityRuleService visibilityRuleService = utilitiesService.getVisibilityRuleService();
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id));
if (!dmp.isPublic() && dmp.getUsers().stream().filter(userInfo -> userInfo.getUser().getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
throw new UnauthorisedException();

View File

@ -164,18 +164,23 @@ public class DataManagementProfileManager {
}
private List<Tuple<String, String>> externalAutocompleteRequest(DmpProfileExternalAutoComplete data, String like) {
List<Tuple<String, String>> result = new LinkedList<>();
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.valueOf("application/vnd.api+json; charset=utf-8")));
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> entity = new HttpEntity<>("parameters", headers);
ResponseEntity<Object> response = restTemplate.exchange(data.getUrl() + "?search=" + like, HttpMethod.GET, entity, Object.class);
DocumentContext jsonContext = JsonPath.parse(response.getBody());
List<Map<String, String>> jsonItems = jsonContext.read(data.getOptionsRoot() + "['" + data.getLabel() + "','" + data.getValue() + "']");
jsonItems.forEach(item -> result.add(new Tuple<>(item.get(data.getValue()), item.get(data.getLabel()))));
return result;
return externalAutocompleteRequest(data.getUrl(), data.getOptionsRoot(), data.getLabel(), data.getValue(), like);
}
public static List<Tuple<String, String>> externalAutocompleteRequest(String url, String optionsRoot, String label, String value, String like) {
List<Tuple<String, String>> result = new LinkedList<>();
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(MediaType.valueOf("application/vnd.api+json; charset=utf-8")));
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> entity = new HttpEntity<>("parameters", headers);
ResponseEntity<Object> response = restTemplate.exchange(url + "?search=" + like, HttpMethod.GET, entity, Object.class);
DocumentContext jsonContext = JsonPath.parse(response.getBody());
List<Map<String, String>> jsonItems = jsonContext.read(optionsRoot + "['" + label + "','" + value + "']");
jsonItems.forEach(item -> result.add(new Tuple<>(item.get(value), item.get(label))));
return result;
}
}

View File

@ -26,6 +26,7 @@ import eu.eudat.logic.mapper.elastic.criteria.DmpCriteriaMapper;
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
@ -49,7 +50,6 @@ import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import eu.eudat.queryable.QueryableList;
import eu.eudat.types.Authorities;
import eu.eudat.types.MetricNames;
import org.apache.commons.io.IOUtils;
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
@ -60,11 +60,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.*;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -91,8 +91,6 @@ import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@Component
public class DatasetManager {
@ -527,7 +525,7 @@ public class DatasetManager {
public String getWordDocumentText (Dataset datasetEntity) throws Exception {
DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(datasetEntity);
datasetWizardModel.setDatasetProfileDefinition(this.getPagedProfile(datasetWizardModel, datasetEntity));
XWPFDocument document = getLightWordDocument(this.configLoader, datasetWizardModel, this.apiContext.getUtilitiesService().getVisibilityRuleService());
XWPFDocument document = getLightWordDocument(this.configLoader, datasetWizardModel, new VisibilityRuleServiceImpl());
XWPFWordExtractor extractor = new XWPFWordExtractor(document);
return extractor.getText();/*.replaceAll("\n\\s*", " ");*/
}
@ -657,7 +655,7 @@ public class DatasetManager {
JSONObject obj = new JSONObject(dataset.getProperties());
VisibilityRuleService visibilityRuleService = this.apiContext.getUtilitiesService().getVisibilityRuleService();
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
visibilityRuleService.setProperties(obj.toMap());
dataset.setProfile(profile);
@ -666,12 +664,16 @@ public class DatasetManager {
for (String validator : datasetProfileValidators) {
if ((obj.has(validator) && (obj.getString(validator) == null || obj.getString(validator).trim().isEmpty())) && isElementVisible(nodeList, validator, visibilityRuleService)) {
if (obj.has(validator) && isNullOrEmpty(obj.getString(validator)) && isElementVisible(nodeList, validator, visibilityRuleService)) {
throw new Exception("Field value of " + validator + " must be filled.");
}
}
}
private boolean isNullOrEmpty(String value) {
return value == null || value.trim().isEmpty();
}
private boolean isElementVisible(NodeList nodeList, String id, VisibilityRuleService visibilityRuleService) {
Element fieldSet = null;
for (int i = 0; i < nodeList.getLength(); i++) {
@ -1048,10 +1050,13 @@ public class DatasetManager {
Set<JsonNode> tagNodes = new HashSet<>();
tagNodes.addAll(JsonSearcher.findNodes(propertiesJson, "renderStyle", "tags", true));
tagNodes.addAll(JsonSearcher.findNodes(propertiesJson, "rdaProperty", "dataset.keyword"));
if(wizardModel.getTags() == null){
wizardModel.setTags(new ArrayList<>());
}
if (!tagNodes.isEmpty()) {
tagNodes.forEach(node -> {
JsonNode value = node.get("value");
if (!value.toString().equals("\"\"")) {
if (!value.toString().equals("\"\"") && !value.toString().equals("null")) {
String stringValue = value.toString().replaceAll("=", ":");
JSONArray values = new JSONArray(stringValue);
values.iterator().forEachRemaining(element -> {

View File

@ -1,30 +1,26 @@
package eu.eudat.logic.services.forms;
import eu.eudat.models.data.user.components.commons.Rule;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* Created by ikalyvas on 3/5/2018.
*/
@Service("visibilityRuleService")
public class VisibilityRuleServiceImpl implements VisibilityRuleService {
private Map<String, Boolean> elementVisibility = new HashMap<>();
private VisibilityContext visibilityContext;
private final Map<String, Boolean> elementVisibility = new HashMap<>();
private Map<String, Object> properties;
public boolean isElementVisible(String id) {
if (!this.elementVisibility.containsKey(id) || this.elementVisibility.get(id)) return true;
return false;
return !this.elementVisibility.containsKey(id) || this.elementVisibility.get(id);
}
public void setProperties(Map<String, Object> properties) {
this.properties = properties;
this.properties.entrySet().stream()
.filter(stringObjectEntry -> stringObjectEntry.getValue() instanceof String && ((String) stringObjectEntry.getValue()).startsWith("[") && ((String) stringObjectEntry.getValue()).endsWith("]")).forEach(stringObjectEntry -> {
stringObjectEntry.setValue(parseArray((String) stringObjectEntry.getValue()));
});
.filter(stringObjectEntry -> stringObjectEntry.getValue() instanceof String && ((String) stringObjectEntry.getValue()).startsWith("[")
&& ((String) stringObjectEntry.getValue()).endsWith("]"))
.forEach(stringObjectEntry -> stringObjectEntry.setValue(parseArray((String) stringObjectEntry.getValue())));
}
private List<String> parseArray(String original) {
@ -33,19 +29,20 @@ public class VisibilityRuleServiceImpl implements VisibilityRuleService {
}
public void buildVisibilityContext(List<Rule> sources) {
this.visibilityContext = new VisibilityContext();
this.visibilityContext.buildVisibilityContext(sources);
this.visibilityContext.getVisibilityRules().forEach(item-> this.evaluateVisibility(item));
VisibilityContext visibilityContext = new VisibilityContext();
visibilityContext.buildVisibilityContext(sources);
visibilityContext.getVisibilityRules().forEach(this::evaluateVisibility);
}
private void evaluateVisibility(VisibilityRule rule) {
List<VisibilityRuleSource> sources = rule.getVisibilityRuleSources();
for(int i = 0; i < sources.size(); i++){
if (properties.containsKey(sources.get(i).getVisibilityRuleSourceId()) && (isContained(properties.get(sources.get(i).getVisibilityRuleSourceId()), sources.get(i).getVisibilityRuleSourceValue()) || properties.get(sources.get(i).getVisibilityRuleSourceId()).equals(sources.get(i).getVisibilityRuleSourceValue()))) {
for(VisibilityRuleSource source: sources){
if (properties.containsKey(source.getVisibilityRuleSourceId())
&& isContained(properties.get(source.getVisibilityRuleSourceId()), source.getVisibilityRuleSourceValue())) {
this.elementVisibility.put(rule.getVisibilityRuleTargetId(), true);
}else{
this.elementVisibility.put(rule.getVisibilityRuleTargetId(), false);
return;
} else {
this.elementVisibility.put(rule.getVisibilityRuleTargetId(),
this.elementVisibility.getOrDefault(rule.getVisibilityRuleTargetId(), false));
}
}
}
@ -53,7 +50,8 @@ public class VisibilityRuleServiceImpl implements VisibilityRuleService {
private Boolean isContained(Object values, String source) {
if (values instanceof List) {
return ((Collection<?>) values).contains(source);
} else {
return values.equals(source);
}
return false;
}
}

View File

@ -11,7 +11,5 @@ public interface UtilitiesService {
MailService getMailService();
VisibilityRuleService getVisibilityRuleService();
ConfirmationEmailService getConfirmationEmailService();
}

View File

@ -1,6 +1,7 @@
package eu.eudat.logic.services.utilities;
import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -12,22 +13,15 @@ public class UtilitiesServiceImpl implements UtilitiesService {
private InvitationService invitationService;
private MailService mailService;
private VisibilityRuleService visibilityRuleService;
private ConfirmationEmailService confirmationEmailService;
@Autowired
public UtilitiesServiceImpl(InvitationService invitationService, MailService mailService, VisibilityRuleService visibilityRuleService, ConfirmationEmailService confirmationEmailService) {
public UtilitiesServiceImpl(InvitationService invitationService, MailService mailService, ConfirmationEmailService confirmationEmailService) {
this.invitationService = invitationService;
this.mailService = mailService;
this.visibilityRuleService = visibilityRuleService;
this.confirmationEmailService = confirmationEmailService;
}
@Override
public VisibilityRuleService getVisibilityRuleService() {
return visibilityRuleService;
}
@Override
public ConfirmationEmailService getConfirmationEmailService() {
return confirmationEmailService;

View File

@ -27,7 +27,9 @@ import java.io.IOException;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAccessor;
@ -191,6 +193,7 @@ public class WordBuilder {
private Boolean createCompositeFields(List<FieldSet> compositeFields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService, Integer page, String section) {
if (createListing) this.addListing(mainDocumentPart, indent, true, true);
boolean hasValue = false;
boolean returnedValue = false;
for (FieldSet compositeField: compositeFields) {
if (visibilityRuleService.isElementVisible(compositeField.getId()) && hasVisibleFields(compositeField, visibilityRuleService)) {
char c = 'a';
@ -205,6 +208,9 @@ public class WordBuilder {
}
}
hasValue = createFields(compositeField.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService);
if(hasValue){
returnedValue = true;
}
if (compositeField.getMultiplicityItems() != null && !compositeField.getMultiplicityItems().isEmpty()) {
List<FieldSet> list = compositeField.getMultiplicityItems().stream().sorted(Comparator.comparingInt(FieldSet::getOrdinal)).collect(Collectors.toList());
for (FieldSet multiplicityFieldset : list) {
@ -213,6 +219,9 @@ public class WordBuilder {
addParagraphContent(c + ".\n", mainDocumentPart, ParagraphStyle.HEADER6, numId);
}
hasValue = createFields(multiplicityFieldset.getFields(), mainDocumentPart, 3, createListing, visibilityRuleService);
if(hasValue){
returnedValue = true;
}
}
}
if (hasValue && compositeField.getHasCommentField() && compositeField.getCommentFieldValue() != null && !compositeField.getCommentFieldValue().isEmpty() && !createListing) {
@ -225,7 +234,7 @@ public class WordBuilder {
}
}
}
return hasValue;
return returnedValue;
}
private Boolean createFields(List<Field> fields, XWPFDocument mainDocumentPart, Integer indent, Boolean createListing, VisibilityRuleService visibilityRuleService) {
@ -395,7 +404,7 @@ public class WordBuilder {
try {
instant = Instant.parse((String) field.getValue());
} catch (DateTimeParseException ex) {
instant = Instant.from(DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).parse((String) field.getValue()));
instant = LocalDate.parse((String) field.getValue()).atStartOfDay().toInstant(ZoneOffset.UTC);
}
return field.getValue() != null ? DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.systemDefault()).format(instant) : "";
}

View File

@ -163,6 +163,11 @@ public class ExportXmlBuilderDatasetProfile {
numbering.setTextContent(field.getNumbering());
elementField.appendChild(numbering);
}
if (field.getRdaProperty() != null) {
Element rdaProperty = element.createElement("rdaProperty");
rdaProperty.setTextContent(field.getRdaProperty());
elementField.appendChild(rdaProperty);
}
if (field.getValidations() != null) {
Element validations = element.createElement("validations");
field.getValidations().forEach(validation -> {

View File

@ -29,6 +29,8 @@ public class Field {
private Object data;
private String rdaProperty;
@XmlAttribute(name = "id")
public String getId() {
return id;
@ -101,6 +103,15 @@ public class Field {
this.data = data;
}
@XmlElement(name = "rdaProperty")
public String getRdaProperty() {
return rdaProperty;
}
public void setRdaProperty(String rdaProperty) {
this.rdaProperty = rdaProperty;
}
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();
@ -120,6 +131,7 @@ public class Field {
if (data != null) {
fieldEntity.setData(data.toMap((Element) this.data));
}
fieldEntity.setRdaCommonStandard(this.rdaProperty);
return fieldEntity;
}
}

View File

@ -13,7 +13,7 @@ import java.util.stream.Collectors;
public class Field implements ViewStyleDefinition<eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field>, Comparable {
public enum ValidationType {
NONE((short) 0), REQUIRED((short) 1);
NONE((short) 0), REQUIRED((short) 1), URL((short) 2);
private short value;
private ValidationType(short value) {
@ -30,6 +30,8 @@ public class Field implements ViewStyleDefinition<eu.eudat.models.data.entities.
return NONE;
case 1:
return REQUIRED;
case 2:
return URL;
default:
return NONE;

View File

@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.data.entities.*;
import eu.eudat.elastic.entities.Tag;
import eu.eudat.logic.managers.DataManagementProfileManager;
import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.proxy.config.entities.PrefillingFixedMapping;
import eu.eudat.logic.proxy.config.entities.PrefillingGet;
@ -18,15 +19,11 @@ import eu.eudat.models.data.dataset.Service;
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.externaldataset.ExternalDatasetListingModel;
import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
import net.minidev.json.JSONValue;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -34,7 +31,6 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel> {
@ -361,6 +357,11 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
if (rawTags.get(0) instanceof String) {
List<Tag> parsedTags = rawTags.stream().map(rawTag -> new Tag((String) rawTag, (String) rawTag)).collect(Collectors.toList());
value = mapper.writeValueAsString(parsedTags);
List<JsonNode> nodes = JsonSearcher.findNodes(parentNode, "rdaProperty", "dataset.keyword");
for (JsonNode node: nodes) {
String id = node.get(0) != null ? node.get(0).get("id").asText() : node.get("id").asText();
properties.put(id, value);
}
}
}
setterMethod.invoke(datasetWizardModel, mapper.readValue(value, params[0]));
@ -375,9 +376,10 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
date = date.plusYears(20);
value = date.toString();
}
StringBuilder freeTextFormat = new StringBuilder();
for (JsonNode node: nodes) {
String id = node.get(0) != null ? node.get(0).get("id").asText() : node.get("id").asText();
if(prefillingMapping.getMaDmpTarget().equals("dataset.distribution.format") && !value.equals("null")){
if(prefillingMapping.getMaDmpTarget().equals("dataset.distribution.format") && !value.equals("null")) {
JSONArray jsonArr = new JSONArray(value);
List<String> formats = new ArrayList<>();
String extension;
@ -389,37 +391,45 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
formats.add(extension);
}
formats = formats.stream().distinct().collect(Collectors.toList());
List<Object> standardFormats = new ArrayList<>();
for(String format: formats) {
RestTemplate restTemplate = new RestTemplate();
String parsedUrl = "https://eestore.paas2.uninett.no/api/fileformat/?search=" + format;
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Collections.singletonList(new MediaType("application", "vnd.api+json")));
HttpEntity<String> entity = new HttpEntity("", headers);
Map<String, Object> data = restTemplate.exchange(parsedUrl, HttpMethod.GET, entity, LinkedHashMap.class).getBody();
jsonArr = new JSONArray(new ObjectMapper().writeValueAsString(data.get("data")));
for(int i = 0; i < jsonArr.length(); i++){
JSONObject jsonObj = jsonArr.getJSONObject(i);
jsonObj = jsonObj.getJSONObject("attributes");
JSONArray extensions = jsonObj.getJSONArray("extensions");
Object formatName = jsonObj.get("name");
boolean found = false;
for(int j = 0; j < extensions.length(); j++){
if(extensions.getString(j).equals(format)){
JSONObject cur = new JSONObject();
cur.put("label", formatName.toString());
standardFormats.add(cur.toString());
found = true;
break;
String renderStyle = node.get(0) != null ? node.get(0).get("viewStyle").get("renderStyle").asText() : node.get("viewStyle").get("renderStyle").asText();
if(renderStyle.equals("combobox")){
String autocomplete = node.get(0) != null ? node.get(0).get("data").get("type").asText() : node.get("data").get("type").asText();
if(autocomplete.equals("autocomplete")) {
JsonNode urlNode = node.get(0) != null ? node.get(0).get("data").get("autoCompleteSingleDataList") : node.get("data").get("autoCompleteSingleDataList");
String url = urlNode.get(0).get("url").asText();
String optionsRoot = urlNode.get(0).get("optionsRoot").asText();
String label = urlNode.get(0).get("autoCompleteOptions").get("label").asText();
String val = urlNode.get(0).get("autoCompleteOptions").get("value").asText();
for (String format : formats) {
List<Tuple<String, String>> result = DataManagementProfileManager.externalAutocompleteRequest(url, optionsRoot, label, val, format);
result = result.stream().distinct().collect(Collectors.toList());
if(!result.isEmpty()){
for (Tuple<String, String> f : result) {
JSONObject cur = new JSONObject();
cur.put("label", f.getLabel());
standardFormats.add(cur.toString());
freeTextFormat.append(f.getLabel()).append(", ");
}
}
else{
freeTextFormat.append(format).append(", ");
}
}
if(found){
break;
properties.put(id, standardFormats);
}
}
else if(renderStyle.equals("freetext")){
if (freeTextFormat.length() == 0) {
for (String format : formats) {
freeTextFormat.append(format).append(", ");
}
}
freeTextFormat.setLength(freeTextFormat.length() - 2);
properties.put(id, freeTextFormat.toString());
}
properties.put(id, standardFormats);
}
else if(prefillingMapping.getMaDmpTarget().equals("dataset.distribution.data_access")){
value = value.replace("\"", "");

View File

@ -89,12 +89,12 @@ public class DistributionRDAMapper {
int i = 1;
while(iter.hasNext()) {
JsonNode current = iter.next();
String format = JavaToJson.objectStringToJson(current.asText());
String format = JavaToJson.objectStringToJson(current.toString());
try {
Map<String, String> result = new ObjectMapper().readValue(format, HashMap.class);
format = result.get("label");
formats.add(format);
rda.setAdditionalProperty("format" + i++, new ObjectMapper().readTree(current.asText()));
rda.setAdditionalProperty("format" + i++, new ObjectMapper().readTree(current.toString()));
}
catch(JsonProcessingException e){
logger.warn(e.getMessage());
@ -103,7 +103,12 @@ public class DistributionRDAMapper {
rda.setFormat(formats);
}
else{
rda.setFormat(new ArrayList<>(Arrays.asList(rdaValue.replace(" ", "").split(","))));
if(rda.getFormat() == null || rda.getFormat().isEmpty()){
rda.setFormat(new ArrayList<>(Arrays.asList(rdaValue.replace(" ", "").split(","))));
}
else{
rda.getFormat().addAll(Arrays.asList(rdaValue.replace(" ", "").split(",")));
}
}
rda.setAdditionalProperty(ImportPropertyName.FORMAT.getName(), node.get("id").asText());
break;
@ -209,19 +214,27 @@ public class DistributionRDAMapper {
break;
case FORMAT:
if (rda.getFormat() != null && !rda.getFormat().isEmpty()) {
Map<String, Object> additionalProperties = rda.getAdditionalProperties();
List<Object> standardFormats = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
rda.getAdditionalProperties().forEach((key, value) -> {
try {
if (key.matches("format\\d+")) {
standardFormats.add(additionalProperties.get(key));
properties.put(distributionNode.get("id").asText(), mapper.writeValueAsString(standardFormats));
}
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
String style = distributionNode.get("viewStyle").get("renderStyle").asText();
if(style.equals("combobox")) {
if (distributionNode.get("data").get("type").asText().equals("autocomplete")) {
Map<String, Object> additionalProperties = rda.getAdditionalProperties();
List<Object> standardFormats = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
rda.getAdditionalProperties().forEach((key, value) -> {
try {
if (key.matches("format\\d+")) {
standardFormats.add(additionalProperties.get(key));
properties.put(distributionNode.get("id").asText(), mapper.writeValueAsString(standardFormats));
}
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
});
}
});
}
else if(style.equals("freetext")){
properties.put(distributionNode.get("id").asText(), String.join(", ", rda.getFormat()));
}
}
break;
case LICENSE:

View File

@ -1,4 +1,18 @@
import {ValidatorFn, Validators} from "@angular/forms";
export enum ValidationType {
None = 0,
Required = 1
Required = 1,
URL = 2
}
export class ValidatorURL {
public static regex = 'https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.' +
'[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.' +
'[a-zA-Z0-9]+\.[^\s]{2,}';
public static get validator(): ValidatorFn {
return Validators.pattern(ValidatorURL.regex);
}
}

View File

@ -21,4 +21,5 @@ export interface Field {
data: any;
validations: Array<ValidationType>;
validationRequired;
}
validationURL;
}

View File

@ -9,6 +9,7 @@
//}
.editor-wrapper {
position: relative;
border: 1px solid transparent !important;
border-radius: 5px;
}
@ -40,6 +41,14 @@
border: 1px solid #f44336 !important;
}
.clear {
position: absolute;
right: 5px;
bottom: 5px;
transform: translate(-50%, -50%);
cursor: pointer;
}
.full-width {
width: 100%;
}

View File

@ -1,5 +1,6 @@
import {Component, Input} from "@angular/core";
import {AngularEditorConfig} from "@kolkov/angular-editor";
import {FormControl} from "@angular/forms";
@Component({
selector: 'rich-text-editor-component',
@ -7,6 +8,7 @@ import {AngularEditorConfig} from "@kolkov/angular-editor";
<div class="editor-wrapper" [class]="wrapperClasses" [formGroup]="parentFormGroup">
<angular-editor class="full-width editor" [id]="id" [config]="editorConfig" [formControlName]="controlName"
placeholder="{{(placeholder? (placeholder | translate) : '') + (required ? ' *': '')}}"></angular-editor>
<mat-icon *ngIf="formInput.value" (click)="formInput.patchValue('')" class="clear">close</mat-icon>
</div>
`,
styleUrls: ['./rich-text-editor.component.scss']
@ -53,6 +55,7 @@ export class RichTextEditorComponent {
]
};
constructor() {
get formInput(): FormControl {
return this.parentFormGroup.get(this.controlName);
}
}

View File

@ -5,11 +5,16 @@
<ng-content></ng-content>
<div class="col-auto">
<ul class="list-unstyled list-inline d-flex align-items-center">
<li class="list-inline-item" >
<li class="list-inline-item">
<mat-slide-toggle class="field-toggler" [checked]="isRequired" (change)="toggleRequired($event)" labelPosition="before" [matTooltip]="'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.MAKE-IT-REQUIRED' | translate" [disabled]="!viewType">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}
</mat-slide-toggle>
</li>
<li *ngIf="viewType === viewTypeEnum.FreeText" class="list-inline-item">
<mat-slide-toggle class="field-toggler" [checked]="isURL" (change)="toggleURL($event)" labelPosition="before" [matTooltip]="'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.MAKE-IT-REQUIRED' | translate" [disabled]="!viewType">
{{'GENERAL.VALIDATION.URL.LABEL' | translate}}
</mat-slide-toggle>
</li>
<!-- <li class="list-inline-item" *ngIf="!viewOnly && viewType && canApplyVisibility">
<mat-icon style="cursor: pointer;" (click)="addNewRule()" [matTooltip]="'DATASET-PROFILE-EDITOR.ACTIONS.FIELD.ADD-VISIBILITY-RULE' | translate">visibility</mat-icon>
</li> -->

View File

@ -1,21 +1,20 @@

import { Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
import {FormArray, FormControl, FormGroup, FormGroupDirective, NgForm,} from '@angular/forms';
import { DatasetProfileFieldViewStyle } from '@app/core/common/enum/dataset-profile-field-view-style';
import { ValidationType } from '@app/core/common/enum/validation-type';
import { DatasetProfileService } from '@app/core/services/dataset-profile/dataset-profile.service';
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
import { RuleEditorModel } from '@app/ui/admin/dataset-profile/admin/rule-editor-model';
import { BaseComponent } from '@common/base/base.component';
import { Subscription } from 'rxjs';
import { ViewStyleType } from './view-style-enum';
import { DatasetProfileComboBoxType } from '@app/core/common/enum/dataset-profile-combo-box-type';
import { ErrorStateMatcher } from '@angular/material/core';
import { MatDialog } from '@angular/material/dialog';
import { MatSlideToggleChange } from '@angular/material/slide-toggle';
import { Field } from '@app/core/model/admin/dataset-profile/dataset-profile';
import { DatasetProfileInternalDmpEntitiesType } from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type';
import { FieldEditorModel } from '../../../admin/field-editor-model';
import {DatasetProfileFieldViewStyle} from '@app/core/common/enum/dataset-profile-field-view-style';
import {ValidationType} from '@app/core/common/enum/validation-type';
import {DatasetProfileService} from '@app/core/services/dataset-profile/dataset-profile.service';
import {EnumUtils} from '@app/core/services/utilities/enum-utils.service';
import {RuleEditorModel} from '@app/ui/admin/dataset-profile/admin/rule-editor-model';
import {BaseComponent} from '@common/base/base.component';
import {Subscription} from 'rxjs';
import {ViewStyleType} from './view-style-enum';
import {DatasetProfileComboBoxType} from '@app/core/common/enum/dataset-profile-combo-box-type';
import {ErrorStateMatcher} from '@angular/material/core';
import {MatDialog} from '@angular/material/dialog';
import {MatSlideToggleChange} from '@angular/material/slide-toggle';
import {Field} from '@app/core/model/admin/dataset-profile/dataset-profile';
import {DatasetProfileInternalDmpEntitiesType} from '@app/core/common/enum/dataset-profile-internal-dmp-entities-type';
import {FieldEditorModel} from '../../../admin/field-editor-model';
import {
AutoCompleteFieldData,
BooleanDecisionFieldData,
@ -28,17 +27,19 @@ import {
ExternalDatasetsFieldData,
FieldDataOption,
FreeTextFieldData,
LicensesFieldData,
OrganizationsFieldData,
PublicationsFieldData,
RadioBoxFieldData,
RegistriesFieldData,
ResearchersAutoCompleteFieldData,
RichTextAreaFieldData,
ServicesFieldData,
TagsFieldData,
TaxonomiesFieldData,
TextAreaFieldData,
RichTextAreaFieldData,
ValidationFieldData,
WordListFieldData,
TaxonomiesFieldData, LicensesFieldData, PublicationsFieldData
WordListFieldData
} from '@app/core/model/dataset-profile-definition/field-data/field-data';
@Component({
@ -185,7 +186,9 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
this.viewType = this.viewTypeEnum.Validation;
break;
}
if(this.viewType !== this.viewTypeEnum.FreeText) {
this.setValidator(ValidationType.URL, false);
}
}
// this.showPreview = true;
@ -891,20 +894,24 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
toggleRequired(event:MatSlideToggleChange){
this.setValidator(ValidationType.Required, event.checked);
}
toggleURL(event:MatSlideToggleChange){
this.setValidator(ValidationType.URL, event.checked);
}
private setValidator(validationType: ValidationType, add: boolean) {
let validationsControl = this.form.get('validations') as FormControl;
let validations: Array<ValidationType> = validationsControl.value;
if(event.checked){
if(!validations.includes(ValidationType.Required)){//IS ALREADY REQUIRED
// validationsControl.setValue(validations.filter(validator=> validator != ValidationType.Required));
// validationsControl.updateValueAndValidity();
validations.push(ValidationType.Required);
// validationsControl.setValue(validations);
if(add){
if(!validations.includes(validationType)){
validations.push(validationType);
validationsControl.updateValueAndValidity();
}
}else{
validationsControl.setValue(validations.filter(validator=> validator != ValidationType.Required));
} else{
validationsControl.setValue(validations.filter(validator=> validator != validationType));
validationsControl.updateValueAndValidity();
}
this.form.markAsDirty();//deactivate guard
@ -916,6 +923,12 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
return validations.includes(ValidationType.Required);
}
get isURL(){
let validationsControl = this.form.get('validations') as FormControl;
let validations: Array<ValidationType> = validationsControl.value;
return validations.includes(ValidationType.URL);
}
onDelete(){
this.delete.emit();

View File

@ -89,7 +89,7 @@
<span class="material-icons">chevron_right</span>
<div>{{'DMP-EDITOR.STEPPER.NEXT' | translate}}</div>
</div>
<div *ngIf="(this.step === this.maxStep) && !lockStatus && formGroup.get('profile').value && !viewOnly" mat-raised-button type="button" class="col-auto stepper-btn add-dataset-btn ml-auto">
<div *ngIf="(step === maxStep) && !lockStatus && formGroup.get('profile').value && !viewOnly" mat-raised-button type="button" class="col-auto stepper-btn add-dataset-btn ml-auto">
<div (click)="save(saveAnd.addNew)">{{ 'DATASET-WIZARD.ACTIONS.SAVE-AND-ADD' | translate }}</div>
</div>
</div>
@ -107,7 +107,7 @@
</div>
<!-- <mat-slide-toggle [(ngModel)]="showtocentriesErrors">
</mat-slide-toggle> -->
<!-- <div class="row">

View File

@ -259,6 +259,9 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.formGroup = this.datasetWizardModel.buildForm();
this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
this.formGroup.get('dmp').disable();
this.maxStep = 1;
this.loadDatasetProfiles();
this.registerFormListeners();
}
})
this.loadDatasetProfiles();

View File

@ -574,19 +574,8 @@ export class DmpEditorComponent extends CheckDeactivateBaseComponent implements
}
onCallbackSuccessAddNew(dmp?: DmpModel) {
// 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(['/datasets', 'new', dmp.id]);
// const showDialog = this.isNew && (this.formGroup.get('datasets') );
let showDialog = false;
try{
showDialog = this.isNew && !this.formGroup.get('datasets').value.length;
}catch{
}
this.editDataset(dmp.id, true, showDialog);
// this.editDataset(dmp.id, true, this.isNew && !this.formGroup.get('datasets').value.length);
this.editDataset(dmp.id, true, false);
}
public setErrorModel(validationErrorModel: ValidationErrorModel) {

View File

@ -11,7 +11,8 @@
</h5>
<mat-form-field *ngSwitchCase="datasetProfileFieldViewStyleEnum.FreeText" class="col-12">
<input matInput [formControl]="form.get('value')" placeholder="{{(form.get('data').value.label) + (form.get('validationRequired').value? ' *': '')}}" [required]="form.get('validationRequired').value">
<mat-error *ngIf="form.get('value')['errors'] && form.get('value')['errors']['required']">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="form.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="form.get('value').hasError('pattern')">{{'GENERAL.VALIDATION.URL.MESSAGE' | translate}}</mat-error>
</mat-form-field>
<div *ngSwitchCase="datasetProfileFieldViewStyleEnum.ComboBox" class="col-12">
@ -105,7 +106,7 @@
<button mat-icon-button type="button" *ngIf="!form.get('value').disabled && form.get('value').value" matSuffix aria-label="Clear" (click)="this.form.patchValue({'value': ''})">
<mat-icon>close</mat-icon>
</button>
<mat-error *ngIf="form.get('value')['errors'] && form.get('value')['errors']['required']">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<mat-error *ngIf="form.get('value')['errors'] && form.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
<ng-container *ngSwitchCase="datasetProfileFieldViewStyleEnum.RichTextArea">
<rich-text-editor-component class="col-12"
@ -115,8 +116,8 @@
[wrapperClasses]="'full-width editor ' +
((form.get('validationRequired').value) ? 'required' : '')">
</rich-text-editor-component>
<div [class]="(form.get('value')['errors'] && form.get('value')['errors']['required']) ? 'visible' : 'invisible'" class="mat-form-field form-field-subscript-wrapper">
<mat-error *ngIf="form.get('value')['errors'] && form.get('value')['errors']['required']">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
<div [class]="(form.get('value')['errors'] && form.get('value').hasError('required')) ? 'visible' : 'invisible'" class="mat-form-field form-field-subscript-wrapper">
<mat-error *ngIf="form.get('value')['errors'] && form.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</div>
</ng-container>

View File

@ -91,10 +91,8 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
}
private checkIfIsRequired(formControl: FormGroup): boolean {
if (formControl.get('validationRequired') && formControl.get('validationRequired').value) {
return true;
}
return false;
return !!(formControl.get('validationRequired') && formControl.get('validationRequired').value);
}
private checkFormsIfIsFieldsAndVisible(formControl: FormGroup): boolean {

View File

@ -1,18 +1,18 @@
import { FormBuilder, FormControl, FormGroup, Validators } from "@angular/forms";
import { Guid } from '@common/types/guid';
import { ValidationType } from "../../../core/common/enum/validation-type";
import { BaseFormModel } from "../../../core/model/base-form-model";
import { CompositeField } from "../../../core/model/dataset-profile-definition/composite-field";
import { DatasetProfileDefinitionModel } from "../../../core/model/dataset-profile-definition/dataset-profile-definition";
import { DefaultValue } from "../../../core/model/dataset-profile-definition/default-value";
import { Field } from "../../../core/model/dataset-profile-definition/field";
import { Multiplicity } from "../../../core/model/dataset-profile-definition/multiplicity";
import { Page } from "../../../core/model/dataset-profile-definition/page";
import { Rule } from "../../../core/model/dataset-profile-definition/rule";
import { Section } from "../../../core/model/dataset-profile-definition/section";
import { ViewStyle } from "../../../core/model/dataset-profile-definition/view-style";
import { BackendErrorValidator } from '@common/forms/validation/custom-validator';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
import {FormBuilder, FormControl, FormGroup, ValidatorFn, Validators} from "@angular/forms";
import {Guid} from '@common/types/guid';
import {ValidationType, ValidatorURL} from "../../../core/common/enum/validation-type";
import {BaseFormModel} from "../../../core/model/base-form-model";
import {CompositeField} from "../../../core/model/dataset-profile-definition/composite-field";
import {DatasetProfileDefinitionModel} from "../../../core/model/dataset-profile-definition/dataset-profile-definition";
import {DefaultValue} from "../../../core/model/dataset-profile-definition/default-value";
import {Field} from "../../../core/model/dataset-profile-definition/field";
import {Multiplicity} from "../../../core/model/dataset-profile-definition/multiplicity";
import {Page} from "../../../core/model/dataset-profile-definition/page";
import {Rule} from "../../../core/model/dataset-profile-definition/rule";
import {Section} from "../../../core/model/dataset-profile-definition/section";
import {ViewStyle} from "../../../core/model/dataset-profile-definition/view-style";
import {BackendErrorValidator} from '@common/forms/validation/custom-validator';
import {ValidationErrorModel} from '@common/forms/validation/error-model/validation-error-model';
export class DatasetDescriptionFormEditorModel extends BaseFormModel {
@ -115,7 +115,7 @@ export class DatasetDescriptionSectionEditorModel extends BaseFormModel {
formGroup.addControl('description', new FormControl({ value: this.description, disabled: true }));
formGroup.addControl('numbering', new FormControl({ value: this.numbering, disabled: true }));
formGroup.addControl('title', new FormControl({ value: this.title, disabled: true }));
formGroup.addControl('id', new FormControl({ value: this.title, disabled: false }));
formGroup.addControl('id', new FormControl({ value: this.id, disabled: false }));
formGroup.addControl('ordinal', new FormControl({ value: this.ordinal, disabled: true }));
return formGroup;
}
@ -229,6 +229,7 @@ export class DatasetDescriptionFieldEditorModel extends BaseFormModel {
public data: any;
public validations: Array<ValidationType>;
public validationRequired = false;
public validationURL = false;
fromModel(item: Field): DatasetDescriptionFieldEditorModel {
this.id = item.id;
@ -253,16 +254,27 @@ export class DatasetDescriptionFieldEditorModel extends BaseFormModel {
buildForm(): FormGroup {
if (this.validations) {
this.validations.forEach(validation => {
if (validation === ValidationType.Required) { this.validationRequired = true; }
if (validation === ValidationType.Required) {
this.validationRequired = true;
} else if(validation === ValidationType.URL) {
this.validationURL = true;
}
});
}
let validators: any[] = [];
if(this.validationRequired) {
validators.push(Validators.required)
}
if(this.validationURL) {
validators.push(ValidatorURL.validator);
}
const formGroup = this.formBuilder.group({
value: [this.value, this.validationRequired === true ? Validators.required : null],
value: [this.value, validators],
id: [{ value: this.id, disabled: false }],
viewStyle: [{ value: this.viewStyle, disabled: true }],
data: [{ value: this.data, disabled: true }],
validationRequired: [{ value: this.validationRequired, disabled: true }],
validationURL: [{ value: this.validationURL, disabled: true }],
description: [{ value: this.description, disabled: true }],
extendedDescription: [{ value: this.extendedDescription, disabled: true }],
additionalInformation: [{ value: this.additionalInformation, disabled: true }],

View File

@ -3,7 +3,11 @@
"VALIDATION": {
"REQUIRED": "Pflichtfeld",
"GRANT-START-AFTER-END": "Anfangsdatum der Förderung kann nicht nach dem Laufzeitende liegen",
"PATTERN-_": "Schriftzeichen \"_\" ist nicht erlaubt"
"PATTERN-_": "Schriftzeichen \"_\" ist nicht erlaubt",
"URL": {
"LABEL": "URL",
"MESSAGE": "Please provide a valid URL"
}
},
"DELETE-CONFIRMATION": {
"TITLE": "Warnung",
@ -731,7 +735,7 @@
"DATASET-NOT-FOUND": "Datensatzbeschreibung ist nicht vorhanden",
"DATASET-NOT-ALLOWED": "Sie haben keinen Zugriff auf diese Datensatzbeschreibung",
"SUCCESS-UPDATE-DATASET-PROFILE": "Vorlage der Datensatzbeschreibung erfolgreich aktualisiert",
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the form and make sure that all required fields are filled. (Missing fields are marked in red color)"
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the DMP and make sure that all required questions are answered and URLs are provided with valid input. (Missing fields are marked in red color)"
},
"UPLOAD": {
"UPLOAD-XML": "Importieren",

View File

@ -3,7 +3,11 @@
"VALIDATION": {
"REQUIRED": "Required",
"GRANT-START-AFTER-END": "Grant start date cannot be after the end date",
"PATTERN-_": "Character \"_\" is not allowed"
"PATTERN-_": "Character \"_\" is not allowed",
"URL": {
"LABEL": "URL",
"MESSAGE": "Please provide a valid URL"
}
},
"DELETE-CONFIRMATION": {
"TITLE": "Warning",
@ -731,7 +735,7 @@
"DATASET-NOT-FOUND": "Dataset does not exist",
"DATASET-NOT-ALLOWED": "You have no access to this Dataset",
"SUCCESS-UPDATE-DATASET-PROFILE": "Dataset Template updated successfully",
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the form and make sure that all required fields are filled. (Missing fields are marked in red color)"
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the DMP and make sure that all required questions are answered and URLs are provided with valid input. (Missing fields are marked in red color)"
},
"UPLOAD": {
"UPLOAD-XML": "Import",

View File

@ -3,7 +3,11 @@
"VALIDATION": {
"REQUIRED": "Obligatorio",
"GRANT-START-AFTER-END": "La fecha de incio de la subvención no puede ser posterior a la fecha de fin",
"PATTERN-_": "Carácter \"_\" no permitido"
"PATTERN-_": "Carácter \"_\" no permitido",
"URL": {
"LABEL": "URL",
"MESSAGE": "Please provide a valid URL"
}
},
"DELETE-CONFIRMATION": {
"TITLE": "Aviso",
@ -731,8 +735,7 @@
"DATASET-NOT-FOUND": "No existe la descripción del dataset",
"DATASET-NOT-ALLOWED": "No tiene acceso a la descricipción de este dataset",
"SUCCESS-UPDATE-DATASET-PROFILE": "Plantilla de descripción del dataset actualizada correctamente",
"MISSING-FIELDS": "Hay campos requeridos sin rellenar. Por favor, compruebe el formulario y rellene los campos obligatorios (Los campos sin rellenar se marcan en color rojo)"
},
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the DMP and make sure that all required questions are answered and URLs are provided with valid input. (Missing fields are marked in red color)" },
"UPLOAD": {
"UPLOAD-XML": "Importar",
"UPLOAD-XML-FILE-TITLE": "Importar la plantilla de descripción del dataset",

View File

@ -3,7 +3,11 @@
"VALIDATION": {
"REQUIRED": "Προαπαιτούμενο",
"GRANT-START-AFTER-END": "Η ημερομηνία έναρξης της επιχορήγησης δεν μπορεί να είναι μεταγενέστερη της ημερομηνίας λήξης",
"PATTERN-_": "Ο χαρακτήρας \"_\" δεν υποστηρίζεται"
"PATTERN-_": "Ο χαρακτήρας \"_\" δεν υποστηρίζεται",
"URL": {
"LABEL": "URL",
"MESSAGE": "Παρακαλώ εισάγεται ένα έγκυρο URL"
}
},
"DELETE-CONFIRMATION": {
"TITLE": "Προσοχή",
@ -731,7 +735,7 @@
"DATASET-NOT-FOUND": "Η Περιγραφή Συνόλου Δεδομένων δεν υπάρχει",
"DATASET-NOT-ALLOWED": "Δεν έχετε πρόσβαση σε αυτή την Περιγραφή Συνόλου Δεδομένων",
"SUCCESS-UPDATE-DATASET-PROFILE": "Επιτυχία ενημέρωσης της Περιγραφής Συνόλου Δεδομένων",
"MISSING-FIELDS": "Υπάρχουν ορισμένα υποχρεωτικά πεδία που δεν έχουν συμπληρωθεί. Ελέγξτε τη φόρμα και βεβαιωθείτε ότι έχουν συμπληρωθεί όλα τα απαιτούμενα πεδία. (Τα πεδία που λείπουν επισημαίνονται με κόκκινο χρώμα)"
"MISSING-FIELDS": "Υπάρχουν ορισμένα υποχρεωτικά πεδία που δεν έχουν συμπληρωθεί. Ελέγξτε το DMP και βεβαιωθείτε ότι έχουν συμπληρωθεί όλα τα απαιτούμενα πεδία και τα URL είναι έγκυρα. (Τα πεδία που λείπουν επισημαίνονται με κόκκινο χρώμα)"
},
"UPLOAD": {
"UPLOAD-XML": "Εισαγωγή",

View File

@ -3,7 +3,11 @@
"VALIDATION": {
"REQUIRED": "Obrigatório",
"GRANT-START-AFTER-END": "A data de início do financiamento não pode ser posterior à data de término",
"PATTERN-_": "O caracter \"_\" não é permitido"
"PATTERN-_": "O caracter \"_\" não é permitido",
"URL": {
"LABEL": "URL",
"MESSAGE": "Please provide a valid URL"
}
},
"DELETE-CONFIRMATION": {
"TITLE": "Atenção",
@ -731,8 +735,7 @@
"DATASET-NOT-FOUND": "O Dataset não existe",
"DATASET-NOT-ALLOWED": "Não tem acesso a este Dataset",
"SUCCESS-UPDATE-DATASET-PROFILE": "O Dataset foi atualizado com sucesso",
"MISSING-FIELDS": "Alguns campos obrigatórios não foram preenchidos. Por favor, verifique o formulário e certifique-se de que todos os campos obrigatórios foram preenchidos. (Os campos ausentes são marcados em vermelho)"
},
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the DMP and make sure that all required questions are answered and URLs are provided with valid input. (Missing fields are marked in red color)" },
"UPLOAD": {
"UPLOAD-XML": "Importar",
"UPLOAD-XML-FILE-TITLE": "Importar o Dataset",

View File

@ -3,7 +3,11 @@
"VALIDATION": {
"REQUIRED": "Povinné",
"GRANT-START-AFTER-END": "Dátum začatia poskytovania grantu nesmie byť po dátume ukončenia",
"PATTERN-_": "Znak \"_\" nie je povolený"
"PATTERN-_": "Znak \"_\" nie je povolený",
"URL": {
"LABEL": "URL",
"MESSAGE": "Please provide a valid URL"
}
},
"DELETE-CONFIRMATION": {
"TITLE": "Upozornenie",
@ -731,7 +735,7 @@
"DATASET-NOT-FOUND": "Súbor dát neexistuje",
"DATASET-NOT-ALLOWED": "K tomuto súboru dát nemáte prístup",
"SUCCESS-UPDATE-DATASET-PROFILE": "Šablóna súboru dát bola úspešne aktualizovaná",
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the form and make sure that all required fields are filled. (Missing fields are marked in red color)"
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the DMP and make sure that all required questions are answered and URLs are provided with valid input. (Missing fields are marked in red color.)"
},
"UPLOAD": {
"UPLOAD-XML": "Importovať",

View File

@ -3,7 +3,11 @@
"VALIDATION": {
"REQUIRED": "Obavezno",
"GRANT-START-AFTER-END": "Datum početka ne može biti kasniji od datuma završetka granta.",
"PATTERN-_": "Karakter \"_\" nije dozvoljen"
"PATTERN-_": "Karakter \"_\" nije dozvoljen",
"URL": {
"LABEL": "URL",
"MESSAGE": "Please provide a valid URL"
}
},
"DELETE-CONFIRMATION": {
"TITLE": "Oprez",
@ -731,7 +735,7 @@
"DATASET-NOT-FOUND": "Skup podataka ne postoji",
"DATASET-NOT-ALLOWED": "Nemate pristup ovom skupu podataka",
"SUCCESS-UPDATE-DATASET-PROFILE": "Obrazac skupa podataka je ažuriran uspešno",
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the form and make sure that all required fields are filled. (Missing fields are marked in red color)"
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the DMP and make sure that all required questions are answered and URLs are provided with valid input. (Missing fields are marked in red color.)"
},
"UPLOAD": {
"UPLOAD-XML": "Uvezite",

View File

@ -3,7 +3,11 @@
"VALIDATION": {
"REQUIRED": "Gerekli",
"GRANT-START-AFTER-END": "Hibe başlangıç tarihi bitiş tarihinden sonra olamaz",
"PATTERN-_": "\"_\" Karakterine izin verilmiyor"
"PATTERN-_": "\"_\" Karakterine izin verilmiyor",
"URL": {
"LABEL": "URL",
"MESSAGE": "Please provide a valid URL"
}
},
"DELETE-CONFIRMATION": {
"TITLE": "Uyarı",
@ -731,7 +735,7 @@
"DATASET-NOT-FOUND": "Veri Seti mevcut değildir",
"DATASET-NOT-ALLOWED": "Bu Veri Setine erişiminiz yok",
"SUCCESS-UPDATE-DATASET-PROFILE": "Veri Seti Tanımı başarılı olarak güncellendi",
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the form and make sure that all required fields are filled. (Missing fields are marked in red color)"
"MISSING-FIELDS": "There are some required fields left unfilled. Please check the DMP and make sure that all required questions are answered and URLs are provided with valid input. (Missing fields are marked in red color.)"
},
"UPLOAD": {
"UPLOAD-XML": "İçeri Aktar",