1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.data.metadata.impl;
17
18 import java.util.HashMap;
19 import java.util.Map;
20
21 import org.kuali.rice.krad.data.metadata.DataObjectMetadata;
22 import org.kuali.rice.krad.data.metadata.MetadataRepository;
23 import org.kuali.rice.krad.data.provider.MetadataProvider;
24 import org.kuali.rice.krad.data.provider.ProviderRegistry;
25 import org.springframework.beans.factory.annotation.Required;
26
27
28
29
30
31
32 public class MetadataRepositoryImpl implements MetadataRepository {
33
34 private ProviderRegistry registry;
35
36 @Required
37 public void setProviderRegistry(ProviderRegistry registry) {
38 this.registry = registry;
39 }
40
41 @Override
42 public synchronized DataObjectMetadata getMetadata(Class<?> type) {
43
44 for (MetadataProvider provider: registry.getMetadataProviders()) {
45 if (provider.handles(type)) {
46 return provider.getMetadataForType(type);
47 }
48 }
49 return null;
50 }
51
52 @Override
53 public Map<Class<?>, DataObjectMetadata> getAllMetadata() {
54 Map<Class<?>, DataObjectMetadata> allMetaData = new HashMap<Class<?>, DataObjectMetadata>();
55
56
57
58 for (MetadataProvider provider: registry.getMetadataProviders()) {
59 allMetaData.putAll(provider.provideMetadata());
60 }
61 return allMetaData;
62 }
63
64 @Override
65 public boolean contains(Class<?> type) {
66 return getMetadata(type) != null;
67 }
68
69 }