Project

General

Profile

Revision 954ad762

ID954ad762555d755079b1adf90d52dd8028483198
Parent 97312e07
Child 397b3cd7

Added by Andreas Kohlbecker over 2 years ago

ref #6621 commenting no longer used registrationCreate and registrationWipeout options

View differences:

src/main/java/eu/etaxonomy/cdm/dataInserter/RegistrationRequiredDataInserter.java
8 8
*/
9 9
package eu.etaxonomy.cdm.dataInserter;
10 10

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

  
22 19
import org.apache.log4j.Logger;
23
import org.joda.time.DateTime;
24
import org.joda.time.DateTimeFieldType;
25
import org.joda.time.Partial;
26
import org.joda.time.format.DateTimeFormatter;
27 20
import org.springframework.context.event.ContextRefreshedEvent;
28 21
import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
29 22
import org.springframework.security.core.GrantedAuthority;
30 23
import org.springframework.transaction.TransactionStatus;
31 24
import org.springframework.transaction.annotation.Transactional;
32 25

  
33
import com.fasterxml.jackson.core.JsonParseException;
34
import com.fasterxml.jackson.databind.JsonMappingException;
35
import com.fasterxml.jackson.databind.ObjectMapper;
36

  
37 26
import eu.etaxonomy.cdm.api.application.AbstractDataInserter;
38 27
import eu.etaxonomy.cdm.api.application.CdmRepository;
39
import eu.etaxonomy.cdm.api.service.pager.Pager;
40 28
import eu.etaxonomy.cdm.model.agent.Institution;
41 29
import eu.etaxonomy.cdm.model.common.DefinedTerm;
42 30
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
43
import eu.etaxonomy.cdm.model.common.ExtensionType;
44 31
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
45 32
import eu.etaxonomy.cdm.model.common.Group;
46 33
import eu.etaxonomy.cdm.model.common.TermVocabulary;
47
import eu.etaxonomy.cdm.model.common.TimePeriod;
48
import eu.etaxonomy.cdm.model.name.Registration;
49
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
50
import eu.etaxonomy.cdm.model.name.TaxonName;
51
import eu.etaxonomy.cdm.model.name.TypeDesignationBase;
52
import eu.etaxonomy.cdm.model.reference.Reference;
53 34
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
54 35
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
55 36
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmPermissionClass;
56 37
import eu.etaxonomy.cdm.persistence.hibernate.permission.Role;
57
import eu.etaxonomy.cdm.persistence.query.MatchMode;
58 38
import eu.etaxonomy.cdm.vaadin.model.registration.KindOfUnitTerms;
59 39
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
60 40

  
61
/**
62
 *
41
/*
63 42
 * Can create missing registrations for names which have Extensions of the Type <code>IAPTRegdata.json</code>.
64
 * See https://dev.e-taxonomy.eu/redmine/issues/6621 for further details.
65
 * This feature can be activated by by supplying one of the following jvm command line arguments:
66
 * <ul>
67
 * <li><code>-DregistrationCreate=iapt</code>: create all iapt Registrations if missing</li>
68
 * <li><code>-DregistrationWipeout=iapt</code>: remove all iapt Registrations</li>
69
 * <li><code>-DregistrationWipeout=all</code>: remove all Registrations</li>
70
 * </ul>
71
 * The <code>-DregistrationWipeout</code> commands are executed before the <code>-DregistrationCreate</code> and will not change the name and type designations.
43
* See https://dev.e-taxonomy.eu/redmine/issues/6621 for further details.
44
    * This feature can be activated by by supplying one of the following jvm command line arguments:
45
        * <ul>
46
* <li><code>-DregistrationCreate=iapt</code>: create all iapt Registrations if missing</li>
47
* <li><code>-DregistrationWipeout=iapt</code>: remove all iapt Registrations</li>
48
* <li><code>-DregistrationWipeout=all</code>: remove all Registrations</li>
49
* </ul>
50
* The <code>-DregistrationWipeout</code> commands are executed before the <code>-DregistrationCreate</code> and will not change the name and type designations.
51
*/
52
/**
72 53
 *
73 54
 * @author a.kohlbecker
74 55
 * @since May 9, 2017
......
76 57
 */
77 58
public class RegistrationRequiredDataInserter extends AbstractDataInserter {
78 59

  
79
    protected static final String PARAM_NAME_CREATE = "registrationCreate";
80

  
81
    protected static final String PARAM_NAME_WIPEOUT = "registrationWipeout";
60
//    protected static final String PARAM_NAME_CREATE = "registrationCreate";
61
//
62
//    protected static final String PARAM_NAME_WIPEOUT = "registrationWipeout";
82 63

  
83 64
    protected static final UUID GROUP_SUBMITTER_UUID = UUID.fromString("c468c6a7-b96c-4206-849d-5a825f806d3e");
84 65

  
......
89 70

  
90 71
    private static final Logger logger = Logger.getLogger(RegistrationRequiredDataInserter.class);
91 72

  
92
    private ExtensionType extensionTypeIAPTRegData;
73
//    private ExtensionType extensionTypeIAPTRegData;
93 74

  
94 75
    Map<String, Institution> instituteMap = new HashMap<>();
95 76

  
......
237 218
            return;
238 219
        }
239 220
        commandsExecuted  = true;
221
//
222
//        String wipeoutCmd = System.getProperty(PARAM_NAME_WIPEOUT);
223
//        String createCmd = System.getProperty(PARAM_NAME_CREATE);
224
//
225
//        // ============ DELETE
226
//        if(wipeoutCmd != null && wipeoutCmd.matches("iapt|all")){
227
//
228
//            boolean onlyIapt = wipeoutCmd.equals("iapt");
229
//            Set<UUID> deleteCandidates = new HashSet<UUID>();
230
//
231
//            TransactionStatus tx = repo.startTransaction(true);
232
//            List<Registration> allRegs = repo.getRegistrationService().list(null, null, null, null, null);
233
//            for(Registration reg : allRegs){
234
//                if(onlyIapt){
235
//                    try {
236
//                        @SuppressWarnings("unchecked")
237
//                        Set<String> extensions = reg.getName().getExtensions(getExtensionTypeIAPTRegData());
238
//                        if(reg.getUuid() != null){
239
//                            deleteCandidates.add(reg.getUuid());
240
//                        }
241
//                    } catch(NullPointerException e){
242
//                        // IGNORE
243
//                    }
244
//                } else {
245
//                    if(reg.getUuid() != null){
246
//                        deleteCandidates.add(reg.getUuid());
247
//                    }
248
//                }
249
//            }
250
//            repo.commitTransaction(tx);
251
//            if(!deleteCandidates.isEmpty()){
252
//                try {
253
//                    repo.getRegistrationService().delete(deleteCandidates);
254
//                } catch (Exception e) {
255
//                    // MySQLIntegrityConstraintViolationException happens here every second run !!!
256
//                    logger.error(e);
257
//                }
258
//            }
259
//        }
260
//
261
//        // ============ CREATE
262
//        int pageIndex = 0;
263
//        if(createCmd != null && createCmd.equals("iapt")){
264
//
265
//            DateTimeFormatter dateFormat1 = org.joda.time.format.DateTimeFormat.forPattern("dd.MM.yy").withPivotYear(1950);
266
//            DateTimeFormatter dateFormat2 = org.joda.time.format.DateTimeFormat.forPattern("yyyy-MM-dd").withPivotYear(1950);
267
//
268
//            TransactionStatus tx = repo.startTransaction(false);
269
//            while(true) {
270
//                Pager<TaxonName> pager = repo.getNameService().page(null, 1000, pageIndex, null, null);
271
//                if(pager.getRecords().isEmpty()){
272
//                    break;
273
//                }
274
//                List<Registration> newRegs = new ArrayList<>(pager.getRecords().size());
275
//                for(TaxonName name : pager.getRecords()){
276
//
277
//
278
//
279
//                    Set<String> extensionValues = name.getExtensions(getExtensionTypeIAPTRegData());
280
//
281
//                    // there is for sure only one
282
//                    if(extensionValues.isEmpty()){
283
//                        continue;
284
//                    }
285
//
286
//                    logger.debug("IAPT Registration for " + name.getTitleCache() + " ...");
287
//
288
//                    String iaptJson = extensionValues.iterator().next();
289
//                    try {
290
//
291
//                        IAPTRegData iaptData = new ObjectMapper().readValue(iaptJson, IAPTRegData.class);
292
//
293
//                        if(iaptData.getRegId() == null){
294
//                            continue;
295
//                        }
296
//
297
//                        DateTime regDate = null;
298
//                        if(iaptData.getDate() != null){
299
//                            DateTimeFormatter dateFormat;
300
//                            if(iaptData.getDate().matches("\\d{4}-\\d{2}-\\d{2}")){
301
//                                dateFormat = dateFormat2;
302
//                            } else {
303
//                                dateFormat = dateFormat1;
304
//                            }
305
//                            try {
306
//                                regDate = dateFormat.parseDateTime(iaptData.getDate());
307
//                                regDate.getYear();
308
//                            } catch (Exception e) {
309
//                                logger.error("Error parsing date : " + iaptData.getDate(), e);
310
//                                continue;
311
//                            }
312
//                        }
313
//
314
//                        Registration reg = Registration.NewInstance();
315
//                        reg.setStatus(RegistrationStatus.PUBLISHED);
316
//                        reg.setIdentifier("http://phycobank.org/" + iaptData.getRegId());
317
//                        reg.setSpecificIdentifier(iaptData.getRegId().toString());
318
//                        reg.setInstitution(getInstitution(iaptData.getOffice()));
319
//
320
//                        boolean isPhycobankID = Integer.valueOf(reg.getSpecificIdentifier()) >= 100000;
321
//
322
//                        Partial youngestDate = null;
323
//                        Reference youngestPub = null;
324
//
325
//                        // find youngest publication
326
//
327
//                        // NOTE:
328
//                        // data imported from IAPT does not have typedesignation citations and sometimes no nomref
329
//
330
//                        if(isPhycobankID){
331
//                            youngestPub = name.getNomenclaturalReference();
332
//                            youngestDate = partial(youngestPub.getDatePublished());
333
//
334
//                            if(name.getTypeDesignations() != null && !name.getTypeDesignations().isEmpty()){
335
//                                for(TypeDesignationBase<?> td : name.getTypeDesignations()){
336
//                                    if(td.getCitation() == null){
337
//                                        continue;
338
//                                    }
339
//                                    Partial pubdate = partial(td.getCitation().getDatePublished());
340
//                                    if(pubdate != null){
341
//
342
//                                        try {
343
//                                            if(youngestDate== null || earlierThanOther(youngestDate, pubdate)){
344
//                                                youngestDate = pubdate;
345
//                                                youngestPub = td.getCitation();
346
//                                            }
347
//                                        } catch (Exception e) {
348
//                                            logger.error("Error comparing " + youngestDate + " with" + pubdate , e);
349
//                                        }
350
//                                    }
351
//                                }
352
//                            }
353
//                        }
354
//
355
//                        if((isPhycobankID && youngestPub == name.getNomenclaturalReference()) || !isPhycobankID) {
356
//                            reg.setName(name);
357
//                        } else {
358
//                            logger.debug("skipping name published in older referece");
359
//                        }
360
//                        if(name.getTypeDesignations() != null && !name.getTypeDesignations().isEmpty()){
361
//                            // do not add the collection directly to avoid "Found shared references to a collection" problem
362
//                            Set<TypeDesignationBase> typeDesignations = new HashSet<>(name.getTypeDesignations().size());
363
//                            for(TypeDesignationBase<?> td : name.getTypeDesignations()){
364
//                                if(td.getCitation() == null && isPhycobankID){
365
//                                    logger.error("Missing TypeDesignation Citation in Phycobank data");
366
//                                    continue;
367
//                                }
368
//                                if((isPhycobankID && youngestPub == td.getCitation()) || !isPhycobankID){
369
//                                    typeDesignations.add(td);
370
//                                } else {
371
//                                    logger.debug("skipping typedesignation published in older reference");
372
//                                }
373
//                            }
374
//                            reg.setTypeDesignations(typeDesignations);
375
//                        }
376
//                        reg.setRegistrationDate(regDate);
377
//                        newRegs.add(reg);
378
//
379
//                    } catch (JsonParseException e) {
380
//                        logger.error("Error parsing IAPTRegData from extension", e);
381
//                    } catch (JsonMappingException e) {
382
//                        logger.error("Error mapping json from extension to IAPTRegData", e);
383
//                    } catch (IOException e) {
384
//                        logger.error(e);
385
//                    }
386
//
387
//                }
388
//                repo.getRegistrationService().save(newRegs);
389
//                tx.flush();
390
//                logger.debug("Registrations saved");
391
//                pageIndex++;
392
//            }
393
//            repo.commitTransaction(tx);
394
//        }
240 395

  
241
        String wipeoutCmd = System.getProperty(PARAM_NAME_WIPEOUT);
242
        String createCmd = System.getProperty(PARAM_NAME_CREATE);
243

  
244
        // ============ DELETE
245
        if(wipeoutCmd != null && wipeoutCmd.matches("iapt|all")){
246

  
247
            boolean onlyIapt = wipeoutCmd.equals("iapt");
248
            Set<UUID> deleteCandidates = new HashSet<UUID>();
249

  
250
            TransactionStatus tx = repo.startTransaction(true);
251
            List<Registration> allRegs = repo.getRegistrationService().list(null, null, null, null, null);
252
            for(Registration reg : allRegs){
253
                if(onlyIapt){
254
                    try {
255
                        @SuppressWarnings("unchecked")
256
                        Set<String> extensions = reg.getName().getExtensions(getExtensionTypeIAPTRegData());
257
                        if(reg.getUuid() != null){
258
                            deleteCandidates.add(reg.getUuid());
259
                        }
260
                    } catch(NullPointerException e){
261
                        // IGNORE
262
                    }
263
                } else {
264
                    if(reg.getUuid() != null){
265
                        deleteCandidates.add(reg.getUuid());
266
                    }
267
                }
268
            }
269
            repo.commitTransaction(tx);
270
            if(!deleteCandidates.isEmpty()){
271
                try {
272
                    repo.getRegistrationService().delete(deleteCandidates);
273
                } catch (Exception e) {
274
                    // MySQLIntegrityConstraintViolationException happens here every second run !!!
275
                    logger.error(e);
276
                }
277
            }
278
        }
279

  
280
        // ============ CREATE
281
        int pageIndex = 0;
282
        if(createCmd != null && createCmd.equals("iapt")){
283

  
284
            DateTimeFormatter dateFormat1 = org.joda.time.format.DateTimeFormat.forPattern("dd.MM.yy").withPivotYear(1950);
285
            DateTimeFormatter dateFormat2 = org.joda.time.format.DateTimeFormat.forPattern("yyyy-MM-dd").withPivotYear(1950);
286

  
287
            TransactionStatus tx = repo.startTransaction(false);
288
            while(true) {
289
                Pager<TaxonName> pager = repo.getNameService().page(null, 1000, pageIndex, null, null);
290
                if(pager.getRecords().isEmpty()){
291
                    break;
292
                }
293
                List<Registration> newRegs = new ArrayList<>(pager.getRecords().size());
294
                for(TaxonName name : pager.getRecords()){
295

  
296

  
297

  
298
                    Set<String> extensionValues = name.getExtensions(getExtensionTypeIAPTRegData());
299

  
300
                    // there is for sure only one
301
                    if(extensionValues.isEmpty()){
302
                        continue;
303
                    }
304

  
305
                    logger.debug("IAPT Registration for " + name.getTitleCache() + " ...");
306

  
307
                    String iaptJson = extensionValues.iterator().next();
308
                    try {
309

  
310
                        IAPTRegData iaptData = new ObjectMapper().readValue(iaptJson, IAPTRegData.class);
311

  
312
                        if(iaptData.getRegId() == null){
313
                            continue;
314
                        }
315

  
316
                        DateTime regDate = null;
317
                        if(iaptData.getDate() != null){
318
                            DateTimeFormatter dateFormat;
319
                            if(iaptData.getDate().matches("\\d{4}-\\d{2}-\\d{2}")){
320
                                dateFormat = dateFormat2;
321
                            } else {
322
                                dateFormat = dateFormat1;
323
                            }
324
                            try {
325
                                regDate = dateFormat.parseDateTime(iaptData.getDate());
326
                                regDate.getYear();
327
                            } catch (Exception e) {
328
                                logger.error("Error parsing date : " + iaptData.getDate(), e);
329
                                continue;
330
                            }
331
                        }
332

  
333
                        Registration reg = Registration.NewInstance();
334
                        reg.setStatus(RegistrationStatus.PUBLISHED);
335
                        reg.setIdentifier("http://phycobank.org/" + iaptData.getRegId());
336
                        reg.setSpecificIdentifier(iaptData.getRegId().toString());
337
                        reg.setInstitution(getInstitution(iaptData.getOffice()));
338

  
339
                        boolean isPhycobankID = Integer.valueOf(reg.getSpecificIdentifier()) >= 100000;
340

  
341
                        Partial youngestDate = null;
342
                        Reference youngestPub = null;
343

  
344
                        // find youngest publication
345

  
346
                        // NOTE:
347
                        // data imported from IAPT does not have typedesignation citations and sometimes no nomref
348

  
349
                        if(isPhycobankID){
350
                            youngestPub = name.getNomenclaturalReference();
351
                            youngestDate = partial(youngestPub.getDatePublished());
352

  
353
                            if(name.getTypeDesignations() != null && !name.getTypeDesignations().isEmpty()){
354
                                for(TypeDesignationBase<?> td : name.getTypeDesignations()){
355
                                    if(td.getCitation() == null){
356
                                        continue;
357
                                    }
358
                                    Partial pubdate = partial(td.getCitation().getDatePublished());
359
                                    if(pubdate != null){
360

  
361
                                        try {
362
                                            if(youngestDate== null || earlierThanOther(youngestDate, pubdate)){
363
                                                youngestDate = pubdate;
364
                                                youngestPub = td.getCitation();
365
                                            }
366
                                        } catch (Exception e) {
367
                                            logger.error("Error comparing " + youngestDate + " with" + pubdate , e);
368
                                        }
369
                                    }
370
                                }
371
                            }
372
                        }
373

  
374
                        if((isPhycobankID && youngestPub == name.getNomenclaturalReference()) || !isPhycobankID) {
375
                            reg.setName(name);
376
                        } else {
377
                            logger.debug("skipping name published in older referece");
378
                        }
379
                        if(name.getTypeDesignations() != null && !name.getTypeDesignations().isEmpty()){
380
                            // do not add the collection directly to avoid "Found shared references to a collection" problem
381
                            Set<TypeDesignationBase> typeDesignations = new HashSet<>(name.getTypeDesignations().size());
382
                            for(TypeDesignationBase<?> td : name.getTypeDesignations()){
383
                                if(td.getCitation() == null && isPhycobankID){
384
                                    logger.error("Missing TypeDesignation Citation in Phycobank data");
385
                                    continue;
386
                                }
387
                                if((isPhycobankID && youngestPub == td.getCitation()) || !isPhycobankID){
388
                                    typeDesignations.add(td);
389
                                } else {
390
                                    logger.debug("skipping typedesignation published in older reference");
391
                                }
392
                            }
393
                            reg.setTypeDesignations(typeDesignations);
394
                        }
395
                        reg.setRegistrationDate(regDate);
396
                        newRegs.add(reg);
397

  
398
                    } catch (JsonParseException e) {
399
                        logger.error("Error parsing IAPTRegData from extension", e);
400
                    } catch (JsonMappingException e) {
401
                        logger.error("Error mapping json from extension to IAPTRegData", e);
402
                    } catch (IOException e) {
403
                        logger.error(e);
404
                    }
405

  
406
                }
407
                repo.getRegistrationService().save(newRegs);
408
                tx.flush();
409
                logger.debug("Registrations saved");
410
                pageIndex++;
411
            }
412
            repo.commitTransaction(tx);
413
        }
414
    }
415

  
416

  
417
    /**
418
     * @param youngestDate
419
     * @param pubdate
420
     * @return
421
     */
422
    protected boolean earlierThanOther(Partial basePartial, Partial other) {
423

  
424
        if(basePartial == null || basePartial.getValues().length == 0){
425
            return false;
426
        }
427
        if(other == null || other.getValues().length == 0){
428
            return true;
429
        }
430
        if(basePartial.size() == other.size()) {
431
            return basePartial.compareTo(other) < 0;
432
        }
433
        basePartial = basePartial.without(DateTimeFieldType.dayOfMonth());
434
        other = other.without(DateTimeFieldType.dayOfMonth());
435
        if(basePartial.size() == other.size()) {
436
            return basePartial.compareTo(other) < 0;
437
        }
438
        basePartial = basePartial.without(DateTimeFieldType.monthOfYear());
439
        other = other.without(DateTimeFieldType.monthOfYear());
440
        return basePartial.compareTo(other) < 0;
441

  
442
    }
443

  
444

  
445
    /**
446
     * @param datePublished
447
     * @return
448
     */
449
    private Partial partial(TimePeriod datePublished) {
450
        if(datePublished != null){
451
            if(datePublished.getEnd() != null){
452
                return datePublished.getEnd();
453
            } else {
454
                return datePublished.getStart();
455
            }
456
        }
457
        return null;
458
    }
459

  
460

  
461
    /**
462
     * @param office
463
     * @return
464
     */
465
    private Institution getInstitution(String office) {
466
        Institution institution;
467
        if(instituteMap.containsKey(office)){
468
            institution = instituteMap.get(office);
469
        } else {
470

  
471
            Pager<Institution> pager = repo.getAgentService().findByTitleWithRestrictions(Institution.class, office, MatchMode.EXACT, null, null, null, null, null);
472
            if(!pager.getRecords().isEmpty()){
473
                institution =  pager.getRecords().get(0);
474
            } else {
475
                Institution institute = (Institution) repo.getAgentService().save(Institution.NewNamedInstance(office));
476
                institution = institute;
477
            }
478
            instituteMap.put(office, institution);
479
        }
480
        return institution;
481 396
    }
482 397

  
483 398

  
484
    private ExtensionType getExtensionTypeIAPTRegData() {
485
        if(extensionTypeIAPTRegData == null){
486
            extensionTypeIAPTRegData = (ExtensionType) repo.getTermService().load(UUID.fromString("9be1bfe3-6ba0-4560-af15-86971ab96e09"));
487
        }
488
        return extensionTypeIAPTRegData;
489
    }
490

  
399
//    /**
400
//     * @param youngestDate
401
//     * @param pubdate
402
//     * @return
403
//     */
404
//    private boolean earlierThanOther(Partial basePartial, Partial other) {
405
//
406
//        if(basePartial == null || basePartial.getValues().length == 0){
407
//            return false;
408
//        }
409
//        if(other == null || other.getValues().length == 0){
410
//            return true;
411
//        }
412
//        if(basePartial.size() == other.size()) {
413
//            return basePartial.compareTo(other) < 0;
414
//        }
415
//        basePartial = basePartial.without(DateTimeFieldType.dayOfMonth());
416
//        other = other.without(DateTimeFieldType.dayOfMonth());
417
//        if(basePartial.size() == other.size()) {
418
//            return basePartial.compareTo(other) < 0;
419
//        }
420
//        basePartial = basePartial.without(DateTimeFieldType.monthOfYear());
421
//        other = other.without(DateTimeFieldType.monthOfYear());
422
//        return basePartial.compareTo(other) < 0;
423
//
424
//    }
425

  
426

  
427
//    /**
428
//     * @param datePublished
429
//     * @return
430
//     */
431
//    private Partial partial(TimePeriod datePublished) {
432
//        if(datePublished != null){
433
//            if(datePublished.getEnd() != null){
434
//                return datePublished.getEnd();
435
//            } else {
436
//                return datePublished.getStart();
437
//            }
438
//        }
439
//        return null;
440
//    }
441

  
442

  
443
//    /**
444
//     * @param office
445
//     * @return
446
//     */
447
//    private Institution getInstitution(String office) {
448
//        Institution institution;
449
//        if(instituteMap.containsKey(office)){
450
//            institution = instituteMap.get(office);
451
//        } else {
452
//
453
//            Pager<Institution> pager = repo.getAgentService().findByTitleWithRestrictions(Institution.class, office, MatchMode.EXACT, null, null, null, null, null);
454
//            if(!pager.getRecords().isEmpty()){
455
//                institution =  pager.getRecords().get(0);
456
//            } else {
457
//                Institution institute = (Institution) repo.getAgentService().save(Institution.NewNamedInstance(office));
458
//                institution = institute;
459
//            }
460
//            instituteMap.put(office, institution);
461
//        }
462
//        return institution;
463
//    }
464

  
465

  
466
//    private ExtensionType getExtensionTypeIAPTRegData() {
467
//        if(extensionTypeIAPTRegData == null){
468
//            extensionTypeIAPTRegData = (ExtensionType) repo.getTermService().load(UUID.fromString("9be1bfe3-6ba0-4560-af15-86971ab96e09"));
469
//        }
470
//        return extensionTypeIAPTRegData;
471
//    }
491 472

  
492 473

  
493 474
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)