当前位置: 首页>>代码示例>>Java>>正文


Java IdDt.hasVersionIdPart方法代码示例

本文整理汇总了Java中ca.uhn.fhir.model.primitive.IdDt.hasVersionIdPart方法的典型用法代码示例。如果您正苦于以下问题:Java IdDt.hasVersionIdPart方法的具体用法?Java IdDt.hasVersionIdPart怎么用?Java IdDt.hasVersionIdPart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca.uhn.fhir.model.primitive.IdDt的用法示例。


在下文中一共展示了IdDt.hasVersionIdPart方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readOrVread

import ca.uhn.fhir.model.primitive.IdDt; //导入方法依赖的package包/类
@Read(version=true)
public Patient readOrVread(@IdParam IdDt theId) {
   Patient retVal = new Patient();

   if (theId.hasVersionIdPart()) {
      // this is a vread   
   } else {
      // this is a read
   }

   // ...populate...
   
   return retVal;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:15,代码来源:RestfulPatientResourceProviderMore.java

示例2: vread

import ca.uhn.fhir.model.primitive.IdDt; //导入方法依赖的package包/类
@Override
public <T extends IBaseResource> T vread(final Class<T> theType, IdDt theId) {
	if (theId.hasVersionIdPart() == false) {
		throw new IllegalArgumentException(myContext.getLocalizer().getMessage(I18N_NO_VERSION_ID_FOR_VREAD, theId.getValue()));
	}
	return doReadOrVRead(theType, theId, true, null, null);
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:8,代码来源:GenericClient.java

示例3: createUpdateInvocation

import ca.uhn.fhir.model.primitive.IdDt; //导入方法依赖的package包/类
public static HttpPutClientInvocation createUpdateInvocation(IResource theResource, String theResourceBody, IdDt theId, FhirContext theContext) {
	String resourceName = theContext.getResourceDefinition(theResource).getName();
	StringBuilder urlBuilder = new StringBuilder();
	urlBuilder.append(resourceName);
	urlBuilder.append('/');
	urlBuilder.append(theId.getIdPart());
	String urlExtension = urlBuilder.toString();

	HttpPutClientInvocation retVal;
	if (StringUtils.isBlank(theResourceBody)) {
		retVal = new HttpPutClientInvocation(theContext, theResource, urlExtension);
	} else {
		retVal = new HttpPutClientInvocation(theContext, theResourceBody, false, urlExtension);
	}

	if (theId.hasVersionIdPart()) {
		if (theContext.getVersion().getVersion().isNewerThan(FhirVersionEnum.DSTU1)) {
			retVal.addHeader(Constants.HEADER_IF_MATCH, '"' + theId.getVersionIdPart() + '"');
		} else {
			String versionId = theId.getVersionIdPart();
			if (StringUtils.isNotBlank(versionId)) {
				urlBuilder.append('/');
				urlBuilder.append(Constants.PARAM_HISTORY);
				urlBuilder.append('/');
				urlBuilder.append(versionId);
				retVal.addHeader(Constants.HEADER_CONTENT_LOCATION, urlBuilder.toString());
			}
		}
	}

	addTagsToPostOrPut(theResource, retVal);
	// addContentTypeHeaderBasedOnDetectedType(retVal, theResourceBody);

	return retVal;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:36,代码来源:MethodUtil.java

示例4: readPatient

import ca.uhn.fhir.model.primitive.IdDt; //导入方法依赖的package包/类
/**
 * This is the "read" operation. The "@Read" annotation indicates that this method supports the read and/or vread operation.
 * <p>
 * Read operations take a single parameter annotated with the {@link IdParam} paramater, and should return a single resource instance.
 * </p>
 * 
 * @param theId
 *            The read operation takes one parameter, which must be of type IdDt and must be annotated with the "@Read.IdParam" annotation.
 * @return Returns a resource matching this identifier, or null if none exists.
 */
@Read(version = true)
public Patient readPatient(@IdParam IdDt theId) {
	Deque<Patient> retVal;
	try {
		retVal = myIdToPatientVersions.get(theId.getIdPartAsLong());
	} catch (NumberFormatException e) {
		/*
		 * If we can't parse the ID as a long, it's not valid so this is an unknown resource
		 */
		throw new ResourceNotFoundException(theId);
	}

	if (theId.hasVersionIdPart() == false) {
		return retVal.getLast();
	} else {
		for (Patient nextVersion : retVal) {
			String nextVersionId = nextVersion.getId().getVersionIdPart();
			if (theId.getVersionIdPart().equals(nextVersionId)) {
				return nextVersion;
			}
		}
		// No matching version
		throw new ResourceNotFoundException("Unknown version: " + theId.getValue());
	}

}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:37,代码来源:PatientResourceProvider.java

示例5: delete

import ca.uhn.fhir.model.primitive.IdDt; //导入方法依赖的package包/类
@Override
public DaoMethodOutcome delete(IdDt theId) {
	StopWatch w = new StopWatch();
	final ResourceTable entity = readEntityLatestVersion(theId);
	if (theId.hasVersionIdPart() && theId.getVersionIdPartAsLong().longValue() != entity.getVersion()) {
		throw new InvalidRequestException("Trying to update " + theId + " but this is not the current version");
	}

	ResourceTable savedEntity = updateEntity(null, entity, true, new Date());

	notifyWriteCompleted();

	ourLog.info("Processed delete on {} in {}ms", theId.getValue(), w.getMillisAndRestart());
	return toMethodOutcome(savedEntity, null);
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:16,代码来源:BaseFhirResourceDao.java

示例6: readEntity

import ca.uhn.fhir.model.primitive.IdDt; //导入方法依赖的package包/类
@Override
public BaseHasResource readEntity(IdDt theId, boolean theCheckForForcedId) {
	validateResourceTypeAndThrowIllegalArgumentException(theId);

	Long pid = translateForcedIdToPid(theId);
	BaseHasResource entity = myEntityManager.find(ResourceTable.class, pid);
	if (theId.hasVersionIdPart()) {
		if (entity.getVersion() != theId.getVersionIdPartAsLong()) {
			entity = null;
		}
	}

	if (entity == null) {
		if (theId.hasVersionIdPart()) {
			TypedQuery<ResourceHistoryTable> q = myEntityManager.createQuery(
					"SELECT t from ResourceHistoryTable t WHERE t.myResourceId = :RID AND t.myResourceType = :RTYP AND t.myResourceVersion = :RVER", ResourceHistoryTable.class);
			q.setParameter("RID", pid);
			q.setParameter("RTYP", myResourceName);
			q.setParameter("RVER", theId.getVersionIdPartAsLong());
			entity = q.getSingleResult();
		}
		if (entity == null) {
			throw new ResourceNotFoundException(theId);
		}
	}

	validateResourceType(entity);

	if (theCheckForForcedId) {
		validateGivenIdIsAppropriateToRetrieveResource(theId, entity);
	}
	return entity;
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:34,代码来源:BaseFhirResourceDao.java

示例7: update

import ca.uhn.fhir.model.primitive.IdDt; //导入方法依赖的package包/类
@Override
public DaoMethodOutcome update(T theResource, String theMatchUrl, boolean thePerformIndexing) {
	StopWatch w = new StopWatch();

	final ResourceTable entity;

	IdDt resourceId;
	if (isNotBlank(theMatchUrl)) {
		Set<Long> match = processMatchUrl(theMatchUrl, myResourceType);
		if (match.size() > 1) {
			String msg = getContext().getLocalizer().getMessage(BaseFhirDao.class, "transactionOperationWithMultipleMatchFailure", "UPDATE", theMatchUrl, match.size());
			throw new PreconditionFailedException(msg);
		} else if (match.size() == 1) {
			Long pid = match.iterator().next();
			entity = myEntityManager.find(ResourceTable.class, pid);
			resourceId = entity.getIdDt();
		} else {
			return create(theResource);
		}
	} else {
		resourceId = theResource.getId();
		if (resourceId == null || isBlank(resourceId.getIdPart())) {
			throw new InvalidRequestException("Can not update a resource with no ID");
		}
		try {
			entity = readEntityLatestVersion(resourceId);
		} catch (ResourceNotFoundException e) {
			if (Character.isDigit(theResource.getId().getIdPart().charAt(0))) {
				throw new InvalidRequestException(getContext().getLocalizer().getMessage(BaseFhirResourceDao.class, "failedToCreateWithClientAssignedNumericId", theResource.getId().getIdPart()));
			}
			return doCreate(theResource, null, thePerformIndexing);
		}
	}

	if (resourceId.hasVersionIdPart() && resourceId.getVersionIdPartAsLong().longValue() != entity.getVersion()) {
		throw new InvalidRequestException("Trying to update " + resourceId + " but this is not the current version");
	}

	ResourceTable savedEntity = updateEntity(theResource, entity, true, null, thePerformIndexing, true);

	notifyWriteCompleted();
	ourLog.info("Processed update on {} in {}ms", resourceId, w.getMillisAndRestart());
	return toMethodOutcome(savedEntity, theResource).setCreated(false);
}
 
开发者ID:gajen0981,项目名称:FHIR-Server,代码行数:45,代码来源:BaseFhirResourceDao.java


注:本文中的ca.uhn.fhir.model.primitive.IdDt.hasVersionIdPart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。