adding base Project

This commit is contained in:
Azmat-7860
2026-10-22 23:53:50 +05:30
commit af8edee8b1
718 changed files with 38983 additions and 0 deletions
@@ -0,0 +1,20 @@
package com.realnet.codeextractor.service;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.realnet.codeextractor.entity.Rn_Bcf_Exception_Rules;
public interface Rn_Bcf_Exception_Rule_Library_Service {
List<Rn_Bcf_Exception_Rules> getAll();
Page<Rn_Bcf_Exception_Rules> getAll(Pageable p);
Rn_Bcf_Exception_Rules getById(int id);
Rn_Bcf_Exception_Rules save(Rn_Bcf_Exception_Rules bcf_rule);
Rn_Bcf_Exception_Rules updateById(int id, Rn_Bcf_Exception_Rules bcf_rule);
boolean deleteById(int id);
List<Rn_Bcf_Exception_Rules> getByType(String tech_stack, String object_type, String sub_object_type);
}
@@ -0,0 +1,78 @@
package com.realnet.codeextractor.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import com.realnet.codeextractor.entity.Rn_Bcf_Exception_Rules;
import com.realnet.codeextractor.repository.Rn_Bcf_Exception_Rule_Library_Repository;
import com.realnet.exceptions.ResourceNotFoundException;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class Rn_Bcf_Exception_Rule_Library_ServiceImpl implements Rn_Bcf_Exception_Rule_Library_Service {
@Autowired
private Rn_Bcf_Exception_Rule_Library_Repository exceptionRuleLibraryRepository;
@Override
public List<Rn_Bcf_Exception_Rules> getAll() {
return exceptionRuleLibraryRepository.findAll();
}
@Override
public Page<Rn_Bcf_Exception_Rules> getAll(Pageable page) {
return exceptionRuleLibraryRepository.findAll(page);
}
@Override
public Rn_Bcf_Exception_Rules getById(int id) {
Rn_Bcf_Exception_Rules bcf_extractor = exceptionRuleLibraryRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Rule Not Found :: " + id));
return bcf_extractor;
}
@Override
public Rn_Bcf_Exception_Rules save(Rn_Bcf_Exception_Rules bcf_extractor) {
Rn_Bcf_Exception_Rules savedExtractor = exceptionRuleLibraryRepository.save(bcf_extractor);
return savedExtractor;
}
@Override
public Rn_Bcf_Exception_Rules updateById(int id, Rn_Bcf_Exception_Rules ruleRequest) {
Rn_Bcf_Exception_Rules old_extractor = exceptionRuleLibraryRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Exception Rule not found :: " + id));
old_extractor.setTech_stack(ruleRequest.getTech_stack());
old_extractor.setObject_type(ruleRequest.getObject_type());
old_extractor.setSub_object_type(ruleRequest.getSub_object_type());
old_extractor.setObject_name_variable(ruleRequest.getObject_name_variable());
old_extractor.setObject_name_dynamic_string(ruleRequest.getObject_name_dynamic_string());
final Rn_Bcf_Exception_Rules updated_rule = exceptionRuleLibraryRepository.save(old_extractor);
return updated_rule;
}
@Override
public boolean deleteById(int id) {
if (!exceptionRuleLibraryRepository.existsById(id)) {
throw new ResourceNotFoundException("Rule not exist");
}
Rn_Bcf_Exception_Rules rule = exceptionRuleLibraryRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Rule not found :: " + id));
exceptionRuleLibraryRepository.delete(rule);
return true;
}
@Override
public List<Rn_Bcf_Exception_Rules> getByType(String tech_stack, String object_type, String sub_object_type) {
return exceptionRuleLibraryRepository.findByType(tech_stack, object_type, sub_object_type);
}
}
@@ -0,0 +1,24 @@
package com.realnet.codeextractor.service;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.realnet.codeextractor.entity.Rn_Bcf_Extractor_Params;
public interface Rn_Bcf_Extractor_Params_Service {
List<Rn_Bcf_Extractor_Params> getAll();
Page<Rn_Bcf_Extractor_Params> getAll(Pageable p);
List<Rn_Bcf_Extractor_Params> getByHeaderId(int headerId);
List<Rn_Bcf_Extractor_Params> getByHeaderIdOrderByDate(int headerId);
Rn_Bcf_Extractor_Params getById(int id);
Rn_Bcf_Extractor_Params save(Rn_Bcf_Extractor_Params bcf_extractor_params);
Rn_Bcf_Extractor_Params updateById(int id, Rn_Bcf_Extractor_Params bcf_extractor_params);
boolean deleteById(int id);
}
@@ -0,0 +1,91 @@
package com.realnet.codeextractor.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import com.realnet.codeextractor.entity.Rn_Bcf_Extractor_Params;
import com.realnet.codeextractor.repository.Rn_Bcf_Extractor_Params_Repository;
import com.realnet.exceptions.ResourceNotFoundException;
import com.realnet.users.service1.AppUserService;
@Service
public class Rn_Bcf_Extractor_Params_ServiceImpl implements Rn_Bcf_Extractor_Params_Service {
@Autowired
private AppUserService userService;
@Autowired
private Rn_Bcf_Extractor_Params_Repository rn_bcf_extractor_params_repository;
@Override
public List<Rn_Bcf_Extractor_Params> getAll() {
return rn_bcf_extractor_params_repository.findAll();
}
@Override
public Page<Rn_Bcf_Extractor_Params> getAll(Pageable page) {
return rn_bcf_extractor_params_repository.findAll(page);
}
@Override
public Rn_Bcf_Extractor_Params getById(int id) {
Rn_Bcf_Extractor_Params bcf_extractor = rn_bcf_extractor_params_repository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Extractor Param Data Not Found :: " + id));
return bcf_extractor;
}
@Override
public Rn_Bcf_Extractor_Params save(Rn_Bcf_Extractor_Params bcf_extractor) {
Rn_Bcf_Extractor_Params savedExtractor = rn_bcf_extractor_params_repository.save(bcf_extractor);
return savedExtractor;
}
@Override
public Rn_Bcf_Extractor_Params updateById(int id, Rn_Bcf_Extractor_Params extractorParamsRequest) {
// User loggedInUser = userService.getLoggedInUser();
Rn_Bcf_Extractor_Params old_extractor = rn_bcf_extractor_params_repository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Menu not found :: " + id));
old_extractor.setTech_stack(extractorParamsRequest.getTech_stack());
old_extractor.setObject_type(extractorParamsRequest.getObject_type());
old_extractor.setSub_object_type(extractorParamsRequest.getSub_object_type());
old_extractor.setFile_code(extractorParamsRequest.getFile_code());
old_extractor.setName_string(extractorParamsRequest.getName_string());
old_extractor.setAddress_string(extractorParamsRequest.getAddress_string());
old_extractor.setMoved_address_string(extractorParamsRequest.getMoved_address_string());
old_extractor.setReference_address_string(extractorParamsRequest.getReference_address_string());
old_extractor.setDescription(extractorParamsRequest.getDescription());
old_extractor.setFile_name_var(extractorParamsRequest.getFile_name_var());
old_extractor.setFile_name_dynamic_string(extractorParamsRequest.getFile_name_dynamic_string());
old_extractor.setIs_extraction_enabled(extractorParamsRequest.isIs_extraction_enabled());
old_extractor.setIs_creation_enabled(extractorParamsRequest.isIs_creation_enabled());
old_extractor.setTotal_project_path_dynamic_string(extractorParamsRequest.getTotal_project_path_dynamic_string());
final Rn_Bcf_Extractor_Params updated_function = rn_bcf_extractor_params_repository.save(old_extractor);
return updated_function;
}
@Override
public boolean deleteById(int id) {
if (!rn_bcf_extractor_params_repository.existsById(id)) {
throw new ResourceNotFoundException("Extractor Data not exist");
}
Rn_Bcf_Extractor_Params bcf_extractor = rn_bcf_extractor_params_repository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Menu not found :: " + id));
rn_bcf_extractor_params_repository.delete(bcf_extractor);
return true;
}
@Override
public List<Rn_Bcf_Extractor_Params> getByHeaderId(int headerId) {
return rn_bcf_extractor_params_repository.findByHeaderId(headerId);
}
@Override
public List<Rn_Bcf_Extractor_Params> getByHeaderIdOrderByDate(int headerId) {
return rn_bcf_extractor_params_repository.findByHeaderIdOrderByDate(headerId);
}
}
@@ -0,0 +1,27 @@
package com.realnet.codeextractor.service;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.realnet.codeextractor.entity.Rn_Bcf_Extractor;
public interface Rn_Bcf_Extractor_Service {
List<Rn_Bcf_Extractor> getAll();
Page<Rn_Bcf_Extractor> getAll(Pageable p);
Rn_Bcf_Extractor getById(int id);
Rn_Bcf_Extractor save(Rn_Bcf_Extractor bcf_extractor);
Rn_Bcf_Extractor updateById(int id, Rn_Bcf_Extractor bcf_extractor);
boolean deleteById(int id);
public void saveListOFiles(int headerId, String tech_stack, String obj_type, String sub_obj_type, String destDirectory)
throws IOException;
public void moveFiles(int id, String toDir) throws IOException;
public void deleteEmptyDirectory(File dir) throws IOException;
}
@@ -0,0 +1,249 @@
package com.realnet.codeextractor.service;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import com.realnet.codeextractor.entity.Rn_Bcf_Extractor;
import com.realnet.codeextractor.entity.Rn_Bcf_Extractor_Params;
import com.realnet.codeextractor.repository.Rn_Bcf_Extractor_Repository;
import com.realnet.exceptions.ResourceNotFoundException;
import com.realnet.fnd.service.FileStorageService;
import com.realnet.users.entity1.AppUser;
import com.realnet.users.service1.AppUserService;
import com.realnet.users.service1.AppUserServiceImpl;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class Rn_Bcf_Extractor_ServiceImpl implements Rn_Bcf_Extractor_Service {
@Autowired
private AppUserServiceImpl userService;
@Autowired
private FileStorageService fileStorageService;
@Autowired
private Rn_Bcf_Extractor_Repository rn_bcf_extractor_repository;
@Autowired
private Rn_Bcf_Extractor_Params_Service rn_bcf_extractor_params_service;
@Override
public List<Rn_Bcf_Extractor> getAll() {
return rn_bcf_extractor_repository.findAll();
}
@Override
public Page<Rn_Bcf_Extractor> getAll(Pageable page) {
return rn_bcf_extractor_repository.findAll(page);
}
@Override
public Rn_Bcf_Extractor getById(int id) {
Rn_Bcf_Extractor bcf_extractor = rn_bcf_extractor_repository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Extractor Table Data Not Found :: " + id));
return bcf_extractor;
}
@Override
public Rn_Bcf_Extractor save(Rn_Bcf_Extractor bcf_extractor) {
// User loggedInUser = userService.getLoggedInUser();
// bcf_extractor.setCreatedBy(loggedInUser.getUserId());
Rn_Bcf_Extractor savedExtractor = rn_bcf_extractor_repository.save(bcf_extractor);
return savedExtractor;
}
@Override
public Rn_Bcf_Extractor updateById(int id, Rn_Bcf_Extractor extractorRequest) {
// User loggedInUser = userService.getLoggedInUser();
Rn_Bcf_Extractor old_extractor = rn_bcf_extractor_repository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Menu not found :: " + id));
old_extractor.setTech_stack(extractorRequest.getTech_stack());
old_extractor.setTech_stack_key(extractorRequest.getTech_stack_key());
old_extractor.setObject_type(extractorRequest.getObject_type());
old_extractor.setSub_object_type(extractorRequest.getSub_object_type());
old_extractor.setForm_type_name(extractorRequest.getForm_type_name());
old_extractor.setStd_wf_name(extractorRequest.getStd_wf_name());
old_extractor.setIcon_file_name(extractorRequest.getIcon_file_name());
old_extractor.setSample_file_name(extractorRequest.getSample_file_name());
old_extractor.setExtractor_stage(extractorRequest.getExtractor_stage());
// line part
old_extractor.setRn_bcf_extractor_Params(extractorRequest.getRn_bcf_extractor_Params());
// old_extractor.setUpdatedBy(loggedInUser.getUserId());
final Rn_Bcf_Extractor updated_function = rn_bcf_extractor_repository.save(old_extractor);
return updated_function;
}
@Override
public boolean deleteById(int id) {
if (!rn_bcf_extractor_repository.existsById(id)) {
throw new ResourceNotFoundException("Extractor Data not exist");
}
Rn_Bcf_Extractor bcf_extractor = rn_bcf_extractor_repository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Menu not found :: " + id));
rn_bcf_extractor_repository.delete(bcf_extractor);
return true;
}
@Override
public void saveListOFiles(int headerId, String tech_stack, String obj_type, String sub_obj_type,
String destDirectory) throws IOException {
File destDir = new File(destDirectory);
System.out.println("Destination Folder Path = " + destDirectory);
ArrayList<String> files = new ArrayList<String>();
// Get all files from a directory.
File[] fList = destDir.listFiles();
if (fList != null) {
for (File file : fList) {
if (file.isFile()) {
files.add(file.getAbsolutePath());
// System.out.println("directory:" + file.getAbsolutePath());
} else if (file.isDirectory()) {
saveListOFiles(headerId, tech_stack, obj_type, sub_obj_type, file.getAbsolutePath());
}
}
}
AppUser user = userService.getLoggedInUser();
Long userId = user.getUserId();
Rn_Bcf_Extractor rn_bcf_extractor = this.getById(headerId);
String sampleFileName = rn_bcf_extractor.getSample_file_name();
Long accId = rn_bcf_extractor.getAccountId();
System.out.println("SAMPLE FILE NAME = " + sampleFileName);
// REMOVING .ZIP
sampleFileName = sampleFileName.substring(0, sampleFileName.lastIndexOf("."));
// System.out.println("AFTER REMOVING .ZIP = " + sampleFileName);
// FOR CONVERTING OBJECT NAMES
// String insertPrefix = "Rn_";
//List<Rn_Bcf_Extractor_Params> params = new ArrayList<Rn_Bcf_Extractor_Params>();
// GET FILE PATHS
for (int i = 0; i < files.size(); i++) {
//List<Rn_Bcf_Extractor_Params> params = new ArrayList<Rn_Bcf_Extractor_Params>();
String filePath = files.get(i).replace("\\", "/");
File finalFile = new File(filePath);
String name = finalFile.getName();
/*
* ***ADD RN PREFIX LOGIC*** if(!name.contains(insertPrefix)) { name =
* name.substring(0,0).concat(insertPrefix) + name.substring(0); }
*/
// DESTINATION ADDRESS PATH(FOR OUTPUT FILES)
/*
* ZIP FILE NAME = Angular_project INPUT :
* {PROJECT_PATH}/src/main/resources/extracted-files/
* Angular_project_1599226114430/rn_header_test1-details.component.html OUTPUT :
* /frontend/src/app/admin/{{DYNAMIC VARIABLE}}/details/
*/
String ref_address_string = filePath.substring(filePath.lastIndexOf(sampleFileName));
ref_address_string = ref_address_string.substring(ref_address_string.indexOf("/"));
// System.out.println("REF ADDRESS STRING = " + ref_address_string);
// // DYNAMIC UI_NAME LOGIC FOR ANGULAR FILE STRUCTURE
// final String ng_prj_struct = "/frontend/src/app/admin/";
// if (ref_address_string.contains(ng_prj_struct)) {
// int len = ng_prj_struct.length();
// String data = ref_address_string.substring(0,len) + "ui_name";
// int tail = ref_address_string.indexOf("/", len + 1);
// String temp = ref_address_string.substring(tail);
// data += temp;
// ref_address_string = data;
// }
// ========ADD IT INTO PARAMETERS TABLE=========
Rn_Bcf_Extractor_Params rn_bcf_extractor_params = new Rn_Bcf_Extractor_Params();
// System.out.println("SET HEADER ID = " + headerId);
// rn_bcf_extractor_params_t.setHeader_id(headerId);
rn_bcf_extractor_params.setTech_stack(tech_stack);
rn_bcf_extractor_params.setObject_type(obj_type);
rn_bcf_extractor_params.setSub_object_type(sub_obj_type);
rn_bcf_extractor_params.setFile_code("200");
rn_bcf_extractor_params.setName_string(name);
rn_bcf_extractor_params.setAddress_string(filePath);
rn_bcf_extractor_params.setReference_address_string(ref_address_string); // FOR OUTPUT FILE PATH
String fileType = net.lingala.zip4j.util.FileUtils.getFileExtension(finalFile);
rn_bcf_extractor_params.setDescription(fileType);
// IF IT'S YES, THEN FILE WILL BE PROCESSED FOR STATIC AND DYNAMIC EXTRACTION.
rn_bcf_extractor_params.setIs_extraction_enabled(true);
rn_bcf_extractor_params.setIs_creation_enabled(true);
rn_bcf_extractor_params.setAccountId(accId);
rn_bcf_extractor_params.setCreatedBy(userId);
// SAVING BASE PROJECT FILE PATH IN PARAMS TABLE
//bcf_extractor_params_service.save(rn_bcf_extractor_params_t);
//rn_bcf_extractor.setRn_bcf_extractor_Params(rn_bcf_extractor_params);
// params.add(rn_bcf_extractor_params);
// rn_bcf_extractor.setRn_bcf_extractor_Params(params);
// this.updateById(headerId, rn_bcf_extractor); // need to test
rn_bcf_extractor_params.setRn_bcf_extractor(rn_bcf_extractor);
rn_bcf_extractor_params_service.save(rn_bcf_extractor_params);
}
}
@Override
public void moveFiles(int id, String toDir) throws IOException {
File moveToFile = new File(toDir);
// List<Rn_Bcf_Extractor_Params> params_t = getById(id).getRn_bcf_extractor_Params();
//Rn_Bcf_Extractor extractor = this.getById(id);
//log.debug("extractor : {} ",extractor);
//List<Rn_Bcf_Extractor_Params> params_t = extractor.getRn_bcf_extractor_Params();
List<Rn_Bcf_Extractor_Params> params_t = rn_bcf_extractor_params_service.getByHeaderId(id);
//log.debug("extractor : {} ", params_t);
for (Rn_Bcf_Extractor_Params params : params_t) {
String fileDirectory = params.getAddress_string();
File file = new File(fileDirectory);
String fileName = file.getName();
// MOVE ALL FILES INTO PARENT DIRECTORY
System.out.println("File name = " + fileName + "\n" + "Move to = " + toDir);
file.renameTo(new File(moveToFile, file.getName()));
String destDir = toDir + "/" + fileName;
// SAVE MOVED DIRECTORY PATH INTO THE PARAMS TABLE
params.setMoved_address_string(destDir);
rn_bcf_extractor_params_service.save(params);
}
// DELETE EMPTY DIRECTORY
this.deleteEmptyDirectory(moveToFile);
}
@Override
public void deleteEmptyDirectory(File dir) throws IOException {
if (dir.isDirectory()) {
File[] fList = dir.listFiles();
if (fList != null) {
for (File file : fList) {
if (!file.isFile()) {
System.out.println("Removing empty directory : " + file.getName());
file.delete();
deleteEmptyDirectory(file);
}
}
dir.delete();
}
}
}
}
@@ -0,0 +1,31 @@
package com.realnet.codeextractor.service;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.realnet.codeextractor.entity.Rn_Bcf_Rules;
public interface Rn_Bcf_Rule_Library_Service {
List<Rn_Bcf_Rules> getAll();
Page<Rn_Bcf_Rules> getAll(Pageable p);
Rn_Bcf_Rules getById(int id);
Rn_Bcf_Rules save(Rn_Bcf_Rules bcf_rule);
Rn_Bcf_Rules updateById(int id, Rn_Bcf_Rules bcf_rule);
boolean deleteById(int id);
List<Rn_Bcf_Rules> copyRules(String to_tech_stack, String to_object_type, String to_sub_object_type,
String from_tech_stack, String from_object_type, String from_sub_object_type);
List<Rn_Bcf_Rules> copyRules2(String from_tech_stack, String from_object_type, String from_sub_object_type);
// String stringReplace(String str, String start, String end, String
// replaceWith, String file_type);
}
@@ -0,0 +1,131 @@
package com.realnet.codeextractor.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import com.realnet.codeextractor.entity.Rn_Bcf_Rules;
import com.realnet.codeextractor.repository.Rn_Bcf_Rule_Library_Repository;
import com.realnet.exceptions.ResourceNotFoundException;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class Rn_Bcf_Rule_Library_ServiceImpl implements Rn_Bcf_Rule_Library_Service {
@Autowired
private Rn_Bcf_Rule_Library_Repository ruleLibraryRepository;
@Override
public List<Rn_Bcf_Rules> getAll() {
return ruleLibraryRepository.findAll();
}
@Override
public Page<Rn_Bcf_Rules> getAll(Pageable page) {
return ruleLibraryRepository.findAll(page);
}
@Override
public Rn_Bcf_Rules getById(int id) {
Rn_Bcf_Rules bcf_extractor = ruleLibraryRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Rule Not Found :: " + id));
return bcf_extractor;
}
@Override
public Rn_Bcf_Rules save(Rn_Bcf_Rules bcf_extractor) {
Rn_Bcf_Rules savedExtractor = ruleLibraryRepository.save(bcf_extractor);
return savedExtractor;
}
@Override
public Rn_Bcf_Rules updateById(int id, Rn_Bcf_Rules ruleRequest) {
Rn_Bcf_Rules old_extractor = ruleLibraryRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Rule not found :: " + id));
old_extractor.setGroup_id(ruleRequest.getGroup_id());
old_extractor.setRule_name(ruleRequest.getRule_name());
old_extractor.setTech_stack(ruleRequest.getTech_stack());
old_extractor.setObject_type(ruleRequest.getObject_type());
old_extractor.setSub_object_type(ruleRequest.getSub_object_type());
old_extractor.setFile_code(ruleRequest.getFile_code());
old_extractor.setRule_type(ruleRequest.getRule_type());
old_extractor.setIdentifier_start_string(ruleRequest.getIdentifier_start_string());
old_extractor.setIdentifier_end_string(ruleRequest.getIdentifier_end_string());
old_extractor.setReplacement_string(ruleRequest.getReplacement_string());
final Rn_Bcf_Rules updated_rule = ruleLibraryRepository.save(old_extractor);
return updated_rule;
}
@Override
public boolean deleteById(int id) {
if (!ruleLibraryRepository.existsById(id)) {
throw new ResourceNotFoundException("Rule not exist");
}
Rn_Bcf_Rules rule = ruleLibraryRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException("Rule not found :: " + id));
ruleLibraryRepository.delete(rule);
return true;
}
// @Override
// public String stringReplace(String str, String start, String end, String replaceWith, String file_type) {
// int i = str.indexOf(start);
// while (i != -1) {
// int j = str.indexOf(end, i + 1);
// if (j != -1) {
// /* @Include starting and ending string
// * String data = str.substring(0, i + start.length()) + "\n" + replaceWith + "\n";
// * String temp = str.substring(j);
// *
// * @Not Include starting and ending string
// * String data = str.substring(0, i) + "\n" + replaceWith + "\n";
// * String temp = str.substring(j + end.length());
// * */
// String data = str.substring(0, i) + "\n" + replaceWith + "\n";
// String temp = str.substring(j + end.length());
// data += temp;
// str = data;
// i = str.indexOf(start, i + replaceWith.length() + end.length() + 1);
// } else {
// break;
// }
// }
//
//// if (replaced) {
//// String newStart = "";
//// String newEnd = "";
//// if(file_type.equals("html") || file_type.equals("jsp")) {
//// newStart = "<!-- bcf-fieldloop-startshere-processed -->";
//// newEnd = "<!-- bcf-fieldloop-endshere-processed -->";
//// str = str.replace(start, newStart);
//// str = str.replace(end, newEnd);
//// }
//// if(file_type.equals("java") || file_type.equals("ts") || file_type.equals("js")) {
//// newStart = "/* bcf-fieldloop-startshere-processed */";
//// newEnd = "/* bcf-fieldloop-endshere-processed */";
//// str = str.replace(start, newStart);
//// str = str.replace(end, newEnd);
//// }
//// }
// return str;
// }
public List<Rn_Bcf_Rules> copyRules(String to_tech_stack, String to_object_type, String to_sub_object_type,String from_tech_stack,String from_object_type, String from_sub_object_type){
List<Rn_Bcf_Rules> rules = ruleLibraryRepository.copyRules(to_tech_stack, to_object_type, to_sub_object_type, from_tech_stack, from_object_type, from_sub_object_type);
log.debug("Nil Copied Rules: {}", rules);
return ruleLibraryRepository.copyRules(to_tech_stack, to_object_type, to_sub_object_type, from_tech_stack, from_object_type, from_sub_object_type);
}
@Override
public List<Rn_Bcf_Rules> copyRules2(String from_tech_stack, String from_object_type, String from_sub_object_type) {
return ruleLibraryRepository.copyRules2(from_tech_stack, from_object_type, from_sub_object_type);
}
}
@@ -0,0 +1,21 @@
package com.realnet.codeextractor.service;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.realnet.codeextractor.entity.ActiveTechStack_DTO;
import com.realnet.codeextractor.entity.Rn_Bcf_Technology_Stack1;
public interface Rn_Bcf_TechnologyStack_Service {
List<Rn_Bcf_Technology_Stack1> getAll();
Page<Rn_Bcf_Technology_Stack1> getAll(Pageable p);
Rn_Bcf_Technology_Stack1 getById(int id);
Rn_Bcf_Technology_Stack1 save(Rn_Bcf_Technology_Stack1 bcf_tech_stack);
Rn_Bcf_Technology_Stack1 updateById(int id, Rn_Bcf_Technology_Stack1 bcf_tech_stack);
boolean deleteById(int id);
List<ActiveTechStack_DTO> getListOfActivateTechnology();
}
@@ -0,0 +1,101 @@
package com.realnet.codeextractor.service;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import com.realnet.codeextractor.entity.ActiveTechStack_DTO;
import com.realnet.codeextractor.entity.Rn_Bcf_Technology_Stack1;
import com.realnet.codeextractor.repository.Rn_Bcf_TechnologyStack_Repository1;
import com.realnet.exceptions.ResourceNotFoundException;
import com.realnet.utils.Constant;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
public class Rn_Bcf_TechnologyStack_ServiceImpl1 implements Rn_Bcf_TechnologyStack_Service {
@Autowired
private Rn_Bcf_TechnologyStack_Repository1 technologStackRepository;
@Override
public List<Rn_Bcf_Technology_Stack1> getAll() {
return technologStackRepository.findAll();
}
@Override
public Page<Rn_Bcf_Technology_Stack1> getAll(Pageable page) {
return technologStackRepository.findAll(page);
}
@Override
public Rn_Bcf_Technology_Stack1 getById(int id) {
Rn_Bcf_Technology_Stack1 bcf_extractor = technologStackRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException(Constant.NOT_FOUND_EXCEPTION + id));
return bcf_extractor;
}
@Override
public Rn_Bcf_Technology_Stack1 save(Rn_Bcf_Technology_Stack1 bcf_extractor) {
Rn_Bcf_Technology_Stack1 savedTechnology = technologStackRepository.save(bcf_extractor);
return savedTechnology;
}
@Override
public Rn_Bcf_Technology_Stack1 updateById(int id, Rn_Bcf_Technology_Stack1 technologyRequest) {
Rn_Bcf_Technology_Stack1 old_extractor = technologStackRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException(Constant.NOT_FOUND_EXCEPTION + id));
old_extractor.setTech_stack(technologyRequest.getTech_stack());
old_extractor.setTech_stack_key(technologyRequest.getTech_stack_key());
old_extractor.setBase_prj_file_name(technologyRequest.getBase_prj_file_name());
old_extractor.setTags(technologyRequest.getTags());
old_extractor.setActive(technologyRequest.isActive());
final Rn_Bcf_Technology_Stack1 updated_technology = technologStackRepository.save(old_extractor);
return updated_technology;
}
@Override
public boolean deleteById(int id) {
if (!technologStackRepository.existsById(id)) {
throw new ResourceNotFoundException(Constant.NOT_EXIST_EXCEPTION);
}
Rn_Bcf_Technology_Stack1 bcf_extractor = technologStackRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException(Constant.NOT_FOUND_EXCEPTION + id));
technologStackRepository.delete(bcf_extractor);
return true;
}
@Override
public List<ActiveTechStack_DTO> getListOfActivateTechnology() {
// List<Rn_Bcf_Technology_Stack1> activeTechList = technologStackRepository.activeTechList();
// log.debug("ACTIVE TECHNOLOGY LIST : {} ", activeTechList);
List<Rn_Bcf_Technology_Stack1> activeTech = technologStackRepository.activeTechStacks();
log.debug("ACTIVE TECHNOLOGY : {} ", activeTech);
// activeTech.forEach(data -> {
// ActiveTechStack_DTO dto = new ActiveTechStack_DTO();
// dto.setId(data.getId());
// dto.setName(data.getBase_prj_file_name());
// });
List<ActiveTechStack_DTO> activeTechDTO = new ArrayList<ActiveTechStack_DTO>();
for (Rn_Bcf_Technology_Stack1 tech : activeTech) {
ActiveTechStack_DTO dto = new ActiveTechStack_DTO();
dto.setId(tech.getId());
dto.setName(tech.getBase_prj_file_name());
activeTechDTO.add(dto);
}
log.debug("activeTechDTO : {} ", activeTechDTO);
System.out.println("ServiceImpl : activeTechDTO " + activeTechDTO);
return activeTechDTO;
}
}
@@ -0,0 +1,44 @@
package com.realnet.codeextractor.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.realnet.codeextractor.entity.Rule_library_keyword;
import com.realnet.codeextractor.repository.Rule_library_keywordRepository;
@Service
public class Rule_library_keywordService {
@Autowired
private Rule_library_keywordRepository Repository;
public Rule_library_keyword Savedata(Rule_library_keyword data) {
return Repository.save(data);
}
public List<Rule_library_keyword> getdetails() {
return (List<Rule_library_keyword>) Repository.findAll();
}
public Rule_library_keyword getdetailsbyId(Integer id) {
return Repository.findById(id).get();
}
public void delete_by_id(Integer id) {
Repository.deleteById(id);
}
public Rule_library_keyword update(Rule_library_keyword data, Integer id) {
Rule_library_keyword old = Repository.findById(id).get();
old.setTech_stack(data.getTech_stack());
old.setObject_type(data.getObject_type());
old.setSub_object_type(data.getSub_object_type());
old.setVersion(data.getVersion());
old.setReplcement_string(data.getReplcement_string());
final Rule_library_keyword test = Repository.save(old);
return test;
}
}
@@ -0,0 +1,105 @@
package com.realnet.codeextractor.service;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.json.simple.parser.ParseException;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
@Service
public class Rule_library_service_gk {
public String rule(String path, String start, String end, String replaceWith) throws ParseException, IOException {
StringBuilder frontend = new StringBuilder();
File staticFile = new File(path);
String staticFileName = staticFile.getName();
// System.out.println("========" + staticFileName + "=============");
String fileString = FileUtils.readFileToString(staticFile, StandardCharsets.UTF_8);
String fileType = FilenameUtils.getExtension(staticFileName);
// don't check empty file for replacement..
if (!fileString.isEmpty()) {
// RULE APPLY
if (end.isEmpty()) {
String f_string = stringReplacewithout_endstring(fileString, start, replaceWith, fileType);
System.out.println(f_string.toString());
}else {
String finalString = stringReplace(fileString, start, end, replaceWith, fileType);
System.out.println(finalString.toString());
}
// BufferedWriter bw = new BufferedWriter(new FileWriter(staticFile, false)); // replaced
// // string
// bw.write(finalString);
// bw.close();
}
return frontend.toString();
}
//WHEN END STRING IS PRESENT
public static String stringReplace(String str, String start, String end, String replaceWith, String file_type) {
int i = str.indexOf(start);
while (i != -1) {
int j = str.indexOf(end, i + 1);
if (j != -1) {
/*
* @Include starting and ending string String data = str.substring(0, i +
* start.length()) + "\n" + replaceWith + "\n"; String temp = str.substring(j);
*
* @Not Include starting and ending string String data = str.substring(0, i) +
* "\n" + replaceWith + "\n"; String temp = str.substring(j + end.length());
*/
// String data = str.substring(0, i+start.length()) +" "+ replaceWith ;
// String temp = str.substring(j-end.length() + end.length());
String data = str.substring(0, i) + start + " " + replaceWith + " " + end;
String temp = str.substring(j + end.length());
data += temp;
str = data;
i = str.indexOf(start, i + replaceWith.length() + end.length() + 1);
} else {
break;
}
}
return str;
}
//WHEN END STRING IS NOT PERSENT
public static String stringReplacewithout_endstring(String str, String start, String replaceWith, String file_type) {
int i = str.indexOf(start);
while (i != -1) {
/*
* @Include starting and ending string String data = str.substring(0, i +
* start.length()) + "\n" + replaceWith + "\n"; String temp = str.substring(j);
*
* @Not Include starting and ending string String data = str.substring(0, i) +
* "\n" + replaceWith + "\n"; String temp = str.substring(j + end.length());
*/
// String data = str.substring(0, i+start.length()) +" "+ replaceWith ;
// String temp = str.substring(j-end.length() + end.length());
String data = str.substring(0, i) + start + " " + replaceWith ;
str = data;
i = str.indexOf(start, i + replaceWith.length() );
}
return str;
}
}