001/*- 002 * #%L 003 * HAPI FHIR JPA Server 004 * %% 005 * Copyright (C) 2014 - 2024 Smile CDR, Inc. 006 * %% 007 * Licensed under the Apache License, Version 2.0 (the "License"); 008 * you may not use this file except in compliance with the License. 009 * You may obtain a copy of the License at 010 * 011 * http://www.apache.org/licenses/LICENSE-2.0 012 * 013 * Unless required by applicable law or agreed to in writing, software 014 * distributed under the License is distributed on an "AS IS" BASIS, 015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 016 * See the License for the specific language governing permissions and 017 * limitations under the License. 018 * #L% 019 */ 020package ca.uhn.fhir.jpa.model.cross; 021 022import ca.uhn.fhir.jpa.model.dao.JpaPid; 023import ca.uhn.fhir.jpa.model.entity.PartitionablePartitionId; 024import org.apache.commons.lang3.builder.ToStringBuilder; 025import org.apache.commons.lang3.builder.ToStringStyle; 026 027import java.util.Date; 028 029public class JpaResourceLookup implements IResourceLookup<JpaPid> { 030 031 private final String myResourceType; 032 private final JpaPid myResourcePid; 033 private final Date myDeletedAt; 034 private final PartitionablePartitionId myPartitionablePartitionId; 035 private final String myFhirId; 036 037 public JpaResourceLookup( 038 String theResourceType, 039 String theFhirId, 040 Long theResourcePid, 041 Date theDeletedAt, 042 PartitionablePartitionId thePartitionablePartitionId) { 043 myResourceType = theResourceType; 044 myFhirId = theFhirId; 045 myDeletedAt = theDeletedAt; 046 myPartitionablePartitionId = thePartitionablePartitionId; 047 048 myResourcePid = JpaPid.fromId(theResourcePid); 049 myResourcePid.setPartitionablePartitionId(myPartitionablePartitionId); 050 } 051 052 public JpaResourceLookup( 053 String theResourceType, 054 String theFhirId, 055 JpaPid theResourcePid, 056 Date theDeletedAt, 057 PartitionablePartitionId thePartitionablePartitionId) { 058 myResourceType = theResourceType; 059 myFhirId = theFhirId; 060 myResourcePid = theResourcePid; 061 myDeletedAt = theDeletedAt; 062 myPartitionablePartitionId = thePartitionablePartitionId; 063 } 064 065 @Override 066 public String getResourceType() { 067 return myResourceType; 068 } 069 070 @Override 071 public String getFhirId() { 072 return myFhirId; 073 } 074 075 @Override 076 public Date getDeleted() { 077 return myDeletedAt; 078 } 079 080 @Override 081 public JpaPid getPersistentId() { 082 return myResourcePid; 083 } 084 085 @Override 086 public String toString() { 087 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) 088 .append("resType", myResourceType) 089 .append("resPid", myResourcePid) 090 .append("deletedAt", myDeletedAt) 091 .append("partId", myPartitionablePartitionId) 092 .toString(); 093 } 094}