]> git.mxchange.org Git - jfinancials-war.git/blob
b80195406c962892dcf477499e662507156898ad
[jfinancials-war.git] /
1 /*
2  * Copyright (C) 2017 Roland Häder
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License as
6  * published by the Free Software Foundation, either version 3 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Affero General Public License for more details.
13  *
14  * You should have received a copy of the GNU Affero General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.jfinancials.beans.business.branchoffice;
18
19 import java.util.ArrayList;
20 import java.util.Date;
21 import java.util.List;
22 import java.util.Objects;
23 import javax.ejb.EJB;
24 import javax.enterprise.context.SessionScoped;
25 import javax.enterprise.event.Event;
26 import javax.enterprise.inject.Any;
27 import javax.inject.Inject;
28 import javax.inject.Named;
29 import org.mxchange.jcontactsbusiness.events.branchoffice.added.BranchOfficeAddedEvent;
30 import org.mxchange.jcontactsbusiness.events.branchoffice.added.ObservableBranchOfficeAddedEvent;
31 import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeAlreadyAddedException;
32 import org.mxchange.jcontactsbusiness.model.basicdata.BusinessBasicData;
33 import org.mxchange.jcontactsbusiness.model.branchoffice.AdminBranchOfficeSessionBeanRemote;
34 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
35 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffices;
36 import org.mxchange.jcontactsbusiness.model.branchoffice.CompanyBranchOffice;
37 import org.mxchange.jcontactsbusiness.model.employee.Employee;
38 import org.mxchange.jcontactsbusiness.model.opening_time.BusinessOpeningTime;
39 import org.mxchange.jcontactsbusiness.model.opening_time.OpeningTime;
40 import org.mxchange.jcontactsbusiness.model.opening_time.dayofweek.DayOfTheWeek;
41 import org.mxchange.jcountry.model.data.Country;
42 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
43 import org.mxchange.jphone.model.phonenumbers.fax.DialableFaxNumber;
44 import org.mxchange.jphone.model.phonenumbers.fax.FaxNumber;
45 import org.mxchange.jphone.model.phonenumbers.landline.DialableLandLineNumber;
46 import org.mxchange.jphone.model.phonenumbers.landline.LandLineNumber;
47 import org.mxchange.jusercore.model.user.User;
48
49 /**
50  * An administrative bean for branch offices
51  * <p>
52  * @author Roland Häder<roland@mxchange.org>
53  */
54 @Named ("adminBranchOfficeController")
55 @SessionScoped
56 public class FinancialsAdminBranchOfficeWebRequestBean extends BaseFinancialsBean implements FinancialsAdminBranchOfficeWebRequestController {
57
58         /**
59          * Serial number
60          */
61         private static final long serialVersionUID = 5_028_697_360_461L;
62
63         /**
64          * EJB for administrative purposes
65          */
66         @EJB (lookup = "java:global/jfinancials-ejb/adminBranchOffice!org.mxchange.jcontactsbusiness.model.branchoffice.AdminBranchOfficeSessionBeanRemote")
67         private AdminBranchOfficeSessionBeanRemote adminBranchOfficeBean;
68
69         /**
70          * City
71          */
72         private String branchCity;
73
74         /**
75          * Assigned company for this branch office
76          */
77         private BusinessBasicData branchCompany;
78
79         /**
80          * Contact person in branch office
81          */
82         private Employee branchContactEmployee;
83
84         /**
85          * Country
86          */
87         private Country branchCountry;
88
89         /**
90          * Email address
91          */
92         private String branchEmailAddress;
93
94         /**
95          * House number
96          */
97         private Short branchHouseNumber;
98
99         /**
100          * Number of branch office
101          */
102         private Long branchNumber;
103
104         /**
105          * An event being fired when a branch office has been successfully added
106          */
107         @Inject
108         @Any
109         private Event<ObservableBranchOfficeAddedEvent> branchOfficeAddedEvent;
110
111         /**
112          * A general branch office controller (backing bean)
113          */
114         @Inject
115         private FinancialsBranchOfficeWebRequestController branchOfficeController;
116
117         /**
118          * Opening times of this branch office
119          */
120         private static List<OpeningTime> branchOpeningTimes;
121
122         /**
123          * Store
124          */
125         private Short branchStore;
126
127         /**
128          * Branch office street name
129          */
130         private String branchStreet;
131
132         /**
133          * Suite number
134          */
135         private Short branchSuiteNumber;
136
137         /**
138          * Owning user instance (which this branch office is assigned to)
139          */
140         private User branchUserOwner;
141
142         /**
143          * ZIP code
144          */
145         private Integer branchZipCode;
146
147         /**
148          * Area code for fax number
149          */
150         private Integer faxAreaCode;
151
152         /**
153          * Country for fax number
154          */
155         private Country faxCountry;
156
157         /**
158          * Dial number for fax number
159          */
160         private Long faxNumber;
161
162         /**
163          * Area code for land-line number
164          */
165         private Integer landLineAreaCode;
166
167         /**
168          * Country for land-line number
169          */
170         private Country landLineCountry;
171
172         /**
173          * Dial number for land-line number
174          */
175         private Long landLineNumber;
176
177         /**
178          * Ending week day
179          */
180         private DayOfTheWeek openingEndDay;
181
182         /**
183          * Ending time
184          */
185         private Date openingEndTime;
186
187         /**
188          * Starting week day
189          */
190         private DayOfTheWeek openingStartDay;
191
192         /**
193          * Starting time
194          */
195         private Date openingStartTime;
196
197         /**
198          * Default constructor
199          */
200         public FinancialsAdminBranchOfficeWebRequestBean () {
201                 // Call super constructor
202                 super();
203
204                 // Is the opening times list there?
205                 if (null == branchOpeningTimes) {
206                         // Init list
207                         branchOpeningTimes = new ArrayList<>(1);
208                 }
209         }
210
211         /**
212          * Adds branch office with all data from this backing bean. First this
213          * action method will validate if the branch office's address is already
214          * registered and if found, it will output a proper faces message.
215          * <p>
216          * @return Redirect outcome
217          */
218         public String addBranchOffice () {
219                 // Get instance
220                 final BranchOffice branchOffice = this.createBranchOffice();
221
222                 // Is the branch office not created yet?
223                 if (this.isBranchOfficeCreatedByRequiredData(branchOffice)) {
224                         // Then show proper faces message
225                         this.showFacesMessage("form-admin-add-branch-office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N
226                         return ""; //NOI18N
227                 }
228
229                 // Delcare updated instance
230                 final BranchOffice updatedOffice;
231
232                 try {
233                         // Try to call EJB
234                         updatedOffice = this.adminBranchOfficeBean.addBranchOffice(branchOffice);
235                 } catch (final BranchOfficeAlreadyAddedException ex) {
236                         // Output message
237                         this.showFacesMessage("form-admin-add-branch-office:branchStreet", "ADMIN_BRANCH_OFFICE_ALREADY_CREATED"); //NOI18N
238                         return ""; //NOI18N
239                 }
240
241                 // Fire event
242                 this.branchOfficeAddedEvent.fire(new BranchOfficeAddedEvent(updatedOffice));
243
244                 // Clear this bean
245                 this.clear();
246
247                 // Redirect to list
248                 return "admin_list_branch_office"; //NOI18N
249         }
250
251         /**
252          * Adds opening time to temporary list which will be sent along with the
253          * branch office data to the EJB.
254          */
255         public void addOpeningTime () {
256                 // Validate all required fields
257                 if (this.getOpeningEndDay() == null) {
258                         // Throw NPE
259                         throw new NullPointerException("this.openingEndDay is null"); //NOI18N
260                 } else if (this.getOpeningEndTime() == null) {
261                         // Throw NPE
262                         throw new NullPointerException("this.openingEndTime is null"); //NOI18N
263                 } else if (this.getOpeningStartDay() == null) {
264                         // Throw NPE
265                         throw new NullPointerException("this.openingStartDay is null"); //NOI18N
266                 } else if (this.getOpeningStartTime() == null) {
267                         // Throw NPE
268                         throw new NullPointerException("this.openingStartTime is null"); //NOI18N
269                 }
270
271                 // Get opening time instance
272                 final OpeningTime openingTime = this.createOpeningTimes();
273
274                 // Is same found?
275                 if (this.isSameOpeningTimeFound(openingTime)) {
276                         // Yes then abort here
277                         this.showFacesMessage("form-admin-add-branch-opening-time:openingStartDay", "ADMIN_OPENING_TIME_ALREADY_CREATED"); //NOI18N
278                         return;
279                 }
280
281                 // Add to temporary list
282                 branchOpeningTimes.add(openingTime);
283
284                 // Clear opening time fields
285                 this.clearOpeningTime();
286         }
287
288         /**
289          * Getter for city
290          * <p>
291          * @return City
292          */
293         public String getBranchCity () {
294                 return this.branchCity;
295         }
296
297         /**
298          * Setter for city
299          * <p>
300          * @param branchCity City
301          */
302         public void setBranchCity (final String branchCity) {
303                 this.branchCity = branchCity;
304         }
305
306         /**
307          * Getter for basic company data
308          * <p>
309          * @return Basic company data
310          */
311         public BusinessBasicData getBranchCompany () {
312                 return this.branchCompany;
313         }
314
315         /**
316          * Setter for basic company data
317          * <p>
318          * @param branchCompany Basic company data
319          */
320         public void setBranchCompany (final BusinessBasicData branchCompany) {
321                 this.branchCompany = branchCompany;
322         }
323
324         /**
325          * Getter for branch office contact person
326          * <p>
327          * @return Branch office contact person
328          */
329         public Employee getBranchContactEmployee () {
330                 return this.branchContactEmployee;
331         }
332
333         /**
334          * Setter for branch office contact person
335          * <p>
336          * @param branchContactEmployee Branch office contact person
337          */
338         public void setBranchContactEmployee (final Employee branchContactEmployee) {
339                 this.branchContactEmployee = branchContactEmployee;
340         }
341
342         /**
343          * Getter for country
344          * <p>
345          * @return Country
346          */
347         public Country getBranchCountry () {
348                 return this.branchCountry;
349         }
350
351         /**
352          * Setter for country
353          * <p>
354          * @param branchCountry Country
355          */
356         public void setBranchCountry (final Country branchCountry) {
357                 this.branchCountry = branchCountry;
358         }
359
360         /**
361          * Getter for email address
362          * <p>
363          * @return Email address
364          */
365         public String getBranchEmailAddress () {
366                 return this.branchEmailAddress;
367         }
368
369         /**
370          * Getter for email address
371          * <p>
372          * @param branchEmailAddress Email address
373          */
374         public void setBranchEmailAddress (final String branchEmailAddress) {
375                 this.branchEmailAddress = branchEmailAddress;
376         }
377
378         /**
379          * Getter for house number
380          * <p>
381          * @return House number
382          */
383         public Short getBranchHouseNumber () {
384                 return this.branchHouseNumber;
385         }
386
387         /**
388          * Setter for house number
389          * <p>
390          * @param branchHouseNumber House number
391          */
392         public void setBranchHouseNumber (final Short branchHouseNumber) {
393                 this.branchHouseNumber = branchHouseNumber;
394         }
395
396         /**
397          * Getter for branch office number
398          * <p>
399          * @return Branch office number
400          */
401         public Long getBranchNumber () {
402                 return this.branchNumber;
403         }
404
405         /**
406          * Setter for branch office number
407          * <p>
408          * @param branchNumber Branch office number
409          */
410         public void setBranchNumber (final Long branchNumber) {
411                 this.branchNumber = branchNumber;
412         }
413
414         /**
415          * Getter for opening times of this branch office
416          * <p>
417          * @return Opening times
418          */
419         @SuppressWarnings ("ReturnOfCollectionOrArrayField")
420         public List<OpeningTime> getBranchOpeningTimes () {
421                 return branchOpeningTimes;
422         }
423
424         /**
425          * Setter for opening times of this branch office
426          * <p>
427          * @param branchOpeningTimes Opening times
428          */
429         @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
430         public void setBranchOpeningTimes (final List<OpeningTime> branchOpeningTimes) {
431                 FinancialsAdminBranchOfficeWebRequestBean.branchOpeningTimes = branchOpeningTimes;
432         }
433
434         /**
435          * Getter for store
436          * <p>
437          * @return Store
438          */
439         public Short getBranchStore () {
440                 return this.branchStore;
441         }
442
443         /**
444          * Setter for store
445          * <p>
446          * @param branchStore Store
447          */
448         public void setBranchStore (final Short branchStore) {
449                 this.branchStore = branchStore;
450         }
451
452         /**
453          * Getter for street name
454          * <p>
455          * @return Street name
456          */
457         public String getBranchStreet () {
458                 return this.branchStreet;
459         }
460
461         /**
462          * Setter for street name
463          * <p>
464          * @param branchStreet Street name
465          */
466         public void setBranchStreet (final String branchStreet) {
467                 this.branchStreet = branchStreet;
468         }
469
470         /**
471          * Getter for suite number
472          * <p>
473          * @return Suite number
474          */
475         public Short getBranchSuiteNumber () {
476                 return this.branchSuiteNumber;
477         }
478
479         /**
480          * Setter for suite number
481          * <p>
482          * @param branchSuiteNumber Suite number
483          */
484         public void setBranchSuiteNumber (final Short branchSuiteNumber) {
485                 this.branchSuiteNumber = branchSuiteNumber;
486         }
487
488         /**
489          * Getter for owning user instance
490          * <p>
491          * @return Owning user instance
492          */
493         public User getBranchUserOwner () {
494                 return this.branchUserOwner;
495         }
496
497         /**
498          * Setter for owning user instance
499          * <p>
500          * @param branchUserOwner Owning user instance
501          */
502         public void setBranchUserOwner (final User branchUserOwner) {
503                 this.branchUserOwner = branchUserOwner;
504         }
505
506         /**
507          * Getter for ZIP code\
508          * <p>
509          * @return ZIP code
510          */
511         public Integer getBranchZipCode () {
512                 return this.branchZipCode;
513         }
514
515         /**
516          * Setter for ZIP code\
517          * <p>
518          * @param branchZipCode ZIP code
519          */
520         public void setBranchZipCode (final Integer branchZipCode) {
521                 this.branchZipCode = branchZipCode;
522         }
523
524         /**
525          * Getter for fax number's area code
526          * <p>
527          * @return Fax number's area code
528          */
529         public Integer getFaxAreaCode () {
530                 return this.faxAreaCode;
531         }
532
533         /**
534          * Setter for fax number's area code
535          * <p>
536          * @param faxAreaCode Fax number's area code
537          */
538         public void setFaxAreaCode (final Integer faxAreaCode) {
539                 this.faxAreaCode = faxAreaCode;
540         }
541
542         /**
543          * Getter for fax's country instance
544          * <p>
545          * @return Fax' country instance
546          */
547         public Country getFaxCountry () {
548                 return this.faxCountry;
549         }
550
551         /**
552          * Setter for fax's country instance
553          * <p>
554          * @param faxCountry Fax' country instance
555          */
556         public void setFaxCountry (final Country faxCountry) {
557                 this.faxCountry = faxCountry;
558         }
559
560         /**
561          * Getter for fax number
562          * <p>
563          * @return Fax number
564          */
565         public Long getFaxNumber () {
566                 return this.faxNumber;
567         }
568
569         /**
570          * Setter for fax number
571          * <p>
572          * @param faxNumber Fax number
573          */
574         public void setFaxNumber (final Long faxNumber) {
575                 this.faxNumber = faxNumber;
576         }
577
578         /**
579          * Getter for land-line number's area code
580          * <p>
581          * @return Land-line number's area code
582          */
583         public Integer getLandLineAreaCode () {
584                 return this.landLineAreaCode;
585         }
586
587         /**
588          * Setter for land-line number's area code
589          * <p>
590          * @param landLineAreaCode Land-line number's area code
591          */
592         public void setLandLineAreaCode (final Integer landLineAreaCode) {
593                 this.landLineAreaCode = landLineAreaCode;
594         }
595
596         /**
597          * Getter for land-line number's country instance
598          * <p>
599          * @return Land-line number's country instance
600          */
601         public Country getLandLineCountry () {
602                 return this.landLineCountry;
603         }
604
605         /**
606          * Setter for land-line number's country instance
607          * <p>
608          * @param landLineCountry Land-line number's country instance
609          */
610         public void setLandLineCountry (final Country landLineCountry) {
611                 this.landLineCountry = landLineCountry;
612         }
613
614         /**
615          * Getter for land-line number
616          * <p>
617          * @return Land-line number
618          */
619         public Long getLandLineNumber () {
620                 return this.landLineNumber;
621         }
622
623         /**
624          * Setter for land-line number
625          * <p>
626          * @param landLineNumber Land-line number
627          */
628         public void setLandLineNumber (final Long landLineNumber) {
629                 this.landLineNumber = landLineNumber;
630         }
631
632         /**
633          * Getter for ending week day
634          * <p>
635          * @return Ending week day
636          */
637         public DayOfTheWeek getOpeningEndDay () {
638                 return this.openingEndDay;
639         }
640
641         /**
642          * Setter for ending week day
643          * <p>
644          * @param openingEndDay Ending week day
645          */
646         public void setOpeningEndDay (final DayOfTheWeek openingEndDay) {
647                 this.openingEndDay = openingEndDay;
648         }
649
650         /**
651          * Getter for ending time
652          * <p>
653          * @return Ending time
654          */
655         @SuppressWarnings ("ReturnOfDateField")
656         public Date getOpeningEndTime () {
657                 return this.openingEndTime;
658         }
659
660         /**
661          * Getter for ending time
662          * <p>
663          * @param openingEndTime Ending time
664          */
665         @SuppressWarnings ("AssignmentToDateFieldFromParameter")
666         public void setOpeningEndTime (final Date openingEndTime) {
667                 this.openingEndTime = openingEndTime;
668         }
669
670         /**
671          * Getter for starting week day
672          * <p>
673          * @return Starting week day
674          */
675         public DayOfTheWeek getOpeningStartDay () {
676                 return this.openingStartDay;
677         }
678
679         /**
680          * Getter for starting week day
681          * <p>
682          * @param openingStartDay Starting week day
683          */
684         public void setOpeningStartDay (final DayOfTheWeek openingStartDay) {
685                 this.openingStartDay = openingStartDay;
686         }
687
688         /**
689          * Getter for starting time
690          * <p>
691          * @return Starting time
692          */
693         @SuppressWarnings ("ReturnOfDateField")
694         public Date getOpeningStartTime () {
695                 return this.openingStartTime;
696         }
697
698         /**
699          * Getter for starting time
700          * <p>
701          * @param openingStartTime Starting time
702          */
703         @SuppressWarnings ("AssignmentToDateFieldFromParameter")
704         public void setOpeningStartTime (final Date openingStartTime) {
705                 this.openingStartTime = openingStartTime;
706         }
707
708         /**
709          * Clears this bean data
710          */
711         private void clear () {
712                 // Clear all branch office data
713                 this.setBranchCity(null);
714                 this.setBranchCompany(null);
715                 this.setBranchContactEmployee(null);
716                 this.setBranchCountry(null);
717                 this.setBranchEmailAddress(null);
718                 this.setBranchHouseNumber(null);
719                 this.setBranchNumber(null);
720                 this.setBranchStore(null);
721                 this.setBranchStreet(null);
722                 this.setBranchSuiteNumber(null);
723                 this.setBranchUserOwner(null);
724                 this.setBranchZipCode(null);
725                 this.setBranchOpeningTimes(null);
726
727                 // Extra-clear opening time
728                 this.clearOpeningTime();
729         }
730
731         /**
732          * Clears all opening time fields
733          */
734         private void clearOpeningTime () {
735                 // Clear all opening time fields
736                 this.setOpeningEndDay(null);
737                 this.setOpeningEndTime(null);
738                 this.setOpeningStartDay(null);
739                 this.setOpeningStartTime(null);
740         }
741
742         /**
743          * Prepares an instance of a BranchOffice object (entity) with all data from
744          * this bean. If a complete fax number or land-line number was provided, it
745          * will be set in the instance as well.
746          * <p>
747          * @return An instance of a BranchOffice class (entity)
748          */
749         private BranchOffice createBranchOffice () {
750                 // Create new branch office instance
751                 final BranchOffice branchOffice = new CompanyBranchOffice(this.getBranchCity(), this.getBranchCompany(), this.getBranchCountry(), this.getBranchStreet(), this.getBranchZipCode(), this.getBranchHouseNumber());
752
753                 // Add all other fields, too
754                 branchOffice.setBranchContactEmployee(this.getBranchContactEmployee());
755                 branchOffice.setBranchEmailAddress(this.getBranchEmailAddress());
756                 branchOffice.setBranchNumber(this.getBranchNumber());
757                 branchOffice.setBranchStore(this.getBranchStore());
758                 branchOffice.setBranchSuiteNumber(this.getBranchSuiteNumber());
759                 branchOffice.setBranchUserOwner(this.getBranchUserOwner());
760
761                 // Generate phone number
762                 final DialableLandLineNumber landLine = new LandLineNumber(this.getLandLineCountry(), this.getLandLineAreaCode(), this.getLandLineNumber());
763                 final DialableFaxNumber fax = new FaxNumber(this.getFaxCountry(), this.getFaxAreaCode(), this.getFaxNumber());
764
765                 // Don't set null or wrong references
766                 if ((landLine instanceof DialableLandLineNumber) && (landLine.getPhoneCountry() instanceof Country) && (this.getLandLineAreaCode() != null) && (this.getLandLineNumber() != null) && (this.getLandLineAreaCode() > 0) && (this.getLandLineNumber() > 0)) {
767                         // Now the number must be given
768                         if (landLine.getPhoneAreaCode() == null) {
769                                 // Is null
770                                 throw new NullPointerException("phone.phoneAreaCode is null"); //NOI18N
771                         } else if (landLine.getPhoneAreaCode() < 1) {
772                                 // Abort here
773                                 throw new IllegalArgumentException("phone.phoneAreaCode is zero or below."); //NOI18N
774                         } else if (landLine.getPhoneNumber() == null) {
775                                 // Is null
776                                 throw new NullPointerException("phone.phoneNumber is null"); //NOI18N
777                         } else if (landLine.getPhoneNumber() < 1) {
778                                 // Abort here
779                                 throw new IllegalArgumentException("phone.phoneNumber is zero or below."); //NOI18N
780                         }
781
782                         // Set phone number
783                         branchOffice.setBranchLandLineNumber(landLine);
784                 }
785
786                 // Don't set null or wrong references
787                 if ((fax instanceof DialableFaxNumber) && (fax.getPhoneCountry() instanceof Country) && (this.getFaxAreaCode() != null) && (this.getFaxNumber() != null) && (this.getFaxAreaCode() > 0) && (this.getFaxNumber() > 0)) {
788                         // Now the number must be given
789                         if (fax.getPhoneAreaCode() == null) {
790                                 // Is null
791                                 throw new NullPointerException("fax.phoneAreaCode is null"); //NOI18N
792                         } else if (fax.getPhoneAreaCode() < 1) {
793                                 // Abort here
794                                 throw new IllegalArgumentException("fax.phoneAreaCode is zero or below."); //NOI18N
795                         } else if (fax.getPhoneNumber() == null) {
796                                 // Is null
797                                 throw new NullPointerException("fax.phoneNumber is null"); //NOI18N
798                         } else if (fax.getPhoneNumber() < 1) {
799                                 // Abort here
800                                 throw new IllegalArgumentException("fax.phoneNumber is zero or below."); //NOI18N
801                         }
802
803                         // Set fax number
804                         branchOffice.setBranchFaxNumber(fax);
805                 }
806                 // Is the opening times list filled?
807                 if (!this.getBranchOpeningTimes().isEmpty()) {
808                         // Yes, then set in branch office, too
809                         branchOffice.setBranchOpeningTimes(this.getBranchOpeningTimes());
810                 }
811
812                 // Return fully prepared instance
813                 return branchOffice;
814         }
815
816         /**
817          * Prepares an instance of a OpeningTimes object (entity) with all data from
818          * this bean. If a complete fax number or land-line number was provided, it
819          * will be set in the instance as well.
820          * <p>
821          * @return An instance of a OpeningTimes class (entity)
822          */
823         private OpeningTime createOpeningTimes () {
824                 // Create new openingTime instance
825                 final OpeningTime openingTime = new BusinessOpeningTime(this.getOpeningEndDay(), this.getOpeningEndTime(), this.getOpeningStartDay(), this.getOpeningStartTime());
826
827                 // Return fully prepared instance
828                 return openingTime;
829         }
830
831         /**
832          * Checks whether the given branch office's address is already found in
833          * local cache. Please note that this method fully relies on the cache, so
834          * you must always fire proper events that add/update/delete entries in
835          * cache.
836          * <p>
837          * @param branchOffice Branch office to check it's address
838          * <p>
839          * @return Whether the address has been found
840          */
841         private boolean isBranchOfficeCreatedByRequiredData (final BranchOffice branchOffice) {
842                 // Get full list from other bean
843                 final List<BranchOffice> branchOffices = this.branchOfficeController.allBranchOffices();
844
845                 // Default is not found
846                 boolean isFound = false;
847
848                 // Now check each entry
849                 for (final BranchOffice bo : branchOffices) {
850                         // Is same address?
851                         if (BranchOffices.isSameAddress(bo, branchOffice)) {
852                                 // Found one
853                                 isFound = true;
854                                 break;
855                         }
856                 }
857
858                 // Return flag
859                 return isFound;
860         }
861
862         /**
863          * Checks if given opening time is already added
864          * <p>
865          * @param openingTime Opening time to be checked
866          * <p>
867          * @return Whether it has been added already
868          */
869         private boolean isSameOpeningTimeFound (final OpeningTime openingTime) {
870                 // Default is not found
871                 boolean isFound = false;
872
873                 // Loop through list
874                 for (final OpeningTime ot : this.getBranchOpeningTimes()) {
875                         // Check it
876                         if (Objects.equals(ot, openingTime)) {
877                                 // Found same match
878                                 isFound = true;
879                                 break;
880                         }
881                 }
882
883                 // Return it
884                 return isFound;
885         }
886
887 }