-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompanyModel.java
More file actions
235 lines (214 loc) · 8.34 KB
/
CompanyModel.java
File metadata and controls
235 lines (214 loc) · 8.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
package com.example.spring.app.company;
import com.example.spring.app.company.dto.CompanyDTO;
import com.example.spring.app.company.objects.ContactDTO;
import com.example.spring.app.company.objects.SocialMediaDTO;
import io.hypersistence.utils.hibernate.type.json.JsonBinaryType;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Type;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
import java.util.Map;
import static com.example.spring.app.company.financial.FinancialPeriodMapper.toFinancialPeriodDTOList;
import static com.example.spring.app.company.CompanyUtil.maskData;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
@Entity
@Table(name = "companies")
public class CompanyModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String companyName;
private String sirenNumber;
private String nicNumber;
private String legalForm;
@Column(name = "ape_code")
private String apeCode;
private String apeLabel;
private String address;
private String postalCode;
private String departmentNumber;
private String department;
private String city;
private String region;
private String tradeName;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate registrationDate;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate deregistrationDate;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2018_1;
private Double revenue_2018_1;
private Double turnover_2018_1;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2018_2;
private Double revenue_2018_2;
private Double turnover_2018_2;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2018_3;
private Double revenue_2018_3;
private Double turnover_2018_3;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2019_1;
private Double revenue_2019_1;
private Double turnover_2019_1;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2019_2;
private Double revenue_2019_2;
private Double turnover_2019_2;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2019_3;
private Double revenue_2019_3;
private Double turnover_2019_3;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2020_1;
private Double revenue_2020_1;
private Double turnover_2020_1;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2020_2;
private Double revenue_2020_2;
private Double turnover_2020_2;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2020_3;
private Double revenue_2020_3;
private Double turnover_2020_3;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2021_1;
private Double revenue_2021_1;
private Double turnover_2021_1;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2021_2;
private Double revenue_2021_2;
private Double turnover_2021_2;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2021_3;
private Double revenue_2021_3;
private Double turnover_2021_3;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2022_1;
private Double revenue_2022_1;
private Double turnover_2022_1;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2022_2;
private Double revenue_2022_2;
private Double turnover_2022_2;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2022_3;
private Double revenue_2022_3;
private Double turnover_2022_3;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2023_1;
private Double revenue_2023_1;
private Double turnover_2023_1;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2023_2;
private Double revenue_2023_2;
private Double turnover_2023_2;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate closingDate_2023_3;
private Double revenue_2023_3;
private Double turnover_2023_3;
private String industrySector;
private String phoneNumber;
@Column(length = 3000)
private String website;
@Type(JsonBinaryType.class)
@Column(length = 100000, columnDefinition = "jsonb")
private Map<String, Object> reviews;
@Type(JsonBinaryType.class)
@Column(length = 100000, columnDefinition = "jsonb")
private String schedule;
@Column(length = 10000)
private String instagram;
@Column(length = 3000)
private String facebook;
@Column(length = 3000)
private String twitter;
@Column(length = 3000)
private String linkedin;
@Column(length = 3000)
private String youtube;
@Column(length = 3000)
private String email;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate scrapingDate;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate dateCreation;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate lastProcessingDate;
private Integer numberOfEmployee;
private String companyCategory;
public void updateFrom(CompanyModel other) {
this.phoneNumber = other.getPhoneNumber();
this.website = other.getWebsite();
this.instagram = other.getInstagram();
this.facebook = other.getFacebook();
this.twitter = other.getTwitter();
this.linkedin = other.getLinkedin();
this.youtube = other.getYoutube();
this.email = other.getEmail();
this.scrapingDate = other.getScrapingDate();
this.reviews = other.getReviews();
this.schedule = other.getSchedule();
}
public void obstructCompany() {
this.email = maskData(this.getEmail());
this.phoneNumber = maskData(this.getPhoneNumber());
this.instagram = maskData(this.getInstagram());
this.facebook = maskData(this.getFacebook());
this.twitter = maskData(this.getTwitter());
this.linkedin = maskData(this.getLinkedin());
this.youtube = maskData(this.getYoutube());
}
public CompanyDTO toCompanyDTO() {
return CompanyDTO.builder()
.id(this.getId())
.companyName(this.getCompanyName())
.sirenNumber(this.getSirenNumber())
.nicNumber(this.getNicNumber())
.legalForm(this.getLegalForm())
.apeCode(this.getApeCode())
.apeLabel(this.getApeLabel())
.address(this.getAddress())
.postalCode(this.getPostalCode())
.departmentNumber(this.getDepartmentNumber())
.department(this.getDepartment())
.city(this.getCity())
.region(this.getRegion())
.tradeName(this.getTradeName())
.registrationDate(this.getRegistrationDate())
.deregistrationDate(this.getDeregistrationDate())
.industrySector(this.getIndustrySector())
.reviews(this.getReviews())
.schedule(this.getSchedule())
.socialMedia(
SocialMediaDTO.builder()
.instagram(this.getInstagram())
.facebook(this.getFacebook())
.twitter(this.getTwitter())
.linkedin(this.getLinkedin())
.youtube(this.getYoutube())
.build()
)
.contact(
ContactDTO.builder()
.email(this.getEmail())
.phoneNumber(this.getPhoneNumber())
.website(this.getWebsite())
.build()
)
.scrapingDate(this.getScrapingDate())
.dateCreation(this.getDateCreation())
.lastProcessingDate(this.getLastProcessingDate())
.numberOfEmployee(this.getNumberOfEmployee())
.companyCategory(this.getCompanyCategory())
.financialPeriods(toFinancialPeriodDTOList(this))
.build();
}
}