Add new fields in personal info and services. Add migration script
This commit is contained in:
parent
cc6d8491fd
commit
3083a73627
|
@ -1,13 +1,13 @@
|
|||
ALTER TABLE ONLY registered_service ADD COLUMN url character varying(255);
|
||||
ALTER TABLE ONLY registered_service ADD COLUMN url character varying(255) NOT NULL DEFAULT '';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS personal_info
|
||||
(
|
||||
id character varying(255) NOT NULL,
|
||||
affiliation character varying(255),
|
||||
email character varying(255),
|
||||
name character varying(255),
|
||||
"position" character varying(255),
|
||||
surname character varying(255)
|
||||
affiliation character varying(255) NOT NULL,
|
||||
email character varying(255) NOT NULL,
|
||||
name character varying(255) NOT NULL,
|
||||
"position" character varying(255) NOT NULL,
|
||||
surname character varying(255) NOT NULL
|
||||
);
|
||||
|
||||
ALTER TABLE ONLY personal_info DROP CONSTRAINT IF EXISTS personal_info_pkey;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
ALTER TABLE ONLY personal_info ADD COLUMN affilation_type character varying(255);
|
||||
ALTER TABLE ONLY personal_info ADD COLUMN affiliation_type character varying(255) NOT NULL;
|
||||
ALTER TABLE ONLY registered_service ADD COLUMN description character varying(255);
|
||||
ALTER TABLE ONLY registered_service ADD COLUMN frequency character varying(255);
|
||||
ALTER TABLE ONLY registered_service ADD COLUMN target text[];
|
||||
ALTER TABLE ONLY registered_service ADD COLUMN frequency character varying(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE ONLY registered_service ADD COLUMN target character varying(255) NOT NULL DEFAULT '';
|
||||
|
|
|
@ -37,7 +37,7 @@ public class SwaggerConfig extends WebMvcConfigurerAdapter {
|
|||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("eu.dnetlib.clientmanagement.controllers"))
|
||||
.apis(RequestHandlerSelectors.basePackage("eu.dnetlib.developers.controllers"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.hibernate.validator.constraints.URL;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ServiceForm {
|
||||
@JsonProperty(required = true)
|
||||
private String name;
|
||||
|
@ -17,6 +19,9 @@ public class ServiceForm {
|
|||
private String value;
|
||||
@JsonIgnore
|
||||
private Jwks jwks;
|
||||
private String description;
|
||||
private String frequency;
|
||||
private List<String> target;
|
||||
|
||||
public ServiceForm() {
|
||||
}
|
||||
|
@ -76,4 +81,28 @@ public class ServiceForm {
|
|||
public void setJwks(Jwks jwks) {
|
||||
this.jwks = jwks;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getFrequency() {
|
||||
return frequency;
|
||||
}
|
||||
|
||||
public void setFrequency(String frequency) {
|
||||
this.frequency = frequency;
|
||||
}
|
||||
|
||||
public List<String> getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(List<String> target) {
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ public class PersonalInfo {
|
|||
String surname;
|
||||
String email;
|
||||
String affiliation;
|
||||
String affiliationType;
|
||||
String position;
|
||||
|
||||
public PersonalInfo() {
|
||||
|
@ -57,6 +58,14 @@ public class PersonalInfo {
|
|||
this.affiliation = affiliation;
|
||||
}
|
||||
|
||||
public String getAffiliationType() {
|
||||
return affiliationType;
|
||||
}
|
||||
|
||||
public void setAffiliationType(String affiliationType) {
|
||||
this.affiliationType = affiliationType;
|
||||
}
|
||||
|
||||
public String getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package eu.dnetlib.developers.entities;
|
||||
|
||||
import eu.dnetlib.developers.utils.StringListConverter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
public class RegisteredService {
|
||||
|
@ -17,15 +21,22 @@ public class RegisteredService {
|
|||
String registrationAccessToken;
|
||||
String keyType;
|
||||
String url;
|
||||
String description;
|
||||
String frequency;
|
||||
@Convert(converter = StringListConverter.class)
|
||||
private List<String> target;
|
||||
|
||||
public RegisteredService() {
|
||||
this.creationDate = new Date();
|
||||
}
|
||||
|
||||
public RegisteredService(String owner, String name, String url, String keyType) {
|
||||
public RegisteredService(String owner, String name, String url, String keyType, String description, String frequency, List<String> target) {
|
||||
this.owner = owner;
|
||||
this.name = name;
|
||||
this.keyType = keyType;
|
||||
this.description = description;
|
||||
this.frequency = frequency;
|
||||
this.target = target;
|
||||
this.creationDate = new Date();
|
||||
}
|
||||
|
||||
|
@ -92,4 +103,28 @@ public class RegisteredService {
|
|||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getFrequency() {
|
||||
return frequency;
|
||||
}
|
||||
|
||||
public void setFrequency(String frequency) {
|
||||
this.frequency = frequency;
|
||||
}
|
||||
|
||||
public List<String> getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(List<String> target) {
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public class APIService {
|
|||
api.setService(service);
|
||||
api.setDetails(readService(service.getClientId(), service.getRegistrationAccessToken()));
|
||||
} else {
|
||||
api.setService(new RegisteredService(authentication.getSub(), form.getName(), form.getUrl(), form.getKeyType()));
|
||||
api.setService(new RegisteredService(authentication.getSub(), form.getName(), form.getUrl(), form.getKeyType(), form.getDescription(), form.getFrequency(), form.getTarget()));
|
||||
}
|
||||
String keyType = form.getKeyType();
|
||||
if(keyType != null && keyType.equals("uri")) {
|
||||
|
@ -111,6 +111,9 @@ public class APIService {
|
|||
}
|
||||
api.getService().setKeyType(form.getKeyType());
|
||||
api.getService().setUrl(form.getUrl());
|
||||
api.getService().setDescription(form.getDescription());
|
||||
api.getService().setFrequency(form.getFrequency());
|
||||
api.getService().setTarget(form.getTarget());
|
||||
api.getService().setName(request.getClientName());
|
||||
api.getService().setClientId(response.getClientId());
|
||||
api.getService().setRegistrationAccessToken(response.getRegistrationAccessToken());
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package eu.dnetlib.developers.utils;
|
||||
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.Converter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Converter
|
||||
public class StringListConverter implements AttributeConverter<List<String>, String> {
|
||||
private static final String ARRAY_DELIMITER = ",";
|
||||
|
||||
@Override
|
||||
public String convertToDatabaseColumn(List<String> attribute) {
|
||||
if (attribute == null || attribute.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return String.join(ARRAY_DELIMITER, attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> convertToEntityAttribute(String dbData) {
|
||||
if (dbData == null || dbData.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return Arrays.asList(dbData.split(ARRAY_DELIMITER));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue