git repo delete functionality implemented
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.olympus.apollo.controllers.FeApi;
|
package com.olympus.apollo.controllers.FeApi;
|
||||||
|
|
||||||
|
import com.olympus.apollo.dto.DeleteGitRepoDetailsRequest;
|
||||||
import com.olympus.apollo.dto.DeletionRequest;
|
import com.olympus.apollo.dto.DeletionRequest;
|
||||||
import com.olympus.apollo.dto.VectorStoreDetails;
|
import com.olympus.apollo.dto.VectorStoreDetails;
|
||||||
import com.olympus.apollo.models.VectorStore;
|
import com.olympus.apollo.models.VectorStore;
|
||||||
@@ -49,4 +50,10 @@ public class VectorStoreController {
|
|||||||
return "Records Deleted Successfully";
|
return "Records Deleted Successfully";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/deleteGitRecords")
|
||||||
|
public String deleteGitRecords(@RequestBody DeleteGitRepoDetailsRequest deleteGitRepoDetailsRequest){
|
||||||
|
deletionService.deleteRecordsOfGitRepo(deleteGitRepoDetailsRequest);
|
||||||
|
return "Git Records Deleted Successfully";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.olympus.apollo.dto;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter @Setter
|
||||||
|
public class DeleteGitRepoDetailsRequest {
|
||||||
|
private String ksGitInfoId;
|
||||||
|
private String ksGitIngestionInfoId;
|
||||||
|
private String ksDoctype;
|
||||||
|
private String ksDocSource;
|
||||||
|
private String ksFileSource;
|
||||||
|
private String ksApplicationName;
|
||||||
|
}
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
package com.olympus.apollo.services;
|
package com.olympus.apollo.services;
|
||||||
|
|
||||||
|
import com.olympus.apollo.dto.DeleteGitRepoDetailsRequest;
|
||||||
|
import com.olympus.apollo.models.KSGitIngestionInfo;
|
||||||
|
import com.olympus.apollo.repository.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.olympus.apollo.dto.DeletionRequest;
|
import com.olympus.apollo.dto.DeletionRequest;
|
||||||
import com.olympus.apollo.dto.VectorStoreMetadataDetails;
|
import com.olympus.apollo.dto.VectorStoreMetadataDetails;
|
||||||
import com.olympus.apollo.models.VectorStore;
|
import com.olympus.apollo.models.VectorStore;
|
||||||
import com.olympus.apollo.repository.KSDocumentRepository;
|
|
||||||
import com.olympus.apollo.repository.KSIngestionInfoRepository;
|
|
||||||
import com.olympus.apollo.repository.VectorStoreRepository;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -25,6 +25,12 @@ public class DeletionService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private KSIngestionInfoRepository ksIngestionInfoRepository;
|
private KSIngestionInfoRepository ksIngestionInfoRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private KSGitIngestionInfoRepository ksGitIngestionInfoRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private KSGitInfoRepository ksGitInfoRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private VectorStoreRepository vectorStoreRepository;
|
private VectorStoreRepository vectorStoreRepository;
|
||||||
|
|
||||||
@@ -67,4 +73,47 @@ public class DeletionService {
|
|||||||
throw new RuntimeException("An error occurred while deleting records", e);
|
throw new RuntimeException("An error occurred while deleting records", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void deleteRecordsOfGitRepo(DeleteGitRepoDetailsRequest deleteGitRepoDetailsRequest) {
|
||||||
|
try {
|
||||||
|
boolean KSGitInfoExists = deleteGitRepoDetailsRequest.getKsGitInfoId() != null && !deleteGitRepoDetailsRequest.getKsGitInfoId().isEmpty() && ksGitInfoRepository.existsById(deleteGitRepoDetailsRequest.getKsGitInfoId());
|
||||||
|
logger.info("KSGitInfo with id {} exists.", deleteGitRepoDetailsRequest.getKsGitInfoId());
|
||||||
|
boolean KSGitIngestionInfoExists = deleteGitRepoDetailsRequest.getKsGitIngestionInfoId() != null && !deleteGitRepoDetailsRequest.getKsGitIngestionInfoId().isEmpty() && ksGitIngestionInfoRepository.existsById(deleteGitRepoDetailsRequest.getKsGitIngestionInfoId());
|
||||||
|
logger.info("KSGitIngestionInfo with id {} exists.", deleteGitRepoDetailsRequest.getKsGitIngestionInfoId());
|
||||||
|
boolean vectorStoreGitDetailsExists = deleteGitRepoDetailsRequest.getKsApplicationName() != null && deleteGitRepoDetailsRequest.getKsDocSource() != null && deleteGitRepoDetailsRequest.getKsFileSource() != null && deleteGitRepoDetailsRequest.getKsDoctype() != null;
|
||||||
|
logger.info("vectorStoreGitDetails records exists.");
|
||||||
|
|
||||||
|
List<VectorStore> vectorStoreMetadataDetails = vectorStoreGitDetailsExists ? vectorStoreRepository.findByMetadata(deleteGitRepoDetailsRequest.getKsDoctype(), deleteGitRepoDetailsRequest.getKsDocSource(), deleteGitRepoDetailsRequest.getKsFileSource(), deleteGitRepoDetailsRequest.getKsApplicationName()) : List.of();
|
||||||
|
|
||||||
|
if (KSGitInfoExists && KSGitIngestionInfoExists && !vectorStoreMetadataDetails.isEmpty()) {
|
||||||
|
if (deleteGitRepoDetailsRequest.getKsGitInfoId() != null && !deleteGitRepoDetailsRequest.getKsGitInfoId().isEmpty()) {
|
||||||
|
ksGitInfoRepository.deleteById(deleteGitRepoDetailsRequest.getKsGitInfoId());
|
||||||
|
logger.info("KsGitInfo with id {} deleted successfully.", deleteGitRepoDetailsRequest.getKsGitInfoId());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deleteGitRepoDetailsRequest.getKsGitIngestionInfoId() != null && !deleteGitRepoDetailsRequest.getKsGitIngestionInfoId().isEmpty()) {
|
||||||
|
ksGitIngestionInfoRepository.deleteById(deleteGitRepoDetailsRequest.getKsGitIngestionInfoId());
|
||||||
|
logger.info("KSGitIngestionInfo with id {} deleted successfully.", deleteGitRepoDetailsRequest.getKsGitIngestionInfoId());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (VectorStore store : vectorStoreMetadataDetails) {
|
||||||
|
vectorStoreRepository.deleteById(store.getId());
|
||||||
|
logger.info("VectorStore with id {} deleted successfully.", store.getId());
|
||||||
|
}
|
||||||
|
logger.info("All records deleted successfully.");
|
||||||
|
} else {
|
||||||
|
if (!KSGitInfoExists) {
|
||||||
|
logger.warn("getKsGitInfo with id {} does not exist.", deleteGitRepoDetailsRequest.getKsGitInfoId());
|
||||||
|
} else if (!KSGitIngestionInfoExists) {
|
||||||
|
logger.warn("KSGitIngestionInfo with id {} does not exist.", deleteGitRepoDetailsRequest.getKsGitIngestionInfoId());
|
||||||
|
} else if (vectorStoreMetadataDetails.isEmpty()) {
|
||||||
|
logger.warn("No VectorStore Data available");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("An error occurred while deleting records: ", e);
|
||||||
|
throw new RuntimeException("An error occurred while deleting records", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ public class StorageProperties {
|
|||||||
/**
|
/**
|
||||||
* Folder location for storing files
|
* Folder location for storing files
|
||||||
*/
|
*/
|
||||||
private String location = "C:\\Users\\vinayak.c.mishra\\dev\\olympus\\upload-dir";
|
private String location = "C:\\Users\\s.shamrao.shinde\\GenAIStorage";
|
||||||
//private String location = "C:\\WindTre\\Repository";
|
//private String location = "C:\\WindTre\\Repository";
|
||||||
public String getLocation() {
|
public String getLocation() {
|
||||||
return location;
|
return location;
|
||||||
|
|||||||
Reference in New Issue
Block a user