Compare commits
10 Commits
778cf14bdc
...
63a0f69100
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63a0f69100 | ||
|
|
7eb045a95a | ||
|
|
fd5945b464 | ||
|
|
301da36697 | ||
|
|
3841a1d0c8 | ||
|
|
38b8fc040c | ||
|
|
477647da0f | ||
|
|
bbca71f125 | ||
|
|
c2b22d5319 | ||
|
|
901b95ffa2 |
@@ -85,6 +85,12 @@
|
|||||||
<version>2.9.2</version>
|
<version>2.9.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-xml</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- end of spring fox dependency-->
|
<!-- end of spring fox dependency-->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@@ -111,13 +117,19 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
|
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>mysql</groupId>
|
<groupId>mysql</groupId>
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
<version>8.0.28</version>
|
<version>8.0.28</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- Manually Added -->
|
<!-- Manually Added -->
|
||||||
|
|
||||||
|
<!-- <dependency>
|
||||||
|
<groupId>org.xerial</groupId>
|
||||||
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
|
<version>3.45.1.0</version>
|
||||||
|
</dependency> -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.realnet.Builders.Entity.Builder_entity_t;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface BuilderRepository extends JpaRepository<Builder_entity_t, Long> {
|
public interface BuilderRepository extends JpaRepository<Builder_entity_t, Long> {
|
||||||
|
|
||||||
@Query(value = "select * from builder_entity_t where job_name= ?1 && job_type=?2", nativeQuery = true)
|
@Query(value = "select * from builder_entity_t where job_name= ?1 AND job_type=?2", nativeQuery = true)
|
||||||
Builder_entity_t findByjobTypeAndName(String job_name, String job_type);
|
Builder_entity_t findByjobTypeAndName(String job_name, String job_type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
package com.realnet.Builders.Services;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SqlDumpExecutor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes a massive SQL dump safely.
|
||||||
|
*
|
||||||
|
* @param connection JDBC connection
|
||||||
|
* @param sqlDump Full SQL dump string from getSql()
|
||||||
|
*/
|
||||||
|
public void executeDump(Connection connection, String sqlDump) {
|
||||||
|
Statement stmt = null;
|
||||||
|
try {
|
||||||
|
stmt = connection.createStatement();
|
||||||
|
connection.setAutoCommit(false);
|
||||||
|
|
||||||
|
// Remove MySQL backticks
|
||||||
|
sqlDump = sqlDump.replaceAll("`", "");
|
||||||
|
|
||||||
|
// Remove table-level DEFAULT COLLATE or CHARSET
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)DEFAULT\\s+CHARSET=[^;\\n]+", "");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)COLLATE=[^;\\n]+", "");
|
||||||
|
|
||||||
|
// Convert data types
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)bigint", "INTEGER");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)int\\([0-9]+\\)", "INTEGER");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)varchar\\([0-9]+\\)", "TEXT");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)bit\\([0-9]+\\)", "INTEGER");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)longblob", "BLOB");
|
||||||
|
|
||||||
|
// Remove AUTO_INCREMENT (if any)
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)AUTO_INCREMENT", "");
|
||||||
|
|
||||||
|
// Remove MySQL-specific directives
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)SET\\s+[^;]+;", "");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)ENGINE=\\w+\\s*", "");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)AUTO_INCREMENT=\\d+", "");
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)CHARSET=\\w+", "");
|
||||||
|
|
||||||
|
// Remove DEFAULT NULL (SQLite allows NULL by default)
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)DEFAULT NULL", "");
|
||||||
|
|
||||||
|
// Convert UNIQUE KEY <name> to UNIQUE
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)UNIQUE KEY [^\\(]+\\(", "UNIQUE(");
|
||||||
|
|
||||||
|
// Remove double commas in CREATE TABLE (,,)
|
||||||
|
sqlDump = sqlDump.replaceAll(",\\s*,", ",");
|
||||||
|
|
||||||
|
// Remove _binary prefix in INSERT statements
|
||||||
|
sqlDump = sqlDump.replaceAll("(?i)_binary\\s+'", "'");
|
||||||
|
|
||||||
|
String delimiter = ";"; // default delimiter
|
||||||
|
StringBuilder sqlStatement = new StringBuilder();
|
||||||
|
|
||||||
|
String[] lines = sqlDump.split("\\r?\\n");
|
||||||
|
for (String line : lines) {
|
||||||
|
line = line.trim();
|
||||||
|
|
||||||
|
// Skip empty lines and comments
|
||||||
|
if (line.isEmpty() || line.startsWith("--") || line.startsWith("//") || line.startsWith("/*")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detect DELIMITER changes (optional, mostly MySQL)
|
||||||
|
if (line.startsWith("DELIMITER ")) {
|
||||||
|
delimiter = line.substring("DELIMITER ".length()).trim();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove MySQL-specific comments like /*! ... */
|
||||||
|
line = line.replaceAll("/\\*!.*?\\*/", "").trim();
|
||||||
|
if (line.isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sqlStatement.append(line).append(" ");
|
||||||
|
|
||||||
|
// Check if statement ends with current delimiter
|
||||||
|
if (sqlStatement.toString().trim().endsWith(delimiter)) {
|
||||||
|
String finalSql = sqlStatement.toString().trim();
|
||||||
|
|
||||||
|
// Remove the delimiter from the end
|
||||||
|
if (delimiter.length() > 0 && finalSql.endsWith(delimiter)) {
|
||||||
|
finalSql = finalSql.substring(0, finalSql.length() - delimiter.length()).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
stmt.execute(finalSql);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
System.err.println("Failed SQL: " + finalSql);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlStatement.setLength(0); // reset for next statement
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.commit();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Error executing SQL dump: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
try {
|
||||||
|
connection.rollback();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
System.err.println("Rollback failed: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (stmt != null) {
|
||||||
|
try {
|
||||||
|
stmt.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
connection.setAutoCommit(true);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package com.realnet.BulkUpload.Controllers;
|
package com.realnet.BulkUpload.Controllers;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -24,7 +22,6 @@ import java.util.Iterator;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -54,7 +51,6 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -64,11 +60,9 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.realnet.BulkUpload.Repository.BulkUpload_Repository;
|
import com.realnet.fnd.response.EntityResponse;
|
||||||
import com.realnet.BulkUpload.Services.BulkUpload_Service;
|
|
||||||
import com.realnet.template.entity.TemplateFileUpload;
|
import com.realnet.template.entity.TemplateFileUpload;
|
||||||
import com.realnet.template.repository.TemplatedataRepo;
|
import com.realnet.template.repository.TemplatedataRepo;
|
||||||
import com.realnet.template.service.DynamicTemplateService;
|
|
||||||
import com.realnet.template.service.FileUploadService;
|
import com.realnet.template.service.FileUploadService;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@@ -78,14 +72,6 @@ public class DataImportController {
|
|||||||
private JdbcTemplate jdbcTemplate;
|
private JdbcTemplate jdbcTemplate;
|
||||||
@Autowired
|
@Autowired
|
||||||
private TemplatedataRepo temprepo;
|
private TemplatedataRepo temprepo;
|
||||||
@Autowired
|
|
||||||
private DynamicTemplateService dynamicTemplateService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BulkUpload_Service bulkUpload_Service;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BulkUpload_Repository bulkUpload_Repository;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private FileUploadService fileUploadService;
|
private FileUploadService fileUploadService;
|
||||||
@@ -280,186 +266,22 @@ public class DataImportController {
|
|||||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/////////// VERY IMPORTANT NOT DELETE THE BELOW///////////
|
|
||||||
|
|
||||||
// @PostMapping("/DownloadExcel/{id}")
|
|
||||||
// public ResponseEntity<?> importdatadownloadexcel(@PathVariable Long id,
|
|
||||||
// @RequestBody Map<String, List<Map<String, Object>>> jsonData) {
|
|
||||||
//
|
|
||||||
// TemplateFileUpload templateFileUpload = fileUploadService.getTemplatebyid(id);
|
|
||||||
//
|
|
||||||
// String entity_name = templateFileUpload.getEntity_name();
|
|
||||||
//
|
|
||||||
// BulkUpload_t bulkUpload_t = bulkUpload_Repository.getentityName(entity_name);
|
|
||||||
// String ruleLine = bulkUpload_t.getRule_line();
|
|
||||||
//
|
|
||||||
// JsonParser parser = new JsonParser();
|
|
||||||
// JsonElement element = parser.parse(ruleLine);
|
|
||||||
// JsonArray array = element.getAsJsonArray();
|
|
||||||
// Iterator<JsonElement> iterator = array.iterator();
|
|
||||||
//
|
|
||||||
// String fromsheet = null;
|
|
||||||
// String fromColumn = null;
|
|
||||||
// String validationTable = null;
|
|
||||||
// String checkColumn = null;
|
|
||||||
// String useColumn = null;
|
|
||||||
// String replacementtable = null;
|
|
||||||
// String replacementcolumn = null;
|
|
||||||
//
|
|
||||||
// while (iterator.hasNext()) {
|
|
||||||
// JsonElement next = iterator.next();
|
|
||||||
// JsonObject jsonObject = next.getAsJsonObject();
|
|
||||||
//
|
|
||||||
// fromsheet = jsonObject.get("fromsheet").getAsString();
|
|
||||||
// fromColumn = jsonObject.get("fromColumn").getAsString();
|
|
||||||
// validationTable = jsonObject.get("validationTable").getAsString();
|
|
||||||
// checkColumn = jsonObject.get("checkColumn").getAsString();
|
|
||||||
// useColumn = jsonObject.get("useColumn").getAsString();
|
|
||||||
// replacementtable = jsonObject.get("useTable").getAsString();
|
|
||||||
// replacementcolumn = jsonObject.get("replacementcolumn").getAsString();
|
|
||||||
//
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// String customerTableName = validationTable;
|
|
||||||
// String siteTableName = replacementtable;
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// Set<String> tableNames = jsonData.keySet(); // Get all unique table names
|
|
||||||
//
|
|
||||||
// String siteEntityName = null;
|
|
||||||
// for (String tableName : tableNames) {
|
|
||||||
// List<Map<String, Object>> tableData = jsonData.get(tableName);
|
|
||||||
//
|
|
||||||
// // Process tableData based on the tableName (e.g., "Site" or "Customer")
|
|
||||||
// System.out.println("Table Name: " + tableName);
|
|
||||||
// for (Map<String, Object> row : tableData) {
|
|
||||||
// // Process individual rows within the table data
|
|
||||||
// System.out.println("Row Data: " + row);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// List<Map<String, Object>> processedDataList = new ArrayList<>(); // List to hold processed data rows
|
|
||||||
//
|
|
||||||
// // Iterate through each customer data entry
|
|
||||||
// List<Map<String, Object>> customerData = jsonData.get("Customer");
|
|
||||||
// for (Map<String, Object> insertCustomerData : customerData) {
|
|
||||||
// String customerName = (String) insertCustomerData.get(checkColumn);
|
|
||||||
//
|
|
||||||
// // Check if the customerName is not null and iterate through "Site" data
|
|
||||||
// List<Map<String, Object>> siteData = jsonData.get(fromsheet);
|
|
||||||
//
|
|
||||||
// List<Map<String, Object>> matchedSiteData = new ArrayList<>();
|
|
||||||
// if (customerName != null) {
|
|
||||||
// // Iterate through "Site" data and check for a matching "entity_name"
|
|
||||||
// for (Map<String, Object> siteRow : siteData) {
|
|
||||||
// // Specify the index as "AM" (39th column)
|
|
||||||
//// String columnIndex = "AM";
|
|
||||||
// String columnIndex = fromColumn;
|
|
||||||
//
|
|
||||||
// // Retrieve the value at the specified index
|
|
||||||
//
|
|
||||||
// for (Map.Entry<String, Object> entry : siteRow.entrySet()) {
|
|
||||||
// if (entry.getKey().equals(columnIndex)) {
|
|
||||||
// siteEntityName = (String) entry.getValue();
|
|
||||||
// break; // Exit the loop once the value is found
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (customerName.equals(siteEntityName)) {
|
|
||||||
// // Add the matching "Site" data to the list
|
|
||||||
// matchedSiteData.add(siteRow);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ObjectMapper objectMapper = new ObjectMapper();
|
|
||||||
// String insertCustomerDataJson = objectMapper.writeValueAsString(insertCustomerData);
|
|
||||||
// String matchedSiteDataJson = objectMapper.writeValueAsString(matchedSiteData);
|
|
||||||
//
|
|
||||||
// String customerSql = getInsertQuery(customerTableName, insertCustomerData);
|
|
||||||
//
|
|
||||||
// // Insert data into the customer table
|
|
||||||
// Object[] customerValues = new Object[insertCustomerData.size() + 5];
|
|
||||||
// int index = 0;
|
|
||||||
// for (Object value : insertCustomerData.values()) {
|
|
||||||
// customerValues[index++] = value;
|
|
||||||
// }
|
|
||||||
// customerValues[index++] = new Timestamp(System.currentTimeMillis()); // created_at
|
|
||||||
// customerValues[index++] = null; // created_by
|
|
||||||
// customerValues[index++] = null; // updated_by
|
|
||||||
// customerValues[index++] = new Timestamp(System.currentTimeMillis()); // updated_at
|
|
||||||
// customerValues[index] = null; // account_id
|
|
||||||
// jdbcTemplate.update(customerSql, customerValues);
|
|
||||||
//
|
|
||||||
// // we can use useColumn here
|
|
||||||
// Long generatedId = jdbcTemplate.queryForObject("SELECT LAST_INSERT_ID()", Long.class);
|
|
||||||
//
|
|
||||||
// List<Map<String, Object>> insertMatchedSiteData = new ArrayList<>(); // List to hold processed data rows
|
|
||||||
//
|
|
||||||
// for (Map<String, Object> siteRow : matchedSiteData) {
|
|
||||||
// // Replace "Customer Name" with "customer_master_id" if it exists
|
|
||||||
// if (siteRow.containsKey(siteEntityName)) {
|
|
||||||
// siteRow.put(replacementcolumn, generatedId);
|
|
||||||
// siteRow.remove(siteEntityName);
|
|
||||||
// }
|
|
||||||
// insertMatchedSiteData.add(siteRow);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (Map<String, Object> siteRow : insertMatchedSiteData) {
|
|
||||||
// Object[] siteValues = new Object[siteRow.size() + 5]; // Create a new array for each row
|
|
||||||
//
|
|
||||||
// int siteIndex = 0;
|
|
||||||
// for (Object value : siteRow.values()) {
|
|
||||||
// siteValues[siteIndex++] = value;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// siteValues[siteIndex++] = new Timestamp(System.currentTimeMillis()); // created_at
|
|
||||||
// siteValues[siteIndex++] = null; // created_by
|
|
||||||
// siteValues[siteIndex++] = null; // updated_by
|
|
||||||
// siteValues[siteIndex++] = new Timestamp(System.currentTimeMillis()); // updated_at
|
|
||||||
// siteValues[siteIndex] = null; // account_id
|
|
||||||
//
|
|
||||||
// String siteSql = getInsertQuery(siteTableName, siteRow);
|
|
||||||
// jdbcTemplate.update(siteSql, siteValues);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Add the processed customer data to the list
|
|
||||||
// processedDataList.add(insertCustomerData);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Use a LinkedHashMap to preserve insertion order in the response
|
|
||||||
// Map<String, List<Map<String, Object>>> response = new LinkedHashMap<>();
|
|
||||||
// response.put("result", processedDataList);
|
|
||||||
//
|
|
||||||
// return new ResponseEntity<>(response, HttpStatus.OK);
|
|
||||||
//
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// // Handle exceptions and return an appropriate response
|
|
||||||
// return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
@PostMapping("/DownloadExcel/{id}")
|
@PostMapping("/DownloadExcel/{id}")
|
||||||
public ResponseEntity<?> importdatadownloadexcel( @PathVariable Long id,
|
public ResponseEntity<?> importdatadownloadexcel(@PathVariable Long id,
|
||||||
@RequestParam(name = "jsonData") String jsonDataParam,
|
@RequestParam(name = "jsonData") String jsonDataParam,
|
||||||
@RequestParam(name = "ruleData") String ruleDataParam)
|
@RequestParam(name = "ruleData") String ruleDataParam)
|
||||||
throws JsonMappingException, JsonProcessingException, UnsupportedEncodingException {
|
throws JsonMappingException, JsonProcessingException, UnsupportedEncodingException {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Inside your method
|
// Inside your method
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
JsonNode ruleDataNode = objectMapper.readTree(ruleDataParam);
|
JsonNode ruleDataNode = objectMapper.readTree(ruleDataParam);
|
||||||
|
|
||||||
if (ruleDataNode.isArray() && ruleDataNode.isEmpty()) {
|
if (ruleDataNode.isArray() && ruleDataNode.isEmpty()) {
|
||||||
// If ruleDataParam is an empty JSON array, directly upload data to the table
|
// If ruleDataParam is an empty JSON array, directly upload data to the table
|
||||||
return uploadDataToTable(id, jsonDataParam);
|
return uploadDataToTable(id, jsonDataParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Parse jsonDataParam to extract the JSON data
|
// Parse jsonDataParam to extract the JSON data
|
||||||
Map<String, List<Map<String, Object>>> jsonData = objectMapper.readValue(
|
Map<String, List<Map<String, Object>>> jsonData = objectMapper.readValue(
|
||||||
URLDecoder.decode(jsonDataParam, "UTF-8"), new TypeReference<Map<String, List<Map<String, Object>>>>() {
|
URLDecoder.decode(jsonDataParam, "UTF-8"), new TypeReference<Map<String, List<Map<String, Object>>>>() {
|
||||||
@@ -478,8 +300,6 @@ public class DataImportController {
|
|||||||
String replacementtable = null;
|
String replacementtable = null;
|
||||||
String replacementcolumn = null;
|
String replacementcolumn = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (ruleData != null && !ruleData.isEmpty()) {
|
if (ruleData != null && !ruleData.isEmpty()) {
|
||||||
// Assuming you want to access the first element in the array
|
// Assuming you want to access the first element in the array
|
||||||
Map<String, String> rule = ruleData.get(0);
|
Map<String, String> rule = ruleData.get(0);
|
||||||
@@ -509,7 +329,6 @@ public class DataImportController {
|
|||||||
// Create a sheet for site data
|
// Create a sheet for site data
|
||||||
XSSFSheet siteSheet = workbook.createSheet("Site");
|
XSSFSheet siteSheet = workbook.createSheet("Site");
|
||||||
|
|
||||||
|
|
||||||
List<Map<String, Object>> customerDataList = new ArrayList<>();
|
List<Map<String, Object>> customerDataList = new ArrayList<>();
|
||||||
List<Map<String, Object>> siteDataList = new ArrayList<>();
|
List<Map<String, Object>> siteDataList = new ArrayList<>();
|
||||||
|
|
||||||
@@ -605,7 +424,7 @@ public class DataImportController {
|
|||||||
if (siteRow.containsKey(responseMessage)) {
|
if (siteRow.containsKey(responseMessage)) {
|
||||||
siteRow.put(replacementcolumn, generatedId);
|
siteRow.put(replacementcolumn, generatedId);
|
||||||
// siteRow.remove(responseMessage);
|
// siteRow.remove(responseMessage);
|
||||||
// siteRow.remove(responseMessage);
|
// siteRow.remove(responseMessage);
|
||||||
}
|
}
|
||||||
newMatchedSiteData.add(siteRow);
|
newMatchedSiteData.add(siteRow);
|
||||||
}
|
}
|
||||||
@@ -731,74 +550,74 @@ public class DataImportController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private ResponseEntity<?> uploadDataToTable(Long id, String jsonDataParam) {
|
private ResponseEntity<?> uploadDataToTable(Long id, String jsonDataParam) {
|
||||||
try {
|
try {
|
||||||
// Get table name from TemplateFileUpload entity
|
// Get table name from TemplateFileUpload entity
|
||||||
Optional<TemplateFileUpload> fileUploadOptional = temprepo.findById(id);
|
Optional<TemplateFileUpload> fileUploadOptional = temprepo.findById(id);
|
||||||
if (fileUploadOptional.isPresent()) {
|
if (fileUploadOptional.isPresent()) {
|
||||||
TemplateFileUpload fileUpload = fileUploadOptional.get();
|
TemplateFileUpload fileUpload = fileUploadOptional.get();
|
||||||
// String tableName = fileUpload.getTablename();
|
// String tableName = fileUpload.getTablename();
|
||||||
String tableName = "aa";
|
String tableName = fileUpload.getEntity_name();
|
||||||
// Insert data into the specified table
|
// String tableName = "aa";
|
||||||
insertDataIntoTable(tableName, jsonDataParam);
|
// Insert data into the specified table
|
||||||
return ResponseEntity.ok().body("Data uploaded successfully to table: " + tableName);
|
insertDataIntoTable(tableName, jsonDataParam);
|
||||||
} else {
|
System.out.println("Data uploaded successfully to table...");
|
||||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Template file with id " + id + " not found");
|
return ResponseEntity.ok().body(new EntityResponse("Data uploaded successfully to table: " + tableName));
|
||||||
}
|
} else {
|
||||||
} catch (Exception e) {
|
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Template file with id " + id + " not found");
|
||||||
e.printStackTrace();
|
}
|
||||||
// Handle exceptions and return an appropriate response
|
} catch (Exception e) {
|
||||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
e.printStackTrace();
|
||||||
}
|
// Handle exceptions and return an appropriate response
|
||||||
|
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void insertDataIntoTable(String tableName, String jsonDataParam) {
|
private void insertDataIntoTable(String tableName, String jsonDataParam) {
|
||||||
try {
|
try {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
// Parse jsonDataParam to extract the JSON data
|
// Parse jsonDataParam to extract the JSON data
|
||||||
Map<String, List<Map<String, Object>>> jsonData = objectMapper.readValue(
|
Map<String, List<Map<String, Object>>> jsonData = objectMapper.readValue(
|
||||||
URLDecoder.decode(jsonDataParam, "UTF-8"), new TypeReference<Map<String, List<Map<String, Object>>>>() {});
|
URLDecoder.decode(jsonDataParam, "UTF-8"),
|
||||||
|
new TypeReference<Map<String, List<Map<String, Object>>>>() {
|
||||||
|
});
|
||||||
|
|
||||||
// Iterate over the entries of the jsonData map
|
// Iterate over the entries of the jsonData map
|
||||||
for (Map.Entry<String, List<Map<String, Object>>> entry : jsonData.entrySet()) {
|
for (Map.Entry<String, List<Map<String, Object>>> entry : jsonData.entrySet()) {
|
||||||
String sheetName = entry.getKey(); // Get the sheet name dynamically
|
String sheetName = entry.getKey(); // Get the sheet name dynamically
|
||||||
List<Map<String, Object>> data = entry.getValue(); // Get the list of maps dynamically
|
List<Map<String, Object>> data = entry.getValue(); // Get the list of maps dynamically
|
||||||
|
|
||||||
// Now you have the list of maps for the current sheet, you can iterate through it and perform your database insertion logic
|
// Now you have the list of maps for the current sheet, you can iterate through
|
||||||
for (Map<String, Object> rowData : data) {
|
// it and perform your database insertion logic
|
||||||
StringBuilder columns = new StringBuilder();
|
for (Map<String, Object> rowData : data) {
|
||||||
StringBuilder values = new StringBuilder();
|
StringBuilder columns = new StringBuilder();
|
||||||
List<Object> params = new ArrayList<>();
|
StringBuilder values = new StringBuilder();
|
||||||
|
List<Object> params = new ArrayList<>();
|
||||||
|
|
||||||
// Build column names and values dynamically
|
// Build column names and values dynamically
|
||||||
for (Map.Entry<String, Object> columnEntry : rowData.entrySet()) {
|
for (Map.Entry<String, Object> columnEntry : rowData.entrySet()) {
|
||||||
if (columns.length() > 0) {
|
if (columns.length() > 0) {
|
||||||
columns.append(", ");
|
columns.append(", ");
|
||||||
values.append(", ");
|
values.append(", ");
|
||||||
}
|
}
|
||||||
columns.append(columnEntry.getKey());
|
columns.append(columnEntry.getKey());
|
||||||
values.append("?");
|
values.append("?");
|
||||||
params.add(columnEntry.getValue());
|
params.add(columnEntry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the SQL query
|
// Construct the SQL query
|
||||||
String sql = "INSERT INTO " + tableName + " (" + columns + ") VALUES (" + values + ")";
|
String sql = "INSERT INTO " + tableName + " (" + columns + ") VALUES (" + values + ")";
|
||||||
|
|
||||||
// Execute the SQL query
|
// Execute the SQL query
|
||||||
jdbcTemplate.update(sql, params.toArray());
|
jdbcTemplate.update(sql, params.toArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
// Handle exceptions appropriately
|
// Handle exceptions appropriately
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String extractExceptionMessage(DataIntegrityViolationException e) {
|
private String extractExceptionMessage(DataIntegrityViolationException e) {
|
||||||
String errorMessage = e.getMessage();
|
String errorMessage = e.getMessage();
|
||||||
int startIndex = errorMessage.indexOf("Incorrect ");
|
int startIndex = errorMessage.indexOf("Incorrect ");
|
||||||
@@ -865,8 +684,6 @@ public class DataImportController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/downloadImportStatement/{id}")
|
@GetMapping("/downloadImportStatement/{id}")
|
||||||
public ResponseEntity<?> downloadImportStatement(@PathVariable Long id) {
|
public ResponseEntity<?> downloadImportStatement(@PathVariable Long id) {
|
||||||
// Retrieve the file data from the database based on the ID
|
// Retrieve the file data from the database based on the ID
|
||||||
@@ -896,8 +713,7 @@ public class DataImportController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get table column
|
||||||
//get table column
|
|
||||||
|
|
||||||
@GetMapping("/columns/{tableName}")
|
@GetMapping("/columns/{tableName}")
|
||||||
public List<String> getColumnNames(@PathVariable String tableName) {
|
public List<String> getColumnNames(@PathVariable String tableName) {
|
||||||
@@ -917,77 +733,62 @@ public class DataImportController {
|
|||||||
return new ArrayList<>(columnNamesSet);
|
return new ArrayList<>(columnNamesSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getCellValue(Map<String, List<Map<String, Object>>> jsonData, String sheetName, String cellAddress)
|
||||||
|
throws IOException {
|
||||||
|
if (jsonData.containsKey(sheetName)) {
|
||||||
|
List<Map<String, Object>> sheetData = jsonData.get(sheetName);
|
||||||
|
int size = sheetData.size();
|
||||||
|
System.out.println(size);
|
||||||
|
Map<String, Object> firstRowData = sheetData.get(0);
|
||||||
|
|
||||||
|
// Separate the numeric part (row part) and non-numeric part (column part)
|
||||||
|
String rowPart = "";
|
||||||
|
String columnPart = "";
|
||||||
|
|
||||||
|
for (char c : cellAddress.toCharArray()) {
|
||||||
|
if (Character.isDigit(c)) {
|
||||||
|
rowPart += c;
|
||||||
|
} else {
|
||||||
|
columnPart += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Column Part: " + columnPart);
|
||||||
|
System.out.println("Row Part: " + rowPart);
|
||||||
|
|
||||||
private String getCellValue(Map<String, List<Map<String, Object>>> jsonData, String sheetName,
|
int columnIndex = getColumnIndex(columnPart); // Get the column index based on the columnPart
|
||||||
String cellAddress) throws IOException {
|
|
||||||
if (jsonData.containsKey(sheetName)) {
|
|
||||||
List<Map<String, Object>> sheetData = jsonData.get(sheetName);
|
|
||||||
int size = sheetData.size();
|
|
||||||
System.out.println(size);
|
|
||||||
Map<String, Object> firstRowData = sheetData.get(0);
|
|
||||||
|
|
||||||
// Separate the numeric part (row part) and non-numeric part (column part)
|
|
||||||
String rowPart = "";
|
|
||||||
String columnPart = "";
|
|
||||||
|
|
||||||
for (char c : cellAddress.toCharArray()) {
|
|
||||||
if (Character.isDigit(c)) {
|
|
||||||
rowPart += c;
|
|
||||||
} else {
|
|
||||||
columnPart += c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("Column Part: " + columnPart);
|
|
||||||
System.out.println("Row Part: " + rowPart);
|
|
||||||
|
|
||||||
int columnIndex = getColumnIndex(columnPart); // Get the column index based on the columnPart
|
|
||||||
// int rowIndex = Integer.parseInt(rowPart) - 1; // Excel-style 1-based index
|
// int rowIndex = Integer.parseInt(rowPart) - 1; // Excel-style 1-based index
|
||||||
System.out.println("Column Index: " + columnIndex);
|
System.out.println("Column Index: " + columnIndex);
|
||||||
|
|
||||||
|
if (columnIndex >= 0) {
|
||||||
|
// Get the list of keys from the firstRowData map
|
||||||
|
List<String> keys = new ArrayList<>(firstRowData.keySet());
|
||||||
|
|
||||||
if (columnIndex >= 0 ) {
|
// Check if the columnIndex is within the range of keys
|
||||||
// Get the list of keys from the firstRowData map
|
if (columnIndex < keys.size()) {
|
||||||
List<String> keys = new ArrayList<>(firstRowData.keySet());
|
String columnName = keys.get(columnIndex);
|
||||||
|
return columnName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the columnIndex is within the range of keys
|
return null;
|
||||||
if (columnIndex < keys.size()) {
|
|
||||||
String columnName = keys.get(columnIndex);
|
|
||||||
return columnName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private int getColumnIndex(String columnPart) {
|
private int getColumnIndex(String columnPart) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int multiplier = 1;
|
int multiplier = 1;
|
||||||
|
|
||||||
// Iterate through the columnPart in reverse order (right to left)
|
// Iterate through the columnPart in reverse order (right to left)
|
||||||
for (int i = columnPart.length() - 1; i >= 0; i--) {
|
for (int i = columnPart.length() - 1; i >= 0; i--) {
|
||||||
char c = columnPart.charAt(i);
|
char c = columnPart.charAt(i);
|
||||||
index += (c - 'A' + 1) * multiplier;
|
index += (c - 'A' + 1) * multiplier;
|
||||||
multiplier *= 26; // Multiply by 26 for each position to calculate the index
|
multiplier *= 26; // Multiply by 26 for each position to calculate the index
|
||||||
}
|
}
|
||||||
|
|
||||||
return index - 1; // Subtract 1 to get a 0-based index
|
return index - 1; // Subtract 1 to get a 0-based index
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// @PostMapping("/DownloadExcel/{entityName}")
|
// @PostMapping("/DownloadExcel/{entityName}")
|
||||||
// public ResponseEntity<Resource> importdatadownloadexcel(@PathVariable String entityName,
|
// public ResponseEntity<Resource> importdatadownloadexcel(@PathVariable String entityName,
|
||||||
// @RequestBody List<Map<String, Object>> data) throws IOException {
|
// @RequestBody List<Map<String, Object>> data) throws IOException {
|
||||||
@@ -1003,80 +804,235 @@ public class DataImportController {
|
|||||||
// return ResponseEntity.ok().body(null);
|
// return ResponseEntity.ok().body(null);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private List<Map<String, Object>> processData(String entityName, List<Map<String, Object>> data) {
|
private List<Map<String, Object>> processData(String entityName, List<Map<String, Object>> data) {
|
||||||
List<Map<String, Object>> processedData = new ArrayList<>();
|
List<Map<String, Object>> processedData = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
String convertedTableName = entityName;
|
String convertedTableName = entityName;
|
||||||
String sql = getInsertQuery(convertedTableName, data.get(0));
|
String sql = getInsertQuery(convertedTableName, data.get(0));
|
||||||
for (int i = 0; i < data.size(); i++) {
|
for (int i = 0; i < data.size(); i++) {
|
||||||
Map<String, Object> row = data.get(i);
|
Map<String, Object> row = data.get(i);
|
||||||
Map<String, Object> processedRow = new HashMap<>();
|
Map<String, Object> processedRow = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
Object[] values = new Object[row.size() + 5]; // +5 for the additional columns
|
Object[] values = new Object[row.size() + 5]; // +5 for the additional columns
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (Object value : row.values()) {
|
for (Object value : row.values()) {
|
||||||
values[index++] = value;
|
values[index++] = value;
|
||||||
}
|
}
|
||||||
values[index++] = new Timestamp(System.currentTimeMillis()); // created_at
|
values[index++] = new Timestamp(System.currentTimeMillis()); // created_at
|
||||||
values[index++] = null; // created_by
|
values[index++] = null; // created_by
|
||||||
values[index++] = null; // updated_by
|
values[index++] = null; // updated_by
|
||||||
values[index++] = new Timestamp(System.currentTimeMillis()); // updated_at
|
values[index++] = new Timestamp(System.currentTimeMillis()); // updated_at
|
||||||
values[index] = null; // account_id
|
values[index] = null; // account_id
|
||||||
jdbcTemplate.update(sql, values);
|
jdbcTemplate.update(sql, values);
|
||||||
processedRow.putAll(row);
|
processedRow.putAll(row);
|
||||||
processedRow.put("Status", "Success");
|
processedRow.put("Status", "Success");
|
||||||
processedRow.put("Exception", "NA");
|
processedRow.put("Exception", "NA");
|
||||||
} catch (DataIntegrityViolationException e) {
|
} catch (DataIntegrityViolationException e) {
|
||||||
processedRow.putAll(row);
|
processedRow.putAll(row);
|
||||||
processedRow.put("Status", "Error");
|
processedRow.put("Status", "Error");
|
||||||
String exceptionMessage = extractExceptionMessage(e);
|
String exceptionMessage = extractExceptionMessage(e);
|
||||||
processedRow.put("Exception", exceptionMessage);
|
processedRow.put("Exception", exceptionMessage);
|
||||||
}
|
}
|
||||||
processedData.add(processedRow);
|
processedData.add(processedRow);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Handle any exceptions here if needed
|
// Handle any exceptions here if needed
|
||||||
}
|
}
|
||||||
return processedData;
|
return processedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private Workbook createWorkbook(List<Map<String, Object>> processedData) {
|
private Workbook createWorkbook(List<Map<String, Object>> processedData) {
|
||||||
Workbook workbook = new XSSFWorkbook();
|
Workbook workbook = new XSSFWorkbook();
|
||||||
Sheet sheet = workbook.createSheet("Failed Records");
|
Sheet sheet = workbook.createSheet("Failed Records");
|
||||||
|
|
||||||
// Add column headers to the worksheet
|
// Add column headers to the worksheet
|
||||||
Row headerRow = sheet.createRow(0);
|
Row headerRow = sheet.createRow(0);
|
||||||
int columnIndex = 0;
|
int columnIndex = 0;
|
||||||
for (String key : processedData.get(0).keySet()) {
|
for (String key : processedData.get(0).keySet()) {
|
||||||
Cell cell = headerRow.createCell(columnIndex++);
|
Cell cell = headerRow.createCell(columnIndex++);
|
||||||
cell.setCellValue(key);
|
cell.setCellValue(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add data rows to the worksheet
|
// Add data rows to the worksheet
|
||||||
int rowIndex = 1;
|
int rowIndex = 1;
|
||||||
for (Map<String, Object> row : processedData) {
|
for (Map<String, Object> row : processedData) {
|
||||||
Row dataRow = sheet.createRow(rowIndex++);
|
Row dataRow = sheet.createRow(rowIndex++);
|
||||||
columnIndex = 0;
|
columnIndex = 0;
|
||||||
for (Object value : row.values()) {
|
for (Object value : row.values()) {
|
||||||
Cell cell = dataRow.createCell(columnIndex++);
|
Cell cell = dataRow.createCell(columnIndex++);
|
||||||
cell.setCellValue(value.toString());
|
cell.setCellValue(value.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return workbook;
|
return workbook;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Resource createExcelResource(Workbook workbook) throws IOException {
|
private Resource createExcelResource(Workbook workbook) throws IOException {
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
workbook.write(outputStream);
|
workbook.write(outputStream);
|
||||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
|
ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
|
||||||
return new InputStreamResource(inputStream);
|
return new InputStreamResource(inputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////// VERY IMPORTANT NOT DELETE THE BELOW///////////
|
||||||
|
|
||||||
|
//@PostMapping("/DownloadExcel/{id}")
|
||||||
|
//public ResponseEntity<?> importdatadownloadexcel(@PathVariable Long id,
|
||||||
|
// @RequestBody Map<String, List<Map<String, Object>>> jsonData) {
|
||||||
|
//
|
||||||
|
// TemplateFileUpload templateFileUpload = fileUploadService.getTemplatebyid(id);
|
||||||
|
//
|
||||||
|
// String entity_name = templateFileUpload.getEntity_name();
|
||||||
|
//
|
||||||
|
// BulkUpload_t bulkUpload_t = bulkUpload_Repository.getentityName(entity_name);
|
||||||
|
// String ruleLine = bulkUpload_t.getRule_line();
|
||||||
|
//
|
||||||
|
// JsonParser parser = new JsonParser();
|
||||||
|
// JsonElement element = parser.parse(ruleLine);
|
||||||
|
// JsonArray array = element.getAsJsonArray();
|
||||||
|
// Iterator<JsonElement> iterator = array.iterator();
|
||||||
|
//
|
||||||
|
// String fromsheet = null;
|
||||||
|
// String fromColumn = null;
|
||||||
|
// String validationTable = null;
|
||||||
|
// String checkColumn = null;
|
||||||
|
// String useColumn = null;
|
||||||
|
// String replacementtable = null;
|
||||||
|
// String replacementcolumn = null;
|
||||||
|
//
|
||||||
|
// while (iterator.hasNext()) {
|
||||||
|
// JsonElement next = iterator.next();
|
||||||
|
// JsonObject jsonObject = next.getAsJsonObject();
|
||||||
|
//
|
||||||
|
// fromsheet = jsonObject.get("fromsheet").getAsString();
|
||||||
|
// fromColumn = jsonObject.get("fromColumn").getAsString();
|
||||||
|
// validationTable = jsonObject.get("validationTable").getAsString();
|
||||||
|
// checkColumn = jsonObject.get("checkColumn").getAsString();
|
||||||
|
// useColumn = jsonObject.get("useColumn").getAsString();
|
||||||
|
// replacementtable = jsonObject.get("useTable").getAsString();
|
||||||
|
// replacementcolumn = jsonObject.get("replacementcolumn").getAsString();
|
||||||
|
//
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// String customerTableName = validationTable;
|
||||||
|
// String siteTableName = replacementtable;
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// Set<String> tableNames = jsonData.keySet(); // Get all unique table names
|
||||||
|
//
|
||||||
|
// String siteEntityName = null;
|
||||||
|
// for (String tableName : tableNames) {
|
||||||
|
// List<Map<String, Object>> tableData = jsonData.get(tableName);
|
||||||
|
//
|
||||||
|
// // Process tableData based on the tableName (e.g., "Site" or "Customer")
|
||||||
|
// System.out.println("Table Name: " + tableName);
|
||||||
|
// for (Map<String, Object> row : tableData) {
|
||||||
|
// // Process individual rows within the table data
|
||||||
|
// System.out.println("Row Data: " + row);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// List<Map<String, Object>> processedDataList = new ArrayList<>(); // List to hold processed data rows
|
||||||
|
//
|
||||||
|
// // Iterate through each customer data entry
|
||||||
|
// List<Map<String, Object>> customerData = jsonData.get("Customer");
|
||||||
|
// for (Map<String, Object> insertCustomerData : customerData) {
|
||||||
|
// String customerName = (String) insertCustomerData.get(checkColumn);
|
||||||
|
//
|
||||||
|
// // Check if the customerName is not null and iterate through "Site" data
|
||||||
|
// List<Map<String, Object>> siteData = jsonData.get(fromsheet);
|
||||||
|
//
|
||||||
|
// List<Map<String, Object>> matchedSiteData = new ArrayList<>();
|
||||||
|
// if (customerName != null) {
|
||||||
|
// // Iterate through "Site" data and check for a matching "entity_name"
|
||||||
|
// for (Map<String, Object> siteRow : siteData) {
|
||||||
|
// // Specify the index as "AM" (39th column)
|
||||||
|
//// String columnIndex = "AM";
|
||||||
|
// String columnIndex = fromColumn;
|
||||||
|
//
|
||||||
|
// // Retrieve the value at the specified index
|
||||||
|
//
|
||||||
|
// for (Map.Entry<String, Object> entry : siteRow.entrySet()) {
|
||||||
|
// if (entry.getKey().equals(columnIndex)) {
|
||||||
|
// siteEntityName = (String) entry.getValue();
|
||||||
|
// break; // Exit the loop once the value is found
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (customerName.equals(siteEntityName)) {
|
||||||
|
// // Add the matching "Site" data to the list
|
||||||
|
// matchedSiteData.add(siteRow);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
// String insertCustomerDataJson = objectMapper.writeValueAsString(insertCustomerData);
|
||||||
|
// String matchedSiteDataJson = objectMapper.writeValueAsString(matchedSiteData);
|
||||||
|
//
|
||||||
|
// String customerSql = getInsertQuery(customerTableName, insertCustomerData);
|
||||||
|
//
|
||||||
|
// // Insert data into the customer table
|
||||||
|
// Object[] customerValues = new Object[insertCustomerData.size() + 5];
|
||||||
|
// int index = 0;
|
||||||
|
// for (Object value : insertCustomerData.values()) {
|
||||||
|
// customerValues[index++] = value;
|
||||||
|
// }
|
||||||
|
// customerValues[index++] = new Timestamp(System.currentTimeMillis()); // created_at
|
||||||
|
// customerValues[index++] = null; // created_by
|
||||||
|
// customerValues[index++] = null; // updated_by
|
||||||
|
// customerValues[index++] = new Timestamp(System.currentTimeMillis()); // updated_at
|
||||||
|
// customerValues[index] = null; // account_id
|
||||||
|
// jdbcTemplate.update(customerSql, customerValues);
|
||||||
|
//
|
||||||
|
// // we can use useColumn here
|
||||||
|
// Long generatedId = jdbcTemplate.queryForObject("SELECT LAST_INSERT_ID()", Long.class);
|
||||||
|
//
|
||||||
|
// List<Map<String, Object>> insertMatchedSiteData = new ArrayList<>(); // List to hold processed data rows
|
||||||
|
//
|
||||||
|
// for (Map<String, Object> siteRow : matchedSiteData) {
|
||||||
|
// // Replace "Customer Name" with "customer_master_id" if it exists
|
||||||
|
// if (siteRow.containsKey(siteEntityName)) {
|
||||||
|
// siteRow.put(replacementcolumn, generatedId);
|
||||||
|
// siteRow.remove(siteEntityName);
|
||||||
|
// }
|
||||||
|
// insertMatchedSiteData.add(siteRow);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// for (Map<String, Object> siteRow : insertMatchedSiteData) {
|
||||||
|
// Object[] siteValues = new Object[siteRow.size() + 5]; // Create a new array for each row
|
||||||
|
//
|
||||||
|
// int siteIndex = 0;
|
||||||
|
// for (Object value : siteRow.values()) {
|
||||||
|
// siteValues[siteIndex++] = value;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// siteValues[siteIndex++] = new Timestamp(System.currentTimeMillis()); // created_at
|
||||||
|
// siteValues[siteIndex++] = null; // created_by
|
||||||
|
// siteValues[siteIndex++] = null; // updated_by
|
||||||
|
// siteValues[siteIndex++] = new Timestamp(System.currentTimeMillis()); // updated_at
|
||||||
|
// siteValues[siteIndex] = null; // account_id
|
||||||
|
//
|
||||||
|
// String siteSql = getInsertQuery(siteTableName, siteRow);
|
||||||
|
// jdbcTemplate.update(siteSql, siteValues);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Add the processed customer data to the list
|
||||||
|
// processedDataList.add(insertCustomerData);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Use a LinkedHashMap to preserve insertion order in the response
|
||||||
|
// Map<String, List<Map<String, Object>>> response = new LinkedHashMap<>();
|
||||||
|
// response.put("result", processedDataList);
|
||||||
|
//
|
||||||
|
// return new ResponseEntity<>(response, HttpStatus.OK);
|
||||||
|
//
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// // Handle exceptions and return an appropriate response
|
||||||
|
// return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
package com.realnet.Communication.Services;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
|
import org.springframework.util.MultiValueMap;
|
||||||
|
import org.springframework.web.client.ResourceAccessException;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.realnet.config.EmailService;
|
||||||
|
import com.realnet.users.entity1.AppUser;
|
||||||
|
import com.realnet.users.service1.AppUserServiceImpl;
|
||||||
|
import com.realnet.utils.Port_Constant;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class EmailNotificationService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailService emailService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
|
||||||
|
public void sendDirectEmail(String email, String subject, String message) throws JsonProcessingException {
|
||||||
|
// Call the sendSimpleMessage method from EmailService
|
||||||
|
emailService.sendSimpleMessage(null, email, subject, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendmailViaSetu(String email, String Name, String type) {
|
||||||
|
// Call the method from EmailCommunicationService
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case "TeamMember":
|
||||||
|
sendEmailTeamMember(email, Name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "WorkSpaceUser":
|
||||||
|
sendEmailtoWorkUser(email, Name);
|
||||||
|
break;
|
||||||
|
case "AddProject":
|
||||||
|
sendEmailAfterAddPrj(email, Name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "CopyProject":
|
||||||
|
sendEmailAfterCopyPrj(email, Name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "CreateWireframe":
|
||||||
|
sendEmailAfterCopyPrj(email, Name);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// for sending mail to team member
|
||||||
|
public ResponseEntity<?> sendEmailTeamMember(String email, String FullName) {
|
||||||
|
// Call the method from EmailCommunicationService
|
||||||
|
|
||||||
|
String subject = "Team Added to Workspace";
|
||||||
|
String message = "Dear " + FullName + ",\n\nYou have been added to the workspace.";
|
||||||
|
String templateName = "addproject";
|
||||||
|
String gatewayName = "ganesh";
|
||||||
|
|
||||||
|
// Sending the email via Setu
|
||||||
|
|
||||||
|
ResponseEntity<?> responseEntity = sendEmailViaSetu(email, message, templateName, gatewayName);
|
||||||
|
return responseEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for sending mail to Sec workspace User
|
||||||
|
public ResponseEntity<?> sendEmailtoWorkUser(String email, String FullName) {
|
||||||
|
// Call the method from EmailCommunicationService
|
||||||
|
|
||||||
|
String subject = "Workspace Access Granted";
|
||||||
|
String message = "Dear " + FullName + ",\n\nYou have been granted access to the workspace.";
|
||||||
|
String templateName = "addproject"; // Replace with actual template name
|
||||||
|
String gatewayName = "ganesh"; // Replace with actual gateway name
|
||||||
|
|
||||||
|
// Sending the email via Setu
|
||||||
|
return sendEmailViaSetu(email, message, templateName, gatewayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// for sending mail After Add project
|
||||||
|
public ResponseEntity<?> sendEmailAfterAddPrj(String email, String Name) {
|
||||||
|
// Call the method from EmailCommunicationService
|
||||||
|
|
||||||
|
String subject = "Add Project";
|
||||||
|
String message = "Project " + Name + " has been created successfully.";
|
||||||
|
String templateName = "addproject"; // Replace with actual template name
|
||||||
|
String gatewayName = "ganesh"; // Replace with actual gateway name
|
||||||
|
|
||||||
|
// Sending the email via Setu
|
||||||
|
return sendEmailViaSetu(email, message, templateName, gatewayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// for sending mail After Copy project
|
||||||
|
public ResponseEntity<?> sendEmailAfterCopyPrj(String email, String Name) {
|
||||||
|
// Call the method from EmailCommunicationService
|
||||||
|
|
||||||
|
String subject = "Copy Project";
|
||||||
|
String message = "Project " + Name + " has been Copied successfully.";
|
||||||
|
String templateName = "addproject"; // Replace with actual template name
|
||||||
|
String gatewayName = "ganesh"; // Replace with actual gateway name
|
||||||
|
|
||||||
|
// Sending the email via Setu
|
||||||
|
return sendEmailViaSetu(email, message, templateName, gatewayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// for sending mail After create Wireframe
|
||||||
|
public ResponseEntity<?> sendEmailAfterCreateWireframe(String email, String Name) {
|
||||||
|
// Call the method from EmailCommunicationService
|
||||||
|
|
||||||
|
String subject = "Create Wireframe";
|
||||||
|
String message = "A new wireframe has been successfully added to your project.";
|
||||||
|
|
||||||
|
String templateName = "addproject"; // Replace with actual template name
|
||||||
|
String gatewayName = "ganesh"; // Replace with actual gateway name
|
||||||
|
|
||||||
|
// Sending the email via Setu
|
||||||
|
return sendEmailViaSetu(email, message, templateName, gatewayName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// send mail via setu
|
||||||
|
public ResponseEntity<?> sendEmailViaSetu(String email, String message, String templateName, String gatewayName)
|
||||||
|
throws ResourceAccessException {
|
||||||
|
|
||||||
|
// template name = notification_template, gateway name = email_gateway
|
||||||
|
try {
|
||||||
|
|
||||||
|
String jsonData = "{\r\n" + " \"job_type\": \"Email\",\r\n" + " \"send_to\": \"" + email.trim()
|
||||||
|
+ "\",\r\n" + " \"cc\": \"cc@example.com\",\r\n"
|
||||||
|
// + " \"attachment\": \"sample-file.txt\",\r\n"
|
||||||
|
+ " \"gatewaydone\": \"N\",\r\n" + " \"template_name\": \"" + templateName.trim() + "\",\r\n"
|
||||||
|
+ " \"replacement_string\": \"Hello, {name} " + message + "!\",\r\n" + " \"gatewayName\": \""
|
||||||
|
+ gatewayName.trim() + "\"\r\n" + "}\r\n";
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
// headers.setContentType(MediaType.MULTIPART_FORM_DATA);
|
||||||
|
|
||||||
|
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||||
|
queryParams.add("data", jsonData);
|
||||||
|
|
||||||
|
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(queryParams, headers);
|
||||||
|
|
||||||
|
String apiUrl2 = Port_Constant.SURE_SETU_DOMAIN
|
||||||
|
+ "/token/Surecommunication/communication/jobtable/Com_jobTable"; // Replace with the
|
||||||
|
// actual API URL
|
||||||
|
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
ResponseEntity<String> responseEntity = restTemplate.postForEntity(apiUrl2, requestEntity, String.class);
|
||||||
|
|
||||||
|
return ResponseEntity.ok(responseEntity.getBody());
|
||||||
|
|
||||||
|
} catch (ResourceAccessException e) {
|
||||||
|
throw new ResourceAccessException("communication server no start..." + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -38,6 +38,9 @@ public class Dashbord1_Line extends dashbord_Who_collumn {
|
|||||||
@Column(length = 5000)
|
@Column(length = 5000)
|
||||||
private String Model;
|
private String Model;
|
||||||
|
|
||||||
|
@Column(length = 5000)
|
||||||
|
private String common_filter;
|
||||||
|
|
||||||
@JsonBackReference
|
@JsonBackReference
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
private Dashbord_Header dashbord_Header;
|
private Dashbord_Header dashbord_Header;
|
||||||
|
|||||||
@@ -23,44 +23,35 @@ public class HeaderService {
|
|||||||
return headerRepository.save(dashbord_Header);
|
return headerRepository.save(dashbord_Header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Dashbord_Header> getdetails() {
|
public List<Dashbord_Header> getdetails() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return (List<Dashbord_Header>) headerRepository.findAll();
|
return (List<Dashbord_Header>) headerRepository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Dashbord_Header getdetailsbyId(int id) {
|
public Dashbord_Header getdetailsbyId(int id) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return headerRepository.findById(id);
|
return headerRepository.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void delete_by_id(int id) {
|
public void delete_by_id(int id) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
headerRepository.deleteById(id);
|
headerRepository.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Dashbord_Header update_dashboard_header(Dashbord_Header dashbord_Header) {
|
public Dashbord_Header update_dashboard_header(Dashbord_Header dashbord_Header) {
|
||||||
return headerRepository.save(dashbord_Header);
|
return headerRepository.save(dashbord_Header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Dashbord1_Line update_Dashbord1_Line(Dashbord1_Line dashbord1_Line) {
|
public Dashbord1_Line update_Dashbord1_Line(Dashbord1_Line dashbord1_Line) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return dashboard_lineRepository.save(dashbord1_Line);
|
return dashboard_lineRepository.save(dashbord1_Line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Dashbord_Header> get_by_module_id(int module_id) {
|
public List<Dashbord_Header> get_by_module_id(int module_id) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return (List<Dashbord_Header>) headerRepository.findbydashboardmodule(module_id);
|
return (List<Dashbord_Header>) headerRepository.findbydashboardmodule(module_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Dashbord1_Line> get_all_lines() {
|
public List<Dashbord1_Line> get_all_lines() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return (List<Dashbord1_Line>) dashboard_lineRepository.findAll();
|
return (List<Dashbord1_Line>) dashboard_lineRepository.findAll();
|
||||||
@@ -78,22 +69,16 @@ public class HeaderService {
|
|||||||
|
|
||||||
public Dashbord1_Line update_Dashbord1_Lineby_id(int id, Dashbord1_Line dashbord1_Line) {
|
public Dashbord1_Line update_Dashbord1_Lineby_id(int id, Dashbord1_Line dashbord1_Line) {
|
||||||
|
|
||||||
|
Dashbord1_Line oldline = dashboard_lineRepository.findById(id);
|
||||||
Dashbord1_Line oldline= dashboard_lineRepository.findById(id);
|
|
||||||
// .orElseThrow(() -> new ResourceNotFoundException(Constant.NOT_FOUND_EXCEPTION + " :" + id));
|
// .orElseThrow(() -> new ResourceNotFoundException(Constant.NOT_FOUND_EXCEPTION + " :" + id));
|
||||||
|
|
||||||
|
|
||||||
oldline.setAccountId(dashbord1_Line.getAccountId());
|
oldline.setAccountId(dashbord1_Line.getAccountId());
|
||||||
oldline.setHeader_id(dashbord1_Line.getHeader_id());
|
oldline.setHeader_id(dashbord1_Line.getHeader_id());
|
||||||
oldline.setModel(dashbord1_Line.getModel());
|
oldline.setModel(dashbord1_Line.getModel());
|
||||||
final Dashbord1_Line newline= dashboard_lineRepository.save(oldline);
|
oldline.setCommon_filter(dashbord1_Line.getCommon_filter());
|
||||||
|
|
||||||
|
final Dashbord1_Line newline = dashboard_lineRepository.save(oldline);
|
||||||
return newline;
|
return newline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,23 @@ import java.sql.ResultSetMetaData;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
@@ -24,7 +33,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import com.realnet.Payment.Paytm.PaytmPayment;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.realnet.SureConnect.Entities.Sure_Connect;
|
||||||
|
import com.realnet.SureConnect.Service.SureService;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
@@ -34,6 +46,9 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@RestController
|
@RestController
|
||||||
public class ChartBuilder {
|
public class ChartBuilder {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SureService sureService;
|
||||||
|
|
||||||
public List<Map<String, Object>> getAllDataFromTable(String tableName) {
|
public List<Map<String, Object>> getAllDataFromTable(String tableName) {
|
||||||
List<Map<String, Object>> tableData = new ArrayList<>();
|
List<Map<String, Object>> tableData = new ArrayList<>();
|
||||||
|
|
||||||
@@ -101,95 +116,74 @@ public class ChartBuilder {
|
|||||||
return tableData;
|
return tableData;
|
||||||
}
|
}
|
||||||
|
|
||||||
//...........................22.07.2023.............................//
|
@GetMapping(value = "/getValue")
|
||||||
|
public ResponseEntity<?> getValue(@RequestParam String apiUrl, @RequestParam Integer sureId,
|
||||||
|
@RequestParam(required = false) String key) throws IOException {
|
||||||
|
|
||||||
// @GetMapping(value = "/getdashjson/{job_type}")
|
System.out.println(" value get..");
|
||||||
// public ResponseEntity<?> jsonretun(@RequestParam String tableName, @PathVariable String job_type,
|
// Step 1: Fetch all table data from API
|
||||||
// @RequestParam String xAxis, @RequestParam String yAxis) throws IOException {
|
List<Map<String, Object>> tableData = getAllDataFromApi(apiUrl, sureId);
|
||||||
//
|
|
||||||
// List<Map<String, Object>> tableData = getAllDataFromTable(tableName); // Retrieve all data from the table
|
// Step 2: Handle null or empty key
|
||||||
//
|
if (key == null || key.trim().isEmpty()) {
|
||||||
// List<Object> yAxisValues = new ArrayList<>();
|
return ResponseEntity.badRequest().body("Key parameter is required");
|
||||||
// List<String> xAxisValues = new ArrayList<>();
|
}
|
||||||
//
|
|
||||||
// for (Map<String, Object> row : tableData) {
|
// Step 3: Extract unique values for that key
|
||||||
// for (Entry<String, Object> entry : row.entrySet()) {
|
Set<Object> uniqueValues = tableData.stream().map(row -> row.get(key)) // get value by key
|
||||||
// String key = entry.getKey();
|
.filter(Objects::nonNull) // remove nulls
|
||||||
// Object value = entry.getValue();
|
.collect(Collectors.toCollection(LinkedHashSet::new)); // keep unique + order
|
||||||
//
|
|
||||||
// if (key.equalsIgnoreCase(xAxis)) {
|
// Step 4: Convert to List
|
||||||
// xAxisValues.add(value.toString());
|
List<Object> resultList = new ArrayList<>(uniqueValues);
|
||||||
// } else if (key.equalsIgnoreCase(yAxis)) {
|
|
||||||
// yAxisValues.add(value);
|
// Step 5: Return as ResponseEntity
|
||||||
// }
|
return ResponseEntity.ok(resultList);
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
//
|
|
||||||
// StringBuilder jsonmap = new StringBuilder();
|
|
||||||
//
|
|
||||||
// if (job_type.equalsIgnoreCase("Bar Chart")) {
|
|
||||||
// jsonmap.append("[\n");
|
|
||||||
// } else if (job_type.equalsIgnoreCase("Line Chart")) {
|
|
||||||
// jsonmap.append(" {\r\n" + " \"chartData\": [\r\n" + " { \"data\": [");
|
|
||||||
// } else if (job_type.equalsIgnoreCase("Doughnut Chart")) {
|
|
||||||
// jsonmap.append("{\"chartData\": [[");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (int i = 0; i < xAxisValues.size(); i++) {
|
|
||||||
// String xValue = xAxisValues.get(i);
|
|
||||||
// Object yValue = yAxisValues.get(i);
|
|
||||||
//
|
|
||||||
// if (job_type.equalsIgnoreCase("Bar Chart")) {
|
|
||||||
// jsonmap.append("{\"name\": \"" + xValue + "\", \"progress\":\"" + yValue + "\"},\n");
|
|
||||||
// } else if (job_type.equalsIgnoreCase("Line Chart")) {
|
|
||||||
// jsonmap.append(yValue + ",");
|
|
||||||
// } else if (job_type.equalsIgnoreCase("Doughnut Chart")) {
|
|
||||||
// jsonmap.append(yValue + ",");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (!xAxisValues.isEmpty() && !yAxisValues.isEmpty()) {
|
|
||||||
// jsonmap.deleteCharAt(jsonmap.lastIndexOf(","));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (job_type.equalsIgnoreCase("Bar Chart")) {
|
|
||||||
// jsonmap.append("]");
|
|
||||||
// } else if (job_type.equalsIgnoreCase("Line Chart")) {
|
|
||||||
// jsonmap.append("], \"label\": \"" + yAxis + "\" }\r\n" + " ],\r\n" + " \"chartLabels\": [ ");
|
|
||||||
// } else if (job_type.equalsIgnoreCase("Doughnut Chart")) {
|
|
||||||
// jsonmap.append("]],\r\n" + " \"chartLabels\": [");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for (String xValue : xAxisValues) {
|
|
||||||
// jsonmap.append("\"" + xValue + "\",");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (!xAxisValues.isEmpty()) {
|
|
||||||
// jsonmap.deleteCharAt(jsonmap.lastIndexOf(","));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if (job_type.equalsIgnoreCase("Line Chart")) {
|
|
||||||
// jsonmap.append("] \n }\n");
|
|
||||||
// } else if (job_type.equalsIgnoreCase("Doughnut Chart")) {
|
|
||||||
// jsonmap.append("]\n" + "}");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return new ResponseEntity<>(jsonmap.toString(), HttpStatus.CREATED);
|
|
||||||
// }
|
|
||||||
|
|
||||||
@GetMapping(value = "/getdashjson/{job_type}")
|
@GetMapping(value = "/getdashjson/{job_type}")
|
||||||
public ResponseEntity<?> jsonretun2(@RequestParam String tableName, @PathVariable String job_type,
|
public ResponseEntity<?> jsonretun(@PathVariable String job_type, @RequestParam String tableName,
|
||||||
@RequestParam(required = false) String xAxis, @RequestParam(required = false) List<String> yAxes)
|
@RequestParam(required = false) String xAxis, @RequestParam(required = false) List<String> yAxes,
|
||||||
|
@RequestParam Integer sureId, @RequestParam(required = false) String parameter,
|
||||||
|
@RequestParam(required = false) String parameterValue, @RequestParam(required = false) String filters)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
|
System.out.println(" chart data getting...");
|
||||||
|
|
||||||
|
List<Map<String, Object>> tableData = getAllDataFromApi(tableName, sureId); // Retrieve all data from the table
|
||||||
|
|
||||||
|
// ✅ Filter table data if parameter and parameterValue are provided
|
||||||
|
if (parameter != null && !parameter.trim().isEmpty() && parameterValue != null
|
||||||
|
&& !parameterValue.trim().isEmpty()) {
|
||||||
|
|
||||||
|
tableData = tableData.stream().filter(row -> {
|
||||||
|
Object paramVal = row.get(parameter);
|
||||||
|
return paramVal != null && paramVal.toString().equalsIgnoreCase(parameterValue);
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
// ✅ Parse filters JSON (supports both string and array values)
|
||||||
|
if (filters != null && !filters.trim().isEmpty()) {
|
||||||
|
Map<String, Object> filtersMap;
|
||||||
|
try {
|
||||||
|
filtersMap = mapper.readValue(filters, new TypeReference<Map<String, Object>>() {
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
return new ResponseEntity<>("Invalid filters JSON format", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ Call reusable filter method
|
||||||
|
tableData = applyFilters(tableData, filtersMap);
|
||||||
|
}
|
||||||
|
|
||||||
StringBuilder jsonmap = new StringBuilder();
|
StringBuilder jsonmap = new StringBuilder();
|
||||||
|
|
||||||
if (job_type.equalsIgnoreCase("Grid View")) {
|
if (job_type.equalsIgnoreCase("Grid")) {
|
||||||
List<Map<String, Object>> allData = getAllDataFromApi(tableName);
|
|
||||||
|
|
||||||
jsonmap.append("[\n");
|
jsonmap.append("[\n");
|
||||||
|
|
||||||
for (Map<String, Object> row : allData) {
|
for (Map<String, Object> row : tableData) {
|
||||||
jsonmap.append("{\n");
|
jsonmap.append("{\n");
|
||||||
|
|
||||||
int colCount = 0;
|
int colCount = 0;
|
||||||
@@ -208,7 +202,7 @@ public class ChartBuilder {
|
|||||||
|
|
||||||
jsonmap.append("}");
|
jsonmap.append("}");
|
||||||
|
|
||||||
if (!row.equals(allData.get(allData.size() - 1))) {
|
if (!row.equals(tableData.get(tableData.size() - 1))) {
|
||||||
jsonmap.append(", ");
|
jsonmap.append(", ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -219,12 +213,11 @@ public class ChartBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (job_type.equalsIgnoreCase("Todo List") && yAxes != null && !yAxes.isEmpty()) {
|
if (job_type.equalsIgnoreCase("Todo List") && yAxes != null && !yAxes.isEmpty()) {
|
||||||
List<Map<String, Object>> allData = getAllDataFromApi(tableName);
|
|
||||||
|
|
||||||
String listName = yAxes.get(0); // Assuming the first column in yAxes to be the list name
|
String listName = yAxes.get(0); // Assuming the first column in yAxes to be the list name
|
||||||
List<Object> listData = new ArrayList<>();
|
List<Object> listData = new ArrayList<>();
|
||||||
|
|
||||||
for (Map<String, Object> row : allData) {
|
for (Map<String, Object> row : tableData) {
|
||||||
Object value = row.get(listName);
|
Object value = row.get(listName);
|
||||||
|
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
@@ -239,10 +232,9 @@ public class ChartBuilder {
|
|||||||
return new ResponseEntity<>(response, HttpStatus.CREATED);
|
return new ResponseEntity<>(response, HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Map<String, Object>> tableData = getAllDataFromApi(tableName); // Retrieve all data from the table
|
|
||||||
|
|
||||||
List<List<Object>> yAxisValuesList = new ArrayList<>();
|
List<List<Object>> yAxisValuesList = new ArrayList<>();
|
||||||
List<String> xAxisValues = new ArrayList<>();
|
List<String> xAxisValues = new ArrayList<>();
|
||||||
|
List<String> parameterValues = new ArrayList<>();
|
||||||
|
|
||||||
// Initialize a list for each y-axis parameter
|
// Initialize a list for each y-axis parameter
|
||||||
for (int i = 0; i < yAxes.size(); i++) {
|
for (int i = 0; i < yAxes.size(); i++) {
|
||||||
@@ -254,7 +246,7 @@ public class ChartBuilder {
|
|||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
|
|
||||||
if (key.equalsIgnoreCase(xAxis)) {
|
if (value != null && key.equalsIgnoreCase(xAxis)) {
|
||||||
xAxisValues.add(value.toString());
|
xAxisValues.add(value.toString());
|
||||||
} else {
|
} else {
|
||||||
int yIndex = yAxes.indexOf(key);
|
int yIndex = yAxes.indexOf(key);
|
||||||
@@ -262,361 +254,148 @@ public class ChartBuilder {
|
|||||||
yAxisValuesList.get(yIndex).add(value);
|
yAxisValuesList.get(yIndex).add(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (job_type.equalsIgnoreCase("Bar Chart")) {
|
jsonmap = getJson(jsonmap, yAxes, xAxisValues, yAxisValuesList, parameterValues);
|
||||||
jsonmap.append("{\n \"barChartData\": [\n");
|
|
||||||
|
|
||||||
for (int j = 0; j < yAxes.size(); j++) {
|
return new ResponseEntity<>(jsonmap.toString(), HttpStatus.CREATED);
|
||||||
String yAxis = yAxes.get(j);
|
}
|
||||||
|
|
||||||
jsonmap.append("{");
|
/**
|
||||||
jsonmap.append("\"data\": [");
|
* ✅ Reusable filter method Supports both single-value and multi-value filters
|
||||||
|
*/
|
||||||
|
private List<Map<String, Object>> applyFilters(List<Map<String, Object>> tableData,
|
||||||
|
Map<String, Object> filtersMap) {
|
||||||
|
if (filtersMap == null || filtersMap.isEmpty())
|
||||||
|
return tableData;
|
||||||
|
|
||||||
for (int i = 0; i < xAxisValues.size(); i++) {
|
return tableData.stream().filter(row -> {
|
||||||
Object yValue = yAxisValuesList.get(j).get(i);
|
for (Map.Entry<String, Object> entry : filtersMap.entrySet()) {
|
||||||
jsonmap.append(yValue);
|
Object filterValue = entry.getValue();
|
||||||
|
Object rowValue = row.get(entry.getKey());
|
||||||
|
|
||||||
if (i < xAxisValues.size() - 1) {
|
// skip empty filters
|
||||||
jsonmap.append(",");
|
if (filterValue == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// ✅ Multi-value filter (List or Array)
|
||||||
|
if (filterValue instanceof List<?>) {
|
||||||
|
List<?> filterList = (List<?>) filterValue;
|
||||||
|
if (filterList.isEmpty())
|
||||||
|
continue;
|
||||||
|
if (rowValue == null
|
||||||
|
|| !filterList.stream().anyMatch(v -> v.toString().equalsIgnoreCase(rowValue.toString()))) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// ✅ Single-value filter
|
||||||
jsonmap.append("],");
|
else {
|
||||||
jsonmap.append("\"label\": \"" + yAxis + "\"");
|
if (rowValue == null || !rowValue.toString().equalsIgnoreCase(filterValue.toString())) {
|
||||||
jsonmap.append("}");
|
return false;
|
||||||
|
|
||||||
if (j < yAxes.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],\n \"barChartLabels\": [ ");
|
|
||||||
|
|
||||||
for (String xValue : xAxisValues) {
|
|
||||||
jsonmap.append("\"" + xValue + "\",");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xAxisValues.isEmpty()) {
|
|
||||||
jsonmap.deleteCharAt(jsonmap.lastIndexOf(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("] \n }\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (job_type.equalsIgnoreCase("Line Chart")) {
|
|
||||||
jsonmap.append("{\n \"chartData\": [\n");
|
|
||||||
|
|
||||||
for (int j = 0; j < yAxes.size(); j++) {
|
|
||||||
String yAxis = yAxes.get(j);
|
|
||||||
|
|
||||||
jsonmap.append("{");
|
|
||||||
jsonmap.append("\"data\": [");
|
|
||||||
|
|
||||||
for (int i = 0; i < xAxisValues.size(); i++) {
|
|
||||||
Object yValue = yAxisValuesList.get(j).get(i);
|
|
||||||
jsonmap.append(yValue);
|
|
||||||
|
|
||||||
if (i < xAxisValues.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
jsonmap.append("],");
|
public StringBuilder getJson(StringBuilder jsonmap, List<String> yAxes, List<String> xAxisValues,
|
||||||
jsonmap.append("\"label\": \"" + yAxis + "\"");
|
List<List<Object>> yAxisValuesList, List<String> parameterValues) {
|
||||||
jsonmap.append("}");
|
|
||||||
|
|
||||||
if (j < yAxes.size() - 1) {
|
jsonmap.append("{\n \"chartData\": [\n");
|
||||||
jsonmap.append(",");
|
|
||||||
|
for (int j = 0; j < yAxes.size(); j++) {
|
||||||
|
String yAxis = yAxes.get(j);
|
||||||
|
|
||||||
|
jsonmap.append("{");
|
||||||
|
jsonmap.append("\"data\": [");
|
||||||
|
|
||||||
|
// --- Y-Axis Data ---
|
||||||
|
for (int i = 0; i < xAxisValues.size(); i++) {
|
||||||
|
List<Object> list = yAxisValuesList.get(j);
|
||||||
|
if (list == null || list.isEmpty() || i >= list.size()) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],\n \"chartLabels\": [ ");
|
Object yValue = list.get(i);
|
||||||
|
if (yValue instanceof Number) {
|
||||||
for (String xValue : xAxisValues) {
|
|
||||||
jsonmap.append("\"" + xValue + "\",");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xAxisValues.isEmpty()) {
|
|
||||||
jsonmap.deleteCharAt(jsonmap.lastIndexOf(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("] \n }\n");
|
|
||||||
} else if (job_type.equalsIgnoreCase("Doughnut Chart")) {
|
|
||||||
jsonmap.append("{\"chartData\": [\n");
|
|
||||||
|
|
||||||
for (int j = 0; j < yAxes.size(); j++) {
|
|
||||||
String yAxis = yAxes.get(j);
|
|
||||||
|
|
||||||
jsonmap.append("[");
|
|
||||||
|
|
||||||
for (int i = 0; i < xAxisValues.size(); i++) {
|
|
||||||
Object yValue = yAxisValuesList.get(j).get(i);
|
|
||||||
jsonmap.append(yValue);
|
jsonmap.append(yValue);
|
||||||
|
} else if (yValue instanceof String) {
|
||||||
if (i < xAxisValues.size() - 1) {
|
String yStr = ((String) yValue).trim();
|
||||||
jsonmap.append(",");
|
try {
|
||||||
|
Double num = Double.parseDouble(yStr);
|
||||||
|
jsonmap.append(num);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
continue; // skip non-numeric
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
continue; // skip invalid
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonmap.append("]");
|
|
||||||
|
|
||||||
if (j < yAxes.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],\n \"chartLabels\": [");
|
|
||||||
|
|
||||||
for (String xValue : xAxisValues) {
|
|
||||||
jsonmap.append("\"" + xValue + "\",");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xAxisValues.isEmpty()) {
|
|
||||||
jsonmap.deleteCharAt(jsonmap.lastIndexOf(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("]\n}");
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (job_type.equalsIgnoreCase("Radar Chart")) {
|
|
||||||
jsonmap.append("{\n \"radarChartData\": [\n");
|
|
||||||
|
|
||||||
for (int j = 0; j < yAxes.size(); j++) {
|
|
||||||
String yAxis = yAxes.get(j);
|
|
||||||
|
|
||||||
jsonmap.append("{");
|
|
||||||
jsonmap.append("\"data\": [");
|
|
||||||
|
|
||||||
for (int i = 0; i < xAxisValues.size(); i++) {
|
|
||||||
Object yValue = yAxisValuesList.get(j).get(i);
|
|
||||||
jsonmap.append(yValue);
|
|
||||||
|
|
||||||
if (i < xAxisValues.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],");
|
|
||||||
jsonmap.append("\"label\": \"" + yAxis + "\"");
|
|
||||||
jsonmap.append("}");
|
|
||||||
|
|
||||||
if (j < yAxes.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],\n \"radarChartLabels\": [ ");
|
|
||||||
|
|
||||||
for (String xValue : xAxisValues) {
|
|
||||||
jsonmap.append("\"" + xValue + "\",");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xAxisValues.isEmpty()) {
|
|
||||||
jsonmap.deleteCharAt(jsonmap.lastIndexOf(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("] \n }\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (job_type.equalsIgnoreCase("PolarArea Chart")) {
|
|
||||||
jsonmap.append("{\n \"polarAreaChartData\": [\n");
|
|
||||||
|
|
||||||
for (int j = 0; j < yAxes.size(); j++) {
|
|
||||||
String yAxis = yAxes.get(j);
|
|
||||||
|
|
||||||
jsonmap.append("{");
|
|
||||||
jsonmap.append("\"data\": [");
|
|
||||||
|
|
||||||
for (int i = 0; i < xAxisValues.size(); i++) {
|
|
||||||
Object yValue = yAxisValuesList.get(j).get(i);
|
|
||||||
jsonmap.append(yValue);
|
|
||||||
|
|
||||||
if (i < xAxisValues.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],");
|
|
||||||
jsonmap.append("\"label\": \"" + yAxis + "\"");
|
|
||||||
jsonmap.append("}");
|
|
||||||
|
|
||||||
if (j < yAxes.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],\n \"polarAreaChartLabels\": [ ");
|
|
||||||
|
|
||||||
for (String xValue : xAxisValues) {
|
|
||||||
jsonmap.append("\"" + xValue + "\",");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xAxisValues.isEmpty()) {
|
|
||||||
jsonmap.deleteCharAt(jsonmap.lastIndexOf(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("] \n }\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (job_type.equalsIgnoreCase("Pie Chart")) {
|
|
||||||
jsonmap.append("{\n \"pieChartData\": [");
|
|
||||||
|
|
||||||
for (int i = 0; i < yAxisValuesList.get(0).size(); i++) { // Assuming "mark" is the first item in yAxes
|
|
||||||
jsonmap.append(yAxisValuesList.get(0).get(i)); // Use the y-axis values
|
|
||||||
|
|
||||||
if (i < yAxisValuesList.get(0).size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],\n \"pieChartLabels\": [ ");
|
|
||||||
|
|
||||||
for (int i = 0; i < xAxisValues.size(); i++) { // Assuming "name" is the x-axis
|
|
||||||
jsonmap.append("\"" + xAxisValues.get(i) + "\""); // Use the x-axis values
|
|
||||||
|
|
||||||
if (i < xAxisValues.size() - 1) {
|
if (i < xAxisValues.size() - 1) {
|
||||||
jsonmap.append(",");
|
jsonmap.append(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonmap.append("] \n }\n");
|
// 🧹 Remove trailing comma
|
||||||
|
int lastIndex = jsonmap.lastIndexOf(",");
|
||||||
|
if (lastIndex == jsonmap.length() - 1) {
|
||||||
|
jsonmap.deleteCharAt(lastIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonmap.append("],");
|
||||||
|
jsonmap.append("\"label\": \"" + yAxis + "\"");
|
||||||
|
jsonmap.append("}");
|
||||||
|
|
||||||
|
if (j < yAxes.size() - 1) {
|
||||||
|
jsonmap.append(",");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (job_type.equalsIgnoreCase("Bubble Chart")) {
|
// --- Chart Labels (X-Axis) ---
|
||||||
jsonmap.append("{\n \"bubbleChartData\": [\n");
|
jsonmap.append("],\n \"chartLabels\": [");
|
||||||
|
for (String xValue : xAxisValues) {
|
||||||
for (int j = 0; j < yAxes.size(); j++) {
|
jsonmap.append("\"").append(xValue).append("\",");
|
||||||
String yAxis = yAxes.get(j);
|
|
||||||
|
|
||||||
jsonmap.append("{");
|
|
||||||
jsonmap.append("\"data\": [");
|
|
||||||
|
|
||||||
for (int i = 0; i < xAxisValues.size(); i++) {
|
|
||||||
Object xValue = xAxisValues.get(i);
|
|
||||||
Object yValue = yAxisValuesList.get(j).get(i);
|
|
||||||
int radius = 5 + (i % 3) * 3; // Adjust the radius as needed
|
|
||||||
|
|
||||||
jsonmap.append("{ \"x\": " + xValue + ", \"y\": " + yValue + ", \"r\": " + radius + "}");
|
|
||||||
|
|
||||||
if (i < xAxisValues.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],");
|
|
||||||
jsonmap.append("\"label\": \"" + yAxis + "\"");
|
|
||||||
jsonmap.append("}");
|
|
||||||
|
|
||||||
if (j < yAxes.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],\n \"bubbleChartLabels\": [ ");
|
|
||||||
|
|
||||||
for (String label : xAxisValues) {
|
|
||||||
jsonmap.append("\"" + label + "\",");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xAxisValues.isEmpty()) {
|
|
||||||
jsonmap.deleteCharAt(jsonmap.lastIndexOf(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("] \n }\n");
|
|
||||||
} else if (job_type.equalsIgnoreCase("Scatter Chart")) {
|
|
||||||
jsonmap.append("{\n \"scatterChartData\": [\n");
|
|
||||||
|
|
||||||
for (int j = 0; j < yAxes.size(); j++) {
|
|
||||||
String yAxis = yAxes.get(j);
|
|
||||||
|
|
||||||
jsonmap.append("{");
|
|
||||||
jsonmap.append("\"data\": [");
|
|
||||||
|
|
||||||
for (int i = 0; i < xAxisValues.size(); i++) {
|
|
||||||
Object xValue = xAxisValues.get(i);
|
|
||||||
Object yValue = yAxisValuesList.get(j).get(i);
|
|
||||||
|
|
||||||
jsonmap.append("{ \"x\": " + xValue + ", \"y\": " + yValue + "}");
|
|
||||||
|
|
||||||
if (i < xAxisValues.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],");
|
|
||||||
jsonmap.append("\"label\": \"" + yAxis + "\"");
|
|
||||||
jsonmap.append("}");
|
|
||||||
|
|
||||||
if (j < yAxes.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],\n \"scatterChartLabels\": [ ");
|
|
||||||
|
|
||||||
for (String label : xAxisValues) {
|
|
||||||
jsonmap.append("\"" + label + "\",");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xAxisValues.isEmpty()) {
|
|
||||||
jsonmap.deleteCharAt(jsonmap.lastIndexOf(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("] \n }\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (job_type.equalsIgnoreCase("Dynamic Chart")) {
|
if (!xAxisValues.isEmpty()) {
|
||||||
jsonmap.append("{\n \"dynamicChartData\": [\n");
|
jsonmap.deleteCharAt(jsonmap.lastIndexOf(","));
|
||||||
|
|
||||||
for (int j = 0; j < yAxes.size(); j++) {
|
|
||||||
String yAxis = yAxes.get(j);
|
|
||||||
|
|
||||||
jsonmap.append("{");
|
|
||||||
jsonmap.append("\"data\": [");
|
|
||||||
|
|
||||||
for (int i = 0; i < xAxisValues.size(); i++) {
|
|
||||||
Object yValue = yAxisValuesList.get(j).get(i);
|
|
||||||
jsonmap.append(yValue);
|
|
||||||
|
|
||||||
if (i < xAxisValues.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],");
|
|
||||||
jsonmap.append("\"label\": \"" + yAxis + "\"");
|
|
||||||
jsonmap.append("}");
|
|
||||||
|
|
||||||
if (j < yAxes.size() - 1) {
|
|
||||||
jsonmap.append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("],\n \"dynamicChartLabels\": [ ");
|
|
||||||
|
|
||||||
for (String xValue : xAxisValues) {
|
|
||||||
jsonmap.append("\"" + xValue + "\",");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xAxisValues.isEmpty()) {
|
|
||||||
jsonmap.deleteCharAt(jsonmap.lastIndexOf(","));
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonmap.append("] \n }\n");
|
|
||||||
}
|
}
|
||||||
|
jsonmap.append("],");
|
||||||
|
|
||||||
return new ResponseEntity<>(jsonmap.toString(), HttpStatus.CREATED);
|
// --- Parameter Values ---
|
||||||
|
jsonmap.append("\n \"parameterValues\": [");
|
||||||
|
if (parameterValues != null && !parameterValues.isEmpty()) {
|
||||||
|
for (String param : parameterValues) {
|
||||||
|
if (param != null && !param.trim().isEmpty()) {
|
||||||
|
jsonmap.append("\"").append(param.trim()).append("\",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Remove trailing comma
|
||||||
|
int lastComma = jsonmap.lastIndexOf(",");
|
||||||
|
if (lastComma == jsonmap.length() - 1) {
|
||||||
|
jsonmap.deleteCharAt(lastComma);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jsonmap.append("]\n}");
|
||||||
|
|
||||||
|
return jsonmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @GetMapping("/getKey")
|
@GetMapping("/getAllKeys")
|
||||||
public List<Map<String, Object>> getAllKeyFromApi(String apiUrl) {
|
public Set<String> getAllKeys(@RequestParam String apiUrl, @RequestParam Integer sureId) {
|
||||||
|
List<Map<String, Object>> apiData = getAllKeyFromApi(apiUrl, sureId);
|
||||||
|
return getAllKeys(apiData);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map<String, Object>> getAllKeyFromApi(String apiUrl, Integer sureId) {
|
||||||
List<Map<String, Object>> apiData = new ArrayList<>();
|
List<Map<String, Object>> apiData = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Make a GET request using the provided URL
|
// Make a GET request using the provided URL
|
||||||
ResponseEntity<Object> responseEntity = GET(apiUrl);
|
ResponseEntity<Object> responseEntity = GETWithObject(apiUrl, sureId);
|
||||||
|
|
||||||
// Convert the response to a List<Map<String, Object>>
|
// Convert the response to a List<Map<String, Object>>
|
||||||
if (responseEntity.getBody() instanceof List) {
|
if (responseEntity.getBody() instanceof List) {
|
||||||
@@ -636,12 +415,6 @@ public class ChartBuilder {
|
|||||||
return apiData;
|
return apiData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getAllKeys")
|
|
||||||
public Set<String> getAllKeys(@RequestParam String apiUrl) {
|
|
||||||
List<Map<String, Object>> apiData = getAllKeyFromApi(apiUrl);
|
|
||||||
return getAllKeys(apiData);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Set<String> getAllKeys(List<Map<String, Object>> apiData) {
|
private Set<String> getAllKeys(List<Map<String, Object>> apiData) {
|
||||||
Set<String> allKeys = new HashSet<>();
|
Set<String> allKeys = new HashSet<>();
|
||||||
|
|
||||||
@@ -652,12 +425,12 @@ public class ChartBuilder {
|
|||||||
return allKeys;
|
return allKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Map<String, Object>> getAllDataFromApi(String apiUrl) {
|
public List<Map<String, Object>> getAllDataFromApi(String apiUrl, Integer sureId) {
|
||||||
List<Map<String, Object>> apiData = new ArrayList<>();
|
List<Map<String, Object>> apiData = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Make a GET request using the provided URL
|
// Make a GET request using the provided URL
|
||||||
ResponseEntity<Object> responseEntity = GET(apiUrl);
|
ResponseEntity<Object> responseEntity = GETWithObject(apiUrl, sureId);
|
||||||
|
|
||||||
// Convert the response to a List<Map<String, Object>>
|
// Convert the response to a List<Map<String, Object>>
|
||||||
if (responseEntity.getBody() instanceof List) {
|
if (responseEntity.getBody() instanceof List) {
|
||||||
@@ -678,7 +451,7 @@ public class ChartBuilder {
|
|||||||
return apiData;
|
return apiData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResponseEntity<Object> GET(String get) {
|
public ResponseEntity<Object> GET1(String get) {
|
||||||
RestTemplate restTemplate = new RestTemplate();
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
ResponseEntity<Object> u = restTemplate.getForEntity(get, Object.class);
|
ResponseEntity<Object> u = restTemplate.getForEntity(get, Object.class);
|
||||||
@@ -686,4 +459,52 @@ public class ChartBuilder {
|
|||||||
return u;
|
return u;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<String> GET(String url, Integer sureid) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setAccept(Collections.singletonList(MediaType.ALL)); // accept JSON or XML
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
// 🔹 Add your token here (you can make it dynamic)
|
||||||
|
String token = getToken(sureid); // helper method (see below)
|
||||||
|
if (token != null && !token.isEmpty()) {
|
||||||
|
headers.set("Authorization", "Bearer " + token);
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||||
|
|
||||||
|
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<Object> GETWithObject(String url, Integer sureid) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setAccept(Collections.singletonList(MediaType.ALL)); // accept JSON or XML
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
// 🔹 Add your token here (you can make it dynamic)
|
||||||
|
String token = getToken(sureid); // helper method (see below)
|
||||||
|
if (token != null && !token.isEmpty()) {
|
||||||
|
headers.set("Authorization", "Bearer " + token);
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||||
|
|
||||||
|
ResponseEntity<Object> response = restTemplate.exchange(url, HttpMethod.GET, entity, Object.class);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getToken(Integer sureid) {
|
||||||
|
Sure_Connect connect = sureService.getbyid(sureid);
|
||||||
|
String access_token = connect.getAccess_token();
|
||||||
|
|
||||||
|
return access_token; // optional
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,49 @@
|
|||||||
|
package com.realnet.Dashboard_builder.Controllers;
|
||||||
|
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class DashboardMockController {
|
||||||
|
|
||||||
|
@GetMapping("/api/getDummyDashboardData")
|
||||||
|
public ResponseEntity<List<Map<String, Object>>> getDummyDashboardData() {
|
||||||
|
List<Map<String, Object>> dataList = new ArrayList<>();
|
||||||
|
|
||||||
|
String[] salesReps = { "Gaurav", "Ravi", "Ankit", "Neha", "Kiran" };
|
||||||
|
String[] partners = { "IBM", "Microsoft", "TCS", "Infosys", "Wipro" };
|
||||||
|
String[] regions = { "Asia", "Europe", "North America", "South America", "Africa" };
|
||||||
|
String[] channels = { "Online", "Retail", "Direct", "Distributor", "Reseller" };
|
||||||
|
String[] products = { "Laptops", "Servers", "Networking", "Cloud", "AI" };
|
||||||
|
|
||||||
|
for (int i = 1; i <= 50; i++) {
|
||||||
|
Map<String, Object> row = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
// 🧩 Fixed pattern numeric data
|
||||||
|
row.put("leadCount", 100 + (i * 10));
|
||||||
|
row.put("dealValue", 5000 + (i * 750));
|
||||||
|
row.put("conversionRate", (i % 100));
|
||||||
|
row.put("activeUsers", 50 + (i * 5));
|
||||||
|
row.put("visits", 200 + (i * 15));
|
||||||
|
|
||||||
|
// 🧠 Repeated pattern text data
|
||||||
|
row.put("salesRep", salesReps[i % salesReps.length]);
|
||||||
|
row.put("partner", partners[i % partners.length]);
|
||||||
|
row.put("region", regions[i % regions.length]);
|
||||||
|
row.put("channel", channels[i % channels.length]);
|
||||||
|
row.put("productLine", products[i % products.length]);
|
||||||
|
|
||||||
|
// 📅 Sequential date data
|
||||||
|
row.put("createdDate", LocalDate.of(2024, (i % 12) + 1, ((i % 28) + 1)));
|
||||||
|
row.put("lastUpdated", LocalDate.of(2025, ((i + 2) % 12) + 1, ((i + 3) % 28) + 1));
|
||||||
|
|
||||||
|
dataList.add(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ResponseEntity.ok(dataList);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
package com.realnet.DataLake.Controllers;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.realnet.DataLake.Entity.Data_lake;
|
||||||
|
import com.realnet.DataLake.Services.Data_lakeService;
|
||||||
|
import com.realnet.fnd.response.EntityResponse;
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Data_lake")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class Data_lakeController {
|
||||||
|
@Autowired
|
||||||
|
private Data_lakeService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
@PostMapping("/Data_lake")
|
||||||
|
public Data_lake Savedata(@RequestBody Data_lake data) {
|
||||||
|
Data_lake save = Service.Savedata(data);
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/Data_lake/{id}")
|
||||||
|
public Data_lake update(@RequestBody Data_lake data, @PathVariable Integer id) {
|
||||||
|
Data_lake update = Service.update(data, id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Data_lake/getall/page")
|
||||||
|
public Page<Data_lake> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Data_lake> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/Data_lake")
|
||||||
|
public List<Data_lake> getdetails() {
|
||||||
|
List<Data_lake> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Data_lake")
|
||||||
|
public List<Data_lake> getallwioutsec() {
|
||||||
|
List<Data_lake> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/Data_lake/{id}")
|
||||||
|
public Data_lake getdetailsbyId(@PathVariable Integer id) {
|
||||||
|
Data_lake get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/Data_lake/{id}")
|
||||||
|
public ResponseEntity<?> delete_by_id(@PathVariable Integer id) {
|
||||||
|
Service.delete_by_id(id);
|
||||||
|
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// json Upadted
|
||||||
|
|
||||||
|
@PutMapping("/Data_lake/json/{id}")
|
||||||
|
public Data_lake update(@PathVariable Integer id) throws JsonProcessingException {
|
||||||
|
Data_lake update = Service.applyCalculation(id);
|
||||||
|
System.out.println("clculation applied..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/Data_lake/merge/{id}")
|
||||||
|
public ResponseEntity<?> mergeBatchData(@PathVariable Integer id) {
|
||||||
|
try {
|
||||||
|
// Get merged JSON string from service
|
||||||
|
String mergedJson = Service.mergeBatchData(id);
|
||||||
|
|
||||||
|
// Parse the merged JSON string back into JSON structure
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
JsonNode jsonNode = mapper.readTree(mergedJson);
|
||||||
|
|
||||||
|
// Return as actual JSON (not as string)
|
||||||
|
return ResponseEntity.ok(jsonNode);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Build error response manually (Map.of() not available in Java 8)
|
||||||
|
Map<String, String> error = new HashMap<>();
|
||||||
|
error.put("error", e.getMessage());
|
||||||
|
return ResponseEntity.status(500).body(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.realnet.DataLake.Controllers;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/token/api")
|
||||||
|
public class XmlApiExample {
|
||||||
|
|
||||||
|
@GetMapping(value = "/getUser", produces = MediaType.APPLICATION_XML_VALUE)
|
||||||
|
public User getUser() {
|
||||||
|
User user = new User();
|
||||||
|
user.setId(101);
|
||||||
|
user.setName("John Doe");
|
||||||
|
user.setEmail("john.doe@example.com");
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dummy XML model class
|
||||||
|
@XmlRootElement(name = "user")
|
||||||
|
public static class User {
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
// Getters and setters
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package com.realnet.DataLake.Controllers;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.realnet.DataLake.Entity.Data_lake;
|
||||||
|
import com.realnet.DataLake.Services.Data_lakeService;
|
||||||
|
import com.realnet.fnd.response.EntityResponse;
|
||||||
|
|
||||||
|
@RequestMapping(value = "/token/Data_lake")
|
||||||
|
@CrossOrigin("*")
|
||||||
|
@RestController
|
||||||
|
public class tokenFree_Data_lakeController {
|
||||||
|
@Autowired
|
||||||
|
private Data_lakeService Service;
|
||||||
|
|
||||||
|
@Value("${projectPath}")
|
||||||
|
private String projectPath;
|
||||||
|
|
||||||
|
@PostMapping("/Data_lake")
|
||||||
|
public Data_lake Savedata(@RequestBody Data_lake data) {
|
||||||
|
Data_lake save = Service.Savedata(data);
|
||||||
|
|
||||||
|
System.out.println("data saved..." + save);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/Data_lake/{id}")
|
||||||
|
public Data_lake update(@RequestBody Data_lake data, @PathVariable Integer id) {
|
||||||
|
Data_lake update = Service.update(data, id);
|
||||||
|
System.out.println("data update..." + update);
|
||||||
|
return update;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get all with pagination
|
||||||
|
@GetMapping("/Data_lake/getall/page")
|
||||||
|
public Page<Data_lake> getall(@RequestParam(value = "page", required = false) Integer page,
|
||||||
|
@RequestParam(value = "size", required = false) Integer size) {
|
||||||
|
Pageable paging = PageRequest.of(page, size);
|
||||||
|
Page<Data_lake> get = Service.getAllWithPagination(paging);
|
||||||
|
|
||||||
|
return get;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/Data_lake")
|
||||||
|
public List<Data_lake> getdetails() {
|
||||||
|
List<Data_lake> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
// get all without authentication
|
||||||
|
|
||||||
|
@GetMapping("/token/Data_lake")
|
||||||
|
public List<Data_lake> getallwioutsec() {
|
||||||
|
List<Data_lake> get = Service.getdetails();
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/Data_lake/{id}")
|
||||||
|
public Data_lake getdetailsbyId(@PathVariable Integer id) {
|
||||||
|
Data_lake get = Service.getdetailsbyId(id);
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/Data_lake/{id}")
|
||||||
|
public ResponseEntity<?> delete_by_id(@PathVariable Integer id) {
|
||||||
|
Service.delete_by_id(id);
|
||||||
|
return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/Data_lake/merge/{id}")
|
||||||
|
public ResponseEntity<?> mergeBatchData(@PathVariable Integer id) {
|
||||||
|
try {
|
||||||
|
// Get merged JSON string from service
|
||||||
|
String mergedJson = Service.mergeBatchData(id);
|
||||||
|
|
||||||
|
// Parse the merged JSON string back into JSON structure
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
JsonNode jsonNode = mapper.readTree(mergedJson);
|
||||||
|
|
||||||
|
// Return as actual JSON (not as string)
|
||||||
|
return ResponseEntity.ok(jsonNode);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Build error response manually (Map.of() not available in Java 8)
|
||||||
|
Map<String, String> error = new HashMap<>();
|
||||||
|
error.put("error", e.getMessage());
|
||||||
|
return ResponseEntity.status(500).body(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.realnet.DataLake.Entity;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Lob;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class BatchData {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private Integer datalake_id;
|
||||||
|
|
||||||
|
@Lob
|
||||||
|
@Column(columnDefinition = "TEXT")
|
||||||
|
private String batchjson;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.realnet.DataLake.Entity;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Lob;
|
||||||
|
|
||||||
|
import com.realnet.WhoColumn.Entity.Extension;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Data_lake extends Extension {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Integer id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private String schedule;
|
||||||
|
|
||||||
|
private String cron_job;
|
||||||
|
|
||||||
|
@Lob
|
||||||
|
@Column(columnDefinition = "TEXT")
|
||||||
|
private String json;
|
||||||
|
|
||||||
|
private Integer batch_volume;
|
||||||
|
|
||||||
|
private Integer sure_connect_id;
|
||||||
|
private String sureconnect_name;
|
||||||
|
|
||||||
|
private String url_endpoint;
|
||||||
|
|
||||||
|
private Integer ref_datalake_id;
|
||||||
|
|
||||||
|
@Lob
|
||||||
|
@Column(columnDefinition = "TEXT")
|
||||||
|
private String calculated_field_json;
|
||||||
|
|
||||||
|
@Lob
|
||||||
|
@Column(columnDefinition = "TEXT")
|
||||||
|
private String groupby_json;
|
||||||
|
|
||||||
|
private Boolean iscalculatedfield;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.realnet.DataLake.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.realnet.DataLake.Entity.BatchData;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface BatchDataRepository extends JpaRepository<BatchData, Integer> {
|
||||||
|
|
||||||
|
@Query(value = "select * from batch_data where created_by=?1", nativeQuery = true)
|
||||||
|
List<BatchData> findAll(Long creayedBy);
|
||||||
|
|
||||||
|
@Query(value = "select * from batch_data where created_by=?1", nativeQuery = true)
|
||||||
|
Page<BatchData> findAll(Long creayedBy, Pageable page);
|
||||||
|
|
||||||
|
@Query(value = "select * from batch_data", nativeQuery = true)
|
||||||
|
List<BatchData> findByDatalake_id(Integer datalake_id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.realnet.DataLake.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.realnet.DataLake.Entity.Data_lake;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface Data_lakeRepository extends JpaRepository<Data_lake, Integer> {
|
||||||
|
|
||||||
|
@Query(value = "select * from data_lake where created_by=?1", nativeQuery = true)
|
||||||
|
List<Data_lake> findAll(Long creayedBy);
|
||||||
|
|
||||||
|
@Query(value = "select * from data_lake where created_by=?1", nativeQuery = true)
|
||||||
|
Page<Data_lake> findAll(Long creayedBy, Pageable page);
|
||||||
|
|
||||||
|
@Query(value = "select * from data_lake where created_by=?1 && ref_datalake_id=?2", nativeQuery = true)
|
||||||
|
List<Data_lake> findAllByRefDatlakeId(Long creayedBy, Integer ref_datalake_id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,669 @@
|
|||||||
|
package com.realnet.DataLake.Services;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.script.ScriptEngine;
|
||||||
|
import javax.script.ScriptEngineManager;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
|
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||||
|
import com.realnet.DataLake.Entity.BatchData;
|
||||||
|
import com.realnet.DataLake.Entity.Data_lake;
|
||||||
|
import com.realnet.DataLake.Repository.BatchDataRepository;
|
||||||
|
import com.realnet.DataLake.Repository.Data_lakeRepository;
|
||||||
|
import com.realnet.SureConnect.Service.SureService;
|
||||||
|
import com.realnet.realm.Entity.Realm;
|
||||||
|
import com.realnet.realm.Services.RealmService;
|
||||||
|
import com.realnet.users.entity1.AppUser;
|
||||||
|
import com.realnet.users.service1.AppUserServiceImpl;
|
||||||
|
import com.realnet.utils.Port_Constant;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class Data_lakeService {
|
||||||
|
@Autowired
|
||||||
|
private Data_lakeRepository Repository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BatchDataRepository batchRepo;
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
@Autowired
|
||||||
|
private RealmService realmService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SureService sureService;
|
||||||
|
|
||||||
|
public Data_lake Savedata(Data_lake data) {
|
||||||
|
|
||||||
|
data.setUpdatedBy(getUser().getUserId());
|
||||||
|
data.setCreatedBy(getUser().getUserId());
|
||||||
|
data.setAccountId(getUser().getAccount().getAccount_id());
|
||||||
|
|
||||||
|
if (data.getSure_connect_id() != null) {
|
||||||
|
|
||||||
|
data.setSureconnect_name(sureService.getbyid(data.getSure_connect_id()).getConnection_name());
|
||||||
|
}
|
||||||
|
|
||||||
|
Data_lake save = Repository.save(data);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get all with pagination
|
||||||
|
public Page<Data_lake> getAllWithPagination(Pageable page) {
|
||||||
|
return Repository.findAll(getUser().getUserId(), page);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Data_lake> getdetails() {
|
||||||
|
List<Realm> realm = realmService.findByUserId(getUser().getUserId());
|
||||||
|
List<Data_lake> all = Repository.findAll(getUser().getUserId());
|
||||||
|
|
||||||
|
return all;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Data_lake getdetailsbyId(Integer id) {
|
||||||
|
return Repository.findById(id).get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delete_by_id(Integer id) {
|
||||||
|
Repository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Data_lake update(Data_lake data, Integer id) {
|
||||||
|
Data_lake old = Repository.findById(id).get();
|
||||||
|
// id auto-generated hai → update nahi karenge
|
||||||
|
|
||||||
|
if (data.getName() != null) {
|
||||||
|
old.setName(data.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.getUrl() != null) {
|
||||||
|
old.setUrl(data.getUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.getSchedule() != null) {
|
||||||
|
old.setSchedule(data.getSchedule());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.getCron_job() != null) {
|
||||||
|
old.setCron_job(data.getCron_job());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.getJson() != null) {
|
||||||
|
old.setJson(data.getJson());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.getBatch_volume() != null) {
|
||||||
|
old.setBatch_volume(data.getBatch_volume());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.getSure_connect_id() != null) {
|
||||||
|
old.setSure_connect_id(data.getSure_connect_id());
|
||||||
|
|
||||||
|
old.setSureconnect_name(sureService.getbyid(data.getSure_connect_id()).getConnection_name());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.getUrl_endpoint() != null) {
|
||||||
|
old.setUrl_endpoint(data.getUrl_endpoint());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.getCalculated_field_json() != null) {
|
||||||
|
old.setCalculated_field_json(data.getCalculated_field_json());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.getIscalculatedfield() != null) {
|
||||||
|
old.setIscalculatedfield(data.getIscalculatedfield());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.getGroupby_json() != null) {
|
||||||
|
old.setGroupby_json(data.getGroupby_json());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.getRef_datalake_id() != null) {
|
||||||
|
old.setRef_datalake_id(data.getRef_datalake_id());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
final Data_lake test = Repository.save(old);
|
||||||
|
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Data_lake applyCalculation(Integer id) throws JsonProcessingException {
|
||||||
|
|
||||||
|
Data_lake old = Repository.findById(id).get();
|
||||||
|
|
||||||
|
String url = old.getUrl();
|
||||||
|
|
||||||
|
ResponseEntity<String> response = GETAsString(url);
|
||||||
|
String rawBody = response.getBody();
|
||||||
|
|
||||||
|
List<Data_lake> datlakes = Repository.findAllByRefDatlakeId(getUser().getUserId(), id);
|
||||||
|
|
||||||
|
datlakes.forEach(lake -> {
|
||||||
|
try {
|
||||||
|
Updatejson(lake.getId(), rawBody);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Data_lake saved = Updatejson(id, rawBody);
|
||||||
|
|
||||||
|
System.out.println(" json updated..");
|
||||||
|
return saved;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Data_lake Updatejson(Integer id, String rawBody) throws JsonProcessingException {
|
||||||
|
|
||||||
|
Data_lake old = Repository.findById(id).get();
|
||||||
|
|
||||||
|
// String url = old.getUrl();
|
||||||
|
//
|
||||||
|
// ResponseEntity<String> response = GETAsString(url);
|
||||||
|
// String rawBody = response.getBody();
|
||||||
|
|
||||||
|
// Convert the JSON object (ArrayList, Map, etc.) to a String
|
||||||
|
// Object responseBody = response.getBody();
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
|
// String jsonString = mapper.writeValueAsString(rawBody);
|
||||||
|
ObjectMapper jsonMapper = new ObjectMapper();
|
||||||
|
Object responseBody;
|
||||||
|
|
||||||
|
// Detect and convert if XML
|
||||||
|
if (isXml(rawBody)) {
|
||||||
|
try {
|
||||||
|
// Convert XML → JSON tree
|
||||||
|
|
||||||
|
XmlMapper xmlMapper = new XmlMapper();
|
||||||
|
|
||||||
|
JsonNode xmlNode = xmlMapper.readTree(rawBody.getBytes());
|
||||||
|
// Convert to standard JSON structure
|
||||||
|
String jsonFromXml = jsonMapper.writeValueAsString(xmlNode);
|
||||||
|
responseBody = jsonMapper.readValue(jsonFromXml, Object.class);
|
||||||
|
System.out.println("XML detected and converted to JSON successfully.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Failed to convert XML to JSON: " + e.getMessage());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Normal JSON response
|
||||||
|
try {
|
||||||
|
responseBody = jsonMapper.readValue(rawBody, Object.class);
|
||||||
|
System.out.println("JSON response detected.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Invalid JSON format: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ✅ Handle calculated fields before batch processing
|
||||||
|
if (Boolean.TRUE.equals(old.getIscalculatedfield()) && old.getCalculated_field_json() != null) {
|
||||||
|
try {
|
||||||
|
responseBody = applyCalculatedFields(responseBody, old.getCalculated_field_json(), mapper, old);
|
||||||
|
System.out.println("Calculated fields applied successfully.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Failed to process calculated fields: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String jsonString = mapper.writeValueAsString(responseBody);
|
||||||
|
old.setJson(jsonString);
|
||||||
|
|
||||||
|
// Process and insert into BatchData as before
|
||||||
|
|
||||||
|
// Process and insert into BatchData
|
||||||
|
processBatchData(old, responseBody, mapper);
|
||||||
|
|
||||||
|
String Url = Port_Constant.DOMAIN + "/Data_lake/Data_lake/merge/" + old.getId();
|
||||||
|
old.setUrl_endpoint(Url);
|
||||||
|
|
||||||
|
old.setUpdatedBy(getUser().getUserId());
|
||||||
|
|
||||||
|
final Data_lake saved = Repository.save(old);
|
||||||
|
|
||||||
|
System.out.println(" json updated..");
|
||||||
|
return saved;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private Object applyCalculatedFields(Object responseBody, String calculatedFieldJson, ObjectMapper mapper,
|
||||||
|
Data_lake old) throws JsonProcessingException {
|
||||||
|
|
||||||
|
// Parse the calculated field JSON
|
||||||
|
List<Map<String, Object>> calcFields = mapper.readValue(calculatedFieldJson, List.class);
|
||||||
|
|
||||||
|
if (!(responseBody instanceof List)) {
|
||||||
|
responseBody = Arrays.asList(responseBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<String, Object>> records = (List<Map<String, Object>>) responseBody;
|
||||||
|
|
||||||
|
for (Map<String, Object> calc : calcFields) {
|
||||||
|
String type = (String) calc.get("type");
|
||||||
|
if ("groupby".equalsIgnoreCase(type)) {
|
||||||
|
// ✅ Handle group-by aggregation
|
||||||
|
List<Map<String, Object>> groupbyrecords = applyGroupBy(records, calc);
|
||||||
|
String groupByRecord = mapper.writeValueAsString(groupbyrecords);
|
||||||
|
|
||||||
|
old.setGroupby_json(groupByRecord);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// ✅ Handle calculated / complex operations (as before)
|
||||||
|
for (Map<String, Object> record : records) {
|
||||||
|
String fieldName = (String) calc.get("fieldName");
|
||||||
|
String operation = (String) calc.get("operation");
|
||||||
|
List<Map<String, Object>> components = (List<Map<String, Object>>) calc.get("fieldComponents");
|
||||||
|
|
||||||
|
// Handle constant fields
|
||||||
|
if (components != null) {
|
||||||
|
for (Map<String, Object> comp : components) {
|
||||||
|
String subField = (String) comp.get("field");
|
||||||
|
Boolean isConstant = comp.get("isConstant") != null && (Boolean) comp.get("isConstant");
|
||||||
|
Object constantValue = comp.get("constant");
|
||||||
|
if (isConstant && subField != null) {
|
||||||
|
record.put(subField, parseNumberOrString(constantValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle complex expression
|
||||||
|
if ("complex".equalsIgnoreCase(operation) && calc.get("complexEquation") != null) {
|
||||||
|
String equation = (String) calc.get("complexEquation");
|
||||||
|
Object result = evaluateComplexExpression(equation, record);
|
||||||
|
record.put(fieldName, result);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle normal arithmetic
|
||||||
|
List<Object> values = new ArrayList<>();
|
||||||
|
if (components != null) {
|
||||||
|
for (Map<String, Object> comp : components) {
|
||||||
|
Boolean isConstant = comp.get("isConstant") != null && (Boolean) comp.get("isConstant");
|
||||||
|
Object val = isConstant ? comp.get("constant") : record.get(comp.get("field"));
|
||||||
|
if (val != null) {
|
||||||
|
values.add(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object result = performOperation(values, operation);
|
||||||
|
record.put(fieldName, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return records;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private List<Map<String, Object>> applyGroupBy(List<Map<String, Object>> records, Map<String, Object> groupConfig) {
|
||||||
|
List<String> groupFields = (List<String>) groupConfig.get("groupFields");
|
||||||
|
List<Map<String, Object>> aggregations = (List<Map<String, Object>>) groupConfig.get("aggregations");
|
||||||
|
|
||||||
|
// Group records by key
|
||||||
|
Map<String, List<Map<String, Object>>> grouped = new LinkedHashMap<>();
|
||||||
|
for (Map<String, Object> record : records) {
|
||||||
|
String key = groupFields.stream().map(f -> String.valueOf(record.getOrDefault(f, "")))
|
||||||
|
.collect(Collectors.joining("|"));
|
||||||
|
grouped.computeIfAbsent(key, k -> new ArrayList<>()).add(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregate results per group
|
||||||
|
List<Map<String, Object>> result = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Map.Entry<String, List<Map<String, Object>>> entry : grouped.entrySet()) {
|
||||||
|
Map<String, Object> groupRecord = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
// Add group fields
|
||||||
|
String[] parts = entry.getKey().split("\\|");
|
||||||
|
for (int i = 0; i < groupFields.size(); i++) {
|
||||||
|
groupRecord.put(groupFields.get(i), parts[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<String, Object>> groupRows = entry.getValue();
|
||||||
|
|
||||||
|
// Apply each aggregation
|
||||||
|
for (Map<String, Object> agg : aggregations) {
|
||||||
|
String field = (String) agg.get("field");
|
||||||
|
String operation = ((String) agg.get("operation")).toLowerCase();
|
||||||
|
List<Double> numericValues = groupRows.stream().map(r -> toDouble(r.get(field)))
|
||||||
|
.filter(v -> !Double.isNaN(v)).collect(Collectors.toList());
|
||||||
|
|
||||||
|
Object aggResult;
|
||||||
|
switch (operation) {
|
||||||
|
case "count":
|
||||||
|
aggResult = groupRows.size();
|
||||||
|
break;
|
||||||
|
case "sum":
|
||||||
|
aggResult = numericValues.stream().mapToDouble(Double::doubleValue).sum();
|
||||||
|
break;
|
||||||
|
case "average":
|
||||||
|
aggResult = numericValues.isEmpty() ? 0.0
|
||||||
|
: numericValues.stream().mapToDouble(Double::doubleValue).average().orElse(0.0);
|
||||||
|
break;
|
||||||
|
case "minimum":
|
||||||
|
aggResult = numericValues.isEmpty() ? null
|
||||||
|
: numericValues.stream().mapToDouble(Double::doubleValue).min().orElse(0.0);
|
||||||
|
break;
|
||||||
|
case "maximum":
|
||||||
|
aggResult = numericValues.isEmpty() ? null
|
||||||
|
: numericValues.stream().mapToDouble(Double::doubleValue).max().orElse(0.0);
|
||||||
|
break;
|
||||||
|
case "median":
|
||||||
|
aggResult = calculateMedian(numericValues);
|
||||||
|
break;
|
||||||
|
case "mode":
|
||||||
|
aggResult = calculateMode(numericValues);
|
||||||
|
break;
|
||||||
|
case "standard deviation":
|
||||||
|
aggResult = calculateStdDev(numericValues);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
aggResult = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
groupRecord.put(field + "_" + operation, aggResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
result.add(groupRecord);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Statistical helpers ---
|
||||||
|
|
||||||
|
private Double calculateMedian(List<Double> values) {
|
||||||
|
if (values == null || values.isEmpty())
|
||||||
|
return null;
|
||||||
|
List<Double> sorted = new ArrayList<>(values);
|
||||||
|
Collections.sort(sorted);
|
||||||
|
int n = sorted.size();
|
||||||
|
if (n % 2 == 1) {
|
||||||
|
return sorted.get(n / 2);
|
||||||
|
} else {
|
||||||
|
return (sorted.get(n / 2 - 1) + sorted.get(n / 2)) / 2.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Double calculateMode(List<Double> values) {
|
||||||
|
if (values == null || values.isEmpty())
|
||||||
|
return null;
|
||||||
|
Map<Double, Long> freq = values.stream().collect(Collectors.groupingBy(v -> v, Collectors.counting()));
|
||||||
|
return freq.entrySet().stream().max(Map.Entry.comparingByValue()).map(Map.Entry::getKey).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Double calculateStdDev(List<Double> values) {
|
||||||
|
if (values == null || values.isEmpty())
|
||||||
|
return null;
|
||||||
|
double mean = values.stream().mapToDouble(Double::doubleValue).average().orElse(0.0);
|
||||||
|
double variance = values.stream().mapToDouble(v -> Math.pow(v - mean, 2)).average().orElse(0.0);
|
||||||
|
return Math.sqrt(variance);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object evaluateComplexExpression(String expression, Map<String, Object> record) {
|
||||||
|
try {
|
||||||
|
// Replace field names with values dynamically
|
||||||
|
for (Map.Entry<String, Object> e : record.entrySet()) {
|
||||||
|
String field = e.getKey();
|
||||||
|
Object val = e.getValue();
|
||||||
|
expression = expression.replaceAll("\\b" + field + "\\b", String.valueOf(val != null ? val : 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Evaluate using ScriptEngine (works on Java 1.8)
|
||||||
|
javax.script.ScriptEngine engine = new javax.script.ScriptEngineManager().getEngineByName("JavaScript");
|
||||||
|
Object result = engine.eval(expression);
|
||||||
|
return result;
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Complex expression error: " + e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// perform normal operation
|
||||||
|
private Object performOperation(List<Object> values, String operation) {
|
||||||
|
if (values.isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
switch (operation.toLowerCase()) {
|
||||||
|
case "add":
|
||||||
|
double sum = 0;
|
||||||
|
for (Object v : values)
|
||||||
|
sum += toDouble(v);
|
||||||
|
return sum;
|
||||||
|
|
||||||
|
case "subtract":
|
||||||
|
double result = toDouble(values.get(0));
|
||||||
|
for (int i = 1; i < values.size(); i++)
|
||||||
|
result -= toDouble(values.get(i));
|
||||||
|
return result;
|
||||||
|
|
||||||
|
case "multiply":
|
||||||
|
double prod = 1;
|
||||||
|
for (Object v : values)
|
||||||
|
prod *= toDouble(v);
|
||||||
|
return prod;
|
||||||
|
|
||||||
|
case "divide":
|
||||||
|
double div = toDouble(values.get(0));
|
||||||
|
for (int i = 1; i < values.size(); i++) {
|
||||||
|
double val = toDouble(values.get(i));
|
||||||
|
if (val != 0)
|
||||||
|
div /= val;
|
||||||
|
}
|
||||||
|
return div;
|
||||||
|
|
||||||
|
case "percentage":
|
||||||
|
if (values.size() < 2)
|
||||||
|
return null;
|
||||||
|
double num = toDouble(values.get(0));
|
||||||
|
double den = toDouble(values.get(1));
|
||||||
|
return den == 0 ? null : (num / den) * 100;
|
||||||
|
|
||||||
|
case "concat":
|
||||||
|
return values.stream().map(Object::toString).collect(Collectors.joining("_"));
|
||||||
|
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ✅ Evaluates complex equations using JavaScript engine Supports math
|
||||||
|
* operations, parentheses, and string concatenation.
|
||||||
|
*/
|
||||||
|
private Object evaluateComplexEquation(String expression, Map<String, Object> record,
|
||||||
|
List<Map<String, Object>> fieldComponents) {
|
||||||
|
|
||||||
|
if (expression == null || expression.trim().isEmpty())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 🔹 Replace constants
|
||||||
|
if (fieldComponents != null) {
|
||||||
|
for (Map<String, Object> comp : fieldComponents) {
|
||||||
|
String field = (String) comp.get("field");
|
||||||
|
Object constant = comp.get("constant");
|
||||||
|
Boolean isConstant = comp.get("isConstant") != null && (Boolean) comp.get("isConstant");
|
||||||
|
|
||||||
|
if (isConstant && constant != null) {
|
||||||
|
String constVal = constant.toString();
|
||||||
|
expression = expression.replaceAll("\\b" + field + "\\b", constVal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🔹 Replace field values from record
|
||||||
|
for (Map.Entry<String, Object> entry : record.entrySet()) {
|
||||||
|
String key = entry.getKey();
|
||||||
|
Object val = entry.getValue();
|
||||||
|
if (val != null) {
|
||||||
|
String safeValue = val.toString();
|
||||||
|
|
||||||
|
// If it's a string containing letters, wrap it in quotes for JS
|
||||||
|
if (!safeValue.matches("^-?\\d+(\\.\\d+)?$")) {
|
||||||
|
safeValue = "'" + safeValue.replace("'", "\\'") + "'";
|
||||||
|
}
|
||||||
|
|
||||||
|
expression = expression.replaceAll("\\b" + key + "\\b", safeValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Evaluate the expression safely
|
||||||
|
Object result = engine.eval(expression);
|
||||||
|
System.out.println(" exoression is : " + expression + " and " + result);
|
||||||
|
return result;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("❌ Error evaluating complex equation: " + e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double toDouble(Object val) {
|
||||||
|
if (val == null)
|
||||||
|
return 0.0;
|
||||||
|
try {
|
||||||
|
return Double.parseDouble(val.toString().trim());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object parseNumberOrString(Object val) {
|
||||||
|
if (val == null)
|
||||||
|
return null;
|
||||||
|
String str = val.toString().trim();
|
||||||
|
try {
|
||||||
|
return Double.parseDouble(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isXml(String content) {
|
||||||
|
if (content == null)
|
||||||
|
return false;
|
||||||
|
String trimmed = content.trim();
|
||||||
|
// XML usually starts with '<' and ends with '>'
|
||||||
|
return trimmed.startsWith("<") && trimmed.endsWith(">");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processBatchData(Data_lake dataLake, Object responseBody, ObjectMapper mapper)
|
||||||
|
throws JsonProcessingException {
|
||||||
|
|
||||||
|
int batchVolume = (dataLake.getBatch_volume() != null && dataLake.getBatch_volume() > 0)
|
||||||
|
? dataLake.getBatch_volume()
|
||||||
|
: 100; // default batch size if not given
|
||||||
|
|
||||||
|
// Convert to JsonNode
|
||||||
|
JsonNode jsonNode = mapper.valueToTree(responseBody);
|
||||||
|
|
||||||
|
if (jsonNode.isArray()) {
|
||||||
|
ArrayNode arrayNode = (ArrayNode) jsonNode;
|
||||||
|
int total = arrayNode.size();
|
||||||
|
System.out.println("Total records: " + total);
|
||||||
|
|
||||||
|
for (int i = 0; i < total; i += batchVolume) {
|
||||||
|
int end = Math.min(i + batchVolume, total);
|
||||||
|
|
||||||
|
// Create a sub-array manually
|
||||||
|
ArrayNode subArray = mapper.createArrayNode();
|
||||||
|
for (int j = i; j < end; j++) {
|
||||||
|
subArray.add(arrayNode.get(j));
|
||||||
|
}
|
||||||
|
|
||||||
|
String subJson = mapper.writeValueAsString(subArray);
|
||||||
|
|
||||||
|
BatchData batch = new BatchData();
|
||||||
|
batch.setDatalake_id(dataLake.getId());
|
||||||
|
batch.setBatchjson(subJson);
|
||||||
|
batchRepo.save(batch);
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Inserted " + (int) Math.ceil((double) total / batchVolume) + " batch records.");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Single object → one record
|
||||||
|
BatchData batch = new BatchData();
|
||||||
|
batch.setDatalake_id(dataLake.getId());
|
||||||
|
batch.setBatchjson(mapper.writeValueAsString(jsonNode));
|
||||||
|
batchRepo.save(batch);
|
||||||
|
|
||||||
|
System.out.println("Inserted single batch record.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String mergeBatchData(Integer datalakeId) throws Exception {
|
||||||
|
List<BatchData> batchList = batchRepo.findByDatalake_id(datalakeId);
|
||||||
|
|
||||||
|
if (batchList.isEmpty()) {
|
||||||
|
throw new RuntimeException("No batch data found for datalake_id: " + datalakeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
ArrayNode mergedArray = mapper.createArrayNode();
|
||||||
|
|
||||||
|
for (BatchData batch : batchList) {
|
||||||
|
String json = batch.getBatchjson();
|
||||||
|
JsonNode node = mapper.readTree(json);
|
||||||
|
|
||||||
|
if (node.isArray()) {
|
||||||
|
// Add each element to merged array
|
||||||
|
for (JsonNode item : node) {
|
||||||
|
mergedArray.add(item);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Single object, just add directly
|
||||||
|
mergedArray.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String mergedJson = mapper.writeValueAsString(mergedArray);
|
||||||
|
System.out.println("Merged JSON size: " + mergedArray.size());
|
||||||
|
return mergedJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<Object> GET(String get) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
ResponseEntity<Object> u = restTemplate.getForEntity(get, Object.class);
|
||||||
|
|
||||||
|
return u;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<String> GETAsString(String url) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
return restTemplate.getForEntity(url, String.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AppUser getUser() {
|
||||||
|
AppUser user = userService.getLoggedInUser();
|
||||||
|
return user;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -38,7 +38,7 @@ public class FileuploadService {
|
|||||||
File projectdir = new File(Path1);
|
File projectdir = new File(Path1);
|
||||||
if (!projectdir.exists()) {
|
if (!projectdir.exists()) {
|
||||||
boolean mkdir = projectdir.mkdirs();
|
boolean mkdir = projectdir.mkdirs();
|
||||||
System.out.println(Path1 + " folder create = " + mkdir);
|
System.out.println(Path1 + " folder created = " + mkdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@@ -25,12 +23,10 @@ public class NotController {
|
|||||||
// return dash;
|
// return dash;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/get_notification")
|
@GetMapping("/get_notification")
|
||||||
public List<NotEntity> getdetails() {
|
public List<NotEntity> getdetails() {
|
||||||
List<NotEntity> dash = notRepo.findTopByOrderByd();
|
List<NotEntity> dash = notRepo.findTopByOrderByd();
|
||||||
return dash;
|
return dash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.realnet.SureConnect.Controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.realnet.SureConnect.Entities.Sure_Connect;
|
||||||
|
import com.realnet.SureConnect.Service.SureService;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class SureController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SureService sureService;
|
||||||
|
|
||||||
|
// CREATE DATA
|
||||||
|
@PostMapping("/Sure_Connect")
|
||||||
|
public ResponseEntity<?> add(@RequestBody Sure_Connect sure_Connect) {
|
||||||
|
Sure_Connect order = sureService.create(sure_Connect);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(order, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// update data
|
||||||
|
@PutMapping("/Sure_Connect/{id}")
|
||||||
|
public ResponseEntity<?> update(@RequestBody Sure_Connect sure_Connect, @PathVariable Integer id) {
|
||||||
|
|
||||||
|
Sure_Connect order = sureService.update(sure_Connect, id);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(order, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all
|
||||||
|
@GetMapping("/Sure_Connect")
|
||||||
|
public ResponseEntity<?> getall() {
|
||||||
|
List<Sure_Connect> pm = sureService.getall();
|
||||||
|
return new ResponseEntity<>(pm, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get by id
|
||||||
|
@GetMapping("/Sure_Connect/{id}")
|
||||||
|
public ResponseEntity<?> getbyid(@PathVariable int id) {
|
||||||
|
Sure_Connect pm = sureService.getbyid(id);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(pm, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete by id
|
||||||
|
@DeleteMapping("/Sure_Connect/{id}")
|
||||||
|
public ResponseEntity<?> deleteOne(@PathVariable int id) {
|
||||||
|
|
||||||
|
sureService.deletebyid(id);
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get by name
|
||||||
|
@GetMapping("/token/Sure_Connectbyname/{connection_name}")
|
||||||
|
public ResponseEntity<?> getbyname(@PathVariable String connection_name) {
|
||||||
|
Sure_Connect pm = sureService.getbyname(connection_name);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(pm, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
package com.realnet.SureConnect.Controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/sure_connect/sure_postman")
|
||||||
|
public class Sure_Postman_Api {
|
||||||
|
|
||||||
|
Logger log = org.slf4j.LoggerFactory.getLogger(Sure_Postman_Api.class);
|
||||||
|
|
||||||
|
@PostMapping("/call_api")
|
||||||
|
public ResponseEntity<?> calldifferentmethod(@RequestBody String json_body,
|
||||||
|
@RequestParam String api_url,
|
||||||
|
//@RequestParam String json_body,
|
||||||
|
@RequestParam String method, @RequestParam String token) {
|
||||||
|
|
||||||
|
|
||||||
|
log.info("executing no json_bodyeters");
|
||||||
|
|
||||||
|
if (method.equalsIgnoreCase("DELETE")) {
|
||||||
|
Object body = DELETE(api_url,token);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(body, HttpStatus.OK);
|
||||||
|
} else {
|
||||||
|
Object object = callmethod(api_url, json_body, method, token);
|
||||||
|
|
||||||
|
System.out.println(object);
|
||||||
|
return new ResponseEntity<>(object, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CALL METHOD
|
||||||
|
public Object callmethod(String urll, String json_body, String method, String token) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (method.equalsIgnoreCase("GET")) {
|
||||||
|
ResponseEntity<Object> get = GET(urll,token);
|
||||||
|
Object body = get.getBody();
|
||||||
|
System.out.println(body);
|
||||||
|
return get.getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (method.equalsIgnoreCase("POST")) {
|
||||||
|
ResponseEntity<Object> post = POST(urll, json_body, token);
|
||||||
|
Object body = post.getBody();
|
||||||
|
System.out.println(body);
|
||||||
|
|
||||||
|
return post.getBody();
|
||||||
|
|
||||||
|
} else if (method.equalsIgnoreCase("PUT")) {
|
||||||
|
ResponseEntity<Object> put = PUT(urll, json_body, token);
|
||||||
|
Object body = put.getBody();
|
||||||
|
System.out.println(body);
|
||||||
|
|
||||||
|
return put.getBody();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private HttpHeaders getHeaders() {
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Content-Type", MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<Object> GET(String url,String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = url;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>( headers);
|
||||||
|
// ResponseEntity<Object> u = restTemplate.getForEntity(url, Object.class);
|
||||||
|
ResponseEntity<Object> u = restTemplate.exchange(resourceUrl, HttpMethod.GET, request, Object.class);
|
||||||
|
|
||||||
|
return u;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<Object> POST(String jobinfo, Object user, String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = jobinfo;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(user, headers);
|
||||||
|
ResponseEntity<Object> res = restTemplate.postForEntity(resourceUrl, request, Object.class);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseEntity<Object> PUT(String jobinfo, Object user, String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = jobinfo;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(user, headers);
|
||||||
|
// ResponseEntity<Object> res = restTemplate.put(resourceUrl, request, Object.class);
|
||||||
|
ResponseEntity<Object> res = restTemplate.exchange(resourceUrl, HttpMethod.PUT, request, Object.class);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object DELETE(String url, String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = url;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(headers);
|
||||||
|
// ResponseEntity<Object> u = restTemplate.getForEntity(url, Object.class);
|
||||||
|
ResponseEntity<Object> u = restTemplate.exchange(resourceUrl, HttpMethod.DELETE, request, Object.class);
|
||||||
|
return u;
|
||||||
|
// restTemplate.delete(url, Object.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.realnet.SureConnect.Entities;
|
||||||
|
|
||||||
|
import javax.persistence.Column;
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Sure_Connect {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy =GenerationType.AUTO)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private String connection_name;
|
||||||
|
|
||||||
|
@Column(length = 10000)
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
private String access_token;
|
||||||
|
private int client_id;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.realnet.SureConnect.Repository;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.realnet.SureConnect.Entities.Sure_Connect;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface SureRepository extends JpaRepository<Sure_Connect, Integer>{
|
||||||
|
|
||||||
|
Sure_Connect findById(int id);
|
||||||
|
|
||||||
|
@Query(value = "select * from sure_connect where connection_name=?1 ", nativeQuery = true)
|
||||||
|
Sure_Connect findByConnection_name(String connection_name);
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.realnet.SureConnect.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.realnet.SureConnect.Entities.Sure_Connect;
|
||||||
|
import com.realnet.SureConnect.Repository.SureRepository;
|
||||||
|
import com.realnet.exceptions.ResourceNotFoundException;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SureService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SureRepository sureRepository;
|
||||||
|
|
||||||
|
public Sure_Connect create(Sure_Connect sure_Connect) {
|
||||||
|
return sureRepository.save(sure_Connect);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Sure_Connect> getall() {
|
||||||
|
return (List<Sure_Connect>) sureRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Sure_Connect getbyid(int id) {
|
||||||
|
return sureRepository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sure_Connect getbyname(String connection_name) {
|
||||||
|
return sureRepository.findByConnection_name(connection_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Sure_Connect update(Sure_Connect sure, int id) {
|
||||||
|
Sure_Connect pm = sureRepository.findById(id);
|
||||||
|
// .orElseThrow(()->new ResourceNotFoundException("not found"));
|
||||||
|
|
||||||
|
pm.setAccess_token(sure.getAccess_token());
|
||||||
|
pm.setClient_id(sure.getClient_id());
|
||||||
|
pm.setConnection_name(sure.getConnection_name());
|
||||||
|
pm.setDescription(sure.getDescription());
|
||||||
|
pm.setPassword(sure.getPassword());
|
||||||
|
pm.setType(sure.getType());
|
||||||
|
pm.setUsername(sure.getUsername());
|
||||||
|
return sureRepository.save(pm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void deletebyid(int id) {
|
||||||
|
sureRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package com.realnet.Workspaceuser.Controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.realnet.Workspaceuser.Entity.DDTable;
|
||||||
|
import com.realnet.Workspaceuser.Entity.SecUsedDd;
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_teams;
|
||||||
|
import com.realnet.Workspaceuser.Repository.Sec_teams_Repository;
|
||||||
|
import com.realnet.users.entity1.AppUser;
|
||||||
|
import com.realnet.users.repository1.AppUserRepository;
|
||||||
|
//@RequestMapping("/Workspace_Dd")
|
||||||
|
@RestController
|
||||||
|
public class DDController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Sec_teams_Repository sec_teams_Repository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AppUserRepository appUserRepository;
|
||||||
|
|
||||||
|
// SEC TEAM DD
|
||||||
|
|
||||||
|
@GetMapping("/Sec_team")
|
||||||
|
public ResponseEntity<?> getteam(){
|
||||||
|
List<Sec_teams> sec = (List<Sec_teams>) sec_teams_Repository.findAll();
|
||||||
|
ArrayList<DDTable> dd = new ArrayList<DDTable>();
|
||||||
|
for(Sec_teams s:sec) {
|
||||||
|
DDTable d = new DDTable();
|
||||||
|
d.setId(s.getId());
|
||||||
|
d.setName(s.getName());
|
||||||
|
dd.add(d);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(dd, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Report To
|
||||||
|
@GetMapping("/Report_to")
|
||||||
|
public ResponseEntity<?> reportto(){
|
||||||
|
List<AppUser> sec = (List<AppUser>) appUserRepository.findAll();
|
||||||
|
ArrayList<SecUsedDd> dd = new ArrayList<SecUsedDd>();
|
||||||
|
for(AppUser s:sec) {
|
||||||
|
SecUsedDd d = new SecUsedDd();
|
||||||
|
d.setUserId(s.getUserId());
|
||||||
|
d.setFullName(s.getFullName());
|
||||||
|
|
||||||
|
dd.add(d);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(dd, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
// assign To
|
||||||
|
@GetMapping("/Assign")
|
||||||
|
public ResponseEntity<?> Assign(){
|
||||||
|
List<AppUser> sec = (List<AppUser>) appUserRepository.findAll();
|
||||||
|
ArrayList<SecUsedDd> dd = new ArrayList<SecUsedDd>();
|
||||||
|
for(AppUser s:sec) {
|
||||||
|
SecUsedDd d = new SecUsedDd();
|
||||||
|
d.setUserId(s.getUserId());
|
||||||
|
d.setFullName(s.getFullName());
|
||||||
|
|
||||||
|
dd.add(d);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(dd, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
// Requestor To
|
||||||
|
@GetMapping("/Requestor")
|
||||||
|
public ResponseEntity<?> Requestor(){
|
||||||
|
List<AppUser> sec = (List<AppUser>) appUserRepository.findAll();
|
||||||
|
ArrayList<SecUsedDd> dd = new ArrayList<SecUsedDd>();
|
||||||
|
for(AppUser s:sec) {
|
||||||
|
SecUsedDd d = new SecUsedDd();
|
||||||
|
d.setUserId(s.getUserId());
|
||||||
|
d.setFullName(s.getFullName());
|
||||||
|
|
||||||
|
dd.add(d);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(dd, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// owner To
|
||||||
|
@GetMapping("/Owner")
|
||||||
|
public ResponseEntity<?> Owner(){
|
||||||
|
List<AppUser> sec = (List<AppUser>) appUserRepository.findAll();
|
||||||
|
ArrayList<SecUsedDd> dd = new ArrayList<SecUsedDd>();
|
||||||
|
for(AppUser s:sec) {
|
||||||
|
SecUsedDd d = new SecUsedDd();
|
||||||
|
d.setUserId(s.getUserId());
|
||||||
|
d.setFullName(s.getFullName());
|
||||||
|
|
||||||
|
dd.add(d);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(dd, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package com.realnet.Workspaceuser.Controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_teams;
|
||||||
|
import com.realnet.Workspaceuser.Service.Sec_teamService;
|
||||||
|
import com.realnet.users.entity1.AppUser;
|
||||||
|
import com.realnet.users.service1.AppUserServiceImpl;
|
||||||
|
|
||||||
|
@RequestMapping("/Workspace_team")
|
||||||
|
@RestController
|
||||||
|
public class SecTeamController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Sec_teamService sec_teamService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
|
||||||
|
// create
|
||||||
|
@PostMapping("/SecTeam")
|
||||||
|
public Sec_teams create(@RequestBody Sec_teams rnrule) {
|
||||||
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
|
|
||||||
|
long accountId = loggedInUser.getAccount().getAccount_id();
|
||||||
|
Long l = accountId;
|
||||||
|
if (l != null) {
|
||||||
|
rnrule.setAccountId(accountId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Sec_teams rn = sec_teamService.create(rnrule);
|
||||||
|
return rn;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get all
|
||||||
|
@GetMapping("/SecTeam")
|
||||||
|
public ResponseEntity<?> getall() {
|
||||||
|
List<Sec_teams> li = sec_teamService.getall();
|
||||||
|
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get all by accountId
|
||||||
|
@GetMapping("/SecTeam/AccountId")
|
||||||
|
public ResponseEntity<?> getallByAccountId() {
|
||||||
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
|
|
||||||
|
long accountId = loggedInUser.getAccount().getAccount_id();
|
||||||
|
|
||||||
|
List<Sec_teams> li = sec_teamService.getallbyAccountId(accountId);
|
||||||
|
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get by id
|
||||||
|
@GetMapping("/SecTeam/{id}")
|
||||||
|
public ResponseEntity<?> getbyid(@PathVariable int id) {
|
||||||
|
Sec_teams rn = sec_teamService.getbyid(id);
|
||||||
|
return new ResponseEntity<>(rn, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update by id
|
||||||
|
@PutMapping("/SecTeam/{id}")
|
||||||
|
public ResponseEntity<?> update(@RequestBody Sec_teams project, @PathVariable int id) {
|
||||||
|
Sec_teams rule_t = sec_teamService.updatebyid(project, id);
|
||||||
|
return new ResponseEntity<>(rule_t, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete by id
|
||||||
|
@DeleteMapping("/SecTeam/{id}")
|
||||||
|
public void deletebyid(@PathVariable int id) {
|
||||||
|
sec_teamService.deletebyid(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
package com.realnet.Workspaceuser.Controller;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.realnet.Communication.Services.EmailNotificationService;
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_team_members;
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_workspace_users;
|
||||||
|
import com.realnet.Workspaceuser.Repository.SecWorkspaceUserRepo;
|
||||||
|
import com.realnet.Workspaceuser.Repository.Sec_team_MemberRepository;
|
||||||
|
|
||||||
|
import com.realnet.users.entity.Role;
|
||||||
|
import com.realnet.users.entity1.AppUser;
|
||||||
|
import com.realnet.users.repository.RoleRepo;
|
||||||
|
import com.realnet.users.repository1.AppUserRepository;
|
||||||
|
import com.realnet.users.response.MessageResponse;
|
||||||
|
import com.realnet.users.service1.AppUserServiceImpl;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/workspace/secworkspaceuser")
|
||||||
|
@EnableCaching
|
||||||
|
public class SecWorkSpaceUSerController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SecWorkspaceUserRepo secWorkspaceUserRepo;
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Sec_team_MemberRepository memberRepository;
|
||||||
|
@Autowired
|
||||||
|
private AppUserRepository userRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RoleRepo roleRepo;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EmailNotificationService emailNotificationService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ADD WHOLE TEAM TO SECWORKSPACE USER BY TEAM_ID
|
||||||
|
@PostMapping("/addteam/{project_id}/{team_id}")
|
||||||
|
public ResponseEntity<?> addwholeteam(@PathVariable Integer project_id, @PathVariable int team_id,
|
||||||
|
@RequestBody Sec_workspace_users users) {
|
||||||
|
List<Object> list = new ArrayList<>();
|
||||||
|
List<Sec_team_members> members = memberRepository.getallteam(team_id);
|
||||||
|
for (Sec_team_members mem : members) {
|
||||||
|
Sec_workspace_users secuser = secWorkspaceUserRepo.getallsecworkspcceuser(mem.getMember_id(), project_id);
|
||||||
|
if (secuser == null) {
|
||||||
|
Sec_workspace_users user = new Sec_workspace_users();
|
||||||
|
Optional<AppUser> us = userRepository.findById(mem.getMember_id());
|
||||||
|
user.setAccountId(us.get().getAccount().getAccount_id());
|
||||||
|
user.setUser_id(mem.getMember_id());
|
||||||
|
user.setWorksapce_id(project_id);
|
||||||
|
user.setProject_id(project_id);
|
||||||
|
user.setUser_name(mem.getMember_name());
|
||||||
|
// Set<Role> roles = new HashSet<>();
|
||||||
|
// String role1 = "ROLE_Developer";
|
||||||
|
// Role userRole = roleRepo.findByName(role1);
|
||||||
|
// roles.add(userRole);
|
||||||
|
// users.setUser_role(roles);
|
||||||
|
Sec_workspace_users save = secWorkspaceUserRepo.save(user);
|
||||||
|
|
||||||
|
list.add(save);
|
||||||
|
|
||||||
|
// send mail to team member
|
||||||
|
try {
|
||||||
|
emailNotificationService.sendmailViaSetu(us.get().getEmail(), us.get().getFullName(), "TeamMember");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("email sending error ..." + e);
|
||||||
|
// TODO: handle exception
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(list, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET ALL SEC_WORKSPACE_USER
|
||||||
|
@GetMapping("/sec_workspace_users")
|
||||||
|
public ResponseEntity<?> getallusers() {
|
||||||
|
List<Sec_workspace_users> list = secWorkspaceUserRepo.findAll();
|
||||||
|
return new ResponseEntity<>(list, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET ALL SEC_WORKSPACE_USER by PROJECT ID
|
||||||
|
@GetMapping("/get_by_projectid/{project_id}")
|
||||||
|
public ResponseEntity<?> getallusers(@PathVariable Integer project_id) {
|
||||||
|
List<Sec_workspace_users> list = secWorkspaceUserRepo.getallproject(project_id);
|
||||||
|
return new ResponseEntity<>(list, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ADD SEC WORKSPACE USER
|
||||||
|
@PostMapping("/add_workspace/users/{userid}/{project_id}/{access_duration}")
|
||||||
|
public ResponseEntity<?> addsecusers(@RequestBody Sec_workspace_users users, @PathVariable Long userid,
|
||||||
|
@PathVariable Integer project_id, @PathVariable Integer access_duration, @RequestParam String role) {
|
||||||
|
|
||||||
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
|
Long fromuserid = loggedInUser.getUserId();
|
||||||
|
// Long account_id = loggedInUser.getAccount().getAccount_id();
|
||||||
|
|
||||||
|
Sec_workspace_users workspace_users = secWorkspaceUserRepo.getallsecworkspcceuser(userid, project_id);
|
||||||
|
if (workspace_users == null) {
|
||||||
|
Optional<AppUser> us = userRepository.findById(userid);
|
||||||
|
users.setAccountId(us.get().getAccount().getAccount_id());
|
||||||
|
users.setFromuserId(fromuserid);
|
||||||
|
users.setUser_id(userid);
|
||||||
|
users.setUser_name(us.get().getFullName());
|
||||||
|
users.setWorksapce_id(project_id);
|
||||||
|
users.setProject_id(project_id);
|
||||||
|
|
||||||
|
users.setAccess_duration(access_duration);
|
||||||
|
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.setTime(new Date());
|
||||||
|
c.add(Calendar.DATE, access_duration);
|
||||||
|
|
||||||
|
// SimpleDateFormat dateFormat = new SimpleDateFormat();
|
||||||
|
// String format = dateFormat.format(c.getTime());
|
||||||
|
|
||||||
|
users.setAccess_till_date(c.getTime());
|
||||||
|
|
||||||
|
Set<Role> roles = new HashSet<>();
|
||||||
|
// String role1 = "ROLE_Developer";
|
||||||
|
Role userRole = roleRepo.findByName(role);
|
||||||
|
// roles.add(userRole);
|
||||||
|
if (userRole != null) {
|
||||||
|
users.setUser_role(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
Sec_workspace_users save = secWorkspaceUserRepo.save(users);
|
||||||
|
|
||||||
|
// send mail to team member
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
emailNotificationService.sendmailViaSetu(us.get().getEmail(), us.get().getFullName(), "WorkSpaceUser");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("email sending error ..." + e);
|
||||||
|
// TODO: handle exception
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(save, HttpStatus.OK);
|
||||||
|
} else
|
||||||
|
return ResponseEntity.badRequest().body(new MessageResponse("user already added"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.realnet.Workspaceuser.Controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.realnet.Workspaceuser.Service.SecTeam_MemberService;
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_team_members;
|
||||||
|
@RequestMapping("/Workspace_team_member")
|
||||||
|
@RestController
|
||||||
|
public class Sec_team_members_Controller {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SecTeam_MemberService secTeam_MemberService;
|
||||||
|
|
||||||
|
// create
|
||||||
|
@PostMapping("/Teammember")
|
||||||
|
public Sec_team_members create(@RequestBody Sec_team_members rnrule){
|
||||||
|
Sec_team_members rn = secTeam_MemberService.create(rnrule);
|
||||||
|
return rn;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get all
|
||||||
|
|
||||||
|
@GetMapping("/Teammember")
|
||||||
|
public ResponseEntity<?> getall(){
|
||||||
|
List<Sec_team_members> li = secTeam_MemberService.getall();
|
||||||
|
return new ResponseEntity<>(li,HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get by id
|
||||||
|
@GetMapping("/Teammember/{id}")
|
||||||
|
public ResponseEntity<?> getbyid(@PathVariable int id){
|
||||||
|
Sec_team_members rn= secTeam_MemberService.getbyid(id);
|
||||||
|
return new ResponseEntity<>(rn,HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update by id
|
||||||
|
@PutMapping("/Teammember/{id}")
|
||||||
|
public ResponseEntity<?> update(@RequestBody Sec_team_members project, @PathVariable int id){
|
||||||
|
Sec_team_members rule_t= secTeam_MemberService.updatebyid(project,id);
|
||||||
|
return new ResponseEntity<>(rule_t,HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete by id
|
||||||
|
@DeleteMapping("/Teammember/{id}")
|
||||||
|
public void deletebyid(@PathVariable int id){
|
||||||
|
secTeam_MemberService.deletebyid(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package com.realnet.Workspaceuser.Controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_workspace;
|
||||||
|
import com.realnet.Workspaceuser.Repository.WorkspaceRepository;
|
||||||
|
import com.realnet.Workspaceuser.Service.WorkspaceService;
|
||||||
|
import com.realnet.users.entity1.AppUser;
|
||||||
|
import com.realnet.users.service1.AppUserServiceImpl;
|
||||||
|
|
||||||
|
@RequestMapping("/Workspace_workspace")
|
||||||
|
@RestController
|
||||||
|
public class WorkspaceController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AppUserServiceImpl userService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WorkspaceService workspaceService;
|
||||||
|
@Autowired
|
||||||
|
private WorkspaceRepository workspaceRepository;
|
||||||
|
|
||||||
|
// create
|
||||||
|
@PostMapping("/workspace")
|
||||||
|
public Sec_workspace create(@RequestBody Sec_workspace rnrule) {
|
||||||
|
|
||||||
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
|
Long userId = loggedInUser.getUserId();
|
||||||
|
rnrule.setOwner_id(userId);
|
||||||
|
|
||||||
|
long accountId = loggedInUser.getAccount().getAccount_id();
|
||||||
|
Long l = accountId;
|
||||||
|
if (l != null) {
|
||||||
|
rnrule.setAccountId(accountId);
|
||||||
|
|
||||||
|
}
|
||||||
|
Sec_workspace rn = workspaceService.create(rnrule);
|
||||||
|
return rn;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get all
|
||||||
|
|
||||||
|
@GetMapping("/workspace")
|
||||||
|
public ResponseEntity<?> getall() {
|
||||||
|
|
||||||
|
List<Sec_workspace> li = workspaceService.getall();
|
||||||
|
|
||||||
|
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get all BY ACCOUNT ID
|
||||||
|
@GetMapping("/FindByaccount")
|
||||||
|
public ResponseEntity<?> getallbyaccount() {
|
||||||
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
|
long accountId = loggedInUser.getAccount().getAccount_id();
|
||||||
|
List<Sec_workspace> li = workspaceRepository.findByAccountId(accountId);
|
||||||
|
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get by id
|
||||||
|
@GetMapping("/workspace/{id}")
|
||||||
|
public ResponseEntity<?> getbyid(@PathVariable int id) {
|
||||||
|
Sec_workspace rn = workspaceService.getbyid(id);
|
||||||
|
return new ResponseEntity<>(rn, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update by id
|
||||||
|
@PutMapping("/workspace/{id}")
|
||||||
|
public ResponseEntity<?> update(@RequestBody Sec_workspace project, @PathVariable int id) {
|
||||||
|
Sec_workspace rule_t = workspaceService.updatebyid(project, id);
|
||||||
|
return new ResponseEntity<>(rule_t, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete by id
|
||||||
|
@DeleteMapping("/workspace/{id}")
|
||||||
|
public void deletebyid(@PathVariable int id) {
|
||||||
|
workspaceService.deletebyid(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.realnet.Workspaceuser.Entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DDTable {
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.realnet.Workspaceuser.Entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SecUsedDd {
|
||||||
|
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
private String fullName;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.realnet.Workspaceuser.Entity;
|
||||||
|
|
||||||
|
import java.sql.Date;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
public class Sec_team_members {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private int team_id;
|
||||||
|
private Long member_id;
|
||||||
|
private boolean member_type;
|
||||||
|
private String access_days;
|
||||||
|
private Date access_start_date;
|
||||||
|
private String member_name;
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package com.realnet.Workspaceuser.Entity;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
import com.realnet.fnd.entity.Rn_Who_AccId_Column;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Sec_teams extends Rn_Who_AccId_Column{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private String Is_active;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.realnet.Workspaceuser.Entity;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
import com.realnet.fnd.entity.Rn_Who_AccId_Column;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Sec_workspace extends Rn_Who_AccId_Column {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private String is_default;
|
||||||
|
private String Is_active;
|
||||||
|
private Long owner_id;
|
||||||
|
private Integer project_id;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.realnet.Workspaceuser.Entity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.realnet.WhoColumn.Entity.Who_column;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Data
|
||||||
|
public class Sec_workspace_users extends Who_column {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
private int worksapce_id;
|
||||||
|
private Long user_id;
|
||||||
|
private String user_name;
|
||||||
|
private Integer project_id;
|
||||||
|
private String user_role;
|
||||||
|
|
||||||
|
private String project_name;
|
||||||
|
private Long fromuserId;
|
||||||
|
|
||||||
|
private Integer access_duration;
|
||||||
|
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-mm-yyyy")
|
||||||
|
private Date access_till_date;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.realnet.Workspaceuser.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_workspace_users;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface SecWorkspaceUserRepo extends JpaRepository<Sec_workspace_users, Long> {
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM sec_workspace_users WHERE user_id=?1 && access_till_date >= NOW();", nativeQuery = true)
|
||||||
|
List<Sec_workspace_users> getallbyuserid(Long userId);
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM sec_workspace_users WHERE user_id=?1 and project_id=?2", nativeQuery = true)
|
||||||
|
Sec_workspace_users getallsecworkspcceuser(Long userid, Integer project_id);
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM sec_workspace_users WHERE project_id=?1", nativeQuery = true)
|
||||||
|
List<Sec_workspace_users> getallproject(Integer project_id);
|
||||||
|
|
||||||
|
@Query(value = "SELECT count(*) FROM sec_workspace_users WHERE user_id=?1", nativeQuery = true)
|
||||||
|
Object countSharewithme(Long userId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.realnet.Workspaceuser.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_team_members;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface Sec_team_MemberRepository extends CrudRepository<Sec_team_members, Integer> {
|
||||||
|
Sec_team_members findById(int id);
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM sec_team_members a where a.team_id =?1", nativeQuery = true)
|
||||||
|
List<Sec_team_members> getallteam(int team_id);
|
||||||
|
@Query(value = "SELECT * FROM sec_team_members a where a.team_id =?1 and a.member_id=?2", nativeQuery = true)
|
||||||
|
Sec_team_members findteammember(int id, Long userId);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.realnet.Workspaceuser.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_teams;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface Sec_teams_Repository extends CrudRepository<Sec_teams, Integer> {
|
||||||
|
|
||||||
|
Sec_teams findById(int id);
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM sec_teams where account_id=?1", nativeQuery = true)
|
||||||
|
List<Sec_teams> findAllByAccountid(Long accountId);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.realnet.Workspaceuser.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_workspace;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface WorkspaceRepository extends CrudRepository<Sec_workspace, Integer> {
|
||||||
|
|
||||||
|
Sec_workspace findById(int id);
|
||||||
|
|
||||||
|
List<Sec_workspace> findByAccountId(Long accountId);
|
||||||
|
|
||||||
|
// List<Sec_workspace> findByProject_id(Integer project_id);
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM sec_workspace WHERE project_id=?1", nativeQuery = true)
|
||||||
|
List<Sec_workspace> findByProject_id(Integer project_id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.realnet.Workspaceuser.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_team_members;
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_teams;
|
||||||
|
import com.realnet.Workspaceuser.Repository.Sec_team_MemberRepository;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class SecTeam_MemberService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Sec_team_MemberRepository sec_team_MemberRepository;
|
||||||
|
|
||||||
|
public Sec_team_members create(Sec_team_members rnrule) {
|
||||||
|
return sec_team_MemberRepository.save(rnrule);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Sec_team_members> getall() {
|
||||||
|
return (List<Sec_team_members>) sec_team_MemberRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Sec_team_members getbyid(int id) {
|
||||||
|
return sec_team_MemberRepository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Sec_team_members updatebyid(Sec_team_members project, int id) {
|
||||||
|
Sec_team_members rule = sec_team_MemberRepository.findById(id);
|
||||||
|
|
||||||
|
// .orElseThrow(()-> ResourceNotFoundException("rueboard","id",id));
|
||||||
|
rule.setAccess_days(project.getAccess_days());
|
||||||
|
rule.setAccess_start_date(project.getAccess_start_date());
|
||||||
|
rule.setMember_id(project.getMember_id());
|
||||||
|
rule.setTeam_id(project.getTeam_id());
|
||||||
|
|
||||||
|
return sec_team_MemberRepository.save(rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void deletebyid(int id) {
|
||||||
|
sec_team_MemberRepository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.realnet.Workspaceuser.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_teams;
|
||||||
|
import com.realnet.Workspaceuser.Repository.Sec_teams_Repository;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class Sec_teamService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Sec_teams_Repository sec_teams_Repository;
|
||||||
|
|
||||||
|
public Sec_teams create(Sec_teams rnrule) {
|
||||||
|
return sec_teams_Repository.save(rnrule);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Sec_teams> getall() {
|
||||||
|
return (List<Sec_teams>) sec_teams_Repository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
// get all by accountId
|
||||||
|
public List<Sec_teams> getallbyAccountId(Long accountId) {
|
||||||
|
return (List<Sec_teams>) sec_teams_Repository.findAllByAccountid(accountId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sec_teams getbyid(int id) {
|
||||||
|
return sec_teams_Repository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Sec_teams updatebyid(Sec_teams project, int id) {
|
||||||
|
Sec_teams rule = sec_teams_Repository.findById(id);
|
||||||
|
|
||||||
|
// .orElseThrow(()-> ResourceNotFoundException("rueboard","id",id));
|
||||||
|
rule.setAccountId(project.getAccountId());
|
||||||
|
rule.setDescription(project.getDescription());
|
||||||
|
rule.setIs_active(project.getIs_active());
|
||||||
|
rule.setName(project.getName());
|
||||||
|
|
||||||
|
return sec_teams_Repository.save(rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deletebyid(int id) {
|
||||||
|
sec_teams_Repository.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package com.realnet.Workspaceuser.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.realnet.Workspaceuser.Entity.Sec_workspace;
|
||||||
|
import com.realnet.Workspaceuser.Repository.WorkspaceRepository;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class WorkspaceService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WorkspaceRepository workspaceRepository;
|
||||||
|
|
||||||
|
public Sec_workspace create(Sec_workspace rnrule) {
|
||||||
|
return workspaceRepository.save(rnrule);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Sec_workspace> getall() {
|
||||||
|
return (List<Sec_workspace>) workspaceRepository.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Sec_workspace getbyid(int id) {
|
||||||
|
return workspaceRepository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Sec_workspace updatebyid(Sec_workspace project, int id) {
|
||||||
|
Sec_workspace rule = workspaceRepository.findById(id);
|
||||||
|
|
||||||
|
// .orElseThrow(()-> ResourceNotFoundException("rueboard","id",id));
|
||||||
|
rule.setAccountId(project.getAccountId());
|
||||||
|
// rule.setDefault_team_id(project.getDefault_team_id());
|
||||||
|
rule.setDescription(project.getDescription());
|
||||||
|
rule.setIs_active(project.getIs_active());
|
||||||
|
rule.setIs_default(project.getIs_default());
|
||||||
|
rule.setName(project.getName());
|
||||||
|
rule.setOwner_id(project.getOwner_id());
|
||||||
|
|
||||||
|
return workspaceRepository.save(rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void deletebyid(int id) {
|
||||||
|
Sec_workspace save = workspaceRepository.findById(id);
|
||||||
|
workspaceRepository.delete(save);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.DeleteMapping;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -23,9 +24,10 @@ public class GeneratetokenController {
|
|||||||
private GeneratetokenService generatetokenService;
|
private GeneratetokenService generatetokenService;
|
||||||
|
|
||||||
@PostMapping("/generateToken")
|
@PostMapping("/generateToken")
|
||||||
public String generatetoken(@RequestParam String token_name) throws JsonProcessingException {
|
public Token_registery generatetoken(@RequestBody Token_registery reg) throws JsonProcessingException {
|
||||||
|
|
||||||
String token = generatetokenService.generatetoken(token_name);
|
String token_name = reg.getToken_name();
|
||||||
|
Token_registery token = generatetokenService.generatetoken(token_name);
|
||||||
|
|
||||||
return token;
|
return token;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.springframework.http.HttpEntity;
|
|||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
@@ -29,13 +30,16 @@ public class GeneratetokenService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private Token_registery_Repository token_registery_Repository;
|
private Token_registery_Repository token_registery_Repository;
|
||||||
|
|
||||||
public String generatetoken(String toekn_name) throws JsonProcessingException {
|
@Autowired
|
||||||
|
private BCryptPasswordEncoder bcryptEncoder;
|
||||||
|
|
||||||
|
public Token_registery generatetoken(String toekn_name) throws JsonProcessingException {
|
||||||
|
|
||||||
AppUser loggedInUser = userServiceImpl.getLoggedInUser();
|
AppUser loggedInUser = userServiceImpl.getLoggedInUser();
|
||||||
|
|
||||||
String username = loggedInUser.getUsername();
|
String username = loggedInUser.getUsername();
|
||||||
|
|
||||||
String userPassw = loggedInUser.getUserPassw();
|
String userPassw = loggedInUser.getChangePassw();
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
@@ -56,13 +60,13 @@ public class GeneratetokenService {
|
|||||||
HttpEntity<Object> request = new HttpEntity<Object>(builder.toString(), headers);
|
HttpEntity<Object> request = new HttpEntity<Object>(builder.toString(), headers);
|
||||||
|
|
||||||
ResponseEntity<String> res = restTemplate.postForEntity(resourceUrl, request, String.class);
|
ResponseEntity<String> res = restTemplate.postForEntity(resourceUrl, request, String.class);
|
||||||
Object object = res.getBody();
|
String object = res.getBody();
|
||||||
|
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String str = mapper.writeValueAsString(object);
|
// String str = mapper.writeValueAsString(object);
|
||||||
|
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
JsonElement element = parser.parse(str);
|
JsonElement element = parser.parse(object);
|
||||||
|
|
||||||
JsonObject obj = element.getAsJsonObject();
|
JsonObject obj = element.getAsJsonObject();
|
||||||
JsonObject item = obj.get("item").getAsJsonObject();
|
JsonObject item = obj.get("item").getAsJsonObject();
|
||||||
@@ -74,9 +78,11 @@ public class GeneratetokenService {
|
|||||||
token_registery.setToken_name(toekn_name);
|
token_registery.setToken_name(toekn_name);
|
||||||
token_registery.setCreatedBy(loggedInUser.getUserId());
|
token_registery.setCreatedBy(loggedInUser.getUserId());
|
||||||
|
|
||||||
|
Token_registery save = token_registery_Repository.save(token_registery);
|
||||||
|
|
||||||
System.out.println("token is == " + token);
|
System.out.println("token is == " + token);
|
||||||
|
|
||||||
return token;
|
return save;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
//package com.realnet.config.sqlite;
|
||||||
|
//
|
||||||
|
//import java.sql.Types;
|
||||||
|
//import org.hibernate.dialect.Dialect;
|
||||||
|
//import org.hibernate.dialect.identity.IdentityColumnSupport;
|
||||||
|
//
|
||||||
|
//public class SQLiteDialect extends Dialect {
|
||||||
|
//
|
||||||
|
// public SQLiteDialect() {
|
||||||
|
// registerColumnType(Types.INTEGER, "integer");
|
||||||
|
// registerColumnType(Types.VARCHAR, "text");
|
||||||
|
// registerColumnType(Types.BLOB, "blob");
|
||||||
|
// registerColumnType(Types.REAL, "real");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public IdentityColumnSupport getIdentityColumnSupport() {
|
||||||
|
// return new SQLiteIdentityColumnSupport();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean hasAlterTable() {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean dropConstraints() {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// @Override
|
||||||
|
// public boolean supportsUnionAll() {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
//package com.realnet.config.sqlite;
|
||||||
|
//
|
||||||
|
//import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
|
||||||
|
//
|
||||||
|
//public class SQLiteIdentityColumnSupport extends IdentityColumnSupportImpl {
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public boolean supportsIdentityColumns() {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public String getIdentitySelectString(String table, String column, int type) {
|
||||||
|
// return "select last_insert_rowid()";
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public String getIdentityColumnString(int type) {
|
||||||
|
// // SQLite mein sirf "integer" + auto increment hota hai
|
||||||
|
// return "integer";
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
//package com.realnet.config.sqlite;
|
||||||
|
//
|
||||||
|
//import java.sql.Connection;
|
||||||
|
//import java.sql.DriverManager;
|
||||||
|
//import java.sql.SQLException;
|
||||||
|
//
|
||||||
|
//public class SQLiteUtil {
|
||||||
|
//
|
||||||
|
// private static final String DB_FILE = "realtest1.db"; // SQLite file
|
||||||
|
//
|
||||||
|
// public static Connection getConnection() throws SQLException {
|
||||||
|
// String url = "jdbc:sqlite:" + DB_FILE;
|
||||||
|
// return DriverManager.getConnection(url);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -1,28 +1,16 @@
|
|||||||
package com.realnet.fnd.entity1;
|
package com.realnet.fnd.entity1;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.FetchType;
|
|
||||||
import javax.persistence.GeneratedValue;
|
import javax.persistence.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.JoinColumn;
|
|
||||||
import javax.persistence.ManyToOne;
|
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.Temporal;
|
|
||||||
import javax.persistence.TemporalType;
|
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
|
|
||||||
import org.springframework.data.annotation.CreatedDate;
|
|
||||||
import org.springframework.data.annotation.LastModifiedDate;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|||||||
222
backend/src/main/java/com/realnet/helper/CnsHelper.java
Normal file
222
backend/src/main/java/com/realnet/helper/CnsHelper.java
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
package com.realnet.helper;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.springframework.http.HttpEntity;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.realnet.utils.Port_Constant;
|
||||||
|
|
||||||
|
public class CnsHelper {
|
||||||
|
|
||||||
|
static Logger log = org.slf4j.LoggerFactory.getLogger(CnsHelper.class);
|
||||||
|
|
||||||
|
// CONNECTOR CALL
|
||||||
|
public static String callconnector(String name) throws JsonProcessingException {
|
||||||
|
|
||||||
|
String token = null;
|
||||||
|
ResponseEntity<Object> u = null;
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String url = Port_Constant.BACKEND_PORTAL_DOMAIN + "/token/Sure_Connectbyname/" + name;
|
||||||
|
|
||||||
|
//
|
||||||
|
try {
|
||||||
|
|
||||||
|
u = restTemplate.getForEntity(url, Object.class);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
System.out.println(" token get error " + e);
|
||||||
|
|
||||||
|
// TODO: handle exception
|
||||||
|
}
|
||||||
|
Object object = u.getBody();
|
||||||
|
|
||||||
|
if (object != null) {
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
String str = mapper.writeValueAsString(object);
|
||||||
|
|
||||||
|
JsonParser parser = new JsonParser();
|
||||||
|
JsonElement element = parser.parse(str);
|
||||||
|
|
||||||
|
JsonObject obj = element.getAsJsonObject();
|
||||||
|
JsonElement tok = obj.get("access_token");
|
||||||
|
System.out.println("token is == " + token);
|
||||||
|
token = tok.getAsString();
|
||||||
|
} else {
|
||||||
|
System.out.println(" empty totek get ...");
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity<?> run(String urll, String param, String method, String token, String username,
|
||||||
|
String password) {
|
||||||
|
|
||||||
|
log.info("executing no parameters");
|
||||||
|
|
||||||
|
if (method.equalsIgnoreCase("DELETE")) {
|
||||||
|
Object body = DELETE(urll);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(body, HttpStatus.OK);
|
||||||
|
} else {
|
||||||
|
Object object = callmethod(urll, param, method, token, username, password);
|
||||||
|
|
||||||
|
System.out.println(object);
|
||||||
|
return new ResponseEntity<>(object, HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean DELETE(String url) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
restTemplate.delete(url, Object.class);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// CALL METHOD
|
||||||
|
public static Object callmethod(String url, String param, String method, String token, String username,
|
||||||
|
String password) {
|
||||||
|
|
||||||
|
if (method.equalsIgnoreCase("GET")) {
|
||||||
|
ResponseEntity<Object> get = GET(url);
|
||||||
|
Object body = get.getBody();
|
||||||
|
System.out.println(body);
|
||||||
|
return get.getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (method.equalsIgnoreCase("POST")) {
|
||||||
|
|
||||||
|
ResponseEntity<Object> post;
|
||||||
|
if (username != null && password != null) {
|
||||||
|
post = POSTForBasicAuth(url, param, username, password);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
post = POST(url, param, token);
|
||||||
|
}
|
||||||
|
Object body = post.getBody();
|
||||||
|
System.out.println(body);
|
||||||
|
|
||||||
|
return post.getBody();
|
||||||
|
|
||||||
|
} else if (method.equalsIgnoreCase("PUT")) {
|
||||||
|
ResponseEntity<Object> put = PUT(url, param, token);
|
||||||
|
Object body = put.getBody();
|
||||||
|
System.out.println(body);
|
||||||
|
|
||||||
|
return put.getBody();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity<Object> GET(String get) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
ResponseEntity<Object> u = restTemplate.getForEntity(get, Object.class);
|
||||||
|
int statusCodeValue = u.getStatusCodeValue();
|
||||||
|
System.out.println(statusCodeValue);
|
||||||
|
|
||||||
|
return u;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity<Object> GET(String get, String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = get;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(headers);
|
||||||
|
ResponseEntity<Object> u = restTemplate.exchange(resourceUrl, HttpMethod.GET, request, Object.class);
|
||||||
|
|
||||||
|
int statusCodeValue = u.getStatusCodeValue();
|
||||||
|
System.out.println(statusCodeValue);
|
||||||
|
|
||||||
|
return u;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity<Object> POST(String jobinfo, Object user, String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = jobinfo;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(user, headers);
|
||||||
|
ResponseEntity<Object> res = restTemplate.postForEntity(resourceUrl, request, Object.class);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity<Object> POSTForBasicAuth(String jobinfo, Object user, String username,
|
||||||
|
String password) {
|
||||||
|
|
||||||
|
System.out.println(" call basic auth..");
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = jobinfo;
|
||||||
|
|
||||||
|
String auth = username + ":" + password;
|
||||||
|
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.US_ASCII));
|
||||||
|
String authHeader = "Basic " + new String(encodedAuth);
|
||||||
|
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
|
||||||
|
headers.set("Authorization", authHeader);
|
||||||
|
|
||||||
|
HttpEntity<Object> request = new HttpEntity<>(user.toString(), headers);
|
||||||
|
ResponseEntity<Object> res = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
res = restTemplate.postForEntity(resourceUrl, request, Object.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
System.out.println(" call basic auth error " + e);
|
||||||
|
// TODO: handle exception
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ResponseEntity<Object> PUT(String jobinfo, Object user, String token) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String resourceUrl = jobinfo;
|
||||||
|
String token1 = "Bearer " + token;
|
||||||
|
HttpHeaders headers = getHeaders();
|
||||||
|
headers.set("Authorization", token1);
|
||||||
|
HttpEntity<Object> request = new HttpEntity<Object>(user, headers);
|
||||||
|
// ResponseEntity<Object> res = restTemplate.put(resourceUrl, request, Object.class);
|
||||||
|
ResponseEntity<Object> res = restTemplate.exchange(resourceUrl, HttpMethod.PUT, request, Object.class);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HttpHeaders getHeaders() {
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.set("Content-Type", MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
return headers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -59,6 +59,7 @@ import com.realnet.users.entity.LoginUser;
|
|||||||
import com.realnet.users.entity.Role;
|
import com.realnet.users.entity.Role;
|
||||||
import com.realnet.users.entity.Sys_Accounts;
|
import com.realnet.users.entity.Sys_Accounts;
|
||||||
import com.realnet.users.entity1.AppUser;
|
import com.realnet.users.entity1.AppUser;
|
||||||
|
import com.realnet.users.entity1.AppUserRole;
|
||||||
import com.realnet.users.entity1.AppUserSessions;
|
import com.realnet.users.entity1.AppUserSessions;
|
||||||
import com.realnet.users.entity1.Registration;
|
import com.realnet.users.entity1.Registration;
|
||||||
import com.realnet.users.response.MessageResponse;
|
import com.realnet.users.response.MessageResponse;
|
||||||
@@ -156,11 +157,13 @@ public class SessionController {
|
|||||||
|
|
||||||
AppUser loggedInUser = userService.getLoggedInUser();
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
MDC.put("USER", loggedInUser.getUsername());
|
MDC.put("USER", loggedInUser.getUsername());
|
||||||
|
AppUserRole usrGrp = loggedInUser.getUsrGrp();
|
||||||
|
String groupName = usrGrp.getGroupName();
|
||||||
// System.out.println("/session logged in user -> " + loggedInUser);
|
// System.out.println("/session logged in user -> " + loggedInUser);
|
||||||
|
|
||||||
// List<String> loggedInUserRoles = new ArrayList<String>();
|
// List<String> loggedInUserRoles = new ArrayList<String>();
|
||||||
StringBuilder roleString = new StringBuilder();
|
StringBuilder roleString = new StringBuilder();
|
||||||
roleString.append(loggedInUser.getUsrGrp().getGroupName());
|
roleString.append(groupName);
|
||||||
// .forEach(role -> {
|
// .forEach(role -> {
|
||||||
//// loggedInUserRoles.add(role.getName());
|
//// loggedInUserRoles.add(role.getName());
|
||||||
// roleString.append(role.getName() + ", ");
|
// roleString.append(role.getName() + ", ");
|
||||||
|
|||||||
@@ -0,0 +1,258 @@
|
|||||||
|
////package com.realnet.excel.controller;
|
||||||
|
//package com.realnet.template.controller;
|
||||||
|
//
|
||||||
|
//import java.io.ByteArrayInputStream;
|
||||||
|
//import java.io.ByteArrayOutputStream;
|
||||||
|
//import java.io.IOException;
|
||||||
|
//
|
||||||
|
//import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
//import org.apache.poi.ss.usermodel.Row;
|
||||||
|
//import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
//import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
//import org.springframework.core.io.InputStreamResource;
|
||||||
|
//import org.springframework.http.HttpHeaders;
|
||||||
|
//import org.springframework.http.HttpStatus;
|
||||||
|
//import org.springframework.http.MediaType;
|
||||||
|
//import org.springframework.http.ResponseEntity;
|
||||||
|
//import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
//import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
//import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
//import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
//import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
//import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
//import org.springframework.web.bind.annotation.RestController;
|
||||||
|
//import org.springframework.web.multipart.MultipartFile;
|
||||||
|
//
|
||||||
|
//import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
//import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
//import com.realnet.template.entity.TemplateFileUpload;
|
||||||
|
//import com.realnet.template.repository.TemplatedataRepo;
|
||||||
|
//import com.realnet.template.service.FileUploadService;
|
||||||
|
//import com.realnet.users.entity1.AppUser;
|
||||||
|
//import com.realnet.users.service1.AppUserServiceImpl;
|
||||||
|
//
|
||||||
|
//@RestController
|
||||||
|
//@RequestMapping("api/template")
|
||||||
|
//public class Controller {
|
||||||
|
// @Autowired
|
||||||
|
// private TemplatedataRepo temprepo;
|
||||||
|
//
|
||||||
|
// @Autowired
|
||||||
|
// FileUploadService fileupload;
|
||||||
|
// @Autowired
|
||||||
|
// private AppUserServiceImpl userService;
|
||||||
|
////
|
||||||
|
//// @Autowired
|
||||||
|
//// private FileUploadService fileUploadService;
|
||||||
|
//
|
||||||
|
//// @Autowired
|
||||||
|
//// private CommFileuploadhelper fileuploadhelper;
|
||||||
|
//
|
||||||
|
// @GetMapping("/demo/download/{file_type}")
|
||||||
|
// public ResponseEntity<?> demoTemplate(@PathVariable String file_type) throws IOException {
|
||||||
|
//
|
||||||
|
// if (file_type.equalsIgnoreCase("Customer")) {
|
||||||
|
//
|
||||||
|
// String filename = "Customer" + ".xlsx";
|
||||||
|
// String[] header = { "Priority Name", "Description", "Is Active", "Effective Start Date",
|
||||||
|
// "Effective End date" };
|
||||||
|
// ByteArrayInputStream in = demoTemplate(header, file_type);
|
||||||
|
// InputStreamResource file = new InputStreamResource(in);
|
||||||
|
// return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + filename)
|
||||||
|
// .contentType(MediaType.parseMediaType("application/vnd.ms-excel")).body(file);
|
||||||
|
//
|
||||||
|
// } else if (file_type.equalsIgnoreCase("impact")) {
|
||||||
|
//
|
||||||
|
// String filename = "Sr_impact2_t" + ".xlsx";
|
||||||
|
// String[] header = { "Impact Name", "Description", "Is Active", "Effective Start Date",
|
||||||
|
// "Effective End date" };
|
||||||
|
// ByteArrayInputStream in = demoTemplate(header, file_type);
|
||||||
|
// InputStreamResource file = new InputStreamResource(in);
|
||||||
|
// return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + filename)
|
||||||
|
// .contentType(MediaType.parseMediaType("application/vnd.ms-excel")).body(file);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return new ResponseEntity<String>("Not Found", HttpStatus.BAD_REQUEST);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static ByteArrayInputStream demoTemplate(String[] HEADERs, String file_type) throws IOException {
|
||||||
|
// String SHEET = file_type;
|
||||||
|
// Workbook workbook = new XSSFWorkbook();
|
||||||
|
// ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
// Sheet sheet = workbook.createSheet(SHEET);
|
||||||
|
// Row headerRow = sheet.createRow(0);
|
||||||
|
// for (int col = 0; col < HEADERs.length; col++) {
|
||||||
|
// Cell cell = headerRow.createCell(col);
|
||||||
|
// cell.setCellValue(HEADERs[col]);
|
||||||
|
// }
|
||||||
|
// workbook.write(out);
|
||||||
|
// return new ByteArrayInputStream(out.toByteArray());
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @GetMapping("/getalltemplate")
|
||||||
|
// public ResponseEntity<?> getALlTemplate() {
|
||||||
|
// return new ResponseEntity<>(temprepo.findAll(), HttpStatus.ACCEPTED);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @GetMapping("/gettemplatebyid/{id}")
|
||||||
|
// public ResponseEntity<?> getTemplateById(@PathVariable Long id) {
|
||||||
|
// return new ResponseEntity<>(fileupload.getTemplatebyid(id), HttpStatus.ACCEPTED);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @PostMapping("/save/{entityName}")
|
||||||
|
// public ResponseEntity<?> post(@RequestParam(required = false) MultipartFile file, @PathVariable String entityName)
|
||||||
|
// throws JsonMappingException, JsonProcessingException {
|
||||||
|
//
|
||||||
|
// TemplateFileUpload job;
|
||||||
|
// AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
|
//
|
||||||
|
//// job = new ObjectMapper().readValue(entityName, TemplateFileUpload.class);
|
||||||
|
//
|
||||||
|
// if (file != null) {
|
||||||
|
// System.out.println(file.getOriginalFilename());
|
||||||
|
//
|
||||||
|
//// boolean f =
|
||||||
|
//// fileUploadService.uploadFile(file);
|
||||||
|
//
|
||||||
|
// fileupload.uploadFile(file, loggedInUser.getUserId(), entityName);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// else {
|
||||||
|
// System.out.println("erro");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//// TemplateFileUpload save = temprepo.save(job);
|
||||||
|
//
|
||||||
|
// return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @DeleteMapping("/deletetemplate/{id}")
|
||||||
|
// public ResponseEntity<String> deleteTemplateFileUploadById(@PathVariable Long id) {
|
||||||
|
// try {
|
||||||
|
// fileupload.deleteTemplateFileUploadById(id);
|
||||||
|
// return ResponseEntity.ok("Template file deleted successfully");
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// // Handle exceptions, e.g., if the entity with the given ID is not found
|
||||||
|
// return ResponseEntity.badRequest().body("Failed to delete template file: " + e.getMessage());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//// @PostMapping("/save/{filetype}")
|
||||||
|
//// public ResponseEntity<?> uploadFile(@RequestParam MultipartFile file, @PathVariable String filetype)
|
||||||
|
//// throws IOException, ParseException {
|
||||||
|
//// BufferedReader br;
|
||||||
|
//// InputStream is = file.getInputStream();
|
||||||
|
//// br = new BufferedReader(new InputStreamReader(is));
|
||||||
|
//// String file_name = file.getOriginalFilename();
|
||||||
|
//// AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
|
////
|
||||||
|
//// if (filetype.equalsIgnoreCase("priority")) {
|
||||||
|
////
|
||||||
|
//// if (file_name.contains("Sr_priority2_t")) {
|
||||||
|
////
|
||||||
|
//// String[] header = { "Priority Name", "Description", "Is Active", "Effective Start Date",
|
||||||
|
//// "Effective End date" };
|
||||||
|
//// ArrayList<Sr_priority2_t> prioritylist = new ArrayList<Sr_priority2_t>();
|
||||||
|
////
|
||||||
|
//// Workbook workbook = WorkbookFactory.create(is);
|
||||||
|
////
|
||||||
|
////// Create a DataFormatter to format and get each cell's value as String
|
||||||
|
//// DataFormatter dataFormatter = new DataFormatter();
|
||||||
|
////
|
||||||
|
//// Sheet sheet = workbook.getSheetAt(0);
|
||||||
|
////
|
||||||
|
//// // Getting number of columns in the Sheet
|
||||||
|
//// int cols = sheet.getRow(0).getLastCellNum();
|
||||||
|
////
|
||||||
|
//// fileupload.uploadFile(file, loggedInUser.getUserId(), filetype);
|
||||||
|
////
|
||||||
|
//// for (Row row : sheet) {
|
||||||
|
////
|
||||||
|
//// if (row.getRowNum() == 0) {
|
||||||
|
//// for (int i = 0; i < cols; i++) {
|
||||||
|
//// String value = dataFormatter.formatCellValue(row.getCell(i));
|
||||||
|
////
|
||||||
|
//// if (!header[i].equalsIgnoreCase(value)) {
|
||||||
|
////
|
||||||
|
//// return new ResponseEntity<>(
|
||||||
|
//// "priority file Should have \"" + header + " \"in the header in excel file",
|
||||||
|
//// HttpStatus.BAD_REQUEST);
|
||||||
|
//// }
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// if (row.getRowNum() != 0) {
|
||||||
|
//// Date date = row.getCell(3).getDateCellValue();
|
||||||
|
//// Date date2 = row.getCell(4).getDateCellValue();
|
||||||
|
////
|
||||||
|
//// Sr_priority2_t priority = new Sr_priority2_t();
|
||||||
|
//// priority.setPriority_name(dataFormatter.formatCellValue(row.getCell(0)));
|
||||||
|
//// priority.setDescription(dataFormatter.formatCellValue(row.getCell(1)));
|
||||||
|
//// priority.setActive(Boolean.valueOf(dataFormatter.formatCellValue(row.getCell(2))));
|
||||||
|
////
|
||||||
|
//// priority.setEffective_start_date(date);
|
||||||
|
//// priority.setEffective_end_date(date2);
|
||||||
|
//// priorityrepo.save(priority);
|
||||||
|
////
|
||||||
|
//// prioritylist.add(priority);
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// }
|
||||||
|
////// priorityrepo.saveAll(prioritylist);
|
||||||
|
//// workbook.close();
|
||||||
|
////
|
||||||
|
//////
|
||||||
|
////
|
||||||
|
//// return new ResponseEntity<>("File Uploaded", HttpStatus.ACCEPTED);
|
||||||
|
//// }
|
||||||
|
//// return new ResponseEntity<>("File name should contain Sr_priority2_t", HttpStatus.BAD_REQUEST);
|
||||||
|
////
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// return new ResponseEntity<>("Something Went Wrong please try again....!!!!! ", HttpStatus.BAD_REQUEST);
|
||||||
|
////
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
////// Download template data in excel Files
|
||||||
|
////
|
||||||
|
//// @GetMapping("/download/{file_type}")
|
||||||
|
////
|
||||||
|
//// public ResponseEntity<?> getFile(@PathVariable String file_type) throws IOException {
|
||||||
|
////
|
||||||
|
//// if (file_type.equalsIgnoreCase("priority")) {
|
||||||
|
////
|
||||||
|
//// String filename = "Sr_priority2_t" + ".xlsx";
|
||||||
|
//// String[] header = { "Priority Name", "Description", "Is Active", "Effective Start Date",
|
||||||
|
//// "Effective End date" };
|
||||||
|
//// List<Sr_priority2_t> findAll = priorityrepo.findAll();
|
||||||
|
//// ByteArrayInputStream in = templateByte(findAll, header);
|
||||||
|
//// InputStreamResource file = new InputStreamResource(in);
|
||||||
|
//// return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + filename)
|
||||||
|
//// .contentType(MediaType.parseMediaType("application/vnd.ms-excel")).body(file);
|
||||||
|
////
|
||||||
|
//// } else if (file_type.equalsIgnoreCase("impact")) {
|
||||||
|
////
|
||||||
|
//// String filename = "Sr_impact2_t" + ".xlsx";
|
||||||
|
//// String[] header = { "Impact Name", "Description", "Is Active", "Effective Start Date",
|
||||||
|
//// "Effective End date" };
|
||||||
|
//// List<Sr_impact2_t> findAll = impactrepo.findAll();
|
||||||
|
//// ByteArrayInputStream in = templateByte3(findAll, header);
|
||||||
|
//// InputStreamResource file = new InputStreamResource(in);
|
||||||
|
//// return ResponseEntity.ok().header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + filename)
|
||||||
|
//// .contentType(MediaType.parseMediaType("application/vnd.ms-excel")).body(file);
|
||||||
|
////
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// return new ResponseEntity<String>("Not Found", HttpStatus.BAD_REQUEST);
|
||||||
|
////
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
//}
|
||||||
@@ -16,9 +16,7 @@ import org.apache.poi.ss.usermodel.Workbook;
|
|||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
|
||||||
import org.springframework.core.io.InputStreamResource;
|
import org.springframework.core.io.InputStreamResource;
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@@ -51,12 +49,6 @@ public class ExcelController {
|
|||||||
FileUploadService fileupload;
|
FileUploadService fileupload;
|
||||||
@Autowired
|
@Autowired
|
||||||
private AppUserServiceImpl userService;
|
private AppUserServiceImpl userService;
|
||||||
//
|
|
||||||
// @Autowired
|
|
||||||
// private FileUploadService fileUploadService;
|
|
||||||
|
|
||||||
// @Autowired
|
|
||||||
// private CommFileuploadhelper fileuploadhelper;
|
|
||||||
|
|
||||||
@GetMapping("/demo/download/{file_type}")
|
@GetMapping("/demo/download/{file_type}")
|
||||||
public ResponseEntity<?> demoTemplate(@PathVariable String file_type) throws IOException {
|
public ResponseEntity<?> demoTemplate(@PathVariable String file_type) throws IOException {
|
||||||
@@ -163,6 +155,56 @@ public class ExcelController {
|
|||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getalltemplate")
|
||||||
|
public ResponseEntity<?> getALlTemplate() {
|
||||||
|
return new ResponseEntity<>(temprepo.findAll(), HttpStatus.ACCEPTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/gettemplatebyid/{id}")
|
||||||
|
public ResponseEntity<?> getTemplateById(@PathVariable Long id) {
|
||||||
|
return new ResponseEntity<>(fileupload.getTemplatebyid(id), HttpStatus.ACCEPTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/save/{entityName}")
|
||||||
|
public ResponseEntity<?> post(@RequestParam(required = false) MultipartFile file, @PathVariable String entityName)
|
||||||
|
throws JsonMappingException, JsonProcessingException {
|
||||||
|
|
||||||
|
TemplateFileUpload job;
|
||||||
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
|
|
||||||
|
// job = new ObjectMapper().readValue(entityName, TemplateFileUpload.class);
|
||||||
|
|
||||||
|
if (file != null) {
|
||||||
|
System.out.println(file.getOriginalFilename());
|
||||||
|
|
||||||
|
// boolean f =
|
||||||
|
// fileUploadService.uploadFile(file);
|
||||||
|
|
||||||
|
fileupload.uploadFile(file, loggedInUser.getUserId(), entityName);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
System.out.println("erro");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TemplateFileUpload save = temprepo.save(job);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/deletetemplate/{id}")
|
||||||
|
public ResponseEntity<String> deleteTemplateFileUploadById(@PathVariable Long id) {
|
||||||
|
try {
|
||||||
|
fileupload.deleteTemplateFileUploadById(id);
|
||||||
|
return ResponseEntity.ok("Template file deleted successfully");
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Handle exceptions, e.g., if the entity with the given ID is not found
|
||||||
|
return ResponseEntity.badRequest().body("Failed to delete template file: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// @PostMapping("/save/{filetype}")
|
// @PostMapping("/save/{filetype}")
|
||||||
// public ResponseEntity<?> uploadFile(@RequestParam MultipartFile file, @PathVariable String filetype)
|
// public ResponseEntity<?> uploadFile(@RequestParam MultipartFile file, @PathVariable String filetype)
|
||||||
// throws IOException, ParseException {
|
// throws IOException, ParseException {
|
||||||
@@ -274,54 +316,4 @@ public class ExcelController {
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
@GetMapping("/getalltemplate")
|
|
||||||
public ResponseEntity<?> getALlTemplate() {
|
|
||||||
return new ResponseEntity<>(temprepo.findAll(), HttpStatus.ACCEPTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/gettemplatebyid/{id}")
|
|
||||||
public ResponseEntity<?> getTemplateById(@PathVariable Long id) {
|
|
||||||
return new ResponseEntity<>(fileupload.getTemplatebyid(id), HttpStatus.ACCEPTED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/save/{entityName}/{name}")
|
|
||||||
public ResponseEntity<?> post(@RequestParam(required = false) MultipartFile file, @PathVariable String entityName,
|
|
||||||
@PathVariable String name) throws JsonMappingException, JsonProcessingException {
|
|
||||||
|
|
||||||
TemplateFileUpload job;
|
|
||||||
AppUser loggedInUser = userService.getLoggedInUser();
|
|
||||||
|
|
||||||
// job = new ObjectMapper().readValue(entityName, TemplateFileUpload.class);
|
|
||||||
|
|
||||||
if (file != null) {
|
|
||||||
System.out.println(file.getOriginalFilename());
|
|
||||||
|
|
||||||
// boolean f =
|
|
||||||
// fileUploadService.uploadFile(file);
|
|
||||||
|
|
||||||
fileupload.uploadFile(file, loggedInUser.getUserId(), entityName, name);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
System.out.println("erro");
|
|
||||||
}
|
|
||||||
|
|
||||||
// TemplateFileUpload save = temprepo.save(job);
|
|
||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@DeleteMapping("/deletetemplate/{id}")
|
|
||||||
public ResponseEntity<String> deleteTemplateFileUploadById(@PathVariable Long id) {
|
|
||||||
try {
|
|
||||||
fileupload.deleteTemplateFileUploadById(id);
|
|
||||||
return ResponseEntity.ok("Template file deleted successfully");
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Handle exceptions, e.g., if the entity with the given ID is not found
|
|
||||||
return ResponseEntity.badRequest().body("Failed to delete template file: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,10 @@ import java.nio.file.StandardCopyOption;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
|
||||||
import org.springframework.core.io.Resource;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|
||||||
import com.realnet.template.entity.TemplateFileUpload;
|
import com.realnet.template.entity.TemplateFileUpload;
|
||||||
import com.realnet.template.repository.TemplatedataRepo;
|
import com.realnet.template.repository.TemplatedataRepo;
|
||||||
|
|
||||||
@@ -28,7 +24,7 @@ public class FileUploadService {
|
|||||||
@Value("${projectPath}")
|
@Value("${projectPath}")
|
||||||
private String projectPath;
|
private String projectPath;
|
||||||
|
|
||||||
public String uploadFile(MultipartFile file, Long user_id, String file_type, String name) {
|
public String uploadFile(MultipartFile file, Long user_id, String entityname) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String filepath = "import-data";
|
String filepath = "import-data";
|
||||||
@@ -74,9 +70,8 @@ public class FileUploadService {
|
|||||||
|
|
||||||
exceldata.setFile_name(file.getOriginalFilename());
|
exceldata.setFile_name(file.getOriginalFilename());
|
||||||
exceldata.setFile_changed_name(str);
|
exceldata.setFile_changed_name(str);
|
||||||
// exceldata.setFile_type(file_type);
|
// exceldata.setFile_type(file_type);
|
||||||
exceldata.setEntity_name(file_type);
|
exceldata.setEntity_name(entityname);
|
||||||
exceldata.setName(name);
|
|
||||||
exceldata.setUser_id(user_id);
|
exceldata.setUser_id(user_id);
|
||||||
repo.save(exceldata);
|
repo.save(exceldata);
|
||||||
|
|
||||||
@@ -89,27 +84,21 @@ public class FileUploadService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public TemplateFileUpload getTemplatebyid(Long Id) {
|
public TemplateFileUpload getTemplatebyid(Long Id) {
|
||||||
TemplateFileUpload one = repo.getOne(Id);
|
TemplateFileUpload one = repo.getOne(Id);
|
||||||
return one;
|
return one;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteTemplateFileUploadById(Long id) {
|
public void deleteTemplateFileUploadById(Long id) {
|
||||||
// Check if the entity with the given ID exists
|
// Check if the entity with the given ID exists
|
||||||
if (repo.existsById(id)) {
|
if (repo.existsById(id)) {
|
||||||
repo.deleteById(id);
|
repo.deleteById(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TemplateFileUpload getFileById(Long id) {
|
||||||
|
// Use your JPA repository to retrieve the file by its ID
|
||||||
public TemplateFileUpload getFileById(Long id) {
|
return repo.findById(id).orElse(null);
|
||||||
// Use your JPA repository to retrieve the file by its ID
|
}
|
||||||
return repo.findById(id).orElse(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,8 +210,7 @@ public class UserController {
|
|||||||
|
|
||||||
String em = user.getEmail();
|
String em = user.getEmail();
|
||||||
String subject = "Pass reset";
|
String subject = "Pass reset";
|
||||||
String url = "http://" + Port_Constant.LOCAL_HOST + ":" + Port_Constant.FRONTEND_PORT_9191
|
String url = Port_Constant.FRONTEND_PORTAL_DOMAIN + "/#/forgotresetpassword/" + token;
|
||||||
+ "/#/forgotresetpassword/" + token;
|
|
||||||
// String url = "http://surecns.ml:30165/#/forgotresetpassword/" + token;
|
// String url = "http://surecns.ml:30165/#/forgotresetpassword/" + token;
|
||||||
// String url = "http://localhost:9191/api" + "/resources/savePassword/" + token;
|
// String url = "http://localhost:9191/api" + "/resources/savePassword/" + token;
|
||||||
emailService.constructEmail(em, subject, url);
|
emailService.constructEmail(em, subject, url);
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.realnet.config.EmailService;
|
import com.realnet.config.EmailService;
|
||||||
|
import com.realnet.fnd.response.EntityResponse;
|
||||||
import com.realnet.session.Service.TokenBlacklistService;
|
import com.realnet.session.Service.TokenBlacklistService;
|
||||||
import com.realnet.userDTO.User;
|
import com.realnet.userDTO.User;
|
||||||
import com.realnet.users.entity.PasswordResetRequest;
|
import com.realnet.users.entity.PasswordResetRequest;
|
||||||
@@ -103,6 +104,21 @@ public class AppUserController {
|
|||||||
return new ResponseEntity<>("User not found", HttpStatus.OK);
|
return new ResponseEntity<>("User not found", HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set iser active inactive
|
||||||
|
@GetMapping("/getOneAppUser/active/{id}")
|
||||||
|
public ResponseEntity<?> getOneAppUser(@PathVariable("id") Long id, @RequestParam Boolean active) {
|
||||||
|
Optional<AppUser> a = appUserServiceImpl.getOneUser(id);
|
||||||
|
|
||||||
|
if (a.get() != null) {
|
||||||
|
a.get().setActive(active);
|
||||||
|
|
||||||
|
boolean insertOrSaveUser = appUserServiceImpl.insertOrSaveUser(a.get());
|
||||||
|
|
||||||
|
return new ResponseEntity<>(a.get(), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>("User not found", HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/addOneAppUser")
|
@PostMapping("/addOneAppUser")
|
||||||
public ResponseEntity<?> addOneUser(@RequestBody Registration reg) {
|
public ResponseEntity<?> addOneUser(@RequestBody Registration reg) {
|
||||||
if (appUserRepository.findByEmail(reg.getEmail()) != null) {
|
if (appUserRepository.findByEmail(reg.getEmail()) != null) {
|
||||||
@@ -193,25 +209,31 @@ public class AppUserController {
|
|||||||
AppUser loggedInUser = userService.getLoggedInUser();
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
Long account_id = loggedInUser.getAccount().getAccount_id();
|
Long account_id = loggedInUser.getAccount().getAccount_id();
|
||||||
|
|
||||||
|
AppUser appUser = new AppUser();
|
||||||
|
|
||||||
AppUser user = userService.findUserByEmail(email);
|
AppUser user = userService.findUserByEmail(email);
|
||||||
if (user != null) {
|
if (user != null && user.isIsComplete()) {
|
||||||
return ResponseEntity.badRequest().body(new MessageResponse(email + " already exist"));
|
return ResponseEntity.badRequest().body(new MessageResponse(email + " already exist"));
|
||||||
} else {
|
}
|
||||||
String token = UUID.randomUUID().toString();
|
|
||||||
AppUser appUser = new AppUser();
|
|
||||||
userService.adduserviaadmin(appUser, token, email, account_id);
|
|
||||||
|
|
||||||
String subject = "add user";
|
if (user != null) {
|
||||||
|
appUser = user;
|
||||||
|
|
||||||
String url = Port_Constant.FRONTEND_PORTAL_DOMAIN + "/#/adduser/" + token;
|
}
|
||||||
// String url = "http://localhost:4200/#/adduser/" +token;
|
String token = UUID.randomUUID().toString();
|
||||||
// String url = "http://surecns.ml:30165/#/adduser/" +token;
|
|
||||||
|
userService.adduserviaadmin(appUser, token, email, account_id);
|
||||||
|
|
||||||
|
String subject = "add user";
|
||||||
|
|
||||||
|
String url = Port_Constant.FRONTEND_PORTAL_DOMAIN + "/#/adduser/" + token;
|
||||||
|
// String url = "http://localhost:4200/#/adduser/" +token;
|
||||||
|
// String url = "http://surecns.ml:30165/#/adduser/" +token;
|
||||||
// String url = "http://" + Port_Constant.LOCAL_HOST + ":" + Port_Constant.BACKEND_PORT_9191 + "/api"
|
// String url = "http://" + Port_Constant.LOCAL_HOST + ":" + Port_Constant.BACKEND_PORT_9191 + "/api"
|
||||||
// + "/admin/adduser/" + token;
|
// + "/admin/adduser/" + token;
|
||||||
|
|
||||||
emailService.sendEmail(email, subject, url);
|
emailService.sendEmail(email, subject, url);
|
||||||
return new ResponseEntity<>("Email sent success", HttpStatus.OK);
|
return new ResponseEntity<>(new EntityResponse("Email sent success"), HttpStatus.OK);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,31 +289,36 @@ public class AppUserController {
|
|||||||
AppUser loggedInUser = userService.getLoggedInUser();
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
String fullName = loggedInUser.getFullName();
|
String fullName = loggedInUser.getFullName();
|
||||||
Long account_id = loggedInUser.getAccount().getAccount_id();
|
Long account_id = loggedInUser.getAccount().getAccount_id();
|
||||||
|
AppUser appUser = new AppUser();
|
||||||
|
|
||||||
if (email.contains(" ")) {
|
if (email.contains(" ")) {
|
||||||
// Replace whitespace with '+'
|
// Replace whitespace with '+'
|
||||||
email = email.replace(" ", "+");
|
email = email.replace(" ", "+");
|
||||||
}
|
}
|
||||||
|
|
||||||
AppUser user = userService.findUserByEmail(email);
|
AppUser user = userService.findUserByEmail(email);
|
||||||
if (user != null) {
|
if (user != null && user.isIsComplete()) {
|
||||||
return ResponseEntity.badRequest().body(new MessageResponse(email + " already exist"));
|
return ResponseEntity.badRequest().body(new MessageResponse(email + " already exist"));
|
||||||
} else {
|
}
|
||||||
String token = UUID.randomUUID().toString();
|
|
||||||
AppUser appUser = new AppUser();
|
if (user != null) {
|
||||||
userService.addguestviaadmin(appUser, token, email, account_id);
|
appUser = user;
|
||||||
|
|
||||||
|
}
|
||||||
|
String token = UUID.randomUUID().toString();
|
||||||
|
userService.addguestviaadmin(appUser, token, email, account_id);
|
||||||
|
|
||||||
// String subject = "add guest";
|
// String subject = "add guest";
|
||||||
String url = Port_Constant.FRONTEND_PORTAL_DOMAIN + "/#/addguest/" + token;
|
String url = Port_Constant.FRONTEND_PORTAL_DOMAIN + "/#/addguest/" + token;
|
||||||
|
|
||||||
// String url = "http://localhost:4200/#/addguest/" +token;
|
// String url = "http://localhost:4200/#/addguest/" +token;
|
||||||
// String url = "http://surecns.ml:30165/#/addguest/" +token;
|
// String url = "http://surecns.ml:30165/#/addguest/" +token;
|
||||||
// String url = "http://" + Port_Constant.LOCAL_HOST + ":" + Port_Constant.BACKEND_PORT_9191 + "/api"
|
// String url = "http://" + Port_Constant.LOCAL_HOST + ":" + Port_Constant.BACKEND_PORT_9191 + "/api"
|
||||||
// + "/admin/addguest/" + token;
|
// + "/admin/addguest/" + token;
|
||||||
|
|
||||||
String subject = "Guest Registration..";
|
String subject = "Guest Registration..";
|
||||||
emailService.sendEmail(email, subject, url);
|
emailService.sendEmail(email, subject, url);
|
||||||
return new ResponseEntity<>("Email sent success", HttpStatus.OK);
|
return new ResponseEntity<>(new EntityResponse("Email sent success"), HttpStatus.OK);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,6 +363,4 @@ public class AppUserController {
|
|||||||
return ResponseEntity.ok().body(new MessageResponse("registration already done"));
|
return ResponseEntity.ok().body(new MessageResponse("registration already done"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ import java.util.List;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@@ -14,6 +16,7 @@ import com.realnet.session.entity.AboutWork;
|
|||||||
import com.realnet.users.entity.Sys_Accounts;
|
import com.realnet.users.entity.Sys_Accounts;
|
||||||
import com.realnet.users.repository.AboutWorkRepo;
|
import com.realnet.users.repository.AboutWorkRepo;
|
||||||
import com.realnet.users.repository.SysAccountRepo;
|
import com.realnet.users.repository.SysAccountRepo;
|
||||||
|
import com.realnet.users.service1.SysAccountService;
|
||||||
|
|
||||||
@RequestMapping("/token/users/sysaccount")
|
@RequestMapping("/token/users/sysaccount")
|
||||||
@RestController
|
@RestController
|
||||||
@@ -25,9 +28,20 @@ public class SysAccountController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private AboutWorkRepo aboutWorkRepo;
|
private AboutWorkRepo aboutWorkRepo;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysAccountService accountService;
|
||||||
|
|
||||||
@PostMapping("/savesysaccount")
|
@PostMapping("/savesysaccount")
|
||||||
public Sys_Accounts save(@RequestBody Sys_Accounts sys_Accounts) {
|
public Sys_Accounts save(@RequestBody Sys_Accounts sys_Accounts) {
|
||||||
Sys_Accounts save = sysAccountRepo.save(sys_Accounts);
|
Sys_Accounts save = accountService.save(sys_Accounts);
|
||||||
|
|
||||||
|
System.out.println("created account data is .." + save);
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/savesysaccount/{accId}")
|
||||||
|
public Sys_Accounts updte(@PathVariable Long accId, @RequestBody Sys_Accounts sys_Accounts) {
|
||||||
|
Sys_Accounts save = accountService.update(accId, sys_Accounts);
|
||||||
|
|
||||||
System.out.println("created account data is .." + save);
|
System.out.println("created account data is .." + save);
|
||||||
return save;
|
return save;
|
||||||
|
|||||||
@@ -1,137 +1,121 @@
|
|||||||
//package com.realnet.users.controller1;
|
package com.realnet.users.controller1;
|
||||||
//
|
|
||||||
//import java.util.List;
|
import java.util.List;
|
||||||
//
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
//import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
//import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
//import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
//import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
//import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
//import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
//import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
//import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
//import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
//
|
|
||||||
//import com.realnet.Workspaceuser.Entity.Sec_team_members;
|
import com.realnet.Workspaceuser.Entity.Sec_team_members;
|
||||||
//import com.realnet.Workspaceuser.Entity.Sec_teams;
|
import com.realnet.Workspaceuser.Entity.Sec_teams;
|
||||||
//import com.realnet.Workspaceuser.Repository.SecWorkspaceUserRepo;
|
import com.realnet.Workspaceuser.Repository.SecWorkspaceUserRepo;
|
||||||
//import com.realnet.Workspaceuser.Repository.Sec_team_MemberRepository;
|
import com.realnet.Workspaceuser.Repository.Sec_team_MemberRepository;
|
||||||
//import com.realnet.Workspaceuser.Repository.Sec_teams_Repository;
|
import com.realnet.Workspaceuser.Repository.Sec_teams_Repository;
|
||||||
//import com.realnet.users.entity1.AppUser;
|
import com.realnet.users.entity1.AppUser;
|
||||||
//import com.realnet.users.repository1.AppUserRepository;
|
import com.realnet.users.repository1.AppUserRepository;
|
||||||
//import com.realnet.users.response.MessageResponse;
|
import com.realnet.users.response.MessageResponse;
|
||||||
//import com.realnet.users.service1.AppUserServiceImpl;
|
import com.realnet.users.service1.AppUserServiceImpl;
|
||||||
//
|
|
||||||
//@RestController
|
@RestController
|
||||||
//@RequestMapping("/User_workSpace")
|
@RequestMapping("/User_workSpace")
|
||||||
//public class WorkSpaceController1 {
|
public class WorkSpaceController1 {
|
||||||
// @Autowired
|
@Autowired
|
||||||
// private AppUserServiceImpl userService;
|
private AppUserServiceImpl userService;
|
||||||
//
|
|
||||||
// @Autowired
|
@Autowired
|
||||||
// private AppUserRepository appUserRepository;
|
private AppUserRepository appUserRepository;
|
||||||
// @Autowired
|
@Autowired
|
||||||
// private Sec_teams_Repository sec_teams_Repository;
|
private Sec_teams_Repository sec_teams_Repository;
|
||||||
//
|
|
||||||
// @Autowired
|
@Autowired
|
||||||
// private Sec_team_MemberRepository memberRepository;
|
private Sec_team_MemberRepository memberRepository;
|
||||||
//
|
|
||||||
// @Autowired
|
@Autowired
|
||||||
// private SecWorkspaceUserRepo secWorkspaceUserRepo;
|
private SecWorkspaceUserRepo secWorkspaceUserRepo;
|
||||||
//
|
|
||||||
// //GET ALL USER attach from login id
|
// GET ALL USER by account id attach from loggedin user
|
||||||
// @GetMapping("/GetAll")
|
@GetMapping("/GetAll/AccountId")
|
||||||
// public ResponseEntity<?> getall(){
|
public ResponseEntity<?> getall() {
|
||||||
// AppUser loggedInUser = userService.getLoggedInUser();
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
// Long account_id = loggedInUser.getAccount().getAccount_id();
|
Long account_id = loggedInUser.getAccount().getAccount_id();
|
||||||
//
|
|
||||||
// List<AppUser> li = appUserRepository.getall(account_id);
|
List<AppUser> li = appUserRepository.getall(account_id);
|
||||||
// return new ResponseEntity<>(li,HttpStatus.OK);
|
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// //ADD USER TO SPECIFIC TEAM
|
// ADD USER TO SPECIFIC TEAM
|
||||||
// @PostMapping("/add_team/{id}/{userId}")
|
@PostMapping("/add_team/{id}/{userId}")
|
||||||
// public ResponseEntity<?> addteam(@RequestBody Sec_team_members team_mem,
|
public ResponseEntity<?> addteam(@RequestBody Sec_team_members team_mem, @PathVariable int id,
|
||||||
// @PathVariable int id,@PathVariable Long userId){
|
@PathVariable Long userId) {
|
||||||
// Sec_team_members members = memberRepository.findteammember(id,userId);
|
Sec_team_members members = memberRepository.findteammember(id, userId);
|
||||||
// if(members == null) {
|
if (members == null) {
|
||||||
//
|
|
||||||
// Sec_teams team = sec_teams_Repository.findById(id);
|
Sec_teams team = sec_teams_Repository.findById(id);
|
||||||
// if(team != null) {
|
if (team != null) {
|
||||||
//
|
|
||||||
// AppUser user = appUserRepository.findById(userId).orElseThrow(null);
|
AppUser user = appUserRepository.findById(userId).orElseThrow(null);
|
||||||
//
|
|
||||||
// team_mem.setTeam_id(team.getId());
|
team_mem.setTeam_id(team.getId());
|
||||||
// team_mem.setMember_name(user.getFullName());
|
team_mem.setMember_name(user.getFullName());
|
||||||
// team_mem.setMember_id(user.getUserId());
|
team_mem.setMember_id(user.getUserId());
|
||||||
// Sec_team_members save = memberRepository.save(team_mem);
|
Sec_team_members save = memberRepository.save(team_mem);
|
||||||
//
|
|
||||||
//
|
return new ResponseEntity<>(save, HttpStatus.OK);
|
||||||
// return new ResponseEntity<>(save, HttpStatus.OK);
|
|
||||||
//
|
} else
|
||||||
// }
|
return ResponseEntity.badRequest().body(new MessageResponse("team not found"));
|
||||||
// else
|
} else
|
||||||
// return ResponseEntity.badRequest().body(new MessageResponse("team not found"));
|
return ResponseEntity.badRequest().body(new MessageResponse("member already added"));
|
||||||
// }
|
}
|
||||||
// else
|
|
||||||
// return ResponseEntity.badRequest().body(new MessageResponse("member already added"));
|
// REMOVE MEMBER FROM TEAM
|
||||||
// }
|
@DeleteMapping("/RemoveMember/{id}/{userId}")
|
||||||
//
|
public MessageResponse removemember(@PathVariable int id, @PathVariable Long userId) {
|
||||||
// //REMOVE MEMBER FROM TEAM
|
Sec_team_members members = memberRepository.findteammember(id, userId);
|
||||||
// @DeleteMapping("/RemoveMember/{id}/{userId}")
|
if (members != null) {
|
||||||
// public MessageResponse removemember(@PathVariable int id,@PathVariable Long userId){
|
memberRepository.delete(members);
|
||||||
// Sec_team_members members = memberRepository.findteammember(id,userId);
|
return new MessageResponse("deleted");
|
||||||
// if(members != null) {
|
} else
|
||||||
// memberRepository.delete(members);
|
|
||||||
// return new MessageResponse("deleted");
|
return new MessageResponse("member not found");
|
||||||
// }else
|
}
|
||||||
//
|
|
||||||
// return new MessageResponse("member not found");
|
// GET ALL USER ADD BY ADMIN
|
||||||
// }
|
@GetMapping("/GetAllUser")
|
||||||
//
|
public ResponseEntity<?> GetUser() {
|
||||||
//
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
// //GET ALL USER ADD BY ADMIN
|
Long account_id = loggedInUser.getAccount().getAccount_id();
|
||||||
// @GetMapping("/GetAllUser")
|
|
||||||
// public ResponseEntity<?> GetUser(){
|
List<AppUser> li = appUserRepository.getalluser(account_id);
|
||||||
// AppUser loggedInUser = userService.getLoggedInUser();
|
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||||
// Long account_id = loggedInUser.getAccount().getAccount_id();
|
}
|
||||||
//
|
|
||||||
// List<AppUser> li = appUserRepository.getalluser(account_id);
|
// GET ALL GUEST ADD BY ADMIN
|
||||||
// return new ResponseEntity<>(li,HttpStatus.OK);
|
@GetMapping("/GetAllGuest")
|
||||||
// }
|
public ResponseEntity<?> Getguest() {
|
||||||
//
|
AppUser loggedInUser = userService.getLoggedInUser();
|
||||||
// //GET ALL GUEST ADD BY ADMIN
|
Long account_id = loggedInUser.getAccount().getAccount_id();
|
||||||
// @GetMapping("/GetAllGuest")
|
|
||||||
// public ResponseEntity<?> Getguest(){
|
List<AppUser> li = appUserRepository.getallguest(account_id);
|
||||||
// AppUser loggedInUser = userService.getLoggedInUser();
|
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||||
// Long account_id = loggedInUser.getAccount().getAccount_id();
|
}
|
||||||
//
|
|
||||||
// List<AppUser> li = appUserRepository.getallguest(account_id);
|
// GET ALL TEAM MEMBER FROM SPECIFIC TEAM
|
||||||
// return new ResponseEntity<>(li,HttpStatus.OK);
|
@GetMapping("/GetAllMember/{team_id}")
|
||||||
// }
|
public ResponseEntity<?> GetAllteamMember(@PathVariable int team_id) {
|
||||||
//
|
|
||||||
// //GET ALL TEAM MEMBER FROM SPECIFIC TEAM
|
List<Sec_team_members> li = memberRepository.getallteam(team_id);
|
||||||
// @GetMapping("/GetAllMember/{team_id}")
|
if (li == null) {
|
||||||
// public ResponseEntity<?> GetAllteamMember(@PathVariable int team_id){
|
return ResponseEntity.badRequest().body(new MessageResponse("team not found"));
|
||||||
//
|
} else
|
||||||
//
|
return new ResponseEntity<>(li, HttpStatus.OK);
|
||||||
// List<Sec_team_members> li = memberRepository.getallteam(team_id);
|
}
|
||||||
// if(li == null) {
|
|
||||||
// return ResponseEntity.badRequest().body(new MessageResponse("team not found"));
|
}
|
||||||
// }else
|
|
||||||
// return new ResponseEntity<>(li,HttpStatus.OK);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ public class AppUser implements Serializable {
|
|||||||
private String password4;
|
private String password4;
|
||||||
private Long pwdChangedCnt;
|
private Long pwdChangedCnt;
|
||||||
private Date lastPwdChangedDate;
|
private Date lastPwdChangedDate;
|
||||||
private Blob photo;
|
// private Blob photo;
|
||||||
private String photoName;
|
private String photoName;
|
||||||
|
|
||||||
private String provider;
|
private String provider;
|
||||||
@@ -157,6 +157,8 @@ public class AppUser implements Serializable {
|
|||||||
@Transient
|
@Transient
|
||||||
private StringBuilder totalLogInfo;
|
private StringBuilder totalLogInfo;
|
||||||
|
|
||||||
|
// private String tshirtsize;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private PasswordResetToken pass;
|
private PasswordResetToken pass;
|
||||||
|
|||||||
@@ -20,6 +20,6 @@ public class AppUserDto {
|
|||||||
private String notification;
|
private String notification;
|
||||||
private Long mob_no;
|
private Long mob_no;
|
||||||
private boolean active;
|
private boolean active;
|
||||||
|
private String tshirtsize;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,6 +392,9 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
|||||||
a.setNotification(
|
a.setNotification(
|
||||||
appUserDto.getNotification() != null ? appUserDto.getNotification() : a.getNotification());
|
appUserDto.getNotification() != null ? appUserDto.getNotification() : a.getNotification());
|
||||||
|
|
||||||
|
// if (appUserDto.getTshirtsize() != null) {
|
||||||
|
// a.setTshirtsize(appUserDto.getTshirtsize());
|
||||||
|
// }
|
||||||
a.setMob_no(appUserDto.getMob_no());
|
a.setMob_no(appUserDto.getMob_no());
|
||||||
a.setActive(appUserDto.isActive());
|
a.setActive(appUserDto.isActive());
|
||||||
|
|
||||||
@@ -527,7 +530,7 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
|||||||
AppUser save = appUserRepository.save(a);
|
AppUser save = appUserRepository.save(a);
|
||||||
System.out.println("Password changed Successfully.. ");
|
System.out.println("Password changed Successfully.. ");
|
||||||
|
|
||||||
return new ResponseEntity<>(save, HttpStatus.ACCEPTED);
|
return new ResponseEntity<>("Password changed Successfully", HttpStatus.ACCEPTED);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -644,6 +647,9 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
|||||||
user.setUsername(email);
|
user.setUsername(email);
|
||||||
user.setEmail(email);
|
user.setEmail(email);
|
||||||
user.setAccount(accounts);
|
user.setAccount(accounts);
|
||||||
|
if (user.getCreatedate() == null) {
|
||||||
|
user.setCreatedate(LocalDateTime.now());
|
||||||
|
}
|
||||||
|
|
||||||
appUserRepository.save(user);
|
appUserRepository.save(user);
|
||||||
|
|
||||||
@@ -657,6 +663,9 @@ public class AppUserServiceImpl implements UserDetailsService, AppUserService {
|
|||||||
user.setUsername(email);
|
user.setUsername(email);
|
||||||
user.setEmail(email);
|
user.setEmail(email);
|
||||||
user.setAccount(accounts);
|
user.setAccount(accounts);
|
||||||
|
if (user.getCreatedate() == null) {
|
||||||
|
user.setCreatedate(LocalDateTime.now());
|
||||||
|
}
|
||||||
// user.setAccess_duration(access_duration);
|
// user.setAccess_duration(access_duration);
|
||||||
//
|
//
|
||||||
// Calendar c = Calendar.getInstance();
|
// Calendar c = Calendar.getInstance();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.itextpdf.text.pdf.PdfStructTreeController.returnType;
|
||||||
import com.realnet.users.entity.Sys_Accounts;
|
import com.realnet.users.entity.Sys_Accounts;
|
||||||
import com.realnet.users.repository.SysAccountRepo;
|
import com.realnet.users.repository.SysAccountRepo;
|
||||||
|
|
||||||
@@ -15,12 +16,64 @@ public class SysAccountService {
|
|||||||
private SysAccountRepo sysAccountRepo;
|
private SysAccountRepo sysAccountRepo;
|
||||||
|
|
||||||
public Sys_Accounts save(Sys_Accounts sys) {
|
public Sys_Accounts save(Sys_Accounts sys) {
|
||||||
|
|
||||||
|
Sys_Accounts account = findByEmail(sys.getEmail());
|
||||||
|
if (account != null) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sys.setActive(true);
|
||||||
Sys_Accounts accounts = sysAccountRepo.save(sys);
|
Sys_Accounts accounts = sysAccountRepo.save(sys);
|
||||||
|
|
||||||
return accounts;
|
return accounts;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update sysaccount
|
||||||
|
|
||||||
|
public Sys_Accounts update(Long accountId, Sys_Accounts request) {
|
||||||
|
|
||||||
|
Sys_Accounts account = sysAccountRepo.findById(accountId).get();
|
||||||
|
// account_id generally auto-generated hai, update me change nahi karenge
|
||||||
|
|
||||||
|
if (request.getCompanyName() != null) {
|
||||||
|
account.setCompanyName(request.getCompanyName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getWorkspace() != null) {
|
||||||
|
account.setWorkspace(request.getWorkspace());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getGstNumber() != null) {
|
||||||
|
account.setGstNumber(request.getGstNumber());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getMobile() != null) {
|
||||||
|
account.setMobile(request.getMobile());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getEmail() != null) {
|
||||||
|
account.setEmail(request.getEmail());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getPancard() != null) {
|
||||||
|
account.setPancard(request.getPancard());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getWorking() != null) {
|
||||||
|
account.setWorking(request.getWorking());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.getActive() != null) {
|
||||||
|
account.setActive(request.getActive());
|
||||||
|
}
|
||||||
|
|
||||||
|
Sys_Accounts save = sysAccountRepo.save(account);
|
||||||
|
|
||||||
|
return save;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public List<Sys_Accounts> getall() {
|
public List<Sys_Accounts> getall() {
|
||||||
|
|
||||||
List<Sys_Accounts> getall = sysAccountRepo.findAll();
|
List<Sys_Accounts> getall = sysAccountRepo.findAll();
|
||||||
|
|||||||
@@ -1,15 +1,113 @@
|
|||||||
package com.realnet.utils;
|
package com.realnet.utils;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class Port_Constant {
|
public class Port_Constant {
|
||||||
|
|
||||||
public final static String LOCAL_HOST = "43.205.154.152";
|
public static String BACKEND_PORTAL_DOMAIN;
|
||||||
public final static String FRONTEND_PORT_9191 = "30165";
|
|
||||||
public static String SURE_SETU_DOMAIN = "http://34.198.218.30:30173";
|
|
||||||
|
|
||||||
public final static String GITEA_IP_ADDRESS = "try.gitea";
|
|
||||||
public final static String GITEA_PORT = "io";
|
|
||||||
public final static String SURE_VAULT_DOMAIN = "http://54.92.243.148:30150";
|
|
||||||
public final static String SUREVAULT_DEPLOYMENT_TYPE = "32";
|
|
||||||
public static String FRONTEND_PORTAL_DOMAIN;
|
public static String FRONTEND_PORTAL_DOMAIN;
|
||||||
|
public static String SUREOPS_DOMAIN;
|
||||||
|
public static String JOBPRO_DOMAIN;
|
||||||
|
public static String APP_BUILD_DOMAIN;
|
||||||
|
public static String SURE_SERVE_DOMAIN;
|
||||||
|
public static String SURE_SETU_DOMAIN;
|
||||||
|
public static String FARM_SCRIPT_RUNNER_DOMAIN;
|
||||||
|
public static String DEPLOYMENT_TYPE;
|
||||||
|
public static String FARM_IP_ADDRESS_online;
|
||||||
|
public static String CONTROL_CENTRE_PORT;
|
||||||
|
public static String CONTROL_CENTRE_MASTER_PORT;
|
||||||
|
public static String CONTROL_CENTRE_MASTER_IP;
|
||||||
|
public static String LOCALHOST;
|
||||||
|
public static String SUREOPS_LOCALHOST;
|
||||||
|
public static String APPBUILD_LOCALHOST;
|
||||||
|
public static String SURE_VAULT_DOMAIN;
|
||||||
|
public static String GITEA_DB_NAME;
|
||||||
|
public static String GITEA_DOMAIN;
|
||||||
|
public static String GITEA_USERNAME;
|
||||||
|
public static String GITEA_URL;
|
||||||
|
public static String PROTOCOL;
|
||||||
|
public static String SONAR_QUBE_DOMAIN;
|
||||||
|
public static String SONAR_QUBE_Username;
|
||||||
|
|
||||||
|
public static String SONAR_QUBE_password;
|
||||||
|
public static String DOMAIN;
|
||||||
|
|
||||||
|
// SETTER
|
||||||
|
|
||||||
|
private final RestTemplate restTemplate = new RestTemplate();
|
||||||
|
|
||||||
|
// Type ('dev', 'prod')
|
||||||
|
private final String type = "dev";
|
||||||
|
|
||||||
|
@Value("${BACKEND_PORTAL_DOMAIN}")
|
||||||
|
private String backendPortalDomain;
|
||||||
|
|
||||||
|
// @PostConstruct is used to make API calls and initialize the constants for the
|
||||||
|
// entire application during startup.
|
||||||
|
@PostConstruct
|
||||||
|
public void initializeConstantsFromApi() {
|
||||||
|
|
||||||
|
// BACKEND_PORTAL_DOMAIN = getUrlFromApi("Backend_portal_domain");
|
||||||
|
// String backendPortalDomain = getBackendPortalUrl();
|
||||||
|
// System.out.println("Fetched BACKEND_PORTAL_DOMAIN: " + backendPortalDomain);
|
||||||
|
|
||||||
|
if (backendPortalDomain != null) {
|
||||||
|
BACKEND_PORTAL_DOMAIN = backendPortalDomain;
|
||||||
|
System.out.println("Fetched BACKEND_PORTAL_DOMAIN from properties file: " + backendPortalDomain);
|
||||||
|
|
||||||
|
FRONTEND_PORTAL_DOMAIN = getUrlFromApi(backendPortalDomain, "Frontend_portal_domain");
|
||||||
|
System.out.println("FRONTEND_PORTAL_DOMAIN: " + FRONTEND_PORTAL_DOMAIN);
|
||||||
|
SUREOPS_DOMAIN = getUrlFromApi(backendPortalDomain, "SUREOPS_DOMAIN");
|
||||||
|
JOBPRO_DOMAIN = getUrlFromApi(backendPortalDomain, "JOBPRO_DOMAIN");
|
||||||
|
APP_BUILD_DOMAIN = getUrlFromApi(backendPortalDomain, "APP_BUILD_DOMAIN");
|
||||||
|
SURE_SERVE_DOMAIN = getUrlFromApi(backendPortalDomain, "SURE_SERVE_DOMAIN");
|
||||||
|
SURE_SETU_DOMAIN = getUrlFromApi(backendPortalDomain, "SURE_SETU_DOMAIN");
|
||||||
|
FARM_SCRIPT_RUNNER_DOMAIN = getUrlFromApi(backendPortalDomain, "FARM_SCRIPT_RUNNER_DOMAIN");
|
||||||
|
DEPLOYMENT_TYPE = getUrlFromApi(backendPortalDomain, "DEPLOYMENT_TYPE");
|
||||||
|
FARM_IP_ADDRESS_online = getUrlFromApi(backendPortalDomain, "FARM_IP_ADDRESS_online");
|
||||||
|
CONTROL_CENTRE_PORT = getUrlFromApi(backendPortalDomain, "CONTROL_CENTRE_PORT");
|
||||||
|
CONTROL_CENTRE_MASTER_PORT = getUrlFromApi(backendPortalDomain, "CONTROL_CENTRE_MASTER_PORT");
|
||||||
|
CONTROL_CENTRE_MASTER_IP = getUrlFromApi(backendPortalDomain, "CONTROL_CENTRE_MASTER_IP");
|
||||||
|
LOCALHOST = getUrlFromApi(backendPortalDomain, "Localhost");
|
||||||
|
SUREOPS_LOCALHOST = getUrlFromApi(backendPortalDomain, "SUREOPS_LOCALHOST");
|
||||||
|
APPBUILD_LOCALHOST = getUrlFromApi(backendPortalDomain, "APPBUILD_LOCALHOST");
|
||||||
|
SURE_VAULT_DOMAIN = getUrlFromApi(backendPortalDomain, "SURE_VAULT_DOMAIN");
|
||||||
|
GITEA_DOMAIN = getUrlFromApi(backendPortalDomain, "GITEA_DOMAIN");
|
||||||
|
GITEA_USERNAME = getUrlFromApi(backendPortalDomain, "GITEA_USERNAME");
|
||||||
|
|
||||||
|
GITEA_URL = getUrlFromApi(backendPortalDomain, "GITEA_URL");
|
||||||
|
|
||||||
|
GITEA_DB_NAME = getUrlFromApi(backendPortalDomain, "GITEA_DB_NAME");
|
||||||
|
|
||||||
|
PROTOCOL = getUrlFromApi(backendPortalDomain, "PROTOCOL");
|
||||||
|
SONAR_QUBE_DOMAIN = getUrlFromApi(backendPortalDomain, "SONAR_QUBE_DOMAIN");
|
||||||
|
SONAR_QUBE_Username = getUrlFromApi(backendPortalDomain, "SONAR_QUBE_Username");
|
||||||
|
|
||||||
|
SONAR_QUBE_password = getUrlFromApi(backendPortalDomain, "SONAR_QUBE_password");
|
||||||
|
DOMAIN = getUrlFromApi(backendPortalDomain, "DOMAIN");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
System.out.println("Error: BACKEND_PORTAL_DOMAIN could not be fetched.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getUrlFromApi(String backendPortalDomain, String serviceName) {
|
||||||
|
try {
|
||||||
|
// Use the provided backendPortalDomain to construct the full URL
|
||||||
|
String baseUrl = backendPortalDomain + "/token/HealthCheckup/DeploymentUrl/Deployment_url/";
|
||||||
|
String url = baseUrl + type + "/" + serviceName;
|
||||||
|
String Object = restTemplate.getForObject(url, String.class); // Fetch URL from API
|
||||||
|
|
||||||
|
System.out.println(serviceName + " : " + Object);
|
||||||
|
return Object;
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("Error fetching URL for " + serviceName + ": " + e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,12 @@ app.auth.tokenExpirationMsec=864000000
|
|||||||
app.oauth2.authorizedRedirectUris=http://localhost:8081/oauth2/redirect,myandroidapp://oauth2/redirect,myiosapp://oauth2/redirect
|
app.oauth2.authorizedRedirectUris=http://localhost:8081/oauth2/redirect,myandroidapp://oauth2/redirect,myiosapp://oauth2/redirect
|
||||||
|
|
||||||
|
|
||||||
projectPath=@project.basedir@
|
# projectPath=@project.basedir@
|
||||||
angularProjectPath=@project.basedir@/webui
|
# angularProjectPath=@project.basedir@/webui
|
||||||
|
|
||||||
|
projectPath=/data
|
||||||
|
angularProjectPath=/data/webui
|
||||||
|
BACKEND_PORTAL_DOMAIN=http://157.66.191.31:30166
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user