2021-09-20 16:47:35 +02:00
|
|
|
package org.gcube.application.geoportal.common.model.profile;
|
|
|
|
|
2022-01-12 18:42:22 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
2021-09-20 16:47:35 +02:00
|
|
|
import java.util.List;
|
2022-01-12 18:42:22 +01:00
|
|
|
import java.util.Map;
|
2021-09-20 16:47:35 +02:00
|
|
|
|
|
|
|
import javax.xml.bind.annotation.XmlRootElement;
|
|
|
|
|
2022-02-23 17:13:22 +01:00
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
2022-01-17 18:19:40 +01:00
|
|
|
import com.vdurmont.semver4j.Semver;
|
2021-12-07 12:16:29 +01:00
|
|
|
import lombok.Data;
|
2021-09-20 16:47:35 +02:00
|
|
|
import lombok.NoArgsConstructor;
|
2022-02-24 18:09:30 +01:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.XSlf4j;
|
2022-02-14 12:23:13 +01:00
|
|
|
import org.gcube.application.geoportal.common.model.document.accounting.AccountingInfo;
|
2021-09-20 16:47:35 +02:00
|
|
|
|
2021-12-07 12:16:29 +01:00
|
|
|
@Data
|
2021-09-20 16:47:35 +02:00
|
|
|
@NoArgsConstructor
|
|
|
|
@XmlRootElement
|
2022-02-24 18:09:30 +01:00
|
|
|
@Slf4j
|
2021-09-20 16:47:35 +02:00
|
|
|
public class Profile{
|
|
|
|
|
2022-02-23 17:13:22 +01:00
|
|
|
public static final String ID="_id";
|
|
|
|
public static final String VERSION="_version";
|
|
|
|
public static final String NAME="_name";
|
|
|
|
public static final String DESCRIPTION="_description";
|
|
|
|
public static final String CREATION_INFO="_creationInfo";
|
|
|
|
public static final String SCHEMA="_schema";
|
|
|
|
public static final String HANDLERS="_handlers";
|
|
|
|
public static final String DATA_ACCESS_POLICIES="_dataAccessPolicies";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@JsonProperty(ID)
|
2021-09-20 16:47:35 +02:00
|
|
|
private String id;
|
2022-02-23 17:13:22 +01:00
|
|
|
@JsonProperty(VERSION)
|
2022-01-17 18:19:40 +01:00
|
|
|
private Semver version;
|
2021-12-07 13:05:08 +01:00
|
|
|
|
2022-02-23 17:13:22 +01:00
|
|
|
@JsonProperty(NAME)
|
2021-12-07 13:05:08 +01:00
|
|
|
private String name;
|
2022-02-23 17:13:22 +01:00
|
|
|
@JsonProperty(DESCRIPTION)
|
2021-12-07 13:05:08 +01:00
|
|
|
private String description;
|
2022-02-23 17:13:22 +01:00
|
|
|
@JsonProperty(CREATION_INFO)
|
2021-12-07 13:05:08 +01:00
|
|
|
private AccountingInfo creationInfo;
|
|
|
|
|
2022-02-23 17:13:22 +01:00
|
|
|
@JsonProperty(SCHEMA)
|
2022-01-17 18:19:40 +01:00
|
|
|
private Field schema;
|
2021-12-07 13:05:08 +01:00
|
|
|
|
2022-02-23 17:13:22 +01:00
|
|
|
@JsonProperty(HANDLERS)
|
2021-12-07 13:05:08 +01:00
|
|
|
private List<HandlerDeclaration> handlers;
|
2022-01-12 18:42:22 +01:00
|
|
|
|
2022-01-27 15:02:53 +01:00
|
|
|
|
2022-02-23 17:13:22 +01:00
|
|
|
@JsonProperty(DATA_ACCESS_POLICIES)
|
2022-01-27 15:02:53 +01:00
|
|
|
private List<DataAccessPolicy> dataAccessPolicies;
|
|
|
|
|
2022-01-12 18:42:22 +01:00
|
|
|
/**
|
|
|
|
* Returns map Type -> Handler Declaration
|
|
|
|
* @return
|
|
|
|
*/
|
2022-02-24 18:09:30 +01:00
|
|
|
public Map<String,List<HandlerDeclaration>> getHandlersMapByType(){
|
2022-01-12 18:42:22 +01:00
|
|
|
HashMap<String,List<HandlerDeclaration>> toReturn=new HashMap<>();
|
|
|
|
handlers.forEach(h->{
|
2022-02-24 18:09:30 +01:00
|
|
|
try {
|
2022-01-12 18:42:22 +01:00
|
|
|
if(!toReturn.containsKey(h.getType()))
|
|
|
|
toReturn.put(h.getType(),new ArrayList<>());
|
|
|
|
toReturn.get(h.getType()).add(h);
|
2022-02-24 18:09:30 +01:00
|
|
|
}catch (Throwable t){log.error("Invalid profile : unable to get Handler Map by Type with {} in profile [ID {}]",h,this.getId(),t);}
|
2022-01-12 18:42:22 +01:00
|
|
|
});
|
|
|
|
return toReturn;
|
|
|
|
}
|
2022-01-17 18:19:40 +01:00
|
|
|
|
2022-02-24 18:09:30 +01:00
|
|
|
/**
|
|
|
|
* Returns map Type -> Handler Declaration
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public Map<String,List<HandlerDeclaration>> getHandlersMapByID(){
|
|
|
|
HashMap<String,List<HandlerDeclaration>> toReturn=new HashMap<>();
|
|
|
|
handlers.forEach(h->{
|
|
|
|
try {
|
|
|
|
if (!toReturn.containsKey(h.getId()))
|
|
|
|
toReturn.put(h.getId(), new ArrayList<>());
|
|
|
|
toReturn.get(h.getId()).add(h);
|
|
|
|
}catch (Throwable t){
|
|
|
|
log.error("Invalid profile : unable to get Handler Map by ID with {} in profile [ID {}]",h,this.getId(),t);}
|
|
|
|
});
|
|
|
|
return toReturn;
|
|
|
|
}
|
2022-01-17 18:19:40 +01:00
|
|
|
|
2021-09-20 16:47:35 +02:00
|
|
|
}
|