From da2d4d0497ea39f645d853b4a9a6c47bc5ede3b9 Mon Sep 17 00:00:00 2001 From: jamesagnew Date: Wed, 24 Jun 2015 08:22:05 -0400 Subject: [PATCH] Stlye issues only --- hapi-fhir-base/pom.xml | 24 + .../BaseRuntimeDeclaredChildDefinition.java | 100 ++-- hapi-fhir-cobertura/pom.xml | 18 +- .../ResourceProviderMultiVersionTest.java | 19 + .../META-INF/fhirtest_persistence.xml | 11 - hapi-tinder-plugin/src/test/resources/tmp.txt | 484 ------------------ pom.xml | 4 +- 7 files changed, 97 insertions(+), 563 deletions(-) delete mode 100644 hapi-tinder-plugin/src/test/resources/tmp.txt diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml index 9fcea136f95..fe15a80ac2e 100644 --- a/hapi-fhir-base/pom.xml +++ b/hapi-fhir-base/pom.xml @@ -222,6 +222,30 @@ + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + + checkstyle + + + + + false + file://${project.basedir}/../src/checkstyle/checkstyle.xml + + + + + diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeDeclaredChildDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeDeclaredChildDefinition.java index 76e289aacd1..9ccc27cf117 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeDeclaredChildDefinition.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeDeclaredChildDefinition.java @@ -38,7 +38,6 @@ import ca.uhn.fhir.util.BeanUtils; public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChildDefinition { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseRuntimeDeclaredChildDefinition.class); - private Boolean ourUseMethodAccessors; private final IAccessor myAccessor; private final String myElementName; private final Field myField; @@ -47,6 +46,7 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil private final int myMin; private final IMutator myMutator; private final String myShortDefinition; + private Boolean ourUseMethodAccessors; BaseRuntimeDeclaredChildDefinition(Field theField, Child theChildAnnotation, Description theDescriptionAnnotation, String theElementName) throws ConfigurationException { super(); @@ -197,11 +197,43 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil } } - protected final class FieldPlainMutator implements IMutator { + private final class FieldListAccessor implements IAccessor { + @SuppressWarnings("unchecked") + @Override + public List getValues(Object theTarget) { + List retVal; + try { + retVal = (List) myField.get(theTarget); + } catch (IllegalArgumentException e) { + throw new ConfigurationException("Failed to get value", e); + } catch (IllegalAccessException e) { + throw new ConfigurationException("Failed to get value", e); + } + if (retVal == null) { + retVal = Collections.emptyList(); + } + return retVal; + } + } + + protected final class FieldListMutator implements IMutator { @Override public void addValue(Object theTarget, IBase theValue) { + addValue(theTarget, theValue, false); + } + + private void addValue(Object theTarget, IBase theValue, boolean theClear) { try { - myField.set(theTarget, theValue); + @SuppressWarnings("unchecked") + List existingList = (List) myField.get(theTarget); + if (existingList == null) { + existingList = new ArrayList(2); + myField.set(theTarget, existingList); + } + if (theClear) { + existingList.clear(); + } + existingList.add(theValue); } catch (IllegalArgumentException e) { throw new ConfigurationException("Failed to set value", e); } catch (IllegalAccessException e) { @@ -211,7 +243,7 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil @Override public void setValue(Object theTarget, IBase theValue) { - addValue(theTarget, theValue); + addValue(theTarget, theValue, true); } } @@ -233,53 +265,21 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil } } - protected final class FieldListMutator implements IMutator { + protected final class FieldPlainMutator implements IMutator { @Override public void addValue(Object theTarget, IBase theValue) { - addValue(theTarget, theValue, false); + try { + myField.set(theTarget, theValue); + } catch (IllegalArgumentException e) { + throw new ConfigurationException("Failed to set value", e); + } catch (IllegalAccessException e) { + throw new ConfigurationException("Failed to set value", e); + } } @Override public void setValue(Object theTarget, IBase theValue) { - addValue(theTarget, theValue, true); - } - - private void addValue(Object theTarget, IBase theValue, boolean theClear) { - try { - @SuppressWarnings("unchecked") - List existingList = (List) myField.get(theTarget); - if (existingList == null) { - existingList = new ArrayList(2); - myField.set(theTarget, existingList); - } - if (theClear) { - existingList.clear(); - } - existingList.add(theValue); - } catch (IllegalArgumentException e) { - throw new ConfigurationException("Failed to set value", e); - } catch (IllegalAccessException e) { - throw new ConfigurationException("Failed to set value", e); - } - } - } - - private final class FieldListAccessor implements IAccessor { - @SuppressWarnings("unchecked") - @Override - public List getValues(Object theTarget) { - List retVal; - try { - retVal = (List) myField.get(theTarget); - } catch (IllegalArgumentException e) { - throw new ConfigurationException("Failed to get value", e); - } catch (IllegalAccessException e) { - throw new ConfigurationException("Failed to get value", e); - } - if (retVal == null) { - retVal = Collections.emptyList(); - } - return retVal; + addValue(theTarget, theValue); } } @@ -312,11 +312,6 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil myMutatorMethod = theMutator; } - @Override - public void addValue(Object theTarget, IBase theValue) { - addValue(theTarget, false, theValue); - } - private void addValue(Object theTarget, boolean theClear, IBase theValue) { List existingList = myAccessor.getValues(theTarget); if (existingList == null) { @@ -337,6 +332,11 @@ public abstract class BaseRuntimeDeclaredChildDefinition extends BaseRuntimeChil existingList.add(theValue); } + @Override + public void addValue(Object theTarget, IBase theValue) { + addValue(theTarget, false, theValue); + } + @Override public void setValue(Object theTarget, IBase theValue) { addValue(theTarget, true, theValue); diff --git a/hapi-fhir-cobertura/pom.xml b/hapi-fhir-cobertura/pom.xml index 09cf787c5ab..124e7f9dcba 100644 --- a/hapi-fhir-cobertura/pom.xml +++ b/hapi-fhir-cobertura/pom.xml @@ -371,7 +371,7 @@ - + org.apache.maven.plugins maven-project-info-reports-plugin @@ -391,20 +391,6 @@ true - - org.apache.maven.plugins - maven-checkstyle-plugin - - - - checkstyle - - - - - false - - diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderMultiVersionTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderMultiVersionTest.java index 7a5673a01cd..0db899efb0a 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderMultiVersionTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderMultiVersionTest.java @@ -16,6 +16,11 @@ import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.dao.BaseJpaTest; import ca.uhn.fhir.jpa.testutil.RandomServerPortProvider; import ca.uhn.fhir.model.api.Bundle; +import ca.uhn.fhir.model.api.Include; +import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt; +import ca.uhn.fhir.model.dstu.resource.AdverseReaction; +import ca.uhn.fhir.model.dstu.resource.AllergyIntolerance; +import ca.uhn.fhir.model.dstu.resource.BaseResource; import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.model.dstu.valueset.AdministrativeGenderCodesEnum; import ca.uhn.fhir.model.dstu2.resource.PaymentNotice; @@ -118,6 +123,20 @@ public class ResourceProviderMultiVersionTest extends BaseJpaTest { assertEquals(ca.uhn.fhir.model.dstu.resource.Patient.class, history.getEntries().get(0).getResource().getClass()); } + @Test + public void testUnknownResourceType2() { + AdverseReaction ar = new AdverseReaction(); + ar.addIdentifier("FOO", "BAR"); + + AllergyIntolerance ai = new AllergyIntolerance(); + ai.addReaction().setResource(ar); + IdDt id = ourClientDstu2.create().resource(ai).execute().getId().toUnqualifiedVersionless(); + + ourClientDstu2.search().forResource(AllergyIntolerance.class.getSimpleName()) + .where(BaseResource.RES_ID.matches().value(id.getIdPart())) + .include(new Include("*")).execute(); + } + @SuppressWarnings("unchecked") @BeforeClass diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/resources/META-INF/fhirtest_persistence.xml b/hapi-fhir-jpaserver-uhnfhirtest/src/main/resources/META-INF/fhirtest_persistence.xml index 7590c543962..e4a910ca433 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/resources/META-INF/fhirtest_persistence.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/resources/META-INF/fhirtest_persistence.xml @@ -22,25 +22,14 @@ true - - - diff --git a/hapi-tinder-plugin/src/test/resources/tmp.txt b/hapi-tinder-plugin/src/test/resources/tmp.txt deleted file mode 100644 index 05c5524e346..00000000000 --- a/hapi-tinder-plugin/src/test/resources/tmp.txt +++ /dev/null @@ -1,484 +0,0 @@ - - - - -
-
<
        
-        
          
-          Query
         xmlns="http://hl7.org/fhir"> 
        
-        
          
-          
            
-            doco
          
        
 <!-- from 
        
-        Resource: 
        
-        extension, 
        
-        modifierExtension, language, 
        
-        text, and 
        
-        contained -->
 <
        
-        
          
-          identifier
         value="[
        
-        
          
-          uri
        ]"/>
        
-        <!-- 
        
-        
          
-          1..1
         
        
-        Links query and its response(s)
        
-         -->
 <
        
-        
          
-          parameter
        >
        
-        <!-- 
        
-        
          
-          1..*
         
        
-        
          
-          Extension
         
        
-        Set of query parameters with values
        
-         --></parameter>
 <
        
-        
          
-          response
        >  
        
-        <!-- 
          
-          
            
-            0..1
           If this is a response to a query -->
  <
        
-        
          
-          identifier
         value="[
        
-        
          
-          uri
        ]"/>
        
-        <!-- 
        
-        
          
-          1..1
         
        
-        Links response to source query
        
-         -->
  <
        
-        
          
-          outcome
         value="[
        
-        
          
-          code
        ]"/>
        
-        <!-- 
        
-        
          
-          1..1
         
        
-        
          
-          ok | limited | refused | error
        
        
-         -->
  <
        
-        
          
-          total
         value="[
        
-        
          
-          integer
        ]"/>
        
-        <!-- 
        
-        
          
-          0..1
         
        
-        Total number of matching records
        
-         -->
  <
        
-        
          
-          parameter
        >
        
-        <!-- 
        
-        
          
-          0..*
         
        
-        
          
-          Extension
         
        
-        Parameters server used
        
-         --></parameter>
  <
        
-        
          
-          first
        >
        
-        <!-- 
        
-        
          
-          0..*
         
        
-        
          
-          Extension
         
        
-        To get first page (if paged)
        
-         --></first>
  <
        
-        
          
-          previous
        >
        
-        <!-- 
        
-        
          
-          0..*
         
        
-        
          
-          Extension
         
        
-        To get previous page (if paged)
        
-         --></previous>
  <
        
-        
          
-          next
        >
        
-        <!-- 
        
-        
          
-          0..*
         
        
-        
          
-          Extension
         
        
-        To get next page (if paged)
        
-         --></next>
  <
        
-        
          
-          last
        >
        
-        <!-- 
        
-        
          
-          0..*
         
        
-        
          
-          Extension
         
        
-        To get last page (if paged)
        
-         --></last>
  <
        
-        
          
-          reference
        >
        
-        <!-- 
        
-        
          
-          0..*
         
        
-        
          
-          Resource(
          
-          Any) 
        
-        Resources that are the results of the search
        
-         --></reference>
 </response>
</Query>
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/pom.xml b/pom.xml index 7a02b0dbfe3..eb42fc32745 100644 --- a/pom.xml +++ b/pom.xml @@ -454,7 +454,7 @@ - src/checkstyle/checkstyle.xml + file://${project.basedir}/src/checkstyle/checkstyle.xml @@ -516,7 +516,7 @@ - + Fixing Checkstyle Report