Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ public class KMFileManager {
@Transient
@Expose
private Integer categoryID;
@Transient

@Column(name = "SubCategoryID")
@Expose
private Integer subCategoryID;
@Transient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,9 @@ ArrayList<KMFileManager> getKMFileLists(@Param("providerServiceMapID") Integer p
@Query("select kmFileManager.fileName, kmFileManager.fileExtension from KMFileManager kmFileManager "
+ "where kmFileManager.fileUID = :fileUID")
List<Object[]> getFileNameByUID(@Param("fileUID") String fileUID);


@Query("SELECT km FROM KMFileManager km WHERE km.subCategoryID = :subCategoryID AND km.deleted = false")
List<KMFileManager> getFilesBySubCategoryID(@Param("subCategoryID") Integer subCategoryID);

}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public String addKMFile(String request) throws IOException, NoSuchAlgorithmExcep
return kmFileManagers.toString();
}


private ArrayList<KMFileManager> addKMFile(Iterable<KMFileManager> kmFileManagers)
throws IOException, NoSuchAlgorithmException {
ArrayList<KMFileManager> savedFileManagers = new ArrayList<KMFileManager>();
Expand Down Expand Up @@ -175,6 +176,9 @@ private ArrayList<KMFileManager> addKMFile(Iterable<KMFileManager> kmFileManager
if (uuid != null) {
kmFileManager.setKmUploadStatus(KM_UPLOADSTATUS_COMPLETED);
kmFileManager.setFileUID(uuid);

kmFileManager.setSubCategoryID(kmFileManager.getSubCategoryID());

savedFileManagers.add(kmFileManagerRepository.save(kmFileManager));
if (kmFileManager.getSubCategoryID() != null) {
updateSubcategoryFilePath(kmFileManager);
Expand All @@ -197,6 +201,7 @@ private ArrayList<KMFileManager> addKMFile(Iterable<KMFileManager> kmFileManager
return savedFileManagers;
}


private void updateSubcategoryFilePath(KMFileManager kmFileManager) {
subCategoryRepository.updateFilePath(kmFileManager.getSubCategoryID(), kmFileManager.getFileUID());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import com.iemr.common.utils.exception.IEMRException;
import com.iemr.common.utils.mapper.InputMapper;
import com.iemr.common.data.common.DocFileManager;
import com.iemr.common.data.kmfilemanager.KMFileManager;

@Service
@PropertySource("classpath:/application.properties")
Expand Down Expand Up @@ -133,29 +134,45 @@ public Iterable<CategoryDetails> getCategories() {
return categoriesList;
}


//newChange
@Override
public Iterable<SubCategoryDetails> getSubCategories(String request) throws IEMRException, JsonMappingException, JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
SubCategoryDetails subCategoryDetails = objectMapper.readValue(request, SubCategoryDetails.class);
List<SubCategoryDetails> subCategoriesList = new ArrayList<SubCategoryDetails>();
ArrayList<Object[]> lists = subCategoryRepository.findByCategoryID(subCategoryDetails.getCategoryID());
for (Object[] objects : lists) {
if (objects != null && objects.length > 1) {
String SubCatFilePath = (String) objects[2];
String fileUIDAsURI = null;
String fileNameWithExtension = null;
if(SubCatFilePath!=null) {
fileUIDAsURI=getFilePath(SubCatFilePath);
List<Object[]> fileNameList = kmFileManagerRepository.getFileNameByUID(SubCatFilePath);
Object[] fileobjects = fileNameList.get(0);
fileNameWithExtension= (String)fileobjects[0]+ (String) fileobjects[1];
}
subCategoriesList.add(new SubCategoryDetails((Integer) objects[0], (String) objects[1], SubCatFilePath, fileUIDAsURI, fileNameWithExtension));
}
}
return subCategoriesList;
ObjectMapper objectMapper = new ObjectMapper();
SubCategoryDetails subCategoryDetails = objectMapper.readValue(request, SubCategoryDetails.class);
List<SubCategoryDetails> subCategoriesList = new ArrayList<>();
ArrayList<Object[]> lists = subCategoryRepository.findByCategoryID(subCategoryDetails.getCategoryID());

for (Object[] objects : lists) {
if (objects != null && objects.length > 1) {
Integer subCatId = (Integer) objects[0];
String subCatName = (String) objects[1];

// Fetch all files under this subcategory from KMFileManager
List<KMFileManager> files = kmFileManagerRepository.getFilesBySubCategoryID(subCatId);
ArrayList<KMFileManager> fileList = new ArrayList<>(files);

String fileURL = null;
String fileNameWithExtension = null;

if (!fileList.isEmpty()) {
KMFileManager firstFile = fileList.get(0); // Just for representative file URL and name
fileURL = getFilePath(firstFile.getFileUID());
fileNameWithExtension = firstFile.getFileName() + firstFile.getFileExtension();
}

SubCategoryDetails subCategory = new SubCategoryDetails(subCatId, subCatName);
subCategory.setFileManger(fileList); // Attach all files here
subCategory.setFileURL(fileURL); // Representative file URL
subCategory.setFileNameWithExtension(fileNameWithExtension); // Representative file name+ext

subCategoriesList.add(subCategory);
}
}
return subCategoriesList;
}


private String getFilePath(String fileUID)
{
String fileUIDAsURI = null;
Expand Down
Loading