001package ca.uhn.fhir.jpa.bulk.export.api; 002 003/*- 004 * #%L 005 * HAPI FHIR Storage api 006 * %% 007 * Copyright (C) 2014 - 2022 Smile CDR, Inc. 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import ca.uhn.fhir.jpa.bulk.export.model.BulkExportJobStatusEnum; 024import ca.uhn.fhir.rest.api.server.RequestDetails; 025import ca.uhn.fhir.rest.api.server.bulk.BulkDataExportOptions; 026import org.hl7.fhir.instance.model.api.IIdType; 027 028import javax.transaction.Transactional; 029import java.util.ArrayList; 030import java.util.Date; 031import java.util.List; 032import java.util.Set; 033 034public interface IBulkDataExportSvc { 035 void buildExportFiles(); 036 037 @Transactional(value = Transactional.TxType.NEVER) 038 void purgeExpiredFiles(); 039 040 /** 041 * Deprecated - Use {@link #submitJob(BulkDataExportOptions, Boolean, RequestDetails)} instead 042 */ 043 @Deprecated 044 JobInfo submitJob(BulkDataExportOptions theBulkDataExportOptions); 045 046 JobInfo submitJob(BulkDataExportOptions theBulkDataExportOptions, Boolean useCache, RequestDetails theRequestDetails); 047 048 JobInfo getJobInfoOrThrowResourceNotFound(String theJobId); 049 050 /** 051 * Return a set of all resource types which contain search parameters which have Patient as a target. 052 */ 053 Set<String> getPatientCompartmentResources(); 054 055 void cancelAndPurgeAllJobs(); 056 057 class JobInfo { 058 private String myJobId; 059 private BulkExportJobStatusEnum myStatus; 060 private List<FileEntry> myFiles; 061 private String myRequest; 062 private Date myStatusTime; 063 private String myStatusMessage; 064 065 public String getRequest() { 066 return myRequest; 067 } 068 069 public void setRequest(String theRequest) { 070 myRequest = theRequest; 071 } 072 073 public Date getStatusTime() { 074 return myStatusTime; 075 } 076 077 public JobInfo setStatusTime(Date theStatusTime) { 078 myStatusTime = theStatusTime; 079 return this; 080 } 081 082 public String getJobId() { 083 return myJobId; 084 } 085 086 public JobInfo setJobId(String theJobId) { 087 myJobId = theJobId; 088 return this; 089 } 090 091 public List<FileEntry> getFiles() { 092 if (myFiles == null) { 093 myFiles = new ArrayList<>(); 094 } 095 return myFiles; 096 097 } 098 099 public BulkExportJobStatusEnum getStatus() { 100 return myStatus; 101 } 102 103 public JobInfo setStatus(BulkExportJobStatusEnum theStatus) { 104 myStatus = theStatus; 105 return this; 106 } 107 108 public String getStatusMessage() { 109 return myStatusMessage; 110 } 111 112 public JobInfo setStatusMessage(String theStatusMessage) { 113 myStatusMessage = theStatusMessage; 114 return this; 115 } 116 117 public FileEntry addFile() { 118 FileEntry retVal = new FileEntry(); 119 getFiles().add(retVal); 120 return retVal; 121 } 122 } 123 124 125 class FileEntry { 126 private String myResourceType; 127 private IIdType myResourceId; 128 129 public String getResourceType() { 130 return myResourceType; 131 } 132 133 public FileEntry setResourceType(String theResourceType) { 134 myResourceType = theResourceType; 135 return this; 136 } 137 138 public IIdType getResourceId() { 139 return myResourceId; 140 } 141 142 public FileEntry setResourceId(IIdType theResourceId) { 143 myResourceId = theResourceId; 144 return this; 145 } 146 } 147 148 149 150}