001package org.hl7.fhir.dstu2.utils.validation;
002
003/*
004  Copyright (c) 2011+, HL7, Inc.
005  All rights reserved.
006  
007  Redistribution and use in source and binary forms, with or without modification, 
008  are permitted provided that the following conditions are met:
009    
010   * Redistributions of source code must retain the above copyright notice, this 
011     list of conditions and the following disclaimer.
012   * Redistributions in binary form must reproduce the above copyright notice, 
013     this list of conditions and the following disclaimer in the documentation 
014     and/or other materials provided with the distribution.
015   * Neither the name of HL7 nor the names of its contributors may be used to 
016     endorse or promote products derived from this software without specific 
017     prior written permission.
018  
019  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 
020  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
021  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
022  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 
023  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
024  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
025  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
027  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
028  POSSIBILITY OF SUCH DAMAGE.
029  
030 */
031
032
033
034import java.util.List;
035
036import org.hl7.fhir.dstu2.model.StructureDefinition;
037import org.hl7.fhir.dstu2.utils.validation.constants.BestPracticeWarningLevel;
038import org.hl7.fhir.dstu2.utils.validation.constants.CheckDisplayOption;
039import org.hl7.fhir.dstu2.utils.validation.constants.IdStatus;
040import org.hl7.fhir.utilities.validation.ValidationMessage;
041import org.w3c.dom.Document;
042import org.w3c.dom.Element;
043
044import com.google.gson.JsonObject;
045
046public interface IResourceValidator {
047
048  /**
049   * how much to check displays for coded elements 
050   * @return
051   */
052  CheckDisplayOption getCheckDisplay();
053
054  /**
055   * how much to check displays for coded elements 
056   * @return
057   */
058  void setCheckDisplay(CheckDisplayOption checkDisplay);
059
060  /**
061   * whether the resource must have an id or not (depends on context)
062   * 
063   * @return
064   */
065
066        IdStatus getResourceIdRule();
067        void setResourceIdRule(IdStatus resourceIdRule);
068  
069  BestPracticeWarningLevel getBasePracticeWarningLevel();
070  void setBestPracticeWarningLevel(BestPracticeWarningLevel value);
071
072  /**
073   * Given a DOM element, return a list of errors in the resource
074   * @- if the underlying infrastructure fails (not if the resource is invalid)
075   */
076  void validate(List<ValidationMessage> errors, Element element) throws Exception;
077
078  /**
079   * Given a JSON Object, return a list of errors in the resource
080   * @- if the underlying infrastructure fails (not if the resource is invalid)
081   */
082  void validate(List<ValidationMessage> errors, JsonObject object) throws Exception;
083
084  /**
085   * Given a DOM element, return a list of errors in the resource
086   * @- if the underlying infrastructure fails (not if the resource is invalid)
087   */
088  List<ValidationMessage> validate(Element element) throws Exception;
089
090  /**
091   * Given a DOM element, return a list of errors in the resource
092   * @- if the underlying infrastructure fails (not if the resource is invalid)
093   */
094  List<ValidationMessage> validate(JsonObject object) throws Exception;
095
096  /**
097   * Given a DOM element, return a list of errors in the resource 
098   * with regard to the specified profile (by logical identifier)
099   * @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
100   */
101  void validate(List<ValidationMessage> errors, Element element, String profile) throws Exception;
102
103  /**
104   * Given a DOM element, return a list of errors in the resource 
105   * with regard to the specified profile (by logical identifier)
106   * @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
107   */
108        List<ValidationMessage> validate(Element element, String profile) throws Exception;
109
110  /**
111   * Given a DOM element, return a list of errors in the resource 
112   * with regard to the specified profile (by logical identifier)
113   * @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
114   */
115  List<ValidationMessage> validate(JsonObject object, StructureDefinition profile) throws Exception;
116
117  /**
118   * Given a DOM element, return a list of errors in the resource 
119   * with regard to the specified profile (by logical identifier)
120   * @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
121   */
122  List<ValidationMessage> validate(JsonObject object, String profile) throws Exception;
123
124  /**
125   * Given a DOM element, return a list of errors in the resource 
126   * with regard to the specified profile 
127   * @- if the underlying infrastructure fails (not if the resource is invalid)
128   */
129  void validate(List<ValidationMessage> errors, Element element, StructureDefinition profile) throws Exception;
130
131  /**
132   * Given a DOM element, return a list of errors in the resource 
133   * with regard to the specified profile 
134   * @- if the underlying infrastructure fails (not if the resource is invalid)
135   */
136  void validate(List<ValidationMessage> errors, JsonObject object, StructureDefinition profile) throws Exception;
137
138  /**
139   * Given a DOM element, return a list of errors in the resource 
140   * with regard to the specified profile 
141   * @- if the underlying infrastructure fails (not if the resource is invalid)
142   */
143  void validate(List<ValidationMessage> errors, JsonObject object, String profile) throws Exception;
144
145  /**
146   * Given a DOM element, return a list of errors in the resource 
147   * with regard to the specified profile
148   * @- if the underlying infrastructure fails (not if the resource is invalid)
149   */
150  List<ValidationMessage> validate(Element element, StructureDefinition profile) throws Exception;
151
152
153  /**
154   * Given a DOM document, return a list of errors in the resource
155   * @- if the underlying infrastructure fails (not if the resource is invalid)
156   */
157  void validate(List<ValidationMessage> errors, Document document) throws Exception;
158
159  /**
160   * Given a DOM document, return a list of errors in the resource
161   * @- if the underlying infrastructure fails (not if the resource is invalid)
162   */
163  List<ValidationMessage> validate(Document document) throws Exception;
164
165  /**
166   * Given a DOM document, return a list of errors in the resource 
167   * with regard to the specified profile (by logical identifier)
168   * @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
169   */
170  void validate(List<ValidationMessage> errors, Document document, String profile) throws Exception;
171
172  /**
173   * Given a DOM document, return a list of errors in the resource 
174   * with regard to the specified profile (by logical identifier)
175   * @- if the underlying infrastructure fails, or the profile can't be found (not if the resource is invalid)
176   */
177        List<ValidationMessage> validate(Document document, String profile) throws Exception;
178
179  /**
180   * Given a DOM document, return a list of errors in the resource 
181   * with regard to the specified profile 
182   * @- if the underlying infrastructure fails (not if the resource is invalid)
183   */
184  void validate(List<ValidationMessage> errors, Document document, StructureDefinition profile) throws Exception;
185
186  /**
187   * Given a DOM document, return a list of errors in the resource 
188   * with regard to the specified profile
189   * @- if the underlying infrastructure fails (not if the resource is invalid)
190   */
191  List<ValidationMessage> validate(Document document, StructureDefinition profile) throws Exception;
192
193}