Rinominata classe StbDevice in StbDevices
This commit is contained in:
@@ -4,26 +4,17 @@ package it.integry.ems.devices;
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.UserSession;
|
||||
import it.integry.ems_model.config.EmsRestConstants;
|
||||
import it.integry.ems_model.entity.StbDevice;
|
||||
import it.integry.ems_model.entity.StbDevices;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.Query;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityDate;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.naming.Context;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.sql.Connection;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -57,14 +48,14 @@ public class DevicesService {
|
||||
UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), selectSql);
|
||||
|
||||
if(!exists) {
|
||||
StbDevice stbDevice = new StbDevice()
|
||||
StbDevices stbDevices = new StbDevices()
|
||||
.setName(appName)
|
||||
.setIdentificationId(deviceId)
|
||||
.setCreatedAt(new Date())
|
||||
.setLastUse(new Date());
|
||||
|
||||
stbDevice.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
entityProcessor.processEntity(stbDevice, multiDBTransactionManager);
|
||||
stbDevices.setOperation(OperationType.INSERT_OR_UPDATE);
|
||||
entityProcessor.processEntity(stbDevices, multiDBTransactionManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class ForeignKeyDTO {
|
||||
put(MtbDepo.ENTITY, "Codice deposito inesistente");
|
||||
put(CtbIreg.ENTITY, "Codice registro documenti inesistente");
|
||||
put(WtbJrept.ENTITY, "Report inesistente");
|
||||
put(StbDevice.ENTITY, "Dispositivo inesistente");
|
||||
put(StbDevices.ENTITY, "Dispositivo inesistente");
|
||||
put(StbPublications.ENTITY, "Pubblicazione inesistente");
|
||||
}};
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class StbAuthToken extends EntityBase {
|
||||
private LocalDateTime expiryDate;
|
||||
|
||||
@SqlField(value = "device_id", nullable = false)
|
||||
@FK(tableName = StbDevice.ENTITY, columnName = "id")
|
||||
@FK(tableName = StbDevices.ENTITY, columnName = "id")
|
||||
private Long deviceId;
|
||||
|
||||
@SqlField(value = "user_name", nullable = false, maxLength = 40)
|
||||
|
||||
@@ -8,9 +8,9 @@ import java.util.Date;
|
||||
|
||||
@Master
|
||||
@PropertyReactive
|
||||
@Table(StbDevice.ENTITY)
|
||||
@JsonTypeName(StbDevice.ENTITY)
|
||||
public class StbDevice extends EntityBase {
|
||||
@Table(StbDevices.ENTITY)
|
||||
@JsonTypeName(StbDevices.ENTITY)
|
||||
public class StbDevices extends EntityBase {
|
||||
|
||||
public static final String ENTITY = "stb_devices";
|
||||
|
||||
@@ -35,7 +35,7 @@ public class StbDevice extends EntityBase {
|
||||
return id;
|
||||
}
|
||||
|
||||
public StbDevice setId(Long id) {
|
||||
public StbDevices setId(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class StbDevice extends EntityBase {
|
||||
return name;
|
||||
}
|
||||
|
||||
public StbDevice setName(String name) {
|
||||
public StbDevices setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class StbDevice extends EntityBase {
|
||||
return identificationId;
|
||||
}
|
||||
|
||||
public StbDevice setIdentificationId(String identificationId) {
|
||||
public StbDevices setIdentificationId(String identificationId) {
|
||||
this.identificationId = identificationId;
|
||||
return this;
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class StbDevice extends EntityBase {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public StbDevice setCreatedAt(Date createdAt) {
|
||||
public StbDevices setCreatedAt(Date createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
return this;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class StbDevice extends EntityBase {
|
||||
return lastUse;
|
||||
}
|
||||
|
||||
public StbDevice setLastUse(Date lastUse) {
|
||||
public StbDevices setLastUse(Date lastUse) {
|
||||
this.lastUse = lastUse;
|
||||
return this;
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.user.UserCacheService;
|
||||
import it.integry.ems.user.dto.UserDTO;
|
||||
import it.integry.ems_model.entity.StbAuthToken;
|
||||
import it.integry.ems_model.entity.StbDevice;
|
||||
import it.integry.ems_model.entity.StbDevices;
|
||||
import it.integry.ems_model.entity.StbUser;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
@@ -142,14 +142,14 @@ public class AuthService {
|
||||
}
|
||||
|
||||
if (multiDBTransactionManager != null) {
|
||||
StbDevice stbDevice = deviceService.createIfNotExist(requestDataDTO.getApplication().toString(), deviceId);
|
||||
StbDevices stbDevices = deviceService.createIfNotExist(requestDataDTO.getApplication().toString(), deviceId);
|
||||
|
||||
// Ottengo access_token se token già creato per device id
|
||||
String sql = String.format(
|
||||
"SELECT access_token FROM %s WHERE user_name = %s AND device_id = %d",
|
||||
StbAuthToken.ENTITY,
|
||||
UtilityDB.valueToString(userData.getUser().getUserName()),
|
||||
stbDevice.getId()
|
||||
stbDevices.getId()
|
||||
);
|
||||
|
||||
String oldAccessToken = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(multiDBTransactionManager.getPrimaryConnection(), sql);
|
||||
@@ -166,7 +166,7 @@ public class AuthService {
|
||||
password,
|
||||
String.valueOf(userData.getUser().getKeyGroup()),
|
||||
primaryProfileDb,
|
||||
stbDevice.getId()
|
||||
stbDevices.getId()
|
||||
);
|
||||
|
||||
applicationEventPublisher.publishEvent(new TokenCreateEvent(primaryProfileDb, stbAuthToken));
|
||||
|
||||
@@ -2,7 +2,7 @@ package it.integry.security.service;
|
||||
|
||||
import it.integry.ems.service.EntityProcessor;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems_model.entity.StbDevice;
|
||||
import it.integry.ems_model.entity.StbDevices;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,29 +20,29 @@ public class DeviceService {
|
||||
@Autowired
|
||||
private EntityProcessor entityProcessor;
|
||||
|
||||
public StbDevice createIfNotExist(String name, String deviceIdentifier) throws Exception {
|
||||
public StbDevices createIfNotExist(String name, String deviceIdentifier) throws Exception {
|
||||
String sql = "SELECT * " +
|
||||
"FROM " + StbDevice.ENTITY + " " +
|
||||
"FROM " + StbDevices.ENTITY + " " +
|
||||
"WHERE identification_id = " + UtilityDB.valueToString(deviceIdentifier);
|
||||
|
||||
StbDevice stbDevice = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbDevice.class);
|
||||
StbDevices stbDevices = UtilityDB.executeSimpleQueryOnlyFirstRowDTO(multiDBTransactionManager.getPrimaryConnection(), sql, StbDevices.class);
|
||||
|
||||
if (stbDevice == null) {
|
||||
stbDevice = new StbDevice()
|
||||
if (stbDevices == null) {
|
||||
stbDevices = new StbDevices()
|
||||
.setIdentificationId(deviceIdentifier)
|
||||
.setCreatedAt(new Date());
|
||||
stbDevice.setOperation(OperationType.INSERT);
|
||||
stbDevices.setOperation(OperationType.INSERT);
|
||||
} else {
|
||||
stbDevice.setOperation(OperationType.UPDATE);
|
||||
stbDevices.setOperation(OperationType.UPDATE);
|
||||
}
|
||||
|
||||
stbDevice.setName(name)
|
||||
stbDevices.setName(name)
|
||||
.setLastUse(new Date());
|
||||
|
||||
|
||||
entityProcessor.processEntity(stbDevice, multiDBTransactionManager);
|
||||
entityProcessor.processEntity(stbDevices, multiDBTransactionManager);
|
||||
|
||||
return stbDevice;
|
||||
return stbDevices;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user