Merge branch 'master' into develop
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
package it.integry.ems.migration.model;
|
||||
|
||||
import it.integry.ems.migration._base.BaseMigration;
|
||||
import it.integry.ems.migration._base.IntegryCustomer;
|
||||
import it.integry.ems.migration._base.IntegryCustomerDB;
|
||||
import it.integry.ems.migration._base.MigrationModelInterface;
|
||||
import it.integry.ems_model.entity.StbCalrOreGg;
|
||||
import it.integry.ems_model.entity.StbCalt;
|
||||
import it.integry.ems_model.types.OperationType;
|
||||
import it.integry.ems_model.utility.UtilityDB;
|
||||
import it.integry.ems_model.utility.UtilityLocalDate;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
public class Migration_20240321144750 extends BaseMigration implements MigrationModelInterface {
|
||||
|
||||
@Override
|
||||
public void up() throws Exception {
|
||||
if (isHistoryDB()) return;
|
||||
if (!isCustomer(IntegryCustomer.Tosca)) return;
|
||||
|
||||
|
||||
String currentDbName = advancedDataSource.getDataSource().getDbName();
|
||||
IntegryCustomerDB db = Arrays.stream(IntegryCustomer.Tosca.getValues()).filter(x -> x.getValue().equalsIgnoreCase(currentDbName)).findFirst().orElse(null);
|
||||
|
||||
LocalDate giorno = UtilityLocalDate.getNow();
|
||||
LocalTime ora;
|
||||
switch (db) {
|
||||
|
||||
case Tosca_Ce:
|
||||
ora = LocalTime.of(7, 0);
|
||||
|
||||
break;
|
||||
case Tosca_Mi:
|
||||
ora = LocalTime.of(6, 30);
|
||||
break;
|
||||
case Tosca_Fc:
|
||||
ora = LocalTime.of(4, 0);
|
||||
break;
|
||||
case Tosca_Vr:
|
||||
case Tosca_Cz:
|
||||
case Tosca_Rg:
|
||||
case Tosca_Rm:
|
||||
case Tosca_Ba:
|
||||
default:
|
||||
ora = LocalTime.of(6, 0);
|
||||
}
|
||||
|
||||
String sql = "SELECT MAX(id_riga) from stb_calr_ore_gg where cod_Cal = 'DEFAULT'";
|
||||
Integer idRiga = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(advancedDataSource.getConnection(), sql);
|
||||
|
||||
if (idRiga == null) {
|
||||
throw new Exception("Calendario DEFAULT non configurato!");
|
||||
}
|
||||
|
||||
StbCalt calendario = new StbCalt();
|
||||
calendario.setOperation(OperationType.NO_OP);
|
||||
calendario.setCodCal("DEFAULT");
|
||||
calendario.setStbCalrOreGg(new ArrayList<>());
|
||||
StbCalrOreGg firstWorkingHour = new StbCalrOreGg();
|
||||
firstWorkingHour
|
||||
.setCodCal("DEFAULT")
|
||||
.setOra(Date.from(giorno.atTime(ora).atZone(ZoneId.systemDefault()).toInstant()))
|
||||
.setFlagTipoOra("L")
|
||||
.setIdRiga(idRiga + 1)
|
||||
.setOperation(OperationType.INSERT);
|
||||
calendario.getStbCalrOreGg().add(firstWorkingHour);
|
||||
|
||||
calendario.manageWithParentConnection(advancedDataSource.getConnection());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void down() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package it.integry.ems_model.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.ems_model.annotation.FK;
|
||||
import it.integry.ems_model.annotation.PK;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.annotation.Table;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@PropertyReactive()
|
||||
@Table(value = JtbCalFasce.ENTITY)
|
||||
@JsonTypeName(value = JtbCalFasce.ENTITY)
|
||||
public class JtbCalFasce extends EntityBase {
|
||||
|
||||
public final static String ENTITY = "jtb_cal_fasce";
|
||||
|
||||
private final static long serialVersionUID = 1L;
|
||||
|
||||
@PK()
|
||||
@SqlField(value = "cod_jcal", maxLength = 5, nullable = false)
|
||||
@FK(tableName = JtbCalendt.ENTITY, columnName = "cod_jcal")
|
||||
@FK(tableName = JtbCalGgSet.ENTITY, columnName = "cod_jcal")
|
||||
private String codJcal;
|
||||
|
||||
@PK()
|
||||
@SqlField(value = "gg_set", nullable = false)
|
||||
@FK(tableName = JtbCalGgSet.ENTITY, columnName = "gg_set")
|
||||
private Integer ggSet;
|
||||
|
||||
@PK()
|
||||
@SqlField(value = "da_ora", nullable = false)
|
||||
private Date daOra;
|
||||
|
||||
@SqlField(value = "a_ora", nullable = false)
|
||||
private Date aOra;
|
||||
|
||||
@SqlField(value = "fascia", maxLength = 40, nullable = false)
|
||||
private String fascia;
|
||||
|
||||
public String getCodJcal() {
|
||||
return codJcal;
|
||||
}
|
||||
|
||||
public JtbCalFasce setCodJcal(String codJcal) {
|
||||
this.codJcal = codJcal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getGgSet() {
|
||||
return ggSet;
|
||||
}
|
||||
|
||||
public JtbCalFasce setGgSet(Integer ggSet) {
|
||||
this.ggSet = ggSet;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getDaOra() {
|
||||
return daOra;
|
||||
}
|
||||
|
||||
public JtbCalFasce setDaOra(Date daOra) {
|
||||
this.daOra = daOra;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getAOra() {
|
||||
return aOra;
|
||||
}
|
||||
|
||||
public JtbCalFasce setAOra(Date aOra) {
|
||||
this.aOra = aOra;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFascia() {
|
||||
return fascia;
|
||||
}
|
||||
|
||||
public JtbCalFasce setFascia(String fascia) {
|
||||
this.fascia = fascia;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package it.integry.ems_model.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@PropertyReactive()
|
||||
@Table(value = JtbCalGgSet.ENTITY)
|
||||
@JsonTypeName(value = JtbCalGgSet.ENTITY)
|
||||
public class JtbCalGgSet extends EntityBase {
|
||||
|
||||
public final static String ENTITY = "jtb_cal_gg_set";
|
||||
|
||||
private final static long serialVersionUID = 1L;
|
||||
|
||||
@PK()
|
||||
@SqlField(value = "cod_jcal", maxLength = 5, nullable = false)
|
||||
@FK(tableName = JtbCalendt.ENTITY, columnName = "cod_jcal")
|
||||
private String codJcal;
|
||||
|
||||
@PK()
|
||||
@SqlField(value = "gg_set", nullable = false)
|
||||
private Integer ggSet;
|
||||
|
||||
@SqlField(value = "flag_lavorativo", maxLength = 1, nullable = false)
|
||||
private String flagLavorativo;
|
||||
|
||||
@EntityChild
|
||||
private List<JtbCalFasce> jtbCalFasce;
|
||||
|
||||
public String getCodJcal() {
|
||||
return codJcal;
|
||||
}
|
||||
|
||||
public JtbCalGgSet setCodJcal(String codJcal) {
|
||||
this.codJcal = codJcal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getGgSet() {
|
||||
return ggSet;
|
||||
}
|
||||
|
||||
public JtbCalGgSet setGgSet(Integer ggSet) {
|
||||
this.ggSet = ggSet;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFlagLavorativo() {
|
||||
return flagLavorativo;
|
||||
}
|
||||
|
||||
public JtbCalGgSet setFlagLavorativo(String flagLavorativo) {
|
||||
this.flagLavorativo = flagLavorativo;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<JtbCalFasce> getJtbCalFasce() {
|
||||
return jtbCalFasce;
|
||||
}
|
||||
|
||||
public JtbCalGgSet setJtbCalFasce(List<JtbCalFasce> jtbCalFasce) {
|
||||
this.jtbCalFasce = jtbCalFasce;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package it.integry.ems_model.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.ems_model.annotation.Master;
|
||||
import it.integry.ems_model.annotation.PK;
|
||||
import it.integry.ems_model.annotation.SqlField;
|
||||
import it.integry.ems_model.annotation.Table;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
import it.integry.ems_model.annotation.FK;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Master
|
||||
@PropertyReactive
|
||||
@@ -29,6 +27,9 @@ public class JtbCalendt extends EntityBase {
|
||||
@SqlField(value = "flag_attivo", maxLength = 1, nullable = false)
|
||||
private String flagAttivo;
|
||||
|
||||
@EntityChild
|
||||
private List<JtbCalGgSet> jtbCalGgSet;
|
||||
|
||||
public JtbCalendt() {
|
||||
super();
|
||||
}
|
||||
@@ -56,4 +57,13 @@ public class JtbCalendt extends EntityBase {
|
||||
public void setFlagAttivo(String flagAttivo) {
|
||||
this.flagAttivo = flagAttivo;
|
||||
}
|
||||
|
||||
public List<JtbCalGgSet> getJtbCalGgSet() {
|
||||
return jtbCalGgSet;
|
||||
}
|
||||
|
||||
public JtbCalendt setJtbCalGgSet(List<JtbCalGgSet> jtbCalGgSet) {
|
||||
this.jtbCalGgSet = jtbCalGgSet;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package it.integry.ems_model.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@PropertyReactive()
|
||||
@Table(value = StbCalrOreGg.ENTITY)
|
||||
@JsonTypeName(value = StbCalrOreGg.ENTITY)
|
||||
public class StbCalrOreGg extends EntityBase {
|
||||
|
||||
public final static String ENTITY = "stb_calr_ore_gg";
|
||||
|
||||
private final static long serialVersionUID = 1L;
|
||||
|
||||
@PK()
|
||||
@ImportFromParent
|
||||
@SqlField(value = "cod_cal", maxLength = 20, nullable = false)
|
||||
@FK(tableName = StbCalt.ENTITY, columnName = "cod_cal")
|
||||
private String codCal;
|
||||
|
||||
@PK()
|
||||
@SqlField(value = "id_riga", nullable = false)
|
||||
private Integer idRiga;
|
||||
|
||||
@SqlField(value = "ora", nullable = false)
|
||||
private Date ora;
|
||||
|
||||
@SqlField(value = "flag_tipo_ora", maxLength = 1, nullable = false)
|
||||
private String flagTipoOra;
|
||||
|
||||
public String getCodCal() {
|
||||
return codCal;
|
||||
}
|
||||
|
||||
public StbCalrOreGg setCodCal(String codCal) {
|
||||
this.codCal = codCal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getIdRiga() {
|
||||
return idRiga;
|
||||
}
|
||||
|
||||
public StbCalrOreGg setIdRiga(Integer idRiga) {
|
||||
this.idRiga = idRiga;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Date getOra() {
|
||||
return ora;
|
||||
}
|
||||
|
||||
public StbCalrOreGg setOra(Date ora) {
|
||||
this.ora = ora;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFlagTipoOra() {
|
||||
return flagTipoOra;
|
||||
}
|
||||
|
||||
public StbCalrOreGg setFlagTipoOra(String flagTipoOra) {
|
||||
this.flagTipoOra = flagTipoOra;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package it.integry.ems_model.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import it.integry.ems_model.annotation.*;
|
||||
import it.integry.ems_model.base.EntityBase;
|
||||
import org.kie.api.definition.type.PropertyReactive;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Master()
|
||||
@PropertyReactive()
|
||||
@Table(value = StbCalt.ENTITY)
|
||||
@JsonTypeName(value = StbCalt.ENTITY)
|
||||
public class StbCalt extends EntityBase {
|
||||
|
||||
public final static String ENTITY = "stb_calt";
|
||||
|
||||
private final static long serialVersionUID = 1L;
|
||||
|
||||
@PK()
|
||||
@SqlField(value = "cod_cal", maxLength = 20, nullable = false)
|
||||
private String codCal;
|
||||
|
||||
@SqlField(value = "descrizione", maxLength = 255, nullable = false)
|
||||
private String descrizione;
|
||||
|
||||
|
||||
@EntityChild
|
||||
private List<StbCalrOreGg> stbCalrOreGg;
|
||||
|
||||
public String getCodCal() {
|
||||
return codCal;
|
||||
}
|
||||
|
||||
public StbCalt setCodCal(String codCal) {
|
||||
this.codCal = codCal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescrizione() {
|
||||
return descrizione;
|
||||
}
|
||||
|
||||
public StbCalt setDescrizione(String descrizione) {
|
||||
this.descrizione = descrizione;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<StbCalrOreGg> getStbCalrOreGg() {
|
||||
return stbCalrOreGg;
|
||||
}
|
||||
|
||||
public StbCalt setStbCalrOreGg(List<StbCalrOreGg> stbCalrOreGg) {
|
||||
this.stbCalrOreGg = stbCalrOreGg;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void updateChilds() throws Exception {
|
||||
insertChilds();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void insertChilds() throws Exception {
|
||||
|
||||
for (StbCalrOreGg stbCalrOreGg : getStbCalrOreGg()) {
|
||||
stbCalrOreGg.manageWithParentConnection(connection, stbCalrOreGg.getOperation(), dataCompleting, entityHolder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteChilds() throws Exception {
|
||||
StbCalrOreGg oreGg = new StbCalrOreGg();
|
||||
oreGg.deleteAllEntities(connection, this);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user