Piccole migliorie
This commit is contained in:
@@ -106,7 +106,7 @@ public class EntityLoggerComponent {
|
||||
|
||||
}
|
||||
|
||||
if (!Stream.of(settingsModel.getAvailableConnections()).anyMatch(x -> x.getDbName().equalsIgnoreCase(destDBName))) {
|
||||
if (settingsModel.getAvailableConnections().stream().noneMatch(x -> x.getDbName().equalsIgnoreCase(destDBName))) {
|
||||
settingsModel.addAvailableConnection(new AvailableConnectionsModel()
|
||||
.setInternalDb(false)
|
||||
.setHost(dbHost)
|
||||
|
||||
@@ -3,7 +3,6 @@ package it.integry.ems.license;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.ems.datasource.DataSource;
|
||||
import it.integry.ems.json.ResponseJSONObjectMapper;
|
||||
import it.integry.ems.looper.service.LooperService;
|
||||
import it.integry.ems.response.EsitoType;
|
||||
@@ -11,7 +10,7 @@ import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.service.HttpRestWrapper;
|
||||
import it.integry.ems.settings.Model.AvailableConnectionsModel;
|
||||
import it.integry.ems.settings.Model.SettingsModel;
|
||||
import it.integry.ems.sync.MultiDBTransaction.Connection;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
@@ -62,15 +61,13 @@ public class LicenseComponent {
|
||||
final HashMap<String, String> listAziende = new HashMap<>();
|
||||
|
||||
for (AvailableConnectionsModel model : settingsModel.getAvailableConnections(true)) {
|
||||
DataSource ds = new DataSource();
|
||||
ds.initialize(model.getProfileName());
|
||||
Connection conn = ds.getConnection();
|
||||
try (MultiDBTransactionManager multiDBTransactionManager = new MultiDBTransactionManager(model)) {
|
||||
String sql = "SELECT part_iva FROM azienda WHERE part_iva is not null";
|
||||
String partIva = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
|
||||
String sql = "SELECT part_iva FROM azienda WHERE part_iva is not null";
|
||||
String partIva = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
|
||||
if (!UtilityString.isNullOrEmpty(partIva)) listAziende.put(model.getProfileName(), partIva);
|
||||
|
||||
ds.forceClose();
|
||||
if (!UtilityString.isNullOrEmpty(partIva))
|
||||
listAziende.put(model.getProfileName(), partIva);
|
||||
}
|
||||
}
|
||||
|
||||
String jsonBody = jsonObjectMapper.writeValueAsString(listAziende.values());
|
||||
|
||||
@@ -825,7 +825,7 @@ public class EmsServices {
|
||||
if (UtilityDebug.isDebugExecution() || UtilityDebug.isIntegryServer())
|
||||
throw new Exception("Cannot export server info in DEBUG mode");
|
||||
|
||||
List<AvailableConnectionsModel> availableConnectionList = settingsModel.getAvailableConnections();
|
||||
List<AvailableConnectionsModel> availableConnectionList = settingsModel.getAvailableConnections(true);
|
||||
|
||||
for (AvailableConnectionsModel model : availableConnectionList) {
|
||||
try {
|
||||
|
||||
@@ -199,7 +199,7 @@ public class EntityProcessor {
|
||||
|
||||
String jsonBody = gson.toJson(arguments);
|
||||
StringBuilder srb = new StringBuilder();
|
||||
int requestStatusCode = HttpRestWrapper.callGeneric(url, null, null, jsonBody, ContentType.APPLICATION_JSON, srb, null,0);
|
||||
int requestStatusCode = HttpRestWrapper.callGeneric(url, null, null, jsonBody, ContentType.APPLICATION_JSON, srb, null, 0);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
|
||||
@@ -263,13 +263,11 @@ public class EntityProcessor {
|
||||
logger.info("SINCRONIZZAZIONE su entity " + entity.getTableName() + " ONLINE: " + isSyncActive);
|
||||
|
||||
if (!isCurrentlyOnDistributore) {
|
||||
//ConnectionCacheHolder.releaseProfile(primaryProfileDB);
|
||||
currentDs = new DataSource();
|
||||
currentDs.initialize(profileDbDistributore);
|
||||
logger.debug("INIT CONN MASTER (" + profileDbDistributore + ")");
|
||||
if (!multiDBTransactionManager.containsDB(profileDbDistributore)) {
|
||||
multiDBTransactionManager.addConnection(profileDbDistributore, currentDs, true);
|
||||
multiDBTransactionManager.addConnection(profileDbDistributore, true);
|
||||
}
|
||||
|
||||
currentDs = multiDBTransactionManager.getDatabaseDataSource(profileDbDistributore).getDataSource();
|
||||
}
|
||||
|
||||
StbSubscription syncDetail = syncDetails.stream()
|
||||
@@ -329,13 +327,8 @@ public class EntityProcessor {
|
||||
|
||||
|
||||
//Se non c'è stata alcuna eccezione allora salvo il LLLLOOOOOGGG
|
||||
if (entity.getException() == null) {
|
||||
// entityLoggerService.log(multiDBTransactionManager.getDistributoreDatasource(), entity);
|
||||
|
||||
if (!UtilityString.isNullOrEmpty(currentDs.getProfile()))
|
||||
entityLoggerNewService.log(currentDs.getProfile(), currentDs.getDbName(), requestDataDTO.getUsername(), entity);
|
||||
}
|
||||
|
||||
if (entity.getException() == null && !UtilityString.isNullOrEmpty(currentDs.getProfile()))
|
||||
entityLoggerNewService.log(currentDs.getProfile(), currentDs.getDbName(), requestDataDTO.getUsername(), entity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package it.integry.ems.settings.Model;
|
||||
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import it.integry.ems.expansion.ObservableArrayList;
|
||||
import it.integry.ems.expansion.ObservableField;
|
||||
@@ -11,6 +9,7 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@@ -159,7 +158,7 @@ public class SettingsModel implements InitializingBean {
|
||||
return null;
|
||||
|
||||
|
||||
Optional<AvailableConnectionsModel> optConn = Stream.of(this.getAvailableConnections())
|
||||
Optional<AvailableConnectionsModel> optConn = this.getAvailableConnections().stream()
|
||||
.filter(x -> x.getProfileName().equalsIgnoreCase(this.getDefaultProfile()))
|
||||
.findFirst();
|
||||
|
||||
@@ -167,7 +166,7 @@ public class SettingsModel implements InitializingBean {
|
||||
}
|
||||
|
||||
public String getProfileDbFromDbName(String dbName) {
|
||||
String profileDb = Stream.of(this.getAvailableConnections())
|
||||
String profileDb = this.getAvailableConnections().stream()
|
||||
.filter(x -> x.getDbName().equalsIgnoreCase(dbName))
|
||||
.map(AvailableConnectionsModel::getProfileName)
|
||||
.findFirst()
|
||||
@@ -177,7 +176,7 @@ public class SettingsModel implements InitializingBean {
|
||||
}
|
||||
|
||||
public String getDbNameFromProfileDb(String profileDb) {
|
||||
String dbName = Stream.of(this.getAvailableConnections())
|
||||
String dbName = this.getAvailableConnections().stream()
|
||||
.filter(x -> x.getProfileName().equalsIgnoreCase(profileDb))
|
||||
.map(AvailableConnectionsModel::getDbName)
|
||||
.findFirst()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package it.integry.ems.settings;
|
||||
|
||||
import com.annimon.stream.Optional;
|
||||
import com.annimon.stream.Stream;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import it.integry.ems.expansion.ObservableArrayList;
|
||||
@@ -26,6 +24,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
@@ -88,7 +87,7 @@ public class SettingsController implements IFileWatcherEvents {
|
||||
String profileDbToSave = settingsConverter.getConvertedDefaultDB();
|
||||
if (settingsModel.getAvailableConnections() != null) {
|
||||
String finalProfileDbToSave = profileDbToSave;
|
||||
Optional<AvailableConnectionsModel> defaultConnection = Stream.of(settingsModel.getAvailableConnections())
|
||||
Optional<AvailableConnectionsModel> defaultConnection = settingsModel.getAvailableConnections().stream()
|
||||
.filter(x -> x.getDbName().equalsIgnoreCase(finalProfileDbToSave) || x.getProfileName().equalsIgnoreCase(finalProfileDbToSave))
|
||||
.findFirst();
|
||||
|
||||
@@ -143,7 +142,7 @@ public class SettingsController implements IFileWatcherEvents {
|
||||
String profileDbToSave = settingsConverter.getConvertedDefaultDB();
|
||||
if (settingsModel.getAvailableConnections() != null) {
|
||||
String finalProfileDbToSave = profileDbToSave;
|
||||
Optional<AvailableConnectionsModel> defaultConnection = Stream.of(settingsModel.getAvailableConnections())
|
||||
Optional<AvailableConnectionsModel> defaultConnection = settingsModel.getAvailableConnections().stream()
|
||||
.filter(x -> x.getDbName().equalsIgnoreCase(finalProfileDbToSave) || x.getProfileName().equalsIgnoreCase(finalProfileDbToSave))
|
||||
.findFirst();
|
||||
|
||||
@@ -283,7 +282,7 @@ public class SettingsController implements IFileWatcherEvents {
|
||||
}
|
||||
|
||||
|
||||
public AvailableConnectionsModel getHistoryDbConnectionModel() throws Exception {
|
||||
public AvailableConnectionsModel getHistoryDbConnectionModel() {
|
||||
AvailableConnectionsModel connectionsModel = settingsModel.getDefaultConnectionModel();
|
||||
|
||||
if (connectionsModel == null) {
|
||||
@@ -292,12 +291,11 @@ public class SettingsController implements IFileWatcherEvents {
|
||||
|
||||
String profileName = connectionsModel.getDbName() + "_history";
|
||||
|
||||
Optional<AvailableConnectionsModel> opt = Stream.of(settingsModel.getAvailableConnections())
|
||||
Optional<AvailableConnectionsModel> opt = settingsModel.getAvailableConnections().stream()
|
||||
.filter(x -> x.getProfileName().equalsIgnoreCase(profileName))
|
||||
.findFirst();
|
||||
|
||||
if (opt.isPresent()) return opt.get();
|
||||
return null;
|
||||
return opt.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user