This commit is contained in:
dtziotzios 2020-06-25 17:52:09 +03:00
commit 6d27abaca8
41 changed files with 2542 additions and 49 deletions

View File

@ -40,6 +40,7 @@ public class ResponsesCache {
caches.add(new GuavaCache("tags", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("researchers", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("externalDatasets", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
caches.add(new GuavaCache("currencies", CacheBuilder.newBuilder().expireAfterAccess(HOW_MANY, TIME_UNIT).build()));
simpleCacheManager.setCaches(caches);
logger.info("OK");
return simpleCacheManager;

View File

@ -0,0 +1,31 @@
package eu.eudat.controllers;
import eu.eudat.logic.managers.LocalFetchManager;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.local.LocalFetchModel;
import eu.eudat.types.ApiMessageCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@CrossOrigin
@RequestMapping(value = "api/currency")
public class CurrencyController {
private LocalFetchManager localFetchManager;
@Autowired
public CurrencyController(LocalFetchManager localFetchManager) {
this.localFetchManager = localFetchManager;
}
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<ResponseItem<List<LocalFetchModel>>> getCurrencies( @RequestParam(value = "query", required = false) String query) throws Exception {
List<LocalFetchModel> currencies = localFetchManager.getCurrency(query);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<LocalFetchModel>>().status(ApiMessageCode.NO_MESSAGE).payload(currencies));
}
}

View File

@ -1404,7 +1404,9 @@ public class DataManagementPlanManager {
}
databaseRepository.getDmpDao().createOrUpdate(dmp);
assignUser(dmp, me);
this.updateIndex(dmp);
if (this.apiContext.getOperationsContext().getElasticRepository().getDmpRepository().getClient() != null) {
this.updateIndex(dmp);
}
dmp.getDataset().forEach(dataset -> {
dataset.setStatus(Dataset.Status.SAVED.getValue());
dataset.setCreated(new Date());

View File

@ -0,0 +1,28 @@
package eu.eudat.logic.managers;
import eu.eudat.logic.proxy.fetching.LocalFetcher;
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
import eu.eudat.models.data.local.LocalFetchModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Component
public class LocalFetchManager {
private LocalFetcher localFetcher;
@Autowired
public LocalFetchManager(LocalFetcher localFetcher) {
this.localFetcher = localFetcher;
}
public List<LocalFetchModel> getCurrency(String query) throws Exception {
List<Map<String, String>> data = localFetcher.retrieveCurrency();
List<LocalFetchModel> result = data.stream().map(entry -> new LocalFetchModel(entry.get("name"), entry.get("value"))).collect(Collectors.toList());
result = result.stream().filter(localFetchModel -> localFetchModel.getValue() != null).filter(StreamDistinctBy.distinctByKey(LocalFetchModel::getValue)).filter(localFetchModel -> localFetchModel.getName().contains(query)).collect(Collectors.toList());
return result;
}
}

View File

@ -34,8 +34,9 @@ public class RDAManager {
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"));
DMPWrap wrap = new DMPWrap(rdaDmp);
result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(wrap);
RDAModel model = new RDAModel();
model.setDmp(rdaDmp);
result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(model);
return result;
}
@ -44,28 +45,7 @@ public class RDAManager {
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"));
Dmp rda = mapper.readValue(json, DMPWrap.class).getDmp();
Dmp rda = mapper.readValue(json, RDAModel.class).getDmp();
return dmpRDAMapper.toEntity(rda, profiles);
}
public static class DMPWrap implements Serializable {
@JsonProperty("dmp")
private Dmp dmp;
public DMPWrap() {
}
public DMPWrap(Dmp dmp) {
this.dmp = dmp;
}
public Dmp getDmp() {
return dmp;
}
public void setDmp(Dmp dmp) {
this.dmp = dmp;
}
}
}

View File

@ -58,7 +58,7 @@ public class DmpMapper {
}
if (dmp.getDataset() != null) {
elastic.setDatasets(dmp.getDataset().stream().map(dataset -> {
elastic.setDatasets(dmp.getDataset().stream().filter(dataset -> dataset.getId() != null).map(dataset -> {
List<Tag> tags = null;
try {
Dataset dataset1 = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString());

View File

@ -0,0 +1,99 @@
package eu.eudat.logic.proxy.fetching;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.eudat.logic.proxy.fetching.entities.Config;
import eu.eudat.logic.proxy.fetching.entities.ConfigSingle;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.beans.PropertyDescriptor;
import java.io.InputStream;
import java.lang.reflect.Method;
import java.util.*;
@Component
public class LocalFetcher {
@Cacheable("currencies")
public List<Map<String, String>> retrieveCurrency() throws Exception {
InputStream is = getClass().getClassLoader().getResource("internal/fetchConfig.xml").openStream();
JAXBContext context = JAXBContext.newInstance(Config.class);
Unmarshaller unmarshaller = context.createUnmarshaller();
Config config = (Config) unmarshaller.unmarshal(is);
ConfigSingle currencyConfig = config.getConfigs().stream().filter(configSingle -> configSingle.getType().equals("currency")).findFirst().get();
return retrieveData(currencyConfig);
}
public List<Map<String, String>> retrieveData(ConfigSingle configSingle) throws Exception {
List<Map<String, String>> result = new ArrayList<>();
InputStream is = getClass().getClassLoader().getResource(configSingle.getFilePath()).openStream();
FileType type = FileType.fromName(configSingle.getFileType());
switch(type) {
case XML:
{
Class<?> aClass = Class.forName(configSingle.getParseClass());
JAXBContext context = JAXBContext.newInstance(aClass);
Unmarshaller unmarshaller = context.createUnmarshaller();
Object object = unmarshaller.unmarshal(is);
Method reader = null;
if (configSingle.getParseField() != null && !configSingle.getParseField().isEmpty()) {
reader = new PropertyDescriptor(configSingle.getParseField(), aClass).getReadMethod();
}
ObjectMapper objectMapper = new ObjectMapper();
List<Map<String, String>> values = new ArrayList<>();
int max = 1;
if (reader != null) {
Object invokedField = reader.invoke(object);
if (invokedField instanceof Collection) {
max = ((Collection) invokedField).size();
}
}
for (int i = 0; i< max; i++) {
Object value;
if (reader != null) {
Object invokedField = reader.invoke(object);
if (invokedField instanceof Collection) {
value = ((Collection) invokedField).toArray()[i];
} else {
value = invokedField;
}
} else {
value = object;
}
Map<String, String> map = objectMapper.convertValue(value, Map.class);
result.add(new HashMap<>());
result.get(result.size() - 1).put("name", map.get(configSingle.getName()));
result.get(result.size() - 1).put("value", map.get(configSingle.getValue()));
}
}
}
return result;
}
public enum FileType {
XML("xml"), JSON("json");
private String name;
FileType(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static FileType fromName(String name) {
for (FileType type: FileType.values()) {
if (name.equals(type.getName())) {
return type;
}
}
throw new NoSuchElementException("File Type [" + name + "] is not supported");
}
}
}

View File

@ -0,0 +1,21 @@
package eu.eudat.logic.proxy.fetching.entities;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "fetchConfig")
public class Config {
private List<ConfigSingle> configs;
@XmlElementWrapper
@XmlElement(name = "config")
public List<ConfigSingle> getConfigs() {
return configs;
}
public void setConfigs(List<ConfigSingle> configs) {
this.configs = configs;
}
}

View File

@ -0,0 +1,71 @@
package eu.eudat.logic.proxy.fetching.entities;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "config")
public class ConfigSingle {
private String type;
private String fileType;
private String filePath;
private String parseClass;
private String parseField;
private String name;
private String value;
@XmlElement(name = "type")
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@XmlElement(name = "fileType")
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
@XmlElement(name = "filePath")
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
@XmlElement(name = "parseClass")
public String getParseClass() {
return parseClass;
}
public void setParseClass(String parseClass) {
this.parseClass = parseClass;
}
@XmlElement(name = "parseField")
public String getParseField() {
return parseField;
}
public void setParseField(String parseField) {
this.parseField = parseField;
}
@XmlElement(name = "name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlElement(name = "value")
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -0,0 +1,21 @@
package eu.eudat.logic.proxy.fetching.entities;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "ISO_4217")
public class CurrencyModel {
private List<CurrencySingleModel> currencies;
@XmlElementWrapper(name = "CcyTbl")
@XmlElement(name = "CcyNtry")
public List<CurrencySingleModel> getCurrencies() {
return currencies;
}
public void setCurrencies(List<CurrencySingleModel> currencies) {
this.currencies = currencies;
}
}

View File

@ -0,0 +1,53 @@
package eu.eudat.logic.proxy.fetching.entities;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "CcyNtry")
public class CurrencySingleModel {
private String country;
private String currency;
private String code;
private Integer numericCode;
private Integer unit;
@XmlElement(name = "CtryNm")
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
@XmlElement(name = "CcyNm")
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
@XmlElement(name = "Ccy")
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@XmlElement(name = "CcyNbr")
public Integer getNumericCode() {
return numericCode;
}
public void setNumericCode(Integer numericCode) {
this.numericCode = numericCode;
}
@XmlElement(name = "CcyMnrUnts")
public Integer getUnit() {
return unit;
}
public void setUnit(Integer unit) {
this.unit = unit;
}
}

View File

@ -93,6 +93,7 @@ public class ModelBuilder {
if (type.equals("researchers")) return (FieldData<U>) new ResearcherData().fromData(data);
if (type.equals("organizations")) return (FieldData<U>) new OrganizationsData().fromData(data);
if (type.equals("datasetIdentifier")) return (FieldData<U>) new DatasetIdentifierData().fromData(data);
if (type.equals("currency")) return (FieldData<U>) new CurrencyData().fromData(data);
return null;
}
@ -130,6 +131,7 @@ public class ModelBuilder {
if (type.equals("researchers")) return (FieldData<U>) new ResearcherData().fromData(data);
if (type.equals("organizations")) return (FieldData<U>) new OrganizationsData().fromData(data);
if (type.equals("datasetIdentifier")) return (FieldData<U>) new DatasetIdentifierData().fromData(data);
if (type.equals("currency")) return (FieldData<U>) new CurrencyData().fromData(data);
return null;
}
}

View File

@ -0,0 +1,42 @@
package eu.eudat.models.data.components.commons.datafield;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.HashMap;
import java.util.Map;
public class CurrencyData extends FieldData<CurrencyData> {
@Override
public CurrencyData fromData(Object data) {
if (data != null) {
this.setLabel((String) ((Map<String, Object>) data).get("label"));
}
return this;
}
@Override
public Object toData() {
return null;
}
@Override
public Element toXml(Document doc) {
Element root = doc.createElement("data");
root.setAttribute("label", this.getLabel());
return root;
}
@Override
public CurrencyData fromXml(Element item) {
this.setLabel(item != null ? item.getAttribute("label") : "");
return this;
}
@Override
public Map<String, Object> toMap(Element item) {
HashMap dataMap = new HashMap();
dataMap.put("label", item != null ? item.getAttribute("label") : "");
return dataMap;
}
}

View File

@ -0,0 +1,27 @@
package eu.eudat.models.data.local;
public class LocalFetchModel {
private String name;
private String value;
public LocalFetchModel(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@ -217,20 +217,22 @@ public class DatasetRDAMapper {
properties.putAll(DistributionRDAMapper.toProperties(rda.getDistribution().get(0), datasetDescriptionObj));
}
List <String> keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList());
boolean takeAll = false;
if (keywordIds.size() < rda.getKeyword().size()) {
takeAll = true;
}
for (int i = 0; i < keywordIds.size(); i++) {
if (takeAll) {
List<String> tags = new ArrayList<>();
for (String keyword: rda.getKeyword()) {
tags.add(mapper.writeValueAsString(toTagEntity(keyword)));
if (rda.getKeyword() != null) {
List<String> keywordIds = rda.getAdditionalProperties().entrySet().stream().filter(entry -> entry.getKey().startsWith("keyword")).map(entry -> entry.getValue().toString()).collect(Collectors.toList());
boolean takeAll = false;
if (keywordIds.size() < rda.getKeyword().size()) {
takeAll = true;
}
for (int i = 0; i < keywordIds.size(); i++) {
if (takeAll) {
List<String> tags = new ArrayList<>();
for (String keyword : rda.getKeyword()) {
tags.add(mapper.writeValueAsString(toTagEntity(keyword)));
}
properties.put(keywordIds.get(i), tags);
} else {
properties.put(keywordIds.get(i), mapper.writeValueAsString(toTagEntity(rda.getKeyword().get(i))));
}
properties.put(keywordIds.get(i), tags);
} else {
properties.put(keywordIds.get(i), mapper.writeValueAsString(toTagEntity(rda.getKeyword().get(i))));
}
}

View File

@ -42,7 +42,9 @@ public class DmpRDAMapper {
rda.setTitle(dmp.getLabel());
Map<String, Object> extraProperties = new org.json.JSONObject(dmp.getExtraProperties()).toMap();
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language").toString()));
if (!extraProperties.isEmpty()) {
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language").toString()));
}
UserInfo creator;
if (dmp.getCreator() != null) {

View File

@ -0,0 +1,13 @@
<fetchConfig>
<configs>
<config>
<type>currency</type>
<fileType>xml</fileType>
<filePath>internal/iso-4217.xml</filePath>
<parseClass>eu.eudat.logic.proxy.fetching.entities.CurrencyModel</parseClass>
<parseField>currencies</parseField>
<name>currency</name>
<value>code</value>
</config>
</configs>
</fetchConfig>

File diff suppressed because it is too large Load Diff

View File

@ -14,5 +14,6 @@ export enum DatasetProfileFieldViewStyle {
Tags = "tags",
Researchers = "researchers",
Organizations = "organizations",
DatasetIdentifier = "datasetIdentifier"
DatasetIdentifier = "datasetIdentifier",
Currency = "currency"
}

View File

@ -42,6 +42,7 @@ import { UserGuideService } from './services/user-guide/user-guide.service';
import { ConfigurationService } from './services/configuration/configuration.service';
import { HttpClient } from '@angular/common/http';
import { LanguageInfoService } from './services/culture/language-info-service';
import { CurrencyService } from './services/currency/currency.service';
//
//
// This is shared module that provides all the services. Its imported only once on the AppModule.
@ -105,6 +106,7 @@ export class CoreServiceModule {
LanguageService,
LockService,
UserGuideService,
CurrencyService,
ConfigurationService,
{
provide: APP_INITIALIZER,

View File

@ -100,3 +100,7 @@ export interface OrganizationsFieldData extends FieldData {
export interface DatasetIdentifierFieldData extends FieldData {
}
export interface CurrencyFieldData extends FieldData {
}

View File

@ -0,0 +1,4 @@
export class LocalFetchModel {
name: string;
value: string;
}

View File

@ -14,6 +14,7 @@ import { environment } from 'environments/environment';
import { Observable, of as observableOf, throwError as observableThrowError } from 'rxjs';
import { catchError, map, takeUntil } from 'rxjs/operators';
import { ConfigurationService } from '../configuration/configuration.service';
import { CookieService } from 'ngx-cookie-service';
@Injectable()
export class AuthService extends BaseService {
@ -26,7 +27,8 @@ export class AuthService extends BaseService {
private language: TranslateService,
private router: Router,
private uiNotificationService: UiNotificationService,
private configurationService: ConfigurationService
private configurationService: ConfigurationService,
private cookieService: CookieService
) {
super();
@ -73,6 +75,7 @@ export class AuthService extends BaseService {
return this.http.post(url, loginInfo, { headers: this.headers }).pipe(
map((res: any) => {
const principal = this.current(res.payload);
this.cookieService.set('cookiesConsent', 'true', 356);
//this.loginContextSubject.next(true);
return principal;
}),
@ -89,6 +92,7 @@ export class AuthService extends BaseService {
return this.http.post(url, credentials, { headers: this.headers }).pipe(
map((res: any) => {
const principal = this.current(res.payload);
this.cookieService.set('cookiesConsent', 'true', 356);
//this.loginContextSubject.next(true);
return principal;
}),

View File

@ -0,0 +1,21 @@
import { ConfigurationService } from '../configuration/configuration.service';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { LocalFetchModel } from '@app/core/model/local-fetch/local-fetch.model';
import { BaseHttpService } from '../http/base-http.service';
@Injectable()
export class CurrencyService {
private actionUrl: string;
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'currency';
}
get(query: string): Observable<LocalFetchModel[]> {
return this.http.get<LocalFetchModel[]>(`${this.actionUrl}?query=${query}`);
}
}

View File

@ -0,0 +1,19 @@
import { ConfigurationService } from '../../configuration/configuration.service';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { LocalFetchModel } from '@app/core/model/local-fetch/local-fetch.model';
import { BaseHttpService } from '../../http/base-http.service';
@Injectable()
export class CurrencyService {
private actionUrl: string;
constructor(private http: BaseHttpService, private configurationService: ConfigurationService) {
this.actionUrl = configurationService.server + 'currency';
}
get(): Observable<LocalFetchModel[]> {
return this.http.get<LocalFetchModel[]>(this.actionUrl);
}
}

View File

@ -83,6 +83,7 @@ export class EnumUtils {
case DatasetProfileFieldViewStyle.Researchers: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.RESEARCHERS');
case DatasetProfileFieldViewStyle.Organizations: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.ORGANIZATIONS');
case DatasetProfileFieldViewStyle.DatasetIdentifier: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.DATASET-IDENTIFIER');
case DatasetProfileFieldViewStyle.Currency: return this.language.instant('TYPES.DATASET-PROFILE-FIELD-VIEW-STYLE.CURRENCY');
}
}

View File

@ -0,0 +1,19 @@
import { FormGroup } from '@angular/forms';
import { FieldDataEditorModel } from './field-data-editor-model';
import { CurrencyFieldData } from '../../../../../core/model/dataset-profile-definition/field-data/field-data';
export class CurrencyDataEditorModel extends FieldDataEditorModel<CurrencyDataEditorModel> {
public label: string;
buildForm(disabled: boolean = false, skipDisable: Array<String> = []): FormGroup {
const formGroup = this.formBuilder.group({
label: [{ value: this.label, disabled: (disabled && !skipDisable.includes('CurrencyDataEditorModel.label')) }]
});
return formGroup;
}
fromModel(item: CurrencyFieldData): CurrencyDataEditorModel {
this.label = item.label;
return this;
}
}

View File

@ -26,6 +26,7 @@ import { TagsDataEditorModel } from './field-data/tags-data-editor-models';
import { ResearchersDataEditorModel } from './field-data/researchers-data-editor-models';
import { OrganizationsDataEditorModel } from './field-data/organizations-data-editor-models';
import { DatasetIdentifierDataEditorModel } from './field-data/dataset-identifier-data-editor-models';
import { CurrencyDataEditorModel } from './field-data/currency-data-editor-models';
export class FieldEditorModel extends BaseFormModel {
@ -73,6 +74,7 @@ export class FieldEditorModel extends BaseFormModel {
if (this.viewStyle.renderStyle === 'researchers') { this.data = new ResearchersDataEditorModel().fromModel(item.data); }
if (this.viewStyle.renderStyle === 'organizations') { this.data = new OrganizationsDataEditorModel().fromModel(item.data); }
if (this.viewStyle.renderStyle === 'datasetIdentifier') { this.data = new DatasetIdentifierDataEditorModel().fromModel(item.data); }
if (this.viewStyle.renderStyle === 'currency') { this.data = new CurrencyDataEditorModel().fromModel(item.data); }
}
}
return this;

View File

@ -36,6 +36,7 @@ import { DatasetProfileEditorTagsFieldComponent } from './editor/components/fiel
import { DatasetProfileEditorResearchersFieldComponent } from './editor/components/field-type/researchers/dataset-profile-editor-researchers-field.component';
import { DatasetProfileEditorOrganizationsFieldComponent } from './editor/components/field-type/organizations/dataset-profile-editor-organizations-field.component';
import { DatasetProfileEditorDatasetIdentifierFieldComponent } from './editor/components/field-type/dataset-identifier/dataset-profile-editor-dataset-identifier-field.component';
import { DatasetProfileEditorCurrencyFieldComponent } from './editor/components/field-type/currency/dataset-profile-editor-currency-field.component';
@NgModule({
imports: [
@ -77,7 +78,8 @@ import { DatasetProfileEditorDatasetIdentifierFieldComponent } from './editor/co
DatasetProfileEditorTagsFieldComponent,
DatasetProfileEditorResearchersFieldComponent,
DatasetProfileEditorOrganizationsFieldComponent,
DatasetProfileEditorDatasetIdentifierFieldComponent
DatasetProfileEditorDatasetIdentifierFieldComponent,
DatasetProfileEditorCurrencyFieldComponent
],
entryComponents: [
DialodConfirmationUploadDatasetProfiles

View File

@ -0,0 +1,9 @@
<div class="row" *ngIf="form.get('data')">
<h5 style="font-weight: bold" class="col-12">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-DATE-PICKER-TITLE'
| translate}}</h5>
<mat-form-field class="col-12">
<input matInput type="string"
placeholder="{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.FIELD-CHECKBOX-PLACEHOLDER' | translate}}"
[formControl]="form.get('data').get('label')">
</mat-form-field>
</div>

View File

@ -0,0 +1,18 @@
import { Component, Input, OnInit } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { DataRepositoriesDataEditorModel } from '@app/ui/admin/dataset-profile/admin/field-data/data-repositories-data-editor-models';
@Component({
selector: 'app-dataset-profile-editor-currency-field-component',
styleUrls: ['./dataset-profile-editor-currency-field.component.scss'],
templateUrl: './dataset-profile-editor-currency-field.component.html'
})
export class DatasetProfileEditorCurrencyFieldComponent implements OnInit {
@Input() form: FormGroup;
private data: DataRepositoriesDataEditorModel = new DataRepositoriesDataEditorModel();
ngOnInit() {
if (!this.form.get('data')) { this.form.addControl('data', this.data.buildForm()); }
}
}

View File

@ -25,6 +25,7 @@
<mat-option [value]="viewStyleEnum.Researchers">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.Researchers)}}</mat-option>
<mat-option [value]="viewStyleEnum.Organizations">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.Organizations)}}</mat-option>
<mat-option [value]="viewStyleEnum.DatasetIdentifier">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.DatasetIdentifier)}}</mat-option>
<mat-option [value]="viewStyleEnum.Currency">{{enumUtils.toDatasetProfileFieldViewStyleString(viewStyleEnum.Currency)}}</mat-option>
</mat-select>
<mat-error *ngIf="this.form.get('viewStyle').get('renderStyle').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
@ -80,6 +81,7 @@
<app-dataset-profile-editor-researchers-field-component *ngSwitchCase="viewStyleEnum.Researchers" class="col-12" [form]="form"></app-dataset-profile-editor-researchers-field-component>
<app-dataset-profile-editor-organizations-field-component *ngSwitchCase="viewStyleEnum.Organizations" class="col-12" [form]="form"></app-dataset-profile-editor-organizations-field-component>
<app-dataset-profile-editor-dataset-identifier-field-component *ngSwitchCase="viewStyleEnum.DatasetIdentifier" class="col-12" [form]="form"></app-dataset-profile-editor-dataset-identifier-field-component>
<app-dataset-profile-editor-currency-field-component *ngSwitchCase="viewStyleEnum.Currency" class="col-12" [form]="form"></app-dataset-profile-editor-currency-field-component>
</div>
<div class="row">
<h4 class="col-12" style="font-weight: bold">{{'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.FIELDS.RULES-TITLE' | translate}}

View File

@ -25,6 +25,7 @@ import { ResearchersDataEditorModel } from '../../../admin/field-data/researcher
import { OrganizationsDataEditorModel } from '../../../admin/field-data/organizations-data-editor-models';
import { DatasetIdentifierDataEditorModel } from '../../../admin/field-data/dataset-identifier-data-editor-models';
import { ExternalDatasetsDataEditorModel } from '../../../admin/field-data/external-datasets-data-editor-models';
import { CurrencyDataEditorModel } from '../../../admin/field-data/currency-data-editor-models';
@Component({
selector: 'app-dataset-profile-editor-field-component',
@ -109,6 +110,9 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
case DatasetProfileFieldViewStyle.DatasetIdentifier:
this.form.addControl('data', new DatasetIdentifierDataEditorModel().buildForm());
break;
case DatasetProfileFieldViewStyle.Currency:
this.form.addControl('data', new CurrencyDataEditorModel().buildForm());
break;
}
}
});
@ -133,6 +137,7 @@ export class DatasetProfileEditorFieldComponent extends BaseComponent implements
case DatasetProfileFieldViewStyle.Registries:
case DatasetProfileFieldViewStyle.Organizations:
case DatasetProfileFieldViewStyle.DatasetIdentifier:
case DatasetProfileFieldViewStyle.Currency:
return false;
default:
return false;

View File

@ -8,7 +8,7 @@
<mat-error *ngIf="formGroup.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
<div class="row">
<div class="row" *ngIf="showUri">
<mat-form-field class="col-sm-12 col-md-6">
<input matInput placeholder="{{'DATASET-EDITOR.FIELDS.URI' | translate}}" type="text" name="uri" formControlName="uri">
<mat-error *ngIf="formGroup.get('uri').hasError('backendError')">{{formGroup.get('uri').getError('backendError').message}}</mat-error>

View File

@ -11,6 +11,7 @@ import { BaseComponent } from '@common/base/base.component';
export class DatasetEditorComponent extends BaseComponent {
@Input() formGroup: FormGroup = null;
showUri: boolean = false;
constructor(
private router: Router,

View File

@ -244,4 +244,16 @@
</mat-form-field>
</div>
</div>
<div *ngSwitchCase="datasetProfileFieldViewStyleEnum.Currency" class="col-12">
<div class="row">
<mat-form-field class="col-md-12">
<app-single-auto-complete placeholder="{{ form.get('data').value.label | translate }}" [formControl]="form.get('value')"
[configuration]="currencyAutoCompleteConfiguration" [required]="form.get('validationRequired').value">
</app-single-auto-complete>
<mat-error *ngIf="form.get('value').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}
</mat-error>
</mat-form-field>
</div>
</div>
</div>

View File

@ -32,6 +32,8 @@ import { ExternalTagEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-w
import { MatChipInputEvent } from '@angular/material';
import { ENTER, COMMA } from '@angular/cdk/keycodes';
import { DatasetIdModel } from '@app/core/model/dataset/dataset-id.model';
import { LocalFetchModel } from '@app/core/model/local-fetch/local-fetch.model';
import { CurrencyService } from '@app/core/services/currency/currency.service';
@Component({
selector: 'app-form-field',
@ -60,6 +62,7 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
tagsAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
researchersAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
organisationsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration;
currencyAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
readonly separatorKeysCodes: number[] = [ENTER, COMMA];
@ -81,7 +84,8 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
private externalSourcesService: ExternalSourcesService,
private language: TranslateService,
private datasetService: DatasetService,
private dmpService: DmpService
private dmpService: DmpService,
private currencyService: CurrencyService
) { super(); }
ngOnInit() {
@ -183,6 +187,15 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
this.form.addControl('value', new DatasetIdModel(value).buildForm());
this.datasetIdInitialized = true;
break;
case DatasetProfileFieldViewStyle.Currency:
this.currencyAutoCompleteConfiguration = {
filterFn: this.searchCurrency.bind(this),
initialItems: () => this.searchCurrency(''),
displayFn: (item) => typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name,
titleFn: (item) => typeof (item) == 'string' ? JSON.parse(item)['name'] : item.name,
valueAssign: (item) => typeof (item) == 'string' ? item : JSON.stringify(item)
};
break;
}
if (this.form.get('viewStyle').value.renderStyle === DatasetProfileFieldViewStyle.InternalDmpEntities) {
@ -347,4 +360,8 @@ export class FormFieldComponent extends BaseComponent implements OnInit {
getDatasetIdControl(name: string): FormControl {
return this.form.get('value').get(name) as FormControl;
}
searchCurrency(query: string): Observable<LocalFetchModel[]> {
return this.currencyService.get(query);
}
}

View File

@ -943,7 +943,8 @@
"TAGS": "Tags",
"RESEARCHERS": "Researchers",
"ORGANIZATIONS": "Organizations",
"DATASET-IDENTIFIER": "Dataset Identifier"
"DATASET-IDENTIFIER": "Dataset Identifier",
"CURRENCY": "Currency"
},
"DATASET-PROFILE-COMBO-BOX-TYPE": {
"WORD-LIST": "Word List",

View File

@ -942,7 +942,8 @@
"TAGS": "Tags",
"RESEARCHERS": "Researchers",
"ORGANIZATIONS": "Organizations",
"DATASET-IDENTIFIER": "Dataset Identifier"
"DATASET-IDENTIFIER": "Dataset Identifier",
"CURRENCY": "Currency"
},
"DATASET-PROFILE-COMBO-BOX-TYPE": {
"WORD-LIST": "Lista de palabras",

View File

@ -62,7 +62,7 @@
"DELETE": "Διαγραφή",
"REMOVE": "Αφαίρεση",
"CANCEL": "Ακύρωση",
"LEAVE": "Αναχώρηση",
"LEAVE": "Αποχώρηση",
"POLICY-AGREE": "Κάντε τα ονόματα ορατά στο κοινό.",
"REQUIRED": "Απαιτείται να κάνετε κλικ στο πλαίσιο ελέγχου."
}
@ -942,7 +942,8 @@
"TAGS": "Tags",
"RESEARCHERS": "Researchers",
"ORGANIZATIONS": "Organizations",
"DATASET-IDENTIFIER": "Dataset Identifier"
"DATASET-IDENTIFIER": "Dataset Identifier",
"CURRENCY": "Currency"
},
"DATASET-PROFILE-COMBO-BOX-TYPE": {
"WORD-LIST": "Λίστα Λέξεων",