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 Long myResourcePid; 033 private final Date myDeletedAt; 034 private final PartitionablePartitionId myPartitionablePartitionId; 035 036 public JpaResourceLookup( 037 String theResourceType, 038 Long theResourcePid, 039 Date theDeletedAt, 040 PartitionablePartitionId thePartitionablePartitionId) { 041 myResourceType = theResourceType; 042 myResourcePid = theResourcePid; 043 myDeletedAt = theDeletedAt; 044 myPartitionablePartitionId = thePartitionablePartitionId; 045 } 046 047 @Override 048 public String getResourceType() { 049 return myResourceType; 050 } 051 052 @Override 053 public Date getDeleted() { 054 return myDeletedAt; 055 } 056 057 @Override 058 public JpaPid getPersistentId() { 059 JpaPid jpaPid = JpaPid.fromId(myResourcePid); 060 jpaPid.setPartitionablePartitionId(myPartitionablePartitionId); 061 062 return jpaPid; 063 } 064 065 @Override 066 public String toString() { 067 return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) 068 .append("resType", myResourceType) 069 .append("resPid", myResourcePid) 070 .append("deletedAt", myDeletedAt) 071 .append("partId", myPartitionablePartitionId) 072 .toString(); 073 } 074}