001package org.kuali.ole.deliver.api;
002
003import org.kuali.rice.kim.api.identity.address.EntityAddressContract;
004import org.kuali.rice.kim.api.identity.email.EntityEmailContract;
005import org.kuali.rice.kim.api.identity.entity.Entity;
006import org.kuali.rice.kim.api.identity.entity.EntityContract;
007import org.kuali.rice.kim.api.identity.name.EntityName;
008import org.kuali.rice.kim.api.identity.name.EntityNameContract;
009import org.kuali.rice.kim.api.identity.phone.EntityPhoneContract;
010import org.kuali.rice.kim.api.identity.type.EntityTypeContactInfo;
011
012import java.sql.Timestamp;
013import java.util.Arrays;
014import java.util.Date;
015import java.util.List;
016import java.util.UUID;
017
018/**
019 * Created with IntelliJ IDEA.
020 * User: pvsubrah
021 * Date: 5/31/12
022 * Time: 12:11 PM
023 * To change this template use File | Settings | File Templates.
024 */
025public class OlePatronDefintionHelper {
026
027    private static final String PATRON_ID = "P1001";
028    private static final String BARCODE = "1234";
029    private static final Date EXPIRATION_DATE =new java.sql.Date((new Timestamp(System.currentTimeMillis())).getTime());
030    private static final Date ACTIVATION_DATE =new java.sql.Date((new Timestamp(System.currentTimeMillis())).getTime());
031
032    private static final boolean GENERAL_BLOCK = true;
033    private static final String PATRON_GENERAL_BLOCK_NOTES ="General Block notes";
034    private static final boolean DELIVERY_PRIVILEGE = true;
035    private static final boolean COURTESY_NOTICE = true;
036    private static final boolean PAGING_PRIVILEGE = true;
037    private static final boolean ACTIVE = true;
038    private static final Long VERSION_NUMBER = new Long(1);
039    private static final String OBJECT_ID = String.valueOf(UUID.randomUUID());
040
041    private static final EntityTypeContactInfo ENTITY_TYPE_CONTACT = EntityTypeContactInfoHelper.create();
042    private static final Entity ENTITY = EntityHelper.create();
043    private static final EntityName ENTITY_NAME = EntityNameHelper.create();
044
045    private static final String BORROWER_ID = "7" ;
046    private static final String BORR_CODE = "UGRAD";
047    private static final String BORR_NAME = "UnderGrad";
048    private static final String BORR_DESC = "UnderGrad";
049    private static final Long BORR_VERSION_NUMBER = new Long(1);
050    private static final String BORR_OBJECT_ID = String.valueOf(UUID.randomUUID());
051
052    private static final String PATRON_NOTE_ID="P2";
053    private static final String PATRON_NOTE_TEXT="Patron Test";
054    private static final String PATRON_NOTE_TYPE_ID="2";
055    private static final String PATRON_NOTE_TYPE_NAME="Note Test";
056    private static final String PATRON_NOTE_TYPE_CODE="NT";
057    private static final Long NOTE_VERSION_NUMBER = new Long(1);
058    private static final String NOTE_OBJECT_ID = String.valueOf(UUID.randomUUID());
059
060    private static final String PROXY_PATRON_ID="P1002";
061    private static final String PROXY_PATRON_DOC_ID = "11";
062    private static final Date PROXY_EXPIRATION_DATE =new java.sql.Date((new Timestamp(System.currentTimeMillis())).getTime());
063    private static final Date PROXY_ACTIVATION_DATE =new java.sql.Date((new Timestamp(System.currentTimeMillis())).getTime());
064    private static final Long PROXY_VERSION_NUMBER = new Long(1);
065    private static final OlePatronDefinition OLE_PATRON = OlePatronDefintionHelper.create();
066    private static final String PROXY_OBJECT_ID = String.valueOf(UUID.randomUUID());
067
068    private static final String PATRON_ADDRESS_ID = "1";
069    private static final boolean PATRON_ADDRESS_VERIFIED = true;
070    private static final boolean DELIVER_ADDRESS = true;
071    private static final Date PATRON_ADDRESS_VALID_FROM = new java.sql.Date((new Timestamp(System.currentTimeMillis())).getTime());
072    private static final Date PATRON_ADDRESS_VALID_TO = new java.sql.Date((new Timestamp(System.currentTimeMillis())).getTime());
073    private static final Long PATRON_ADDRESS_VERSION_NUMBER = new Long(1);
074    private static final String PATRON_ADDRESS_OBJECT_ID = String.valueOf(UUID.randomUUID());
075
076    private static final String PATRON_ADDRESS_SOURCE_ID = "1";
077    private static final String PATRON_ADDRESS_SOURCE_CODE = "REG";
078    private static final String PATRON_ADDRESS_SOURCE_NAME = "Registrar";
079    private static final String PATRON_ADDRESS_SOURCE_DESC = "Registrar";
080    private static final Long PATRON_ADDRESS_SOURCE_VERSION_NUMBER = new Long(1);
081    private static final String PATRON_ADDRESS_SOURCE_OBJECT_ID = String.valueOf(UUID.randomUUID());
082
083    private static final String PATRON_SOURCE_ID = "1";
084    private static final String PATRON_SOURCE_CODE = "HR";
085    private static final String PATRON_SOURCE_NAME = "Human Resource";
086    private static final String PATRON_SOURCE_DESC = "Human Resource";
087    private static final Long PATRON_SOURCE_VERSION_NUMBER = new Long(1);
088    private static final String PATRON_SOURCE_OBJECT_ID = String.valueOf(UUID.randomUUID());
089
090    private static final String PATRON_STATISTICAL_CATEGORY_ID = "1";
091    private static final String PATRON_STATISTICAL_CATEGORY_CODE = "REG";
092    private static final String PATRON_STATISTICAL_CATEGORY_NAME = "Registrar";
093    private static final String PATRON_STATISTICAL_CATEGORY_DESC = "Registrar";
094    private static final Long PATRON_STATISTICAL_CATEGORY_VERSION_NUMBER = new Long(1);
095    private static final String PATRON_STATISTICAL_CATEGORY_OBJECT_ID = String.valueOf(UUID.randomUUID());
096
097    private static final String PATRON_LOST_BARCODE_ID = "P11";
098    private static final String PATRON_LOST_BARCODE = "222222";
099    private static final Date  PATRON_LOST_BARCODE_EFF_DATE= new java.sql.Date((new Timestamp(System.currentTimeMillis())).getTime());
100    private static final Long PATRON_LOST_BARCODE_VERSION_NUMBER = new Long(1);
101
102    private static final String PATRON_LOCAL_SEQ_ID = "P10";
103    private static final String LOCAL_ID = "222222";
104    private static final Long PATRON_LOCAL_ID_VERSION_NUMBER = new Long(1);
105    private static final String PATRON_LOCAL_ID_OBJECT_ID = String.valueOf(UUID.randomUUID());
106
107    public static OlePatronDefinition create() {
108        return OlePatronDefinition.Builder.create(new OlePatronContract() {
109            @Override
110            public String getOlePatronId() {
111                return PATRON_ID;
112            }
113
114            @Override
115            public String getBarcode() {
116                return BARCODE;
117            }
118
119            @Override
120            public String getBorrowerType() {
121                return BORROWER_ID ;
122            }
123
124            @Override
125            public boolean isGeneralBlock() {
126                return GENERAL_BLOCK;
127            }
128
129            @Override
130            public boolean isPagingPrivilege() {
131                return PAGING_PRIVILEGE;
132            }
133
134            @Override
135            public boolean isCourtesyNotice() {
136                return COURTESY_NOTICE;
137            }
138
139            @Override
140            public boolean isDeliveryPrivilege() {
141                return DELIVERY_PRIVILEGE;
142            }
143
144            @Override
145            public Date getExpirationDate() {
146                return EXPIRATION_DATE;
147            }
148
149            @Override
150            public Date getActivationDate() {
151                return ACTIVATION_DATE;
152            }
153
154            @Override
155            public List<? extends EntityAddressContract> getAddresses() {
156                return ENTITY_TYPE_CONTACT.getAddresses();
157            }
158
159            @Override
160            public List<? extends EntityEmailContract> getEmails() {
161                return ENTITY_TYPE_CONTACT.getEmailAddresses();
162            }
163
164            @Override
165            public EntityNameContract getName() {
166                return ENTITY_NAME;
167            }
168
169            @Override
170            public List<? extends EntityPhoneContract> getPhones() {
171                return ENTITY_TYPE_CONTACT.getPhoneNumbers();
172            }
173
174            @Override
175            public EntityContract getEntity() {
176                return ENTITY;
177            }
178
179            @Override
180            public boolean isActiveIndicator() {
181                return ACTIVE;
182            }
183
184            @Override
185            public List<? extends OlePatronNotesContract> getNotes() {
186                return Arrays.asList(OlePatronNotesDefinition.Builder.create(new OlePatronNotesContract() {
187                    @Override
188                    public String getObjectId() {
189                        return NOTE_OBJECT_ID;
190                    }
191
192                    @Override
193                    public String getPatronNoteId() {
194                        return PATRON_NOTE_ID;
195                    }
196
197                    @Override
198                    public String getOlePatronId() {
199                        return PATRON_ID;
200                    }
201
202                    @Override
203                    public String getPatronNoteText() {
204                        return PATRON_NOTE_TEXT;
205                    }
206
207                    @Override
208                    public OlePatronNoteTypeContract getOlePatronNoteType() {
209                        return OlePatronNoteTypeDefinition.Builder.create(new OlePatronNoteTypeContract() {
210                            @Override
211                            public String getPatronNoteTypeId() {
212                                return PATRON_NOTE_TYPE_ID;
213                            }
214
215                            @Override
216                            public String getPatronNoteTypeCode() {
217                                return PATRON_NOTE_TYPE_CODE;
218                            }
219
220                            @Override
221                            public String getPatronNoteTypeName() {
222                                return PATRON_NOTE_TYPE_NAME;
223                            }
224
225                            @Override
226                            public String getId() {
227                                return PATRON_NOTE_TYPE_ID;
228                            }
229
230                            @Override
231                            public boolean isActive() {
232                                return ACTIVE;
233                            }
234
235                        }).build();
236                    }
237
238
239                    @Override
240                    public String getId() {
241                        return PATRON_NOTE_ID;
242                    }
243
244                    @Override
245                    public Long getVersionNumber() {
246                        return NOTE_VERSION_NUMBER;
247                    }
248
249                    @Override
250                    public boolean isActive() {
251                        return ACTIVE;
252                    }
253                }).build());
254            }
255
256            @Override
257            public List<? extends OleEntityAddressContract> getOleEntityAddressBo() {
258                return Arrays.asList(OleEntityAddressDefinition.Builder.create(new OleEntityAddressContract() {
259
260                    @Override
261                    public OleAddressContract getOleAddressBo() {
262                        return OleAddressDefinition.Builder.create(new OleAddressContract() {
263
264
265                            @Override
266                            public String getOleAddressId() {
267                                return PATRON_ADDRESS_ID;
268                            }
269
270                            @Override
271                            public boolean isAddressVerified() {
272                                return PATRON_ADDRESS_VERIFIED;
273                            }
274
275                            @Override
276                            public String getOlePatronId() {
277                                return PATRON_ID;
278                            }
279
280                            @Override
281                            public String getId() {
282                                return PATRON_ADDRESS_ID;
283                            }
284
285                            @Override
286                            public Date getAddressValidFrom() {
287                                return PATRON_ADDRESS_VALID_FROM;
288                            }
289
290                            @Override
291                            public Date getAddressValidTo() {
292                                return PATRON_ADDRESS_VALID_TO;
293                            }
294
295                            @Override
296                            public String getAddressSource() {
297                                return PATRON_ADDRESS_SOURCE_ID;
298                            }
299                            @Override
300                            public boolean isDeliverAddress(){ return PATRON_ADDRESS_VERIFIED; }
301
302                            @Override
303                            public OleAddressSourceContract getAddressSourceBo() {
304                                return OleAddressSourceDefinition.Builder.create(new OleAddressSourceContract() {
305
306
307                                    @Override
308                                    public String getId() {
309                                        return PATRON_ADDRESS_SOURCE_ID;
310                                    }
311
312                                    @Override
313                                    public String getOleAddressSourceId() {
314                                        return PATRON_ADDRESS_SOURCE_ID;
315                                    }
316
317                                    @Override
318                                    public String getOleAddressSourceCode() {
319                                        return PATRON_ADDRESS_SOURCE_CODE;
320                                    }
321
322                                    @Override
323                                    public String getOleAddressSourceName() {
324                                        return PATRON_ADDRESS_SOURCE_NAME;
325                                    }
326
327                                    @Override
328                                    public String getOleAddressSourceDesc() {
329                                        return PATRON_ADDRESS_SOURCE_DESC;
330                                    }
331
332                                    @Override
333                                    public boolean isActive() {
334                                        return ACTIVE;
335                                    }
336
337                                    @Override
338                                    public Long getVersionNumber() {
339                                        return PATRON_ADDRESS_SOURCE_VERSION_NUMBER;
340                                    }
341                                }).build();
342                            }
343
344                           /* @Override
345                            public EntityAddressContract getEntityAddress() {
346                                return ENTITY_TYPE_CONTACT.getAddresses().get(0);
347                            }
348*/
349                            @Override
350                            public Long getVersionNumber() {
351                                return PATRON_ADDRESS_VERSION_NUMBER;
352                            }
353                        }).build();
354                    }
355                    @Override
356                    public EntityAddressContract getEntityAddressBo() {
357                        return ENTITY_TYPE_CONTACT.getAddresses().get(0);
358                    }
359
360                }).build());
361            }
362
363
364
365            @Override
366            public List<? extends OlePatronAffiliationContract> getPatronAffiliations() {
367                return null;  //To change body of implemented methods use File | Settings | File Templates.
368            }
369
370            @Override
371            public List<? extends OleProxyPatronContract> getOleProxyPatronDocuments() {
372                return Arrays.asList(OleProxyPatronDefinition.Builder.create(new OleProxyPatronContract() {
373
374                    @Override
375                    public String getOleProxyPatronDocumentId() {
376                        return PROXY_PATRON_DOC_ID;
377                    }
378
379                    @Override
380                    public String getProxyPatronId() {
381                        return PROXY_PATRON_ID;
382                    }
383
384                    @Override
385                    public String getOlePatronId() {
386                        return PATRON_ID;
387                    }
388/*
389                    @Override
390                    public OlePatronContract getOlePatronDocument() {
391                        return OLE_PATRON;
392                    }*/
393
394                    @Override
395                    public Date getProxyPatronExpirationDate() {
396                        return PROXY_EXPIRATION_DATE;
397                    }
398
399                    @Override
400                    public Date getProxyPatronActivationDate() {
401                        return PROXY_ACTIVATION_DATE;
402                    }
403
404                    @Override
405                    public boolean isActive() {
406                        return ACTIVE;
407                    }
408
409                    @Override
410                    public String getId() {
411                        return PROXY_PATRON_DOC_ID;
412                    }
413
414                    @Override
415                    public Long getVersionNumber() {
416                        return PROXY_VERSION_NUMBER;
417                    }
418                }).build());
419            }
420
421           /* @Override
422            public List<? extends OlePatronContract> getOlePatronDocuments() {
423                return null;
424            }*/
425
426            @Override
427            public List<? extends OlePatronLostBarcodeContract> getLostBarcodes() {
428                return Arrays.asList(OlePatronLostBarcodeDefinition.Builder.create(new OlePatronLostBarcodeContract() {
429
430                    @Override
431                    public String getOlePatronLostBarcodeId() {
432                        return PATRON_LOST_BARCODE_ID;
433                    }
434
435                    @Override
436                    public String getOlePatronId() {
437                        return PATRON_ID;
438                    }
439
440                    @Override
441                    public Date getInvalidOrLostBarcodeEffDate() {
442                        return PATRON_LOST_BARCODE_EFF_DATE;
443                    }
444
445                    @Override
446                    public String getInvalidOrLostBarcodeNumber() {
447                        return PATRON_LOST_BARCODE;
448                    }
449
450                    @Override
451                    public String getObjectId() {
452                        return NOTE_OBJECT_ID;
453                    }
454
455                    @Override
456                    public String getId() {
457                        return PATRON_LOST_BARCODE_ID;
458                    }
459
460                    @Override
461                    public Long getVersionNumber() {
462                        return PATRON_LOST_BARCODE_VERSION_NUMBER;
463                    }
464                }).build());
465            }
466
467            @Override
468            public String getGeneralBlockNotes() {
469                return PATRON_GENERAL_BLOCK_NOTES;
470            }
471
472            @Override
473            public String getSource() {
474                return PATRON_SOURCE_ID;
475            }
476
477            @Override
478            public String getStatisticalCategory() {
479                return PATRON_STATISTICAL_CATEGORY_ID;
480            }
481
482            @Override
483            public List<? extends OleAddressContract> getOleAddresses() {
484
485                    return Arrays.asList(OleAddressDefinition.Builder.create(new OleAddressContract() {
486
487
488                        @Override
489                        public String getOleAddressId() {
490                            return PATRON_ADDRESS_ID;
491                        }
492
493                        @Override
494                        public boolean isAddressVerified() {
495                            return PATRON_ADDRESS_VERIFIED;
496                        }
497
498                        @Override
499                        public String getOlePatronId() {
500                            return PATRON_ID;
501                        }
502
503                        @Override
504                        public String getId() {
505                            return PATRON_ADDRESS_ID;
506                        }
507
508                        @Override
509                        public Date getAddressValidFrom() {
510                            return PATRON_ADDRESS_VALID_FROM;
511                        }
512
513                        @Override
514                        public Date getAddressValidTo() {
515                            return PATRON_ADDRESS_VALID_TO;
516                        }
517
518                        @Override
519                        public String getAddressSource() {
520                            return PATRON_ADDRESS_SOURCE_ID;
521                        }
522
523                        @Override
524                        public OleAddressSourceContract getAddressSourceBo() {
525                            return OleAddressSourceDefinition.Builder.create(new OleAddressSourceContract() {
526
527
528                                @Override
529                                public String getId() {
530                                    return PATRON_ADDRESS_SOURCE_ID;
531                                }
532
533                                @Override
534                                public String getOleAddressSourceId() {
535                                    return PATRON_ADDRESS_SOURCE_ID;
536                                }
537
538                                @Override
539                                public String getOleAddressSourceCode() {
540                                    return PATRON_ADDRESS_SOURCE_CODE;
541                                }
542
543                                @Override
544                                public String getOleAddressSourceName() {
545                                    return PATRON_ADDRESS_SOURCE_NAME;
546                                }
547
548                                @Override
549                                public String getOleAddressSourceDesc() {
550                                    return PATRON_ADDRESS_SOURCE_DESC;
551                                }
552
553                                @Override
554                                public boolean isActive() {
555                                    return ACTIVE;
556                                }
557
558                                @Override
559                                public Long getVersionNumber() {
560                                    return PATRON_ADDRESS_SOURCE_VERSION_NUMBER;
561                                }
562                            }).build();
563                        }
564
565                        @Override
566                        public boolean isDeliverAddress() {
567                            return DELIVER_ADDRESS;
568                        }
569
570                       /* @Override
571                        public EntityAddressContract getEntityAddress() {
572                            return ENTITY_TYPE_CONTACT.getAddresses().get(0);
573                        }*/
574
575                        @Override
576                        public Long getVersionNumber() {
577                            return PATRON_ADDRESS_VERSION_NUMBER;
578                        }
579                    }).build());
580            }
581
582            @Override
583            public List<? extends OlePatronLocalIdentificationContract> getOlePatronLocalIds() {
584                return Arrays.asList(OlePatronLocalIdentificationDefinition.Builder.create(new OlePatronLocalIdentificationContract() {
585
586                    @Override
587                    public String getPatronLocalSeqId() {
588                        return PATRON_LOCAL_SEQ_ID;
589                    }
590
591                    @Override
592                    public String getLocalId() {
593                        return LOCAL_ID;
594                    }
595
596                    @Override
597                    public String getOlePatronId() {
598                        return PATRON_ID;
599                    }
600
601                    @Override
602                    public String getObjectId() {
603                        return PATRON_LOCAL_ID_OBJECT_ID;
604                    }
605
606                    @Override
607                    public String getId() {
608                        return PATRON_LOCAL_SEQ_ID;
609                    }
610
611                    @Override
612                    public Long getVersionNumber() {
613                        return PATRON_LOCAL_ID_VERSION_NUMBER;
614                    }
615                }).build());
616            }
617
618            // @Override
619            public OleBorrowerTypeContract getOleBorrowerType() {
620                return OleBorrowerTypeDefinition.Builder.create(new OleBorrowerTypeContract() {
621                    @Override
622                    public String getBorrowerTypeId() {
623                        return BORROWER_ID;
624                    }
625
626                    @Override
627                    public String getBorrowerTypeCode() {
628                        return BORR_CODE;
629                    }
630
631                    @Override
632                    public String getBorrowerTypeDescription() {
633                        return BORR_DESC;
634                    }
635
636                    @Override
637                    public String getBorrowerTypeName() {
638                        return BORR_NAME;
639                    }
640
641                    @Override
642                    public String getId() {
643                        return BORROWER_ID;
644                    }
645
646                    @Override
647                    public Long getVersionNumber() {
648                        return BORR_VERSION_NUMBER;
649                    }
650                }).build();
651            }
652
653            @Override
654            public String getId() {
655                return PATRON_ID;
656            }
657
658            @Override
659            public Long getVersionNumber() {
660                return VERSION_NUMBER;
661            }
662        }) .build();
663    }
664
665    public OleSourceContract getSourceBo() {
666        return OleSourceDefinition.Builder.create(new OleSourceContract() {
667
668            @Override
669            public String getOleSourceId() {
670                return PATRON_SOURCE_ID;
671            }
672
673            @Override
674            public String getOleSourceCode() {
675                return PATRON_SOURCE_CODE;
676            }
677
678            @Override
679            public String getOleSourceName() {
680                return PATRON_SOURCE_NAME;
681            }
682
683            @Override
684            public String getOleSourceDesc() {
685                return PATRON_SOURCE_DESC;
686            }
687
688            @Override
689            public boolean isActive() {
690                return ACTIVE;
691            }
692
693            @Override
694            public String getId() {
695                return PATRON_SOURCE_ID;
696            }
697
698            @Override
699            public Long getVersionNumber() {
700                return PATRON_SOURCE_VERSION_NUMBER;
701            }
702        }).build();
703    }
704
705    public OleStatisticalCategoryContract getStatisticalCategoryBo() {
706        return OleStatisticalCategoryDefinition.Builder.create(new OleStatisticalCategoryContract() {
707
708
709            @Override
710            public String getOleStatisticalCategoryId() {
711                return PATRON_STATISTICAL_CATEGORY_ID;
712            }
713
714            @Override
715            public String getOleStatisticalCategoryCode() {
716                return PATRON_STATISTICAL_CATEGORY_CODE;
717            }
718
719            @Override
720            public String getOleStatisticalCategoryName() {
721                return PATRON_STATISTICAL_CATEGORY_NAME;
722            }
723
724            @Override
725            public String getOleStatisticalCategoryDesc() {
726                return PATRON_STATISTICAL_CATEGORY_DESC;
727            }
728
729            @Override
730            public boolean isActive() {
731                return ACTIVE;
732            }
733
734            @Override
735            public String getId() {
736                return PATRON_STATISTICAL_CATEGORY_ID;
737            }
738
739            @Override
740            public Long getVersionNumber() {
741                return PATRON_STATISTICAL_CATEGORY_VERSION_NUMBER;
742            }
743        }).build();
744    }
745
746}