add loggers

version_2
floxx2112 1 year ago
parent 951904394b
commit c37c5f15c8
  1. 5
      pom.xml
  2. 9
      src/main/java/com/apside/assistDbBackend/controller/InfoColumnController.java
  3. 10
      src/main/java/com/apside/assistDbBackend/controller/InfoTableController.java
  4. 11
      src/main/java/com/apside/assistDbBackend/controller/LinkInfoController.java
  5. 3
      src/main/java/com/apside/assistDbBackend/controller/ResetDataController.java
  6. 8
      src/main/java/com/apside/assistDbBackend/controller/ScriptController.java
  7. 6
      src/main/java/com/apside/assistDbBackend/controller/TagsController.java
  8. 13
      src/main/java/com/apside/assistDbBackend/service/GitService.java
  9. 12
      src/main/java/com/apside/assistDbBackend/service/InfoColumnService.java
  10. 15
      src/main/java/com/apside/assistDbBackend/service/InfoTableService.java
  11. 8
      src/main/java/com/apside/assistDbBackend/service/LinkInfoService.java
  12. 6
      src/main/java/com/apside/assistDbBackend/service/ResetDataService.java
  13. 28
      src/main/java/com/apside/assistDbBackend/service/ScriptsService.java
  14. 12
      src/main/java/com/apside/assistDbBackend/service/TagsService.java
  15. 2
      src/main/resources/application.properties
  16. 15
      src/main/resources/log4j.properties

@ -92,6 +92,11 @@
<version>3.4.1</version> <version>3.4.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -2,6 +2,7 @@ package com.apside.assistDbBackend.controller;
import com.apside.assistDbBackend.model.InfoColumn; import com.apside.assistDbBackend.model.InfoColumn;
import com.apside.assistDbBackend.service.InfoColumnService; import com.apside.assistDbBackend.service.InfoColumnService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -12,6 +13,7 @@ import java.util.Optional;
@RestController @RestController
@RequestMapping("/api") @RequestMapping("/api")
@Slf4j
public class InfoColumnController { public class InfoColumnController {
@Autowired @Autowired
private InfoColumnService infoColumnService; private InfoColumnService infoColumnService;
@ -23,6 +25,7 @@ public class InfoColumnController {
*/ */
@GetMapping("/column/{id}") @GetMapping("/column/{id}")
public InfoColumn getColumn(@PathVariable("id") final Long id) { public InfoColumn getColumn(@PathVariable("id") final Long id) {
log.debug("Start GetColumn - Get Request - with id: " + id);
Optional<InfoColumn> infoColumn = infoColumnService.getColumn(id); Optional<InfoColumn> infoColumn = infoColumnService.getColumn(id);
if(infoColumn.isPresent()) { if(infoColumn.isPresent()) {
return infoColumn.get(); return infoColumn.get();
@ -37,6 +40,7 @@ public class InfoColumnController {
*/ */
@GetMapping("/columns/all") @GetMapping("/columns/all")
public Iterable<InfoColumn> getColumns() { public Iterable<InfoColumn> getColumns() {
log.debug("Start getColumns - Get Request");
return infoColumnService.getAllColumns(); return infoColumnService.getAllColumns();
} }
@ -46,16 +50,20 @@ public class InfoColumnController {
*/ */
@GetMapping("/columns/{schema}/{table}") @GetMapping("/columns/{schema}/{table}")
public Iterable<InfoColumn> getSelectedColumns(@PathVariable("schema") final String schema, @PathVariable("table") final String table) { public Iterable<InfoColumn> getSelectedColumns(@PathVariable("schema") final String schema, @PathVariable("table") final String table) {
log.debug("Start GetSelectedColumns - Get Request - with schema: {}, table: {}", schema, table);
return infoColumnService.getSelectedColumns(table, schema); return infoColumnService.getSelectedColumns(table, schema);
} }
@GetMapping("/columns/{firstSchema}/{secondSchema}/{firstTable}/{secondTable}") @GetMapping("/columns/{firstSchema}/{secondSchema}/{firstTable}/{secondTable}")
public Iterable<InfoColumn> getColumnsForJoin(@PathVariable("firstTable") final String firstTable, @PathVariable("secondTable") final String secondTable, @PathVariable("firstSchema") final String firstSchema, @PathVariable("secondSchema") final String secondSchema) { public Iterable<InfoColumn> getColumnsForJoin(@PathVariable("firstTable") final String firstTable, @PathVariable("secondTable") final String secondTable, @PathVariable("firstSchema") final String firstSchema, @PathVariable("secondSchema") final String secondSchema) {
log.debug("Start GetColumnsForJoin - Get Request - with firstTable: {}, secondTable: {}, firstSchema: {}, secondSchema: {}", firstTable, secondTable, firstSchema, secondSchema);
return infoColumnService.getColumnsForJoin(firstTable, secondTable, firstSchema, secondSchema); return infoColumnService.getColumnsForJoin(firstTable, secondTable, firstSchema, secondSchema);
} }
@GetMapping("/columns/joins") @GetMapping("/columns/joins")
public Iterable<InfoColumn> getColumnsForJoinTwo(@RequestParam("tables") String tables, @RequestParam("schemas") String schemas) { public Iterable<InfoColumn> getColumnsForJoinTwo(@RequestParam("tables") String tables, @RequestParam("schemas") String schemas) {
log.debug("Start GetColumnsForJoinTwo - Get Request - with tables: {}, schemas: {}", tables, schemas);
List<String> tablesList = new ArrayList<>(Arrays.asList(tables.split(","))); List<String> tablesList = new ArrayList<>(Arrays.asList(tables.split(",")));
List<String> schemasList = new ArrayList<>(Arrays.asList(schemas.split(","))); List<String> schemasList = new ArrayList<>(Arrays.asList(schemas.split(",")));
return infoColumnService.getColumnsForJoinTwo(tablesList, schemasList); return infoColumnService.getColumnsForJoinTwo(tablesList, schemasList);
@ -63,6 +71,7 @@ public class InfoColumnController {
@DeleteMapping("/columns/deleteAll") @DeleteMapping("/columns/deleteAll")
public void deleteAllColumns() { public void deleteAllColumns() {
log.debug("DeleteAllColumns called");
infoColumnService.deleteAllColumn(); infoColumnService.deleteAllColumn();
} }

@ -2,13 +2,16 @@ package com.apside.assistDbBackend.controller;
import com.apside.assistDbBackend.service.InfoTableService; import com.apside.assistDbBackend.service.InfoTableService;
import com.apside.assistDbBackend.model.InfoTable; import com.apside.assistDbBackend.model.InfoTable;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Optional; import java.util.Optional;
@RestController @RestController
@RequestMapping("/api") @RequestMapping("/api")
@Slf4j
public class InfoTableController { public class InfoTableController {
@Autowired @Autowired
private InfoTableService infoTableService; private InfoTableService infoTableService;
@ -21,6 +24,7 @@ public class InfoTableController {
*/ */
@GetMapping("/table/{id}") @GetMapping("/table/{id}")
public InfoTable getTable(@PathVariable("id") final Long id) { public InfoTable getTable(@PathVariable("id") final Long id) {
log.debug("Start getTable - Get Request - with id: " + id);
Optional<InfoTable> infoTable = infoTableService.getTable(id); Optional<InfoTable> infoTable = infoTableService.getTable(id);
if(infoTable.isPresent()) { if(infoTable.isPresent()) {
return infoTable.get(); return infoTable.get();
@ -44,6 +48,7 @@ public class InfoTableController {
*/ */
@GetMapping("/schemas/all") @GetMapping("/schemas/all")
public Iterable<String> getSchemas() { public Iterable<String> getSchemas() {
log.debug("Start getSchemas - Get Request");
return infoTableService.getAllSchemas(); return infoTableService.getAllSchemas();
} }
@ -52,17 +57,20 @@ public class InfoTableController {
* @return - An Iterable object of InfoTable full filled * @return - An Iterable object of InfoTable full filled
*/ */
@GetMapping("/tables/{schema}") @GetMapping("/tables/{schema}")
public Iterable<InfoTable> getTables(@PathVariable("schema") final String schema) { public Iterable<InfoTable> getTablesBySchemaName(@PathVariable("schema") final String schema) {
log.debug("Start getTablesBySchemaName - Get Request - with schema: {}", schema);
return infoTableService.getTablesBySchemaName(schema); return infoTableService.getTablesBySchemaName(schema);
} }
@GetMapping("/schemas/{table}") @GetMapping("/schemas/{table}")
public Iterable<InfoTable> getSchemaByTableName(@PathVariable("table") final String table) { public Iterable<InfoTable> getSchemaByTableName(@PathVariable("table") final String table) {
log.debug("Start getSchemaByTableName - Get Request - with table: {}", table);
return infoTableService.getSchemaByTableName(table); return infoTableService.getSchemaByTableName(table);
} }
@DeleteMapping("/tables/deleteAll") @DeleteMapping("/tables/deleteAll")
public void deleteAllTables() { public void deleteAllTables() {
log.debug("DeleteAllTables called");
infoTableService.deleteAllTable(); infoTableService.deleteAllTable();
} }

@ -2,13 +2,15 @@ package com.apside.assistDbBackend.controller;
import com.apside.assistDbBackend.model.LinkInfo; import com.apside.assistDbBackend.model.LinkInfo;
import com.apside.assistDbBackend.service.LinkInfoService; import com.apside.assistDbBackend.service.LinkInfoService;
import lombok.extern.slf4j.Slf4j;
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.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.Optional; import java.util.Optional;
@RestController
@RequestMapping("/api")
@Slf4j
public class LinkInfoController { public class LinkInfoController {
@Autowired @Autowired
@ -22,6 +24,7 @@ public class LinkInfoController {
*/ */
@GetMapping("/link/{id}") @GetMapping("/link/{id}")
public LinkInfo getLinkInfo(@PathVariable("id") final Long id) { public LinkInfo getLinkInfo(@PathVariable("id") final Long id) {
log.debug("Start getLinkInfo - Get Request - with id: " + id);
Optional<LinkInfo> linkInfo = linkInfoService.getLinkInfo(id); Optional<LinkInfo> linkInfo = linkInfoService.getLinkInfo(id);
if(linkInfo.isPresent()) { if(linkInfo.isPresent()) {
return linkInfo.get(); return linkInfo.get();
@ -36,11 +39,13 @@ public class LinkInfoController {
*/ */
@GetMapping("/links/all") @GetMapping("/links/all")
public Iterable<LinkInfo> getLinksInfos() { public Iterable<LinkInfo> getLinksInfos() {
log.debug("Start getLinksInfos - Get Request");
return linkInfoService.getAllLinksInfos(); return linkInfoService.getAllLinksInfos();
} }
@DeleteMapping("/links/deleteAll") @DeleteMapping("/links/deleteAll")
public void deleteAllLinks() { public void deleteAllLinks() {
log.debug("DeleteAllLinks called");
linkInfoService.deleteAllLinks(); linkInfoService.deleteAllLinks();
} }
} }

@ -3,11 +3,13 @@ package com.apside.assistDbBackend.controller;
import java.io.IOException; import java.io.IOException;
import com.apside.assistDbBackend.service.ResetDataService; import com.apside.assistDbBackend.service.ResetDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@RestController @RestController
@RequestMapping("/api") @RequestMapping("/api")
@Slf4j
public class ResetDataController { public class ResetDataController {
@Autowired @Autowired
private ResetDataService resetDataService; private ResetDataService resetDataService;
@ -15,6 +17,7 @@ public class ResetDataController {
@PostMapping("/reset") @PostMapping("/reset")
public void resetData() throws IOException { public void resetData() throws IOException {
log.debug("ResetData called");
resetDataService.deleteEverything(); resetDataService.deleteEverything();
resetDataService.insertEverything(); resetDataService.insertEverything();
resetDataService.checkAndInsertLinks(); resetDataService.checkAndInsertLinks();

@ -3,8 +3,10 @@ package com.apside.assistDbBackend.controller;
import com.apside.assistDbBackend.model.LinkScriptTag; import com.apside.assistDbBackend.model.LinkScriptTag;
import com.apside.assistDbBackend.model.Script; import com.apside.assistDbBackend.model.Script;
import com.apside.assistDbBackend.service.ScriptsService; import com.apside.assistDbBackend.service.ScriptsService;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.IOException; import java.io.IOException;
@ -13,34 +15,40 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/api") @RequestMapping("/api")
@Slf4j
public class ScriptController { public class ScriptController {
@Autowired @Autowired
ScriptsService scriptsService; ScriptsService scriptsService;
@GetMapping("/scripts") @GetMapping("/scripts")
public List<Script> getAllScripts() throws IOException, GitAPIException { public List<Script> getAllScripts() throws IOException, GitAPIException {
log.debug("GetAllScripts called");
return scriptsService.retrieveScripts(); return scriptsService.retrieveScripts();
} }
@GetMapping("/scripts/link") @GetMapping("/scripts/link")
public List<LinkScriptTag> getAllLinkScriptsTags() throws IOException { public List<LinkScriptTag> getAllLinkScriptsTags() throws IOException {
log.debug("GetAllLinkScriptsTags called");
return scriptsService.getAllScriptTag(); return scriptsService.getAllScriptTag();
} }
@DeleteMapping("/script/delete/{name}") @DeleteMapping("/script/delete/{name}")
public void deleteScript(@PathVariable("name") final String name){ public void deleteScript(@PathVariable("name") final String name){
log.debug("Start DeleteScript - Delete Request - with name: {}" + name);
scriptsService.deleteOneScript(name); scriptsService.deleteOneScript(name);
} }
@GetMapping("/script/add") @GetMapping("/script/add")
public void addScript(@RequestParam("content") String content, @RequestParam("name") String name, @RequestParam("desc") String description, @RequestParam("tagList") List<String> tagsList, @RequestParam("linkid") int linkId) throws IOException, GitAPIException, URISyntaxException { public void addScript(@RequestParam("content") String content, @RequestParam("name") String name, @RequestParam("desc") String description, @RequestParam("tagList") List<String> tagsList, @RequestParam("linkid") int linkId) throws IOException, GitAPIException, URISyntaxException {
log.debug("Start AddScript - Get Request - with name: {}, description: {}, tagsList: {} and linkId: {}", name, description, tagsList, linkId);
scriptsService.addOneScript(content, name); scriptsService.addOneScript(content, name);
scriptsService.addOneLink(name, description, tagsList, linkId); scriptsService.addOneLink(name, description, tagsList, linkId);
} }
@GetMapping("/script/edit") @GetMapping("/script/edit")
public void editScript(@RequestParam("content") String content, @RequestParam("defaultname") String defaultName, @RequestParam("newname") String newName, @RequestParam("desc") String description, @RequestParam("tagList") List<String> tagsList, @RequestParam("linkid") int linkId) throws IOException, GitAPIException, URISyntaxException { public void editScript(@RequestParam("content") String content, @RequestParam("defaultname") String defaultName, @RequestParam("newname") String newName, @RequestParam("desc") String description, @RequestParam("tagList") List<String> tagsList, @RequestParam("linkid") int linkId) throws IOException, GitAPIException, URISyntaxException {
log.debug("Start EditScript - Get Request - with defaultName: {}, newName: {}, description: {}, tagsList: {}, linkId: {}", defaultName, newName, description, tagsList, linkId);
scriptsService.simpleDeleteScript(defaultName); scriptsService.simpleDeleteScript(defaultName);
scriptsService.addOneScript(content, newName); scriptsService.addOneScript(content, newName);
scriptsService.updateOneLink(newName, description, tagsList, linkId); scriptsService.updateOneLink(newName, description, tagsList, linkId);

@ -2,6 +2,7 @@ package com.apside.assistDbBackend.controller;
import com.apside.assistDbBackend.model.Tag; import com.apside.assistDbBackend.model.Tag;
import com.apside.assistDbBackend.service.TagsService; import com.apside.assistDbBackend.service.TagsService;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -12,6 +13,7 @@ import java.util.List;
@RestController @RestController
@RequestMapping("/api") @RequestMapping("/api")
@Slf4j
public class TagsController { public class TagsController {
@Autowired @Autowired
@ -19,21 +21,25 @@ public class TagsController {
@GetMapping("/tags/all") @GetMapping("/tags/all")
public List<Tag> getTags() throws IOException, GitAPIException { public List<Tag> getTags() throws IOException, GitAPIException {
log.debug("GetTags called");
return tagsService.getAllTags(); return tagsService.getAllTags();
} }
@DeleteMapping("/tag/delete/{nameTag}") @DeleteMapping("/tag/delete/{nameTag}")
public void deleteTag(@PathVariable("nameTag") final String nameTag) throws IOException, GitAPIException, URISyntaxException { public void deleteTag(@PathVariable("nameTag") final String nameTag) throws IOException, GitAPIException, URISyntaxException {
log.debug("Start DeleteTag - Delete Request - with name: {}", nameTag);
tagsService.deleteTag(nameTag); tagsService.deleteTag(nameTag);
} }
@PostMapping("/tag/add") @PostMapping("/tag/add")
public void addTag(@RequestBody Tag tag) throws IOException, GitAPIException, URISyntaxException { public void addTag(@RequestBody Tag tag) throws IOException, GitAPIException, URISyntaxException {
log.debug("Start AddTag - Post Request - with tag: {}", tag);
tagsService.addTag(tag); tagsService.addTag(tag);
} }
@PutMapping("/tag/update/{prevTag}") @PutMapping("/tag/update/{prevTag}")
public void updateTag(@PathVariable("prevTag") final String prevTag, @RequestBody Tag tag) throws IOException, GitAPIException, URISyntaxException { public void updateTag(@PathVariable("prevTag") final String prevTag, @RequestBody Tag tag) throws IOException, GitAPIException, URISyntaxException {
log.debug("Start UpdateTag - Put Request - with previous tag: {}, new tag info: {}", prevTag, tag);
tagsService.updateTag(prevTag, tag); tagsService.updateTag(prevTag, tag);
} }
} }

@ -1,6 +1,7 @@
package com.apside.assistDbBackend.service; package com.apside.assistDbBackend.service;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.RemoteAddCommand; import org.eclipse.jgit.api.RemoteAddCommand;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
@ -15,6 +16,7 @@ import java.net.URISyntaxException;
@Data @Data
@Service @Service
@Slf4j
public class GitService { public class GitService {
private final String tempDirectoryPath; private final String tempDirectoryPath;
@ -31,6 +33,7 @@ public class GitService {
private String accesToken; private String accesToken;
public void pushToGit() throws IOException, GitAPIException, URISyntaxException { public void pushToGit() throws IOException, GitAPIException, URISyntaxException {
log.debug("Starting pushToGit method.");
try (Git git = Git.open(new File(tempDirectoryPath))){ try (Git git = Git.open(new File(tempDirectoryPath))){
RemoteAddCommand remoteAddCommand = git.remoteAdd(); RemoteAddCommand remoteAddCommand = git.remoteAdd();
remoteAddCommand.setName("origin"); remoteAddCommand.setName("origin");
@ -45,12 +48,22 @@ public class GitService {
userPass = new UsernamePasswordCredentialsProvider(userGit, accesToken); userPass = new UsernamePasswordCredentialsProvider(userGit, accesToken);
git.push().setCredentialsProvider(userPass).call(); git.push().setCredentialsProvider(userPass).call();
log.info("Push to Git successful.");
} catch (IOException|GitAPIException exception){
log.error("Error push from git", exception);
throw exception;
} }
} }
public void pullFromGit() throws IOException, GitAPIException { public void pullFromGit() throws IOException, GitAPIException {
log.debug("Starting pullFromGit method.");
try (Git git = Git.open(new File(tempDirectoryPath))){ try (Git git = Git.open(new File(tempDirectoryPath))){
git.pull().setCredentialsProvider(new UsernamePasswordCredentialsProvider(userGit, accesToken)).setRemote("origin").setRemoteBranchName("main").call(); git.pull().setCredentialsProvider(new UsernamePasswordCredentialsProvider(userGit, accesToken)).setRemote("origin").setRemoteBranchName("main").call();
log.info("Pull from Git successful.");
} catch (IOException|GitAPIException exception){
log.error("Error push from git", exception);
throw exception;
} }
} }

@ -3,6 +3,7 @@ package com.apside.assistDbBackend.service;
import com.apside.assistDbBackend.repository.InfoColumnRepository; import com.apside.assistDbBackend.repository.InfoColumnRepository;
import com.apside.assistDbBackend.model.InfoColumn; import com.apside.assistDbBackend.model.InfoColumn;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -11,47 +12,58 @@ import java.util.Optional;
@Data @Data
@Service @Service
@Slf4j
public class InfoColumnService { public class InfoColumnService {
@Autowired @Autowired
private InfoColumnRepository infoColumnRepository; private InfoColumnRepository infoColumnRepository;
public Optional<InfoColumn> getColumn(final Long id) { public Optional<InfoColumn> getColumn(final Long id) {
log.debug("Start GetColumn method - CRUD");
return infoColumnRepository.findById(id); return infoColumnRepository.findById(id);
} }
public Iterable<InfoColumn> getAllColumns() { public Iterable<InfoColumn> getAllColumns() {
log.debug("Start GetAllColumns method - CRUD");
return infoColumnRepository.findAll(); return infoColumnRepository.findAll();
} }
public Iterable<InfoColumn> getSelectedColumns(String table, String schema) { public Iterable<InfoColumn> getSelectedColumns(String table, String schema) {
log.debug("Start GetSelectedColumn method - Custom");
return infoColumnRepository.getSelectedColumns(table, schema); return infoColumnRepository.getSelectedColumns(table, schema);
} }
public Iterable<InfoColumn> getColumnsForJoin(String firstTable, String secondTable, String firstSchema, String secondSchema) { public Iterable<InfoColumn> getColumnsForJoin(String firstTable, String secondTable, String firstSchema, String secondSchema) {
log.debug("Start GetColumnForJoin method - Custom");
return infoColumnRepository.getColumnsForJoin(firstTable, secondTable, firstSchema, secondSchema); return infoColumnRepository.getColumnsForJoin(firstTable, secondTable, firstSchema, secondSchema);
} }
public Iterable<InfoColumn> getColumnsForJoinTwo(List<String> tables, List<String> schemas) { public Iterable<InfoColumn> getColumnsForJoinTwo(List<String> tables, List<String> schemas) {
log.debug("Start GetColumnForJoinTwo method - Custom");
return infoColumnRepository.getColumnsForJoinTwo(tables, schemas); return infoColumnRepository.getColumnsForJoinTwo(tables, schemas);
} }
public void deleteColumn(final Long id) { public void deleteColumn(final Long id) {
log.debug("Start deleteColumn method - CRUD");
infoColumnRepository.deleteById(id); infoColumnRepository.deleteById(id);
} }
public void deleteAllColumn() { public void deleteAllColumn() {
log.debug("Start deleteAllColumns method - CRUD");
infoColumnRepository.deleteAll(); infoColumnRepository.deleteAll();
} }
public InfoColumn addOrUpdateColumn(InfoColumn infoColumn) { public InfoColumn addOrUpdateColumn(InfoColumn infoColumn) {
log.debug("Start addOrUpdateColumn method - CRUD");
return infoColumnRepository.save(infoColumn); return infoColumnRepository.save(infoColumn);
} }
public InfoColumn getSpecCol(String nameCol, String dataType, int lengthCol, String columnText){ public InfoColumn getSpecCol(String nameCol, String dataType, int lengthCol, String columnText){
log.debug("Start getSpecCol method - Custom");
return infoColumnRepository.getSpecColumn(nameCol, dataType, lengthCol, columnText); return infoColumnRepository.getSpecColumn(nameCol, dataType, lengthCol, columnText);
} }
public void truncateMyColumn(){ public void truncateMyColumn(){
log.debug("Start truncateMyColumn method - Custom");
infoColumnRepository.truncateMyColumn(); infoColumnRepository.truncateMyColumn();
} }
} }

@ -3,6 +3,7 @@ package com.apside.assistDbBackend.service;
import com.apside.assistDbBackend.repository.InfoTableRepository; import com.apside.assistDbBackend.repository.InfoTableRepository;
import com.apside.assistDbBackend.model.InfoTable; import com.apside.assistDbBackend.model.InfoTable;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -10,40 +11,52 @@ import java.util.Optional;
@Data @Data
@Service @Service
@Slf4j
public class InfoTableService { public class InfoTableService {
@Autowired @Autowired
private InfoTableRepository infoTableRepository; private InfoTableRepository infoTableRepository;
public Optional<InfoTable> getTable(final Long id) { public Optional<InfoTable> getTable(final Long id) {
log.debug("Start getTable method - CRUD");
return infoTableRepository.findById(id); return infoTableRepository.findById(id);
} }
public Iterable<InfoTable> getAllTables() { public Iterable<InfoTable> getAllTables() {
log.debug("Start getAllTables method - CRUD");
return infoTableRepository.findAll(); return infoTableRepository.findAll();
} }
public Iterable<InfoTable> getTablesBySchemaName(String schema) { public Iterable<InfoTable> getTablesBySchemaName(String schema) {
log.debug("Start getTableBySchemaName method - Custom");
return infoTableRepository.getTablesBySchemaName(schema); return infoTableRepository.getTablesBySchemaName(schema);
} }
public Iterable<InfoTable> getSchemaByTableName(String table) { public Iterable<InfoTable> getSchemaByTableName(String table) {
log.debug("Start getSchemaByTableName method - Custom");
return infoTableRepository.getSchemaByTableName(table); return infoTableRepository.getSchemaByTableName(table);
} }
public Iterable<String> getAllSchemas(){return infoTableRepository.getAllSchemas();} public Iterable<String> getAllSchemas(){
log.debug("Start getAllSchemas method - CRUD");
return infoTableRepository.getAllSchemas();
}
public void deleteTable(final Long id) { public void deleteTable(final Long id) {
log.debug("Start deleteTable method - CRUD");
infoTableRepository.deleteById(id); infoTableRepository.deleteById(id);
} }
public void deleteAllTable() { public void deleteAllTable() {
log.debug("Start deleteAllTable method - CRUD");
infoTableRepository.deleteAll(); infoTableRepository.deleteAll();
} }
public InfoTable addOrUpdateTable(InfoTable infoTable) { public InfoTable addOrUpdateTable(InfoTable infoTable) {
log.debug("Start deleteAllTable method - CRUD");
return infoTableRepository.save(infoTable); return infoTableRepository.save(infoTable);
} }
public void truncateMyTable(){ public void truncateMyTable(){
log.debug("Start truncateMyTable method - Custom");
infoTableRepository.truncateMyTable(); infoTableRepository.truncateMyTable();
} }

@ -3,6 +3,7 @@ package com.apside.assistDbBackend.service;
import com.apside.assistDbBackend.model.LinkInfo; import com.apside.assistDbBackend.model.LinkInfo;
import com.apside.assistDbBackend.repository.LinkInfoRepository; import com.apside.assistDbBackend.repository.LinkInfoRepository;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -10,32 +11,39 @@ import java.util.Optional;
@Data @Data
@Service @Service
@Slf4j
public class LinkInfoService { public class LinkInfoService {
@Autowired @Autowired
private LinkInfoRepository linkInfoRepository; private LinkInfoRepository linkInfoRepository;
public Optional<LinkInfo> getLinkInfo(final Long id) { public Optional<LinkInfo> getLinkInfo(final Long id) {
log.debug("Start getLinkInfo method - CRUD");
return linkInfoRepository.findById(id); return linkInfoRepository.findById(id);
} }
public Iterable<LinkInfo> getAllLinksInfos() { public Iterable<LinkInfo> getAllLinksInfos() {
log.debug("Start getAllLinksInfos method - CRUD");
return linkInfoRepository.findAll(); return linkInfoRepository.findAll();
} }
public void deleteLinkInfo(final Long id) { public void deleteLinkInfo(final Long id) {
log.debug("Start deleteLinkInfo method - CRUD");
linkInfoRepository.deleteById(id); linkInfoRepository.deleteById(id);
} }
public void deleteAllLinks() { public void deleteAllLinks() {
log.debug("Start deleteAllLinks method - CRUD");
linkInfoRepository.deleteAll(); linkInfoRepository.deleteAll();
} }
public LinkInfo addOrUpdateLink(LinkInfo linkInfo) { public LinkInfo addOrUpdateLink(LinkInfo linkInfo) {
log.debug("Start addOrUpdateLink method - CRUD");
return linkInfoRepository.save(linkInfo); return linkInfoRepository.save(linkInfo);
} }
public void truncateMyLink(){ public void truncateMyLink(){
log.debug("Start truncateMyLink method - Custom");
linkInfoRepository.truncateMyLink(); linkInfoRepository.truncateMyLink();
} }
} }

@ -4,6 +4,7 @@ import com.apside.assistDbBackend.model.LinkInfo;
import com.apside.assistDbBackend.model.InfoColumn; import com.apside.assistDbBackend.model.InfoColumn;
import com.apside.assistDbBackend.model.InfoTable; import com.apside.assistDbBackend.model.InfoTable;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -16,6 +17,7 @@ import java.nio.file.Paths;
@Data @Data
@Service @Service
@Slf4j
public class ResetDataService { public class ResetDataService {
@Autowired @Autowired
@ -46,6 +48,7 @@ public class ResetDataService {
} }
public void insertEverything() throws IOException { public void insertEverything() throws IOException {
log.debug("Start insert every data into DB");
JSONArray jo = new JSONArray(result); JSONArray jo = new JSONArray(result);
for (int i=0; i<jo.length(); i++){ for (int i=0; i<jo.length(); i++){
JSONObject schema = jo.getJSONObject(i); JSONObject schema = jo.getJSONObject(i);
@ -115,9 +118,11 @@ public class ResetDataService {
} }
} }
} }
log.info("Insert all data into DB - success");
} }
public void checkAndInsertLinks() throws IOException { public void checkAndInsertLinks() throws IOException {
log.debug("Start check data into DB and insert links between table and columns");
JSONArray jo = new JSONArray(result); JSONArray jo = new JSONArray(result);
for (int i=0; i<jo.length(); i++){ for (int i=0; i<jo.length(); i++){
JSONObject schema = jo.getJSONObject(i); JSONObject schema = jo.getJSONObject(i);
@ -175,6 +180,7 @@ public class ResetDataService {
} }
} }
} }
log.info("Check and insert links data into DB - success");
} }

@ -3,6 +3,9 @@ package com.apside.assistDbBackend.service;
import com.apside.assistDbBackend.model.LinkScriptTag; import com.apside.assistDbBackend.model.LinkScriptTag;
import com.apside.assistDbBackend.model.Script; import com.apside.assistDbBackend.model.Script;
import lombok.Data; import lombok.Data;
import lombok.extern.java.Log;
import lombok.extern.slf4j.Slf4j;
import org.apache.log4j.Logger;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -11,6 +14,7 @@ import org.springframework.stereotype.Service;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOError;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.file.Files; import java.nio.file.Files;
@ -20,6 +24,7 @@ import java.util.*;
@Data @Data
@Service @Service
@Slf4j
public class ScriptsService { public class ScriptsService {
@Autowired @Autowired
private GitService gitService; private GitService gitService;
@ -40,7 +45,7 @@ public class ScriptsService {
private static final String TAGS_STRING = "tags"; private static final String TAGS_STRING = "tags";
private static final String DATA_STRING = "data"; private static final String DATA_STRING = "data";
public ScriptsService() throws IOException { public ScriptsService() {
linkScriptTagPath = new File(System.getProperty(USER_DIR_STRING)).getParent() + "/AssistDB_AdditionalFiles/scripts.json"; linkScriptTagPath = new File(System.getProperty(USER_DIR_STRING)).getParent() + "/AssistDB_AdditionalFiles/scripts.json";
pathOfLink = Paths.get(linkScriptTagPath); pathOfLink = Paths.get(linkScriptTagPath);
tempDirectoryPath = new File(System.getProperty(USER_DIR_STRING)).getParent() + PATH_TO_SCRIPT_DIR; tempDirectoryPath = new File(System.getProperty(USER_DIR_STRING)).getParent() + PATH_TO_SCRIPT_DIR;
@ -54,6 +59,7 @@ public class ScriptsService {
} }
public List<Script> retrieveScripts() throws IOException, GitAPIException { public List<Script> retrieveScripts() throws IOException, GitAPIException {
log.debug("Start retrieve all scripts");
gitService.pullFromGit(); gitService.pullFromGit();
List<Script> listOfScripts = new ArrayList<>(); List<Script> listOfScripts = new ArrayList<>();
//Creating a File object for directory //Creating a File object for directory
@ -65,10 +71,12 @@ public class ScriptsService {
Script tempScript = new Script(extension, contents[i], allData); Script tempScript = new Script(extension, contents[i], allData);
listOfScripts.add(tempScript); listOfScripts.add(tempScript);
} }
log.info("Get all Scripts successful");
return listOfScripts; return listOfScripts;
} }
public List<LinkScriptTag> getAllScriptTag() throws IOException { public List<LinkScriptTag> getAllScriptTag() throws IOException {
log.debug("Start retrieve all links scripts/tags");
initialize(); initialize();
List<LinkScriptTag> listLinkScriptTag = new ArrayList<>(); List<LinkScriptTag> listLinkScriptTag = new ArrayList<>();
if (dataLinkScriptsTags.length()>0){ if (dataLinkScriptsTags.length()>0){
@ -88,40 +96,51 @@ public class ScriptsService {
listLinkScriptTag.add(newLinkScriptTag); listLinkScriptTag.add(newLinkScriptTag);
} }
} }
log.info("Get all links between Scripts and Tags successful");
return listLinkScriptTag; return listLinkScriptTag;
} }
public void deleteOneScript(final String name){ public void deleteOneScript(final String name){
log.debug("Start delete one script with Git");
try { try {
File scriptDirectory = new File(tempDirectoryPath + "/" + name); File scriptDirectory = new File(tempDirectoryPath + "/" + name);
scriptDirectory.delete(); scriptDirectory.delete();
gitService.pushToGit(); gitService.pushToGit();
gitService.pullFromGit(); gitService.pullFromGit();
log.info("Delete one Script successful");
} catch (Exception e){ } catch (Exception e){
log.error("Error : ", e);
e.printStackTrace(); e.printStackTrace();
} }
} }
public void simpleDeleteScript(final String name){ public void simpleDeleteScript(final String name){
log.debug("Start delete one script without Git");
try { try {
File scriptDirectory = new File(tempDirectoryPath + "/" + name); File scriptDirectory = new File(tempDirectoryPath + "/" + name);
scriptDirectory.delete(); scriptDirectory.delete();
log.info("Delete one Script successful");
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
log.error("Error : ", e);
} }
} }
public void addOneScript(final String content, final String name) throws IOException { public void addOneScript(final String content, final String name) throws IOException {
log.debug("Start add one scripts");
File newFile = new File(tempDirectoryPath + "/" + name); File newFile = new File(tempDirectoryPath + "/" + name);
newFile.createNewFile(); newFile.createNewFile();
try (FileWriter writerDataFile = new FileWriter(tempDirectoryPath + "/" + name);) { try (FileWriter writerDataFile = new FileWriter(tempDirectoryPath + "/" + name);) {
writerDataFile.write(content); writerDataFile.write(content);
log.info("Add one Script successful");
} catch (IOException ioException){
log.error("Error add one Script : ", ioException);
throw ioException;
} }
} }
public void addOneLink(final String name, final String description, final List<String> tagList, final int linkId) throws IOException, GitAPIException, URISyntaxException { public void addOneLink(final String name, final String description, final List<String> tagList, final int linkId) throws IOException, GitAPIException, URISyntaxException {
log.debug("Start add one link between script and tags");
initialize(); initialize();
gitService.pullFromGit(); gitService.pullFromGit();
JSONObject newLink = new JSONObject(); JSONObject newLink = new JSONObject();
@ -139,9 +158,11 @@ public class ScriptsService {
JSONObject newObj = dataGlobalScripts.put(DATA_STRING, newArr); JSONObject newObj = dataGlobalScripts.put(DATA_STRING, newArr);
Files.write(pathOfLink, newObj.toString().getBytes()); Files.write(pathOfLink, newObj.toString().getBytes());
gitService.pushToGit(); gitService.pushToGit();
log.info("Add one link successful");
} }
public void updateOneLink(final String name, final String description, final List<String> tagList, final int linkId) throws IOException, GitAPIException, URISyntaxException { public void updateOneLink(final String name, final String description, final List<String> tagList, final int linkId) throws IOException, GitAPIException, URISyntaxException {
log.debug("Start update one link between script and tags");
initialize(); initialize();
gitService.pullFromGit(); gitService.pullFromGit();
JSONArray newArr = new JSONArray(); JSONArray newArr = new JSONArray();
@ -169,6 +190,7 @@ public class ScriptsService {
Files.write(pathOfLink, newObj.toString().getBytes()); Files.write(pathOfLink, newObj.toString().getBytes());
gitService.pushToGit(); gitService.pushToGit();
log.info("Update one link successful");
} }
} }

@ -2,6 +2,7 @@ package com.apside.assistDbBackend.service;
import com.apside.assistDbBackend.model.Tag; import com.apside.assistDbBackend.model.Tag;
import lombok.Data; import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.GitAPIException;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -19,6 +20,7 @@ import java.util.Objects;
@Data @Data
@Service @Service
@Slf4j
public class TagsService { public class TagsService {
@Autowired @Autowired
private GitService gitService; private GitService gitService;
@ -31,7 +33,7 @@ public class TagsService {
private static final String DATA_STRING = "data"; private static final String DATA_STRING = "data";
private static final String TAG_STRING = "tag"; private static final String TAG_STRING = "tag";
private static final String DESCRIPTION_STRING = "description"; private static final String DESCRIPTION_STRING = "description";
public TagsService() throws IOException { public TagsService() {
tempDirectoryPath = new File(System.getProperty("user.dir")).getParent() + "/AssistDB_AdditionalFiles/tags.json"; tempDirectoryPath = new File(System.getProperty("user.dir")).getParent() + "/AssistDB_AdditionalFiles/tags.json";
path = Paths.get(tempDirectoryPath); path = Paths.get(tempDirectoryPath);
} }
@ -43,6 +45,7 @@ public class TagsService {
} }
public List<Tag> getAllTags() throws IOException, GitAPIException { public List<Tag> getAllTags() throws IOException, GitAPIException {
log.debug("Start get all tags from json");
gitService.pullFromGit(); gitService.pullFromGit();
initialize(); initialize();
List<Tag> listOfTag = new ArrayList<>(); List<Tag> listOfTag = new ArrayList<>();
@ -54,10 +57,12 @@ public class TagsService {
Tag tempTag = new Tag(tagId, tagName, tagDescription); Tag tempTag = new Tag(tagId, tagName, tagDescription);
listOfTag.add(tempTag); listOfTag.add(tempTag);
} }
log.info("Get all tags from json successful");
return listOfTag; return listOfTag;
} }
public void deleteTag(final String deleteNameTag) throws IOException, GitAPIException, URISyntaxException { public void deleteTag(final String deleteNameTag) throws IOException, GitAPIException, URISyntaxException {
log.debug("Start delete one tag in json");
initialize(); initialize();
JSONArray newArr = new JSONArray(); JSONArray newArr = new JSONArray();
for (int i=0; i<data.length(); i++) { for (int i=0; i<data.length(); i++) {
@ -71,9 +76,11 @@ public class TagsService {
Files.write(path, newObj.toString().getBytes()); Files.write(path, newObj.toString().getBytes());
gitService.pushToGit(); gitService.pushToGit();
gitService.pullFromGit(); gitService.pullFromGit();
log.info("Delete one tag in json file successful");
} }
public void addTag(Tag tag) throws IOException, GitAPIException, URISyntaxException { public void addTag(Tag tag) throws IOException, GitAPIException, URISyntaxException {
log.debug("Start add one tag in json");
initialize(); initialize();
gitService.pullFromGit(); gitService.pullFromGit();
JSONObject newTag = new JSONObject(); JSONObject newTag = new JSONObject();
@ -85,8 +92,10 @@ public class TagsService {
Files.write(path, newObj.toString().getBytes()); Files.write(path, newObj.toString().getBytes());
gitService.pushToGit(); gitService.pushToGit();
gitService.pullFromGit(); gitService.pullFromGit();
log.info("Delete one tag in json successful");
} }
public void updateTag(final String prevTag, Tag modTag) throws IOException, GitAPIException, URISyntaxException { public void updateTag(final String prevTag, Tag modTag) throws IOException, GitAPIException, URISyntaxException {
log.debug("Start update one tag in json");
initialize(); initialize();
gitService.pullFromGit(); gitService.pullFromGit();
JSONArray newArr = new JSONArray(); JSONArray newArr = new JSONArray();
@ -107,6 +116,7 @@ public class TagsService {
Files.write(path, newObj.toString().getBytes()); Files.write(path, newObj.toString().getBytes());
gitService.pushToGit(); gitService.pushToGit();
gitService.pullFromGit(); gitService.pullFromGit();
log.info("Update one tag in json successful");
} }
} }

@ -6,7 +6,7 @@ spring.datasource.password=Pompom.21
server.port=9001 server.port=9001
USERNAME_GIT = fhibert@apside.fr USERNAME_GIT = fhibert@apside.fr
ACCESS_TOKEN_GIT = e54612b6d1d73eef4f0a49c88b0e35ccf02d45eb ACCESS_TOKEN_GIT = accesstokenexemple
logging.level.org.springframework.boot.web.embedded.tomcat=INFO logging.level.org.springframework.boot.web.embedded.tomcat=INFO
logging.level.org.springframework=error logging.level.org.springframework=error

@ -0,0 +1,15 @@
# Log4J configuration
log4j.rootLogger=DEBUG,CONSOLE,FILE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[%d] %t %c %L %-5p - %m%n
log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.FILE.File=/apps/logs/appname.log
log4j.appender.FILE.DatePattern='.'yyyy-MM-dd
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=[%d] %t %c %L %-5p - %m%n
log4j.logger.org.springframework=WARN
Loading…
Cancel
Save