first commit

This commit is contained in:
MaddoScientisto 2026-03-14 20:04:39 +01:00
commit 4d332ef662
27586 changed files with 3281783 additions and 0 deletions

View file

@ -0,0 +1,22 @@
package com.ablia.a.Itext5;
import Font;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.lowagie.text.Paragraph;
public abstract class DBAdapter5 extends DBAdapter {
public DBAdapter5() {}
public DBAdapter5(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public static final Paragraph creaParagrafoConGrassetto5(String paramString, Font paramFont1, Font paramFont2) {
throw new Error("Unresolved compilation problems: \n\tFont cannot be resolved to a type\n\tFont cannot be resolved to a type\n");
}
public static final Paragraph creaParagrafoConGrassetto5(String paramString, Font paramFont1, Font paramFont2, float paramFloat) {
throw new Error("Unresolved compilation problems: \n\tFont cannot be resolved to a type\n\tFont cannot be resolved to a type\n");
}
}

View file

@ -0,0 +1,138 @@
package com.ablia.a.Itext5;
import com.ablia.db.ResParm;
import com.ablia.util.ConsoleInput;
import com.ablia.util.FileWr;
import com.ablia.util.Vectumerator;
import com.lowagie.tools.ConcatPdf;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
public class PDFMerger5 extends ConsoleInput {
private Vectumerator inputFileNames;
private String outputFileName;
private FileWr outFile;
public class PdfFilter implements FileFilter {
public boolean accept(File pathname) {
if (pathname.isDirectory())
return true;
String name = pathname.getName().toLowerCase();
return name.toLowerCase().endsWith("pdf");
}
}
public static void main(String[] args) {
PDFMerger5 p = new PDFMerger5();
List<File> files = new ArrayList<>();
files.add(new File("/Users/acolzi/Documents/webapps/ctexpress/_docs/2017/FD-1016-2017-_1488379609709.pdf"));
files.add(new File("/Users/acolzi/Documents/webapps/ctexpress/_docs/2017/FD-1030-2017-_1488379574278.pdf"));
concatenatePdfs(files, new File("/Users/acolzi/Documents/webapps/ctexpress/_docs/pio.pdf"));
}
public String getOutputFileName() {
if (this.outputFileName == null) {
this.outputFileName = readLine("Nome file output?: ");
if (!this.outputFileName.endsWith(".pdf"))
this.outputFileName = String.valueOf(this.outputFileName) + ".pdf";
}
return this.outputFileName;
}
public void mergePdf() {
System.out.println("Merge pdf V. 1.0");
String temp = "";
try {
Vectumerator<String> vec;
System.out.println("Premi D per unire in ordine alfabetico i file PDF di una directori:");
System.out.println("Premi F per unire i singoli file PDF:");
temp = readLine("Scegli D o F ?: ");
while (!temp.toLowerCase().equals("d") && !temp.toLowerCase().equals("f"))
temp = readLine("Scegli D o F ?: ");
if (temp.toLowerCase().equals("f")) {
vec = getInputFileNames();
} else {
vec = getDirFileNames();
}
String[] args = new String[vec.getTotNumberOfRecords() + 1];
int i = 0;
while (vec.hasMoreElements()) {
String currentInputFile = vec.nextElement();
args[i] = currentInputFile;
i++;
}
args[i] = getOutputFileName();
ConcatPdf.main(args);
} catch (Exception e) {
e.printStackTrace(System.out);
System.out.println(temp);
}
}
public void setOutputFileName(String outputFileName) {
this.outputFileName = outputFileName;
}
public Vectumerator getDirFileNames() {
if (this.inputFileNames == null) {
this.inputFileNames = new Vectumerator();
String temp = readLine("Dammi la directori contentente tutti i file pdf: ");
File dirTargetDir = new File(temp);
while (!dirTargetDir.isDirectory() || !dirTargetDir.exists()) {
System.out.println("Directori non trovata!!!");
temp = readLine("Dammi la directori contentente tutti i file pdf: ");
}
try {
File[] pdfFiles = dirTargetDir.listFiles(new PdfFilter());
for (int j = 0; j < pdfFiles.length; j++) {
System.out.println("File n. " + (j + 1) + ": " + pdfFiles[j].getCanonicalPath());
this.inputFileNames.addElement(pdfFiles[j].getCanonicalPath());
}
} catch (Exception e) {
e.printStackTrace();
}
}
return this.inputFileNames;
}
public void setInputFileNames(Vectumerator inputFileNames) {
this.inputFileNames = inputFileNames;
}
public FileWr getOutFile() {
if (this.outFile == null)
this.outFile = new FileWr(getOutputFileName(), false);
return this.outFile;
}
public void setOutFile(FileWr outFile) {
this.outFile = outFile;
}
public Vectumerator getInputFileNames() {
if (this.inputFileNames == null) {
this.inputFileNames = new Vectumerator();
int i = 0;
String temp;
while (!(temp = readLine("Dammi il file pdf n. " + i + ": ")).equals("")) {
if (!temp.endsWith(".pdf"))
temp = String.valueOf(temp) + ".pdf";
this.inputFileNames.add(i, temp);
i++;
}
}
return this.inputFileNames;
}
public static ResParm concatenatePdfs(List<File> paramList, File paramFile) {
throw new Error("Unresolved compilation problems: \n\tDocument cannot be resolved to a type\n\tDocument cannot be resolved to a type\n\tThe method addDocument(PdfReader) is undefined for the type PdfCopy\n");
}
public static ResParm concatenatePdfs2(List<File> paramList, File paramFile) {
throw new Error("Unresolved compilation problems: \n\tDocument cannot be resolved to a type\n\tDocument cannot be resolved to a type\n\tThe method addDocument(PdfReader) is undefined for the type PdfCopy\n");
}
}

View file

@ -0,0 +1,87 @@
package com.ablia.a.Itext5;
import Document;
import Rectangle;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfPageEvent;
import com.lowagie.text.pdf.PdfWriter;
public class PdfWatermarkEvent5 implements PdfPageEvent {
private String wmFileName;
private boolean printMiddleDash;
private Rectangle pageSize;
public PdfWatermarkEvent5(String paramString, boolean paramBoolean, Rectangle paramRectangle) {}
public PdfWatermarkEvent5(String paramString, boolean paramBoolean) {}
public void onChapter(PdfWriter paramPdfWriter, Document paramDocument, float paramFloat, Paragraph paramParagraph) {
throw new Error("Unresolved compilation problem: \n\tDocument cannot be resolved to a type\n");
}
public void onChapterEnd(PdfWriter paramPdfWriter, Document paramDocument, float paramFloat) {
throw new Error("Unresolved compilation problem: \n\tDocument cannot be resolved to a type\n");
}
public void onCloseDocument(PdfWriter paramPdfWriter, Document paramDocument) {
throw new Error("Unresolved compilation problem: \n\tDocument cannot be resolved to a type\n");
}
public void onEndPage(PdfWriter paramPdfWriter, Document paramDocument) {
throw new Error("Unresolved compilation problem: \n\tDocument cannot be resolved to a type\n");
}
public void onGenericTag(PdfWriter paramPdfWriter, Document paramDocument, Rectangle paramRectangle, String paramString) {
throw new Error("Unresolved compilation problems: \n\tDocument cannot be resolved to a type\n\tRectangle cannot be resolved to a type\n");
}
public void onOpenDocument(PdfWriter paramPdfWriter, Document paramDocument) {
throw new Error("Unresolved compilation problem: \n\tDocument cannot be resolved to a type\n");
}
public void onParagraph(PdfWriter paramPdfWriter, Document paramDocument, float paramFloat) {
throw new Error("Unresolved compilation problem: \n\tDocument cannot be resolved to a type\n");
}
public void onParagraphEnd(PdfWriter paramPdfWriter, Document paramDocument, float paramFloat) {
throw new Error("Unresolved compilation problem: \n\tDocument cannot be resolved to a type\n");
}
public void onSection(PdfWriter paramPdfWriter, Document paramDocument, float paramFloat, int paramInt, Paragraph paramParagraph) {
throw new Error("Unresolved compilation problem: \n\tDocument cannot be resolved to a type\n");
}
public void onSectionEnd(PdfWriter paramPdfWriter, Document paramDocument, float paramFloat) {
throw new Error("Unresolved compilation problem: \n\tDocument cannot be resolved to a type\n");
}
public void onStartPage(PdfWriter paramPdfWriter, Document paramDocument) {
throw new Error("Unresolved compilation problems: \n\tDocument cannot be resolved to a type\n\tThe method getPageSize() from the type PdfWatermarkEvent5 refers to the missing type Rectangle\n\tBaseColor cannot be resolved to a variable\n\tThe method getPageSize() from the type PdfWatermarkEvent5 refers to the missing type Rectangle\n\tImage cannot be resolved to a type\n\tImage cannot be resolved\n\tThe method getPageSize() from the type PdfWatermarkEvent5 refers to the missing type Rectangle\n\tThe method getPageSize() from the type PdfWatermarkEvent5 refers to the missing type Rectangle\n");
}
public String getWmFileName() {
throw new Error("Unresolved compilation problem: \n");
}
public void setWmFileName(String paramString) {
throw new Error("Unresolved compilation problem: \n");
}
public boolean isPrintMiddleDash() {
throw new Error("Unresolved compilation problem: \n");
}
public void setPrintMiddleDash(boolean paramBoolean) {
throw new Error("Unresolved compilation problem: \n");
}
public Rectangle getPageSize() {
throw new Error("Unresolved compilation problems: \n\tRectangle cannot be resolved to a type\n\tRectangle cannot be resolved to a type\n\tPageSize cannot be resolved to a variable\n\tRectangle cannot be resolved to a type\n");
}
public void setPageSize(Rectangle paramRectangle) {
throw new Error("Unresolved compilation problems: \n\tRectangle cannot be resolved to a type\n\tRectangle cannot be resolved to a type\n");
}
}

View file

@ -0,0 +1,112 @@
package com.ablia.a.Itext5;
import BaseColor;
import Font;
import com.ablia.common.Parm;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.util.Vectumerator;
import java.util.Hashtable;
public class TtFont5 extends DBAdapter {
private String ttfName;
private String ttfPath;
private Parm parm;
private static Hashtable fonts;
private static final Font PDF_f_Default;
private static final int PDF_fsize_Default = 10;
private static TtFont5 ttFontInstance;
static final String WIN_DEFAULT_TTF_PATH = "C:/windows/fonts/";
private TtFont5() {}
private TtFont5(ApplParmFull paramApplParmFull) {}
public ResParm delete() {
throw new Error("Unresolved compilation problem: \n");
}
public Vectumerator findAll() {
throw new Error("Unresolved compilation problem: \n");
}
public void findByPrimaryKey(Object paramObject) {
throw new Error("Unresolved compilation problem: \n");
}
public int getDBState() {
throw new Error("Unresolved compilation problem: \n");
}
public String getTtfPath() {
throw new Error("Unresolved compilation problem: \n");
}
public ResParm save() {
throw new Error("Unresolved compilation problem: \n");
}
public void setNuovaIstanzaOggettoRemoto(boolean paramBoolean) {
throw new Error("Unresolved compilation problem: \n");
}
public Object[] getFieldSetArg(String paramString, Class paramClass) {
throw new Error("Unresolved compilation problem: \n");
}
public void setTtfPath(String paramString) {
throw new Error("Unresolved compilation problem: \n");
}
public String getTtfName() {
throw new Error("Unresolved compilation problem: \n");
}
public void setTtfName(String paramString) {
throw new Error("Unresolved compilation problem: \n");
}
public String getTtf() {
throw new Error("Unresolved compilation problem: \n");
}
protected ResParm checkDeleteCascade() {
throw new Error("Unresolved compilation problem: \n");
}
protected void deleteCascade() {
throw new Error("Unresolved compilation problem: \n");
}
public Parm getParm(String paramString) {
throw new Error("Unresolved compilation problem: \n");
}
public Font getFont(String paramString, int paramInt1, int paramInt2, BaseColor paramBaseColor) {
throw new Error("Unresolved compilation problems: \n\tFont cannot be resolved to a type\n\tBaseColor cannot be resolved to a type\n\tFont cannot be resolved to a type\n\tFont cannot be resolved to a type\n\tFont cannot be resolved to a type\n\tBaseColor cannot be resolved to a variable\n\tFont cannot be resolved to a type\n\tFont cannot be resolved to a type\n\tFont cannot be resolved to a type\n");
}
protected boolean isDatabaseBean() {
throw new Error("Unresolved compilation problem: \n");
}
public static synchronized TtFont5 getInstance(ApplParmFull paramApplParmFull) {
throw new Error("Unresolved compilation problem: \n");
}
public static synchronized void reset() {
throw new Error("Unresolved compilation problems: \n\tFont cannot be resolved to a type\n\tFont cannot be resolved to a type\n");
}
private static Hashtable getFonts() {
throw new Error("Unresolved compilation problem: \n");
}
}

View file

@ -0,0 +1 @@
package com.ablia.a.Itext5;

View file

@ -0,0 +1,16 @@
package com.ablia.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface CRDescriptor {
String descrizione() default "";
boolean abilita() default true;
}

View file

@ -0,0 +1 @@
package com.ablia.annotation;

View file

@ -0,0 +1,80 @@
package com.ablia.bookmark;
import com.ablia.util.AbMessages;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.util.Hashtable;
public class Bookmark implements Serializable {
private static final long serialVersionUID = 1L;
private Hashtable items = null;
private int numberOfItems = 0;
private String msg;
public Bookmark() {
this.items = new Hashtable();
}
public String addBookmarkItem(BookmarkItem theBI) {
if (!this.items.containsKey(theBI.getBookmarkItemId())) {
this.items.put(theBI.getBookmarkItemId(), theBI);
this.numberOfItems++;
setMsg(AbMessages.getMessage("BM_ITEM_ADDED"));
return AbMessages.getMessage("BM_ITEM_ADDED");
}
setMsg(AbMessages.getMessage("BM_ITEM_PRESENT"));
return AbMessages.getMessage("BM_ITEM_PRESENT");
}
public void clear() {
this.items.clear();
this.numberOfItems = 0;
}
protected void finalize() throws Throwable {
this.items.clear();
}
public Vectumerator getItems() {
return new Vectumerator(this.items.elements());
}
public String getMsg() {
if (this.msg == null)
return "";
String temp = this.msg;
setMsg(null);
return temp;
}
public int getNumberOfItems() {
return this.numberOfItems;
}
public String removeBookmarkItem(BookmarkItem theBI) {
if (this.items.containsKey(theBI.getBookmarkItemId())) {
this.items.remove(theBI.getBookmarkItemId());
this.numberOfItems--;
setMsg(AbMessages.getMessage("BM_ITEM_DELETED"));
return AbMessages.getMessage("BM_ITEM_DELETED");
}
setMsg(AbMessages.getMessage("BM_ITEM_NOT_PRESENT"));
return AbMessages.getMessage("BM_ITEM_NOT_PRESENT");
}
public String removeBookmarkItem(Long bookmarkItemId) {
if (this.items.containsKey(bookmarkItemId)) {
this.items.remove(bookmarkItemId);
this.numberOfItems--;
return AbMessages.getMessage("BM_ITEM_DELETED");
}
return AbMessages.getMessage("BM_ITEM_NOT_PRESENT");
}
private void setMsg(String newMsg) {
this.msg = newMsg;
}
}

View file

@ -0,0 +1,136 @@
package com.ablia.bookmark;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import java.io.Serializable;
public class BookmarkItem implements Serializable {
private static final long serialVersionUID = 1L;
private Object itemId;
private Class itemClass;
private ApplParmFull applParmFull;
private DBAdapter dbItem;
private String flgTipoBookmarkItem;
public static final String TIPO_RISORSA = "R";
public static final String TIPO_LINK = "L";
private String link;
private String itemDescription;
public BookmarkItem(Object anItemPrimaryKey, Class theItemClass, String theItemDescription, ApplParmFull theApplParmFull) {
setItemClass(theItemClass);
setApplParmFull(theApplParmFull);
setFflgTipoBookmarkItem("R");
setItemDescription(theItemDescription);
setItemId(anItemPrimaryKey);
}
public BookmarkItem(String link) {
setLink(link);
setFflgTipoBookmarkItem("L");
}
public ApplParmFull getApplParmFull() {
return this.applParmFull;
}
public Long getBookmarkItemId() {
if (getFlgTipoBookmarkItem().equals("L"))
return new Long((long)(String.valueOf(getFlgTipoBookmarkItem()) + getLink()).hashCode());
return new Long(
(long)(String.valueOf(getFlgTipoBookmarkItem()) + String.valueOf(getItemId()) + getItemClass().toString()).hashCode());
}
public DBAdapter getDbItem() {
if (this.dbItem == null && this.itemId != null)
try {
this.dbItem =
getItemClass().newInstance();
this.dbItem.setApFull(getApplParmFull());
this.dbItem.findByPrimaryKey(getItemId());
} catch (Exception e) {
e.printStackTrace();
}
return this.dbItem;
}
private Class getItemClass() {
return this.itemClass;
}
public String getItemDescription() {
return (this.itemDescription == null) ? "" : this.itemDescription;
}
public Object getItemId() {
return new Long((String)this.itemId);
}
public String getLink() {
return this.link;
}
private void setApplParmFull(ApplParmFull newApplParmFull) {
this.applParmFull = newApplParmFull;
}
private void setDbItem(DBAdapter newDbItem) {
this.dbItem = newDbItem;
}
private void setFflgTipoBookmarkItem(String newFflgTipoBookmarkItem) {
this.flgTipoBookmarkItem = newFflgTipoBookmarkItem;
}
private void setItemClass(Class newItemClass) {
this.itemClass = newItemClass;
}
private void setItemDescription(String newItemDescription) {
this.itemDescription = newItemDescription;
}
public void setItemId(Object newItemId) {
this.itemId = newItemId;
setDbItem(null);
}
private void setLink(String newLink) {
this.link = newLink;
}
public String getDescrizione() {
if (getFlgTipoBookmarkItem().equals("L"))
return getLink();
if (getFlgTipoBookmarkItem().equals("R"))
return getItemDescription();
return "???";
}
public String getFlgTipoBookmarkItem() {
return this.flgTipoBookmarkItem;
}
public String getTipoBookmarkItem() {
if (getFlgTipoBookmarkItem().equals("L"))
return "Link";
if (getFlgTipoBookmarkItem().equals("R"))
return "Risorsa";
return "???";
}
public String getItemClassType() {
return this.itemClass.toString().substring(6);
}
}

View file

@ -0,0 +1,79 @@
package com.ablia.cart;
public class AcCartObject {
private Class<CartItemIterface> itemClass;
private Object id;
private double quantity;
private boolean RM;
public AcCartObject() {}
public AcCartObject(Class theItemClass, Object theId, double theQuantity) {
setItemClass(theItemClass);
setId(theId);
setQuantity(theQuantity);
}
public AcCartObject(Class theItemClass, long theId, double theQuantity, boolean rm) {
setItemClass(theItemClass);
setId(new Long(theId));
setQuantity(theQuantity);
setRM(rm);
}
public AcCartObject(Class theItemClass, long theId, double theQuantity) {
setItemClass(theItemClass);
setId(new Long(theId));
setQuantity(theQuantity);
}
public AcCartObject(Class theItemClass, Object theId, double theQuantity, boolean rm) {
setItemClass(theItemClass);
setId(theId);
setQuantity(theQuantity);
setRM(rm);
}
public Object getId() {
return this.id;
}
public Class<CartItemIterface> getItemClass() {
return this.itemClass;
}
public double getQuantity() {
return this.quantity;
}
public void setId(Object newId) {
this.id = newId;
}
public void setId(long newId) {
this.id = new Long(newId);
}
public void setItemClass(Class<CartItemIterface> newItemClass) {
this.itemClass = newItemClass;
}
public void setQuantity(double newQuantity) {
this.quantity = newQuantity;
}
public String getItemsKey() {
return getId() + " " + getItemClass().toString();
}
public boolean isRM() {
return this.RM;
}
public void setRM(boolean rM) {
this.RM = rM;
}
}

View file

@ -0,0 +1,878 @@
package com.ablia.cart;
import com.ablia.common.Parm;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.util.DoubleOperator;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.Date;
import java.text.NumberFormat;
import java.util.Calendar;
import java.util.Enumeration;
import java.util.Hashtable;
public class Cart implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
private Hashtable<String, CartItem> items = null;
private long numberOfItems = 0L;
private Date dataNoleggioStart;
private Date dataNoleggioEnd;
private long flgCartType;
private String id_cart;
private boolean usePriceWithVat = true;
private long id_ivaDelivery;
private double aliquotaIvaDelivery;
private String descDiscountPerc;
private long discountPerc;
private String promotionCode;
private boolean deliveryCostSetted = false;
private ApplParmFull applParmFull;
private double deliveryWarnCost;
private double moreCost;
private String note;
private IvaGroup rri;
private IvaGroup rriCompleto;
private String giftAddress;
private long flgGift;
private long flgPayment;
private String giftText;
private long flgShipping;
private String descShipping;
private long flgStatus;
private double deliveryCost;
private String descMoreCost;
private long id_users;
private long flgPickup;
private double discount;
private String descDiscount;
public static String P_CART_WITH_VAT = "CART_WITH_VAT";
public static String P_DELIVERY_WARN_COST = "DELIV_WARN_COST";
public static String P_ID_IVA_CEE = "ID_IVA_CEE";
public static String P_DELIVERY_IVA_ID = "DELIV_IVA_ID";
public static String P_RESOMSG = "RESO_MSG";
public static String P_CHECKOUTMSG = "CHECKOUT_MSG";
public static String P_USERMSG = "USER_MSG";
public static String P_DELIVERY_COST = "DELIV_COST";
public static String P_USE_PRICE_WITH_VAT = "PRICE_W_VAT";
public static String P_DELIVERY_IVA_ALIQUOTA = "DELIV_IVA_ALIQUOTA";
public static String P_ID_IVA_EXTRACEE = "ID_IVA_EXTRACEE";
public static String P_LOSTPWDMSG = "LOSTPWD_MSG";
public static String P_MLISTMSG = "MLIST_MSG";
public static String P_MORE_COST = "MORE_COST";
public static String P_DELIVERY_FREE_ABOVE = "DELIVERY_FREE_ABOVE";
public static String P_PROCEDI_PAGAMENTO = "PROCEDI_PAGAMENTO";
public Cart() {
this.items = new Hashtable<>();
this.id_users = 0L;
createCartId();
}
public Cart(ApplParmFull theApplParmFull) {
this.items = new Hashtable<>();
this.id_users = 0L;
setApplParmFull(theApplParmFull);
createCartId();
}
@Deprecated
public ResParm add(AcCartObject l_aco) {
return add(l_aco, true);
}
public void clear() {
this.items.clear();
this.numberOfItems = 0L;
}
private void createCartId() {
if (getId_cart().isEmpty()) {
Calendar cal = Calendar.getInstance();
setId_cart(String.valueOf(cal.getTimeInMillis()));
}
}
protected void finalize() throws Throwable {
this.items.clear();
}
public ApplParmFull getApplParmFull() {
return this.applParmFull;
}
public double getDeliveryCost() {
return this.deliveryCost;
}
public boolean areAllItemsAvailable() {
Enumeration<CartItem> enu = getItems();
while (enu.hasMoreElements()) {
CartItem ci = enu.nextElement();
if (!ci.isItemAvailable())
return false;
}
return true;
}
public Enumeration<CartItem> getItems() {
return new Vectumerator<>(this.items.elements());
}
public long getNumberOfItems() {
return this.numberOfItems;
}
public double getQuantityOfItems() {
Enumeration<CartItem> enu = getItems();
double quantityOfItems = 0.0D;
while (enu.hasMoreElements()) {
CartItem row = enu.nextElement();
quantityOfItems += row.getQuantity();
}
return quantityOfItems;
}
public double xgetAvailItemQty(long theId, double l_dispo) {
Long itemPrimaryKey = new Long(theId);
if (this.items.containsKey(itemPrimaryKey)) {
CartItem cartItem = this.items.get(itemPrimaryKey);
DoubleOperator dispo = new DoubleOperator(l_dispo);
dispo.subtract(cartItem.getQuantity());
return dispo.getResult();
}
return l_dispo;
}
public ResParm quantityDecrement(AcCartObject l_aco) {
ResParm rp = new ResParm(true);
if (this.items.containsKey(l_aco.getItemsKey())) {
CartItem cartItem = this.items.get(l_aco.getItemsKey());
if (cartItem.getQuantity() - 1.0D == 0.0D) {
remove(l_aco);
} else {
cartItem.setQuantity(cartItem.getQuantity() - 1.0D);
}
}
setRri(null);
setRriCompleto(null);
return rp;
}
public ResParm quantityIncrement(AcCartObject l_aco, boolean checkAvail) {
ResParm rp = new ResParm(true);
if (this.items.containsKey(l_aco.getItemsKey())) {
CartItem cartItem = this.items.get(l_aco.getItemsKey());
if (checkAvail) {
double l_avail = cartItem.getAvailItemQty();
if (cartItem.getQuantity() >= l_avail) {
rp.setStatus(false);
rp.setMsg("QUANTITA' RICHIESTA NON DISPONIBILE");
} else {
cartItem.setQuantity(cartItem.getQuantity() + 1.0D);
}
} else {
cartItem.setQuantity(cartItem.getQuantity() + 1.0D);
}
} else {
CartItem newItem = new CartItem(l_aco, getApplParmFull(), 1.0D);
if (checkAvail) {
double l_avail = newItem.getAvailItemQty();
if (newItem.getQuantity() > l_avail) {
rp.setStatus(false);
rp.setMsg("QUANTITA' RICHIESTA NON DISPONIBILE");
} else {
this.items.put(l_aco.getItemsKey(), newItem);
this.numberOfItems++;
}
} else {
this.items.put(l_aco.getItemsKey(), newItem);
this.numberOfItems++;
}
}
setRri(null);
setRriCompleto(null);
return rp;
}
public void remove(AcCartObject l_aco) {
if (this.items.containsKey(l_aco.getItemsKey())) {
this.items.remove(l_aco.getItemsKey());
this.numberOfItems--;
setRri(null);
setRriCompleto(null);
}
}
public void setApplParmFull(ApplParmFull newApplParmFull) {
this.applParmFull = newApplParmFull;
}
public void setDeliveryCost(double newDeliveryCost) {
this.deliveryCost = newDeliveryCost;
}
public double getTotPrice() {
DoubleOperator temp = new DoubleOperator();
Enumeration<CartItem> enu = getItems();
while (enu.hasMoreElements()) {
CartItem row = enu.nextElement();
temp.setScale(4, 5);
temp.add(row.getTotPrice(getId_users()));
}
return temp.getResult();
}
public double getScontrinoTotPriceVAT() {
DoubleOperator temp = new DoubleOperator();
Enumeration<CartItem> enu = getItems();
while (enu.hasMoreElements()) {
CartItem row = enu.nextElement();
temp.setScale(4, 5);
temp.add(row.getTotPriceWVat(getId_users()));
}
return temp.getResult();
}
public double getImportoIvaTotale() {
return getRriCompleto().getTotIva();
}
public double getImportoIva() {
return getRri().getTotIva();
}
public double getTotPriceNoSale() {
DoubleOperator temp = new DoubleOperator();
Enumeration<CartItem> enu = getItems();
while (enu.hasMoreElements()) {
CartItem row = enu.nextElement();
if (!row.isSale()) {
temp.setScale(4, 5);
temp.add(row.getTotPrice(getId_users()));
}
}
return temp.getResult();
}
public double getScontrinoTotPriceNoSale() {
DoubleOperator temp = new DoubleOperator();
Enumeration<CartItem> enu = getItems();
while (enu.hasMoreElements()) {
CartItem row = enu.nextElement();
if (!row.isSale()) {
temp.setScale(4, 5);
temp.add(row.getTotPriceWVat(getId_users()));
}
}
return temp.getResult();
}
public double getTotPriceWDiscount() {
if (getDiscountPerc() == 0L)
return getTotPrice();
DoubleOperator temp = new DoubleOperator(getTotPrice());
temp.setScale(4, 5);
temp.subtract(getTotDiscount());
return temp.getResult();
}
public double getScontrinoTotPriceWDiscount() {
if (getDiscountPerc() == 0L)
return getScontrinoTotPriceVAT();
DoubleOperator temp = new DoubleOperator(getScontrinoTotPriceVAT());
temp.setScale(4, 5);
temp.subtract(getScontrinoTotDiscount());
return temp.getResult();
}
public double getTotDiscount() {
if (getDiscountPerc() == 0L)
return 0.0D;
DoubleOperator temp = new DoubleOperator(getTotPriceNoSale());
temp.setScale(4, 5);
temp.multiply(getDiscountPerc());
temp.divide(100.0F);
return temp.getResult();
}
public double getScontrinoTotDiscount() {
if (getDiscountPerc() == 0L)
return 0.0D;
DoubleOperator temp = new DoubleOperator(getScontrinoTotPriceNoSale());
temp.setScale(4, 5);
temp.multiply(getDiscountPerc());
temp.divide(100.0F);
return temp.getResult();
}
public double getTotCart() {
DoubleOperator temp = new DoubleOperator(getTotPriceWDiscount());
temp.setScale(4, 5);
temp.add(getDeliveryCost());
temp.add(getDeliveryWarnCost());
temp.add(getMoreCost());
temp.subtract(getDiscount());
return temp.getResult();
}
public double getTotCartVAT() {
DoubleOperator temp = new DoubleOperator(getTotCart());
temp.setScale(4, 5);
temp.add(getImportoIvaTotale());
return temp.getResult();
}
public double getTotPriceVAT() {
DoubleOperator temp = new DoubleOperator(getTotPrice());
temp.setScale(4, 5);
temp.add(getImportoIva());
return temp.getResult();
}
public String getId_cart() {
return (this.id_cart == null) ? "" : this.id_cart;
}
public void setId_cart(String id_cart) {
this.id_cart = id_cart;
}
public boolean isDeliveryCostSetted() {
return this.deliveryCostSetted;
}
public void setDeliveryCostSetted(boolean deliveryCostSetted) {
this.deliveryCostSetted = deliveryCostSetted;
}
public String getDescDiscountPerc() {
return (this.descDiscountPerc == null) ? "" : this.descDiscountPerc;
}
public void setDescDiscountPerc(String descDiscount) {
this.descDiscountPerc = descDiscount;
}
public long getDiscountPerc() {
return this.discountPerc;
}
public void setDiscountPerc(long discount) {
this.discountPerc = discount;
}
public String getPromotionCode() {
return (this.promotionCode == null) ? "" : this.promotionCode;
}
public void setPromotionCode(String promotionCode) {
this.promotionCode = promotionCode;
}
public IvaGroup getRri() {
Enumeration<CartItem> vecRighe = getItems();
this.rri = new IvaGroup();
while (vecRighe.hasMoreElements()) {
CartItem row = vecRighe.nextElement();
double imponibile = row.getTotPrice(getId_users());
this.rri.addCartRowRM(imponibile, row.getIvaItemId(getId_users()), row.getIvaAliquota(getId_users()), row.isRM(), row.getCost());
}
return this.rri;
}
public boolean isUsePriceWithVat() {
return this.usePriceWithVat;
}
public void setRriCompleto(IvaGroup rriCompleto) {
this.rriCompleto = rriCompleto;
}
public void setRri(IvaGroup rri) {
this.rri = rri;
}
public IvaGroup getRriCompleto() {
Enumeration<CartItem> vecRighe = getItems();
this.rriCompleto = new IvaGroup();
while (vecRighe.hasMoreElements()) {
CartItem row = vecRighe.nextElement();
double imponibile = row.getTotPrice(getId_users());
this.rriCompleto.addCartRowRM(imponibile, row.getIvaItemId(getId_users()), row.getIvaAliquota(getId_users()), row.isRM(),
row.getCost());
}
this.rriCompleto.addCartRowRM(getDeliveryCost(), getId_ivaDelivery(), getAliquotaIvaDelivery(), false, 0.0D);
this.rriCompleto.addCartRowRM(getDeliveryWarnCost(), getId_ivaDelivery(), getAliquotaIvaDelivery(), false, 0.0D);
this.rriCompleto.addCartRowRM(getMoreCost(), getId_ivaDelivery(), getAliquotaIvaDelivery(), false, 0.0D);
return this.rriCompleto;
}
public long getId_ivaDelivery() {
return (this.id_ivaDelivery == 0L) ? 1L : this.id_ivaDelivery;
}
public void setId_ivaDelivery(long id_ivaDelivery) {
this.id_ivaDelivery = id_ivaDelivery;
}
public double getAliquotaIvaDelivery() {
return this.aliquotaIvaDelivery;
}
public void setAliquotaIvaDelivery(double aliquotaIvaDelivery) {
this.aliquotaIvaDelivery = aliquotaIvaDelivery;
}
public double getMoreCost() {
return this.moreCost;
}
public double getMoreCostWVat() {
return DBAdapter.conIva(this.moreCost, getAliquotaIvaDelivery());
}
public void setMoreCost(double moreCost) {
this.moreCost = moreCost;
}
public long getFlgPayment() {
return this.flgPayment;
}
public void setFlgPayment(long flgPayment) {
this.flgPayment = flgPayment;
}
public String getDescMoreCost() {
return (this.descMoreCost == null) ? "" : this.descMoreCost.trim();
}
public void setDescMoreCost(String moreCostDescription) {
this.descMoreCost = moreCostDescription;
}
public double getAvailItemQty(long theId, double l_dispo) {
Long itemPrimaryKey = new Long(theId);
if (this.items.containsKey(itemPrimaryKey)) {
CartItem cartItem = this.items.get(itemPrimaryKey);
DoubleOperator dispo = new DoubleOperator(l_dispo);
dispo.subtract(cartItem.getQuantity());
return dispo.getResult();
}
return l_dispo;
}
public void setUsePriceWithVat(boolean usePriceWithVat) {
this.usePriceWithVat = usePriceWithVat;
}
public String getGiftAddress() {
return (this.giftAddress == null) ? "" : this.giftAddress.trim();
}
public void setGiftAddress(String giftAddress) {
this.giftAddress = giftAddress;
}
public long getFlgGift() {
return this.flgGift;
}
public void setFlgGift(long flgGift) {
this.flgGift = flgGift;
}
public String getGiftText() {
return (this.giftText == null) ? "" : this.giftText.trim();
}
public void setGiftText(String giftText) {
this.giftText = giftText;
}
public static final void initCartParms(ApplParmFull ap) {
if (ap != null) {
Parm bean = new Parm(ap);
String l_tipoParm = "CART";
bean.findByCodice(P_PROCEDI_PAGAMENTO);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_PROCEDI_PAGAMENTO);
bean.setDescrizione(P_PROCEDI_PAGAMENTO);
bean.setFlgTipo(1L);
bean.setNota("Quando registro l'ordine, imposta il procedi con il pagamento:0:no,1:si");
bean.save();
bean.findByCodice(P_USE_PRICE_WITH_VAT);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_USE_PRICE_WITH_VAT);
bean.setDescrizione(P_USE_PRICE_WITH_VAT);
bean.setFlgTipo(1L);
bean.setNota("Prezzi con iva:0:no,1:si");
bean.save();
bean.findByCodice(P_CHECKOUTMSG);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_CHECKOUTMSG);
bean.setDescrizione(P_CHECKOUTMSG);
bean.setFlgTipo(0L);
if (bean.getTesto().isEmpty())
bean.setTesto("mailMessage/checkOut.html");
bean.setNota("Path relativo a docbase");
bean.save();
bean.findByCodice(P_USERMSG);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_USERMSG);
bean.setDescrizione(P_USERMSG);
bean.setFlgTipo(0L);
if (bean.getTesto().isEmpty())
bean.setTesto("mailMessage/userMsg.html");
bean.setNota("Path relativo a docbase");
bean.save();
bean.findByCodice(P_LOSTPWDMSG);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_LOSTPWDMSG);
bean.setDescrizione(P_LOSTPWDMSG);
bean.setFlgTipo(0L);
if (bean.getTesto().isEmpty())
bean.setTesto("/mailMessage/lostPwd.html");
bean.setNota("Path relativo a docbase");
bean.save();
bean.findByCodice(P_MLISTMSG);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_MLISTMSG);
bean.setDescrizione(P_MLISTMSG);
bean.setFlgTipo(0L);
if (bean.getTesto().isEmpty())
bean.setTesto("/relativo a docbasemailMessage/ml.txt");
bean.setNota("Path relativo a docbase. Registrazione Mailing List");
bean.save();
bean.findByCodice(P_RESOMSG);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_RESOMSG);
bean.setDescrizione(P_RESOMSG);
bean.setFlgTipo(0L);
if (bean.getTesto().isEmpty())
bean.setTesto("mailMessage/reso.html");
bean.setNota("Path relativo a docbase. Reso merce");
bean.save();
bean.findByCodice(P_DELIVERY_COST);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_DELIVERY_COST);
bean.setDescrizione(P_DELIVERY_COST);
bean.setFlgTipo(1L);
bean.setNota("Costo spedizione standard.");
bean.save();
bean.findByCodice(P_CART_WITH_VAT);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_CART_WITH_VAT);
bean.setDescrizione(P_CART_WITH_VAT);
bean.setFlgTipo(5L);
bean.setNota("CARRELLO SENZA EVIDENZA DELL'IVA.");
bean.save();
bean.findByCodice(P_DELIVERY_FREE_ABOVE);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_DELIVERY_FREE_ABOVE);
bean.setDescrizione(P_DELIVERY_FREE_ABOVE);
bean.setFlgTipo(1L);
if (bean.getId_parm() == 0L)
bean.setNumero(9000000.0D);
bean.setNota("TOT CARRELLO (COMPRESO IVA) OLTRE IL QUALE LA SPEDIZIONE DIVENTA GRATIS");
bean.save();
bean.findByCodice(P_DELIVERY_WARN_COST);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_DELIVERY_WARN_COST);
bean.setDescrizione(P_DELIVERY_WARN_COST);
bean.setFlgTipo(1L);
bean.setNota("Costo avviso spedizione standard.");
bean.save();
bean.findByCodice(P_MORE_COST);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_MORE_COST);
bean.setDescrizione(P_MORE_COST);
bean.setFlgTipo(1L);
bean.setNota("Costo aggiuntivo tipo per contrassegno.");
bean.save();
bean.findByCodice(P_DELIVERY_IVA_ALIQUOTA);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_DELIVERY_IVA_ALIQUOTA);
bean.setDescrizione(P_DELIVERY_IVA_ALIQUOTA);
bean.setFlgTipo(1L);
bean.setNota("Aliquota standard spese spedizione. DEVE COINCIDERE CON LA PERCENTUALE IVA DI DELIVERY_IVA_ID.");
bean.save();
bean.findByCodice(P_DELIVERY_IVA_ID);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_DELIVERY_IVA_ID);
bean.setDescrizione(P_DELIVERY_IVA_ID);
bean.setFlgTipo(1L);
bean.setNota("ID iva aliquota spese di spedizione. VERIFICA DELIVERY_IVA_ALIQUOTA CHE LA PERCENTUALE COINCIDA.");
bean.save();
bean.findByCodice(P_ID_IVA_CEE);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_ID_IVA_CEE);
bean.setDescrizione(P_ID_IVA_CEE);
bean.setFlgTipo(1L);
bean.setNota("ID iva aliquota articoli in caso di esenzione per paese CEE.");
bean.save();
bean.findByCodice(P_ID_IVA_EXTRACEE);
bean.setFlgAdmin(1L);
bean.setTipoParm(l_tipoParm);
bean.setCodice(P_ID_IVA_EXTRACEE);
bean.setDescrizione(P_ID_IVA_EXTRACEE);
bean.setFlgTipo(1L);
bean.setNota("ID iva aliquota articoli in caso di esenzione per paese EXTRA-CEE.");
bean.save();
}
}
public long getFlgShipping() {
return this.flgShipping;
}
public void setFlgShipping(long flgShipping) {
this.flgShipping = flgShipping;
}
public String getDescShipping() {
return (this.descShipping == null) ? "" : this.descShipping.trim();
}
public void setDescShipping(String descShipping) {
this.descShipping = descShipping;
}
public long getFlgStatus() {
return this.flgStatus;
}
public void setFlgStatus(long flgStatus) {
this.flgStatus = flgStatus;
}
public double getDeliveryWarnCost() {
return this.deliveryWarnCost;
}
public double getDeliveryWarnCostWVat() {
return DBAdapter.conIva(this.deliveryWarnCost, getAliquotaIvaDelivery());
}
public void setDeliveryWarnCost(double deliveryWarnCost) {
this.deliveryWarnCost = deliveryWarnCost;
}
public String getNote() {
return (this.note == null) ? "" : this.note.trim();
}
public void setNote(String note) {
this.note = note;
}
public long getId_users() {
return this.id_users;
}
public void setId_users(long l_id_users) {
if (l_id_users != this.id_users) {
setRri(null);
setRriCompleto(null);
}
this.id_users = l_id_users;
}
public boolean hasItemKey(String l_itemKey) {
if (l_itemKey == null || l_itemKey.isEmpty())
return false;
if (this.items.containsKey(l_itemKey))
return true;
return false;
}
public long getFlgPickup() {
return this.flgPickup;
}
public void setFlgPickup(long flgPickup) {
this.flgPickup = flgPickup;
}
public ResParm add(AcCartObject l_aco, boolean checkAvail) {
ResParm rp = new ResParm(true);
if (this.items.containsKey(l_aco.getItemsKey())) {
CartItem cartItem = this.items.get(l_aco.getItemsKey());
if (checkAvail) {
double l_avail = cartItem.getAvailItemQty();
if (l_aco.getQuantity() > l_avail) {
rp.setStatus(false);
rp.setMsg("QUANTITA' RICHIESTA NON DISPONIBILE");
cartItem.setQuantity(l_avail);
} else {
cartItem.setQuantity(l_aco.getQuantity());
}
} else {
cartItem.setQuantity(l_aco.getQuantity());
}
cartItem.setDbItem(null);
if (cartItem.getQuantity() == 0.0D) {
this.items.remove(l_aco.getItemsKey());
} else {
this.items.put(l_aco.getItemsKey(), cartItem);
}
} else {
CartItem newItem = new CartItem(l_aco, getApplParmFull(), l_aco.getQuantity());
if (checkAvail) {
double l_avail = newItem.getAvailItemQty();
if (l_aco.getQuantity() > l_avail) {
rp.setStatus(false);
rp.setMsg("QUANTITA' RICHIESTA NON DISPONIBILE");
} else {
newItem.setRM(l_aco.isRM());
this.items.put(l_aco.getItemsKey(), newItem);
this.numberOfItems++;
}
} else {
newItem.setRM(l_aco.isRM());
this.items.put(l_aco.getItemsKey(), newItem);
this.numberOfItems++;
}
}
setRri(null);
setRriCompleto(null);
return rp;
}
public Date getDataNoleggioStart() {
return this.dataNoleggioStart;
}
public void setDataNoleggioStart(Date dataHireStart) {
this.dataNoleggioStart = dataHireStart;
}
public Date getDataNoleggioEnd() {
return this.dataNoleggioEnd;
}
public void setDataNoleggioEnd(Date dataHireEnd) {
this.dataNoleggioEnd = dataHireEnd;
}
public long getFlgCartType() {
return this.flgCartType;
}
public void setFlgCartType(long flgCartType) {
this.flgCartType = flgCartType;
}
public double getDiscount() {
return this.discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
public String getDescDiscount() {
return (this.descDiscount == null) ? "" : this.descDiscount;
}
public void setDescDiscount(String descDiscount) {
this.descDiscount = descDiscount;
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
public CartItem getItem(String itemKey) {
if (this.items.containsKey(itemKey))
return this.items.get(itemKey);
return null;
}
public double getDeliveryCostWVat() {
return DBAdapter.conIva(getDeliveryCost(), getAliquotaIvaDelivery());
}
public double getScontrinoTotCartVAT() {
DoubleOperator temp = new DoubleOperator(getScontrinoTotPriceWDiscount());
temp.setScale(4, 5);
temp.add(getDeliveryCostWVat());
temp.add(getDeliveryWarnCostWVat());
temp.add(getMoreCostWVat());
temp.subtract(getDiscount());
return temp.getResult();
}
public NumberFormat getNf2() {
return getApplParmFull().getAp().getNf2();
}
public NumberFormat getNf() {
return getNf2();
}
}

View file

@ -0,0 +1,234 @@
package com.ablia.cart;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.util.DoubleOperator;
import java.io.Serializable;
import java.text.NumberFormat;
import java.util.Locale;
public class CartItem implements CartItemIterface, Serializable {
private NumberFormat nf2;
private boolean RM;
private static final long serialVersionUID = 1L;
private String cartItemTag;
private Object itemId;
private double quantity;
private Class<CartItemIterface> itemClass;
private ApplParmFull applParmFull;
private DBAdapter dbItem;
public CartItem() {
this.quantity = 1.0D;
}
public CartItem(AcCartObject l_aco, ApplParmFull theApplParmFull, double newQuantity) {
setItemId(l_aco.getId());
setQuantity(newQuantity);
setItemClass(l_aco.getItemClass());
setApplParmFull(theApplParmFull);
try {
CartItemIterface bean = getItemClass().newInstance();
this.cartItemTag = bean.getCartItemTag();
} catch (Exception e) {
e.printStackTrace();
}
}
public ApplParmFull getApplParmFull() {
return this.applParmFull;
}
public DBAdapter getDbItem() {
if (this.dbItem == null && this.itemId != null)
try {
DBAdapter bean = (DBAdapter)getItemClass().newInstance();
bean.setApFull(getApplParmFull());
bean.findByPrimaryKey(getItemId());
if (bean.getDBState() == 1)
this.dbItem = bean;
} catch (Exception e) {
e.printStackTrace();
}
try {
return (this.dbItem == null) ? (DBAdapter)getItemClass().newInstance() : this.dbItem;
} catch (Exception e) {
e.printStackTrace();
return this.dbItem;
}
}
public Class<CartItemIterface> getItemClass() {
return this.itemClass;
}
public Object getItemId() {
return this.itemId;
}
public double getQuantity() {
return this.quantity;
}
public void setApplParmFull(ApplParmFull newApplParmFull) {
this.applParmFull = newApplParmFull;
}
public void setDbItem(DBAdapter newDbItem) {
this.dbItem = newDbItem;
}
public void setItemClass(Class<CartItemIterface> newItemClass) {
this.itemClass = newItemClass;
}
public void setItemId(Object newItemId) {
this.itemId = newItemId;
setDbItem(null);
}
public void setQuantity(double newQuantity) {
this.quantity = newQuantity;
}
public double getPriceWVat() {
return ((CartItemIterface)getDbItem()).getPriceWVat();
}
public double getPrice() {
return ((CartItemIterface)getDbItem()).getPrice();
}
public boolean isItemAvailable() {
if (getQuantity() <= getAvailItemQty())
return true;
return false;
}
public double getTotPrice() {
DoubleOperator temp = new DoubleOperator(getQuantity());
temp.setScale(4, 5);
temp.multiply(getPrice());
return temp.getResult();
}
public double getAvailItemQty() {
double l_dispo = 0.0D;
if (this.itemId != null) {
this.dbItem = null;
l_dispo = ((CartItemIterface)getDbItem()).getAvail();
return l_dispo;
}
return l_dispo;
}
public double getAvail() {
return ((CartItemIterface)getDbItem()).getAvail();
}
public String getCartItemDescriptionUrl() {
return ((CartItemIterface)getDbItem()).getCartItemDescriptionUrl();
}
public String getCartItemDescription3(String lang) {
return ((CartItemIterface)getDbItem()).getCartItemDescription3(lang);
}
public String getCartItemDescription2(String lang) {
return ((CartItemIterface)getDbItem()).getCartItemDescription2(lang);
}
public String getCartItemImage() {
return ((CartItemIterface)getDbItem()).getCartItemImage();
}
public double getCost() {
return ((CartItemIterface)getDbItem()).getCost();
}
public double getDiscount() {
return ((CartItemIterface)getDbItem()).getDiscount();
}
public boolean isSale() {
return ((CartItemIterface)getDbItem()).isSale();
}
public double getIvaAliquota(long l_id_users) {
return ((CartItemIterface)getDbItem()).getIvaAliquota(l_id_users);
}
public Object getId_iva() {
return null;
}
public boolean isRM() {
return this.RM;
}
public long getIvaItemId(long l_id_users) {
return ((CartItemIterface)getDbItem()).getIvaItemId(l_id_users);
}
public long getCartItemUdm() {
return ((CartItemIterface)getDbItem()).getCartItemUdm();
}
public double getPrice(long l_id_users) {
return ((CartItemIterface)getDbItem()).getPrice(l_id_users);
}
public String getCartItemDescription(String lang) {
return ((CartItemIterface)getDbItem()).getCartItemDescription(lang);
}
public double getTotPrice(long l_id_users) {
DoubleOperator temp = new DoubleOperator(getQuantity());
temp.setScale(4, 5);
temp.multiply(getPrice(l_id_users));
return temp.getResult();
}
public String getCartItemTag() {
return (this.cartItemTag == null) ? "" : this.cartItemTag.trim();
}
public void setRM(boolean rM) {
this.RM = rM;
}
public NumberFormat getNf() {
if (this.nf2 == null) {
this.nf2 = NumberFormat.getInstance(Locale.ITALY);
this.nf2.setMaximumFractionDigits(2);
this.nf2.setMinimumFractionDigits(2);
}
return this.nf2;
}
public double getTotPriceWVat() {
DoubleOperator temp = new DoubleOperator(getQuantity());
temp.setScale(4, 5);
temp.multiply(getPriceWVat());
return temp.getResult();
}
public double getTotPriceWVat(long l_id_users) {
DoubleOperator temp = new DoubleOperator(getQuantity());
temp.setScale(4, 5);
temp.multiply(getPriceWVat(l_id_users));
return temp.getResult();
}
public double getPriceWVat(long l_id_users) {
return ((CartItemIterface)getDbItem()).getPriceWVat(l_id_users);
}
}

View file

@ -0,0 +1,41 @@
package com.ablia.cart;
public interface CartItemIterface {
Object getItemId();
double getPrice();
double getPriceWVat();
boolean isSale();
boolean isRM();
double getDiscount();
double getCost();
String getCartItemDescriptionUrl();
String getCartItemDescription2(String paramString);
String getCartItemDescription3(String paramString);
long getCartItemUdm();
double getAvail();
double getIvaAliquota(long paramLong);
long getIvaItemId(long paramLong);
String getCartItemImage();
String getCartItemDescription(String paramString);
String getCartItemTag();
double getPrice(long paramLong);
double getPriceWVat(long paramLong);
}

View file

@ -0,0 +1,29 @@
package com.ablia.cart;
public class CartStatus {
private long status = 0L;
public static final long RES_ADD_ITEM_OK = 21L;
public static final long RES_ADD_ITEM_KO = 22L;
public static long ST_CHECK_OUT_ERROR = 9L;
public static long ST_CHECK_OUT_OK = 1L;
public static long ST_CHECK_OUT_OK_NO_MAIL = 2L;
public static long ST_LOSTPWD_SEND_ERROR = 12L;
public static long ST_OK = 0L;
public static long ST_LOSTPWD_SEND_OK = 10L;
public long getStatus() {
return this.status;
}
public void setStatus(long status) {
this.status = status;
}
}

View file

@ -0,0 +1,105 @@
package com.ablia.cart;
import com.ablia.util.DoubleOperator;
import java.util.Enumeration;
import java.util.Hashtable;
public class IvaGroup {
private Hashtable ri;
private DoubleOperator totImponibileDO;
private double importoRM;
public void addCartRow(double imponibile, long l_iva, double l_aliquota, boolean isRM) {
Object theKey = new Long(l_iva);
if (!isRM) {
IvaGroupItem rii;
if (getRi().containsKey(theKey)) {
rii = (IvaGroupItem)getRi().get(theKey);
} else {
rii = new IvaGroupItem(l_iva, l_aliquota);
}
rii.addImporto(imponibile);
getTotImponibileDO().add(imponibile);
getRi().put(theKey, rii);
} else {
synchronized (this) {
DoubleOperator dop = new DoubleOperator(this.importoRM);
dop.add(imponibile);
this.importoRM = dop.getResult();
}
}
}
public Enumeration elements() {
return getRi().elements();
}
private Hashtable getRi() {
if (this.ri == null)
this.ri = new Hashtable();
return this.ri;
}
public double getImportoRM() {
return this.importoRM;
}
public void setImportoRM(double importoRM) {
this.importoRM = importoRM;
}
public void addCartRowRM(double imponibile, long l_iva, double l_aliquota, boolean isRM, double costo) {
Object theKey = new Long(l_iva);
if (!isRM) {
IvaGroupItem rii;
if (getRi().containsKey(theKey)) {
rii = (IvaGroupItem)getRi().get(theKey);
} else {
rii = new IvaGroupItem(l_iva, l_aliquota);
}
rii.addImporto(imponibile);
getTotImponibileDO().add(imponibile);
getRi().put(theKey, rii);
} else {
synchronized (this) {
IvaGroupItem rii;
DoubleOperator dop = new DoubleOperator(this.importoRM);
dop.add(imponibile);
this.importoRM = dop.getResult();
double l_imponibile = 0.0D;
if (getRi().containsKey(theKey)) {
rii = (IvaGroupItem)getRi().get(theKey);
} else {
rii = new IvaGroupItem(l_iva, l_aliquota);
}
rii.addImporto(l_imponibile);
getTotImponibileDO().add(l_imponibile);
getRi().put(theKey, rii);
}
}
}
private DoubleOperator getTotImponibileDO() {
if (this.totImponibileDO == null)
this.totImponibileDO = new DoubleOperator();
return this.totImponibileDO;
}
public double getTotImponibile() {
return getTotImponibileDO().getResult();
}
public double getTotIva() {
Enumeration<IvaGroupItem> enu = getRi().elements();
DoubleOperator dIva = new DoubleOperator();
dIva.setScale(4, 5);
while (enu.hasMoreElements()) {
IvaGroupItem row = enu.nextElement();
dIva.add(row.getImportoIvaCalc());
}
dIva.setScale(2, 5);
return dIva.getResult();
}
}

View file

@ -0,0 +1,56 @@
package com.ablia.cart;
import com.ablia.util.DoubleOperator;
public class IvaGroupItem {
private long iva;
private double aliquota;
private double imponibile;
public IvaGroupItem(long l_iva, double l_aliquota) {
setIva(l_iva);
setAliquota(l_aliquota);
}
public void addImporto(double l_imponibile) {
DoubleOperator dImponibile = new DoubleOperator(getImponibile());
dImponibile.add(l_imponibile);
dImponibile.setScale(2, 5);
setImponibile(dImponibile.getResult());
}
public double getImponibile() {
return this.imponibile;
}
public void setImponibile(double d) {
this.imponibile = d;
}
public long getIva() {
return this.iva;
}
public double getImportoIvaCalc() {
DoubleOperator temp = new DoubleOperator(getImponibile());
temp.setScale(4, 5);
temp.multiply(getAliquota());
temp.divide(100.0F);
temp.setScale(2, 5);
return temp.getResult();
}
public void setIva(long iva) {
this.iva = iva;
}
public double getAliquota() {
return this.aliquota;
}
public void setAliquota(double aliquota) {
this.aliquota = aliquota;
}
}

View file

@ -0,0 +1,15 @@
package com.ablia.cloudmsg;
public class ApnsJson {
private HeadersJson headers;
public HeadersJson getHeaders() {
if (this.headers == null)
this.headers = new HeadersJson();
return this.headers;
}
public void setHeaders(HeadersJson headers) {
this.headers = headers;
}
}

View file

@ -0,0 +1,51 @@
package com.ablia.cloudmsg;
public class CloudMsgJson {
private MsgJson notification;
private MsgJson data;
private String to;
private ApnsJson apns;
public CloudMsgJson(MsgJson notification, MsgJson data, String token) {
this.notification = notification;
this.data = data;
this.to = token;
}
public CloudMsgJson() {}
public MsgJson getNotification() {
return this.notification;
}
public void setNotification(MsgJson notification) {
this.notification = notification;
}
public MsgJson getData() {
return this.data;
}
public void setData(MsgJson data) {
this.data = data;
}
public String getTo() {
return this.to;
}
public void setTo(String to) {
this.to = to;
}
public ApnsJson getApns() {
return this.apns;
}
public void setApns(ApnsJson apns) {
this.apns = apns;
}
}

View file

@ -0,0 +1,16 @@
package com.ablia.cloudmsg;
import com.google.gson.annotations.SerializedName;
public class HeadersJson {
@SerializedName("apns-priority")
private String apnspriority;
public String getApnspriority() {
return (this.apnspriority == null) ? "10" : this.apnspriority.trim();
}
public void setApnspriority(String apnspriority) {
this.apnspriority = apnspriority;
}
}

View file

@ -0,0 +1,61 @@
package com.ablia.cloudmsg;
public class MsgJson {
private String notificationType;
private String title;
private String body;
private String sound;
private String priority;
public MsgJson(String notificationType, String title, String body) {
this.notificationType = notificationType;
this.title = title;
this.body = body;
}
public MsgJson() {}
public String getNotificationType() {
return this.notificationType;
}
public void setNotificationType(String notificationType) {
this.notificationType = notificationType;
}
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
public String getBody() {
return this.body;
}
public void setBody(String body) {
this.body = body;
}
public String getSound() {
return (this.sound == null) ? "default" : this.sound.trim();
}
public void setSound(String sound) {
this.sound = sound;
}
public String getPriority() {
return (this.priority == null) ? "high" : this.priority.trim();
}
public void setPriority(String priprity) {
this.priority = priprity;
}
}

View file

@ -0,0 +1,61 @@
package com.ablia.cloudmsg;
import com.google.gson.Gson;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
public class PushNotificationService {
public PushNotificationService(String serverkey) {
setFirebaseServerkey(serverkey);
}
private final String FIREBASE_API_URL = "https://fcm.googleapis.com/fcm/send";
private String firebaseServerkey;
public void sendPushNotification(List<String> tokens, MsgJson notifica, MsgJson data) {
tokens.forEach(token -> {
System.out.println("\nCalling fcm Server >>>>>>>");
String response = callToFcmServer(token, paramMsgJson1, paramMsgJson2);
System.out.println("Got response from fcm Server : " + response + "\n\n");
});
}
private String callToFcmServer(String token, MsgJson notifica, MsgJson data) {
CloudMsgJson cmj = new CloudMsgJson(notifica, data, token);
StringBuilder result = new StringBuilder();
try {
CloseableHttpClient closeableHttpClient = HttpClientBuilder.create().build();
HttpPost request = new HttpPost("https://fcm.googleapis.com/fcm/send");
request.setHeader("Content-Type", "application/json");
request.setHeader("Authorization", "key=" + getFirebaseServerkey());
Gson gson = new Gson();
StringEntity params = new StringEntity(gson.toJson(cmj));
request.setEntity((HttpEntity)params);
HttpResponse resp = closeableHttpClient.execute((HttpUriRequest)request);
String content = EntityUtils.toString(resp.getEntity());
int statusCode = resp.getStatusLine().getStatusCode();
result.append("Status Code: " + statusCode);
result.append("\nstatusCode = " + statusCode);
result.append("\ncontent = " + content);
} catch (Exception e) {
e.printStackTrace();
}
return result.toString();
}
public String getFirebaseServerkey() {
return this.firebaseServerkey;
}
public void setFirebaseServerkey(String firebaseServerkey) {
this.firebaseServerkey = firebaseServerkey;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,32 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class AccessCR extends CRAdapter {
private String id_access;
private long flgTabella = -1L;
public AccessCR() {}
public AccessCR(ApplParmFull newAp) {
super(newAp);
}
public String getId_access() {
return this.id_access;
}
public void setId_access(String id_access) {
this.id_access = id_access;
}
public long getFlgTabella() {
return this.flgTabella;
}
public void setFlgTabella(long flgTabella) {
this.flgTabella = flgTabella;
}
}

View file

@ -0,0 +1,137 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class AccessDitta extends DBAdapter implements Serializable {
private static final long serialVersionUID = -1022126863968745800L;
private long id_accessDitta;
private String id_access;
private String attr1Maiuscoli;
private String attrMaiuscoli;
private String attrMinuscoli;
private String descrizione;
private long flgSafeUpdate;
private Access access;
public AccessDitta(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public AccessDitta() {}
public void setId_accessDitta(long newId_accessDitta) {
this.id_accessDitta = newId_accessDitta;
}
public void setId_access(String newId_access) {
this.id_access = newId_access;
setAccess(null);
}
public void setAttr1Maiuscoli(String newAttr1Maiuscoli) {
this.attr1Maiuscoli = newAttr1Maiuscoli;
}
public void setAttrMaiuscoli(String newAttrMaiuscoli) {
this.attrMaiuscoli = newAttrMaiuscoli;
}
public void setAttrMinuscoli(String newAttrMinuscoli) {
this.attrMinuscoli = newAttrMinuscoli;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public void setFlgSafeUpdate(long newFlgSafeUpdate) {
this.flgSafeUpdate = newFlgSafeUpdate;
}
public long getId_accessDitta() {
return this.id_accessDitta;
}
public String getId_access() {
return (this.id_access == null) ? "" : this.id_access.trim();
}
public String getAttr1Maiuscoli() {
return (this.attr1Maiuscoli == null) ? "" : this.attr1Maiuscoli.trim();
}
public String getAttrMaiuscoli() {
return (this.attrMaiuscoli == null) ? "" : this.attrMaiuscoli.trim();
}
public String getAttrMinuscoli() {
return (this.attrMinuscoli == null) ? "" : this.attrMinuscoli.trim();
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione.trim();
}
public long getFlgSafeUpdate() {
return this.flgSafeUpdate;
}
public void setAccess(Access newAccess) {
this.access = newAccess;
}
public Access getAccess() {
this.access = (Access)getSecondaryObject(
this.access,
Access.class, getId_access());
return this.access;
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator<? extends DBAdapter> findByCR(AccessDittaCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from ACCESS_DITTA AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
if (!CR.getSearchTxt().trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
StringBuffer txt = new StringBuffer("(");
while (st.hasMoreTokens()) {
String token = st.nextToken();
txt.append("(A.Cognome like '%" + token + "%' or A.Nome like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
}

View file

@ -0,0 +1,96 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class AccessDittaCR extends CRAdapter {
private long id_accessDitta;
private String id_access;
private String attr1Maiuscoli;
private String attrMaiuscoli;
private String attrMinuscoli;
private String descrizione;
private long flgSafeUpdate;
private Access access;
public AccessDittaCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public AccessDittaCR() {}
public void setId_accessDitta(long newId_accessDitta) {
this.id_accessDitta = newId_accessDitta;
}
public void setId_access(String newId_access) {
this.id_access = newId_access;
setAccess(null);
}
public void setAttr1Maiuscoli(String newAttr1Maiuscoli) {
this.attr1Maiuscoli = newAttr1Maiuscoli;
}
public void setAttrMaiuscoli(String newAttrMaiuscoli) {
this.attrMaiuscoli = newAttrMaiuscoli;
}
public void setAttrMinuscoli(String newAttrMinuscoli) {
this.attrMinuscoli = newAttrMinuscoli;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public void setFlgSafeUpdate(long newFlgSafeUpdate) {
this.flgSafeUpdate = newFlgSafeUpdate;
}
public long getId_accessDitta() {
return this.id_accessDitta;
}
public String getId_access() {
return (this.id_access == null) ? "" : this.id_access.trim();
}
public String getAttr1Maiuscoli() {
return (this.attr1Maiuscoli == null) ? "" : this.attr1Maiuscoli.trim();
}
public String getAttrMaiuscoli() {
return (this.attrMaiuscoli == null) ? "" : this.attrMaiuscoli.trim();
}
public String getAttrMinuscoli() {
return (this.attrMinuscoli == null) ? "" : this.attrMinuscoli.trim();
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione.trim();
}
public long getFlgSafeUpdate() {
return this.flgSafeUpdate;
}
public void setAccess(Access newAccess) {
this.access = newAccess;
}
public Access getAccess() {
this.access = (Access)getSecondaryObject(
this.access,
Access.class, getId_access());
return this.access;
}
}

View file

@ -0,0 +1,190 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class AccessGroup extends DBAdapter implements Serializable {
private long id_accessGroup;
private String descrizione;
private String nota;
public AccessGroup(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public AccessGroup() {}
public void setId_accessGroup(long newId_accessGroup) {
this.id_accessGroup = newId_accessGroup;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public long getId_accessGroup() {
return this.id_accessGroup;
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione;
}
public String getUsers() {
if (getId_accessGroup() != 0L) {
Vectumerator<UserAccessGroup> vec = getUserAccessGroup(0, 0);
StringBuffer temp = new StringBuffer();
while (vec.hasMoreElements()) {
UserAccessGroup row = vec.nextElement();
temp.append(row.getUsers().getCognomeNome());
if (vec.hasMoreElements())
temp.append(", ");
}
return temp.toString();
}
return "";
}
public String getAccesses() {
if (getId_accessGroup() != 0L) {
Vectumerator<AccessGroupAccess> vec = findAccessGroupAccess(0, 0);
StringBuffer temp = new StringBuffer();
while (vec.hasMoreElements()) {
AccessGroupAccess row = vec.nextElement();
temp.append(row.getAccess().getId_access());
temp.append(" (" + row.getRW() + ")");
if (vec.hasMoreElements())
temp.append(", ");
}
return temp.toString();
}
return "";
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator findByCR(AccessGroupCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from ACCESS_GROUP AS A";
String s_Sql_Order = " order by A.descrizione";
WcString wc = new WcString();
if (!CR.getSearchTxt().trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
StringBuffer txt = new StringBuffer("(");
while (st.hasMoreTokens()) {
String token = st.nextToken();
txt.append("(A.descrizione like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public ResParm addUser(UserAccessGroup row) {
UserAccessGroup bean = new UserAccessGroup(getApFull());
if (row.getId_userAccessGroup() != 0L) {
bean.findByPrimaryKey(row.getId_userAccessGroup());
} else {
bean.findByAccessGroupUser(row.getId_accessGroup(), row.getId_users());
}
if (bean != null) {
row.setDBState(bean.getDBState());
row.setId_userAccessGroup(bean.getId_userAccessGroup());
} else {
row.setDBState(0);
}
return row.save();
}
public ResParm delAccess(AccessGroupAccess row) {
AccessGroupAccess bean = new AccessGroupAccess(getApFull());
bean.findByPrimaryKey(row.getId_accessGroupAccess());
return bean.delete();
}
public ResParm addAccess(AccessGroupAccess row) {
AccessGroupAccess bean = new AccessGroupAccess(getApFull());
if (row.getId_accessGroupAccess() != 0L) {
bean.findByPrimaryKey(row.getId_accessGroupAccess());
} else {
bean.findByAccessGroupAccess(row.getId_accessGroup(), row.getId_access());
}
if (bean != null) {
row.setDBState(bean.getDBState());
row.setId_accessGroupAccess(bean.getId_accessGroupAccess());
} else {
row.setDBState(0);
}
return row.save();
}
public ResParm delUser(UserAccessGroup row) {
UserAccessGroup bean = new UserAccessGroup(getApFull());
bean.findByPrimaryKey(row.getId_userAccessGroup());
return bean.delete();
}
public Vectumerator<AccessGroupAccess> findAccessGroupAccess(int pageNumber, int pageRows) {
return new AccessGroupAccess(getApFull()).findByAccessGroup(getId_accessGroup(), pageNumber, pageRows);
}
public Vectumerator getUserAccessGroup(int pageNumber, int pageRows) {
return new UserAccessGroup(getApFull()).findByAccessGroup(getId_accessGroup(), pageNumber, pageRows);
}
public long getFlgRW(String l_id_access) {
if (getId_accessGroup() == 0L)
return 0L;
AccessGroupAccess aga = new AccessGroupAccess(getApFull());
aga.findByAccessGroupAccess(getId_accessGroup(), l_id_access);
return aga.getFlgRW();
}
public ResParm duplica() {
if (getId_accessGroup() == 0L)
return new ResParm(false, "Errore! bean non valido!");
Vectumerator<AccessGroupAccess> vecAGA = findAccessGroupAccess(0, 0);
setId_accessGroup(0L);
setDBState(0);
setDescrizione(String.valueOf(getDescrizione()) + " copia");
ResParm rp = save();
if (rp.getStatus())
while (vecAGA.hasMoreElements()) {
AccessGroupAccess rowAGA = vecAGA.nextElement();
rowAGA.setId_accessGroupAccess(0L);
rowAGA.setDBState(0);
rowAGA.setId_accessGroup(getId_accessGroup());
rowAGA.save();
}
return new ResParm(false, "Errore! bean non valido!");
}
public String getNota() {
return (this.nota == null) ? "" : this.nota.trim();
}
public void setNota(String nota) {
this.nota = nota;
}
}

View file

@ -0,0 +1,150 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class AccessGroupAccess extends DBAdapter implements Serializable {
private static final long serialVersionUID = -218207150565122890L;
private long id_accessGroupAccess;
private long flgRW;
private String id_access;
private long id_accessGroup;
private Access access;
private AccessGroup accessGroup;
public AccessGroupAccess(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public AccessGroupAccess() {}
public void setId_accessGroupAccess(long newId_accessGroupAccess) {
this.id_accessGroupAccess = newId_accessGroupAccess;
}
public void setFlgRW(long newFlgRW) {
this.flgRW = newFlgRW;
}
public void setId_access(String newId_access) {
this.id_access = newId_access;
setAccess(null);
}
public void setId_accessGroup(long newId_accessGroup) {
this.id_accessGroup = newId_accessGroup;
setAccessGroup(null);
}
public long getId_accessGroupAccess() {
return this.id_accessGroupAccess;
}
public long getFlgRW() {
return this.flgRW;
}
public String getId_access() {
return (this.id_access == null) ? "" : this.id_access;
}
public long getId_accessGroup() {
return this.id_accessGroup;
}
public void setAccess(Access newAccess) {
this.access = newAccess;
}
public Access getAccess() {
this.access = (Access)getSecondaryObject(this.access, Access.class, getId_access());
return this.access;
}
public void setAccessGroup(AccessGroup newAccessGroup) {
this.accessGroup = newAccessGroup;
}
public AccessGroup getAccessGroup() {
this.accessGroup = (AccessGroup)getSecondaryObject((DBAdapter)this.accessGroup, AccessGroup.class, getId_accessGroup());
return this.accessGroup;
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator findByCR(AccessGroupAccessCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from ACCESS_GROUP_ACCESS AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
if (!CR.getSearchTxt().trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
StringBuffer txt = new StringBuffer("(");
while (st.hasMoreTokens()) {
String token = st.nextToken();
txt.append("(A.Cognome like '%" + token + "%' or A.Nome like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public String getRW() {
return DBAdapter.getRW(getFlgRW());
}
public Vectumerator<AccessGroupAccess> findByAccessGroup(long l_id_accessGroup, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from ACCESS_GROUP_ACCESS AS A, ACCESS AS B";
String s_Sql_Order = " order by B.descrizione";
WcString wc = new WcString();
wc.addWc("A.id_access=B.id_access");
wc.addWc("A.id_accessGroup =" + l_id_accessGroup);
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc + s_Sql_Order);
return (Vectumerator)findRows(stmt, pageNumber, pageRows);
} catch (Exception e) {
handleDebug(e);
return (Vectumerator)AB_EMPTY_VECTUMERATOR;
}
}
public void findByAccessGroupAccess(long l_id_accessGroup, String l_id_access) {
String s_Sql_Find = "select A.* from ACCESS_GROUP_ACCESS AS A, ACCESS AS B";
String s_Sql_Order = " order by B.descrizione";
WcString wc = new WcString();
wc.addWc("A.id_access=B.id_access");
wc.addWc("A.id_accessGroup =" + l_id_accessGroup);
wc.addWc("A.id_access ='" + l_id_access + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc + s_Sql_Order);
findFirstRecord(stmt);
} catch (Exception e) {
handleDebug(e);
}
}
}

View file

@ -0,0 +1,81 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
import com.ablia.db.DBAdapter;
public class AccessGroupAccessCR extends CRAdapter {
private long id_accessGroupAccess;
private long flgRW;
private String id_access;
private long id_accessGroup;
private Access access;
private AccessGroup accessGroup;
public AccessGroupAccessCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public AccessGroupAccessCR() {}
public void setId_accessGroupAccess(long newId_accessGroupAccess) {
this.id_accessGroupAccess = newId_accessGroupAccess;
}
public void setFlgRW(long newFlgRW) {
this.flgRW = newFlgRW;
}
public void setId_access(String newId_access) {
this.id_access = newId_access;
setAccess(null);
}
public void setId_accessGroup(long newId_accessGroup) {
this.id_accessGroup = newId_accessGroup;
setAccessGroup(null);
}
public long getId_accessGroupAccess() {
return this.id_accessGroupAccess;
}
public long getFlgRW() {
return this.flgRW;
}
public String getId_access() {
return (this.id_access == null) ? "" : this.id_access;
}
public long getId_accessGroup() {
return this.id_accessGroup;
}
public void setAccess(Access newAccess) {
this.access = newAccess;
}
public Access getAccess() {
this.access = (Access)getSecondaryObject(
this.access,
Access.class, getId_access());
return this.access;
}
public void setAccessGroup(AccessGroup newAccessGroup) {
this.accessGroup = newAccessGroup;
}
public AccessGroup getAccessGroup() {
this.accessGroup = (AccessGroup)getSecondaryObject(
(DBAdapter)this.accessGroup,
AccessGroup.class, getId_accessGroup());
return this.accessGroup;
}
}

View file

@ -0,0 +1,32 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class AccessGroupCR extends CRAdapter {
private long id_accessGroup;
private String descrizione;
public AccessGroupCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public AccessGroupCR() {}
public void setId_accessGroup(long newId_accessGroup) {
this.id_accessGroup = newId_accessGroup;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public long getId_accessGroup() {
return this.id_accessGroup;
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione;
}
}

View file

@ -0,0 +1,162 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class Blacklist extends DBAdapter implements Serializable {
private long id_blacklist;
private long flgAttivo;
private String descrizione;
private String ipAddress;
private String eMail;
public Blacklist(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public Blacklist() {}
public void setId_blacklist(long newId_blackList) {
this.id_blacklist = newId_blackList;
}
public void setFlgAttivo(long newFlgAttivo) {
this.flgAttivo = newFlgAttivo;
}
public void setIpAddress(String newIpAddress) {
this.ipAddress = newIpAddress;
}
public void setEMail(String newEMail) {
this.eMail = newEMail;
}
public long getId_blacklist() {
return this.id_blacklist;
}
public String getAttivo() {
return (this.flgAttivo == 0L) ? "N" : "S";
}
public long getFlgAttivo() {
return this.flgAttivo;
}
public String getIpAddress() {
return (this.ipAddress == null) ? "" : this.ipAddress.trim();
}
public String getEMail() {
return (this.eMail == null) ? "" : this.eMail.trim();
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator findByCR(BlacklistCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from BLACKLIST AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
if (!CR.getSearchTxt().trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(),
" ");
StringBuffer txt = new StringBuffer("(");
while (st.hasMoreTokens()) {
String token = st.nextToken();
txt.append("(A.descrizione like '%" + token +
"%' or A.ipAddress like '%" + token +
"%' or A.eMail like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
if (CR.getFlgAttivo() == 0L) {
wc.addWc("(A.flgAttivo is null or A.flgAttivo=0)");
} else if (CR.getFlgAttivo() == 1L) {
wc.addWc("A.flgAttivo =1");
}
try {
PreparedStatement stmt = getConn().prepareStatement(
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public void findByIp(String l_ip) {
String s_Sql_Find = "select A.* from BLACKLIST AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
wc.addWc("A.ipAddress like '" + l_ip + "%'");
wc.addWc("A.flgAttivo=1");
try {
PreparedStatement stmt = getConn().prepareStatement(
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
findFirstRecord(stmt);
} catch (SQLException e) {
handleDebug(e);
}
}
public void findByEmail(String l_eMail) {
String s_Sql_Find = "select A.* from BLACKLIST AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
if (l_eMail.indexOf("@") > 0) {
String temp = l_eMail.substring(l_eMail.indexOf("@"));
wc.addWc("(A.eMail like '" + temp + "%' or A.eMail like '%" +
l_eMail + "%')");
} else {
wc.addWc("A.eMail like '%" + l_eMail + "%'");
}
wc.addWc("A.flgAttivo=1");
try {
PreparedStatement stmt = getConn().prepareStatement(
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
findFirstRecord(stmt);
} catch (SQLException e) {
handleDebug(e);
}
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione.trim();
}
public String getDescrizioneCompleta() {
StringBuffer temp = new StringBuffer();
if (!getIpAddress().isEmpty()) {
temp.append("Ip addr.: ");
temp.append(getIpAddress());
}
if (!getEMail().isEmpty()) {
temp.append(" Email addr.: ");
temp.append(getEMail());
}
return temp.toString().trim();
}
public void setDescrizione(String descrizione) {
this.descrizione = descrizione;
}
}

View file

@ -0,0 +1,62 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class BlacklistCR extends CRAdapter {
private long id_blacklist;
private long flgAttivo = -1L;
private String ipAddress;
private String eMail;
private String descrizione;
public BlacklistCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public BlacklistCR() {}
public void setId_blacklist(long newId_blackList) {
this.id_blacklist = newId_blackList;
}
public void setFlgAttivo(long newFlgAttivo) {
this.flgAttivo = newFlgAttivo;
}
public void setIpAddress(String newIpAddress) {
this.ipAddress = newIpAddress;
}
public void setEMail(String newEMail) {
this.eMail = newEMail;
}
public long getId_blacklist() {
return this.id_blacklist;
}
public long getFlgAttivo() {
return this.flgAttivo;
}
public String getIpAddress() {
return (this.ipAddress == null) ? "" : this.ipAddress.trim();
}
public String getEMail() {
return (this.eMail == null) ? "" : this.eMail.trim();
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione.trim();
}
public void setDescrizione(String descrizione) {
this.descrizione = descrizione;
}
}

View file

@ -0,0 +1,8 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.ResParm;
public interface CrontabInterface {
ResParm crontabJob(ApplParmFull paramApplParmFull);
}

View file

@ -0,0 +1,41 @@
package com.ablia.common;
public class DescLangItem {
private String value;
private String lang;
private String campo;
public DescLangItem(String campo, String lang, String value) {
this.value = value;
this.lang = lang;
this.campo = campo;
}
public DescLangItem() {}
public String getCampo() {
return (this.campo == null) ? "" : this.campo.trim();
}
public void setCampo(String newCampo) {
this.campo = newCampo;
}
public String getLang() {
return (this.lang == null) ? "" : this.lang.trim();
}
public void setLang(String newLang) {
this.lang = newLang;
}
public String getValue() {
return (this.value == null) ? "" : this.value.trim();
}
public void setValue(String value) {
this.value = value;
}
}

View file

@ -0,0 +1,299 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Hashtable;
public class DescTxtLang extends DBAdapter implements Serializable {
private static Hashtable<String, Hashtable<String, Integer>> initTableDescLangDescriptorDb;
private static final String _DESCRIZIONE = "descrizione";
private String tabella;
private long idTabella;
private String campo;
private String lang;
private String descrizione;
private String descrizione254;
public DescTxtLang(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public DescTxtLang() {}
public void setTabella(String newTabella) {
this.tabella = newTabella;
}
public void setIdTabella(long newIdTabella) {
this.idTabella = newIdTabella;
}
public void setCampo(String newCampo) {
this.campo = newCampo;
}
public void setLang(String newLang) {
this.lang = newLang;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public String getTabella() {
return (this.tabella == null) ? "" : this.tabella.trim();
}
public long getIdTabella() {
return this.idTabella;
}
public String getCampo() {
return (this.campo == null) ? "" : this.campo.trim();
}
public String getLang() {
return (this.lang == null) ? "" : this.lang.trim();
}
public String getDescrizioneScript() {
return DBAdapter.prepareScriptString(getDescrizione(), true, false);
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator findByCR(DescTxtLangCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from DESC_TXT_LANG AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
if (!CR.getSearchTxt().trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
StringBuffer txt = new StringBuffer("(");
while (st.hasMoreTokens()) {
String token = st.nextToken();
txt.append("(A.Cognome like '%" + token + "%' or A.Nome like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public String getDescrizione254() {
return (this.descrizione254 == null) ? "" : this.descrizione254.trim();
}
public void setDescrizione254(String descrizione254) {
this.descrizione254 = descrizione254;
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione.trim();
}
public String getDescrizione254Script() {
return DBAdapter.prepareScriptString(getDescrizione254(), true, false);
}
public void findByIdtabellaLangTabellaCampo(long l_idTabella, String l_lang, String l_tabella, String l_campo) {
String s_Sql_Find = "select A.* from DESC_TXT_LANG AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
wc.addWc("A.idTabella=" + l_idTabella);
wc.addWc("A.lang='" + l_lang + "'");
wc.addWc("A.tabella='" + l_tabella + "'");
wc.addWc("A.campo='" + l_campo + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
findFirstRecord(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
}
}
public Vectumerator<DescTxtLang> findCampiByIdtabellaLangTabella(long l_idTabella, String l_lang, String l_tabella) {
String s_Sql_Find = "select A.* from DESC_TXT_LANG AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
wc.addWc("A.idTabella=" + l_idTabella);
wc.addWc("A.lang='" + l_lang + "'");
wc.addWc("A.tabella='" + l_tabella + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return (Vectumerator)findRows(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return (Vectumerator)AB_EMPTY_VECTUMERATOR;
}
}
protected final int getStringValueCase(String l_columnName) {
return 0;
}
public Vectumerator<? extends DBAdapter> findCampiTabella(String l_tabella) {
String s_Sql_Find = "select distinct A.campo from DESC_TXT_LANG AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
wc.addWc("A.tabella='" + l_tabella + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public ResParm deleteByTabellaIdtabella(String l_tabella, long l_id_tabella) {
String s_Sql_Find = "delete from DESC_TXT_LANG ";
WcString wc = new WcString();
wc.addWc("tabella='" + l_tabella + "'");
wc.addWc("idTabella=" + l_id_tabella);
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString());
return delete(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return new ResParm(false, e);
}
}
public Vectumerator findAllTxtByIdLangTable(long l_idTabella, String l_lang, String l_tabella) {
String s_Sql_Find = "select A.* from DESC_TXT_LANG AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
wc.addWc("A.idTabella=" + l_idTabella);
if (!l_lang.isEmpty())
wc.addWc("A.lang='" + l_lang + "'");
wc.addWc("A.tabella='" + l_tabella + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public static void resetHashtables() {
if (initTableDescLangDescriptorDb != null) {
initTableDescLangDescriptorDb.clear();
initTableDescLangDescriptorDb = null;
}
}
private static Hashtable<String, Hashtable<String, Integer>> getInitTableDescLangDescriptorDb() {
if (initTableDescLangDescriptorDb == null)
initTableDescLangDescriptorDb = new Hashtable<>();
return initTableDescLangDescriptorDb;
}
protected void fillFields(ResultSet rst) {
super.fillFields(rst);
int l_stringCaseValue = 0;
Hashtable<String, Integer> columnDescriptorHT = getInitTableDescLangDescriptorDb().get(String.valueOf(getTabella()) + getApFull().getApCode());
if (columnDescriptorHT != null && columnDescriptorHT.containsKey(getCampo())) {
l_stringCaseValue = columnDescriptorHT.get(getCampo());
} else {
Access access = new Access(getApFull());
access.findByPrimaryKey(getTabella());
l_stringCaseValue = access.getTableColumnStringValueCase(getCampo());
if (columnDescriptorHT == null)
columnDescriptorHT = new Hashtable<>();
columnDescriptorHT.put(getCampo(), Integer.valueOf(l_stringCaseValue));
getInitTableDescLangDescriptorDb().put(String.valueOf(getTabella()) + getApFull().getApCode(), columnDescriptorHT);
}
if (l_stringCaseValue != 0) {
String temp;
switch (l_stringCaseValue) {
case 1:
temp = getDescrizione();
if (temp != null) {
temp = temp.toUpperCase();
temp = temp.replaceAll("&EURO;", "&euro;");
}
setDescrizione(temp);
temp = getDescrizione254();
if (temp != null) {
temp = temp.toUpperCase();
temp = temp.replaceAll("&EURO;", "&euro;");
}
setDescrizione254(temp);
break;
case 2:
temp = getDescrizione();
if (temp != null)
temp = temp.toLowerCase();
setDescrizione(temp);
temp = getDescrizione254();
if (temp != null)
temp = temp.toLowerCase();
setDescrizione254(temp);
break;
case 3:
temp = getDescrizione();
if (temp != null)
temp = convertTo1stCap(temp);
setDescrizione(temp);
temp = getDescrizione254();
if (temp != null)
temp = temp.toLowerCase();
setDescrizione254(temp);
break;
}
}
}
protected final int getStringValueCaseOLD(String l_columnName) {
if (getTabella().isEmpty() || !l_columnName.startsWith("descrizione"))
return 0;
int l_stringCaseValue = 0;
Hashtable<String, Integer> columnDescriptorHT = getInitTableDescLangDescriptorDb().get(String.valueOf(getTabella()) + getApFull().getApCode());
if (columnDescriptorHT != null && columnDescriptorHT.containsKey(getCampo())) {
l_stringCaseValue = columnDescriptorHT.get(getCampo());
} else {
Access access = new Access(getApFull());
access.findByPrimaryKey(getTabella());
l_stringCaseValue = access.getTableColumnStringValueCase(getCampo());
if (columnDescriptorHT == null)
columnDescriptorHT = new Hashtable<>();
columnDescriptorHT.put(getCampo(), Integer.valueOf(l_stringCaseValue));
getInitTableDescLangDescriptorDb().put(String.valueOf(getTabella()) + getApFull().getApCode(), columnDescriptorHT);
}
return l_stringCaseValue;
}
}

View file

@ -0,0 +1,62 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class DescTxtLangCR extends CRAdapter {
private String tabella;
private long idTabella;
private String campo;
private String lang;
private String descrizione;
public DescTxtLangCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public DescTxtLangCR() {}
public void setTabella(String newTabella) {
this.tabella = newTabella;
}
public void setIdTabella(long newIdTabella) {
this.idTabella = newIdTabella;
}
public void setCampo(String newCampo) {
this.campo = newCampo;
}
public void setLang(String newLang) {
this.lang = newLang;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public String getTabella() {
return (this.tabella == null) ? "" : this.tabella.trim();
}
public long getIdTabella() {
return this.idTabella;
}
public String getCampo() {
return (this.campo == null) ? "" : this.campo.trim();
}
public String getLang() {
return (this.lang == null) ? "" : this.lang.trim();
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione.trim();
}
}

View file

@ -0,0 +1,54 @@
package com.ablia.common;
import java.io.Serializable;
public class DescTxtLangKey implements Serializable {
private String tabella;
private long idTabella;
private String campo;
private String lang;
public DescTxtLangKey() {}
public DescTxtLangKey(String newTabella, long newIdTabella, String newCampo, String newLang) {
setTabella(newTabella);
setIdTabella(newIdTabella);
setCampo(newCampo);
setLang(newLang);
}
public void setTabella(String newTabella) {
this.tabella = newTabella;
}
public void setIdTabella(long newIdTabella) {
this.idTabella = newIdTabella;
}
public void setCampo(String newCampo) {
this.campo = newCampo;
}
public void setLang(String newLang) {
this.lang = newLang;
}
public String getTabella() {
return (this.tabella == null) ? "" : this.tabella.trim();
}
public long getIdTabella() {
return this.idTabella;
}
public String getCampo() {
return (this.campo == null) ? "" : this.campo.trim();
}
public String getLang() {
return (this.lang == null) ? "" : this.lang.trim();
}
}

View file

@ -0,0 +1,57 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import java.io.Serializable;
public class Dictionary extends DBAdapter implements Serializable {
private static final long serialVersionUID = 1L;
private String id_dictionary;
private String id_language;
private String descrizione;
public Dictionary() {
initFields();
}
public Dictionary(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public String getDescrizione() {
return (this.descrizione == null) ? "" :
this.descrizione;
}
public String getId_dictionary() {
return (this.id_dictionary == null) ? "" :
this.id_dictionary;
}
public String getId_language() {
return (this.id_language == null) ? "" :
this.id_language;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public void setId_dictionary(String newId_dictionary) {
this.id_dictionary = newId_dictionary;
}
public void setId_language(String newId_language) {
this.id_language = newId_language;
}
}

View file

@ -0,0 +1,27 @@
package com.ablia.common;
import java.io.Serializable;
public class DictionaryKey implements Serializable {
private static final long serialVersionUID = 1L;
private String id_dictionary;
private String id_language;
public String getId_dictionary() {
return this.id_dictionary;
}
public String getId_language() {
return this.id_language;
}
public void setId_dictionary(String newId_dictionary) {
this.id_dictionary = newId_dictionary;
}
public void setId_language(String newId_language) {
this.id_language = newId_language;
}
}

View file

@ -0,0 +1,212 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class DittaCR extends CRAdapter {
private String cognome;
private String nome;
private String indirizzo;
private String numeroCivico;
private String descrizioneComune;
private String provinciaComune;
private String capComune;
private String capZona;
private String descrizioneNazione;
private String codFisc;
private String pIva;
private String eMail;
private String eMailAmm;
private String cellulare;
private String telefono;
private String telefonoAmm;
private String fax;
private String nota;
private String imgTmst;
private long id_ditta;
public DittaCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public DittaCR() {}
public void setCognome(String newCognome) {
this.cognome = newCognome;
}
public void setNome(String newNome) {
this.nome = newNome;
}
public void setIndirizzo(String newIndirizzo) {
this.indirizzo = newIndirizzo;
}
public void setNumeroCivico(String newNumeroCivico) {
this.numeroCivico = newNumeroCivico;
}
public void setDescrizioneComune(String newDescrizioneComune) {
this.descrizioneComune = newDescrizioneComune;
}
public void setProvinciaComune(String newProvinciaComune) {
this.provinciaComune = newProvinciaComune;
}
public void setCapComune(String newCapComune) {
this.capComune = newCapComune;
}
public void setCapZona(String newCapZona) {
this.capZona = newCapZona;
}
public void setDescrizioneNazione(String newDescrizioneNazione) {
this.descrizioneNazione = newDescrizioneNazione;
}
public void setCodFisc(String newCodFisc) {
this.codFisc = newCodFisc;
}
public void setPIva(String newPIva) {
this.pIva = newPIva;
}
public void setEMail(String newEMail) {
this.eMail = newEMail;
}
public void setEMailAmm(String newEMailAmm) {
this.eMailAmm = newEMailAmm;
}
public void setCellulare(String newCellulare) {
this.cellulare = newCellulare;
}
public void setTelefono(String newTelefono) {
this.telefono = newTelefono;
}
public void setTelefonoAmm(String newTelefonoAmm) {
this.telefonoAmm = newTelefonoAmm;
}
public void setFax(String newFax) {
this.fax = newFax;
}
public void setNota(String newNota) {
this.nota = newNota;
}
public void setImgTmst(String newImgTmst) {
this.imgTmst = newImgTmst;
}
public String getCognome() {
return (this.cognome == null) ? "" : this.cognome.trim();
}
public String getNome() {
return (this.nome == null) ? "" : this.nome.trim();
}
public String getIndirizzo() {
return (this.indirizzo == null) ? "" : this.indirizzo.trim();
}
public String getNumeroCivico() {
return (this.numeroCivico == null) ? "" : this.numeroCivico.trim();
}
public String getDescrizioneComune() {
return (this.descrizioneComune == null) ? "" : this.descrizioneComune.trim();
}
public String getProvinciaComune() {
return (this.provinciaComune == null) ? "" : this.provinciaComune.trim();
}
public String getCapComune() {
return (this.capComune == null) ? "" : this.capComune.trim();
}
public String getCapZona() {
return (this.capZona == null) ? "" : this.capZona.trim();
}
public String getDescrizioneNazione() {
return (this.descrizioneNazione == null) ? "" : this.descrizioneNazione.trim();
}
public String getCodFisc() {
return (this.codFisc == null) ? "" : this.codFisc.trim();
}
public String getPIva() {
return (this.pIva == null) ? "" : this.pIva.trim();
}
public String getEMail() {
return (this.eMail == null) ? "" : this.eMail.trim();
}
public String getEMailAmm() {
return (this.eMailAmm == null) ? "" : this.eMailAmm.trim();
}
public String getCellulare() {
return (this.cellulare == null) ? "" : this.cellulare.trim();
}
public String getTelefono() {
return (this.telefono == null) ? "" : this.telefono.trim();
}
public String getTelefonoAmm() {
return (this.telefonoAmm == null) ? "" : this.telefonoAmm.trim();
}
public String getFax() {
return (this.fax == null) ? "" : this.fax.trim();
}
public String getNota() {
return (this.nota == null) ? "" : this.nota.trim();
}
public String getImgTmst() {
return (this.imgTmst == null) ? "" : this.imgTmst.trim();
}
public long getId_ditta() {
return this.id_ditta;
}
public void setId_ditta(long id_ditta) {
this.id_ditta = id_ditta;
}
}

View file

@ -0,0 +1,52 @@
package com.ablia.common;
public class JsonUploadFileResponse {
private String fileName;
private String fileNameLink;
private String message;
private boolean result;
public JsonUploadFileResponse() {}
public JsonUploadFileResponse(boolean result, String message, String fileName, String fileNameLink) {
this.result = result;
this.message = message;
this.fileName = fileName;
this.fileNameLink = fileNameLink;
}
public String getFileName() {
return this.fileName;
}
public String getMessage() {
return this.message;
}
public void setFileName(String imgPath) {
this.fileName = imgPath;
}
public void setMessage(String message) {
this.message = message;
}
public boolean isResult() {
return this.result;
}
public void setResult(boolean result) {
this.result = result;
}
public String getFileNameLink() {
return this.fileNameLink;
}
public void setFileNameLink(String fileNameLink) {
this.fileNameLink = fileNameLink;
}
}

View file

@ -0,0 +1,41 @@
package com.ablia.common;
public class JsonUploadImageResponse {
private String imgPath;
private String message;
private boolean result;
public JsonUploadImageResponse() {}
public JsonUploadImageResponse(boolean result, String message, String imgpath) {
this.result = result;
this.message = message;
this.imgPath = imgpath;
}
public String getImgPath() {
return this.imgPath;
}
public String getMessage() {
return this.message;
}
public void setImgPath(String imgPath) {
this.imgPath = imgPath;
}
public void setMessage(String message) {
this.message = message;
}
public boolean isResult() {
return this.result;
}
public void setResult(boolean result) {
this.result = result;
}
}

View file

@ -0,0 +1,39 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.DBAdapterException;
import com.ablia.db.ResParm;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.sql.SQLException;
public class Lang extends DBAdapter {
private String lang;
protected void deleteCascade() {}
public static Vectumerator<Lang> findAllLangAvailable(ApplParmFull ap) {
Vectumerator<Lang> vec = new Vectumerator<>();
String lingue = ap.getParm("LANG_AVAILABLE").getTesto();
StringTokenizer st = new StringTokenizer(lingue, ",");
while (st.hasMoreTokens()) {
Lang lg = new Lang();
lg.setLang(st.nextToken());
vec.add(lg);
}
return vec;
}
protected ResParm checkDeleteCascade() throws DBAdapterException, SQLException {
return null;
}
public String getLang() {
return (this.lang == null) ? "" : this.lang;
}
public void setLang(String lang) {
this.lang = lang;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,73 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class ParmCR extends CRAdapter {
private String tipoParm;
private long id_userProfile;
private long id_user;
public ParmCR() {}
public ParmCR(ApplParmFull newAp) {
setApFull(newAp);
}
public String getTipoParm() {
return (this.tipoParm == null) ? "" :
this.tipoParm;
}
public void setTipoParm(String newTxtRicerca) {
this.tipoParm = newTxtRicerca;
}
private long flgAdmin = -1L;
private long flgTipo = -1L;
private long id_parm;
public long getId_user() {
return this.id_user;
}
public void setId_user(long id_user) {
this.id_user = id_user;
}
public long getId_userProfile() {
return this.id_userProfile;
}
public void setId_userProfile(long id_userProfile) {
this.id_userProfile = id_userProfile;
}
public long getFlgAdmin() {
return this.flgAdmin;
}
public void setFlgAdmin(long flgAdmin) {
this.flgAdmin = flgAdmin;
}
public long getFlgTipo() {
return this.flgTipo;
}
public void setFlgTipo(long flgTipo) {
this.flgTipo = flgTipo;
}
public long getId_parm() {
return this.id_parm;
}
public void setId_parm(long id_parm) {
this.id_parm = id_parm;
}
}

View file

@ -0,0 +1,113 @@
package com.ablia.common;
import com.lowagie.text.Document;
import com.lowagie.text.Image;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfContentByte;
import com.lowagie.text.pdf.PdfPageEvent;
import com.lowagie.text.pdf.PdfWriter;
import java.awt.Color;
public class PdfWatermarkEvent implements PdfPageEvent {
private String wmFileName;
public PdfWatermarkEvent(String wmFileName, boolean printMiddleDash, Rectangle l_pageSize) {
this.wmFileName = wmFileName;
this.printMiddleDash = printMiddleDash;
setPageSize(this.pageSize);
}
public PdfWatermarkEvent(String wmFileName, boolean printMiddleDash) {
this.wmFileName = wmFileName;
this.printMiddleDash = printMiddleDash;
}
public void onChapter(PdfWriter arg0, Document arg1, float arg2, Paragraph arg3) {}
public void onChapterEnd(PdfWriter arg0, Document arg1, float arg2) {}
public void onCloseDocument(PdfWriter arg0, Document arg1) {}
public void onEndPage(PdfWriter arg0, Document arg1) {}
public void onGenericTag(PdfWriter arg0, Document arg1, Rectangle arg2, String arg3) {}
public void onOpenDocument(PdfWriter arg0, Document arg1) {}
public void onParagraph(PdfWriter arg0, Document arg1, float arg2) {}
public void onParagraphEnd(PdfWriter arg0, Document arg1, float arg2) {}
public void onSection(PdfWriter arg0, Document arg1, float arg2, int arg3, Paragraph arg4) {}
public void onSectionEnd(PdfWriter arg0, Document arg1, float arg2) {}
public void onStartPage(PdfWriter writer, Document arg1) {
if (isPrintMiddleDash()) {
float middleY = getPageSize().getHeight() / 2.0F;
PdfContentByte cb = writer.getDirectContent();
cb.moveTo(0.0F, middleY);
cb.setLineDash(5.0F, 5.0F, 10.0F);
cb.setLineWidth(0.5F);
cb.setColorStroke(Color.gray);
cb.lineTo(getPageSize().getWidth(), middleY);
cb.stroke();
}
if (!getWmFileName().isEmpty()) {
PdfContentByte cb = writer.getDirectContent();
try {
Image wmImage = Image.getInstance(getWmFileName());
wmImage.setRotationDegrees(45.0F);
wmImage.scaleToFit(
wmImage.getHeight() * 30.0F / wmImage.getHeight(), 30.0F);
float newH = 30.0F;
float newW = wmImage.getHeight() * newH / wmImage.getHeight();
int nCol = 3;
int nRow = 6;
float xStep = (getPageSize().getWidth() - 2.0F * newW) / (float)nCol;
float yStep = (getPageSize().getHeight() - 2.0F * newH) / (float)nRow;
for (int i = 0; i < nCol; i++) {
for (int j = 0; j < nRow; j++) {
float x = (float)((double)i + 0.5D) * xStep;
float y = (float)((double)j + 0.5D) * yStep;
wmImage.setAbsolutePosition(x, y);
cb.addImage(wmImage);
}
}
cb.stroke();
} catch (Exception e) {
e.printStackTrace();
}
}
}
private boolean printMiddleDash = false;
private Rectangle pageSize;
public String getWmFileName() {
return (this.wmFileName == null) ? "" : this.wmFileName;
}
public void setWmFileName(String wmFileName) {
this.wmFileName = wmFileName;
}
public boolean isPrintMiddleDash() {
return this.printMiddleDash;
}
public void setPrintMiddleDash(boolean printMiddleDash) {
this.printMiddleDash = printMiddleDash;
}
public Rectangle getPageSize() {
return (this.pageSize == null) ? PageSize.A4 : this.pageSize;
}
public void setPageSize(Rectangle pageSize) {
this.pageSize = pageSize;
}
}

View file

@ -0,0 +1,156 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class Postazione extends DBAdapter implements PostazioneI, Serializable {
private static final long serialVersionUID = 7416669184945044393L;
private long id_postazione;
private String descrizione;
private String ipAddress;
private String stampanteA4;
private String stampanteEtichette;
private long flgTipo;
private String hostname;
public Postazione(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public Postazione() {}
public void setId_postazione(long newId_postazione) {
this.id_postazione = newId_postazione;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public void setIpAddress(String newIpAddress) {
this.ipAddress = newIpAddress;
}
public void setStampanteA4(String newStampanteLaser) {
this.stampanteA4 = newStampanteLaser;
}
public void setStampanteEtichette(String newStampanteEtichette) {
this.stampanteEtichette = newStampanteEtichette;
}
public long getId_postazione() {
return this.id_postazione;
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione.trim();
}
public String getIpAddress() {
return (this.ipAddress == null) ? "" : this.ipAddress.trim();
}
public String getStampanteA4() {
return (this.stampanteA4 == null) ? "" : this.stampanteA4.trim();
}
public String getStampanteEtichette() {
return (this.stampanteEtichette == null) ? "" : this.stampanteEtichette.trim();
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator findByCR(PostazioneCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from POSTAZIONE AS A";
String s_Sql_Order = " order By A.descrizione";
WcString wc = new WcString();
if (!CR.getSearchTxt().trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
StringBuffer txt = new StringBuffer("(");
while (st.hasMoreTokens()) {
String token = st.nextToken();
txt.append("(A.Cognome like '%" + token + "%' or A.Nome like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public void findByIp(String l_ip) {
String s_Sql_Find = "select A.* from POSTAZIONE AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
wc.addWc("A.ipAddress='" + l_ip + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
findFirstRecord(stmt);
} catch (SQLException e) {
handleDebug(e);
}
}
public void findByHostname(String l_hostname) {
String s_Sql_Find = "select A.* from POSTAZIONE AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
wc.addWc("A.hostname='" + l_hostname + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
findFirstRecord(stmt);
} catch (SQLException e) {
handleDebug(e);
}
}
public long getFlgTipo() {
return this.flgTipo;
}
public void setFlgTipo(long flgTipo) {
this.flgTipo = flgTipo;
}
public String getStampanteA4Script() {
return getStampanteA4().replaceAll("\\\\", "\\\\\\\\");
}
public String getStampanteEtichetteScript() {
return getStampanteEtichette().replaceAll("\\\\", "\\\\\\\\");
}
public String getHostname() {
return (this.hostname == null) ? "" : this.hostname.trim();
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
}

View file

@ -0,0 +1,86 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
import java.sql.Timestamp;
public class PostazioneCR extends CRAdapter {
private long id_postazione;
private String descrizione;
private String ipAddress;
private String stampanteLaser;
private String stampanteEtichette;
private Timestamp lastUpdTmst;
private long lastUpdId_user;
public PostazioneCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public PostazioneCR() {}
public void setId_postazione(long newId_postazione) {
this.id_postazione = newId_postazione;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public void setIpAddress(String newIpAddress) {
this.ipAddress = newIpAddress;
}
public void setStampanteLaser(String newStampanteLaser) {
this.stampanteLaser = newStampanteLaser;
}
public void setStampanteEtichette(String newStampanteEtichette) {
this.stampanteEtichette = newStampanteEtichette;
}
public void setLastUpdTmst(Timestamp newLastUpdTmst) {
this.lastUpdTmst = newLastUpdTmst;
}
public void setLastUpdId_user(long newLastUpdId_user) {
this.lastUpdId_user = newLastUpdId_user;
}
public long getId_postazione() {
return this.id_postazione;
}
public String getDescrizione() {
return (this.descrizione == null) ? "" :
this.descrizione.trim();
}
public String getIpAddress() {
return (this.ipAddress == null) ? "" : this.ipAddress.trim();
}
public String getStampanteLaser() {
return (this.stampanteLaser == null) ? "" :
this.stampanteLaser.trim();
}
public String getStampanteEtichette() {
return (this.stampanteEtichette == null) ? "" :
this.stampanteEtichette.trim();
}
public Timestamp getLastUpdTmst() {
return this.lastUpdTmst;
}
public long getLastUpdId_user() {
return this.lastUpdId_user;
}
}

View file

@ -0,0 +1,39 @@
package com.ablia.common;
import com.ablia.util.Vectumerator;
public interface PostazioneI {
void setId_postazione(long paramLong);
void setDescrizione(String paramString);
void setIpAddress(String paramString);
void setStampanteA4(String paramString);
void setStampanteEtichette(String paramString);
long getId_postazione();
String getDescrizione();
String getIpAddress();
String getStampanteA4();
String getStampanteEtichette();
Vectumerator findByCR(PostazioneCR paramPostazioneCR, int paramInt1, int paramInt2);
void findByIp(String paramString);
void findByHostname(String paramString);
long getFlgTipo();
void setFlgTipo(long paramLong);
String getStampanteA4Script();
String getStampanteEtichetteScript();
}

View file

@ -0,0 +1,303 @@
package com.ablia.common;
import com.ablia.util.Vectumerator;
import java.util.Enumeration;
import java.util.Hashtable;
public class SimboliLavaggio {
private long lavaggio;
private long candeggio;
private long stiratura;
private long pulituraSecco;
private long asciugatura;
private long asciugaturaNaturale;
private static Hashtable<Long, SimboloLavaggio> dbSimboli;
public static final int NESSUN_SIMBOLO = 0;
public static final int LAVAGGIO_NO = 101;
public static final int LAVAGGIO_A_MANO = 102;
public static final int LAVAGGIO_DELICATO_MAX_30_1 = 103;
public static final int LAVAGGIO_DELICATO_MAX_30_2 = 104;
public static final int LAVAGGIO_DELICATO_MAX_30_3 = 105;
public static final int LAVAGGIO_DELICATO_MAX_40_1 = 106;
public static final int LAVAGGIO_DELICATO_MAX_40_2 = 107;
public static final int LAVAGGIO_DELICATO_MAX_40_3 = 108;
public static final int LAVAGGIO_DELICATO_MAX_50_1 = 109;
public static final int LAVAGGIO_DELICATO_MAX_50_2 = 110;
public static final int LAVAGGIO_DELICATO_MAX_60_1 = 111;
public static final int LAVAGGIO_DELICATO_MAX_60_2 = 112;
public static final int LAVAGGIO_DELICATO_MAX_70_1 = 113;
public static final int LAVAGGIO_DELICATO_MAX_95_1 = 114;
public static final int LAVAGGIO_DELICATO_MAX_95_2 = 115;
public static final int LAVAGGIO_ACQUA_PROFESSIONALE_1 = 601;
public static final int LAVAGGIO_ACQUA_PROFESSIONALE_2 = 602;
public static final int LAVAGGIO_ACQUA_PROFESSIONALE_3 = 603;
public static final int CANDEGGIO_NO = 201;
public static final int CANDEGGIO_CLORO_E_PERBORATO = 202;
public static final int CANDEGGIO_SOLO_PERBORATO = 203;
public static final int CANDEGGIO_CON_CLORO = 204;
public static final int ASCIUGARE_NO = 301;
public static final int ASCIUGARE_TEMP_INF_60 = 302;
public static final int ASCIUGARE_ALTA_TEMP = 303;
public static final int ASCIUGARE_SI = 304;
public static final int ASCIUGARE_NATURALE_1 = 701;
public static final int ASCIUGARE_NATURALE_2 = 702;
public static final int ASCIUGARE_NATURALE_3 = 703;
public static final int ASCIUGARE_NATURALE_4 = 704;
public static final int ASCIUGARE_NATURALE_5 = 705;
public static final int ASCIUGARE_NATURALE_6 = 706;
public static final int STIRO_NO = 401;
public static final int STIRO_BASSA_TEMP = 402;
public static final int STIRO_MEDIA_TEMP = 403;
public static final int STIRO_ALTA_TEMP = 404;
public static final int PULITURA_NO = 501;
public static final int PULITURA_TUTTI_I_SOLVENTI_1 = 502;
public static final int PULITURA_TUTTI_I_SOLVENTI_IN_USO_A = 503;
public static final int PULITURA_BENZIA_AVIO_E_R113 = 504;
public static final int PULITURA_BENZIA_AVIO_E_R113_CON_LIMITI_TEMP_UMIDITA = 505;
public static final int PULITURA_IDROC_E_TRIFLUORO_TRICLOROETANO = 506;
public static final int PULITURA_IDROC_E_TRIFLUORO_TRICLOROETANO_CON_LIMITI = 507;
private long lavaggioProfessionale;
public SimboliLavaggio() {
getDbSimboli();
}
public SimboloLavaggio getAsciugatura() {
if (getDbSimboli().containsKey(new Long(this.asciugatura)))
return getDbSimboli().get(new Long(this.asciugatura));
return new SimboloLavaggio();
}
public Vectumerator<SimboloLavaggio> getAsciugature() {
return getSimboli(1, 3);
}
public Vectumerator<SimboloLavaggio> getCandeggi() {
return getSimboli(11, 12);
}
public SimboloLavaggio getCandeggio() {
if (getDbSimboli().containsKey(new Long(this.candeggio)))
return getDbSimboli().get(new Long(this.candeggio));
return new SimboloLavaggio();
}
private Hashtable<Long, SimboloLavaggio> getDbSimboli() {
if (dbSimboli == null) {
dbSimboli = new Hashtable<>(40);
dbSimboli.put(new Long(0L), new SimboloLavaggio(0, "Nessun Simbolo"));
dbSimboli.put(new Long(101L), new SimboloLavaggio(101, "Non Lavare"));
dbSimboli.put(new Long(102L), new SimboloLavaggio(102, "Lavare a mano"));
dbSimboli.put(new Long(103L),
new SimboloLavaggio(103, "Lavaggio delicato max 30°"));
dbSimboli.put(new Long(104L),
new SimboloLavaggio(104, "Lavaggio delicato max 30°"));
dbSimboli.put(new Long(105L),
new SimboloLavaggio(105, "Lavaggio delicato max 30°"));
dbSimboli.put(new Long(106L),
new SimboloLavaggio(106, "Lavaggio delicato max 40°"));
dbSimboli.put(new Long(107L),
new SimboloLavaggio(107, "Lavaggio delicato max 40°"));
dbSimboli.put(new Long(108L),
new SimboloLavaggio(108, "Lavaggio delicato max 40°"));
dbSimboli.put(new Long(109L),
new SimboloLavaggio(109, "Lavaggio delicato max 50°"));
dbSimboli.put(new Long(110L),
new SimboloLavaggio(110, "Lavaggio delicato max 50°"));
dbSimboli.put(new Long(111L),
new SimboloLavaggio(111, "Lavaggio delicato max 60°"));
dbSimboli.put(new Long(112L),
new SimboloLavaggio(112, "Lavaggio delicato max 60°"));
dbSimboli.put(new Long(113L),
new SimboloLavaggio(113, "Lavaggio delicato max 70°"));
dbSimboli.put(new Long(114L),
new SimboloLavaggio(114, "Lavaggio delicato max 95°"));
dbSimboli.put(new Long(115L),
new SimboloLavaggio(115, "Lavaggio delicato max 95°"));
dbSimboli.put(new Long(201L), new SimboloLavaggio(201, "Non Candeggiabile"));
dbSimboli.put(new Long(202L),
new SimboloLavaggio(202, "Ammesso candeggio cloro e perborato"));
dbSimboli.put(new Long(203L),
new SimboloLavaggio(203, "Ammesso candeggio solo perborato"));
dbSimboli.put(new Long(204L), new SimboloLavaggio(204, "Ammesso candeggio con cloro"));
dbSimboli.put(new Long(301L), new SimboloLavaggio(301, "Non Asciugare"));
dbSimboli.put(new Long(302L), new SimboloLavaggio(302, "Temperatura inferiore a 60°"));
dbSimboli.put(new Long(303L), new SimboloLavaggio(303, "Alta Temperatura"));
dbSimboli.put(new Long(304L), new SimboloLavaggio(304, "Asciugare"));
dbSimboli.put(new Long(401L), new SimboloLavaggio(401, "Non stirare"));
dbSimboli.put(new Long(402L), new SimboloLavaggio(402, "Bassa Temperatura"));
dbSimboli.put(new Long(403L), new SimboloLavaggio(403, "Media Temperatura"));
dbSimboli.put(new Long(404L), new SimboloLavaggio(404, "Alta temperatura"));
dbSimboli.put(new Long(501L), new SimboloLavaggio(501, "Non pulire a secco"));
dbSimboli.put(new Long(502L), new SimboloLavaggio(502, "Tutti i solventi"));
dbSimboli.put(new Long(503L),
new SimboloLavaggio(503, "Tutti i solventi in uso"));
dbSimboli.put(new Long(504L), new SimboloLavaggio(504, "Benzina Avio e R113"));
dbSimboli.put(new Long(505L),
new SimboloLavaggio(505,
"Benzina Avio e R113 nel rispetto dei limiti di temperatura e umidita'"));
dbSimboli.put(new Long(506L),
new SimboloLavaggio(506, "Lavaggio con idrocarburi e trifluoro-tricloroetano"));
dbSimboli.put(new Long(507L),
new SimboloLavaggio(507,
"Lavaggio con idrocarburi e trifluoro-tricloroetano nel rispetto dei limiti di temperatura e umidita'"));
dbSimboli.put(new Long(601L),
new SimboloLavaggio(601, "Lavaggio ad acqua professionale"));
dbSimboli.put(new Long(602L),
new SimboloLavaggio(602, "Lavaggio ad acqua professionale"));
dbSimboli.put(new Long(603L),
new SimboloLavaggio(603, "Lavaggio ad acqua professionale"));
dbSimboli.put(new Long(701L), new SimboloLavaggio(701, "Asciugatura Naturale"));
dbSimboli.put(new Long(702L), new SimboloLavaggio(702, "Asciugatura Naturale"));
dbSimboli.put(new Long(703L), new SimboloLavaggio(703, "Asciugatura Naturale"));
dbSimboli.put(new Long(704L), new SimboloLavaggio(704, "Asciugatura Naturale"));
dbSimboli.put(new Long(705L), new SimboloLavaggio(705, "Asciugatura Naturale"));
dbSimboli.put(new Long(706L), new SimboloLavaggio(706, "Asciugatura Naturale"));
}
return dbSimboli;
}
public Vectumerator<SimboloLavaggio> getLavaggi() {
return getSimboli(41, 49);
}
public SimboloLavaggio getLavaggio() {
if (getDbSimboli().containsKey(new Long(this.lavaggio)))
return getDbSimboli().get(new Long(this.lavaggio));
return new SimboloLavaggio();
}
public SimboloLavaggio getPulituraSecco() {
if (getDbSimboli().containsKey(new Long(this.pulituraSecco)))
return getDbSimboli().get(new Long(this.pulituraSecco));
return new SimboloLavaggio();
}
public Vectumerator<SimboloLavaggio> getPulitureSecco() {
return getSimboli(31, 34);
}
private Vectumerator<SimboloLavaggio> getSimboli(int start, int end) {
Vectumerator<SimboloLavaggio> vec = new Vectumerator<>();
for (int i = start; i <= end; i++)
vec.addElement(getDbSimboli().get(new Long((long)i)));
return vec;
}
public SimboloLavaggio getStiratura() {
if (getDbSimboli().containsKey(new Long(this.stiratura)))
return getDbSimboli().get(new Long(this.stiratura));
return new SimboloLavaggio();
}
public Vectumerator<SimboloLavaggio> getStirature() {
return getSimboli(21, 24);
}
public Vectumerator<SimboloLavaggio> getTuttiSimboli() {
Vectumerator<SimboloLavaggio> vec = new Vectumerator<>();
Enumeration<SimboloLavaggio> enu = getDbSimboli().elements();
while (enu.hasMoreElements())
vec.addElement(enu.nextElement());
return vec;
}
public void setAsciugatura(long newAsciugatura) {
this.asciugatura = newAsciugatura;
}
public void setCandeggio(long newCandeggio) {
this.candeggio = newCandeggio;
}
public void setLavaggio(long newLavaggio) {
this.lavaggio = newLavaggio;
}
public void setPulituraSecco(long newPulituraSecco) {
this.pulituraSecco = newPulituraSecco;
}
public void setStiratura(long newStiratura) {
this.stiratura = newStiratura;
}
public long getAsciugaturaNaturale() {
return this.asciugaturaNaturale;
}
public void setAsciugaturaNaturale(long asciugaturaNaturale) {
this.asciugaturaNaturale = asciugaturaNaturale;
}
public long getLavaggioProfessionale() {
return this.lavaggioProfessionale;
}
public void setLavaggioProfessionale(long lavaggioProfessionale) {
this.lavaggioProfessionale = lavaggioProfessionale;
}
public boolean hasTuttiISimboli() {
if (this.candeggio == 0L || this.asciugatura == 0L || this.lavaggio == 0L || this.pulituraSecco == 0L || this.stiratura == 0L)
return false;
return true;
}
public boolean hasAlmenoUnSimbolo() {
if (this.candeggio != 0L || this.asciugatura != 0L || this.lavaggio != 0L || this.pulituraSecco != 0L || this.stiratura != 0L)
return true;
return false;
}
}

View file

@ -0,0 +1,30 @@
package com.ablia.common;
public class SimboloLavaggio {
private int codiceSimbolo;
private String descrizione;
public SimboloLavaggio() {}
public SimboloLavaggio(int codiceSimbolo, String descrizione) {
this.codiceSimbolo = codiceSimbolo;
this.descrizione = descrizione;
}
public int getCodiceSimbolo() {
return this.codiceSimbolo;
}
public String getDescrizione() {
return this.descrizione;
}
public void setCodiceSimbolo(int newCodiceSimbolo) {
this.codiceSimbolo = newCodiceSimbolo;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
}

View file

@ -0,0 +1,134 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class StatusMsg extends DBAdapter implements Serializable {
private static final long serialVersionUID = 1543946266505L;
private long id_statusMsg;
private String tag;
private String msg;
public StatusMsg(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public StatusMsg() {}
public void setId_statusMsg(long newId_statusMsg) {
this.id_statusMsg = newId_statusMsg;
}
public void setTag(String newTag) {
this.tag = newTag;
}
public void setMsg(String newMsg) {
this.msg = newMsg;
}
public long getId_statusMsg() {
return this.id_statusMsg;
}
public String getTag() {
return (this.tag == null) ? "" : this.tag.trim();
}
public String getMsg() {
return (this.msg == null) ? "" : this.msg.trim();
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator<StatusMsg> findByCR(StatusMsgCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select DISTINCT A.* from STATUS_MSG AS A";
String s_Sql_Order = " order by A.id_statusMsg";
WcString wc = new WcString();
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return (Vectumerator)findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return (Vectumerator)AB_EMPTY_VECTUMERATOR;
}
}
public void findByTag(String l_tag) {
String s_Sql_Find = "select DISTINCT A.* from STATUS_MSG AS A";
String s_Sql_Order = " order by A.id_statusMsg";
WcString wc = new WcString();
if (!l_tag.isEmpty())
wc.addWc("A.tag='" + l_tag + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
findFirstRecord(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
}
}
public static final synchronized ResParm deleteAllMsg(ApplParmFull apFull) {
StatusMsg bean = new StatusMsg(apFull);
ResParm rp = bean.delete("delete from STATUS_MSG");
return rp;
}
public static final synchronized ResParm deleteMsgByTag(ApplParmFull apFull, String l_tag) {
StatusMsg bean = new StatusMsg(apFull);
ResParm rp = bean.delete("delete from STATUS_MSG where tag='" + l_tag + "'");
return rp;
}
public static final synchronized void appendMsgByTag(ApplParmFull apFull, String l_tag, String l_msg) {
StatusMsg bean = new StatusMsg(apFull);
bean.findByTag(l_tag);
bean.setTag(l_tag);
bean.setMsg(String.valueOf(bean.getMsg()) + "\n" + l_msg);
bean.save();
}
public static final synchronized String getMsgByTag(ApplParmFull apFull, String l_tag) {
StatusMsg bean = new StatusMsg(apFull);
Vectumerator<StatusMsg> vec = bean.findByCR(null, 0, 0);
StringBuilder sb = new StringBuilder();
while (vec.hasMoreElements()) {
StatusMsg row = vec.nextElement();
if (!row.getTag().isEmpty()) {
sb.append(row.getTag());
sb.append(": ");
}
sb.append(row.getMsg());
if (vec.hasMoreElements())
sb.append("\n");
}
return sb.toString();
}
public static final synchronized String getMsgHtmlByTag(ApplParmFull apFull, String l_tag) {
return DBAdapter.convertStringToHtml(getMsgByTag(apFull, l_tag));
}
public static final synchronized void updateMsgByTag(ApplParmFull apFull, String l_tag, String l_msg) {
StatusMsg bean = new StatusMsg(apFull);
bean.findByTag(l_tag);
bean.setTag(l_tag);
bean.setMsg(l_msg);
bean.save();
}
}

View file

@ -0,0 +1,42 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class StatusMsgCR extends CRAdapter {
private long id_statusMsg;
private String tag;
private String msg;
public StatusMsgCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public StatusMsgCR() {}
public void setId_statusMsg(long newId_statusMsg) {
this.id_statusMsg = newId_statusMsg;
}
public void setTag(String newTag) {
this.tag = newTag;
}
public void setMsg(String newMsg) {
this.msg = newMsg;
}
public long getId_statusMsg() {
return this.id_statusMsg;
}
public String getTag() {
return (this.tag == null) ? "" : this.tag.trim();
}
public String getMsg() {
return (this.msg == null) ? "" : this.msg.trim();
}
}

View file

@ -0,0 +1,695 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class TableDesc extends DBAdapter implements Serializable {
private static final long serialVersionUID = 1501275837045L;
public static final long FORM_FIELD_INPUT = 0L;
public static final long FORM_FIELD_COMBO = 1L;
public static final long FORM_FIELD_COMBO_FLG = 2L;
public static final long FORM_FIELD_CHECKBOX = 3L;
public static final long FORM_FIELD_RADIOBUTON = 4L;
public static final long FORM_FIELD_TEXT_AREA = 5L;
public static final long FORM_FIELD_AJAX = 6L;
private long id_tableDesc;
private long flgAjaxUseSubmit;
private String ajaxNextAction;
private String label;
private long flgTipo;
private long flgReadOnly;
private long ordine;
private long rowNumbCR;
private long colLg;
private long colXsCR;
private String ajaxSearchString;
private String valoreDefaultCR;
private boolean firstField;
private Access access;
private long maxLenght;
private long flgHidden;
private long colLgCR;
private long colXs;
private long ordineCR;
private long rowNumb;
private long flgPk;
private long numColSearch;
private long flgFormField;
private long flgCR;
private long tabOrder;
private String tabName;
private String comboFlgValuelist;
private String toolTip;
private long flgHtml;
private long ajaxNChar;
private String nomeColonna;
private long flgAjaxUseMono;
private String id_access;
private String ajaxJavascriptmodify;
private String ajaxJavascriptnew;
private String ajaxFieldsMapping;
public TableDesc(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public TableDesc() {}
public void setId_tableDesc(long newId_tableDesc) {
this.id_tableDesc = newId_tableDesc;
}
public void setId_access(String newId_access) {
this.id_access = newId_access;
setAccess(null);
}
public void setNomeColonna(String newNomeColonna) {
this.nomeColonna = newNomeColonna;
}
public void setLabel(String newLabel) {
this.label = newLabel;
}
public void setFlgTipo(long newFlgTipo) {
this.flgTipo = newFlgTipo;
}
public void setFlgCR(long newFlgCR) {
this.flgCR = newFlgCR;
}
public void setOrdine(long newOrdine) {
this.ordine = newOrdine;
}
public void setRowNumb(long newRowNumb) {
this.rowNumb = newRowNumb;
}
public void setColLg(long newColLg) {
this.colLg = newColLg;
}
public void setColXs(long newColXs) {
this.colXs = newColXs;
}
public void setAjaxSearchString(String newAjaxSearchString) {
this.ajaxSearchString = newAjaxSearchString;
}
public void setAjaxFieldsMapping(String newAjaxReturnValues) {
this.ajaxFieldsMapping = newAjaxReturnValues;
}
public long getId_tableDesc() {
return this.id_tableDesc;
}
public String getId_access() {
return (this.id_access == null) ? "" : this.id_access.trim();
}
public String getNomeColonna() {
return (this.nomeColonna == null) ? "" : this.nomeColonna.trim();
}
public String getLabel() {
return (this.label == null) ? "" : this.label.trim();
}
public long getFlgTipo() {
return this.flgTipo;
}
public long getFlgCR() {
return this.flgCR;
}
public long getOrdine() {
return this.ordine;
}
public long getRowNumb() {
return this.rowNumb;
}
public long getColLg() {
return this.colLg;
}
public long getColXs() {
return this.colXs;
}
public String getAjaxSearchString() {
return (this.ajaxSearchString == null) ? "" : this.ajaxSearchString.trim();
}
public String getAjaxFieldsMapping() {
return (this.ajaxFieldsMapping == null) ? "" : this.ajaxFieldsMapping.trim();
}
public void setAccess(Access newAccess) {
this.access = newAccess;
}
public Access getAccess() {
this.access = (Access)getSecondaryObject(this.access, Access.class, getId_access());
return this.access;
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator<TableDesc> findHiddenByTable(String l_id_access) {
String s_Sql_Find = "select DISTINCT A.* from TABLE_DESC AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
wc.addWc("A.id_access='" + l_id_access + "'");
wc.addWc("A.flgHidden=1");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return (Vectumerator)findRows(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return (Vectumerator)AB_EMPTY_VECTUMERATOR;
}
}
public Vectumerator<TableDesc> findPrimaryDetailFieldsByTable(String l_id_access) {
String s_Sql_Find = "select DISTINCT A.* from TABLE_DESC AS A";
String s_Sql_Order = " order by A.rowNumb, A.ordine";
WcString wc = new WcString();
wc.addWc("A.id_access='" + l_id_access + "'");
wc.addWc("(A.flgHidden is null or A.flgHidden=0)");
wc.addWc("A.rowNumb>0");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return (Vectumerator)findRows(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return (Vectumerator)AB_EMPTY_VECTUMERATOR;
}
}
public void findByTabellaColonna(String nomeTabella, String nomeColonna) {
String s_Sql_Find = "select DISTINCT A.* from TABLE_DESC AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
wc.addWc("A.id_access='" + nomeTabella + "'");
wc.addWc("A.nomeColonna='" + nomeColonna + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
findFirstRecord(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
}
}
public Vectumerator<TableDesc> findByTabella(String nomeTabella, long l_flgSearchType) {
String s_Sql_Find = "select DISTINCT A.*, if(A.numColSearch is null,9999999999,A.numColSearch) as numColSearchOrder from TABLE_DESC AS A";
String s_Sql_Order = " order by A.flgPk desc,A.nomeColonna";
if (l_flgSearchType == 1L) {
s_Sql_Order = " order by A.flgPk desc,A.rowNumbCR,A.ordineCR, A.nomeColonna";
} else if (l_flgSearchType == 2L) {
s_Sql_Order = " order by numColSearchOrder, A.nomeColonna";
} else if (l_flgSearchType == 3L) {
s_Sql_Order = " order by A.flgPk desc,A.rowNumb,A.ordine, A.nomeColonna";
}
WcString wc = new WcString();
wc.addWc("A.id_access='" + nomeTabella + "'");
if (l_flgSearchType == 1L)
wc.addWc("A.flgCR=1");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return (Vectumerator)findRows(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return (Vectumerator)AB_EMPTY_VECTUMERATOR;
}
}
public long getMaxLenght() {
return this.maxLenght;
}
public void setMaxLenght(long maxLenght) {
this.maxLenght = maxLenght;
}
public long getFlgHidden() {
return this.flgHidden;
}
public void setFlgHidden(long flgHidden) {
this.flgHidden = flgHidden;
}
public long getRowNumbCR() {
return this.rowNumbCR;
}
public void setRowNumbCR(long rowNumbCR) {
this.rowNumbCR = rowNumbCR;
}
public long getColXsCR() {
return this.colXsCR;
}
public void setColXsCR(long colXsCR) {
this.colXsCR = colXsCR;
}
public long getColLgCR() {
return this.colLgCR;
}
public void setColLgCR(long colLgCR) {
this.colLgCR = colLgCR;
}
public long getOrdineCR() {
return this.ordineCR;
}
public void setOrdineCR(long ordineCR) {
this.ordineCR = ordineCR;
}
public long getFlgPk() {
return this.flgPk;
}
public void setFlgPk(long flgPk) {
this.flgPk = flgPk;
}
public long getNumColSearch() {
return this.numColSearch;
}
public void setNumColSearch(long numColSearch) {
this.numColSearch = numColSearch;
}
public Vectumerator<TableDesc> findByCR(TableDescCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select DISTINCT A.* from TABLE_DESC AS A";
String s_Sql_Order = " order by nomeColonna";
WcString wc = new WcString();
if (!CR.getSearchTxt().trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
StringBuffer txt = new StringBuffer("(");
while (st.hasMoreTokens()) {
String token = st.nextToken();
txt.append("(A.id_access like '%" + token + "%' )");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return (Vectumerator)findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return (Vectumerator)AB_EMPTY_VECTUMERATOR;
}
}
public String getComboDescColumnMethod() {
if (getNomeColonna().indexOf("id_") != 0 || getFlgPk() == 1L)
return "";
Access fkAccess = getFkAccess();
String comboDescColumn = fkAccess.getComboDescColumn(getNomeColonna());
System.out.println("comboDescColumn: " + getNomeColonna() + " " + comboDescColumn);
if (comboDescColumn != null) {
String theFkBean = String.valueOf(getNomeColonna().substring(3, 4).toUpperCase()) + getNomeColonna().substring(4);
String getMethodName = "get" + theFkBean + "()";
if (comboDescColumn.isEmpty())
return String.valueOf(getMethodName) + ".getDescrizione()";
return String.valueOf(getMethodName) + ".get" + comboDescColumn.substring(0, 1).toUpperCase() + comboDescColumn.substring(1) + "()";
}
return "";
}
public static final String getFormField(long l_flgFormField) {
switch ((int)l_flgFormField) {
case 6:
return "Ajax search";
case 3:
return "CheckBox";
case 1:
return "ComboBox";
case 2:
return "ComboBox con flg";
case 0:
return "Text";
case 4:
return "Radio Button";
case 5:
return "Text Area";
}
return "??";
}
public final String getFormField() {
return getFormField(getFlgFormField());
}
public void setFlgFormField(long flgFormField) {
this.flgFormField = flgFormField;
}
public static final String getTipo(long l_flgTipo) {
switch ((int)l_flgTipo) {
case 12:
return "Varchar";
case 1:
return "Char";
case -16:
return "Long N Varchar";
case -1:
return "Long Varchar";
case 4:
return "Integer";
case -5:
return "Bigint";
case 5:
return "Smallint";
case 8:
return "Double";
case 3:
return "Decimal";
case 6:
return "Float";
case 91:
return "Data";
case 92:
return "Time";
case 2013:
return "Time with timezone";
case 93:
return "Timestamp";
case 16:
return "Boolean";
}
return "Non Gestito: " + l_flgTipo;
}
public final String getTipo() {
return getTipo(getFlgTipo());
}
public long getFlgReadOnly() {
return this.flgReadOnly;
}
public void setFlgReadOnly(long flgReadOnly) {
this.flgReadOnly = flgReadOnly;
}
public long getTabOrder() {
return this.tabOrder;
}
public void setTabOrder(long tabOrder) {
this.tabOrder = tabOrder;
}
public String getTabName() {
return (this.tabName == null) ? "" : this.tabName.trim();
}
public void setTabName(String tabName) {
this.tabName = tabName;
}
public Vectumerator<TableDesc> findCRFieldsByTable(String l_id_access) {
String s_Sql_Find = "select DISTINCT A.* from TABLE_DESC AS A";
String s_Sql_Order = " order by A.rowNumbCR, A.ordineCR";
WcString wc = new WcString();
wc.addWc("A.id_access='" + l_id_access + "'");
wc.addWc("(A.flgHidden is null or A.flgHidden=0)");
wc.addWc("A.flgCR=1");
wc.addWc("A.rowNumbCR>0");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return (Vectumerator)findRows(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return (Vectumerator)AB_EMPTY_VECTUMERATOR;
}
}
public Vectumerator<TableDesc> findCRListFieldsByTable(String l_id_access) {
String s_Sql_Find = "select DISTINCT A.* from TABLE_DESC AS A";
String s_Sql_Order = " order by A.numColSearch";
WcString wc = new WcString();
wc.addWc("A.id_access='" + l_id_access + "'");
wc.addWc("A.numColSearch>0");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return (Vectumerator)findRows(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return (Vectumerator)AB_EMPTY_VECTUMERATOR;
}
}
public boolean isFirstField() {
return this.firstField;
}
public void setFirstField(boolean firstField) {
this.firstField = firstField;
}
public String getComboFlgValuelist() {
return (this.comboFlgValuelist == null) ? "" : this.comboFlgValuelist.trim();
}
public void setComboFlgValuelist(String newOptionValues) {
this.comboFlgValuelist = newOptionValues;
}
public String getToolTip() {
return (this.toolTip == null) ? "" : this.toolTip.trim();
}
public void setToolTip(String toolTip) {
this.toolTip = toolTip;
}
public long getFlgHtml() {
return this.flgHtml;
}
public void setFlgHtml(long flgHtml) {
this.flgHtml = flgHtml;
}
public ResParm updateFields(String fieldName, String value) {
if (getId_tableDesc() == 0L)
return new ResParm(false, "Errore! Impossibile aggiornare un bean nuovo.");
long valueL = 0L;
try {
valueL = Long.parseLong(value);
} catch (Exception e) {}
if (fieldName.equals("label")) {
setLabel(value);
} else if (fieldName.equals("flgFormField")) {
setFlgFormField(valueL);
} else if (fieldName.equals("flgHidden")) {
setFlgHidden(valueL);
} else if (fieldName.equals("flgReadOnly")) {
setFlgReadOnly(valueL);
} else if (fieldName.equals("valoreDefaultCR")) {
setValoreDefaultCR(value);
} else if (fieldName.equals("flgHtml")) {
setFlgHtml(valueL);
} else if (fieldName.equals("maxLenght")) {
setMaxLenght(valueL);
} else if (fieldName.equals("comboFlgValuelist")) {
setComboFlgValuelist(value);
} else if (fieldName.equals("ajaxFieldsMapping")) {
setAjaxFieldsMapping(value);
} else if (fieldName.equals("toolTip")) {
setToolTip(value);
} else if (fieldName.equals("ajaxSearchString")) {
setAjaxSearchString(value);
} else if (fieldName.equals("ajaxReturnValues")) {
setAjaxFieldsMapping(value);
} else if (fieldName.equals("flgCR")) {
setFlgCR(valueL);
} else if (fieldName.equals("rowNumb")) {
setRowNumb(valueL);
} else if (fieldName.equals("ordine")) {
setOrdine(valueL);
} else if (fieldName.equals("colLg")) {
setColLg(valueL);
} else if (fieldName.equals("colXs")) {
setColXs(valueL);
} else if (fieldName.equals("rowNumbCR")) {
setRowNumbCR(valueL);
} else if (fieldName.equals("ordineCR")) {
setOrdineCR(valueL);
} else if (fieldName.equals("colLgCR")) {
setColLgCR(valueL);
} else if (fieldName.equals("colXsCR")) {
setColXsCR(valueL);
} else if (fieldName.equals("numColSearch")) {
setNumColSearch(valueL);
}
return save();
}
public long getFlgFormField() {
return this.flgFormField;
}
public long getAjaxNChar() {
return this.ajaxNChar;
}
public void setAjaxNChar(long nChar) {
this.ajaxNChar = nChar;
}
public String getAjaxNextAction() {
return (this.ajaxNextAction == null) ? "" : this.ajaxNextAction.trim();
}
public void setAjaxNextAction(String ajaxNextAction) {
this.ajaxNextAction = ajaxNextAction;
}
public long getFlgAjaxUseSubmit() {
return this.flgAjaxUseSubmit;
}
public void setFlgAjaxUseSubmit(long flgAjaxUseSubmit) {
this.flgAjaxUseSubmit = flgAjaxUseSubmit;
}
public long getFlgAjaxUseMono() {
return this.flgAjaxUseMono;
}
public void setFlgAjaxUseMono(long flgAjaxUseMono) {
this.flgAjaxUseMono = flgAjaxUseMono;
}
public String getAjaxJavascriptmodify() {
return (this.ajaxJavascriptmodify == null) ? "" : this.ajaxJavascriptmodify.trim();
}
public void setAjaxJavascriptmodify(String ajaxJavascriptmodify) {
this.ajaxJavascriptmodify = ajaxJavascriptmodify;
}
public String getAjaxJavascriptnew() {
return (this.ajaxJavascriptnew == null) ? "" : this.ajaxJavascriptnew.trim();
}
public void setAjaxJavascriptnew(String ajaxJavascriptnew) {
this.ajaxJavascriptnew = ajaxJavascriptnew;
}
public Access getFkAccess() {
if (getNomeColonna().indexOf("id_") != 0 || getFlgPk() == 1L)
return new Access(getApFull());
String id_access = Access.convertFieldToTableName(getNomeColonna().substring(3));
Access access = new Access(getApFull());
access.findByPrimaryKey(id_access);
return access;
}
public String getValoreDefaultCR() {
return (this.valoreDefaultCR == null) ? "" : this.valoreDefaultCR.trim();
}
public void setValoreDefaultCR(String valoreDefaultCR) {
this.valoreDefaultCR = valoreDefaultCR;
}
public Vectumerator<TableDesc> findByTabellaDefaultValue(String nomeTabella) {
String s_Sql_Find = "select DISTINCT A.*, if(A.numColSearch is null,9999999999,A.numColSearch) as numColSearchOrder from TABLE_DESC AS A";
String s_Sql_Order = " order by A.flgPk desc,A.nomeColonna";
WcString wc = new WcString();
wc.addWc("A.id_access='" + nomeTabella + "'");
wc.addWc("A.defaultValueCR is not null");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return (Vectumerator)findRows(stmt);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return (Vectumerator)AB_EMPTY_VECTUMERATOR;
}
}
}

View file

@ -0,0 +1,180 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class TableDescCR extends CRAdapter {
private long id_tableDesc;
private String id_access;
private String nomeColonna;
private String lebel;
private long flgTipo;
private long flgCR;
private long ordine;
private long rowNumb;
private long colLg;
private long colXs;
private String optionValues;
private String comboDescColumn;
private String ajaxSearchString;
private String ajaxReturnValues;
public static final long SEARCH_TYPE_ELENCO_COLONNE = 0L;
public static final long SEARCH_TYPE_VISTA_CR = 1L;
public static final long SEARCH_TYPE_VISTA_CR_LISTA = 2L;
public static final long SEARCH_TYPE_VISTA_DETTAGLIO = 3L;
private Access access;
public TableDescCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public TableDescCR() {}
public void setId_tableDesc(long newId_tableDesc) {
this.id_tableDesc = newId_tableDesc;
}
public void setId_access(String newId_access) {
this.id_access = newId_access;
setAccess(null);
}
public void setNomeColonna(String newNomeColonna) {
this.nomeColonna = newNomeColonna;
}
public void setLebel(String newLebel) {
this.lebel = newLebel;
}
public void setFlgTipo(long newFlgTipo) {
this.flgTipo = newFlgTipo;
}
public void setFlgCR(long newFlgCR) {
this.flgCR = newFlgCR;
}
public void setOrdine(long newOrdine) {
this.ordine = newOrdine;
}
public void setRowNumb(long newRowNumb) {
this.rowNumb = newRowNumb;
}
public void setColLg(long newColLg) {
this.colLg = newColLg;
}
public void setColXs(long newColXs) {
this.colXs = newColXs;
}
public void setOptionValues(String newOptionValues) {
this.optionValues = newOptionValues;
}
public void setComboDescColumn(String newComboDescColumn) {
this.comboDescColumn = newComboDescColumn;
}
public void setAjaxSearchString(String newAjaxSearchString) {
this.ajaxSearchString = newAjaxSearchString;
}
public void setAjaxReturnValues(String newAjaxReturnValues) {
this.ajaxReturnValues = newAjaxReturnValues;
}
public long getId_tableDesc() {
return this.id_tableDesc;
}
public String getId_access() {
return (this.id_access == null) ? "" : this.id_access.trim();
}
public String getNomeColonna() {
return (this.nomeColonna == null) ? "" : this.nomeColonna.trim();
}
public String getLebel() {
return (this.lebel == null) ? "" : this.lebel.trim();
}
public long getFlgTipo() {
return this.flgTipo;
}
public long getFlgCR() {
return this.flgCR;
}
public long getOrdine() {
return this.ordine;
}
public long getRowNumb() {
return this.rowNumb;
}
public long getColLg() {
return this.colLg;
}
public long getColXs() {
return this.colXs;
}
public String getOptionValues() {
return (this.optionValues == null) ? "" : this.optionValues.trim();
}
public String getComboDescColumn() {
return (this.comboDescColumn == null) ? "" : this.comboDescColumn.trim();
}
public String getAjaxSearchString() {
return (this.ajaxSearchString == null) ? "" : this.ajaxSearchString.trim();
}
public String getAjaxReturnValues() {
return (this.ajaxReturnValues == null) ? "" : this.ajaxReturnValues.trim();
}
public void setAccess(Access newAccess) {
this.access = newAccess;
}
public Access getAccess() {
this.access = (Access)getSecondaryObject(this.access, Access.class, getId_access());
return this.access;
}
public final String getTipo() {
return TableDesc.getTipo(getFlgTipo());
}
public static final String getTipo(long l_flgTipo) {
return TableDesc.getTipo(l_flgTipo);
}
}

View file

@ -0,0 +1,35 @@
package com.ablia.common;
import com.ablia.util.Vectumerator;
public interface TipoInterface {
Vectumerator findFigli(int paramInt1, int paramInt2);
long getNumeroFigli(long paramLong);
long getId_tipoPadre();
String getDescrizione();
String getDescrizioneCompleta();
String getDescrizione4Script();
long getFlgUsaVarianti();
long getId_tipo();
String getDescrizione(String paramString);
String getDescrizione4Script(String paramString);
String getDescrizioneCompleta(String paramString);
String getDescrizione(String paramString, int paramInt);
String getDescrizione(String paramString1, String paramString2);
String getDescrizione(String paramString1, String paramString2, int paramInt);
String getDescrizione(int paramInt);
}

View file

@ -0,0 +1,70 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class TipoPostazione extends DBAdapter implements Serializable {
private long id_tipoPostazione;
private String descrizione;
public TipoPostazione(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public TipoPostazione() {}
public void setId_tipoPostazione(long newId_tipoAzienda) {
this.id_tipoPostazione = newId_tipoAzienda;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public long getId_tipoPostazione() {
return this.id_tipoPostazione;
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione;
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator findByCR(TipoPostazioneCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from TIPO_POSTAZIONE AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
if (!CR.getSearchTxt().trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
StringBuffer txt = new StringBuffer("(");
while (st.hasMoreTokens()) {
String token = st.nextToken();
txt.append("(A.Cognome like '%" + token + "%' or A.Nome like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
}

View file

@ -0,0 +1,32 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class TipoPostazioneCR extends CRAdapter {
private long id_tipoPostazione;
private String descrizione;
public TipoPostazioneCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public TipoPostazioneCR() {}
public void setId_tipoPostazione(long newId_tipoAzienda) {
this.id_tipoPostazione = newId_tipoAzienda;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public long getId_tipoPostazione() {
return this.id_tipoPostazione;
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione;
}
}

View file

@ -0,0 +1,177 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.util.Vectumerator;
import com.lowagie.text.Font;
import com.lowagie.text.pdf.BaseFont;
import java.awt.Color;
import java.io.File;
import java.util.Enumeration;
import java.util.Hashtable;
public class TtFont extends DBAdapter {
private String ttfName;
private String ttfPath;
private Parm parm;
private static Hashtable fonts;
private static final Font PDF_f_Default = new Font(2, 10.0F,
0);
private static final int PDF_fsize_Default = 10;
private static TtFont ttFontInstance;
static final String WIN_DEFAULT_TTF_PATH = "C:/windows/fonts/";
private TtFont() {}
private TtFont(ApplParmFull newApplParmFull) {
setApFull(newApplParmFull);
}
public ResParm delete() {
return null;
}
public Vectumerator findAll() {
int numRec = 0;
File dir = new File(getTtfPath());
File[] fonts = dir.listFiles();
if (fonts != null) {
File theFont = null;
Vectumerator<TtFont> vec = new Vectumerator();
try {
for (int i = 0; i < fonts.length; i++) {
theFont = fonts[i];
if (theFont.getName().toLowerCase().endsWith("ttf")) {
numRec++;
TtFont myBean = new TtFont(getApFull());
myBean.setTtfName(theFont.getName());
vec.addElement(myBean);
}
}
vec.setTotNumberOfRecords(numRec);
return vec;
} catch (Exception e) {
e.printStackTrace();
return DBAdapter.AB_EMPTY_VECTUMERATOR;
}
}
return DBAdapter.AB_EMPTY_VECTUMERATOR;
}
public void findByPrimaryKey(Object obj) {}
public int getDBState() {
return 1;
}
public String getTtfPath() {
return String.valueOf(getDocBase()) + "admin/_V4/_font/";
}
public ResParm save() {
return null;
}
public void setNuovaIstanzaOggettoRemoto(boolean flag) {}
public Object[] getFieldSetArg(String parmValue, Class type) {
return null;
}
public void setTtfPath(String ttfPath) {
this.ttfPath = ttfPath;
}
public String getTtfName() {
return this.ttfName;
}
public void setTtfName(String ttfName) {
this.ttfName = ttfName;
}
public String getTtf() {
return String.valueOf(getTtfPath()) + getTtfName();
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Parm getParm(String theKey) {
if (this.parm == null)
this.parm = new Parm(getApFull());
try {
this.parm.findByCodice(theKey);
return this.parm;
} catch (Exception e) {
handleDebug(e);
return this.parm;
}
}
public Font getFont(String baseFont, int size, int type, Color theColor) {
Long fontKey = new Long(
(long)(baseFont.hashCode() + size + type + ((theColor == null) ? 0 : theColor.hashCode())));
if (!getFonts().containsKey(fontKey))
try {
Font ft;
if (baseFont.isEmpty()) {
ft = PDF_f_Default;
} else {
BaseFont bf = BaseFont.createFont(baseFont,
"Identity-H", true);
int fontSize = size;
if (fontSize <= 0)
fontSize = 10;
if (theColor == null) {
ft = new Font(bf, (float)fontSize, type, Color.black);
} else {
ft = new Font(bf, (float)fontSize, type, theColor);
}
}
getFonts().put(fontKey, ft);
return ft;
} catch (Exception e) {
e.printStackTrace();
return PDF_f_Default;
}
return (Font)getFonts().get(fontKey);
}
protected boolean isDatabaseBean() {
return false;
}
public static synchronized TtFont getInstance(ApplParmFull ap) {
if (ttFontInstance == null)
ttFontInstance = new TtFont(ap);
return ttFontInstance;
}
public static synchronized void reset() {
Enumeration<Font> enu = getFonts().elements();
while (enu.hasMoreElements()) {
Font row = enu.nextElement();
getFonts().remove(row);
row = null;
}
fonts = null;
}
private static Hashtable getFonts() {
if (fonts == null)
fonts = new Hashtable();
return fonts;
}
}

View file

@ -0,0 +1,121 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
public class UserAccess extends DBAdapter implements Serializable {
private static final long serialVersionUID = 1L;
private long flgRW;
private String id_access;
private long id_userAccess;
private Access access;
private Users users;
private long id_users;
public Vectumerator findAccesssByUser(long l_id_user, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from USER_ACCESS AS A, ACCESS AS B";
String s_Sql_Order = " order by B.descrizione";
WcString wc = new WcString();
wc.addWc("A.id_access =B.id_access");
wc.addWc("A.id_users =" + l_id_user);
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (Exception e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public UserAccess() {}
public UserAccess(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public long getFlgRW() {
return this.flgRW;
}
public String getRW() {
return DBAdapter.getRW(getFlgRW());
}
public String getId_access() {
return (this.id_access == null) ? "" : this.id_access;
}
public long getId_users() {
return this.id_users;
}
public Access getAccess() {
this.access = (Access)getSecondaryObject(this.access, Access.class, getId_access());
return this.access;
}
public Users getUsers() {
this.users = (Users)getSecondaryObject(this.users, Users.class, new Long(getId_users()));
return this.users;
}
public void setFlgRW(long newFlgRW) {
this.flgRW = newFlgRW;
}
public void setId_access(String newId_access) {
this.id_access = newId_access;
setAccess(null);
}
public void setId_users(long newId_user) {
this.id_users = newId_user;
setUsers(null);
}
public void setAccess(Access newAccess) {
this.access = newAccess;
}
public void setUsers(Users newUser) {
this.users = newUser;
}
public long getId_userAccess() {
return this.id_userAccess;
}
public void setId_userAccess(long id_userAccess) {
this.id_userAccess = id_userAccess;
}
public void findByUserAccess(long l_id_user, String l_id_access) {
String s_Sql_Find = "select A.* from USER_ACCESS AS A";
WcString wc = new WcString();
wc.addWc("A.id_users =" + l_id_user);
wc.addWc("A.id_access ='" + l_id_access + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString());
findFirstRecord(stmt);
} catch (Exception e) {
handleDebug(e);
}
}
}

View file

@ -0,0 +1,172 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class UserAccessGroup extends DBAdapter implements Serializable {
private long id_userAccessGroup;
private long id_accessGroup;
private long id_users;
private AccessGroup accessGroup;
private Users users;
public UserAccessGroup(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public UserAccessGroup() {}
public void setId_userAccessGroup(long newId_userAccessGroup) {
this.id_userAccessGroup = newId_userAccessGroup;
}
public void setId_accessGroup(long newId_accessGroup) {
this.id_accessGroup = newId_accessGroup;
setAccessGroup(null);
}
public void setId_users(long newId_users) {
this.id_users = newId_users;
setUsers(null);
}
public long getId_userAccessGroup() {
return this.id_userAccessGroup;
}
public long getId_accessGroup() {
return this.id_accessGroup;
}
public long getId_users() {
return this.id_users;
}
public void setAccessGroup(AccessGroup newAccessGroup) {
this.accessGroup = newAccessGroup;
}
public AccessGroup getAccessGroup() {
this.accessGroup = (AccessGroup)getSecondaryObject((DBAdapter)this.accessGroup,
AccessGroup.class, getId_accessGroup());
return this.accessGroup;
}
public void setUsers(Users newUsers) {
this.users = newUsers;
}
public Users getUsers() {
this.users = (Users)getSecondaryObject((DBAdapter)this.users, Users.class, getId_users());
return this.users;
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator findByCR(UserAccessGroupCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from USER_ACCESS_GROUP AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
if (!CR.getSearchTxt().trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(),
" ");
StringBuffer txt = new StringBuffer("(");
while (st.hasMoreTokens()) {
String token = st.nextToken();
txt.append("(A.descrizione like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
try {
PreparedStatement stmt = getConn().prepareStatement(
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public Vectumerator findByUser(long l_id_user, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from USER_ACCESS_GROUP AS A, USERS as B, ACCESS_GROUP AS C";
String s_Sql_Order = " order by C.descrizione, B.cognome, B.nome";
WcString wc = new WcString();
wc.addWc("A.id_users =B.id_users");
wc.addWc("A.id_accessGroup =C.id_accessGroup");
wc.addWc("A.id_users =" + l_id_user);
try {
PreparedStatement stmt = getConn().prepareStatement(
String.valueOf(s_Sql_Find) + wc + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (Exception e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public Vectumerator findByAccessGroup(long l_id_accessGroup, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from USER_ACCESS_GROUP AS A, USERS AS B, ACCESS_GROUP AS C";
String s_Sql_Order = " order by C.descrizione, B.cognome, B.nome";
WcString wc = new WcString();
wc.addWc("A.id_users =B.id_users");
wc.addWc("A.id_accessGroup=C.id_accessGroup");
wc.addWc("A.id_accessGroup =" + l_id_accessGroup);
try {
PreparedStatement stmt = getConn().prepareStatement(
String.valueOf(s_Sql_Find) + wc + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (Exception e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public void findByAccessGroupUser(long l_id_accessGroup, long l_id_user) {
String s_Sql_Find = "select A.* from USER_ACCESS_GROUP AS A";
String wc = "";
wc = buildWc(wc, "A.id_users =" + l_id_user);
wc = buildWc(wc, "A.id_accessGroup =" + l_id_accessGroup);
try {
PreparedStatement stmt = getConn().prepareStatement(
String.valueOf(s_Sql_Find) + wc);
findFirstRecord(stmt);
} catch (Exception e) {
handleDebug(e);
}
}
public void findByAccessUser(String l_id_access, long l_id_user) {
String s_Sql_Find = "select A.* from USER_ACCESS_GROUP AS A, ACCESS_GROUP_ACCESS AS B, ACCESS AS C";
String s_Sql_Order = " order by C.descrizione";
WcString wc = new WcString();
wc.addWc("A.id_accessGroup =B.id_accessGroup");
wc.addWc("B.id_access=C.id_access");
wc.addWc("A.id_users =" + l_id_user);
wc.addWc("B.id_access ='" + l_id_access + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(
String.valueOf(s_Sql_Find) + wc + s_Sql_Order);
findFirstRecord(stmt);
} catch (Exception e) {
handleDebug(e);
}
}
}

View file

@ -0,0 +1,71 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
import com.ablia.db.DBAdapter;
public class UserAccessGroupCR extends CRAdapter {
private long id_userAccessGroup;
private long id_accessGroup;
private long id_users;
private AccessGroup accessGroup;
private Users users;
public UserAccessGroupCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public UserAccessGroupCR() {}
public void setId_userAccessGroup(long newId_userAccessGroup) {
this.id_userAccessGroup = newId_userAccessGroup;
}
public void setId_accessGroup(long newId_accessGroup) {
this.id_accessGroup = newId_accessGroup;
setAccessGroup(null);
}
public void setId_users(long newId_users) {
this.id_users = newId_users;
setUsers(null);
}
public long getId_userAccessGroup() {
return this.id_userAccessGroup;
}
public long getId_accessGroup() {
return this.id_accessGroup;
}
public long getId_users() {
return this.id_users;
}
public void setAccessGroup(AccessGroup newAccessGroup) {
this.accessGroup = newAccessGroup;
}
public AccessGroup getAccessGroup() {
this.accessGroup = (AccessGroup)getSecondaryObject(
(DBAdapter)this.accessGroup,
AccessGroup.class, getId_accessGroup());
return this.accessGroup;
}
public void setUsers(Users newUsers) {
this.users = newUsers;
}
public Users getUsers() {
this.users = (Users)getSecondaryObject(
(DBAdapter)this.users,
Users.class, getId_users());
return this.users;
}
}

View file

@ -0,0 +1,148 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.util.Hashtable;
import java.util.StringTokenizer;
public class UserProfile extends DBAdapter implements Serializable {
private long id_userProfile;
private String descrizione;
private String policy;
public UserProfile() {}
public UserProfile(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
public boolean checkRights(long l_id_profiloUtente) {
if (getPolicy().equals("*"))
return true;
StringTokenizer st = new StringTokenizer(getPolicy(), ",");
while (st.hasMoreTokens()) {
if (l_id_profiloUtente == Long.parseLong(st.nextToken()))
return true;
}
return false;
}
protected void deleteCascade() {}
public void fillObject(Hashtable htable) {}
public Vectumerator findProfiles(String l_listaProfili) {
String s_Sql_Find = "select A.* from USER_PROFILE AS A";
String wc = "";
if (l_listaProfili.equals("#")) {
wc = " where id_userProfile is null";
} else if (!l_listaProfili.equals("*")) {
StringTokenizer st = new StringTokenizer(l_listaProfili, ",");
while (st.hasMoreTokens()) {
if (!wc.isEmpty()) {
wc = String.valueOf(wc) + " or id_userProfile=" + st.nextToken();
continue;
}
wc = " where id_userProfile=" + st.nextToken();
}
}
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc);
return findRows(stmt);
} catch (Exception e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public Vectumerator findUserProfiles() {
String s_Sql_Find = "select A.* from USER_PROFILE AS A";
String wc = " where id_userProfile !=1";
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc);
return findRows(stmt);
} catch (Exception e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public Vectumerator findUserProfiles(String policy) {
String s_Sql_Find = "select A.* from USER_PROFILE AS A";
String wc = "";
wc = managePolicyFind(policy, wc);
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc);
return findRows(stmt);
} catch (Exception e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione;
}
public long getId_userProfile() {
return this.id_userProfile;
}
public String getPolicy() {
if (getId_userProfile() == 1L)
return "*";
return (this.policy == null) ? "#" : this.policy;
}
protected String managePolicyFind(String policy, String l_wc) {
if (policy.equals("#") || policy.isEmpty()) {
l_wc = buildWc(l_wc, "A.id_userProfile is null");
} else if (!policy.equals("*")) {
StringTokenizer st = new StringTokenizer(policy, ",");
String l_wcOr = "";
while (st.hasMoreTokens()) {
if (!l_wcOr.isEmpty()) {
l_wcOr = String.valueOf(l_wcOr) + " or id_userProfile=" + st.nextToken();
continue;
}
l_wcOr = " id_userProfile=" + st.nextToken();
}
l_wc = buildWc(l_wc, "(" + l_wcOr + ")");
}
return l_wc;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public void setId_userProfile(long newId_profiloUtente) {
this.id_userProfile = newId_profiloUtente;
}
public void setPolicy(String newPolicy) {
this.policy = newPolicy;
}
protected void setPrimaryKey(long newPrimaryKey) {
setId_userProfile(newPrimaryKey);
}
protected boolean isUseSafeUpdate() {
return true;
}
public Vectumerator findByCR(UserProfileCR CR, int pageNumber, int pageRows) {
return findAll();
}
}

View file

@ -0,0 +1,22 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class UserProfileCR extends CRAdapter {
private String descrizioneS;
public UserProfileCR() {}
public UserProfileCR(ApplParmFull newAp) {
super(newAp);
}
public String getDescrizioneS() {
return (this.descrizioneS == null) ? "" : this.descrizioneS.trim();
}
public void setDescrizioneS(String descrizioneS) {
this.descrizioneS = descrizioneS;
}
}

View file

@ -0,0 +1,109 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class UserWhitelist extends DBAdapter implements Serializable {
private long id_userWhitelist;
private long id_whitelist;
private long id_users;
private Whitelist whitelist;
private Users users;
public UserWhitelist(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public UserWhitelist() {}
public void setId_userWhitelist(long newId_usersWhitelist) {
this.id_userWhitelist = newId_usersWhitelist;
}
public void setId_whitelist(long newId_whitelist) {
this.id_whitelist = newId_whitelist;
setWhitelist(null);
}
public void setId_users(long newId_users) {
this.id_users = newId_users;
setUsers(null);
}
public long getId_userWhitelist() {
return this.id_userWhitelist;
}
public long getId_whitelist() {
return this.id_whitelist;
}
public long getId_users() {
return this.id_users;
}
public void setWhitelist(Whitelist newWhitelist) {
this.whitelist = newWhitelist;
}
public Whitelist getWhitelist() {
this.whitelist = (Whitelist)getSecondaryObject(
(DBAdapter)this.whitelist,
Whitelist.class, getId_whitelist());
return this.whitelist;
}
public void setUsers(Users newUsers) {
this.users = newUsers;
}
public Users getUsers() {
this.users = (Users)getSecondaryObject(
(DBAdapter)this.users,
Users.class, getId_users());
return this.users;
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator findByCR(UserWhitelistCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from USERS_WHITELIST AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
if (!CR.getSearchTxt().trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
StringBuffer txt = new StringBuffer("(");
while (st.hasMoreTokens()) {
String token = st.nextToken();
txt.append("(A.Cognome like '%" + token + "%' or A.Nome like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
}

View file

@ -0,0 +1,71 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
import com.ablia.db.DBAdapter;
public class UserWhitelistCR extends CRAdapter {
private long id_userWhitelist;
private long id_whitelist;
private long id_users;
private Whitelist whitelist;
private Users users;
public UserWhitelistCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public UserWhitelistCR() {}
public void setId_userWhitelist(long newId_usersWhitelist) {
this.id_userWhitelist = newId_usersWhitelist;
}
public void setId_whitelist(long newId_whitelist) {
this.id_whitelist = newId_whitelist;
setWhitelist(null);
}
public void setId_users(long newId_users) {
this.id_users = newId_users;
setUsers(null);
}
public long getId_userWhitelist() {
return this.id_userWhitelist;
}
public long getId_whitelist() {
return this.id_whitelist;
}
public long getId_users() {
return this.id_users;
}
public void setWhitelist(Whitelist newWhitelist) {
this.whitelist = newWhitelist;
}
public Whitelist getWhitelist() {
this.whitelist = (Whitelist)getSecondaryObject(
(DBAdapter)this.whitelist,
Whitelist.class, getId_whitelist());
return this.whitelist;
}
public void setUsers(Users newUsers) {
this.users = newUsers;
}
public Users getUsers() {
this.users = (Users)getSecondaryObject(
(DBAdapter)this.users,
Users.class, getId_users());
return this.users;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,176 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class UsersCR extends CRAdapter {
private String flgValido;
private boolean code1 = false;
private long id_userProfile;
private String policy;
private UserProfile userProfile;
private String txtRicerca;
private String cognome;
private String eMail;
private String login;
private String nome;
private long flgPresenza = -1L;
private String codFisc;
private long flgMl = -1L;
private long flgControlCode = -1L;
private long id_usersS;
public UsersCR() {}
public UsersCR(Users theUser) {
setPolicy(theUser.getUserProfile().getPolicy());
}
public UsersCR(ApplParmFull newAp) {
setApFull(newAp);
}
public UsersCR(ApplParmFull newAp, Users theUser) {
setApFull(newAp);
setPolicy(theUser.getUserProfile().getPolicy());
}
public String getFlgValido() {
return (this.flgValido == null) ? "" : this.flgValido;
}
public long getId_userProfile() {
return this.id_userProfile;
}
public String getPolicy() {
return (this.policy == null) ? "" : this.policy;
}
public UserProfile getUserProfile() {
if (this.userProfile == null && getId_userProfile() != 0L)
try {
this.userProfile = new UserProfile(getApFull());
this.userProfile.findByPrimaryKey(new Long(getId_userProfile()));
} catch (Exception e) {}
return (this.userProfile == null) ? new UserProfile() : this.userProfile;
}
public String getTxtRicerca() {
return (this.txtRicerca == null) ? "" : this.txtRicerca;
}
public void setFlgValido(String newFlgValido) {
this.flgValido = newFlgValido;
}
public void setId_userProfile(long newId_profiloUtente) {
this.id_userProfile = newId_profiloUtente;
}
public void setPolicy(String newPolicy) {
this.policy = newPolicy;
}
public void setUserProfile(UserProfile newProfiloUtente) {
this.userProfile = newProfiloUtente;
}
public void setTxtRicerca(String newTxtRicerca) {
this.txtRicerca = newTxtRicerca;
}
public boolean isCode1() {
return this.code1;
}
public void setCode1(boolean code1) {
this.code1 = code1;
}
public String getCognome() {
return (this.cognome == null) ? "" : this.cognome;
}
public void setCognome(String cognome) {
this.cognome = cognome;
}
public String getEMail() {
return (this.eMail == null) ? "" : this.eMail;
}
public void setEMail(String mail) {
this.eMail = mail;
}
public String getLogin() {
return (this.login == null) ? "" : this.login;
}
public void setLogin(String login) {
this.login = login;
}
public String getNome() {
return (this.nome == null) ? "" : this.nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public long getFlgPresenza() {
return this.flgPresenza;
}
public void setFlgPresenza(long flgPresenza) {
this.flgPresenza = flgPresenza;
}
public String getCodFisc() {
return (this.codFisc == null) ? "" : this.codFisc.trim();
}
public void setCodFisc(String codFisc) {
this.codFisc = codFisc;
}
public long getFlgMl() {
return this.flgMl;
}
public void setFlgMl(long flgMl) {
this.flgMl = flgMl;
}
public long getFlgControlCode() {
return this.flgControlCode;
}
public void setFlgControlCode(long flgControlCode) {
this.flgControlCode = flgControlCode;
}
public long getId_usersS() {
return this.id_usersS;
}
public void setId_usersS(long id_usersS) {
this.id_usersS = id_usersS;
}
}

View file

@ -0,0 +1,57 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.pre.Presenza;
import java.util.Hashtable;
public interface UsersI {
String getChangeLog();
long getId_userProfile();
long getFlgPresenza();
Presenza getUltimoMovimento();
long getNextMovValido();
String getCognomeNome();
String getDescrizione();
String getCognome();
String getNome();
UserProfile getUserProfile();
void initApplicationParms(ApplParmFull paramApplParmFull);
long getGrantType(String paramString);
long getGrantType(String paramString, boolean paramBoolean);
String translate(String paramString1, String paramString2);
long getId_users();
long getFlgChangeLog();
void resetChangeLog();
PostazioneI getPostazione();
String getScadenzaPasswordMessage();
long getGiorniAScadenzaPassword();
long getFlgSuper();
Hashtable<String, Long> getHtAccess();
String getImgFileName(int paramInt);
String getLogin();
String getLang();
}

View file

@ -0,0 +1,81 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class Whitelist extends DBAdapter implements Serializable {
private long id_whitelist;
private String descrizione;
private String ipAddress;
public Whitelist(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public Whitelist() {}
public void setId_whitelist(long newId_whitelist) {
this.id_whitelist = newId_whitelist;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public void setIpAddress(String newIpAddress) {
this.ipAddress = newIpAddress;
}
public long getId_whitelist() {
return this.id_whitelist;
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione.trim();
}
public String getIpAddress() {
return (this.ipAddress == null) ? "" : this.ipAddress.trim();
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public Vectumerator findByCR(WhitelistCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select A.* from WHITELIST AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
if (!CR.getSearchTxt().trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
StringBuffer txt = new StringBuffer("(");
while (st.hasMoreTokens()) {
String token = st.nextToken();
txt.append("(A.Cognome like '%" + token + "%' or A.Nome like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
try {
PreparedStatement stmt = getConn().prepareStatement(String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
removeCPConnection();
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
}

View file

@ -0,0 +1,42 @@
package com.ablia.common;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class WhitelistCR extends CRAdapter {
private long id_whitelist;
private String descrizione;
private String ipAddress;
public WhitelistCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public WhitelistCR() {}
public void setId_whitelist(long newId_whitelist) {
this.id_whitelist = newId_whitelist;
}
public void setDescrizione(String newDescrizione) {
this.descrizione = newDescrizione;
}
public void setIpAddress(String newIpAddress) {
this.ipAddress = newIpAddress;
}
public long getId_whitelist() {
return this.id_whitelist;
}
public String getDescrizione() {
return (this.descrizione == null) ? "" : this.descrizione.trim();
}
public String getIpAddress() {
return (this.ipAddress == null) ? "" : this.ipAddress.trim();
}
}

View file

@ -0,0 +1,17 @@
package com.ablia.db;
public interface AddImgInterface {
String getPathAttach();
String getImgFileName(int paramInt);
String getImgFileName(int paramInt, String paramString);
String getImgTmst();
void setImgTmst(String paramString);
ResParm save();
void findByPrimaryKey(long paramLong);
}

View file

@ -0,0 +1,957 @@
package com.ablia.db;
import com.ablia.common.Parm;
import com.ablia.common.TtFont;
import com.ablia.util.Debug;
import com.ablia.util.FileWr;
import com.ablia.util.SimpleDateFormat;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.FileInputStream;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.text.NumberFormat;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
import java.util.Properties;
import java.util.ResourceBundle;
public class ApplParm extends Debug implements Serializable {
private static final long serialVersionUID = 1L;
private static HashMap<Locale, NumberFormat> hmNf0 = new HashMap<>();
private static HashMap<Locale, NumberFormat> hmNf1 = new HashMap<>();
private static HashMap<Locale, NumberFormat> hmNf2 = new HashMap<>();
private static HashMap<Locale, NumberFormat> hmNf3 = new HashMap<>();
private static HashMap<Locale, NumberFormat> hmNf4 = new HashMap<>();
private static HashMap<String, Locale> hmLocale = new HashMap<>();
public static final String DB_VALIDATION_QUERY = "SELECT 1";
private String apCode;
private boolean block = true;
public static final int CONNECTION_LIFE_TIME_DEFAULT_MIN = 0;
private int connectionLifeTime = 0;
private String database;
public static final String DB_PROPERTIES_FILE = "ablia";
public static final String PROP_DB_DRIVER = "dbDriver";
public static final String PROP_DB_DATABASE = "database";
public static final String PROP_DB_PASSWORD = "password";
public static final String PROP_DB_ATINAV_PASSWORD = "atinavPassword";
public static final String PROP_DB_INITIAL_CONS = "initialCons";
public static final String PROP_DB_REUSE_CONS = "reuseCons";
public static final String PROP_DB_TIMEOUT = "timeout";
public static final String PROP_DB_USER = "user";
public static final String PROP_DB_PROPERTY_FILE = "dbPropertyFile";
public static final String PROP_DB_PROPERTY_DEFAULT_FILE = "ablia";
public static final String PROP_DB_MAX_CONS = "maxCons";
public static final String PROP_DB_MAX_CONNECTION_HITS = "maxConnectionHits";
private Properties dbEnvironProperty;
private String dbAtinavpasswd;
private int dbType = 0;
private SimpleDateFormat tsf;
private SimpleDateFormat tsfForFile;
private int initialCons = 1;
private String langCode;
private int maxConnectionHits = 0;
private int maxCons = 10;
private String mdwpath;
private String password;
public static final String PASSWORD = "Password";
public static final String PROP_FALSE = "FALSE";
public static final String PROP_TRUE = "true";
private String propertyFileName;
private ResourceBundle propertyResource;
private boolean reuseCons = true;
private SimpleDateFormat tf;
private int timeout = 300;
private String user;
private SimpleDateFormat df;
private String apCodeParms;
private static Hashtable<String, Hashtable<String, Parm>> allWebAppParms;
private static Hashtable<String, ResourceBundle> dictionarys;
private static Hashtable<String, String> missedDictionaryKey = new Hashtable<>();
private static Hashtable<String, Hashtable<String, RewriteRule>> allRewriteRules;
public static final String PROP_DB_CONN_LIFE_TIME = "connectionLifeTime";
public static final String USER = "User";
private boolean isLogParm = false;
public ApplParm() {}
public ApplParm(int theDbType, String theDatabase) {
this.dbType = theDbType;
this.database = theDatabase;
}
public ApplParm(int theDbType, String theDatabase, String theUser, String thePassword) {
this.dbType = theDbType;
this.database = theDatabase;
this.user = theUser;
this.password = thePassword;
}
public ApplParm(int theDbType, String theDatabase, String theUser, String thePassword, int initial_Cons, int max_Cons, int time_Out) {
this.dbType = theDbType;
this.database = theDatabase;
this.user = theUser;
this.password = thePassword;
this.initialCons = initial_Cons;
this.maxCons = max_Cons;
this.timeout = time_Out;
}
public String getApCode() {
if (this.apCode == null || this.apCode.isEmpty())
this.apCode = String.valueOf(this.dbType) + this.database + this.user + this.password;
return this.apCode;
}
private String getApCodeParms() {
if (this.apCodeParms == null || this.apCodeParms.isEmpty()) {
String tempDB = this.database;
if (this.database.indexOf("_log") > 0)
tempDB = this.database.replace("_log", "");
this.apCodeParms = String.valueOf(this.dbType) + tempDB + this.user + this.password;
}
return this.apCodeParms;
}
public String getApCode(DBAdapter obj) {
StringBuilder sb = new StringBuilder(obj.getClass().getName());
sb.append(getApCode());
return sb.toString();
}
public static final void resetHashtable() {
if (dictionarys != null) {
dictionarys.clear();
dictionarys = null;
}
if (allWebAppParms != null) {
allWebAppParms.clear();
allWebAppParms = null;
}
if (allRewriteRules != null) {
allRewriteRules.clear();
allRewriteRules = null;
}
}
public String getApDescription() {
StringBuffer temp = new StringBuffer();
temp.append("PropFile: " + getPropertyFileName());
temp.append("\nSOURCE DB ");
temp.append("\ndriver: " + getDbType());
temp.append("\ndb name: " + getDatabase());
temp.append("\nuser: " + getUser());
temp.append("\npassword: " + getPassword());
temp.append("\nConnection String: " + getConnectionString());
temp.append("\ntimeout: " + getTimeout());
temp.append("\ninitial cons: " + getInitialCons());
temp.append("\nmax cons: " + getMaxCons());
temp.append("\nAP CODE: " + getApCode());
return temp.toString();
}
public int getConnectionLifeTime() {
return this.connectionLifeTime;
}
public String getConnectionString() {
return DriversJdbc.getConnectionString(getDbType());
}
public String getDatabase() {
if (this.database == null)
this.database = "test";
return this.database;
}
public SimpleDateFormat getDataFormat() {
if (this.df == null)
if (getResource("DATA_FORMAT").isEmpty()) {
this.df = new SimpleDateFormat("dd/MM/yyyy");
} else {
this.df = new SimpleDateFormat(getResource("DATA_FORMAT"));
}
return this.df;
}
public Properties getDbEnvironProperty() {
if (this.dbEnvironProperty == null)
if (getDbType() == 13 || getDbType() == 14) {
this.dbEnvironProperty = new Properties();
if (!getUser().isEmpty())
this.dbEnvironProperty.put("user", getUser());
if (!getPassword().isEmpty())
this.dbEnvironProperty.put("password", getPassword());
} else if (getDbType() == 11 && (!getDbAtinavpasswd().isEmpty() || !getMdwpath().isEmpty())) {
this.dbEnvironProperty = new Properties();
if (!getMdwpath().isEmpty())
this.dbEnvironProperty.put("mdwpath", getMdwpath());
if (!getUser().isEmpty())
this.dbEnvironProperty.put("user", getUser());
if (!getPassword().isEmpty())
this.dbEnvironProperty.put("password", getPassword());
if (!getDbAtinavpasswd().isEmpty())
this.dbEnvironProperty.put("dbpasswd", getDbAtinavpasswd());
} else if (getDbType() == 12) {
this.dbEnvironProperty = new Properties();
this.dbEnvironProperty.put("logonuser", getUser());
this.dbEnvironProperty.put("logonpassword", getPassword());
}
return this.dbEnvironProperty;
}
public String getDbAtinavpasswd() {
if (this.dbAtinavpasswd == null)
this.dbAtinavpasswd = "";
return this.dbAtinavpasswd;
}
public int getDbType() {
if (this.dbType == 0) {
Properties prop = new Properties();
FileInputStream in = null;
try {
in = new FileInputStream(getPropertyFileName());
prop.load(in);
this.dbType = Integer.valueOf(prop.getProperty("dbDriver"));
} catch (Exception e) {}
}
return this.dbType;
}
public boolean getDebug() {
if (getResource("DEBUG").equals("true"))
return true;
return false;
}
public String getDebugFile() {
if (getResource("LOG_FILE").isEmpty())
return super.getDebugFile();
return getResource("LOG_FILE");
}
public int getDebugLevel() {
return getParm("DEBUG_LEVEL").getNumeroInt();
}
public String getDefaultLangCode() {
if (!getResource("LOCALE").isEmpty())
return getResource("LOCALE").toLowerCase();
return Locale.ITALIAN.getLanguage();
}
public String getDriverManager() {
return DriversJdbc.getDriverManager(getDbType());
}
public int getInitialCons() {
return this.initialCons;
}
public String getLangCode() {
if (this.langCode == null || this.langCode.isEmpty())
this.langCode = getDefaultLangCode();
return this.langCode;
}
public Locale getLocale() {
if (!hmLocale.containsKey(getLangCode())) {
Locale locale = new Locale(getLangCode(), getLangCode());
System.out.println("applparm getlocale lang:" + getLangCode());
hmLocale.put(getLangCode(), locale);
}
return hmLocale.get(getLangCode());
}
public int getMaxConnectionHits() {
return this.maxConnectionHits;
}
public int getMaxCons() {
return this.maxCons;
}
public String getMdwpath() {
if (this.mdwpath == null)
this.mdwpath = "";
return this.mdwpath;
}
public NumberFormat getNf() {
return getNf2();
}
public String getPassword() {
if (this.password == null) {
Properties prop = new Properties();
FileInputStream in = null;
try {
in = new FileInputStream("ablia");
prop.load(in);
this.password = prop.getProperty("password");
} catch (Exception e) {}
if (this.password == null)
this.password = "";
}
return this.password;
}
public String getPropertyFileName() {
return (this.propertyFileName == null) ? "ablia" : this.propertyFileName;
}
private ResourceBundle getPropertyResource() {
try {
if (this.propertyResource == null)
this.propertyResource = ResourceBundle.getBundle(getPropertyFileName());
} catch (Exception e) {
System.out.println("ERROR!! ApplParm.getPropertyResource() property file: " + getPropertyFileName() + "\n" + e.getMessage());
}
return this.propertyResource;
}
public String getResource(String key) {
try {
String temp = getParm(key).getTesto();
if (temp.isEmpty())
return getResourceFromPropertyFile(key);
return temp;
} catch (Exception e) {
if (key.equals("DEBUG") || key.equals("LOG_FILE")) {
System.out.println("SEVERE ERROR!! DEBUG or LOG_FILE not set. ApplParm: " + e.getMessage() + " . Property file:" +
getPropertyFileName());
} else {
handleDebug("ApplParm: " + e.getMessage() + " . Property file:" + getPropertyFileName(), 5);
}
return "";
}
}
public String getResourceFromPropertyFile(String key) {
try {
return getPropertyResource().getString(key);
} catch (Exception e) {
if (key.equals("DEBUG")) {
System.out.println("WARNING!!! ApplParm: " + e.getMessage() + " . Property file:" + getPropertyFileName());
} else {
handleDebug("ApplParm: " + e.getMessage() + " . Property file:" + getPropertyFileName(), 5);
}
return "";
}
}
public SimpleDateFormat getTimeFormat() {
if (this.tf == null)
if (getResource("TIME_FORMAT").isEmpty()) {
this.tf = new SimpleDateFormat("hh:mm");
} else {
this.tf = new SimpleDateFormat(getResource("TIME_FORMAT"));
}
return this.tf;
}
public int getTimeout() {
return this.timeout;
}
public String getUrl() {
return String.valueOf(getConnectionString()) + ":" + getDatabase();
}
public String getUser() {
if (this.user == null)
this.user = "";
return this.user;
}
public boolean isBlock() {
return this.block;
}
public boolean isReuseCons() {
return this.reuseCons;
}
public void setApCode(String newApCode) {
this.apCode = newApCode;
}
public void setBlock(boolean block) {
this.block = block;
}
public void setConnectionLifeTime(int l_connectionLifeTime) {
this.connectionLifeTime = l_connectionLifeTime;
}
public void setDatabase(String s) {
this.database = s;
setApCode(null);
}
public void setDbEnvironProperty(Properties newDbEnvironProperty) {
this.dbEnvironProperty = newDbEnvironProperty;
}
public void setDbAtinavpasswd(String dbpasswd) {
this.dbAtinavpasswd = dbpasswd;
}
public void setDbType(int newDbType) {
this.dbType = newDbType;
setApCode(null);
}
public void setDebugFile(String string) {
super.setDebugFile(string);
}
public void setInitialCons(int i) {
this.initialCons = i;
}
public void setLangCode(String newLangCode) {
if (!newLangCode.isEmpty() && this.langCode != newLangCode)
this.langCode = newLangCode;
}
public void setMaxConnectionHits(int maxConnectionHits) {
this.maxConnectionHits = maxConnectionHits;
}
public void setMaxCons(int i) {
this.maxCons = i;
}
public void setMdwpath(String mdwpath) {
this.mdwpath = mdwpath;
}
public void setPassword(String s) {
if (this.password == null)
this.password = "db2admin";
this.password = s;
setApCode(null);
}
public void setPropertyFileName(String newPropertyFileName) {
this.propertyFileName = newPropertyFileName;
}
public void setReuseCons(boolean reuseCons) {
this.reuseCons = reuseCons;
}
public void setTimeout(int i) {
this.timeout = i;
}
public void setUser(String s) {
this.user = s;
setApCode(null);
}
public RewriteRule getRewriteRule(String theCode) {
if (allRewriteRules == null)
allRewriteRules = new Hashtable<>();
synchronized (allRewriteRules) {
if (!allRewriteRules.containsKey(getApCode())) {
Hashtable<String, RewriteRule> theApRules = new Hashtable<>();
StringTokenizer rules = new StringTokenizer(getParm("REWRITE_URL_RULES").getTesto(), "\n");
while (rules.hasMoreTokens()) {
String currentRule = rules.nextToken();
if (!currentRule.startsWith("#")) {
if (currentRule.endsWith("\r"))
currentRule = currentRule.substring(0, currentRule.length() - 1);
StringTokenizer ruleValues = new StringTokenizer(currentRule, ",");
if (ruleValues.countToken() >= 2) {
RewriteRule aRule = new RewriteRule();
aRule.setCode(ruleValues.getToken(0));
if (ruleValues.getToken(1).startsWith("/")) {
aRule.setServlet(ruleValues.getToken(1));
} else {
aRule.setServlet("/" + ruleValues.getToken(1));
}
aRule.setCmd(ruleValues.getToken(2));
aRule.setAct(ruleValues.getToken(3));
if (ruleValues.getToken(4) != null) {
StringTokenizer ruleParms = new StringTokenizer(ruleValues.getToken(4), "@");
if (ruleParms.hasMoreTokens()) {
Vectumerator<String> vecParms = new Vectumerator<>();
Vectumerator<String> vecConstParms = new Vectumerator<>();
Vectumerator<String> vecConstValues = new Vectumerator<>();
ruleParms.nextToken();
while (ruleParms.hasMoreTokens()) {
String aParm = ruleParms.nextToken();
int idx;
if ((idx = aParm.indexOf('=')) > 0) {
String theParm = aParm.substring(0, idx);
String theValue = aParm.substring(idx + 1);
vecConstParms.add(theParm);
vecConstValues.add(theValue);
continue;
}
vecParms.add(aParm);
}
aRule.setParms(vecParms);
aRule.setConstParms(vecConstParms);
aRule.setConstValues(vecConstValues);
}
}
theApRules.put(aRule.getCode(), aRule);
}
}
}
allRewriteRules.put(getApCode(), theApRules);
}
}
Hashtable<String, RewriteRule> apRules = allRewriteRules.get(getApCode());
if (apRules.containsKey(theCode))
return apRules.get(theCode);
handleDebug("WARNING: AP: " + getDatabase() + " rewrite rule non presente: " + theCode, 3);
return null;
}
public void resetCurrentApParms() {
if (allWebAppParms != null && allWebAppParms.containsKey(getApCode()))
allWebAppParms.remove(getApCode());
if (allRewriteRules != null && allRewriteRules.containsKey(getApCode()))
allRewriteRules.remove(getApCode());
this.df = null;
this.tf = null;
dictionarys = null;
reloadAllResourceBundles();
TtFont.reset();
}
private static synchronized void appendNewLangKey(String theContentKey, String l_lang, String missedFileName) {
try {
if (!missedDictionaryKey.containsKey(String.valueOf(theContentKey) + "_" + l_lang)) {
missedFileName = String.valueOf(missedFileName) + "_missed";
try {
ResourceBundle rb = ResourceBundle.getBundle(missedFileName, new Locale(l_lang, l_lang));
rb.getString(theContentKey);
} catch (Exception e) {
FileWr fw = new FileWr(String.valueOf(missedFileName) + "_" + l_lang + ".properties", true);
fw.writeLine(String.valueOf(theContentKey) + "=");
fw.closeFile();
}
missedDictionaryKey.put(String.valueOf(theContentKey) + "_" + l_lang, theContentKey);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private String getMissDictionaryPropertyPath() {
String temp = getResource("DICT_MISS_PROP_PTH");
return temp.isEmpty() ? "/" : temp;
}
private String getDictionaryPropertyFile() {
String temp = getResource("DICT_PROP_FILE");
return temp.isEmpty() ? "dict" : temp;
}
public String translate(String sentence, String l_lang) {
String sentenceKey = sentence;
l_lang = l_lang.toLowerCase();
if (l_lang.isEmpty() || l_lang.equals(getDefaultLangCode()))
return sentence;
try {
ResourceBundle rb;
sentenceKey = sentence.replace('\n', ' ');
sentenceKey = sentenceKey.replace('\r', ' ');
sentenceKey = sentenceKey.trim().replaceAll(" +", "_");
String translation = null;
if (!getDictionarys().containsKey(String.valueOf(l_lang) + getApCode())) {
rb = ResourceBundle.getBundle(getDictionaryPropertyFile(), new Locale(l_lang, l_lang));
dictionarys.put(String.valueOf(l_lang) + getApCode(), rb);
} else {
rb = dictionarys.get(String.valueOf(l_lang) + getApCode());
}
translation = rb.getString(sentenceKey);
if (translation == null || translation.isEmpty()) {
if (translation != null)
appendNewLangKey(sentenceKey, l_lang, String.valueOf(getMissDictionaryPropertyPath()) + getDictionaryPropertyFile());
return "." + sentence + ".";
}
return new String(translation.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
} catch (MissingResourceException mre) {
String temp = "Translate key for " + getDictionaryPropertyFile() + "_" + l_lang + " missed: " + sentenceKey;
appendNewLangKey(sentenceKey, l_lang, String.valueOf(getMissDictionaryPropertyPath()) + getDictionaryPropertyFile());
handleDebug(temp, 2);
return "." + sentence + ".";
} catch (Exception e) {
handleDebug(e, 2);
return "Translate failed";
}
}
public NumberFormat getNf0() {
if (!hmNf0.containsKey(getLocale())) {
getLocale();
NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN);
nf.setMaximumFractionDigits(0);
nf.setMinimumFractionDigits(0);
hmNf0.put(getLocale(), nf);
}
return hmNf0.get(getLocale());
}
public NumberFormat getNf2() {
if (!hmNf2.containsKey(getLocale())) {
getLocale();
NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN);
nf.setMaximumFractionDigits(2);
nf.setMinimumFractionDigits(2);
hmNf2.put(getLocale(), nf);
}
return hmNf2.get(getLocale());
}
public NumberFormat getNf3() {
if (!hmNf3.containsKey(getLocale())) {
getLocale();
NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN);
nf.setMaximumFractionDigits(3);
nf.setMinimumFractionDigits(3);
hmNf3.put(getLocale(), nf);
}
return hmNf3.get(getLocale());
}
public String getConnectionsCreateTs() {
ConnectionPool cp = ConnectionPool.getInstance(this);
Enumeration<CPConnection> enuF = cp.getFree().elements();
Enumeration<CPConnection> enuU = cp.getUsed().elements();
StringBuffer res = new StringBuffer();
int i = 0;
while (enuF.hasMoreElements()) {
i++;
CPConnection row = enuF.nextElement();
res.append("F");
res.append(" #");
res.append(i);
res.append(" ");
res.append(row.getLifeTime());
res.append("-->");
res.append(row.getHits());
res.append(" hits");
if (enuF.hasMoreElements())
res.append("<br>");
}
i = 0;
if (enuU.hasMoreElements()) {
res.append("<br><span style=\"color:#FF0000\">");
while (enuU.hasMoreElements()) {
i++;
CPConnection row = enuU.nextElement();
res.append("U");
res.append(" #");
res.append(i);
res.append(" ");
res.append(row.getLifeTime());
res.append(" (");
res.append(row.getCallTime());
res.append(")");
res.append("-->");
res.append(row.getHits());
res.append(" hits");
if (!row.getReqIpAddress().isEmpty()) {
res.append("<br><b>ip</b>: ");
res.append(row.getReqIpAddress());
}
if (!row.getReqUrl().isEmpty()) {
res.append("<br><b>Url</b>: ");
res.append(row.getReqUrl());
}
if (row.getLastUpdId_user() != 0L) {
res.append("<br><b>User id</b>: ");
res.append(row.getLastUpdId_user());
}
res.append("<br>");
res.append(DBAdapter.convertStringToHtml(row.getLastCallingStackTrace()));
if (enuU.hasMoreElements())
res.append("<br>");
}
res.append("</span>");
}
return res.toString();
}
public NumberFormat getNf4() {
if (!hmNf4.containsKey(getLocale())) {
getLocale();
NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN);
nf.setMaximumFractionDigits(4);
nf.setMinimumFractionDigits(4);
hmNf4.put(getLocale(), nf);
}
return hmNf4.get(getLocale());
}
public NumberFormat getNf1() {
if (!hmNf1.containsKey(getLocale())) {
getLocale();
NumberFormat nf = NumberFormat.getInstance(Locale.ITALIAN);
nf.setMaximumFractionDigits(1);
nf.setMinimumFractionDigits(1);
hmNf1.put(getLocale(), nf);
}
return hmNf1.get(getLocale());
}
public Parm getParmXXXXXX(String theKey) {
int logLevel = 2;
if (allWebAppParms == null)
allWebAppParms = new Hashtable<>();
if (!allWebAppParms.containsKey(getApCodeParms()))
synchronized (allWebAppParms) {
if (!allWebAppParms.containsKey(getApCodeParms())) {
Hashtable<String, Parm> theParms = new Hashtable<>();
Parm parm = new Parm(new ApplParmFull(this));
Vectumerator<? extends DBAdapter> vec = parm.findAll();
while (vec.hasMoreElements()) {
Parm row = (Parm)vec.nextElement();
theParms.put(row.getCodice(), row);
}
allWebAppParms.put(getApCodeParms(), theParms);
}
}
theKey = theKey.trim().toUpperCase();
Hashtable<String, Parm> parms = allWebAppParms.get(getApCodeParms());
if (parms.containsKey(theKey))
return parms.get(theKey);
Parm bean = new Parm();
if (theKey.equals("DEBUG")) {
bean.setCodice("DEBUG");
bean.setTesto("false");
bean.setNumero(1.0D);
} else if (theKey.equals("LOCALE")) {
bean.setCodice("LOCALE");
bean.setTesto("it");
} else if (theKey.equals("LOG_USERS_UPDATES")) {
bean.setCodice("LOG_USERS_UPDATES");
bean.setNumero(0.0D);
} else {
if (theKey.equals("FROM") || theKey.equals("TO_DEBUG") ||
theKey.equals("SMTP"))
logLevel = 2;
handleDebug("Parm.getParm(theKey): codice NON PRESENTE: " + theKey, logLevel);
}
System.out.println("WARNING: AP: " + getDatabase() + " codice non presente: " + theKey);
return bean;
}
public SimpleDateFormat getTimestampFormat() {
if (this.tsf == null)
this.tsf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
return this.tsf;
}
public SimpleDateFormat getTimestampFormatForFiles() {
if (this.tsfForFile == null)
this.tsfForFile = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss_SSS");
return this.tsfForFile;
}
public static final void resetHashtable(String apCode) {
if (dictionarys != null) {
dictionarys.clear();
dictionarys = null;
}
if (allWebAppParms != null && allWebAppParms.containsKey(apCode))
allWebAppParms.remove(apCode);
if (allRewriteRules != null && allRewriteRules.containsKey(apCode))
allRewriteRules.remove(apCode);
}
public static final void resetAll() {
resetHashtable();
reloadAllResourceBundles();
}
public static void reloadAllResourceBundles() {
try {
Field cacheList = ResourceBundle.class.getDeclaredField("cacheList");
cacheList.setAccessible(true);
((Map<?, ?>)cacheList.get(ResourceBundle.class)).clear();
} catch (Exception e) {
System.err.println("ApplPrm.reloadAllResourceBundles : " + e.getMessage());
}
}
private static Hashtable<String, ResourceBundle> getDictionarys() {
if (dictionarys == null)
dictionarys = new Hashtable<>();
return dictionarys;
}
public Parm getParmNoHt(String theKey) {
if (theKey.equals("DEBUG")) {
Parm bean = new Parm();
bean.setCodice("DEBUG");
bean.setTesto(getResourceFromPropertyFile(theKey));
if (bean.getTesto().equals("true"))
bean.setNumero(1.0D);
return bean;
}
if (theKey.equals("LOCALE")) {
Parm bean = new Parm();
bean.setCodice("LOCALE");
bean.setTesto(getResourceFromPropertyFile(theKey));
return bean;
}
Parm parm = new Parm(new ApplParmFull(this));
try {
parm.findByCodice(theKey);
return parm;
} catch (Exception e) {
handleDebug(e, 3);
return parm;
}
}
public Parm getParm(String theKey) {
if (allWebAppParms == null)
allWebAppParms = new Hashtable<>();
int logLevel = 2;
if (!allWebAppParms.containsKey(getApCodeParms())) {
if (theKey.equals("DEBUG")) {
Parm parm = new Parm();
parm.setCodice("DEBUG");
parm.setTesto("false");
parm.setNumero(0.0D);
return parm;
}
if (theKey.equals("LOCALE")) {
Parm parm = new Parm();
parm.setCodice("LOCALE");
parm.setTesto("it");
return parm;
}
if (theKey.equals("LOG_USERS_UPDATES")) {
Parm parm = new Parm();
parm.setCodice("LOG_USERS_UPDATES");
parm.setNumero(0.0D);
return parm;
}
}
if (!allWebAppParms.containsKey(getApCodeParms()))
synchronized (allWebAppParms) {
if (!allWebAppParms.containsKey(getApCodeParms())) {
Hashtable<String, Parm> theParms = new Hashtable<>();
Parm parm = new Parm(new ApplParmFull(this));
Vectumerator<? extends DBAdapter> vec = parm.findAll();
while (vec.hasMoreElements()) {
Parm row = (Parm)vec.nextElement();
theParms.put(row.getCodice(), row);
}
if (theParms.containsKey("LANG_AVAILABLE")) {
Parm pLangAvail = theParms.get("LANG_AVAILABLE");
StringTokenizer st = new StringTokenizer(pLangAvail.getTesto(), ",");
if (st.hasMoreTokens()) {
Parm p = new Parm(new ApplParmFull(this));
p.setCodice("LANG_PRIMARY");
p.setTesto(st.nextToken());
theParms.put(p.getCodice(), p);
}
if (st.hasMoreTokens()) {
Parm p = new Parm(new ApplParmFull(this));
p.setCodice("LANG_SECONARY");
p.setTesto(st.nextToken());
theParms.put(p.getCodice(), p);
}
}
allWebAppParms.put(getApCodeParms(), theParms);
}
}
theKey = theKey.trim().toUpperCase();
Hashtable<String, Parm> parms = allWebAppParms.get(getApCodeParms());
if (parms.containsKey(theKey))
return parms.get(theKey);
Parm bean = new Parm();
if (theKey.equals("DEBUG")) {
bean.setCodice("DEBUG");
bean.setTesto("false");
bean.setNumero(1.0D);
} else if (theKey.equals("LOCALE")) {
bean.setCodice("LOCALE");
bean.setTesto("it");
} else {
if (theKey.equals("FROM") || theKey.equals("TO_DEBUG") ||
theKey.equals("SMTP"))
logLevel = 2;
handleDebug("Parm.getParm(theKey): codice NON PRESENTE: " + theKey, logLevel);
}
System.out.println("WARNING: AP: " + getDatabase() + " codice non presente: " + theKey);
return bean;
}
public boolean isParmsHtReadyxxx() {
if (allWebAppParms != null && allWebAppParms.containsKey(getApCodeParms()))
return true;
return false;
}
}

View file

@ -0,0 +1,404 @@
package com.ablia.db;
import com.ablia.common.Parm;
import com.ablia.common.Users;
import com.ablia.reg.EcDc;
import com.ablia.util.SimpleDateFormat;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.text.NumberFormat;
import java.util.Locale;
import java.util.Properties;
public class ApplParmFull implements Serializable {
private static final long serialVersionUID = 5716730193350553875L;
private ApplParm ap;
private long lastUpdId_user;
private String reqIpAddress;
private Users lastUpdUser;
private String reqUrl;
public ApplParmFull(ApplParm applParm, long lastUpdId_user, String reqIpAddress, String reqUrl) {
this.ap = applParm;
this.lastUpdId_user = lastUpdId_user;
this.reqIpAddress = reqIpAddress;
this.reqUrl = reqUrl;
}
public long getLastUpdId_user() {
return this.lastUpdId_user;
}
public void setLastUpdId_user(long lastUpdId_user) {
this.lastUpdId_user = lastUpdId_user;
setLastUpdUser(null);
}
public String getReqIpAddress() {
return (this.reqIpAddress == null) ? "" : this.reqIpAddress.trim();
}
public void setReqIpAddress(String reqIpAddress) {
this.reqIpAddress = reqIpAddress;
}
public ApplParmFull() {}
public ApplParmFull(ApplParm applParm) {
this.ap = applParm;
}
public ApplParm getAp() {
return this.ap;
}
public void setAp(ApplParm applParm) {
this.ap = applParm;
}
public Parm getParm(String theKey) {
return getAp().getParm(theKey);
}
public String getApCode() {
return getAp().getApCode();
}
public int hashCode() {
return this.ap.hashCode();
}
public void handleDebug(Exception exception) {
this.ap.handleDebug(exception);
}
public void handleDebug(Exception exception, int logLevel) {
this.ap.handleDebug(exception, logLevel);
}
public void handleDebug(PreparedStatement ps) {
this.ap.handleDebug(ps);
}
public void handleDebug(PreparedStatement ps, int logLevel) {
this.ap.handleDebug(ps, logLevel);
}
public void handleDebug(String s) {
this.ap.handleDebug(s);
}
public void handleDebug(String s, int logLevel) {
this.ap.handleDebug(s, logLevel);
}
public String getApCode(DBAdapter obj) {
return this.ap.getApCode(obj);
}
public void setDebug(boolean flag) {
this.ap.setDebug(flag);
}
public void setDebugLevel(int i) {
this.ap.setDebugLevel(i);
}
public void writeLog(String msg) {
this.ap.writeLog(msg);
}
public String getApDescription() {
return this.ap.getApDescription();
}
public int getConnectionLifeTime() {
return this.ap.getConnectionLifeTime();
}
public String getConnectionString() {
return this.ap.getConnectionString();
}
public String getDatabase() {
return this.ap.getDatabase();
}
public SimpleDateFormat getDataFormat() {
return this.ap.getDataFormat();
}
public String toString() {
return this.ap.toString();
}
public Properties getDbEnvironProperty() {
return this.ap.getDbEnvironProperty();
}
public String getDbAtinavpasswd() {
return this.ap.getDbAtinavpasswd();
}
public int getDbType() {
return this.ap.getDbType();
}
public boolean getDebug() {
return this.ap.getDebug();
}
public String getDebugFile() {
return this.ap.getDebugFile();
}
public int getDebugLevel() {
return this.ap.getDebugLevel();
}
public String getDefaultLangCode() {
return this.ap.getDefaultLangCode();
}
public String getDriverManager() {
return this.ap.getDriverManager();
}
public int getInitialCons() {
return this.ap.getInitialCons();
}
public String getLangCode() {
return this.ap.getLangCode();
}
public Locale getLocale() {
return this.ap.getLocale();
}
public int getMaxConnectionHits() {
return this.ap.getMaxConnectionHits();
}
public int getMaxCons() {
return this.ap.getMaxCons();
}
public String getMdwpath() {
return this.ap.getMdwpath();
}
public NumberFormat getNf() {
return this.ap.getNf();
}
public String getPassword() {
return this.ap.getPassword();
}
public String getPropertyFileName() {
return this.ap.getPropertyFileName();
}
public String getResource(String key) {
return this.ap.getResource(key);
}
public String getPropertyFile() {
return this.ap.getPropertyFile();
}
public void setPropertyFile(String propertyFile) {
this.ap.setPropertyFile(propertyFile);
}
public final String getSoftwareVersion() {
return this.ap.getSoftwareVersion();
}
public String getResourceFromPropertyFile(String key) {
return this.ap.getResourceFromPropertyFile(key);
}
public final String getSoftwareVersionLog() {
return this.ap.getSoftwareVersionLog();
}
public SimpleDateFormat getTimeFormat() {
return this.ap.getTimeFormat();
}
public int getTimeout() {
return this.ap.getTimeout();
}
public String getUrl() {
return this.ap.getUrl();
}
public String getUser() {
return this.ap.getUser();
}
public boolean isBlock() {
return this.ap.isBlock();
}
public boolean isReuseCons() {
return this.ap.isReuseCons();
}
public void setApCode(String newApCode) {
this.ap.setApCode(newApCode);
}
public void setBlock(boolean block) {
this.ap.setBlock(block);
}
public void setConnectionLifeTime(int l_connectionLifeTime) {
this.ap.setConnectionLifeTime(l_connectionLifeTime);
}
public void setDatabase(String s) {
this.ap.setDatabase(s);
}
public void setDbEnvironProperty(Properties newDbEnvironProperty) {
this.ap.setDbEnvironProperty(newDbEnvironProperty);
}
public void setDbAtinavpasswd(String dbpasswd) {
this.ap.setDbAtinavpasswd(dbpasswd);
}
public void setDbType(int newDbType) {
this.ap.setDbType(newDbType);
}
public void setDebugFile(String string) {
this.ap.setDebugFile(string);
}
public void setInitialCons(int i) {
this.ap.setInitialCons(i);
}
public void setLangCode(String newLangCode) {
this.ap.setLangCode(newLangCode);
}
public void setMaxConnectionHits(int maxConnectionHits) {
this.ap.setMaxConnectionHits(maxConnectionHits);
}
public void setMaxCons(int i) {
this.ap.setMaxCons(i);
}
public void setMdwpath(String mdwpath) {
this.ap.setMdwpath(mdwpath);
}
public void setPassword(String s) {
this.ap.setPassword(s);
}
public void setPropertyFileName(String newPropertyFileName) {
this.ap.setPropertyFileName(newPropertyFileName);
}
public void setReuseCons(boolean reuseCons) {
this.ap.setReuseCons(reuseCons);
}
public void setTimeout(int i) {
this.ap.setTimeout(i);
}
public void setUser(String s) {
this.ap.setUser(s);
}
public RewriteRule getRewriteRule(String theCode) {
return this.ap.getRewriteRule(theCode);
}
public void resetCurrentApParms() {
this.ap.resetCurrentApParms();
}
public String translate(String sentence, String l_lang) {
return this.ap.translate(sentence, l_lang);
}
public NumberFormat getNf0() {
return this.ap.getNf0();
}
public NumberFormat getNf2() {
return this.ap.getNf2();
}
public NumberFormat getNf3() {
return this.ap.getNf3();
}
public String getConnectionsCreateTs() {
return this.ap.getConnectionsCreateTs();
}
public NumberFormat getNf4() {
return this.ap.getNf4();
}
public NumberFormat getNf1() {
return this.ap.getNf1();
}
public SimpleDateFormat getTimestampFormat() {
return this.ap.getTimestampFormat();
}
public Parm getParmNoHt(String theKey) {
return this.ap.getParmNoHt(theKey);
}
public Users getLastUpdUser() {
if (this.lastUpdUser == null && getLastUpdId_user() > 0L) {
this.lastUpdUser = new Users(this);
this.lastUpdUser.findByPrimaryKey(getLastUpdId_user());
}
return (this.lastUpdUser == null) ? new Users(this) : this.lastUpdUser;
}
public void setLastUpdUser(Users lastUpdUser) {
this.lastUpdUser = lastUpdUser;
}
public String getReqUrl() {
return (this.reqUrl == null) ? "" : this.reqUrl.trim();
}
public void setReqUrl(String reqUrl) {
this.reqUrl = reqUrl;
}
public String getEncryptedPassword(String plainPassword) {
long flgCrypt = getParm("PWD_CRYPT").getNumeroLong();
String cryptedPwd = plainPassword;
if (flgCrypt == 1L) {
cryptedPwd = EcDc.encodeDizionario(plainPassword, "Xg3Z5sFQ");
} else if (flgCrypt == 2L) {
cryptedPwd = EcDc.cryptMD5(plainPassword);
} else if (flgCrypt == 3L) {
cryptedPwd = EcDc.cryptSHA(plainPassword, "SHA-256");
}
return cryptedPwd;
}
}

View file

@ -0,0 +1,209 @@
package com.ablia.db;
import com.ablia.util.Debug;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Calendar;
public class CPConnection extends Debug {
private ApplParm ap;
private Connection conn;
private Timestamp createTs;
private int hits;
private String lastCallingStackTrace;
private Timestamp callTs;
private String reqUrl;
private long lastUpdId_user;
private String reqIpAddress;
private ResParm rp;
public static CPConnection getInstance(ApplParm ap) {
CPConnection cpC = null;
synchronized (ap) {
cpC = new CPConnection(ap);
cpC.setRp(cpC.initConn());
}
return cpC;
}
private CPConnection(ApplParm newAp) {
this.ap = newAp;
}
public void addHit() {
this.hits++;
}
public void close() {
if (this.conn != null)
try {
this.conn.close();
} catch (SQLException e) {
handleDebug(e, 0);
}
}
protected void finalize() throws Throwable {
close();
this.conn = null;
}
public ApplParm getApFull() {
return this.ap;
}
public Connection getConn() {
return this.conn;
}
public Timestamp getCreateTs() {
return this.createTs;
}
public boolean getDebug() {
if (getApFull() != null)
return getApFull().getDebug();
return super.getDebug();
}
public String getDebugFile() {
if (getApFull() != null)
return getApFull().getDebugFile();
return getDebugFile();
}
public int getDebugLevel() {
if (getApFull() != null)
return getApFull().getDebugLevel();
return getDebugLevel();
}
public int getHits() {
return this.hits;
}
public String getLastCallingStackTrace() {
return this.lastCallingStackTrace;
}
public Timestamp getCallTs() {
return this.callTs;
}
private ResParm initConn() {
ResParm rp = new ResParm(true);
if (this.conn == null) {
try {
if (this.ap.getDbEnvironProperty() != null) {
this.conn = DriverManager.getConnection(String.valueOf(this.ap.getConnectionString()) + ":" + this.ap.getDatabase(), this.ap.getDbEnvironProperty());
} else {
this.conn = DriverManager.getConnection(String.valueOf(this.ap.getConnectionString()) + ":" + this.ap.getDatabase(), this.ap.getUser(), this.ap.getPassword());
}
this.createTs = new Timestamp(Calendar.getInstance().getTime().getTime());
this.hits = 0;
rp.setStatus(true);
} catch (Exception e) {
rp.setStatus(false);
rp.setMsg("CPConnection.initConn: Error during connection.....: " + e.getMessage() + "\nDatabase resource: " +
this.ap.getDatabase() + "\nDatabase type: " + this.ap.getDbType() + "\nDatabase url: " + this.ap.getUrl() + "\nUser: " +
this.ap.getUser() + "\nPassword: " + this.ap.getPassword() + "\nDbpasswd: " + this.ap.getDbAtinavpasswd() + "\n" +
e.getMessage());
}
} else {
rp.setStatus(false);
rp.setMsg("CPConnection.initConn: connessione nulla!!");
}
return rp;
}
public boolean isValid() {
if (getConn() == null)
return false;
try {
return getConn().isValid(0);
} catch (Exception e) {
handleDebug(e, 0);
return false;
}
}
public void setLastCallingStackTrace(String lastCallingStackTrace) {
this.lastCallingStackTrace = lastCallingStackTrace;
}
public void setCallTs(Timestamp lastFreeTs) {
this.callTs = lastFreeTs;
}
public long getLifeTimeSeconds() {
long mt1 = getCreateTs().getTime();
long mt2 = Calendar.getInstance().getTimeInMillis();
return (mt2 - mt1) / 1000L;
}
public String getLifeTime() {
return DBAdapter.secToHourMinSec(getLifeTimeSeconds());
}
public String getCallTime() {
long ctm = getCallTimeMilliSeconds();
if (ctm < 10000L) {
int sec = (int)ctm / 1000;
int ms = (int)(ctm - (long)(sec * 1000));
return String.valueOf(sec) + "," + ms + " ms";
}
return DBAdapter.secToHourMinSec(ctm / 1000L);
}
public long getCallTimeMilliSeconds() {
if (getCallTs() != null) {
long mt1 = getCallTs().getTime();
long mt2 = Calendar.getInstance().getTimeInMillis();
return mt2 - mt1;
}
return 0L;
}
public String getReqIpAddress() {
return (this.reqIpAddress == null) ? "" : this.reqIpAddress;
}
public void setReqIpAddress(String reqIpAddress) {
this.reqIpAddress = reqIpAddress;
}
public String getReqUrl() {
return (this.reqUrl == null) ? "" : this.reqUrl;
}
public void setReqUrl(String reqUrl) {
this.reqUrl = reqUrl;
}
public long getLastUpdId_user() {
return this.lastUpdId_user;
}
public void setLastUpdId_user(long lastUpdId_user) {
this.lastUpdId_user = lastUpdId_user;
}
public ResParm getRp() {
return this.rp;
}
public void setRp(ResParm rp) {
this.rp = rp;
}
}

View file

@ -0,0 +1,472 @@
package com.ablia.db;
import com.ablia.annotation.CRDescriptor;
import com.ablia.common.Parm;
import com.ablia.util.Debug;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
public abstract class CRAdapter extends Debug {
public static final String AB_EMPTY_STRING = "";
protected HashMap<String, FieldsDescriptor> crFieldDescriptor;
private ApplParmFull apFull;
private Timestamp createTmst;
private String searchTxt;
protected DBAdapter getSecondaryObject(DBAdapter obj, Class<?> objClass, long pkLongValue) {
return getSecondaryObject(obj, objClass, new Long(pkLongValue));
}
protected DBAdapter getSecondaryObject(DBAdapter obj, Class<?> objClass, Object pkValue) {
try {
return DBAdapter.getSecondaryObject(getApFull(), obj, objClass, pkValue);
} catch (Exception e) {
handleDebug(e);
return obj;
}
}
private boolean searchRequest = false;
private long flgOrderBy;
private long flgTipoReport;
private int pageRow;
private int pageNumber;
private int searchPageNumber;
private String currentTab;
private String cmd;
private String flgReport;
private long id_users;
private String act;
private String lang;
private long flgShowDeleteLogic = 0L;
private String currentFocus;
private String _id;
private String filePdf;
private String fileName;
private Timestamp lastUpdTmst;
private String searchRighe;
private String searchRighe2;
public CRAdapter() {}
public CRAdapter(ApplParmFull newAp) {
setApFull(newAp);
}
public ApplParmFull getApFull() {
return this.apFull;
}
public String getFlgReport() {
return (this.flgReport == null) ? "" : this.flgReport.trim();
}
public String getLang() {
return (this.lang == null) ? "it" : this.lang.trim().toLowerCase();
}
public int getSearchPageNumber() {
return (this.searchPageNumber == 0) ? 1 : this.searchPageNumber;
}
public boolean isSearchRequest() {
return this.searchRequest;
}
public void setApFull(ApplParmFull newAp) {
this.apFull = newAp;
}
public void setFlgReport(String newFlgReport) {
this.flgReport = newFlgReport;
}
public void setLang(String newLang) {
this.lang = newLang;
}
public void setSearchPageNumber(int newSearchPageNumber) {
this.searchPageNumber = newSearchPageNumber;
}
public void setSearchRequest(boolean newSearchRequest) {
this.searchRequest = newSearchRequest;
}
public long getFlgTipoReport() {
return this.flgTipoReport;
}
public void setFlgTipoReport(long flgTipoReport) {
this.flgTipoReport = flgTipoReport;
}
public int getPageNumber() {
return this.pageNumber;
}
public void setPageNumber(int pageNumber) {
this.pageNumber = pageNumber;
}
public int getPageRow() {
return this.pageRow;
}
public void setPageRow(int pageRow) {
this.pageRow = pageRow;
}
public String getSearchTxt() {
return (this.searchTxt == null) ? "" : this.searchTxt.trim();
}
public void setSearchTxt(String searchTxt) {
this.searchTxt = searchTxt;
}
public String getCurrentTab() {
return (this.currentTab == null) ? "" : this.currentTab.trim();
}
public void setCurrentTab(String currentTab) {
this.currentTab = currentTab;
}
public long getFlgOrderBy() {
return this.flgOrderBy;
}
public void setFlgOrderBy(long flgOrderBy) {
this.flgOrderBy = flgOrderBy;
}
public long getId_users() {
return this.id_users;
}
public void setId_users(long newId_users) {
this.id_users = newId_users;
}
public String getCmd() {
return (this.cmd == null) ? "" : this.cmd.trim();
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public String getAct() {
return (this.act == null) ? "" : this.act.trim();
}
public void setAct(String act) {
this.act = act;
}
public long getFlgShowDeleteLogic() {
return this.flgShowDeleteLogic;
}
public void setFlgShowDeleteLogic(long flgShowDeleteLogic) {
this.flgShowDeleteLogic = flgShowDeleteLogic;
}
public String getCurrentFocus() {
return (this.currentFocus == null) ? "" : this.currentFocus.trim();
}
public void setCurrentFocus(String currentFocus) {
this.currentFocus = currentFocus;
}
public String get_id() {
return (this._id == null) ? "" : this._id.trim();
}
public void set_id(String anchor) {
this._id = anchor;
}
public String getFilePdf() {
return this.filePdf;
}
public void setFilePdf(String filePdf) {
this.filePdf = filePdf;
}
private void buildDescrizioneCRMap() {
boolean debug = true;
StringBuilder sb = new StringBuilder();
initCrFieldDescriptor();
Class<?> currentclClass = getClass();
while (!currentclClass.getName().equals("com.ablia.db.CRAdapter")) {
Field[] ff1 = currentclClass.getDeclaredFields();
int order = 1000;
for (int i = 0; i < ff1.length; i++) {
String name = ff1[i].getName();
String desc = name;
CRDescriptor annotation = ff1[i].<CRDescriptor>getAnnotation(CRDescriptor.class);
if (annotation == null || annotation.abilita()) {
if (annotation != null)
desc = annotation.descrizione();
Object valueUpd = getCRValueByFieldname(name, ff1[i].getType(), this);
String valueS = convertCRValueToString(valueUpd, ff1[i].getType());
DBAdapter.logDebug(debug, "buildDescrizioneCRMap: " + desc + " (" + name + ")" + ": " + valueS);
DBAdapter.logDebug(debug, String.valueOf(name) + ": " + valueUpd);
if (!valueS.isEmpty())
if (getCrFieldDescriptor().containsKey(desc)) {
FieldsDescriptor currentCRFD = getCrFieldDescriptor().get(desc);
currentCRFD.setVal(valueS);
getCrFieldDescriptor().put(desc, currentCRFD);
} else {
getCrFieldDescriptor().put(desc,
new FieldsDescriptor(desc, (long)order, desc, convertCRValueToString(valueUpd, ff1[i].getType())));
order++;
}
}
}
currentclClass = currentclClass.getSuperclass();
}
}
private static Object getCRValueByFieldname(String filedName, Class<?> tipo, CRAdapter thiss) {
String functionName = "get" + filedName.substring(0, 1).toUpperCase() + filedName.substring(1);
Object value = null;
try {
Method method = thiss.getClass().getMethod(functionName);
value = method.invoke(thiss);
if (filedName.startsWith("flg") && value instanceof Long) {
String descColumn = filedName.substring(3);
functionName = "get" + descColumn.substring(0, 1).toUpperCase() + descColumn.substring(1);
Class[] parm = new Class<?>[1];
parm[0] = long.class;
Long[] parmValue = { (Long)value };
method = thiss.getClass().getMethod(functionName);
value = method.invoke(thiss);
} else if (filedName.startsWith("id_")) {
functionName = "get" + filedName.substring(3, 4).toUpperCase() + filedName.substring(4);
method = thiss.getClass().getMethod(functionName);
Object currentObj = method.invoke(thiss);
Method descMethod = currentObj.getClass().getMethod("getDescrizione");
value = descMethod.invoke(currentObj);
}
} catch (SecurityException e) {
} catch (NoSuchMethodException e) {
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {}
return value;
}
private static boolean isNotEmpty(Object valueUpd, Class<?> tipo) {
boolean ret = false;
if (valueUpd != null) {
String sclass = valueUpd.getClass().getName();
if (sclass.indexOf("Long") > 0 || sclass.indexOf("Double") > 0 || sclass.indexOf("String") > 0 || sclass.indexOf("Date") > 0 ||
sclass.indexOf("Time") > 0)
if (tipo.getName() == "long") {
if ((Long)valueUpd == 0L || (Long)valueUpd == -1L) {
ret = false;
} else {
ret = true;
}
} else if (tipo.getName() == "double") {
if ((Double)valueUpd == 0.0D) {
ret = false;
} else {
ret = true;
}
} else if (tipo.getName().indexOf("String") > 0) {
if (((String)valueUpd).equals("") || ((String)valueUpd).isEmpty()) {
ret = false;
} else {
ret = true;
}
} else if (tipo.getName().indexOf("Date") > 0) {
Date data = (Date)valueUpd;
if (data == null) {
ret = false;
} else {
ret = true;
}
} else if (tipo.getName().indexOf("Time") > 0) {
if ((Time)valueUpd == null) {
ret = false;
} else {
ret = true;
}
}
}
return ret;
}
private final String convertCRValueToString(Object valueUpd, Class<?> tipo) {
String ret = "";
if (valueUpd != null) {
String sclass = valueUpd.getClass().getName();
if (sclass.indexOf("String") > 0) {
ret = (String)valueUpd;
} else if (sclass.indexOf("Long") > 0 || sclass.indexOf("Double") > 0 || sclass.indexOf("String") > 0 || sclass.indexOf("Date") > 0 ||
sclass.indexOf("Time") > 0) {
if (tipo.getName() == "long") {
if ((Long)valueUpd > 0L)
ret = valueUpd.toString();
} else if (tipo.getName() == "double" || tipo.getName() == "float") {
if ((Double)valueUpd > 0.0D)
ret = getApFull().getNf().format(valueUpd);
} else if (tipo.getName().indexOf("String") > 0) {
ret = (String)valueUpd;
} else if (tipo.getName().indexOf("Date") > 0) {
Date data = (Date)valueUpd;
if (data != null)
ret = getApFull().getDataFormat().format(data);
} else if (tipo.getName().indexOf("Time") > 0 &&
(Time)valueUpd != null) {
ret = getApFull().getTimeFormat().format((Time)valueUpd);
}
}
}
return ret.trim();
}
public String getFileName() {
return (this.fileName == null) ? "" : this.fileName.trim();
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public Parm getParm(String theKey) {
if (getApFull() != null)
return getApFull().getAp().getParm(theKey);
return new Parm();
}
public final boolean checkVersion(String theKey) {
String temp = "," + getParm("VERSION").getTesto();
if (temp.indexOf("," + theKey) >= 0)
return true;
return false;
}
public Timestamp getCreateTmst() {
return this.createTmst;
}
public void setCreateTmst(Timestamp createTmst) {
this.createTmst = createTmst;
}
public final HashMap<String, FieldsDescriptor> getCrFieldDescriptor() {
return this.crFieldDescriptor;
}
public void setCrFieldDescriptor(HashMap<String, FieldsDescriptor> crFieldDescriptor) {
this.crFieldDescriptor = crFieldDescriptor;
}
protected void initCrFieldDescriptor() {
if (this.crFieldDescriptor == null)
this.crFieldDescriptor = new HashMap<>();
}
public String getDescrizioneCR() {
StringBuilder sb = new StringBuilder();
buildDescrizioneCRMap();
FieldsComparator comparator = new FieldsComparator(getCrFieldDescriptor());
Map<String, FieldsDescriptor> orderMap = new TreeMap<>(comparator);
orderMap.putAll(getCrFieldDescriptor());
for (Map.Entry<String, FieldsDescriptor> entry : orderMap.entrySet()) {
if (!entry.getValue().getVal().isEmpty()) {
if (sb.length() > 0)
sb.append(" - ");
sb.append(String.valueOf(entry.getValue().getDesc()) + ": ");
sb.append(entry.getValue().getVal());
}
}
return sb.toString();
}
public String getDescrizioneHtmlCR() {
StringBuilder sb = new StringBuilder();
buildDescrizioneCRMap();
FieldsComparator comparator = new FieldsComparator(getCrFieldDescriptor());
Map<String, FieldsDescriptor> orderMap = new TreeMap<>(comparator);
orderMap.putAll(getCrFieldDescriptor());
for (Map.Entry<String, FieldsDescriptor> entry : orderMap.entrySet()) {
if (!entry.getValue().getVal().isEmpty()) {
if (sb.length() > 0)
sb.append("<br />");
sb.append(String.valueOf(entry.getValue().getDesc()) + ": ");
sb.append(entry.getValue().getVal());
}
}
return sb.toString();
}
public Timestamp getLastUpdTmst() {
return this.lastUpdTmst;
}
public void setLastUpdTmst(Timestamp lastUpdTmst) {
this.lastUpdTmst = lastUpdTmst;
}
public String getSearchRighe() {
return (this.searchRighe == null) ? "" : this.searchRighe.trim();
}
public void setSearchRighe(String searchRighe) {
this.searchRighe = searchRighe;
}
public String getSearchRighe2() {
return (this.searchRighe2 == null) ? "" : this.searchRighe2.trim();
}
public void setSearchRighe2(String searchRighe2) {
this.searchRighe2 = searchRighe2;
}
public boolean isGoogleTranslatorEnable() {
return getParm("USE_GOOGLE_TRANSLATOR").isTrue();
}
}

View file

@ -0,0 +1,145 @@
package com.ablia.db;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
public class ColumnDescriptor {
private boolean autoIncrement = false;
private String columnName;
private short dataType;
private int columnSize;
private Field field;
private int stringCaseValue = 0;
private EncodedField encodedField;
private boolean fk;
public int getStringCaseValue() {
return this.stringCaseValue;
}
public void setStringCaseValue(int stringCaseValue) {
this.stringCaseValue = stringCaseValue;
}
public Field getField() {
return this.field;
}
public void setField(Field field) {
this.field = field;
}
public int getColumnSize() {
return this.columnSize;
}
public void setColumnSize(int columnSize) {
this.columnSize = columnSize;
}
private boolean fkNum = false;
private boolean pk;
private Method getMethod;
private Method setMethod;
public ColumnDescriptor(String theColumnName, short theDataType, int theColumnSize, boolean isPk) {
setColumnName(theColumnName);
setDataType(theDataType);
setPk(isPk);
setColumnSize(theColumnSize);
}
public ColumnDescriptor(String theColumnName, short theDataType, int theColumnSize, boolean isPk, Field theField, int l_strigCase, EncodedField l_econdedField) {
setColumnName(theColumnName);
setDataType(theDataType);
setPk(isPk);
setColumnSize(theColumnSize);
setField(theField);
setStringCaseValue(l_strigCase);
setEncodedField(l_econdedField);
}
public String getColumnName() {
return this.columnName;
}
public short getDataType() {
return this.dataType;
}
public boolean isAutoIncrement() {
return this.autoIncrement;
}
public boolean isFk() {
return this.fk;
}
public boolean isFkNum() {
return this.fkNum;
}
public boolean isPk() {
return this.pk;
}
public void setAutoIncrement(boolean newAutoIncrement) {
this.autoIncrement = newAutoIncrement;
}
public void setColumnName(String newColumnName) {
this.columnName = newColumnName;
}
public void setDataType(short newDataType) {
this.dataType = newDataType;
}
public void setFk(boolean newFk) {
this.fk = newFk;
}
public void setFkNum(boolean newFkNum) {
this.fkNum = newFkNum;
}
public void setPk(boolean newPk) {
this.pk = newPk;
}
public Method getGetMethod() {
return this.getMethod;
}
public Method getSetMethod() {
return this.setMethod;
}
public void setGetMethod(Method method) {
this.getMethod = method;
}
public void setSetMethod(Method method) {
this.setMethod = method;
}
public EncodedField getEncodedField() {
if (this.encodedField == null)
this.encodedField = new EncodedField();
return this.encodedField;
}
public void setEncodedField(EncodedField encodedField) {
this.encodedField = encodedField;
}
}

View file

@ -0,0 +1,507 @@
package com.ablia.db;
import com.ablia.util.Debug;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;
public class ConnectionPool extends Debug {
private static Hashtable<String, ConnectionPool> ht_connectionPools;
private static final String NO_CALLING_STACK_TRACE_MSG = "<b>For full stack trace pls. set debug level to DEBUG (5) or INFO1 (1)</b>";
private ApplParm ap;
private Vector<CPConnection> free;
private int freeCons;
private Vector<CPConnection> used;
private int usedCons;
private ApplParmFull apFull;
private static Hashtable<String, ConnectionPool> getHt_connectionPools() {
if (ht_connectionPools == null)
ht_connectionPools = new Hashtable<>();
return ht_connectionPools;
}
public static Enumeration<ConnectionPool> getCpools() {
return getHt_connectionPools().elements();
}
public static synchronized ConnectionPool getInstance(ApplParm ap) {
String cpKey = String.valueOf(ap.getDatabase()) + "_" + ap.getUser() + "_" + ap.getPassword();
if (getHt_connectionPools().containsKey(cpKey))
return getHt_connectionPools().get(cpKey);
ConnectionPool cp = new ConnectionPool(ap);
cp.initCPConnection();
getHt_connectionPools().put(cpKey, cp);
return cp;
}
public static void resetAll() {
Enumeration<ConnectionPool> enu = getCpools();
while (enu.hasMoreElements()) {
ConnectionPool l_cp = enu.nextElement();
l_cp.resetAllConnection();
}
ht_connectionPools = null;
}
private ConnectionPool(ApplParm newAp) {
this.ap = newAp;
try {
Class.forName(this.ap.getDriverManager()).newInstance();
} catch (ClassNotFoundException cnf) {
System.err.println("Connection Pool: " + cnf.getMessage());
} catch (Exception e) {
System.err.println("Connection Pool: " + e.getMessage());
}
}
private ConnectionPool(ApplParmFull newAp) {
this.apFull = newAp;
this.ap = this.apFull.getAp();
try {
Class.forName(this.ap.getDriverManager()).newInstance();
} catch (ClassNotFoundException cnf) {
System.err.println("Connection Pool: " + cnf.getMessage());
} catch (Exception e) {
System.err.println("Connection Pool: " + e.getMessage());
}
}
private ResParm addCPConnection() {
CPConnection cpConn = CPConnection.getInstance(getAp());
ResParm rp = new ResParm();
if (cpConn == null) {
rp.setStatus(false);
rp.setMsg("Errore! addCPConnection.getInstance() CPConnection null!");
} else if (cpConn.getConn() == null) {
rp.setStatus(false);
rp.setMsg("Errore! addCPConnection.getInstance() Connection null! " + cpConn.getRp().getMsg());
} else {
rp = cpConn.getRp();
}
if (rp.getStatus()) {
getFree().addElement(cpConn);
this.freeCons++;
printDebugMsg("Add new connection...");
}
return rp;
}
private synchronized boolean checkFreeConnection() {
boolean test = true;
Enumeration<CPConnection> enu = ((Vector<CPConnection>)getFree().clone()).elements();
while (enu.hasMoreElements()) {
CPConnection con = enu.nextElement();
if (!con.isValid()) {
removeFreeConnection(con);
test = false;
}
}
return test;
}
private synchronized boolean checkUsedConnection() {
boolean test = true;
Enumeration<CPConnection> enu = ((Vector<CPConnection>)getUsed().clone()).elements();
while (enu.hasMoreElements()) {
CPConnection con = enu.nextElement();
if (!con.isValid()) {
removeCPConnection(con);
test = false;
}
}
return test;
}
private synchronized boolean resetAllConnection() {
boolean test = false;
Enumeration<CPConnection> enu = ((Vector<CPConnection>)getUsed().clone()).elements();
while (enu.hasMoreElements()) {
CPConnection con = enu.nextElement();
removeCPConnection(con);
test = true;
}
this.used = null;
enu = ((Vector<CPConnection>)getFree().clone()).elements();
while (enu.hasMoreElements()) {
CPConnection con = enu.nextElement();
con.close();
getFree().removeElement(con);
con = null;
this.freeCons--;
test = true;
}
this.free = null;
return test;
}
protected void finalize() throws Throwable {
resetAllConnection();
}
public final synchronized String garbageCollection(int l_logLevel) {
String msg = "\nConnection Pool Garbage Collection for:" + getAp().getUrl();
try {
int uc = getUsedCons();
int fc = getFreeCons();
checkUsedConnection();
checkFreeConnection();
msg = String.valueOf(msg) + "\nUsed connections before gc: " + uc;
msg = String.valueOf(msg) + "\nUsed connections after gc: " + getUsedCons();
msg = String.valueOf(msg) + "\nReleased connections: " + (uc - getUsedCons());
msg = String.valueOf(msg) + "\nFree connections before gc: " + fc;
msg = String.valueOf(msg) + "\nFree connections after gc: " + getFreeCons();
msg = String.valueOf(msg) + "\nDeleted connections: " + (fc - getFreeCons());
msg = String.valueOf(msg) + "\n--------------------------------------------\n";
handleDebug(msg, l_logLevel);
Class.forName(this.ap.getDriverManager()).newInstance();
} catch (Exception e) {
handleDebug(e, 0);
}
return msg;
}
public synchronized CPConnection getCPConnection() throws SQLException {
if (this.freeCons < 0)
this.freeCons = 0;
ResParm rp = new ResParm(true);
if (this.freeCons == 0)
if (this.ap.getMaxCons() == 0 || this.usedCons < this.ap.getMaxCons()) {
rp = addCPConnection();
if (!rp.getStatus())
throw new SQLException("cp.getCPConnection() addCPConnection(): cannot get a new connection ...db:" + getAp().getUrl() +
"\nusername:" + getAp().getUser() + "\npassword:" + getAp().getPassword() + "\nfree:" + this.freeCons + " used:" +
getUsedCons() + "\naddCPConnection Exception:\n" + rp.getMsg() + "\n***************************\n");
} else if (this.ap.isBlock()) {
try {
wait((long)this.ap.getTimeout());
} catch (InterruptedException ie) {
System.err.println("Interrupted Exception: " + ie.getMessage());
}
if (this.freeCons == 0)
if (this.ap.getMaxCons() == 0 || this.usedCons < this.ap.getMaxCons()) {
rp = addCPConnection();
} else if (checkUsedConnection()) {
if (resetAllConnection()) {
rp = addCPConnection();
handleDebug(
"WARNING! CONNECTION POOL RESET. CHANGE TIMEOUT OR MAXCON PARMS OR CHECK FOR ERRORS ON YOU CODE db:" +
getAp().getUrl(),
0);
} else {
throw new SQLException("After timeout error resetting all connection...db:" + getAp().getUrl() +
" free:" + this.freeCons + " used:" + getUsedCons() + "\n***************************\n");
}
} else if (this.ap.getMaxCons() == 0 || this.usedCons < this.ap.getMaxCons()) {
rp = addCPConnection();
} else {
throw new SQLException("After timeout still connection non available. IT SHOULD BE NEVER HAPPEN!!..db:" +
getAp().getUrl() + " free:" + this.freeCons + " used:" + getUsedCons() +
"\n***************************\n");
}
} else {
throw new SQLException("Max number of connections reached!\n***************************\n");
}
if (!rp.getStatus())
throw new SQLException("cp.getCPConnection() after retries: cannot get a new connection ...db:" + getAp().getUrl() +
"\nusername:" + getAp().getUser() + "\npassword:" + getAp().getPassword() + "\nfree:" + this.freeCons + " used:" +
getUsedCons() + "\naddCPConnection Exception:\n" + rp.getMsg() + "\n***************************\n");
CPConnection cpCon = getFree().lastElement();
getFree().removeElement(cpCon);
this.freeCons--;
if (getAp().getConnectionLifeTime() > 0) {
Calendar cts = Calendar.getInstance();
cts.setTime(cpCon.getCreateTs());
cts.add(12, getAp().getConnectionLifeTime());
if (Calendar.getInstance().after(cts)) {
handleDebug("getCPConnection: too old connection. I'll get a new one. db:" + getAp().getUrl() + " free:" + this.freeCons +
" used:" + getUsedCons() + " connection timestamp: " + cpCon.getLifeTime() + " Connection life time: " +
getAp().getConnectionLifeTime() + " min.", 5);
cpCon.close();
cpCon = null;
return getCPConnection();
}
}
if (!cpCon.isValid()) {
handleDebug("getCPConnection: connection no more valid. db:" + getAp().getUrl() + " free:" + this.freeCons + " used:" + getUsedCons() +
" connection timestamp: " + cpCon.getLifeTime(), 5);
cpCon = CPConnection.getInstance(getAp());
rp = cpCon.getRp();
}
if (cpCon == null || cpCon.getConn() == null || !rp.getStatus())
throw new SQLException("cp.getCPConnection(): cannot get a new connection ...db:" + getAp().getUrl() + "\nusername:" +
getAp().getUser() + "\npassword:" + getAp().getPassword() + "\nfree:" + this.freeCons + " used:" + getUsedCons() + "\n" +
"\naddCPConnection new connection after invalid connection. Exception:\n" + rp.getMsg() +
"\n***************************\n");
getUsed().addElement(cpCon);
this.usedCons++;
cpCon.addHit();
cpCon.setCallTs(new Timestamp(System.currentTimeMillis()));
if (getDebug() && getDebugLevel() >= 1) {
StringBuffer msg = new StringBuffer("Connection Calling Stack Trace:\n");
StringBuffer msgAll = new StringBuffer("Connection Calling Stack Trace (NO DBAdapter class found!):\n");
StackTraceElement[] callingFrame = Thread.currentThread().getStackTrace();
boolean dbAdapterTrovato = false;
boolean dbAdapterSparito = false;
if (callingFrame.length > 0) {
int numRigheDBAdapter = 0;
for (int i = 1; i < callingFrame.length; i++) {
String temp = String.valueOf(callingFrame[i].getClassName()) + "." + callingFrame[i].getMethodName();
msgAll.append(temp);
msgAll.append("\n");
if (temp.indexOf("DBAdapter") > 1)
dbAdapterTrovato = true;
if (dbAdapterTrovato && temp.indexOf("DBAdapter") < 0)
dbAdapterSparito = true;
if (dbAdapterSparito) {
msg.append(temp);
msg.append("\n");
numRigheDBAdapter++;
if (numRigheDBAdapter >= 4)
break;
}
}
}
if (dbAdapterSparito) {
cpCon.setLastCallingStackTrace(msg.toString());
} else {
cpCon.setLastCallingStackTrace(msgAll.toString());
}
} else {
cpCon.setLastCallingStackTrace("<b>For full stack trace pls. set debug level to DEBUG (5) or INFO1 (1)</b>");
}
handleDebug("getCPConnection: db:" + getAp().getUrl() + " free:" + this.freeCons + " used:" + getUsedCons(), 5);
return cpCon;
}
public String getCpParms() {
String temp = "Initial Connections: " + this.ap.getInitialCons() + "\n" + "Max Connections: " + this.ap.getMaxCons() + "\n" + "Timeout: " +
this.ap.getTimeout() + "\n" + "Free Connections: " + this.freeCons + "\n" + "Used Connections: " + this.usedCons;
return temp;
}
public boolean getDebug() {
if (getAp() != null)
return super.getDebug();
return super.getDebug();
}
public int getFreeCons() {
return this.freeCons;
}
public int getUsedCons() {
return this.usedCons;
}
private void initCPConnection() {
int i = 0;
while (this.freeCons < this.ap.getInitialCons() && i < this.ap.getMaxCons()) {
ResParm rp = addCPConnection();
if (rp.getStatus()) {
i++;
continue;
}
break;
}
this.usedCons = 0;
}
public void releaseCPConnection(CPConnection con) {
releaseCPConnection(con, this.ap.isReuseCons());
}
private synchronized void releaseCPConnection(CPConnection con, boolean reuseThisCon) {
if (con != null) {
con.setReqIpAddress("");
if (getUsed().contains(con)) {
getUsed().removeElement(con);
this.usedCons--;
if (reuseThisCon) {
if (this.ap.getMaxConnectionHits() > 0) {
if (con.getHits() > this.ap.getMaxConnectionHits()) {
con.close();
con = null;
} else {
getFree().addElement(con);
this.freeCons++;
}
} else {
getFree().addElement(con);
this.freeCons++;
}
} else {
con.close();
con = null;
printDebugMsg("Removed connection...");
}
notify();
} else {
handleDebug(
"releaseCPConnection: used Connection " + con +
" not from this Connection Pool or connection already removed! Processing Garbage Collection...db:" +
getAp().getUrl() + " free:" + this.freeCons + " used:" + getUsedCons() + "\n" + con.getLastCallingStackTrace(),
0);
garbageCollection(0);
}
} else {
handleDebug("releaseCPConnection: trying to release a null connection!! Processing Garbage Collection db:" + getAp().getUrl() +
" free:" + this.freeCons + " used:" + getUsedCons(), 0);
garbageCollection(0);
}
handleDebug("releaseCPConnection: well done ...db:" + getAp().getUrl() + " free:" + this.freeCons + " used:" + getUsedCons(),
5);
}
private synchronized void removeFreeConnection(CPConnection con) {
if (con != null) {
con.setReqIpAddress("");
if (getFree().contains(con)) {
getFree().removeElement(con);
con.close();
con = null;
this.freeCons--;
} else {
handleDebug("removeFreeConnection: Free Connection " + con +
" not from this Connection Pool or connection already removed!...db:" + getAp().getUrl() + " free:" + this.freeCons +
" used:" + getUsedCons(), 0);
garbageCollection(0);
}
notify();
} else {
handleDebug("removeFreeConnection: trying to release a null connection!! Processing Garbage Collection db:" + getAp().getUrl() +
" free:" + this.freeCons + " used:" + getUsedCons(), 0);
garbageCollection(0);
}
handleDebug("removeFreeConnection: well done ...db:" + getAp().getUrl() + " free:" + this.freeCons + " used:" + getUsedCons(),
5);
}
public void removeCPConnection(CPConnection con) {
releaseCPConnection(con, false);
}
public void setFreeCons(int newFreeCons) {
this.freeCons = newFreeCons;
}
public void setUsedCons(int newUsedCons) {
this.usedCons = newUsedCons;
}
public String getDebugFile() {
if (getAp() != null)
return getAp().getDebugFile();
return getDebugFile();
}
public int getDebugLevel() {
if (getAp() != null)
return getAp().getDebugLevel();
return getDebugLevel();
}
public Vector<CPConnection> getFree() {
if (this.free == null)
this.free = new Vector<>(this.ap.getInitialCons());
return this.free;
}
public void setFree(Vector<CPConnection> free) {
this.free = free;
}
public Vector<CPConnection> getUsed() {
if (this.used == null)
this.used = new Vector<>(this.ap.getInitialCons());
return this.used;
}
public void setUsed(Vector<CPConnection> used) {
this.used = used;
}
private void resetOldUsedConnection(long min) {
System.out.println("Resetting used connection for " + getAp().getApCode());
Enumeration<CPConnection> enu = ((Vector<CPConnection>)getUsed().clone()).elements();
int i = 0;
while (enu.hasMoreElements()) {
i++;
CPConnection con = enu.nextElement();
if (con.getCallTimeMilliSeconds() > min * 60000L) {
System.out.println("Force closing used connection " + i + " ....");
con.close();
getUsed().removeElement(con);
con = null;
this.usedCons--;
}
}
}
public ApplParm getAp() {
return this.ap;
}
private final void printDebugMsg(String msg) {
String methodName = Thread.currentThread().getStackTrace()[10].getMethodName();
String className = Thread.currentThread().getStackTrace()[10].getClassName();
if (methodName.indexOf("findRows") >= 0) {
methodName = Thread.currentThread().getStackTrace()[9].getMethodName();
className = Thread.currentThread().getStackTrace()[9].getClassName();
}
StringBuilder sb = new StringBuilder(">>>>>>>> Connection Pool:\n");
Date d = new Date(System.currentTimeMillis());
sb.append(d.toString());
sb.append("\n");
sb.append(msg);
sb.append("\n");
sb.append(className);
sb.append(".");
sb.append(methodName);
sb.append("\n");
if (this.apFull != null) {
sb.append(this.apFull.getReqUrl());
sb.append("\n");
}
sb.append(this.ap.getDatabase());
sb.append("\nTot connections= ");
sb.append(this.freeCons + this.usedCons);
sb.append("\nMax connections= ");
sb.append(this.ap.getMaxCons());
sb.append("\n<<<<<<<<<");
System.out.println(sb.toString());
}
public static synchronized ConnectionPool getInstance(ApplParmFull apFull) {
String cpKey = String.valueOf(apFull.getAp().getDatabase()) + "_" + apFull.getAp().getUser() + "_" + apFull.getAp().getPassword();
if (getHt_connectionPools().containsKey(cpKey))
return getHt_connectionPools().get(cpKey);
ConnectionPool cp = new ConnectionPool(apFull.getAp());
cp.initCPConnection();
getHt_connectionPools().put(cpKey, cp);
return cp;
}
public static void resetOldUsed(final long min) {
new Thread() {
public void run() {
Enumeration<ConnectionPool> enu = ConnectionPool.getCpools();
while (enu.hasMoreElements()) {
ConnectionPool l_cp = enu.nextElement();
l_cp.resetOldUsedConnection(min);
}
}
}.start();
}
}

View file

@ -0,0 +1,102 @@
package com.ablia.db;
import com.ablia.common.CrontabInterface;
import com.ablia.common.Users;
import com.ablia.mail.MailProperties;
import com.ablia.util.Timer;
import java.sql.Timestamp;
import java.util.Hashtable;
public class CrontabJobThread extends Thread {
public boolean isRunning = false;
private ApplParmFull apFull;
private CrontabInterface crontabInterface;
private String jobName;
private String eMail;
private static Hashtable<String, CrontabJobThread> runningInstaces = new Hashtable<>();
private CrontabJobThread(CrontabInterface crontabInterface, ApplParmFull ap, String jobName, String eMail) {
this.crontabInterface = crontabInterface;
setApFull(ap);
this.eMail = eMail;
this.jobName = jobName;
start();
}
public synchronized void run() {
this.isRunning = true;
Timer timer = new Timer();
timer.start();
String corpoMessaggio = String.valueOf(timer.getTStart().toString()) + " " + getApFull().getDatabase() + " CrontabJobThread: " + this.jobName + " started!!";
System.out.println(corpoMessaggio);
CrontabThread.appendLog(this.apFull, corpoMessaggio);
ResParm rp = new ResParm();
try {
rp = this.crontabInterface.crontabJob(getApFull());
} catch (Exception e) {
e.printStackTrace();
rp.setException(e);
}
Timestamp tEnd = new Timestamp(System.currentTimeMillis());
timer.stop();
String endMsg = String.valueOf(timer.getTStop().toString()) + " " + getApFull().getDatabase() + " CrontabJobThread: " + this.jobName + " (" +
timer.getDurataHourMin() + ") FINISHED";
if (!rp.getStatus() || !rp.getMsg().isEmpty())
endMsg = String.valueOf(endMsg) + "\n---- start crontabjob message -----\n" + rp.getMsg() + (
(rp.getException() != null) ? ("\n" + rp.getExceptionStackTrace()) : "") + "\n----- end crontabjob message ------";
CrontabThread.appendLog(this.apFull, endMsg);
corpoMessaggio = String.valueOf(corpoMessaggio) + "\n" + endMsg;
this.isRunning = false;
if (this.eMail != null && !this.eMail.isEmpty()) {
Users bean = new Users(this.apFull);
MailProperties mp = new MailProperties();
mp.put("TO", this.eMail);
mp.setProperty("FROM", this.apFull.getParm("FROM").getTesto());
mp.put("SUBJECT", "Crontab Job " + this.jobName + " " + this.apFull.getDatabase() + " del " + tEnd);
mp.setProperty("BCC", "");
mp.setProperty("CC", "");
mp.put("MSG", corpoMessaggio);
try {
bean.sendMailMessage(mp);
} catch (Exception e) {
e.printStackTrace();
CrontabThread.appendLog(this.apFull, String.valueOf(new Timestamp(System.currentTimeMillis()).toString()) + " " + getApFull().getDatabase() +
" CrontabJobThread: " + this.jobName + " SEND MAIL ERROR TO " + this.eMail + "\n" + e.getMessage());
}
}
runningInstaces.remove(this.jobName);
}
public ApplParmFull getApFull() {
return this.apFull;
}
private void setApFull(ApplParmFull ap) {
this.apFull = ap;
}
public static String minToTempoHourMin(long min) {
return String.valueOf(String.valueOf((int)(min / 60L))) + " h " + String.valueOf(min - (long)((int)(min / 60L) * 60)) + " min";
}
public static String secToTempoHourMin(long sec) {
long h = sec / 3600L;
long min = (sec - h * 60L) / 60L;
long secF = sec - h * 3660L - min * 60L;
return String.valueOf(h) + " h " + min + " min " + secF + " sec";
}
public static CrontabJobThread getInstance(CrontabInterface crontabInterface, ApplParmFull ap, String jobName, String eMail) {
if (!runningInstaces.containsKey(jobName)) {
CrontabJobThread currentThread = new CrontabJobThread(crontabInterface, ap, jobName, eMail);
runningInstaces.put(jobName, currentThread);
return currentThread;
}
return runningInstaces.get(jobName);
}
}

View file

@ -0,0 +1,200 @@
package com.ablia.db;
import com.ablia.common.CrontabInterface;
import com.ablia.log.Log;
import com.ablia.util.FileLogger;
import com.ablia.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.Calendar;
import java.util.Date;
import java.util.Hashtable;
public class CrontabThread extends Thread {
private static Hashtable<String, CrontabThread> instance = new Hashtable<>();
public boolean isRunning = false;
private ApplParmFull apFull;
public static void getInstance(ApplParmFull theApplParmFull) {
boolean debug = true;
if (!instance.containsKey(theApplParmFull.getApCode())) {
DBAdapter.logDebug(debug, "\n****** Init Crontab Servlet started!! " + theApplParmFull.getApCode() + " ******");
CrontabThread currentThread = new CrontabThread(theApplParmFull);
instance.put(theApplParmFull.getApCode(), currentThread);
}
}
private CrontabThread(ApplParmFull l_ap) {
setApFull(l_ap);
start();
}
public synchronized void run() {
this.isRunning = true;
String dashLine = "******************************************************\n";
String endDashLine = "######################################################\n";
Date d = new Date(System.currentTimeMillis());
System.out.println("\n" + d.toString() + " " + getApFull().getDatabase() + " ****** CrontabThread started!! ******");
appendLog(this.apFull, String.valueOf(dashLine) + d.toString() + " " + getApFull().getDatabase() + " CrontabThread started!!\n" + dashLine);
if ((long)getApFull().getParm("DAILY_CRONTAB_ENABLE").getNumeroInt() == 1L)
while (this.isRunning) {
if ((long)getApFull().getParm("DAILY_CRONTAB_ENABLE").getNumeroInt() == 1L) {
try {
String crontabs = getApFull().getParm("DAILY_CRONTAB").getTesto().trim();
String job = "NO JOB SELECTED!";
if (!crontabs.isEmpty())
try {
String crontabsOk = crontabs;
String delimeter = "\n";
if (crontabs.indexOf('\r') > 1) {
crontabsOk = crontabs.replaceAll("\n", "");
delimeter = "\r";
} else if (crontabs.indexOf('\n') > 1) {
crontabsOk = crontabs.replaceAll("\r", "");
delimeter = "\n";
}
StringTokenizer st = new StringTokenizer(crontabsOk, delimeter);
while (st.hasMoreTokens()) {
job = st.nextToken();
String eMail = null;
if (eseguoJob(job)) {
StringTokenizer stJob = new StringTokenizer(job, " ");
if (stJob.countToken() == 7) {
eMail = stJob.getToken(6);
} else if (stJob.countToken() == 2) {
eMail = st.getToken(1);
}
String realJob = job.substring(0, job.indexOf(' '));
Class<?> jobClass = Class.forName(realJob);
Object jobInst = jobClass.newInstance();
CrontabJobThread.getInstance((CrontabInterface)jobInst, this.apFull, realJob, eMail);
}
}
} catch (Exception e) {
d = new Date(System.currentTimeMillis());
appendLog(this.apFull, String.valueOf(d.toString()) + " Exception CRONTAB JOB: " + job + "\n" + e.getMessage());
}
if (getApFull().getParm("USE_LOG").getNumero() == 1.0D && (getApFull().getParm("LOG_GG").getNumero() > 0.0D ||
getApFull().getParm("LOG_MAIL_GG").getNumero() > 0.0D)) {
job = "com.ablia.common.Log 0 0 * * * ";
if (eseguoJob(job))
try {
CrontabJobThread.getInstance(new Log(), this.apFull, "Pulizia Log giornaliera",
getApFull().getParm("LOG_CRONTAB_MAIL").getTesto());
} catch (Exception e) {
d = new Date(System.currentTimeMillis());
appendLog(this.apFull, String.valueOf(d.toString()) + " Exception CRONTAB JOB: " + job + "\n" + e.getMessage());
}
}
Calendar calNow = Calendar.getInstance();
long milsNow = calNow.getTimeInMillis();
calNow.set(14, 0);
calNow.set(13, 0);
sleep(60000L - milsNow + calNow.getTimeInMillis());
} catch (Exception e) {
e.printStackTrace();
}
continue;
}
this.isRunning = false;
}
instance.remove(getApFull().getApCode());
d = new Date(System.currentTimeMillis());
appendLog(this.apFull, String.valueOf(endDashLine) + d.toString() + " CrontabThread STOPPED!!\n" + endDashLine);
System.out.println("\n" + d.toString() + " CrontabThread STOPPED!!");
setApFull(null);
}
public ApplParmFull getApFull() {
return this.apFull;
}
private void setApFull(ApplParmFull ap) {
this.apFull = ap;
}
private boolean eseguoJob(String currentJob) {
java.util.StringTokenizer orari = new java.util.StringTokenizer(currentJob, " ");
if (orari.countTokens() >= 1 && orari.countTokens() <= 7) {
int minute = 0, hour = 0, mday = -1, month = -1, wday = -1;
if (orari.countTokens() >= 6) {
orari.nextToken();
String temp = orari.nextToken();
minute = temp.equals("*") ? -1 : Integer.parseInt(temp);
temp = orari.nextToken();
hour = temp.equals("*") ? -1 : Integer.parseInt(temp);
temp = orari.nextToken();
mday = temp.equals("*") ? -1 : Integer.parseInt(temp);
temp = orari.nextToken();
month = temp.equals("*") ? -1 : Integer.parseInt(temp);
temp = orari.nextToken();
wday = temp.equals("*") ? -1 : Integer.parseInt(temp);
}
Calendar cal = Calendar.getInstance();
int currentMese = cal.get(2);
int currentWday = cal.get(7);
int currentMday = cal.get(5);
int currentHour = cal.get(11);
int currentMin = cal.get(12);
if ((month < 0 || currentMese == month) && (mday < 0 || currentMday == mday) && (wday < 0 || currentWday == wday) && (
hour < 0 || currentHour == hour) && (minute < 0 || currentMin == minute))
return true;
return false;
}
String nomeJob = orari.nextToken();
Date d = new Date(System.currentTimeMillis());
appendLog(this.apFull, String.valueOf(d.toString()) + " CRONTAB JOB: " + nomeJob + "\nERRORE! riga crontab errata: " + currentJob);
return false;
}
public static final ResParm appendLog(ApplParmFull ap, String msg) {
ResParm rp = new ResParm();
synchronized (ap) {
FileLogger.getInstance(ap.getParm("DAILY_CRONTAB_MAIN_LOG_FILE").getTesto().trim()).writeMessage(msg);
}
return rp;
}
public static final ResParm clearLog(ApplParmFull ap) {
ResParm rp = new ResParm(true);
synchronized (ap) {
try {
File clog = new File(ap.getParm("DAILY_CRONTAB_MAIN_LOG_FILE").getTesto().trim());
if (clog.exists())
clog.delete();
clog.createNewFile();
} catch (Exception e) {
e.printStackTrace();
rp.setStatus(false);
rp.setMsg(e.getMessage());
}
}
return rp;
}
public static final String getLog(ApplParmFull ap) {
String logMsg = "";
File clog = new File(ap.getParm("DAILY_CRONTAB_MAIN_LOG_FILE").getTesto().trim());
if (clog.exists()) {
String NL = "\n";
try {
StringBuilder sb = new StringBuilder();
BufferedReader bufferedreader = new BufferedReader(
new FileReader(ap.getParm("DAILY_CRONTAB_MAIN_LOG_FILE").getTesto().trim()));
String s1;
while ((s1 = bufferedreader.readLine()) != null) {
sb.append(s1);
sb.append("\n");
}
bufferedreader.close();
logMsg = sb.toString();
} catch (Exception exception) {
exception.printStackTrace(System.out);
}
}
return logMsg;
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,68 @@
package com.ablia.db;
import java.sql.SQLException;
public class DBAdapterException extends SQLException {
private static final long serialVersionUID = -8013752768366984642L;
private ResParm rp = null;
private boolean duplicateKeyError = false;
private String mySQLState;
public DBAdapterException() {}
public DBAdapterException(Exception e) {
super(e.toString());
}
public DBAdapterException(String s) {
super(s);
}
public DBAdapterException(String s, ResParm rp) {
super(s);
setRp(rp);
}
public DBAdapterException(SQLException sqle) {
super(sqle.getMessage());
setSQLState(sqle.getSQLState());
if (sqle.getSQLState() != null)
if (sqle.getSQLState().equals("S1000") ||
sqle.getSQLState().equals("S1009")) {
this.duplicateKeyError = true;
} else {
this.duplicateKeyError = false;
}
}
public String getMessage() {
if (isDuplicateKeyError())
return "Duplicated Key error!!!";
return super.getMessage();
}
public ResParm getRp() {
return this.rp;
}
public String getSQLState() {
if (this.mySQLState == null)
return super.getSQLState();
return this.mySQLState;
}
public boolean isDuplicateKeyError() {
return this.duplicateKeyError;
}
private void setRp(ResParm newRp) {
this.rp = newRp;
}
private void setSQLState(String newSQLState) {
this.mySQLState = newSQLState;
}
}

View file

@ -0,0 +1,61 @@
package com.ablia.db;
public class DBAdapterSaveResponse {
private String _id;
private String lastUpdTmst;
private String lastUpdInfo;
private String msg;
private boolean status;
public DBAdapterSaveResponse(String _id, String lastUpdTmst, String lastUpdInfo, String msg, boolean status) {
this._id = _id;
this.lastUpdInfo = lastUpdInfo;
this.lastUpdTmst = lastUpdTmst;
this.msg = msg;
this.status = status;
}
public String get_id() {
return this._id;
}
public void set_id(String _id) {
this._id = _id;
}
public String getMsg() {
return "xxx" + this.msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public String getLastUpdTmst() {
return this.lastUpdTmst;
}
public void setLastUpdTmst(String lastUpdTmst) {
this.lastUpdTmst = lastUpdTmst;
}
public String getLastUpdInfo() {
return this.lastUpdInfo;
}
public void setLastUpdInfo(String lastUpdInfo) {
this.lastUpdInfo = lastUpdInfo;
}
public boolean isStatus() {
return this.status;
}
public void setStatus(boolean dbStatus) {
this.status = dbStatus;
}
}

View file

@ -0,0 +1,46 @@
package com.ablia.db;
import com.ablia.util.Debug;
import com.ablia.util.SimpleDateFormat;
import java.sql.Date;
import java.text.ParseException;
public abstract class DBReflectAdapter extends Debug implements DBReflectInterface {
private ApplParm fieldAp;
public ApplParm getApFull() {
return this.fieldAp;
}
public Object[] getFieldSetArg(String parmValue, Class type) throws ParseException {
Object[] retParm = new Object[1];
if (type.equals(String.class)) {
retParm[0] = parmValue;
} else if (type.equals(Long.class) ||
type.getName().equals("long")) {
retParm[0] = new Long(parmValue);
} else if (type.equals(Integer.class) ||
type.getName().equals("int")) {
retParm[0] = new Integer(parmValue);
} else if (type.equals(Double.class) ||
type.getName().equals("double")) {
retParm[0] = Double.valueOf(parmValue.replace(',', '.'));
} else if (type.equals(Float.class) ||
type.getName().equals("float")) {
retParm[0] = Float.valueOf(parmValue.replace(',', '.'));
} else if (type.equals(Date.class)) {
try {
retParm[0] = new Date(getApFull().getDataFormat().parse(
parmValue).getTime());
} catch (ParseException e) {}
retParm[0] = new Date(
new SimpleDateFormat("dd/MM/yy")
.parse(parmValue).getTime());
}
return retParm;
}
public void setAp(ApplParm newFieldAp) {
this.fieldAp = newFieldAp;
}
}

View file

@ -0,0 +1,7 @@
package com.ablia.db;
import java.text.ParseException;
public interface DBReflectInterface {
Object[] getFieldSetArg(String paramString, Class paramClass) throws ParseException;
}

View file

@ -0,0 +1,47 @@
package com.ablia.db;
import com.ablia.common.DescLangItem;
import com.ablia.util.Vectumerator;
import java.util.Vector;
public interface DbInterface {
ResParm delete();
Vectumerator<? extends DBAdapter> findAll();
void findByPrimaryKey(Object paramObject);
int getDBState();
ResParm save();
ResParm translateAllDbDesc(String paramString);
String getReqIpAddress();
void setReqIpAddress(String paramString);
boolean useDescLangTables();
boolean isGoogleTranslatorEnable();
void setDescTxtLangValues(Vector<DescLangItem> paramVector);
String getCurrentFocus();
String getCurrentLang();
String getCurrentTab();
String getLastUpdTmstString();
String getLastUpdTmstForFiles();
String get_Id();
String get_IdName();
String getReqUrl();
String getSqlQuery();
}

View file

@ -0,0 +1,135 @@
package com.ablia.db;
public class DriversJdbc {
public static final String SLQSTATE_COMMUNICATION_ERROR = "08S01";
public static final String SLQSTATE_SQLSERVER_LOCK_REQUEST_TIME_EXEDEED = "S0003";
public static final String SLQSTATE_INTEGRITY_CONSTRAINT_VIOLATION = "23000";
public static final String MYSQL_UTF8_CONNECTION_STRING = "?useUnicode=true&characterEncoding=UTF-8";
private static final int TOT_NUMBER_OF_DRIVERS = 17;
public static final int JDBC_ODBC = 0;
public static final int ORACLE = 1;
public static final int HSQLDB = 2;
public static final int MYSQL_CONNECTORJ = 3;
public static final int POSTGRES = 4;
public static final int MARIA_DB = 5;
public static final int SYBASE = 6;
public static final int INTERBASE = 7;
public static final int DB2 = 8;
public static final int INFORMIX = 9;
public static final int ZYH_DBF = 10;
public static final int ATINAV_ACCESS = 11;
public static final int EASY_JDBC = 12;
public static final int MS_SQL_SERVER_2000 = 13;
public static final int MS_SQL_SERVER_2005_2008 = 14;
public static final int PERVASIVE_PSQL_JDBC = 15;
public static final int UCANACCESS = 16;
private static String[] driverDescription;
private static String[] driverManager;
private static String[] connectionString;
public static final String LAST_INSERT_ID_MYSQL = "Select LAST_INSERT_ID() as id ";
public static final String LAST_INSERT_ID_MS_SQL_SERVER = "SELECT @@IDENTITY AS id ";
public static final String LAST_INSERT_ID_INFORMIX = "Select dbinfo('sqlca.sqlerrd1') as id from ";
public static String getConnectionString(int i) {
if (connectionString == null) {
connectionString = new String[17];
connectionString[0] = "jdbc:odbc";
connectionString[1] = "jdbc:oracle";
connectionString[2] = "jdbc:hsqldb";
connectionString[3] = "jdbc:mysql";
connectionString[4] = "jdbc:postgresql";
connectionString[5] = "jdbc:mariadb";
connectionString[6] = "jdbc:sybase:Tds";
connectionString[7] = "jdbc:interbase";
connectionString[8] = "jdbc:db2";
connectionString[9] = "jdbc:informix-sqli";
connectionString[10] = "jdbc:DBF";
connectionString[11] = "jdbc:atinav";
connectionString[12] = "jdbc:easysoft";
connectionString[13] = "jdbc:microsoft:sqlserver";
connectionString[14] = "jdbc:sqlserver";
connectionString[15] = "jdbc:pervasive";
connectionString[16] = "jdbc:ucanaccess";
}
return connectionString[i];
}
public static String getDriverDescription(int i) {
if (driverDescription == null) {
driverDescription = new String[17];
driverDescription[0] = "JDBC-ODBC:\t<data-source-name>[;<attribute-name>=<attribute-value>] (es:UID=me;PWD=secret)";
driverDescription[1] = "ORACLE THIN: ";
driverDescription[2] = "HSQLDB DRIVER:\thsql://[hostname] (Server Mode)\n\t\t[DatabasePath] (Stand alone)";
driverDescription[3] = "jdbc:mysql://[hostname][,failoverhost...][:port]/[dbname][?param1=value1][&param2=value2]";
driverDescription[4] = "POSTGRES:\t[//[hostname]/][dbname]:";
driverDescription[5] = "MARIA DB:\t//[hostname][:port]/[DB?user=[dbuser]&password=[dbpassword]]: ";
driverDescription[6] = "SYBASE: ";
driverDescription[7] = "INTERBASE: ";
driverDescription[8] = "DB2: ";
driverDescription[9] = "INFORMIX IFX:\t[//][host]:[port]/[dbname]:INFORMIXSERVER=[dbservername]: ";
driverDescription[10] = "ZYH DBF-FOXPRO:\t/[path to dbf files] or [//][host][:port]/[DatabasePath]: ";
driverDescription[11] = "ATINAV-ACCESS:\t[hostname]:[serverportno]:[databasepath] (port usually is 7227): ";
driverDescription[12] = "EasySoft JDBC-ODBC:\t//[hostname]/[DSN]: ";
driverDescription[13] = "MS Sql Server 2000 JDBC driver:\t//[hostname]:1433;databaseName=[dbname];user=[dbuser];password=[dbpassword];: ";
driverDescription[14] = "MS Sql Server 2005/2008 JDBC driver:\t//[hostname]:1433;databaseName=[dbname];user=[dbuser];password=[dbpassword];: ";
driverDescription[15] = "Pervasive PSQL 10 JDBC driver:\t//[hostname]:1583/[DATABASE][;encoding=;encrypt=;encryption=] ";
driverDescription[16] = "UCanAccess JDBC driver:\t//db_or_accdb_file_path";
}
return driverDescription[i];
}
public static String getDriverManager(int i) {
if (driverManager == null) {
driverManager = new String[17];
driverManager[0] = "sun.jdbc.odbc.JdbcOdbcDriver";
driverManager[1] = "oracle.jdbc.ddndlthin";
driverManager[2] = "org.hsqldb.jdbcDriver";
driverManager[3] = "com.mysql.jdbc.Driver";
driverManager[4] = "org.postgresql.Driver";
driverManager[5] = "org.mariadb.jdbc.Driver";
driverManager[6] = "com.sybase.jdbc.SybDriver";
driverManager[7] = "interbase.interclient.Driver";
driverManager[8] = "COM.ibm.db2.jdbc.app.DB2Driver";
driverManager[9] = "com.informix.jdbc.IfxDriver";
driverManager[10] = "zyh.sql.dbf.DBFDriver";
driverManager[11] = "acs.jdbc.Driver";
driverManager[12] = "easysoft.sql.jobDriver";
driverManager[13] = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
driverManager[14] = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
driverManager[15] = "com.pervasive.jdbc.v2.Driver";
driverManager[16] = "net.ucanaccess.jdbc.UcanaccessDriver";
}
return driverManager[i];
}
public static int getTotNumberOfDrivers() {
return 17;
}
}

View file

@ -0,0 +1,57 @@
package com.ablia.db;
public class EncodedField {
public static final long MODALITA_MASTER = 0L;
public static final long MODALITA_USER = 1L;
public EncodedField(boolean codifica, long flgAlgoritmo, long modalita) {
this.flgAlgoritmo = flgAlgoritmo;
this.codifica = codifica;
this.flgModalita = modalita;
}
private long flgAlgoritmo = 1L;
private boolean codifica = false;
private long flgModalita;
public EncodedField() {}
public long getFlgAlgoritmo() {
return this.flgAlgoritmo;
}
public void setFlgAlgoritmo(long flgAlgoritmo) {
this.flgAlgoritmo = flgAlgoritmo;
}
public boolean isCodifica() {
return this.codifica;
}
public void setCodifica(boolean codifica) {
this.codifica = codifica;
}
public long getFlgModalita() {
return this.flgModalita;
}
public void setFlgModalita(long modalita) {
this.flgModalita = modalita;
}
public String getEncodedFieldsPrefix() {
return String.valueOf(getFlgModalita()) + "," + getFlgAlgoritmo() + ",0";
}
public static final String getModalita(long l_flgModalita) {
if (l_flgModalita == 0L)
return "Master Key";
if (l_flgModalita == 1L)
return "User";
return "";
}
}

View file

@ -0,0 +1,18 @@
package com.ablia.db;
import java.util.Comparator;
import java.util.Map;
public class FieldsComparator implements Comparator<Object> {
Map<String, FieldsDescriptor> map;
public FieldsComparator(Map<String, FieldsDescriptor> map) {
this.map = map;
}
public int compare(Object o1, Object o2) {
if (this.map.get(o1).getOrder() == this.map.get(o2).getOrder())
return 1;
return Long.valueOf(this.map.get(o1).getOrder()).compareTo(Long.valueOf(this.map.get(o2).getOrder()));
}
}

View file

@ -0,0 +1,50 @@
package com.ablia.db;
public class FieldsDescriptor {
private String fieldName;
private long order;
private String desc;
private String val;
public FieldsDescriptor(String fieldName, long order, String desc, String val) {
this.fieldName = fieldName;
this.order = order;
this.desc = desc;
this.val = val;
}
public String getFieldName() {
return (this.fieldName == null) ? "" : this.fieldName.trim();
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public long getOrder() {
return this.order;
}
public void setOrder(long order) {
this.order = order;
}
public String getDesc() {
return (this.desc == null) ? "" : this.desc.trim();
}
public void setDesc(String desc) {
this.desc = (desc == null) ? "" : desc.trim();
}
public String getVal() {
return (this.val == null) ? "" : this.val.trim();
}
public void setVal(String val) {
this.val = val;
}
}

View file

@ -0,0 +1,88 @@
package com.ablia.db;
import com.ablia.util.Debug;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class JdbcStub extends Debug {
private boolean isRegistered;
private Statement stmt;
private ResultSet rst;
private Connection conn;
private ApplParm ap;
public JdbcStub(ApplParm applparm) throws SQLException {
this.isRegistered = false;
this.ap = applparm;
if (!this.isRegistered)
synchronized (this) {
try {
Class.forName(this.ap.getDriverManager()).newInstance();
} catch (Exception exception) {
System.err.println("Errore: " + exception.getMessage());
}
this.isRegistered = true;
}
String s = String.valueOf(this.ap.getConnectionString()) + ":" + this.ap.getDatabase();
handleDebug("Connecting... with " + s + " user:" + this.ap.getUser() + " Pwd:" + this.ap.getPassword());
if (this.ap.getUser().isEmpty()) {
setConn(DriverManager.getConnection(s));
} else {
setConn(DriverManager.getConnection(s, this.ap.getUser(), this.ap.getPassword()));
}
handleDebug("Connessione ok");
}
public JdbcStub(Connection connection) {
this.isRegistered = false;
this.conn = connection;
}
public void Close() throws SQLException {
if (this.stmt != null)
this.stmt.close();
}
public ResultSet ExecuteQuery(String s) throws SQLException {
try {
this.stmt = this.conn.createStatement();
this.rst = this.stmt.executeQuery(s);
return this.rst;
} catch (SQLException _ex) {
throw _ex;
}
}
public int ExecuteUpdate(String s) throws SQLException {
Close();
try {
this.stmt = this.conn.createStatement();
int i = this.stmt.executeUpdate(s);
return i;
} catch (SQLException sqlexception) {
sqlexception.printStackTrace(System.out);
throw new SQLException();
} finally {
this.stmt.close();
}
}
protected void finalize() throws SQLException {
Close();
}
public Connection getConn() {
return this.conn;
}
public void setConn(Connection connection) {
this.conn = connection;
}
}

View file

@ -0,0 +1,44 @@
package com.ablia.db;
public class OrString {
private static final String OR = " OR ";
private static final String SPACE = " ";
private StringBuffer theString;
private static final String START = " (";
private static final String STOP = ") ";
public String toString() {
return String.valueOf(getTheString().toString()) + ") ";
}
public void addOr(String l_or) {
if (!l_or.trim().isEmpty()) {
if (getTheString().length() == 0) {
getTheString().append(" (");
} else {
getTheString().append(" OR ");
}
getTheString().append(" ");
getTheString().append(l_or);
}
}
private StringBuffer getTheString() {
if (this.theString == null)
this.theString = new StringBuffer();
return this.theString;
}
public static final String prepareSqlStatement(String sqlString) {
int idx = sqlString.indexOf('\'');
while (idx != -1) {
sqlString = String.valueOf(sqlString.substring(0, idx)) + "'" + sqlString.substring(idx, sqlString.length());
idx = sqlString.indexOf('\'', idx + 2);
}
return sqlString;
}
}

View file

@ -0,0 +1,140 @@
package com.ablia.db;
import com.ablia.util.Out;
import java.util.Vector;
public class ResParm {
private String msg;
private Vector vec;
private long errorCode = 0L;
private Exception exception;
private boolean status;
private String infoMsg;
private Object returnObj;
public ResParm() {}
public ResParm(boolean l_status, String l_msg) {
setStatus(l_status);
setMsg(l_msg);
}
public ResParm(boolean l_status) {
setStatus(l_status);
setMsg("");
}
public ResParm(boolean l_status, Exception e) {
setStatus(l_status);
setException(e);
setMsg(e.getMessage());
}
public String getMsg() {
return (this.msg == null) ? "" : this.msg;
}
public boolean getStatus() {
return this.status;
}
public Vector getVec() {
return this.vec;
}
public void appendMsg(String s) {
setMsg(String.valueOf(getMsg()) + s);
}
public void append(ResParm rp2) {
setStatus((getStatus() && rp2.getStatus()));
if (getMsg().isEmpty()) {
if (!rp2.getMsg().isEmpty())
setMsg(rp2.getMsg());
} else if (!rp2.getMsg().isEmpty()) {
setMsg(String.valueOf(getMsg()) + "->" + rp2.getMsg());
}
if (getInfoMsg().isEmpty()) {
if (!rp2.getInfoMsg().isEmpty())
setInfoMsg(rp2.getInfoMsg());
} else if (!rp2.getInfoMsg().isEmpty()) {
setInfoMsg(String.valueOf(getInfoMsg()) + "->" + rp2.getInfoMsg());
}
setReturnObj(rp2.getReturnObj());
setVec(rp2.getVec());
}
public void setStatus(boolean flag) {
this.status = flag;
}
public void setVec(Vector vector) {
this.vec = vector;
}
public Exception getException() {
return this.exception;
}
public String getExceptionStackTrace() {
if (getException() != null) {
Out o = new Out(System.out);
getException().printStackTrace(o);
return String.valueOf(getException().toString()) + "\n" + o.getMsg();
}
return "";
}
public void setException(Exception exception) {
this.exception = exception;
}
public void setMsg(String s) {
this.msg = s;
}
public void setMsg(Exception e) {
setException(e);
this.msg = String.valueOf(e.toString()) + ": " + e.getMessage();
}
public long getErrorCode() {
return this.errorCode;
}
public void setErrorCode(long errorCode) {
this.errorCode = errorCode;
}
public String getErrMsg() {
if (!getStatus() && getMsg().toLowerCase().indexOf("erro") < 0)
return "Error! " + getMsg();
return getMsg();
}
public String getInfoMsg() {
return (this.infoMsg == null) ? "" : this.infoMsg;
}
public void setInfoMsg(String infoMsg) {
this.infoMsg = infoMsg;
}
public void appendInfoMsg(String s) {
setInfoMsg(String.valueOf(getInfoMsg()) + s);
}
public Object getReturnObj() {
return this.returnObj;
}
public void setReturnObj(Object returnObj) {
this.returnObj = returnObj;
}
}

View file

@ -0,0 +1,84 @@
package com.ablia.db;
import com.ablia.util.Vectumerator;
public class RewriteRule {
private String cmd;
private String servlet;
private String code;
private Vectumerator parms;
private String act;
private Vectumerator constValues;
private Vectumerator constParms;
public String getCmd() {
return this.cmd;
}
public void setCmd(String cmd) {
this.cmd = cmd;
}
public String getAct() {
return this.act;
}
public void setAct(String act) {
this.act = act;
}
public String getCode() {
return this.code;
}
public void setCode(String code) {
this.code = code;
}
public Vectumerator getParms() {
return this.parms;
}
public void setParms(Vectumerator parms) {
this.parms = parms;
}
public String getServlet() {
return this.servlet;
}
public void setServlet(String servlet) {
this.servlet = servlet;
}
public String getParm(int idx) {
if (getParms() != null) {
if (idx < getParms().getTotNumberOfRecords())
return getParms().get(idx);
return null;
}
return null;
}
public Vectumerator getConstValues() {
return this.constValues;
}
public void setConstValues(Vectumerator values) {
this.constValues = values;
}
public Vectumerator getConstParms() {
return this.constParms;
}
public void setConstParms(Vectumerator constParms) {
this.constParms = constParms;
}
}

View file

@ -0,0 +1,88 @@
package com.ablia.db;
public class WcString {
private static final String GROUP_BY = " GROUP BY";
private static final String WHERE = " WHERE";
private static final String SPACE = " ";
private StringBuffer theString;
private StringBuffer theGroupBy;
private static final String AND = " AND ";
private static final String HAVING = " HAVING";
public String toString() {
return String.valueOf(getTheGroupBy().toString()) + " " + getTheString().toString();
}
public void addWc(String l_wc) {
if (!l_wc.trim().isEmpty()) {
if (getTheString().length() == 0) {
getTheString().append(" WHERE");
} else {
getTheString().append(" AND ");
}
getTheString().append(" ");
getTheString().append(l_wc);
}
}
public void addHavingWc(String l_wc) {
if (getTheString().length() == 0) {
getTheString().append(" HAVING");
} else {
getTheString().append(" AND ");
}
getTheString().append(" ");
getTheString().append(l_wc);
}
private StringBuffer getTheString() {
if (this.theString == null)
this.theString = new StringBuffer();
return this.theString;
}
public void addGroupBy(String l_column) {
if (!l_column.trim().isEmpty()) {
if (getTheGroupBy().length() == 0) {
getTheGroupBy().append(" GROUP BY");
} else {
getTheGroupBy().append(",");
}
getTheGroupBy().append(" ");
getTheGroupBy().append(l_column);
}
}
private StringBuffer getTheGroupBy() {
if (this.theGroupBy == null)
this.theGroupBy = new StringBuffer();
return this.theGroupBy;
}
public String toStringWOWhere() {
if (getTheString().length() == 0)
return getTheString().toString();
return getTheString().toString().substring(
" WHERE".length() + " ".length());
}
public void setWhere(String l_whereCondition) {
this.theString = new StringBuffer(l_whereCondition);
}
public static final String prepareSqlStatement(String sqlString) {
int idx = sqlString.indexOf('\'');
while (idx != -1) {
sqlString = String.valueOf(sqlString.substring(0, idx)) + "'" +
sqlString.substring(idx, sqlString.length());
idx = sqlString.indexOf('\'', idx + 2);
}
return sqlString;
}
}

View file

@ -0,0 +1,87 @@
package com.ablia.db;
import com.ablia.util.FileWr;
import java.io.IOException;
public class XmlTableExporter {
private static final String START_DB = "<export-database name='";
private static final String END_DB = "</export-database>";
private static final String START_FILE = "<dbadapter>";
private static final String START_TABLE = "<table name='";
private static final String END_TABLE = "</table>";
private static final String END_FILE = "</dbadapter>";
private static final String START_ROW = "<row>";
private static final String END_ROW = "</row>";
private static final String START_COL = "<col name='";
private static final String END_COL = "</col>";
private static final String START_CDATA = "<![CDATA[";
private static final String END_CDATA = "]]>";
private static final String CLOSING_WITH_TICK = "'>";
private FileWr _fw;
public XmlTableExporter(FileWr fw) {
this._fw = fw;
}
public void close() throws IOException {
if (this._fw != null)
this._fw.closeFile();
}
public void startDbExport(String dbName) throws IOException {
String stg = "<export-database name='" + dbName + "'>";
this._fw.writeLine(stg);
}
public void endDbExport() throws IOException {
this._fw.writeLine("</export-database>");
}
public void startTable(String tableName) throws IOException {
String stg = "<table name='" + tableName + "'>";
this._fw.writeLine(stg);
}
public void endTable() throws IOException {
this._fw.writeLine("</table>");
}
public void endFile() throws IOException {
this._fw.writeLine("</dbadapter>");
}
public void startRow() throws IOException {
this._fw.writeLine("<row>");
}
public void endRow() throws IOException {
this._fw.writeLine("</row>");
}
public void addColumn(String name, String val) throws IOException {
String stg;
if (val != null && (val.indexOf("<") > 0 || val.indexOf(">") > 0)) {
stg = "<col name='" + name + "'>" + "<![CDATA[" + val + "]]>" + "</col>";
} else {
stg = "<col name='" + name + "'>" + val + "</col>";
}
this._fw.writeLine(stg);
}
public void startFile() throws IOException {
this._fw.writeLine("<dbadapter>");
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -0,0 +1,170 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<!-- #BeginTemplate "/Templates/packageSpec.dwt" -->
<head>
<!--
@(#)package.html 1.60 98/01/27
Copyright 1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.
This software is the confidential and proprietary information of Sun
Microsystems, Inc. ("Confidential Information"). You shall not
disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement you entered into
with Sun.
CopyrightVersion 1.2
-->
</head>
<body bgcolor="white">
<h2>Package <!-- #BeginEditable "nomePackage" -->com.ablia.db<!-- #EndEditable -->
description </h2>
<!-- #BeginEditable "packageSpec" -->
<p>Provide an architecture for database access.<br>
Here is an example about the use of the classes under this package. We start
with a simple database like this:</p>
<p><img src="demo.gif" width="597" height="357"></p>
<p>Here we have:</p>
<ul>
<li>2 kernel entity (SUPPLIER and ITEM)</li>
<li>1 association entity (ITEM_SUPPLIER) with 2primary/foreign key</li>
<li>1 attribute entity (SUPPLIER_TYPE)</li>
</ul>
<p>You should name your entity like this:</p>
<ul>
<li>all the entity (tables) singolar and capitalized;</li>
<li>the primary key like &quot;id_[name_of_the_entity_lowercased]&quot;. If
an entity has a two-part name (like SUPPLIER_TYPE), the primary key should
be &quot;id_[first_part_lowercased][second_part_with_first_letter_capitalized][<i>and
so on</i>]&quot;. </li>
</ul>
<p>If you use these rules, you can use com.ablia.tools.Db2Bean class to automatically
create your beans from a created database. Otherwhise you should create your
bean manually inheriting the class com.ablia.DBAdapter and writing by hands
all the abstract method.<br>
The create statements for the database we use as example are (for a mysql database):<code><br>
CREATE TABLE ITEM(<br>
id_item VARCHAR(30) NOT NULL,<br>
price DECIMAL(18,4),<br>
description VARCHAR(30),<br>
nota TEXT,<br>
PRIMARY KEY (id_item),<br>
UNIQUE UC_id_item (id_item));</code></p>
<p><code><br>
CREATE TABLE SUPPLIER_TYPE(<br>
id_supplierType VARCHAR(4) NOT NULL,<br>
description VARCHAR(60),<br>
PRIMARY KEY (id_supplierType),<br>
UNIQUE UC_id_supplierType (id_supplierType));</code></p>
<p><code><br>
CREATE TABLE SUPPLIER(<br>
id_supplier INT NOT NULL AUTO_INCREMENT,<br>
name VARCHAR(60),<br>
address VARCHAR(60),<br>
tel VARCHAR(30),<br>
fax VARCHAR(30),<br>
eMail VARCHAR(30),<br>
city VARCHAR(30),<br>
state VARCHAR(30),<br>
nota TEXT,<br>
id_supplierType VARCHAR(4) NOT NULL,<br>
FOREIGN KEY (id_supplierType) REFERENCES SUPPLIER_TYPE (id_supplierType),<br>
PRIMARY KEY (id_supplier));</code></p>
<p><code><br>
CREATE TABLE ITEM_SUPPLIER(<br>
price DECIMAL(18,4),<br>
id_item VARCHAR(30) NOT NULL,<br>
id_supplier INT NOT NULL,<br>
FOREIGN KEY (id_item) REFERENCES ITEM (id_item),<br>
FOREIGN KEY (id_supplier) REFERENCES SUPPLIER (id_supplier),<br>
PRIMARY KEY (id_item,id_supplier));</code></p>
<p>Just cut and paste on the mysql client console to create it (You have to create
a demo database with a statement like this</p>
<p><code>mysqladmin -uroot -proot create demo</code></p>
<p>Once you have created the database, lets use Db2Bean class to create the access
bean. Here is the console on a Feebsd:</p>
<p><code>test# /usr/local/linux-jdk1.2.2/bin/java -cp /usr/local/linux-jdk1.2.2/jre/lib/rt.jar:/usr/local/ablia/java/lib/ablia.jar:/usr/local/ablia/java/lib/mysql.jar:/usr/local/ablia/java/classes/
com.ablia.tools.Db2Bean<br>
Jdbc connection.....<br>
Choose the Jdbc driver (it must be in your classpath):<br>
(0) JDBC-ODBC:<br>
(1) ORACLE THIN:<br>
(2) IDB DRIVER:<br>
(3) TWZ MYSQL:<br>
(4) POSTGRES:<br>
(5) MM MYSQL: //[hostname]/[dbname]:<br>
(6) SYBASE:<br>
(7) INTERBASE:<br>
(8) DB2:<br>
(9) INFORMIX IFX: [//][host]:[port]/[dbname]:INFORMIXSERVER=[dbservername]:<br>
(10) ZYH DBF-FOXPRO: /[path to dbf files] or [//][host][:port]/[DatabasePath]:<br>
Driver=5<br>
jdbc resource: MM MYSQL: //[hostname]/[dbname]: //localhost/demo<br>
Login: root<br>
Password: root<br>
Output path:(c:/000) /tmp<br>
Package: com.demo<br>
creating table bean ITEM.....Done<br>
creating table bean ITEM_SUPPLIER.....Done<br>
creating table bean SUPPLIER.....Done<br>
creating table bean SUPPLIER_TYPE.....Done<br>
Creating key classes ITEM_SUPPLIER ........Done<br>
bye</code><br>
</p>
<p>In /tmp we should have these classes:</p>
<p><code>Item.java<br>
ItemSupplier.java<br>
ItemSupplierKey.java<br>
Supplier.java<br>
SupplierType.java</code><br>
</p>
<p>These classes ar just a start point. You should develop your own method just
like a find method with a corresponding [bean]CR class (CR stands for search
criteria) like this:</p>
<p><code>public com.ablia.util.Vectumerator findItemsByCR(<br>
com.demo.ItemCR CR,<br>
int pageNumber,<br>
int pageRows)<br>
throws com.ablia.db.DBAdapterException, java.sql.SQLException<br>
{<br>
//////////////////////////////////////////////////<br>
// serach statement<br>
//////////////////////////////////////////////////<br>
String s_Sql_Find = &quot;select DISTINCT A.* from ITEM AS A&quot;;<br>
//////////////////////////////////////////////////<br>
String s_Sql_Order = &quot; order by A.description&quot;;</code></p>
<p><code> // search condition<br>
String wc = &quot;&quot;; // where dataFineVld is null&quot;;<br>
if (!CR.getDescription().equals(&quot;&quot;))<br>
&nbsp;&nbsp;&nbsp;&nbsp;wc = buildWc(wc, &quot;A.description like'&quot; + CR.getDescription()+&quot;%'&quot;);<br>
//other search criteria</code></p>
<p><code><br>
java.sql.PreparedStatement stmt =<br>
getConn().prepareStatement(s_Sql_Find + wc + s_Sql_Order);</code></p>
<p><code> </code><code>return findRows(stmt, pageNumber, pageRows);</code></p>
<p><code>}</code></p>
<p>The <code>findRows(stmt, pageNumber, pageRows);</code> return a Vectumerator
(something like a Vector and an enumeration) with information about the tot
number of records, the page we ar fetching and how many rows contain a page.
This is usefull for page next / page previous command with jsp. You can use
for this the nextVec, prevVec and pageList tag in com.ablia.taglib package.</p>
<p>To use the bean you just create you should:</p>
<ul>
<li>crate an com.ablia.db.ApplParm object with all necessary parameters to connect
to a database (see the ApplParm constructor);</li>
<li>Create the bean (com.demo.Item item = new com.demo.Item(ap);)</li>
<li>Just use the bean: set some properties, save it, find all the objects/rows
of the table, find by primary key, delete an object/row, and so on</li>
</ul>
<p>Today, on march 2002, there are about 10/15 applications that use this architecture,
for web site or for intranet application.</p>
<!-- #EndEditable -->
<h2>&nbsp;</h2>
<!-- Put @see and @since tags down here. -->
</body>
<!-- #EndTemplate -->
</html>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,99 @@
package com.ablia.help;
import com.ablia.db.ApplParmFull;
import com.ablia.db.DBAdapter;
import com.ablia.db.ResParm;
import com.ablia.db.WcString;
import com.ablia.util.StringTokenizer;
import com.ablia.util.Vectumerator;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class ExcludeKeywords extends DBAdapter implements Serializable {
private String id_excludeKeywords;
private String lang;
private String theKey;
public ExcludeKeywords(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public ExcludeKeywords() {}
public void setId_excludeKeywords(String newId_excludeKeywords) {
this.id_excludeKeywords = newId_excludeKeywords;
}
public void setLang(String newLang) {
this.lang = newLang;
}
public String getId_excludeKeywords() {
return (this.id_excludeKeywords == null) ? "" :
this.id_excludeKeywords.trim();
}
public String getLang() {
return (this.lang == null) ? "" : this.lang.trim();
}
protected ResParm checkDeleteCascade() {
return new ResParm(true);
}
protected void deleteCascade() {}
public void findByKeyLang(String l_key, String lang) {
String s_Sql_Find = "select DISTINCT A.* from EXCLUDE_KEYWORDS AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
wc.addWc("A.lang='" + lang + "'");
wc.addWc("A.theKey='" + prepareMySqlString(l_key, false) + "'");
try {
PreparedStatement stmt = getConn().prepareStatement(
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
findFirstRecord(stmt);
} catch (SQLException e) {
handleDebug(e);
}
}
public String getTheKey() {
return (this.theKey == null) ? "" : this.theKey.trim();
}
public void setTheKey(String theKey) {
this.theKey = theKey;
}
public Vectumerator findByCR(ExcludeKeywordsCR CR, int pageNumber, int pageRows) {
String s_Sql_Find = "select DISTINCT A.* from EXCLUDE_KEYWORDS AS A";
String s_Sql_Order = "";
WcString wc = new WcString();
if (!CR.getSearchTxt().trim().isEmpty()) {
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(),
" ");
StringBuffer txt = new StringBuffer("(");
while (st.hasMoreTokens()) {
String token = st.nextToken();
txt.append("(A.Cognome like '%" + token +
"%' or A.Nome like '%" + token + "%')");
if (st.hasMoreTokens())
txt.append(" and ");
}
txt.append(")");
wc.addWc(txt.toString());
}
try {
PreparedStatement stmt = getConn().prepareStatement(
String.valueOf(s_Sql_Find) + wc.toString() + s_Sql_Order);
return findRows(stmt, pageNumber, pageRows);
} catch (SQLException e) {
handleDebug(e);
return AB_EMPTY_VECTUMERATOR;
}
}
}

View file

@ -0,0 +1,32 @@
package com.ablia.help;
import com.ablia.db.ApplParmFull;
import com.ablia.db.CRAdapter;
public class ExcludeKeywordsCR extends CRAdapter {
private String id_excludeKeywords;
private String theKey;
public ExcludeKeywordsCR(ApplParmFull newApplParmFull) {
super(newApplParmFull);
}
public ExcludeKeywordsCR() {}
public void setId_excludeKeywords(String newId_excludeKeywords) {
this.id_excludeKeywords = newId_excludeKeywords;
}
public String getId_excludeKeywords() {
return (this.id_excludeKeywords == null) ? "" : this.id_excludeKeywords.trim();
}
public String getTheKey() {
return (this.theKey == null) ? "" : this.theKey.trim();
}
public void setTheKey(String theKey) {
this.theKey = theKey;
}
}

Some files were not shown because too many files have changed in this diff Show more