Implementato servizio di generazione del JSON del menù
This commit is contained in:
@@ -5,6 +5,7 @@ import it.integry.ems.devices.DevicesService;
|
||||
import it.integry.ems.devices.dto.RegisterDeviceRequestDTO;
|
||||
import it.integry.ems.entity_development.dto.CreateEntityItemRequestDTO;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -24,6 +25,11 @@ public class EntityDevelopmentController {
|
||||
@RequestMapping(value = "create", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse create(@RequestBody CreateEntityItemRequestDTO[] createEntityItemRequestList) throws Exception {
|
||||
if (!UtilityDebug.isDebugExecution())
|
||||
throw new Exception("Puoi eseguire questa procedura solo in ambiente DEBUG!");
|
||||
|
||||
if (UtilityDebug.isIntegryServerDev())
|
||||
throw new Exception("Non puoi eseguire questa azione su SERVERDEV!");
|
||||
|
||||
entityDevelopmentService.create(createEntityItemRequestList);
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
|
||||
@@ -16,6 +16,7 @@ import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTable;
|
||||
import it.integry.ems.entity_logger.db_schema_manager.dto.DatabaseTableColumn;
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDirs;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
@@ -59,10 +60,7 @@ public class EntityDevelopmentService {
|
||||
masterDetailClassesDeclaration.add(new AbstractMap.SimpleEntry<>(createEntityItemRequestDTO.isMaster(), javaClassDeclaration));
|
||||
}
|
||||
|
||||
|
||||
String executionPath = new File(BaseMigration.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
|
||||
final String baseProjectPath = executionPath.substring(0, executionPath.indexOf("ems-engine\\target")) + "ems-core\\src\\main\\";
|
||||
final String entitiesJavaPath = baseProjectPath + "java\\it\\integry\\ems_model\\entity\\";
|
||||
final String entitiesJavaPath = UtilityDirs.getDevelopmentJavaBaseFolder() + "it\\integry\\ems_model\\entity\\";
|
||||
|
||||
for (AbstractMap.SimpleEntry<Boolean, CompilationUnit> booleanClassOrInterfaceDeclarationSimpleEntry : masterDetailClassesDeclaration) {
|
||||
final TypeDeclaration<?> classDeclaration = booleanClassOrInterfaceDeclarationSimpleEntry.getValue().getType(0);
|
||||
|
||||
@@ -6,6 +6,7 @@ import it.integry.ems.menu.dto.MenuConfigDTO;
|
||||
import it.integry.ems.menu.dto.StbMenuDTO;
|
||||
import it.integry.ems.menu.dto.StbMenuOpzDTO;
|
||||
import it.integry.ems.menu.dto.StbTipoAziendaDTO;
|
||||
import it.integry.ems.utility.UtilityDirs;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
|
||||
@@ -31,9 +32,11 @@ public class MenuStaticCreator {
|
||||
connection.setTransactionIsolation(java.sql.Connection.TRANSACTION_READ_UNCOMMITTED);
|
||||
connection.setAutoCommit(false);
|
||||
|
||||
final String baseProjectPath = new File("").getAbsolutePath() + "\\ems-core\\src\\main\\";
|
||||
final String menuJsonResourceFolder = baseProjectPath + "resources\\menus\\";
|
||||
createMenu(connection, UtilityDirs.getDevelopmentMenusFolder());
|
||||
}
|
||||
|
||||
|
||||
public static void createMenu(Connection connection, String menuJsonResourceFolder) throws Exception {
|
||||
ObjectMapper jsonObjectMapper = new ObjectMapper();
|
||||
|
||||
final List<StbMenuOpzDTO> stbMenuOpzs = UtilityDB.executeSimpleQueryDTO(connection, "SELECT * FROM stb_menu_opz", StbMenuOpzDTO.class);
|
||||
@@ -43,7 +46,6 @@ public class MenuStaticCreator {
|
||||
final List<StbMenuDTO> stbMenus = UtilityDB.executeSimpleQueryDTO(connection, "SELECT * FROM stb_menu", StbMenuDTO.class);
|
||||
final Map<String, List<StbMenuDTO>> menusByAzienda = stbMenus.stream().collect(Collectors.groupingBy(StbMenuDTO::getTipoAzienda));
|
||||
|
||||
|
||||
MenuConfigDTO menuConfigDTO = new MenuConfigDTO(Integer.parseInt(CommonConstants.DATESTAMP_FORMATTER.format(UtilityLocalDate.getNow())))
|
||||
.setStbMenuOpz(stbMenuOpzs)
|
||||
.setStbTipoAzienda(stbTipoAziendas)
|
||||
@@ -55,7 +57,6 @@ public class MenuStaticCreator {
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void writeContentToFile(String filePath, String content, boolean overwrite) throws IOException {
|
||||
File f = new File(filePath);
|
||||
if (overwrite && f.exists()) f.delete();
|
||||
|
||||
@@ -4,6 +4,7 @@ import it.integry.common.var.CommonConstants;
|
||||
import it.integry.ems.menu.service.MenuConfigurationService;
|
||||
import it.integry.ems.response.ServiceRestResponse;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -30,4 +31,17 @@ public class MenuConfigurationController {
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "generate", method = RequestMethod.POST)
|
||||
public @ResponseBody
|
||||
ServiceRestResponse generate() throws Exception {
|
||||
if (!UtilityDebug.isDebugExecution())
|
||||
throw new Exception("Puoi eseguire questa procedura solo in ambiente DEBUG!");
|
||||
|
||||
if (UtilityDebug.isIntegryServerDev())
|
||||
throw new Exception("Non puoi eseguire questa azione su SERVERDEV!");
|
||||
|
||||
menuConfigurationService.generate();
|
||||
return ServiceRestResponse.createPositiveResponse();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,36 +23,8 @@ public class StbMenuDTO {
|
||||
@SqlField(value = "descrizione_estesa", maxLength = 8000, nullable = true)
|
||||
private String descrizioneEstesa;
|
||||
|
||||
@SqlField(value = "entity_name", maxLength = 40, nullable = true)
|
||||
private String entityName;
|
||||
|
||||
@SqlField(value = "flag_attivo", maxLength = 1, nullable = true, defaultObjectValue = "S")
|
||||
private String flagAttivo;
|
||||
|
||||
@SqlField(value = "flag_printer_setup", maxLength = 1, nullable = true, defaultObjectValue = "N")
|
||||
private String flagPrinterSetup;
|
||||
|
||||
@SqlField(value = "gest_name", maxLength = 40, nullable = true)
|
||||
private String gestName;
|
||||
|
||||
@SqlField(value = "note", maxLength = 255, nullable = true)
|
||||
private String note;
|
||||
|
||||
@SqlField(value = "object_type", maxLength = 5, nullable = true)
|
||||
private String objectType;
|
||||
|
||||
@SqlField(value = "open_type", maxLength = 1, nullable = true)
|
||||
private String openType;
|
||||
|
||||
@SqlField(value = "parameter", maxLength = 255, nullable = true)
|
||||
private String parameter;
|
||||
|
||||
@SqlField(value = "picture_menu", maxLength = 1024, nullable = true)
|
||||
private String pictureMenu;
|
||||
|
||||
@SqlField(value = "picture_select", maxLength = 1024, nullable = true)
|
||||
private String pictureSelect;
|
||||
|
||||
@SqlField(value = "pos", nullable = true)
|
||||
private Integer pos;
|
||||
|
||||
@@ -62,9 +34,6 @@ public class StbMenuDTO {
|
||||
@SqlField(value = "pos_tipo_azienda", nullable = true)
|
||||
private Integer posTipoAzienda;
|
||||
|
||||
@SqlField(value = "type", maxLength = -1, nullable = true, defaultObjectValue = "F")
|
||||
private String menuType;
|
||||
|
||||
@SqlField(value = "url_descrizione", maxLength = 1024, nullable = true)
|
||||
private String urlDescrizione;
|
||||
|
||||
@@ -122,15 +91,6 @@ public class StbMenuDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEntityName() {
|
||||
return entityName;
|
||||
}
|
||||
|
||||
public StbMenuDTO setEntityName(String entityName) {
|
||||
this.entityName = entityName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFlagAttivo() {
|
||||
return flagAttivo;
|
||||
}
|
||||
@@ -140,78 +100,6 @@ public class StbMenuDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFlagPrinterSetup() {
|
||||
return flagPrinterSetup;
|
||||
}
|
||||
|
||||
public StbMenuDTO setFlagPrinterSetup(String flagPrinterSetup) {
|
||||
this.flagPrinterSetup = flagPrinterSetup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getGestName() {
|
||||
return gestName;
|
||||
}
|
||||
|
||||
public StbMenuDTO setGestName(String gestName) {
|
||||
this.gestName = gestName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public StbMenuDTO setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getObjectType() {
|
||||
return objectType;
|
||||
}
|
||||
|
||||
public StbMenuDTO setObjectType(String objectType) {
|
||||
this.objectType = objectType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOpenType() {
|
||||
return openType;
|
||||
}
|
||||
|
||||
public StbMenuDTO setOpenType(String openType) {
|
||||
this.openType = openType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getParameter() {
|
||||
return parameter;
|
||||
}
|
||||
|
||||
public StbMenuDTO setParameter(String parameter) {
|
||||
this.parameter = parameter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPictureMenu() {
|
||||
return pictureMenu;
|
||||
}
|
||||
|
||||
public StbMenuDTO setPictureMenu(String pictureMenu) {
|
||||
this.pictureMenu = pictureMenu;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPictureSelect() {
|
||||
return pictureSelect;
|
||||
}
|
||||
|
||||
public StbMenuDTO setPictureSelect(String pictureSelect) {
|
||||
this.pictureSelect = pictureSelect;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPos() {
|
||||
return pos;
|
||||
}
|
||||
@@ -239,15 +127,6 @@ public class StbMenuDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getMenuType() {
|
||||
return menuType;
|
||||
}
|
||||
|
||||
public StbMenuDTO setMenuType(String menuType) {
|
||||
this.menuType = menuType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUrlDescrizione() {
|
||||
return urlDescrizione;
|
||||
}
|
||||
@@ -264,20 +143,10 @@ public class StbMenuDTO {
|
||||
.setTipoAzienda(getTipoAzienda())
|
||||
.setDescrizione(getDescrizione())
|
||||
.setDescrizioneEstesa(getDescrizioneEstesa())
|
||||
.setEntityName(getEntityName())
|
||||
.setFlagAttivo(getFlagAttivo())
|
||||
.setFlagPrinterSetup(getFlagPrinterSetup())
|
||||
.setGestName(getGestName())
|
||||
.setNote(getNote())
|
||||
.setObjectType(getObjectType())
|
||||
.setOpenType(getOpenType())
|
||||
.setParameter(getParameter())
|
||||
.setPictureMenu(getPictureMenu())
|
||||
.setPictureSelect(getPictureSelect())
|
||||
.setPos(getPos())
|
||||
.setPosCliente(getPosCliente())
|
||||
.setPosTipoAzienda(getPosTipoAzienda())
|
||||
.setMenuType(getMenuType())
|
||||
.setUrlDescrizione(getUrlDescrizione());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package it.integry.ems.menu.service;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import it.integry.annotations.PostContextAutowired;
|
||||
import it.integry.annotations.PostContextConstruct;
|
||||
import it.integry.ems.menu.MenuStaticCreator;
|
||||
import it.integry.ems.menu.dto.MenuConfigDTO;
|
||||
import it.integry.ems.menu.dto.StbMenuDTO;
|
||||
import it.integry.ems.menu.dto.StbMenuOpzDTO;
|
||||
@@ -11,12 +12,14 @@ import it.integry.ems.settings.SettingsController;
|
||||
import it.integry.ems.sync.MultiDBTransaction.AdvancedDataSource;
|
||||
import it.integry.ems.sync.MultiDBTransaction.MultiDBTransactionManager;
|
||||
import it.integry.ems.utility.UtilityDebug;
|
||||
import it.integry.ems.utility.UtilityDirs;
|
||||
import it.integry.ems_model.entity.Azienda;
|
||||
import it.integry.ems_model.entity.StbMenu;
|
||||
import it.integry.ems_model.entity.StbMenuOpz;
|
||||
import it.integry.ems_model.entity.StbTipoAzienda;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
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;
|
||||
@@ -25,6 +28,8 @@ import org.springframework.stereotype.Service;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.sql.Connection;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.List;
|
||||
|
||||
import static it.integry.ems_model.utility.UtilityDB.executeStatement;
|
||||
@@ -43,7 +48,7 @@ public class MenuConfigurationService {
|
||||
|
||||
@PostContextConstruct(priority = 5)
|
||||
public void init() throws Exception {
|
||||
if(UtilityDebug.isDebugExecution()) return;
|
||||
//if(UtilityDebug.isDebugExecution()) return;
|
||||
|
||||
logger.debug(MenuConfigurationService.class.getSimpleName() + ": Refresh menu");
|
||||
|
||||
@@ -142,4 +147,10 @@ public class MenuConfigurationService {
|
||||
|
||||
connection.commit();
|
||||
}
|
||||
|
||||
public void generate() throws Exception {
|
||||
try (MultiDBTransactionManager studioMlMultiDb = new MultiDBTransactionManager("INTEGRY")) {
|
||||
MenuStaticCreator.createMenu(studioMlMultiDb.getPrimaryConnection(), UtilityDirs.getDevelopmentMenusFolder());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package it.integry.ems.utility;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.properties.EmsProperties;
|
||||
import org.springframework.web.context.ContextLoader;
|
||||
|
||||
@@ -65,4 +66,28 @@ public class UtilityDirs {
|
||||
return CATALINA_HOME + "/webapps/ems-api/";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String getDevelopmentJavaBaseFolder() {
|
||||
String executionPath = new File(BaseMigration.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
|
||||
|
||||
int indexOf = executionPath.indexOf("ems-engine\\target");
|
||||
if(indexOf < 0) indexOf = executionPath.indexOf("ems-core\\target");
|
||||
|
||||
return executionPath.substring(0, indexOf) + "ems-core\\src\\main\\java\\";
|
||||
}
|
||||
|
||||
public static String getDevelopmentResourcesBaseFolder() {
|
||||
String executionPath = new File(BaseMigration.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
|
||||
|
||||
int indexOf = executionPath.indexOf("ems-engine\\target");
|
||||
if(indexOf < 0) indexOf = executionPath.indexOf("ems-core\\target");
|
||||
|
||||
return executionPath.substring(0, indexOf) + "ems-core\\src\\main\\resources\\";
|
||||
}
|
||||
|
||||
public static String getDevelopmentMenusFolder() {
|
||||
return getDevelopmentResourcesBaseFolder() + "menus\\";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,36 +35,9 @@ public class StbMenu extends EntityBase {
|
||||
@SqlField(value = "descrizione_estesa", maxLength = 8000, nullable = true)
|
||||
private String descrizioneEstesa;
|
||||
|
||||
@SqlField(value = "entity_name", maxLength = 40, nullable = true)
|
||||
private String entityName;
|
||||
|
||||
@SqlField(value = "flag_attivo", maxLength = 1, nullable = true, defaultObjectValue = "S")
|
||||
private String flagAttivo;
|
||||
|
||||
@SqlField(value = "flag_printer_setup", maxLength = 1, nullable = true, defaultObjectValue = "N")
|
||||
private String flagPrinterSetup;
|
||||
|
||||
@SqlField(value = "gest_name", maxLength = 40, nullable = true)
|
||||
private String gestName;
|
||||
|
||||
@SqlField(value = "note", maxLength = 255, nullable = true)
|
||||
private String note;
|
||||
|
||||
@SqlField(value = "object_type", maxLength = 5, nullable = true)
|
||||
private String objectType;
|
||||
|
||||
@SqlField(value = "open_type", maxLength = 1, nullable = true)
|
||||
private String openType;
|
||||
|
||||
@SqlField(value = "parameter", maxLength = 255, nullable = true)
|
||||
private String parameter;
|
||||
|
||||
@SqlField(value = "picture_menu", maxLength = 1024, nullable = true)
|
||||
private String pictureMenu;
|
||||
|
||||
@SqlField(value = "picture_select", maxLength = 1024, nullable = true)
|
||||
private String pictureSelect;
|
||||
|
||||
@SqlField(value = "pos", nullable = true)
|
||||
private Integer pos;
|
||||
|
||||
@@ -130,15 +103,6 @@ public class StbMenu extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEntityName() {
|
||||
return entityName;
|
||||
}
|
||||
|
||||
public StbMenu setEntityName(String entityName) {
|
||||
this.entityName = entityName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFlagAttivo() {
|
||||
return flagAttivo;
|
||||
}
|
||||
@@ -148,78 +112,6 @@ public class StbMenu extends EntityBase {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFlagPrinterSetup() {
|
||||
return flagPrinterSetup;
|
||||
}
|
||||
|
||||
public StbMenu setFlagPrinterSetup(String flagPrinterSetup) {
|
||||
this.flagPrinterSetup = flagPrinterSetup;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getGestName() {
|
||||
return gestName;
|
||||
}
|
||||
|
||||
public StbMenu setGestName(String gestName) {
|
||||
this.gestName = gestName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public StbMenu setNote(String note) {
|
||||
this.note = note;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getObjectType() {
|
||||
return objectType;
|
||||
}
|
||||
|
||||
public StbMenu setObjectType(String objectType) {
|
||||
this.objectType = objectType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getOpenType() {
|
||||
return openType;
|
||||
}
|
||||
|
||||
public StbMenu setOpenType(String openType) {
|
||||
this.openType = openType;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getParameter() {
|
||||
return parameter;
|
||||
}
|
||||
|
||||
public StbMenu setParameter(String parameter) {
|
||||
this.parameter = parameter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPictureMenu() {
|
||||
return pictureMenu;
|
||||
}
|
||||
|
||||
public StbMenu setPictureMenu(String pictureMenu) {
|
||||
this.pictureMenu = pictureMenu;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getPictureSelect() {
|
||||
return pictureSelect;
|
||||
}
|
||||
|
||||
public StbMenu setPictureSelect(String pictureSelect) {
|
||||
this.pictureSelect = pictureSelect;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user