1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.xds.core.validate;
17
18 import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLClassification;
19 import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLRegistryObject;
20 import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLSlot;
21 import org.openehealth.ipf.commons.ihe.xds.core.metadata.Vocabulary;
22
23 import java.util.HashSet;
24 import java.util.List;
25 import java.util.Set;
26
27 import static org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage.AUTHOR_INCOMPLETE;
28 import static org.openehealth.ipf.commons.ihe.xds.core.validate.ValidatorAssertions.metaDataAssert;
29
30
31
32
33 public class AuthorClassificationValidation extends ClassificationValidation {
34 private static final Set<String> SLOT_NAMES;
35 static {
36 SLOT_NAMES = new HashSet<>();
37 SLOT_NAMES.add(Vocabulary.SLOT_NAME_AUTHOR_PERSON);
38 SLOT_NAMES.add(Vocabulary.SLOT_NAME_AUTHOR_TELECOM);
39 SLOT_NAMES.add(Vocabulary.SLOT_NAME_AUTHOR_INSTITUTION);
40 }
41
42 public AuthorClassificationValidation(String classScheme, SlotValueValidation[] slotValidations) {
43 super(classScheme, 0, Integer.MAX_VALUE, Vocabulary.DisplayNameUsage.OPTIONAL, Vocabulary.NodeRepresentationUsage.PROHIBITED, slotValidations);
44 }
45
46 @Override
47 public void validate(EbXMLRegistryObject obj) throws XDSMetaDataException {
48 super.validate(obj);
49
50 List<EbXMLClassification> classifications = obj.getClassifications(classScheme);
51 for (EbXMLClassification classification : classifications) {
52
53
54 boolean authorComplete = false;
55 for (EbXMLSlot slot : classification.getSlots()) {
56 if (SLOT_NAMES.contains(slot.getName())) {
57 authorComplete = true;
58 break;
59 }
60 }
61 metaDataAssert(authorComplete, AUTHOR_INCOMPLETE, classScheme);
62 }
63
64 }
65 }