Skip to content

Commit

Permalink
Fix caricamento BulkPersistentInfo e aggiornamento framework 4.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
mspasiano committed Oct 22, 2016
1 parent eb2fe50 commit d9530fc
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 155 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -25,7 +25,7 @@
<java.version>1.8</java.version>
<opencmis.version>1.0.0</opencmis.version>
<spring.version>4.3.3.RELEASE</spring.version>
<jada.version>4.0.8</jada.version>
<jada.version>4.0.9</jada.version>
<project.build.sourceEncoding>ISO-8859-1</project.build.sourceEncoding>
<sigla.build.number>${maven.build.timestamp}</sigla.build.number>
<slf4j.version>1.7.21</slf4j.version>
Expand Down
Expand Up @@ -9,33 +9,49 @@ public class NazioneKey extends OggettoBulk implements KeyedPersistent {
// PG_NAZIONE DECIMAL(10,0) NOT NULL (PK)
private java.lang.Long pg_nazione;

public NazioneKey() {
super();
}
public NazioneKey(java.lang.Long pg_nazione) {
this.pg_nazione = pg_nazione;
}
public boolean equalsByPrimaryKey(Object o) {
if (this == o) return true;
if (!(o instanceof NazioneKey)) return false;
NazioneKey k = (NazioneKey)o;
if(!compareKey(getPg_nazione(),k.getPg_nazione())) return false;
return true;
}
/*
* Getter dell'attributo pg_nazione
*/
public java.lang.Long getPg_nazione() {
return pg_nazione;
}
public int primaryKeyHashCode() {
return
calculateKeyHashCode(getPg_nazione());
}
/*
* Setter dell'attributo pg_nazione
*/
public void setPg_nazione(java.lang.Long pg_nazione) {
this.pg_nazione = pg_nazione;
}
public NazioneKey() {
super();
}

public NazioneKey(java.lang.Long pg_nazione) {
this.pg_nazione = pg_nazione;
}

public boolean equalsByPrimaryKey(Object o) {
if (this == o)
return true;
if (!(o instanceof NazioneKey))
return false;
NazioneKey k = (NazioneKey) o;
if (!compareKey(getPg_nazione(), k.getPg_nazione()))
return false;
return true;
}

/*
* Getter dell'attributo pg_nazione
*/
public java.lang.Long getPg_nazione() {
return pg_nazione;
}

public int primaryKeyHashCode() {
return calculateKeyHashCode(getPg_nazione());
}

/*
* Setter dell'attributo pg_nazione
*/
public void setPg_nazione(java.lang.Long pg_nazione) {
this.pg_nazione = pg_nazione;
}

@Override
public boolean equals(Object obj) {
return equalsByPrimaryKey(obj);
}

public int hashCode() {
return primaryKeyHashCode();
};
}
Expand Up @@ -66,6 +66,7 @@
import org.apache.chemistry.opencmis.client.api.QueryResult;
import org.apache.chemistry.opencmis.client.api.SecondaryType;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;

/**
* Gestisce le catene di elementi correlate con la fattura passiva in uso.
Expand Down Expand Up @@ -1596,7 +1597,7 @@ protected CMISPath getCMISPath(Fattura_passivaBulk fattura_passivaBulk, boolean
return CMISPath.construct(
((Folder)SpringUtil.getBean("cmisService", SiglaCMISService.class).getNodeByNodeRef(fattura_passivaBulk.getDocumentoEleTestata().getDocumentoEleTrasmissione().getCmisNodeRef())).getPath()
);
} catch (ApplicationException e) {
} catch (ApplicationException|CmisObjectNotFoundException e) {
return null;
}
}
Expand Down
33 changes: 33 additions & 0 deletions sigla-ejb/src/main/java/it/cnr/contab/util/Utility.java
Expand Up @@ -26,12 +26,22 @@
import it.cnr.contab.prevent01.ejb.PdgContrSpeseComponentSession;
import it.cnr.contab.progettiric00.ejb.geco.ProgettoGecoComponentSession;
import it.cnr.jada.bulk.OggettoBulk;
import it.cnr.jada.ejb.AdminSession;
import it.cnr.jada.persistency.sql.SQLPersistentInfo;
import it.cnr.jada.util.ejb.EJBCommonServices;

import java.math.BigDecimal;
import java.rmi.RemoteException;
import java.util.Set;

import javax.ejb.EJBException;
import javax.servlet.ServletException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
import org.springframework.core.type.filter.AssignableTypeFilter;

/**
* @author mspasiano
Expand All @@ -40,6 +50,8 @@
* Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
*/
public final class Utility {
private transient static final Logger logger = LoggerFactory.getLogger(Utility.class);

public static final java.math.BigDecimal ZERO = new java.math.BigDecimal(0);
public static String TIPO_GESTIONE_SPESA = "S";
public static String TIPO_GESTIONE_ENTRATA = "E";
Expand Down Expand Up @@ -145,6 +157,27 @@ public static String NumberToText(BigDecimal importo) {
}
}

public static synchronized void loadPersistentInfos() throws ServletException{
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(true);
provider.addIncludeFilter(new AssignableTypeFilter(OggettoBulk.class));
AdminSession adminSession = (AdminSession) EJBCommonServices.createEJB("JADAEJB_AdminSession");
Set<BeanDefinition> components = provider.findCandidateComponents("it/cnr");
for (BeanDefinition component : components){
try {
Class<?> clazz = Class.forName(component.getBeanClassName());
logger.info("Load PersistentInfo for class: {}",clazz.getName());
adminSession.loadPersistentInfos(clazz);
if(clazz.getName().endsWith("Bulk")) {
logger.info("Load BulkInfo for class: {}",clazz.getName());
adminSession.loadBulkInfos(clazz);
}
} catch (Exception e) {
logger.error("Cannot load persistentInfo for class : {}", component.getBeanClassName(), e);
}

}
}

private static String NumberToTextRicorsiva(int n) {
if (n < 0) {
return "meno " + NumberToTextRicorsiva(-n);
Expand Down
Expand Up @@ -27,7 +27,7 @@
<columnMapping
columnName="PROTOCOLLO_INVIO"
propertyName="protocollo_invio"
sqlTypeName="STRING"
sqlTypeName="VARCHAR"
columnSize="6"
nullable="false"
primary="true" />
Expand Down
Expand Up @@ -57,7 +57,7 @@
<columnMapping
columnName="ESERCIZIO_ORIGINALE"
propertyName="esercizio_originale"
sqlTypeName="NUMBER"
sqlTypeName="DECIMAL"
columnSize="4" />
<columnMapping
columnName="CD_TIPO_DOCUMENTO_CONT"
Expand All @@ -67,7 +67,7 @@
<columnMapping
columnName="IM_VOCE"
propertyName="im_voce"
sqlTypeName="NUMBER"
sqlTypeName="DECIMAL"
columnSize="15"
columnScale="2"/>
</defaultColumnMap>
Expand Down
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<SQLPersistentInfo persistentClassName="it.cnr.contab.inventario00.consultazioni.bulk.Ubicazione_beneRestBulk"
homeClassName="it.cnr.contab.inventario00.tabrif.bulk.Ubicazione_beneRestHome" >
homeClassName="it.cnr.contab.inventario00.consultazioni.bulk.Ubicazione_beneRestHome" >

</SQLPersistentInfo>
Expand Up @@ -60,7 +60,7 @@
name="im_rimborso"
property="im_rimborso"
inputType="TEXT"
formatName="it.jada.stone.util.EuroFormat"
formatName="it.cnr.contab.util.EuroFormat"
enabledOnEdit="false"
nullable="false"
label="Quota Rimborso" />
Expand Down
Empty file.
122 changes: 3 additions & 119 deletions sigla-web/src/main/java/it/cnr/contab/util/servlet/UtilServlet.java
Expand Up @@ -3,12 +3,9 @@
import it.cnr.contab.config00.bulk.Parametri_enteBulk;
import it.cnr.contab.config00.bulk.Parametri_enteHome;
import it.cnr.contab.progettiric00.ejb.ProgettoRicercaPadreComponentSession;
import it.cnr.contab.reports.bulk.Print_spoolerBulk;
import it.cnr.contab.reports.bulk.Print_spoolerHome;
import it.cnr.contab.utenze00.bp.CNRUserContext;
import it.cnr.contab.util.Utility;
import it.cnr.jada.UserContext;
import it.cnr.jada.excel.bulk.Excel_spoolerBulk;
import it.cnr.jada.excel.bulk.Excel_spoolerHome;
import it.cnr.jada.persistency.sql.LoggableStatement;
import it.cnr.jada.util.SendMail;
import it.cnr.jada.util.ejb.EJBCommonServices;
Expand All @@ -19,7 +16,6 @@
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.jar.Attributes;
import java.util.jar.Manifest;

Expand All @@ -29,9 +25,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpDelete;
import org.apache.http.impl.client.HttpClientBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -122,6 +115,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse resp)
public void init()
throws ServletException
{
Utility.loadPersistentInfos();
final GregorianCalendar dataInizio = (GregorianCalendar) GregorianCalendar.getInstance();
class PrintThread
implements Runnable
Expand All @@ -133,8 +127,6 @@ public void run()
try{
Thread.sleep(1000*60*20);
if (new java.text.SimpleDateFormat("HH").format(new java.util.Date()).equalsIgnoreCase("02")){
deletePrintSpooler();
deleteExcel();
aggiornaGECO(String.valueOf(dataInizio.get(GregorianCalendar.YEAR)), null);
deleteMessaggi();
}
Expand Down Expand Up @@ -182,115 +174,7 @@ private void aggiornaGECO(String esercizio, String cds) {
SendMail.sendErrorMail(text,e.toString());
}
}

public void deletePrintSpooler()
{
try{
LoggableStatement statement = null;
ResultSet rs = null;
Connection conn = null;
try{
conn = it.cnr.jada.util.ejb.EJBCommonServices.getConnection();
conn.setAutoCommit(false);
it.cnr.jada.persistency.sql.HomeCache homeCache = new it.cnr.jada.persistency.sql.HomeCache(conn);
Print_spoolerHome print_spoolerHome = (Print_spoolerHome)homeCache.getHome(Print_spoolerBulk.class);
statement = print_spoolerHome.selectJobsToDelete().prepareStatement(conn);
rs = statement.executeQuery();
while (rs.next()){
try{
StringBuffer reportServerURL = new StringBuffer(rs.getString("SERVER"));
HttpClient httpclient = HttpClientBuilder.create().build();
reportServerURL.append("/").append(rs.getString("UTCR"));
reportServerURL.append("/").append(rs.getString("NOME_FILE"));
HttpDelete method = new HttpDelete(reportServerURL.toString());
method.addHeader("Accept-Language", Locale.getDefault().toString());
httpclient.execute(method);
//Cancelliamo la riga sul DB
Print_spoolerBulk bulk = (Print_spoolerBulk)print_spoolerHome.findByPrimaryKey(new Print_spoolerBulk(new Long(rs.getLong("PG_STAMPA"))));
print_spoolerHome.deleteRiga(bulk, null);
} catch(java.net.UnknownHostException e) {
} catch(java.net.ConnectException e){
}catch(IOException e) {
//In questo caso Il file è già stato cancellato e quindi cancello la riga
Print_spoolerBulk bulk = (Print_spoolerBulk)print_spoolerHome.findByPrimaryKey(new Print_spoolerBulk(new Long(rs.getLong("PG_STAMPA"))));
print_spoolerHome.deleteRiga(bulk, null);
}

}
}
finally {
if (rs != null)
rs.close();
if (statement != null)
statement.close();
if (conn != null){
conn.commit();
conn.close();
}
}
}
catch(EJBException ex){
}
catch(Throwable _ex){
System.out.println("UtilServlet.init()" + _ex.getMessage());
}

}
public void deleteExcel()
{
try{
LoggableStatement statement = null;
ResultSet rs = null;
Connection conn = null;
try{
conn = it.cnr.jada.util.ejb.EJBCommonServices.getConnection();
conn.setAutoCommit(false);
it.cnr.jada.persistency.sql.HomeCache homeCache = new it.cnr.jada.persistency.sql.HomeCache(conn);
Excel_spoolerHome excel_spoolerHome = (Excel_spoolerHome)homeCache.getHome(Excel_spoolerBulk.class);
statement = excel_spoolerHome.selectJobsToDelete().prepareStatement(conn);
rs = statement.executeQuery();
while (rs.next()){
try{
StringBuffer reportServerURL = new StringBuffer(rs.getString("SERVER"));
reportServerURL.append("?user=");
reportServerURL.append(java.net.URLEncoder.encode(rs.getString("UTCR")));
reportServerURL.append("&file=");
reportServerURL.append(java.net.URLEncoder.encode(rs.getString("NOME_FILE")));
reportServerURL.append("&command=delete");
java.net.URLConnection urlConn = new java.net.URL(reportServerURL.toString()).openConnection();
urlConn.setUseCaches(false);
urlConn.connect();
java.io.InputStream is = urlConn.getInputStream();
is.close();
//Cancelliamo la riga sul DB
Excel_spoolerBulk bulk = (Excel_spoolerBulk)excel_spoolerHome.findByPrimaryKey(new Excel_spoolerBulk(new Long(rs.getLong("PG_ESTRAZIONE"))));
excel_spoolerHome.deleteRiga(bulk);
} catch(java.net.UnknownHostException e) {
} catch(java.net.ConnectException e){
}catch(IOException e) {
//In questo caso Il file è già stato cancellato e quindi cancello la riga
Excel_spoolerBulk bulk = (Excel_spoolerBulk)excel_spoolerHome.findByPrimaryKey(new Excel_spoolerBulk(new Long(rs.getLong("PG_ESTRAZIONE"))));
excel_spoolerHome.deleteRiga(bulk);
}
}
}
finally {
if (rs != null)
rs.close();
if (statement != null)
statement.close();
if (conn != null){
conn.commit();
conn.close();
}
}
}
catch(EJBException ex){
}
catch(Throwable _ex){
System.out.println("UtilServlet.init()" + _ex.getMessage());
}
}

public void deleteMessaggi()
{
try{
Expand Down

0 comments on commit d9530fc

Please sign in to comment.