Project

General

Profile

Download (24.2 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2017 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.dataInserter;
10

    
11
import java.util.ArrayList;
12
import java.util.Arrays;
13
import java.util.EnumSet;
14
import java.util.HashMap;
15
import java.util.List;
16
import java.util.Map;
17
import java.util.Set;
18
import java.util.UUID;
19

    
20
import org.apache.logging.log4j.LogManager;
21
import org.apache.logging.log4j.Logger;
22
import org.hibernate.Session;
23
import org.springframework.context.event.ContextRefreshedEvent;
24
import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
25
import org.springframework.security.core.GrantedAuthority;
26
import org.springframework.transaction.TransactionStatus;
27
import org.springframework.transaction.annotation.Transactional;
28

    
29
import eu.etaxonomy.cdm.api.application.AbstractDataInserter;
30
import eu.etaxonomy.cdm.api.application.CdmRepository;
31
import eu.etaxonomy.cdm.api.service.pager.Pager;
32
import eu.etaxonomy.cdm.common.LogUtils;
33
import eu.etaxonomy.cdm.model.agent.Institution;
34
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus;
35
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType;
36
import eu.etaxonomy.cdm.model.name.Rank;
37
import eu.etaxonomy.cdm.model.name.TaxonName;
38
import eu.etaxonomy.cdm.model.permission.CRUD;
39
import eu.etaxonomy.cdm.model.permission.GrantedAuthorityImpl;
40
import eu.etaxonomy.cdm.model.permission.Group;
41
import eu.etaxonomy.cdm.model.permission.PermissionClass;
42
import eu.etaxonomy.cdm.model.taxon.Taxon;
43
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
44
import eu.etaxonomy.cdm.model.term.DefinedTerm;
45
import eu.etaxonomy.cdm.model.term.DefinedTermBase;
46
import eu.etaxonomy.cdm.model.term.TermVocabulary;
47
import eu.etaxonomy.cdm.persistence.dao.common.IPreferenceDao;
48
import eu.etaxonomy.cdm.persistence.dao.hibernate.taxonGraph.AbstractHibernateTaxonGraphProcessor;
49
import eu.etaxonomy.cdm.persistence.dao.taxonGraph.TaxonGraphException;
50
import eu.etaxonomy.cdm.persistence.permission.CdmAuthority;
51
import eu.etaxonomy.cdm.persistence.permission.Role;
52
import eu.etaxonomy.cdm.vaadin.model.registration.KindOfUnitTerms;
53
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
54

    
55
///*
56
// * Can create missing registrations for names which have Extensions of the Type <code>IAPTRegdata.json</code>.
57
//* See https://dev.e-taxonomy.eu/redmine/issues/6621 for further details.
58
//* This feature can be activated by by supplying one of the following jvm command line arguments:
59
//* <ul>
60
//* <li><code>-DregistrationCreate=iapt</code>: create all iapt Registrations if missing</li>
61
//* <li><code>-DregistrationWipeout=iapt</code>: remove all iapt Registrations</li>
62
//* <li><code>-DregistrationWipeout=all</code>: remove all Registrations</li>
63
//* </ul>
64
//* The <code>-DregistrationWipeout</code> commands are executed before the <code>-DregistrationCreate</code> and will not change the name and type designations.
65
//*/
66
/**
67
 * This feature can be activated by by supplying one of the following jvm command line arguments:
68
 * <ul>
69
 *   <li><code>-DtaxonGraphCreate=true</code>: create taxon graph relations for all names below genus level</li>
70
 * </ul>
71
 *
72
 * @author a.kohlbecker
73
 * @since May 9, 2017
74
 */
75
public class RegistrationRequiredDataInserter extends AbstractDataInserter {
76

    
77
    private final static Logger logger = LogManager.getLogger();
78

    
79
//    protected static final String PARAM_NAME_CREATE = "registrationCreate";
80
//
81
//    protected static final String PARAM_NAME_WIPEOUT = "registrationWipeout";
82

    
83
    protected static final String TAXON_GRAPH_CREATE = "taxonGraphCreate";
84

    
85
    protected static final UUID GROUP_SUBMITTER_UUID = UUID.fromString("c468c6a7-b96c-4206-849d-5a825f806d3e");
86

    
87
    protected static final UUID GROUP_CURATOR_UUID = UUID.fromString("135210d3-3db7-4a81-ab36-240444637d45");
88

    
89
    private static final EnumSet<CRUD> CREATE_READ = EnumSet.of(CRUD.CREATE, CRUD.READ);
90
    private static final EnumSet<CRUD> CREATE_READ_UPDATE_DELETE = EnumSet.of(CRUD.CREATE, CRUD.READ, CRUD.UPDATE, CRUD.DELETE);
91

    
92

    
93
//    private ExtensionType extensionTypeIAPTRegData;
94

    
95
    private Map<String, Institution> instituteMap = new HashMap<>();
96

    
97
    public static boolean commandsExecuted = false;
98

    
99
    private CdmRepository repo;
100

    
101
    private boolean hasRun = false;
102

    
103
    public void setCdmRepository(CdmRepository repo){
104
      this.repo = repo;
105
    }
106

    
107
    @Override
108
    public void onApplicationEvent(ContextRefreshedEvent event) {
109
        if(hasRun){
110
            return;
111
        }
112
        runAsAuthentication(Role.ROLE_ADMIN);
113
        insertRequiredData();
114
        executeSuppliedCommands();
115
        restoreAuthentication();
116
        hasRun = true;
117
    }
118

    
119
    @Transactional
120
    private void insertRequiredData() {
121

    
122
        TransactionStatus txStatus = repo.startTransaction(false);
123

    
124
        Role roleCuration = RolesAndPermissions.ROLE_CURATION;
125
        if(repo.getGrantedAuthorityService().find(roleCuration.getUuid()) == null){
126
            repo.getGrantedAuthorityService().saveOrUpdate(roleCuration.asNewGrantedAuthority());
127
        }
128

    
129
        Group groupCurator = repo.getGroupService().load(GROUP_CURATOR_UUID, Arrays.asList("grantedAuthorities"));
130
        if(groupCurator == null){
131
            groupCurator = Group.NewInstance();
132
            groupCurator.setUuid(GROUP_CURATOR_UUID);
133
            groupCurator.setName("Curator");
134
        }
135
        assureGroupHas(groupCurator, new CdmAuthority(PermissionClass.REGISTRATION, CREATE_READ_UPDATE_DELETE).toString());
136
        repo.getGroupService().saveOrUpdate(groupCurator);
137

    
138
        Group groupSubmitter = repo.getGroupService().load(GROUP_SUBMITTER_UUID, Arrays.asList("grantedAuthorities"));
139
        if(groupSubmitter == null){
140
            groupSubmitter = Group.NewInstance();
141
            groupSubmitter.setUuid(GROUP_SUBMITTER_UUID);
142
            groupSubmitter.setName("Submitter");
143
        }
144
        assureGroupHas(groupSubmitter, new CdmAuthority(PermissionClass.TAXONNAME, CREATE_READ).toString());
145
        assureGroupHas(groupSubmitter, new CdmAuthority(PermissionClass.TEAMORPERSONBASE, CREATE_READ).toString());
146
        assureGroupHas(groupSubmitter, new CdmAuthority(PermissionClass.REGISTRATION, CREATE_READ).toString());
147
        assureGroupHas(groupSubmitter, new CdmAuthority(PermissionClass.REFERENCE, CREATE_READ).toString());
148
        assureGroupHas(groupSubmitter, new CdmAuthority(PermissionClass.SPECIMENOROBSERVATIONBASE, CREATE_READ).toString());
149
        assureGroupHas(groupSubmitter, new CdmAuthority(PermissionClass.COLLECTION, CREATE_READ).toString());
150
        repo.getGroupService().saveOrUpdate(groupSubmitter);
151

    
152
        TermVocabulary<DefinedTerm> kindOfUnitVocabulary = repo.getVocabularyService().find(KindOfUnitTerms.KIND_OF_UNIT_VOCABULARY().getUuid());
153
        if(kindOfUnitVocabulary == null){
154
            kindOfUnitVocabulary = repo.getVocabularyService().save(KindOfUnitTerms.KIND_OF_UNIT_VOCABULARY());
155
        }
156

    
157
        DefinedTermBase<?> kouSpecimen = repo.getTermService().find(KindOfUnitTerms.SPECIMEN().getUuid());
158
        DefinedTermBase<?> kouImage = repo.getTermService().find(KindOfUnitTerms.PUBLISHED_IMAGE().getUuid());
159
        DefinedTermBase<?> kouUnpublishedImage = repo.getTermService().find(KindOfUnitTerms.UNPUBLISHED_IMAGE().getUuid());
160
        DefinedTermBase<?> kouCulture = repo.getTermService().find(KindOfUnitTerms.CULTURE_METABOLIC_INACTIVE().getUuid());
161

    
162
        if(kouSpecimen == null){
163
            kouSpecimen = repo.getTermService().save(KindOfUnitTerms.SPECIMEN());
164
        }
165
        if(kouImage == null){
166
            kouImage = repo.getTermService().save(KindOfUnitTerms.PUBLISHED_IMAGE());
167
        }
168
        if(kouUnpublishedImage == null){
169
            kouUnpublishedImage = repo.getTermService().save(KindOfUnitTerms.UNPUBLISHED_IMAGE());
170
        }
171
        if(kouCulture == null){
172
            kouCulture = repo.getTermService().save(KindOfUnitTerms.CULTURE_METABOLIC_INACTIVE());
173
        }
174

    
175
        Set<DefinedTerm> termInVocab = kindOfUnitVocabulary.getTerms();
176
        List<DefinedTermBase> kouTerms = Arrays.asList(kouCulture, kouImage, kouSpecimen, kouUnpublishedImage);
177

    
178
        for(DefinedTermBase<?> t : kouTerms){
179
            if(!termInVocab.contains(t)){
180
                kindOfUnitVocabulary.addTerm((DefinedTerm)t);
181
            }
182
        }
183

    
184
        repo.commitTransaction(txStatus);
185

    
186
    }
187

    
188
    private void assureGroupHas(Group group, String authorityString){
189
        boolean authorityExists = false;
190

    
191
        for(GrantedAuthority ga : group.getGrantedAuthorities()){
192
            if((authorityExists = ga.getAuthority().equals(authorityString)) == true){
193
                break;
194
            }
195
        }
196
        if(!authorityExists){
197
            group.addGrantedAuthority(findGrantedAuthority(authorityString));
198
        }
199
    }
200

    
201
    private GrantedAuthorityImpl findGrantedAuthority(String authorityString){
202
        GrantedAuthorityImpl ga = null;
203
        try{
204
            ga = repo.getGrantedAuthorityService().findAuthorityString(authorityString);
205
        } catch (AuthenticationCredentialsNotFoundException e){
206
            e.printStackTrace();
207
        }
208
        if(ga == null){
209
            ga = GrantedAuthorityImpl.NewInstance(authorityString);
210
            repo.getGrantedAuthorityService().save(ga);
211
        }
212
        return ga;
213
    }
214

    
215
    private void executeSuppliedCommands() {
216

    
217
        if(commandsExecuted){
218
            // do not run twice
219
            // a second run could take place during initialization of the web context
220
            return;
221
        }
222
        commandsExecuted  = true;
223

    
224
        String taxonGraphCreate = System.getProperty(TAXON_GRAPH_CREATE);
225

    
226
        if(taxonGraphCreate != null){
227
            IPreferenceDao prefDao = (IPreferenceDao) repo.getBean("preferenceDao");
228

    
229
            AbstractHibernateTaxonGraphProcessor processor = new AbstractHibernateTaxonGraphProcessor(prefDao) {
230
                @Override
231
                public Session getSession() {
232
                    return repo.getSession();
233
                }
234
            };
235

    
236
            int chunksize = 1000;
237
            int pageIndex = 0;
238
            TransactionStatus tx;
239
            Pager<Taxon> taxonPage;
240
            List<TaxonBase> taxa = new ArrayList<>();
241
            LogUtils.logAsDebug(logger, "======= fixing sec refrences =========");
242
            while(true){
243
                tx = repo.startTransaction(false);
244
                taxonPage = repo.getTaxonService().page(Taxon.class, chunksize, pageIndex++, null, null);
245
                if(taxonPage.getRecords().size() == 0){
246
                    repo.commitTransaction(tx);
247
                    break;
248
                }
249
                for(Taxon taxon : taxonPage.getRecords()){
250
                    taxon.setSec(processor.secReference());
251
                    repo.getTaxonService().saveOrUpdate(taxon);
252
                }
253
                repo.commitTransaction(tx);
254
            }
255

    
256
            LogUtils.logAsDebug(logger, "======= creating taxon graph =========");
257
            pageIndex = 0;
258
            Pager<TaxonName> page;
259
            while(true){
260
               tx = repo.startTransaction(false);
261
               page = repo.getNameService().page(null, chunksize, pageIndex++, null, null);
262
               if(page.getRecords().size() == 0){
263
                   repo.commitTransaction(tx);
264
                   break;
265
               }
266
               LogUtils.logAsDebug(logger, TAXON_GRAPH_CREATE + ": chunk " + pageIndex + "/" + Math.ceil(page.getCount() / chunksize));
267
               taxa = new ArrayList<>();
268

    
269
               for(TaxonName name : page.getRecords()){
270
                   if(name.getRank() != null && name.getRank().isLower(Rank.GENUS())){
271
                       NomenclaturalStatusType illegitimType = findILegitimateStatusType(name);
272
                       if(illegitimType == null){
273
                           Taxon taxon;
274
                           try {
275
                               LogUtils.logAsDebug(logger, "Processing name: " + name.getTitleCache() + " [" + name.getRank().getLabel() + "]");
276
                               taxon = processor.assureSingleTaxon(name);
277
                               processor.updateEdges(taxon);
278
                               taxa.add(taxon);
279
                           } catch (TaxonGraphException e) {
280
                               logger.error(e.getMessage());
281
                           }
282
                       } else {
283
                           LogUtils.logAsDebug(logger, "Skipping illegitimate name: " + name.getTitleCache() + " " + illegitimType.getLabel() + " [" + name.getRank().getLabel() + "]");
284
                       }
285
                   } else {
286
                       LogUtils.logAsDebug(logger, "Skipping name: " + name.getTitleCache() + " [" + (name.getRank() != null ? name.getRank().getLabel() : "NULL") + "]");
287
                   }
288
               }
289
               repo.getTaxonService().saveOrUpdate(taxa);
290
               repo.commitTransaction(tx);
291
            }
292
        }
293

    
294
//        String wipeoutCmd = System.getProperty(PARAM_NAME_WIPEOUT);
295
//        String createCmd = System.getProperty(PARAM_NAME_CREATE);
296
//
297
//        // ============ DELETE
298
//        if(wipeoutCmd != null && wipeoutCmd.matches("iapt|all")){
299
//
300
//            boolean onlyIapt = wipeoutCmd.equals("iapt");
301
//            Set<UUID> deleteCandidates = new HashSet<UUID>();
302
//
303
//            TransactionStatus tx = repo.startTransaction(true);
304
//            List<Registration> allRegs = repo.getRegistrationService().list(null, null, null, null, null);
305
//            for(Registration reg : allRegs){
306
//                if(onlyIapt){
307
//                    try {
308
//                        @SuppressWarnings("unchecked")
309
//                        Set<String> extensions = reg.getName().getExtensions(getExtensionTypeIAPTRegData());
310
//                        if(reg.getUuid() != null){
311
//                            deleteCandidates.add(reg.getUuid());
312
//                        }
313
//                    } catch(NullPointerException e){
314
//                        // IGNORE
315
//                    }
316
//                } else {
317
//                    if(reg.getUuid() != null){
318
//                        deleteCandidates.add(reg.getUuid());
319
//                    }
320
//                }
321
//            }
322
//            repo.commitTransaction(tx);
323
//            if(!deleteCandidates.isEmpty()){
324
//                try {
325
//                    repo.getRegistrationService().delete(deleteCandidates);
326
//                } catch (Exception e) {
327
//                    // MySQLIntegrityConstraintViolationException happens here every second run !!!
328
//                    logger.error(e);
329
//                }
330
//            }
331
//        }
332
//
333
//        // ============ CREATE
334
//        int pageIndex = 0;
335
//        if(createCmd != null && createCmd.equals("iapt")){
336
//
337
//            DateTimeFormatter dateFormat1 = org.joda.time.format.DateTimeFormat.forPattern("dd.MM.yy").withPivotYear(1950);
338
//            DateTimeFormatter dateFormat2 = org.joda.time.format.DateTimeFormat.forPattern("yyyy-MM-dd").withPivotYear(1950);
339
//
340
//            TransactionStatus tx = repo.startTransaction(false);
341
//            while(true) {
342
//                Pager<TaxonName> pager = repo.getNameService().page(null, 1000, pageIndex, null, null);
343
//                if(pager.getRecords().isEmpty()){
344
//                    break;
345
//                }
346
//                List<Registration> newRegs = new ArrayList<>(pager.getRecords().size());
347
//                for(TaxonName name : pager.getRecords()){
348
//
349
//
350
//
351
//                    Set<String> extensionValues = name.getExtensions(getExtensionTypeIAPTRegData());
352
//
353
//                    // there is for sure only one
354
//                    if(extensionValues.isEmpty()){
355
//                        continue;
356
//                    }
357
//
358
//                    logger.debug("IAPT Registration for " + name.getTitleCache() + " ...");
359
//
360
//                    String iaptJson = extensionValues.iterator().next();
361
//                    try {
362
//
363
//                        IAPTRegData iaptData = new ObjectMapper().readValue(iaptJson, IAPTRegData.class);
364
//
365
//                        if(iaptData.getRegId() == null){
366
//                            continue;
367
//                        }
368
//
369
//                        DateTime regDate = null;
370
//                        if(iaptData.getDate() != null){
371
//                            DateTimeFormatter dateFormat;
372
//                            if(iaptData.getDate().matches("\\d{4}-\\d{2}-\\d{2}")){
373
//                                dateFormat = dateFormat2;
374
//                            } else {
375
//                                dateFormat = dateFormat1;
376
//                            }
377
//                            try {
378
//                                regDate = dateFormat.parseDateTime(iaptData.getDate());
379
//                                regDate.getYear();
380
//                            } catch (Exception e) {
381
//                                logger.error("Error parsing date : " + iaptData.getDate(), e);
382
//                                continue;
383
//                            }
384
//                        }
385
//
386
//                        Registration reg = Registration.NewInstance();
387
//                        reg.setStatus(RegistrationStatus.PUBLISHED);
388
//                        reg.setIdentifier("http://phycobank.org/" + iaptData.getRegId());
389
//                        reg.setSpecificIdentifier(iaptData.getRegId().toString());
390
//                        reg.setInstitution(getInstitution(iaptData.getOffice()));
391
//
392
//                        boolean isPhycobankID = Integer.valueOf(reg.getSpecificIdentifier()) >= 100000;
393
//
394
//                        Partial youngestDate = null;
395
//                        Reference youngestPub = null;
396
//
397
//                        // find youngest publication
398
//
399
//                        // NOTE:
400
//                        // data imported from IAPT does not have typedesignation citations and sometimes no nomref
401
//
402
//                        if(isPhycobankID){
403
//                            youngestPub = name.getNomenclaturalReference();
404
//                            youngestDate = partial(youngestPub.getDatePublished());
405
//
406
//                            if(name.getTypeDesignations() != null && !name.getTypeDesignations().isEmpty()){
407
//                                for(TypeDesignationBase<?> td : name.getTypeDesignations()){
408
//                                    if(td.getCitation() == null){
409
//                                        continue;
410
//                                    }
411
//                                    Partial pubdate = partial(td.getCitation().getDatePublished());
412
//                                    if(pubdate != null){
413
//
414
//                                        try {
415
//                                            if(youngestDate== null || earlierThanOther(youngestDate, pubdate)){
416
//                                                youngestDate = pubdate;
417
//                                                youngestPub = td.getCitation();
418
//                                            }
419
//                                        } catch (Exception e) {
420
//                                            logger.error("Error comparing " + youngestDate + " with" + pubdate , e);
421
//                                        }
422
//                                    }
423
//                                }
424
//                            }
425
//                        }
426
//
427
//                        if((isPhycobankID && youngestPub == name.getNomenclaturalReference()) || !isPhycobankID) {
428
//                            reg.setName(name);
429
//                        } else {
430
//                            logger.debug("skipping name published in older referece");
431
//                        }
432
//                        if(name.getTypeDesignations() != null && !name.getTypeDesignations().isEmpty()){
433
//                            // do not add the collection directly to avoid "Found shared references to a collection" problem
434
//                            Set<TypeDesignationBase> typeDesignations = new HashSet<>(name.getTypeDesignations().size());
435
//                            for(TypeDesignationBase<?> td : name.getTypeDesignations()){
436
//                                if(td.getCitation() == null && isPhycobankID){
437
//                                    logger.error("Missing TypeDesignation Citation in Phycobank data");
438
//                                    continue;
439
//                                }
440
//                                if((isPhycobankID && youngestPub == td.getCitation()) || !isPhycobankID){
441
//                                    typeDesignations.add(td);
442
//                                } else {
443
//                                    logger.debug("skipping typedesignation published in older reference");
444
//                                }
445
//                            }
446
//                            reg.setTypeDesignations(typeDesignations);
447
//                        }
448
//                        reg.setRegistrationDate(regDate);
449
//                        newRegs.add(reg);
450
//
451
//                    } catch (JsonParseException e) {
452
//                        logger.error("Error parsing IAPTRegData from extension", e);
453
//                    } catch (JsonMappingException e) {
454
//                        logger.error("Error mapping json from extension to IAPTRegData", e);
455
//                    } catch (IOException e) {
456
//                        logger.error(e);
457
//                    }
458
//
459
//                }
460
//                repo.getRegistrationService().save(newRegs);
461
//                tx.flush();
462
//                logger.debug("Registrations saved");
463
//                pageIndex++;
464
//            }
465
//            repo.commitTransaction(tx);
466
//        }
467

    
468
    }
469

    
470
    private NomenclaturalStatusType findILegitimateStatusType(TaxonName name){
471
        for(NomenclaturalStatus status : name.getStatus()){
472
            if(status.getType() != null && !status.getType().isLegitimate()){
473
                return status.getType();
474
            }
475
        }
476
        return null;
477
    }
478

    
479

    
480
//    /**
481
//     * @param youngestDate
482
//     * @param pubdate
483
//     * @return
484
//     */
485
//    private boolean earlierThanOther(Partial basePartial, Partial other) {
486
//
487
//        if(basePartial == null || basePartial.getValues().length == 0){
488
//            return false;
489
//        }
490
//        if(other == null || other.getValues().length == 0){
491
//            return true;
492
//        }
493
//        if(basePartial.size() == other.size()) {
494
//            return basePartial.compareTo(other) < 0;
495
//        }
496
//        basePartial = basePartial.without(DateTimeFieldType.dayOfMonth());
497
//        other = other.without(DateTimeFieldType.dayOfMonth());
498
//        if(basePartial.size() == other.size()) {
499
//            return basePartial.compareTo(other) < 0;
500
//        }
501
//        basePartial = basePartial.without(DateTimeFieldType.monthOfYear());
502
//        other = other.without(DateTimeFieldType.monthOfYear());
503
//        return basePartial.compareTo(other) < 0;
504
//
505
//    }
506

    
507

    
508
//    /**
509
//     * @param datePublished
510
//     * @return
511
//     */
512
//    private Partial partial(TimePeriod datePublished) {
513
//        if(datePublished != null){
514
//            if(datePublished.getEnd() != null){
515
//                return datePublished.getEnd();
516
//            } else {
517
//                return datePublished.getStart();
518
//            }
519
//        }
520
//        return null;
521
//    }
522

    
523

    
524
//    /**
525
//     * @param office
526
//     * @return
527
//     */
528
//    private Institution getInstitution(String office) {
529
//        Institution institution;
530
//        if(instituteMap.containsKey(office)){
531
//            institution = instituteMap.get(office);
532
//        } else {
533
//
534
//            Pager<Institution> pager = repo.getAgentService().findByTitleWithRestrictions(Institution.class, office, MatchMode.EXACT, null, null, null, null, null);
535
//   )         if(!pager.getRecords().isEmpty()){
536
//                institution =  pager.getRecords().get(0);
537
//            } else {
538
//                Institution institute = (Institution) repo.getAgentService().save(Institution.NewNamedInstance(office));
539
//                institution = institute;
540
//            }
541
//            instituteMap.put(office, institution);
542
//        }
543
//        return institution;
544
//    }
545

    
546

    
547
//    private ExtensionType getExtensionTypeIAPTRegData() {
548
//        if(extensionTypeIAPTRegData == null){
549
//            extensionTypeIAPTRegData = (ExtensionType) repo.getTermService().load(UUID.fromString("9be1bfe3-6ba0-4560-af15-86971ab96e09"));
550
//        }
551
//        return extensionTypeIAPTRegData;
552
//    }
553

    
554

    
555
}
(2-2/2)