FaoInstituteDTO.java
/*
* Copyright 2024 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys.server.api.v2.model.impl;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.genesys.blocks.security.serialization.Permissions;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Data
public class FaoInstituteDTO {
private Long id;
@Size(max = 10)
@NotNull
private String code;
@Size(max = 300)
private String fullName;
@Size(max = 100)
private String type;
@Size(max = 300)
private String url;
@Size(max = 300)
private String email;
@Size(max = 300)
private String address;
@Size(max = 40)
private String zipCode;
@Size(max = 200)
private String cityState;
@Size(max = 100)
private String phone;
@Size(max = 100)
private String fax;
private String acronym;
@Size(max = 10)
private String vCode;
private String codeSGSV;
private boolean current;
private CountryInfo country;
private Map<String, FaoInstituteSettingInfo> settings = new HashMap<>();
private List<PGRFANetworkInfo> networks;
private PartnerInfo owner;
private long accessionCount;
private boolean pgrActivity;
private boolean maintainsCollection;
private Double latitude;
private Double longitude;
private Double elevation;
private boolean uniqueAcceNumbs = false;
private boolean allowMaterialRequests = false;
private Double pdciMin;
private Double pdciMax;
private Double pdciAvg;
private String pdciHistogram;
/** Remote site URL for external requests */
private URL requestApiEndpoint;
/** Remote site authorization header */
@Size(max = 1024)
private String requestApiAuthorization;
private Permissions _permissions;
/**
* Transient. Get the list of valid URLs from {@link #url}
*
* @throws MalformedURLException
*/
public List<URL> getUrls() {
if (StringUtils.isBlank(this.url)) {
return null;
}
String[] s = this.url.split("[,;\\s]+");
ArrayList<URL> urls = new ArrayList<URL>(s.length);
for (String u : s) {
if (StringUtils.isBlank(u)) {
continue;
}
try {
urls.add(new URL(u.trim()));
} catch (MalformedURLException e) {
}
}
return urls;
}
}