Try to get coverage report working

This commit is contained in:
James Agnew 2017-07-30 20:56:10 -04:00
parent 72b88849b3
commit 1ae37b0db3
6 changed files with 67 additions and 84 deletions

View File

@ -3,7 +3,6 @@ package ca.uhn.fhir.jpa.dao;
import java.util.Collection;
import java.util.Set;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.FhirContext;
@ -12,7 +11,6 @@ import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.jpa.entity.BaseHasResource;
import ca.uhn.fhir.jpa.entity.ResourceTable;
import ca.uhn.fhir.jpa.search.PersistedJpaBundleProvider;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum.ResourceMetadataKeySupportingAnyResource;
/*
@ -37,30 +35,7 @@ import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum.ResourceMetadataKeySupporti
public interface IDao {
public static final ResourceMetadataKeySupportingAnyResource<Long, Long> RESOURCE_PID = new ResourceMetadataKeySupportingAnyResource<Long, Long>("RESOURCE_PID") {
private static final long serialVersionUID = 1L;
@Override
public Long get(IAnyResource theResource) {
return (Long) theResource.getUserData(RESOURCE_PID.name());
}
@Override
public Long get(IResource theResource) {
return (Long) theResource.getResourceMetadata().get(RESOURCE_PID);
}
@Override
public void put(IAnyResource theResource, Long theObject) {
theResource.setUserData(RESOURCE_PID.name(), theObject);
}
@Override
public void put(IResource theResource, Long theObject) {
theResource.getResourceMetadata().put(RESOURCE_PID, theObject);
}
};
public static final ResourceMetadataKeySupportingAnyResource<Long, Long> RESOURCE_PID = new MetadataKeyResourcePid("RESOURCE_PID");
FhirContext getContext();

View File

@ -0,0 +1,34 @@
package ca.uhn.fhir.jpa.dao;
import org.hl7.fhir.instance.model.api.IAnyResource;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum.ResourceMetadataKeySupportingAnyResource;
final class MetadataKeyResourcePid extends ResourceMetadataKeySupportingAnyResource<Long, Long> {
private static final long serialVersionUID = 1L;
MetadataKeyResourcePid(String theValue) {
super(theValue);
}
@Override
public Long get(IAnyResource theResource) {
return (Long) theResource.getUserData(IDao.RESOURCE_PID.name());
}
@Override
public Long get(IResource theResource) {
return (Long) theResource.getResourceMetadata().get(IDao.RESOURCE_PID);
}
@Override
public void put(IAnyResource theResource, Long theObject) {
theResource.setUserData(IDao.RESOURCE_PID.name(), theObject);
}
@Override
public void put(IResource theResource, Long theObject) {
theResource.getResourceMetadata().put(IDao.RESOURCE_PID, theObject);
}
}

View File

@ -0,0 +1,25 @@
package ca.uhn.fhir.jpa.util;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.util.CoverageIgnore;
final class AllowStatusChangeMetadata extends ResourceMetadataKeyEnum<Object> {
private static final long serialVersionUID = 1;
AllowStatusChangeMetadata(String theValue) {
super(theValue);
}
@CoverageIgnore
@Override
public Object get(IResource theResource) {
throw new UnsupportedOperationException();
}
@CoverageIgnore
@Override
public void put(IResource theResource, Object theObject) {
throw new UnsupportedOperationException();
}
}

View File

@ -28,7 +28,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
import ca.uhn.fhir.jpa.dao.FhirResourceDaoSubscriptionDstu2;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.model.dstu2.resource.Subscription;
import ca.uhn.fhir.model.dstu2.valueset.SubscriptionChannelTypeEnum;
@ -37,8 +36,6 @@ import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import ca.uhn.fhir.util.CoverageIgnore;
/**
* Interceptor which requires newly created {@link Subscription subscriptions} to be in
@ -46,21 +43,7 @@ import ca.uhn.fhir.util.CoverageIgnore;
*/
public class SubscriptionsRequireManualActivationInterceptorDstu2 extends InterceptorAdapter {
public static final ResourceMetadataKeyEnum<Object> ALLOW_STATUS_CHANGE = new ResourceMetadataKeyEnum<Object>(FhirResourceDaoSubscriptionDstu2.class.getName() + "_ALLOW_STATUS_CHANGE") {
private static final long serialVersionUID = 1;
@CoverageIgnore
@Override
public Object get(IResource theResource) {
throw new UnsupportedOperationException();
}
@CoverageIgnore
@Override
public void put(IResource theResource, Object theObject) {
throw new UnsupportedOperationException();
}
};
public static final ResourceMetadataKeyEnum<Object> ALLOW_STATUS_CHANGE = new AllowStatusChangeMetadata(FhirResourceDaoSubscriptionDstu2.class.getName() + "_ALLOW_STATUS_CHANGE");
@Autowired
@Qualifier("mySubscriptionDaoDstu2")

View File

@ -32,13 +32,11 @@ import org.springframework.beans.factory.annotation.Qualifier;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.dstu3.FhirResourceDaoSubscriptionDstu3;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter;
import ca.uhn.fhir.util.CoverageIgnore;
/**
* Interceptor which requires newly created {@link Subscription subscriptions} to be in
@ -46,21 +44,7 @@ import ca.uhn.fhir.util.CoverageIgnore;
*/
public class SubscriptionsRequireManualActivationInterceptorDstu3 extends InterceptorAdapter {
public static final ResourceMetadataKeyEnum<Object> ALLOW_STATUS_CHANGE = new ResourceMetadataKeyEnum<Object>(FhirResourceDaoSubscriptionDstu3.class.getName() + "_ALLOW_STATUS_CHANGE") {
private static final long serialVersionUID = 1;
@CoverageIgnore
@Override
public Object get(IResource theResource) {
throw new UnsupportedOperationException();
}
@CoverageIgnore
@Override
public void put(IResource theResource, Object theObject) {
throw new UnsupportedOperationException();
}
};
public static final ResourceMetadataKeyEnum<Object> ALLOW_STATUS_CHANGE = new AllowStatusChangeMetadata(FhirResourceDaoSubscriptionDstu3.class.getName() + "_ALLOW_STATUS_CHANGE");
@Autowired
@Qualifier("mySubscriptionDaoDstu3")

View File

@ -2,10 +2,6 @@ package ca.uhn.fhir.jpa.util;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import org.hl7.fhir.r4.model.Subscription;
import org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType;
import org.hl7.fhir.r4.model.Subscription.SubscriptionStatus;
/*
* #%L
* HAPI FHIR JPA Server
@ -27,18 +23,19 @@ import org.hl7.fhir.r4.model.Subscription.SubscriptionStatus;
*/
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.Subscription;
import org.hl7.fhir.r4.model.Subscription.SubscriptionChannelType;
import org.hl7.fhir.r4.model.Subscription.SubscriptionStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.r4.FhirResourceDaoSubscriptionR4;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.rest.server.interceptor.InterceptorAdapter;
import ca.uhn.fhir.util.CoverageIgnore;
/**
* Interceptor which requires newly created {@link Subscription subscriptions} to be in
@ -46,22 +43,7 @@ import ca.uhn.fhir.util.CoverageIgnore;
*/
public class SubscriptionsRequireManualActivationInterceptorR4 extends InterceptorAdapter {
public static final ResourceMetadataKeyEnum<Object> ALLOW_STATUS_CHANGE = new ResourceMetadataKeyEnum<Object>(FhirResourceDaoSubscriptionR4.class.getName() + "_ALLOW_STATUS_CHANGE") {
private static final long serialVersionUID = 1;
@CoverageIgnore
@Override
public Object get(IResource theResource) {
throw new UnsupportedOperationException();
}
@CoverageIgnore
@Override
public void put(IResource theResource, Object theObject) {
throw new UnsupportedOperationException();
}
};
public static final ResourceMetadataKeyEnum<Object> ALLOW_STATUS_CHANGE = new AllowStatusChangeMetadata(FhirResourceDaoSubscriptionR4.class.getName() + "_ALLOW_STATUS_CHANGE");
@Autowired
@Qualifier("mySubscriptionDaoR4")
private IFhirResourceDao<Subscription> myDao;