Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit bf33e6b

Browse files
author
Tim Sowers
committed
Empty values getting into data; (DOECODE-866)
1 parent 7bc079a commit bf33e6b

File tree

5 files changed

+360
-309
lines changed

5 files changed

+360
-309
lines changed
Lines changed: 120 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,120 @@
1-
package gov.osti.entity;
2-
3-
import com.fasterxml.jackson.annotation.JsonIgnore;
4-
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5-
import gov.osti.services.Validation;
6-
import java.io.Serializable;
7-
import javax.persistence.Column;
8-
import javax.persistence.GeneratedValue;
9-
import javax.persistence.GenerationType;
10-
import javax.persistence.Id;
11-
import javax.persistence.MappedSuperclass;
12-
import javax.validation.constraints.Size;
13-
import org.apache.commons.lang3.StringUtils;
14-
import org.slf4j.Logger;
15-
import org.slf4j.LoggerFactory;
16-
17-
/**
18-
* Base class for "Persons" or Agents: currently parent class for Developers
19-
* and Contributors.
20-
*
21-
* @author ensornl
22-
*/
23-
@MappedSuperclass
24-
@JsonIgnoreProperties ( ignoreUnknown = true )
25-
public class Agent implements Serializable {
26-
private static Logger log = LoggerFactory.getLogger(Agent.class);
27-
private Long agentId = 0L;
28-
private String email = "";
29-
private String orcid = "";
30-
private String firstName = "";
31-
private String lastName = "";
32-
private String middleName = "";
33-
34-
public Agent() {
35-
36-
}
37-
38-
@Id
39-
@GeneratedValue(strategy = GenerationType.AUTO)
40-
@Column (name = "AGENT_ID")
41-
@JsonIgnore
42-
public Long getAgentId() {
43-
return this.agentId;
44-
}
45-
46-
public void setAgentId(Long id) {
47-
this.agentId = id;
48-
}
49-
50-
@Size (max = 255, message = "First name is limited to 255 characters.")
51-
@Column (name = "FIRST_NAME")
52-
public String getFirstName() {
53-
return firstName;
54-
}
55-
public void setFirstName(String firstName) {
56-
this.firstName = firstName;
57-
}
58-
@Size (max = 255, message = "Last name is limited to 255 characters.")
59-
@Column (name = "LAST_NAME")
60-
public String getLastName() {
61-
return lastName;
62-
}
63-
public void setLastName(String lastName) {
64-
this.lastName = lastName;
65-
}
66-
@Size (max = 255, message = "Middle name is limited to 255 characters.")
67-
@Column (name = "MIDDLE_NAME")
68-
public String getMiddleName() {
69-
return middleName;
70-
}
71-
public void setMiddleName(String middleName) {
72-
this.middleName = middleName;
73-
}
74-
75-
@Size (max = 640, message = "Email is limited to 640 characters.")
76-
@Column (length = 640)
77-
public String getEmail() {
78-
return email;
79-
}
80-
public void setEmail(String email) {
81-
this.email = email;
82-
}
83-
84-
85-
86-
public String getOrcid() {
87-
return orcid;
88-
}
89-
public void setOrcid(String orcid) {
90-
this.orcid = Validation.formatORCID(orcid, "dashed");
91-
}
92-
93-
/**
94-
* Generate a "full name" for indexing purposes. Should return
95-
* "Last, First Middle" will null-safe protection.
96-
*
97-
* @return the Agent full name as a String
98-
*/
99-
@Override
100-
public String toString() {
101-
return ((StringUtils.isEmpty(getLastName())) ? "" : getLastName() + ", ") +
102-
((StringUtils.isEmpty(getFirstName()) ? " " : getFirstName() + " ")) +
103-
((StringUtils.isEmpty(getMiddleName()) ? "" : getMiddleName()));
104-
}
105-
}
1+
package gov.osti.entity;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnore;
4+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import gov.osti.services.Validation;
6+
import java.io.Serializable;
7+
import javax.persistence.Column;
8+
import javax.persistence.GeneratedValue;
9+
import javax.persistence.GenerationType;
10+
import javax.persistence.Id;
11+
import javax.persistence.MappedSuperclass;
12+
import javax.validation.constraints.Size;
13+
import org.apache.commons.lang3.StringUtils;
14+
import org.slf4j.Logger;
15+
import org.slf4j.LoggerFactory;
16+
import java.util.List;
17+
18+
/**
19+
* Base class for "Persons" or Agents: currently parent class for Developers
20+
* and Contributors.
21+
*
22+
* @author ensornl
23+
*/
24+
@MappedSuperclass
25+
@JsonIgnoreProperties ( ignoreUnknown = true )
26+
public class Agent implements Serializable {
27+
private static Logger log = LoggerFactory.getLogger(Agent.class);
28+
private Long agentId = 0L;
29+
private String email = "";
30+
private String orcid = "";
31+
private String firstName = "";
32+
private String lastName = "";
33+
private String middleName = "";
34+
35+
public Agent() {
36+
37+
}
38+
39+
@Id
40+
@GeneratedValue(strategy = GenerationType.AUTO)
41+
@Column (name = "AGENT_ID")
42+
@JsonIgnore
43+
public Long getAgentId() {
44+
return this.agentId;
45+
}
46+
47+
public void setAgentId(Long id) {
48+
this.agentId = id;
49+
}
50+
51+
@Size (max = 255, message = "First name is limited to 255 characters.")
52+
@Column (name = "FIRST_NAME")
53+
public String getFirstName() {
54+
return firstName;
55+
}
56+
public void setFirstName(String firstName) {
57+
this.firstName = firstName;
58+
}
59+
@Size (max = 255, message = "Last name is limited to 255 characters.")
60+
@Column (name = "LAST_NAME")
61+
public String getLastName() {
62+
return lastName;
63+
}
64+
public void setLastName(String lastName) {
65+
this.lastName = lastName;
66+
}
67+
@Size (max = 255, message = "Middle name is limited to 255 characters.")
68+
@Column (name = "MIDDLE_NAME")
69+
public String getMiddleName() {
70+
return middleName;
71+
}
72+
public void setMiddleName(String middleName) {
73+
this.middleName = middleName;
74+
}
75+
76+
@Size (max = 640, message = "Email is limited to 640 characters.")
77+
@Column (length = 640)
78+
public String getEmail() {
79+
return email;
80+
}
81+
public void setEmail(String email) {
82+
this.email = email;
83+
}
84+
85+
86+
87+
public String getOrcid() {
88+
return orcid;
89+
}
90+
public void setOrcid(String orcid) {
91+
this.orcid = Validation.formatORCID(orcid, "dashed");
92+
}
93+
94+
/**
95+
* Generate a "full name" for indexing purposes. Should return
96+
* "Last, First Middle" will null-safe protection.
97+
*
98+
* @return the Agent full name as a String
99+
*/
100+
@Override
101+
public String toString() {
102+
return ((StringUtils.isEmpty(getLastName())) ? "" : getLastName() + ", ") +
103+
((StringUtils.isEmpty(getFirstName()) ? " " : getFirstName() + " ")) +
104+
((StringUtils.isEmpty(getMiddleName()) ? "" : getMiddleName()));
105+
}
106+
107+
protected List<String> CleanList(List<String> list) {
108+
if (list != null) {
109+
// remove empty data
110+
int cnt = list.size();
111+
for (int i = cnt - 1; i >= 0; i--) {
112+
String s = list.get(i);
113+
if (StringUtils.isBlank(s))
114+
list.remove(i);
115+
}
116+
}
117+
118+
return list;
119+
}
120+
}

0 commit comments

Comments
 (0)