Creato un servizio per la creazione degli indici
This commit is contained in:
@@ -36,6 +36,17 @@ public class UtilityDB {
|
||||
}
|
||||
|
||||
public static void createIndex(Connection conn, IndexTableDTO indexTableDTO) throws Exception {
|
||||
/*Esempio di chiamata:
|
||||
List<IndexTableDTO.ColumnIndex> columnsIndex = new ArrayList<>();
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex("data_ord"));
|
||||
columnsIndex.add(new IndexTableDTO.ColumnIndex("data_ord"));
|
||||
IndexTableDTO indexTableDTO = new IndexTableDTO()
|
||||
.setTableName("dtb_ordt")
|
||||
.setIndexName("ix_dtb_ordr_id_contratto")
|
||||
.setColumnsIndex(columnsIndex)
|
||||
.setOverride(true)
|
||||
.setColumnsInclude("ciao", "prova", "sole");
|
||||
UtilityDB.createIndex(multiDBTransactionManager.getPrimaryConnection(),indexTableDTO );*/
|
||||
if (UtilityString.isNullOrEmpty(indexTableDTO.getTableName()))
|
||||
throw new Exception("Nome tabella non trovato");
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@ package it.integry.ems_model.utility.dto;
|
||||
import com.annimon.stream.Stream;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class IndexTableDTO {
|
||||
private String tableName;
|
||||
private String indexName;
|
||||
|
||||
private boolean cluster;
|
||||
private boolean unique;
|
||||
private boolean override;
|
||||
private List<String> columnsInclude;
|
||||
private List<columnIndex> columnsIndex;
|
||||
private List<ColumnIndex> columnsIndex;
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
@@ -75,6 +75,15 @@ public class IndexTableDTO {
|
||||
this.columnsInclude = columnsInclude;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IndexTableDTO setColumnsInclude(String... columnInclude ) {
|
||||
if (this.columnsInclude == null)
|
||||
this.columnsInclude = new ArrayList<>();
|
||||
for(String c:columnInclude){
|
||||
this.columnsInclude.add(c);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public String getColumnsIndexString() {
|
||||
if (columnsIndex == null || columnsIndex.size() == 0)
|
||||
return "";
|
||||
@@ -87,24 +96,36 @@ public class IndexTableDTO {
|
||||
|
||||
return columnsIndexString;
|
||||
}
|
||||
public List<columnIndex> getColumnsIndex() {
|
||||
public List<ColumnIndex> getColumnsIndex() {
|
||||
return columnsIndex;
|
||||
}
|
||||
|
||||
public IndexTableDTO setColumnsIndex(List<columnIndex> columnsIndex) {
|
||||
public IndexTableDTO setColumnsIndex(List<ColumnIndex> columnsIndex) {
|
||||
this.columnsIndex = columnsIndex;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class columnIndex {
|
||||
public static class ColumnIndex {
|
||||
private String columnName;
|
||||
private String sort;
|
||||
|
||||
public ColumnIndex(String columnName, String sort) {
|
||||
this.columnName = columnName;
|
||||
this.sort = sort;
|
||||
}
|
||||
public ColumnIndex(String columnName) {
|
||||
this.columnName = columnName;
|
||||
this.sort = "ASC";
|
||||
}
|
||||
|
||||
public ColumnIndex() {
|
||||
}
|
||||
|
||||
public String getColumnName() {
|
||||
return columnName;
|
||||
}
|
||||
|
||||
public columnIndex setColumnName(String columnName) {
|
||||
public ColumnIndex setColumnName(String columnName) {
|
||||
this.columnName = columnName;
|
||||
return this;
|
||||
}
|
||||
@@ -113,7 +134,7 @@ public class IndexTableDTO {
|
||||
return sort==null?"ASC":sort;
|
||||
}
|
||||
|
||||
public columnIndex setSort(String sort) {
|
||||
public ColumnIndex setSort(String sort) {
|
||||
this.sort = sort;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import javax.xml.validation.Validator;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@@ -173,40 +174,6 @@ public class UtilityController {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "provaMina", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse provaMina() throws Exception {
|
||||
ServiceRestResponse response = new ServiceRestResponse();
|
||||
List<IndexTableDTO.columnIndex> columnsIndex = new ArrayList<>();
|
||||
IndexTableDTO.columnIndex columnIndex =
|
||||
new IndexTableDTO.columnIndex()
|
||||
.setColumnName("data_ord");
|
||||
columnsIndex.add(columnIndex);
|
||||
columnIndex =
|
||||
new IndexTableDTO.columnIndex()
|
||||
.setColumnName("num_ord");
|
||||
columnsIndex.add(columnIndex);
|
||||
|
||||
List<String> columnsInclude = new ArrayList<>();
|
||||
columnsInclude.add("gestione");
|
||||
columnsInclude.add("cod_anag");
|
||||
IndexTableDTO indexTableDTO = new IndexTableDTO()
|
||||
.setTableName("dtb_ordt")
|
||||
.setIndexName("ix_dtb_ordr_id_contratto")
|
||||
.setColumnsIndex(columnsIndex)
|
||||
.setOverride(true)
|
||||
.setColumnsInclude(columnsInclude);
|
||||
UtilityDB.createIndex(multiDBTransactionManager.getPrimaryConnection(),indexTableDTO );
|
||||
try {
|
||||
response.setEsito(EsitoType.OK);
|
||||
} catch (Exception e) {
|
||||
response.setEsito(EsitoType.KO);
|
||||
response.setErrorMessage(e.getMessage());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@RequestMapping(value = EmsRestConstants.PATH_READ_REMOTE_FILE, method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse readRemoteFile(@RequestBody JsonNode body) {
|
||||
|
||||
Reference in New Issue
Block a user