source: VirtualCollectionRegistry/tags/VirtualCollectionRegistry-0.4.0-alpha2/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/service/impl/ChaningCreatorProvider.java @ 5557

Last change on this file since 5557 was 5557, checked in by Twan Goosen, 10 years ago

tag for VCR alpha 2

File size: 2.3 KB
Line 
1package eu.clarin.cmdi.virtualcollectionregistry.service.impl;
2
3import eu.clarin.cmdi.virtualcollectionregistry.model.Creator;
4import eu.clarin.cmdi.virtualcollectionregistry.service.CreatorProvider;
5import java.security.Principal;
6import java.util.ArrayList;
7import java.util.List;
8
9/**
10 *
11 * @author twagoo
12 */
13public class ChaningCreatorProvider implements CreatorProvider {
14
15    private final List<CreatorProvider> providerChain;
16
17    public ChaningCreatorProvider(List<CreatorProvider> providerChain) {
18        this.providerChain = providerChain;
19    }
20
21    @Override
22    public Creator getCreator(Principal principal) {
23        final List<Creator> creators = new ArrayList<>(providerChain.size());
24        for (CreatorProvider provider : providerChain) {
25            creators.add(provider.getCreator(principal));
26        }
27
28        final Creator creator = new Creator();
29        for (Creator template : creators) {
30            if (template.getAddress() != null) {
31                creator.setAddress(template.getAddress());
32                break;
33            }
34        }
35        for (Creator template : creators) {
36            if (template.getEMail() != null) {
37                creator.setEMail(template.getEMail());
38                break;
39            }
40        }
41        for (Creator template : creators) {
42            if (template.getOrganisation() != null) {
43                creator.setOrganisation(template.getOrganisation());
44                break;
45            }
46        }
47        for (Creator template : creators) {
48            if (template.getPerson() != null) {
49                creator.setPerson(template.getPerson());
50                break;
51            }
52        }
53        for (Creator template : creators) {
54            if (template.getRole() != null) {
55                creator.setRole(template.getRole());
56                break;
57            }
58        }
59        for (Creator template : creators) {
60            if (template.getTelephone() != null) {
61                creator.setTelephone(template.getTelephone());
62                break;
63            }
64        }
65        for (Creator template : creators) {
66            if (template.getWebsite() != null) {
67                creator.setWebsite(template.getWebsite());
68                break;
69            }
70        }
71        return creator;
72    }
73
74}
Note: See TracBrowser for help on using the repository browser.