From caaffcdbbcafcac4a6bc63bd5a4f9f6a48f3026d Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 5 Apr 2019 15:54:31 +0200 Subject: [PATCH 1/7] IDEMPIERE-3924 Implement EventHandler for pre/after/post processes / adding suggestion from Hiep --- org.adempiere.base/src/org/compiere/process/SvrProcess.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org.adempiere.base/src/org/compiere/process/SvrProcess.java b/org.adempiere.base/src/org/compiere/process/SvrProcess.java index ad72f1ba82..af3e6c2bf1 100644 --- a/org.adempiere.base/src/org/compiere/process/SvrProcess.java +++ b/org.adempiere.base/src/org/compiere/process/SvrProcess.java @@ -259,7 +259,8 @@ public abstract class SvrProcess implements ProcessCall Event event = EventManager.newEvent(topic, new EventProperty(EventManager.EVENT_DATA, m_pi), new EventProperty("processUUID", m_pi.getAD_Process_UU()), - new EventProperty("className", m_pi.getClassName())); + new EventProperty("className", m_pi.getClassName()), + new EventProperty("processClassName", this.getClass().getName())); EventManager.getInstance().sendEvent(event); return event; } From 1acb94c4a847813f8b38d75b6f5ff14eec0e0652 Mon Sep 17 00:00:00 2001 From: hieplq Date: Sat, 23 Mar 2019 16:51:31 +0700 Subject: [PATCH 2/7] current zk*.sources bundle have wrong manifest data, it have export class, so some time make eclipse bind to it instead of binary --- .../org.idempiere.maven.to.p2/pom.xml | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/org.idempiere.maven.to.p2/org.idempiere.maven.to.p2/pom.xml b/org.idempiere.maven.to.p2/org.idempiere.maven.to.p2/pom.xml index 37abad15c7..1a0054055f 100644 --- a/org.idempiere.maven.to.p2/org.idempiere.maven.to.p2/pom.xml +++ b/org.idempiere.maven.to.p2/org.idempiere.maven.to.p2/pom.xml @@ -648,7 +648,6 @@ - org.apache.servicemix.bundles.spring-beans.source spring-expression.source org.apache.servicemix.bundles.spring-beans;version="${springframework.version}";roots:="." @@ -670,7 +669,6 @@ - org.apache.servicemix.bundles.spring-core.source spring-expression.source org.apache.servicemix.bundles.spring-core;version="${springframework.version}";roots:="." @@ -698,7 +696,6 @@ - org.apache.servicemix.bundles.spring-context.source spring-expression.source org.apache.servicemix.bundles.spring-context;version="${springframework.version}";roots:="." @@ -720,7 +717,6 @@ - org.apache.servicemix.bundles.spring-expression.source spring-expression.source org.apache.servicemix.bundles.spring-expression;version="${springframework.version}";roots:="." @@ -737,7 +733,6 @@ - org.apache.servicemix.bundles.spring-aop.source spring-aop.source org.apache.servicemix.bundles.spring-aop;version="${springframework.version}";roots:="." @@ -759,7 +754,6 @@ - org.apache.servicemix.bundles.spring-web.source spring-web.source org.apache.servicemix.bundles.spring-web;version="${springframework.version}";roots:="." @@ -781,7 +775,6 @@ - org.apache.servicemix.bundles.spring-context-support.source spring-context-support.source org.apache.servicemix.bundles.spring-context-support;version="${springframework.version}";roots:="." @@ -943,6 +936,9 @@ zkplus;version="${zk.version}";roots:="." zkplus zkplus.source + + + @@ -953,6 +949,9 @@ zweb;version="${zk.version}";roots:="." zweb zweb.source + + + @@ -963,6 +962,9 @@ zul;version="${zk.version}";roots:="." zul zul.source + + + @@ -973,6 +975,9 @@ zk;version="${zk.version}";roots:="." zk zk.source + + + @@ -983,6 +988,9 @@ zhtml;version="${zk.version}";roots:="." zhtml zhtml.source + + + @@ -993,6 +1001,9 @@ zkbind;version="${zk.version}";roots:="." zkbind zkbind.source + + + @@ -1003,6 +1014,9 @@ zel;version="${zk.version}";roots:="." zel zel.source + + + @@ -1013,6 +1027,9 @@ zcommon;version="${zk.version}";roots:="." zcommon zcommon.source + + + @@ -1023,6 +1040,9 @@ zkwebfragment;version="${zk.version}";roots:="." zkwebfragment zkwebfragment.source + + + @@ -1034,6 +1054,9 @@ zjavassist ${zk.version} zjavassist.source + + + From a726ea78eec6fbc767a22f68ababe6934f9d505f Mon Sep 17 00:00:00 2001 From: Diego Ruiz Date: Tue, 9 Apr 2019 11:57:10 +0200 Subject: [PATCH 3/7] IDEMPIERE-3945 Country name Germany - Deutschland should be named Germany --- migration/i6.2/oracle/201904091130_IDEMPIERE-3945.sql | 11 +++++++++++ .../i6.2/postgresql/201904091130_IDEMPIERE-3945.sql | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 migration/i6.2/oracle/201904091130_IDEMPIERE-3945.sql create mode 100644 migration/i6.2/postgresql/201904091130_IDEMPIERE-3945.sql diff --git a/migration/i6.2/oracle/201904091130_IDEMPIERE-3945.sql b/migration/i6.2/oracle/201904091130_IDEMPIERE-3945.sql new file mode 100644 index 0000000000..f198245303 --- /dev/null +++ b/migration/i6.2/oracle/201904091130_IDEMPIERE-3945.sql @@ -0,0 +1,11 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- IDEMPIERE-3945 Country name "Germany - Deutschland" should be named Germany +-- Apr 9, 2019, 11:22:01 AM CEST +UPDATE C_Country SET Name='Germany',Description='Deutschland',Updated=TO_DATE('2019-04-09 11:22:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_Country_ID=101 +; + +SELECT register_migration_script('201904091130_IDEMPIERE-3945.sql') FROM dual +; + diff --git a/migration/i6.2/postgresql/201904091130_IDEMPIERE-3945.sql b/migration/i6.2/postgresql/201904091130_IDEMPIERE-3945.sql new file mode 100644 index 0000000000..6d0a7866f6 --- /dev/null +++ b/migration/i6.2/postgresql/201904091130_IDEMPIERE-3945.sql @@ -0,0 +1,8 @@ +-- IDEMPIERE-3945 Country name "Germany - Deutschland" should be named Germany +-- Apr 9, 2019, 11:22:01 AM CEST +UPDATE C_Country SET Name='Germany',Description='Deutschland',Updated=TO_TIMESTAMP('2019-04-09 11:22:01','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_Country_ID=101 +; + +SELECT register_migration_script('201904091130_IDEMPIERE-3945.sql') FROM dual +; + From f61ef24e7742e0c75e8a21387be44c7969cf2929 Mon Sep 17 00:00:00 2001 From: Ray Lee Date: Mon, 8 Apr 2019 06:01:10 +0800 Subject: [PATCH 4/7] IDEMPIERE-3942 Implement JoinElement ADN Status --- .../src/org/compiere/wf/MWFProcess.java | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/org.adempiere.base/src/org/compiere/wf/MWFProcess.java b/org.adempiere.base/src/org/compiere/wf/MWFProcess.java index 0752aa5b9f..b343120d18 100644 --- a/org.adempiere.base/src/org/compiere/wf/MWFProcess.java +++ b/org.adempiere.base/src/org/compiere/wf/MWFProcess.java @@ -369,9 +369,23 @@ public class MWFProcess extends X_AD_WF_Process // Start new Activity... MWFActivity activity = new MWFActivity (this, transitions[i].getAD_WF_Next_ID(), lastPO); + /** + * IDEMPIERE-3942 + * Implement JoinElement AND Status + */ + if(MWFNode.JOINELEMENT_AND.equals(activity.getNode().getJoinElement())) + { + if(!isJoinElementANDProcessed(activity)) + { + activity.delete(true, get_TrxName()); + continue; + } + } + activity.set_TrxName(trxName); activity.run(); + // only the first valid if XOR if (MWFNode.SPLITELEMENT_XOR.equals(split)) return true; @@ -379,7 +393,35 @@ public class MWFProcess extends X_AD_WF_Process return true; } // startNext - + /* + * IDEMPIERE-3942 + * Implement JoinElement AND Status + */ + private boolean isJoinElementANDProcessed(MWFActivity activity) { + + + Query queryNodeNextTest = new Query(Env.getCtx(), MWFNodeNext.Table_Name, "AD_WF_Next_ID = ?", get_TrxName()); + queryNodeNextTest.setParameters(activity.getAD_WF_Node_ID()); + List NodeNexts = queryNodeNextTest.list(); + for (MWFNodeNext nodeNext : NodeNexts) { + + Query queryMWFActivity = new Query(Env.getCtx(), MWFActivity.Table_Name, + "AD_WF_Process_ID = ? AND AD_WF_Node_ID = ? ", get_TrxName()); + + Object params[] = { activity.getAD_WF_Process_ID(), nodeNext.getAD_WF_Node_ID() }; + + queryMWFActivity.setParameters(params); + List parentActivitys = queryMWFActivity.list(); + for (MWFActivity parentActivity : parentActivitys) { + if(!parentActivity.isProcessed()) + return false; + } + + } + + return true; + } + /************************************************************************** * Set Workflow Responsible. * Searches for a Invoker. From fc1014f25a97b7966aa16faf735ca2a616b0f536 Mon Sep 17 00:00:00 2001 From: Ray Lee Date: Tue, 9 Apr 2019 17:17:11 +0800 Subject: [PATCH 5/7] IDEMPIERE-3942 #2 Transition need to match with Activity --- .../src/org/compiere/wf/MWFProcess.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/wf/MWFProcess.java b/org.adempiere.base/src/org/compiere/wf/MWFProcess.java index b343120d18..9ae9528c5d 100644 --- a/org.adempiere.base/src/org/compiere/wf/MWFProcess.java +++ b/org.adempiere.base/src/org/compiere/wf/MWFProcess.java @@ -348,14 +348,6 @@ public class MWFProcess extends X_AD_WF_Process if (transitions == null || transitions.length == 0) return false; // done - // We need to wait for last activity - if (MWFNode.JOINELEMENT_AND.equals(last.getNode().getJoinElement())) - { - // get previous nodes - // check if all have closed activities - // return false for all but the last - } - // eliminate from active processed last.setProcessed(true); last.saveEx(); @@ -400,11 +392,16 @@ public class MWFProcess extends X_AD_WF_Process private boolean isJoinElementANDProcessed(MWFActivity activity) { - Query queryNodeNextTest = new Query(Env.getCtx(), MWFNodeNext.Table_Name, "AD_WF_Next_ID = ?", get_TrxName()); - queryNodeNextTest.setParameters(activity.getAD_WF_Node_ID()); - List NodeNexts = queryNodeNextTest.list(); - for (MWFNodeNext nodeNext : NodeNexts) { - + Query queryNodeNext = new Query(Env.getCtx(), MWFNodeNext.Table_Name, "AD_WF_Next_ID = ?", get_TrxName()); + queryNodeNext.setParameters(activity.getAD_WF_Node_ID()); + List nodeNexts = queryNodeNext.list(); + /** + * IDEMPIERE-3942 #2 Transition need to match with Activity + */ + int totalParent = 0; + int totalActivities = 0; + for (MWFNodeNext nodeNext : nodeNexts) { + totalParent++; Query queryMWFActivity = new Query(Env.getCtx(), MWFActivity.Table_Name, "AD_WF_Process_ID = ? AND AD_WF_Node_ID = ? ", get_TrxName()); @@ -413,11 +410,14 @@ public class MWFProcess extends X_AD_WF_Process queryMWFActivity.setParameters(params); List parentActivitys = queryMWFActivity.list(); for (MWFActivity parentActivity : parentActivitys) { + totalActivities++; if(!parentActivity.isProcessed()) return false; } } + if(totalParent < totalActivities) + return false; return true; } From 18ec16c2fb07cf7d2ff84e13e7571afb60cfa841 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 9 Apr 2019 12:39:05 +0200 Subject: [PATCH 6/7] IDEMPIERE-3944 SynchronizeTerminology FK error (FHEG-637) --- .../oracle/02_SynchronizeTerminology.sql | 6 ----- .../postgresql/02_SynchronizeTerminology.sql | 6 ----- .../process/SynchronizeTerminology.java | 25 ------------------- 3 files changed, 37 deletions(-) diff --git a/migration/processes_post_migration/oracle/02_SynchronizeTerminology.sql b/migration/processes_post_migration/oracle/02_SynchronizeTerminology.sql index ae2d180598..7aa7999507 100644 --- a/migration/processes_post_migration/oracle/02_SynchronizeTerminology.sql +++ b/migration/processes_post_migration/oracle/02_SynchronizeTerminology.sql @@ -6,12 +6,6 @@ INSERT INTO AD_ELEMENT_TRL (AD_Element_ID, AD_LANGUAGE, AD_Client_ID, AD_Org_ID, UPDATE AD_COLUMN c SET AD_Element_id = (SELECT AD_Element_ID FROM AD_ELEMENT e WHERE UPPER(c.ColumnName)=UPPER(e.ColumnName)) WHERE AD_Element_ID IS NULL ; -DELETE FROM AD_ELEMENT_TRL WHERE AD_Element_ID >= 1000000 AND AD_Element_ID IN (SELECT AD_Element_ID FROM AD_ELEMENT e WHERE NOT EXISTS (SELECT 1 FROM AD_COLUMN c WHERE UPPER(e.ColumnName)=UPPER(c.ColumnName)) AND NOT EXISTS (SELECT 1 FROM AD_PROCESS_PARA p WHERE UPPER(e.ColumnName)=UPPER(p.ColumnName)) AND NOT EXISTS (SELECT 1 FROM AD_INFOCOLUMN i WHERE UPPER(e.ColumnName)=UPPER(i.ColumnName))) -; - -DELETE FROM AD_ELEMENT e WHERE AD_Element_ID >= 1000000 AND NOT EXISTS (SELECT 1 FROM AD_COLUMN c WHERE UPPER(e.ColumnName)=UPPER(c.ColumnName)) AND NOT EXISTS (SELECT 1 FROM AD_PROCESS_PARA p WHERE UPPER(e.ColumnName)=UPPER(p.ColumnName)) AND NOT EXISTS (SELECT 1 FROM AD_INFOCOLUMN i WHERE UPPER(e.ColumnName)=UPPER(i.ColumnName)) -; - UPDATE AD_COLUMN c SET (ColumnName, Name, Description, Help, Placeholder) = (SELECT ColumnName, Name, Description, Help, Placeholder FROM AD_ELEMENT e WHERE c.AD_Element_ID=e.AD_Element_ID), Updated = SYSDATE WHERE EXISTS (SELECT 1 FROM AD_ELEMENT e WHERE c.AD_Element_ID=e.AD_Element_ID AND (c.ColumnName <> e.ColumnName OR c.Name <> e.Name OR COALESCE(c.Description,N' ') <> COALESCE(e.Description,N' ') OR COALESCE(c.Help,N' ') <> COALESCE(e.Help,N' ') OR COALESCE(c.Placeholder,N' ') <> COALESCE(e.Placeholder,N' '))) ; diff --git a/migration/processes_post_migration/postgresql/02_SynchronizeTerminology.sql b/migration/processes_post_migration/postgresql/02_SynchronizeTerminology.sql index 247f222826..eb3b89e5ce 100644 --- a/migration/processes_post_migration/postgresql/02_SynchronizeTerminology.sql +++ b/migration/processes_post_migration/postgresql/02_SynchronizeTerminology.sql @@ -6,12 +6,6 @@ INSERT INTO AD_ELEMENT_TRL (AD_Element_ID, AD_LANGUAGE, AD_Client_ID, AD_Org_ID, UPDATE AD_COLUMN SET AD_Element_id = (SELECT AD_Element_ID FROM AD_ELEMENT e WHERE UPPER(AD_COLUMN.ColumnName)=UPPER(e.ColumnName)) WHERE AD_Element_ID IS NULL ; -DELETE FROM AD_ELEMENT_TRL WHERE AD_Element_ID >= 1000000 AND AD_Element_ID IN (SELECT AD_Element_ID FROM AD_ELEMENT e WHERE NOT EXISTS (SELECT 1 FROM AD_COLUMN c WHERE UPPER(e.ColumnName)=UPPER(c.ColumnName)) AND NOT EXISTS (SELECT 1 FROM AD_PROCESS_PARA p WHERE UPPER(e.ColumnName)=UPPER(p.ColumnName)) AND NOT EXISTS (SELECT 1 FROM AD_INFOCOLUMN i WHERE UPPER(e.ColumnName)=UPPER(i.ColumnName))) -; - -DELETE FROM AD_ELEMENT WHERE AD_Element_ID >= 1000000 AND NOT EXISTS (SELECT 1 FROM AD_COLUMN c WHERE UPPER(AD_ELEMENT.ColumnName)=UPPER(c.ColumnName)) AND NOT EXISTS (SELECT 1 FROM AD_PROCESS_PARA p WHERE UPPER(AD_ELEMENT.ColumnName)=UPPER(p.ColumnName)) AND NOT EXISTS (SELECT 1 FROM AD_INFOCOLUMN i WHERE UPPER(AD_ELEMENT.ColumnName)=UPPER(i.ColumnName)) -; - UPDATE AD_COLUMN SET ColumnName=e.ColumnName,Name=e.Name,Description=e.Description,Help=e.Help,Placeholder=e.Placeholder, Updated = statement_timestamp() FROM AD_ELEMENT e WHERE AD_COLUMN.AD_Element_ID=e.AD_Element_ID AND EXISTS (SELECT 1 FROM AD_ELEMENT e WHERE AD_COLUMN.AD_Element_ID=e.AD_Element_ID AND (AD_COLUMN.ColumnName <> e.ColumnName OR AD_COLUMN.Name <> e.Name OR COALESCE(AD_COLUMN.Description,' ') <> COALESCE(e.Description,' ') OR COALESCE(AD_COLUMN.Help,' ') <> COALESCE(e.Help,' ') OR COALESCE(AD_COLUMN.Placeholder,' ') <> COALESCE(e.Placeholder,' '))) ; diff --git a/org.adempiere.base.process/src/org/compiere/process/SynchronizeTerminology.java b/org.adempiere.base.process/src/org/compiere/process/SynchronizeTerminology.java index f1de81178b..2a63ae81e0 100644 --- a/org.adempiere.base.process/src/org/compiere/process/SynchronizeTerminology.java +++ b/org.adempiere.base.process/src/org/compiere/process/SynchronizeTerminology.java @@ -131,31 +131,6 @@ public class SynchronizeTerminology extends SvrProcess if (log.isLoggable(Level.INFO)) log.info(" rows updated: "+no); trx.commit(true); - log.info("Deleting unused Elements"); - sql="DELETE AD_ELEMENT_TRL" - +" WHERE AD_Element_ID >= 1000000 AND AD_Element_ID IN" - +" (SELECT AD_Element_ID FROM AD_ELEMENT e " - +" WHERE NOT EXISTS" - +" (SELECT 1 FROM AD_COLUMN c WHERE UPPER(e.ColumnName)=UPPER(c.ColumnName))" - +" AND NOT EXISTS" - +" (SELECT 1 FROM AD_PROCESS_PARA p WHERE UPPER(e.ColumnName)=UPPER(p.ColumnName))" - +" AND NOT EXISTS" - +" (SELECT 1 FROM AD_INFOCOLUMN i WHERE UPPER(e.ColumnName)=UPPER(i.ColumnName)))"; - no = DB.executeUpdate(sql, false, get_TrxName()); - if (log.isLoggable(Level.INFO)) log.info(" rows deleted: "+no); - trx.commit(true); - - sql="DELETE AD_ELEMENT e" - +" WHERE AD_Element_ID >= 1000000 AND NOT EXISTS" - +" (SELECT 1 FROM AD_COLUMN c WHERE UPPER(e.ColumnName)=UPPER(c.ColumnName))" - +" AND NOT EXISTS" - +" (SELECT 1 FROM AD_PROCESS_PARA p WHERE UPPER(e.ColumnName)=UPPER(p.ColumnName))" - +" AND NOT EXISTS" - +" (SELECT 1 FROM AD_INFOCOLUMN i WHERE UPPER(e.ColumnName)=UPPER(i.ColumnName))"; - no = DB.executeUpdate(sql, false, get_TrxName()); - if (log.isLoggable(Level.INFO)) log.info(" rows deleted: "+no); - trx.commit(true); - // Columns log.info("Synchronize Column"); sql=" UPDATE AD_COLUMN c" From d28c1e682dc740404e4899e715753d2c435c45d1 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 10 Apr 2019 17:57:08 +0200 Subject: [PATCH 7/7] Integrate contribution from TrekGlobal - developed by Heng Sin Low and Elaine Tan 1007781 Fix barcode text bug 1009003 add QR Code as Barcode Type for Print Formats 1006829 Add "Print Barcode Text" flag to print format item. Fix wrong scaling for barcode image. Fix barcode print format item doesn't respect max height. IDEMPIERE-3948 Implement QRCode support in report engine IDEMPIERE-1854 Barcode issue: Code Missing from barcodes in Code 128 B IDEMPIERE-1838 Adding UPC-A barcode support in print format and adding setting fonts from print format item --- .../oracle/201611301200_Ticket_1006829.sql | 170 +++++++++++++ .../oracle/201705231845_Ticket_1007781.sql | 14 ++ .../oracle/201805221235_Ticket_1009003.sql | 10 + .../201611301200_Ticket_1006829.sql | 167 +++++++++++++ .../201705231845_Ticket_1007781.sql | 11 + .../201805221235_Ticket_1009003.sql | 7 + org.adempiere.base/.classpath | 3 +- org.adempiere.base/META-INF/MANIFEST.MF | 8 +- org.adempiere.base/build.properties | 1 + org.adempiere.base/pom.xml | 5 + .../compiere/model/I_AD_PrintFormatItem.java | 13 + .../compiere/model/X_AD_PrintFormatItem.java | 34 ++- .../compiere/print/layout/BarcodeElement.java | 89 +++++-- .../krysalis/barcode4j/impl/qr/QRCode.java | 97 ++++++++ .../barcode4j/impl/qr/QRCodeBean.java | 229 ++++++++++++++++++ .../barcode4j/impl/qr/QRConstants.java | 49 ++++ .../barcode4j/impl/qr/QRHighLevelEncoder.java | 64 +++++ .../barcode4j/impl/qr/QRLogicImpl.java | 116 +++++++++ .../org/krysalis/barcode4j/tools/ECIUtil.java | 82 +++++++ 19 files changed, 1142 insertions(+), 27 deletions(-) create mode 100644 migration/i6.2/oracle/201611301200_Ticket_1006829.sql create mode 100644 migration/i6.2/oracle/201705231845_Ticket_1007781.sql create mode 100644 migration/i6.2/oracle/201805221235_Ticket_1009003.sql create mode 100644 migration/i6.2/postgresql/201611301200_Ticket_1006829.sql create mode 100644 migration/i6.2/postgresql/201705231845_Ticket_1007781.sql create mode 100644 migration/i6.2/postgresql/201805221235_Ticket_1009003.sql create mode 100644 org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRCode.java create mode 100644 org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRCodeBean.java create mode 100644 org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRConstants.java create mode 100644 org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRHighLevelEncoder.java create mode 100644 org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRLogicImpl.java create mode 100644 org.adempiere.base/src/org/krysalis/barcode4j/tools/ECIUtil.java diff --git a/migration/i6.2/oracle/201611301200_Ticket_1006829.sql b/migration/i6.2/oracle/201611301200_Ticket_1006829.sql new file mode 100644 index 0000000000..578680b3b2 --- /dev/null +++ b/migration/i6.2/oracle/201611301200_Ticket_1006829.sql @@ -0,0 +1,170 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- Nov 29, 2016 2:52:01 PM GMT+08:00 +-- 1006829 - Create product label +INSERT INTO AD_Element (AD_Element_ID,ColumnName,Updated,Name,Description,PrintName,AD_Element_UU,IsActive,Created,AD_Org_ID,CreatedBy,UpdatedBy,AD_Client_ID,EntityType) VALUES (203058,'IsPrintBarcodeText',TO_DATE('2016-11-29 14:51:59','YYYY-MM-DD HH24:MI:SS'),'Print Barcode Text','Print barcode text at the bottom of barcode','Print Barcode Text','ef298ad1-4d63-44eb-bf6f-c38f442bda1f','Y',TO_DATE('2016-11-29 14:51:59','YYYY-MM-DD HH24:MI:SS'),0,100,100,0,'U') +; + +-- Nov 29, 2016 2:53:24 PM GMT+08:00 +UPDATE AD_Element SET EntityType='D',Updated=TO_DATE('2016-11-29 14:53:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=203058 +; + +-- Nov 29, 2016 2:53:57 PM GMT+08:00 +INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,DefaultValue,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,AD_Org_ID,Created,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES (212946,0,'N',0,'Y','N','N',0,'N',1,'N','N','N','Y','bbe56dbf-97c7-4705-96be-5fc434f1c6c1',TO_DATE('2016-11-29 14:53:56','YYYY-MM-DD HH24:MI:SS'),'Y','IsPrintBarcodeText','Print barcode text at the bottom of barcode','Y','Print Barcode Text','Y','Y',100,100,'N','N',0,0,TO_DATE('2016-11-29 14:53:56','YYYY-MM-DD HH24:MI:SS'),'D','N','N','N',203058,20,489) +; + +-- Nov 29, 2016 2:54:06 PM GMT+08:00 +ALTER TABLE AD_PrintFormatItem ADD IsPrintBarcodeText CHAR(1) DEFAULT 'Y' CHECK (IsPrintBarcodeText IN ('Y','N')) NOT NULL +; + +-- Nov 29, 2016 2:57:37 PM GMT+08:00 +INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,DisplayLogic,AD_Org_ID,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID) VALUES (0,204351,'N',0,'N','N',560,'Y','N','@PrintFormatType@=F & @BarcodeType@!''''',0,TO_DATE('2016-11-29 14:57:36','YYYY-MM-DD HH24:MI:SS'),'Print barcode text at the bottom of barcode','Print Barcode Text','0bc427e5-7aae-498a-8a27-d6fe946cdaf5','Y','N',100,100,'Y','Y',560,1,'N',0,TO_DATE('2016-11-29 14:57:36','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',212946,'D',426) +; + +-- Nov 29, 2016 2:58:35 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=220, IsDisplayed='Y', XPosition=2,Updated=TO_DATE('2016-11-29 14:58:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204351 +; + +-- Nov 29, 2016 2:58:36 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=230,Updated=TO_DATE('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5677 +; + +-- Nov 29, 2016 2:58:36 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=240,Updated=TO_DATE('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5761 +; + +-- Nov 29, 2016 2:58:36 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=250,Updated=TO_DATE('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5690 +; + +-- Nov 29, 2016 2:58:36 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=260,Updated=TO_DATE('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5681 +; + +-- Nov 29, 2016 2:58:37 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=270,Updated=TO_DATE('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5669 +; + +-- Nov 29, 2016 2:58:37 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=280,Updated=TO_DATE('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5804 +; + +-- Nov 29, 2016 2:58:37 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=290,Updated=TO_DATE('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5763 +; + +-- Nov 29, 2016 2:58:37 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=300,Updated=TO_DATE('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5695 +; + +-- Nov 29, 2016 2:58:38 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=310,Updated=TO_DATE('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5691 +; + +-- Nov 29, 2016 2:58:38 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=320,Updated=TO_DATE('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5685 +; + +-- Nov 29, 2016 2:58:38 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=330,Updated=TO_DATE('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5673 +; + +-- Nov 29, 2016 2:58:38 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=340,Updated=TO_DATE('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5678 +; + +-- Nov 29, 2016 2:58:38 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=350,Updated=TO_DATE('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5805 +; + +-- Nov 29, 2016 2:58:39 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=360,Updated=TO_DATE('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11023 +; + +-- Nov 29, 2016 2:58:39 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=370,Updated=TO_DATE('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5689 +; + +-- Nov 29, 2016 2:58:39 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=380,Updated=TO_DATE('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5688 +; + +-- Nov 29, 2016 2:58:39 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=390,Updated=TO_DATE('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11021 +; + +-- Nov 29, 2016 2:58:40 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=400,Updated=TO_DATE('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5682 +; + +-- Nov 29, 2016 2:58:40 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=410,Updated=TO_DATE('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5686 +; + +-- Nov 29, 2016 2:58:40 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=420,Updated=TO_DATE('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11020 +; + +-- Nov 29, 2016 2:58:40 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=430,Updated=TO_DATE('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5693 +; + +-- Nov 29, 2016 2:58:40 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=440,Updated=TO_DATE('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5674 +; + +-- Nov 29, 2016 2:58:41 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=450,Updated=TO_DATE('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200001 +; + +-- Nov 29, 2016 2:58:41 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=460,Updated=TO_DATE('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5694 +; + +-- Nov 29, 2016 2:58:41 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=470,Updated=TO_DATE('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5676 +; + +-- Nov 29, 2016 2:58:41 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=480,Updated=TO_DATE('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5680 +; + +-- Nov 29, 2016 2:58:42 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=490,Updated=TO_DATE('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8294 +; + +-- Nov 29, 2016 2:58:42 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=500,Updated=TO_DATE('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5757 +; + +-- Nov 29, 2016 2:58:42 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=510,Updated=TO_DATE('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8293 +; + +-- Nov 29, 2016 2:58:42 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=520,Updated=TO_DATE('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8295 +; + +-- Nov 29, 2016 2:58:43 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=530,Updated=TO_DATE('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8292 +; + +-- Nov 29, 2016 2:58:43 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=540,Updated=TO_DATE('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5758 +; + +-- Nov 29, 2016 2:58:43 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=550,Updated=TO_DATE('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8604 +; + +-- Nov 29, 2016 2:58:43 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=560,Updated=TO_DATE('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8605 +; + +UPDATE AD_PrintFormatItem SET IsPrintBarcodeText='N' WHERE BarcodeType='USP' +; + +SELECT register_migration_script('201611301200_Ticket_1006829.sql') FROM dual +; + diff --git a/migration/i6.2/oracle/201705231845_Ticket_1007781.sql b/migration/i6.2/oracle/201705231845_Ticket_1007781.sql new file mode 100644 index 0000000000..80258f43a7 --- /dev/null +++ b/migration/i6.2/oracle/201705231845_Ticket_1007781.sql @@ -0,0 +1,14 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- May 23, 2017 6:42:29 PM SGT +-- 1007781 Fix barcode text bug +INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Ref_List_UU,Name,Value,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created,Updated,EntityType,AD_Reference_ID) VALUES (200374,'af593ade-94ff-47bf-9b4e-a60c278d3541','Code 39 with Checksum','39C','Y',100,100,0,0,TO_DATE('2017-05-23 18:42:28','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2017-05-23 18:42:28','YYYY-MM-DD HH24:MI:SS'),'D',377) +; + +-- May 23, 2017 6:42:30 PM SGT +INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Ref_List_UU,Name,Value,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created,Updated,EntityType,AD_Reference_ID) VALUES (200375,'918c6018-41f7-40ba-965b-65512ec99808','Code 39 w/o Checksum','39c','Y',100,100,0,0,TO_DATE('2017-05-23 18:42:29','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2017-05-23 18:42:29','YYYY-MM-DD HH24:MI:SS'),'D',377) +; + +SELECT register_migration_script('201705231845_Ticket_1007781.sql') FROM dual +; diff --git a/migration/i6.2/oracle/201805221235_Ticket_1009003.sql b/migration/i6.2/oracle/201805221235_Ticket_1009003.sql new file mode 100644 index 0000000000..acff3c9c0d --- /dev/null +++ b/migration/i6.2/oracle/201805221235_Ticket_1009003.sql @@ -0,0 +1,10 @@ +SET SQLBLANKLINES ON +SET DEFINE OFF + +-- May 17, 2018 12:24:17 PM SGT +-- 1009003 add QR Code as Barcode Type for Print Formats +INSERT INTO AD_Ref_List (AD_Ref_List_ID,Created,Updated,EntityType,AD_Client_ID,AD_Org_ID,CreatedBy,UpdatedBy,Value,Name,IsActive,AD_Ref_List_UU,AD_Reference_ID) VALUES (200396,TO_DATE('2018-05-17 12:24:15','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2018-05-17 12:24:15','YYYY-MM-DD HH24:MI:SS'),'D',0,0,100,100,'QRC','QR Code','Y','702f344c-557a-4a34-aaae-578cb1b2d137',377) +; + +SELECT register_migration_script('201805221235_Ticket_1009003.sql') FROM dual +; \ No newline at end of file diff --git a/migration/i6.2/postgresql/201611301200_Ticket_1006829.sql b/migration/i6.2/postgresql/201611301200_Ticket_1006829.sql new file mode 100644 index 0000000000..b01cf16a2d --- /dev/null +++ b/migration/i6.2/postgresql/201611301200_Ticket_1006829.sql @@ -0,0 +1,167 @@ +-- Nov 29, 2016 2:52:01 PM GMT+08:00 +-- 1006829 - Create product label +INSERT INTO AD_Element (AD_Element_ID,ColumnName,Updated,Name,Description,PrintName,AD_Element_UU,IsActive,Created,AD_Org_ID,CreatedBy,UpdatedBy,AD_Client_ID,EntityType) VALUES (203058,'IsPrintBarcodeText',TO_TIMESTAMP('2016-11-29 14:51:59','YYYY-MM-DD HH24:MI:SS'),'Print Barcode Text','Print barcode text at the bottom of barcode','Print Barcode Text','ef298ad1-4d63-44eb-bf6f-c38f442bda1f','Y',TO_TIMESTAMP('2016-11-29 14:51:59','YYYY-MM-DD HH24:MI:SS'),0,100,100,0,'U') +; + +-- Nov 29, 2016 2:53:24 PM GMT+08:00 +UPDATE AD_Element SET EntityType='D',Updated=TO_TIMESTAMP('2016-11-29 14:53:24','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=203058 +; + +-- Nov 29, 2016 2:53:57 PM GMT+08:00 +INSERT INTO AD_Column (AD_Column_ID,SeqNoSelection,IsSyncDatabase,Version,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,IsKey,IsAutocomplete,IsAllowLogging,AD_Column_UU,Updated,IsUpdateable,ColumnName,Description,DefaultValue,Name,IsAllowCopy,IsActive,CreatedBy,UpdatedBy,IsToolbarButton,IsAlwaysUpdateable,AD_Client_ID,AD_Org_ID,Created,EntityType,IsEncrypted,IsSecure,FKConstraintType,AD_Element_ID,AD_Reference_ID,AD_Table_ID) VALUES (212946,0,'N',0,'Y','N','N',0,'N',1,'N','N','N','Y','bbe56dbf-97c7-4705-96be-5fc434f1c6c1',TO_TIMESTAMP('2016-11-29 14:53:56','YYYY-MM-DD HH24:MI:SS'),'Y','IsPrintBarcodeText','Print barcode text at the bottom of barcode','Y','Print Barcode Text','Y','Y',100,100,'N','N',0,0,TO_TIMESTAMP('2016-11-29 14:53:56','YYYY-MM-DD HH24:MI:SS'),'D','N','N','N',203058,20,489) +; + +-- Nov 29, 2016 2:54:06 PM GMT+08:00 +ALTER TABLE AD_PrintFormatItem ADD COLUMN IsPrintBarcodeText CHAR(1) DEFAULT 'Y' CHECK (IsPrintBarcodeText IN ('Y','N')) NOT NULL +; + +-- Nov 29, 2016 2:57:37 PM GMT+08:00 +INSERT INTO AD_Field (SortNo,AD_Field_ID,IsEncrypted,DisplayLength,IsSameLine,IsHeading,SeqNo,IsCentrallyMaintained,IsReadOnly,DisplayLogic,AD_Org_ID,Updated,Description,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,CreatedBy,UpdatedBy,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry,AD_Client_ID,Created,ColumnSpan,NumLines,IsAdvancedField,IsDefaultFocus,AD_Column_ID,EntityType,AD_Tab_ID) VALUES (0,204351,'N',0,'N','N',560,'Y','N','@PrintFormatType@=F & @BarcodeType@!''''',0,TO_TIMESTAMP('2016-11-29 14:57:36','YYYY-MM-DD HH24:MI:SS'),'Print barcode text at the bottom of barcode','Print Barcode Text','0bc427e5-7aae-498a-8a27-d6fe946cdaf5','Y','N',100,100,'Y','Y',560,1,'N',0,TO_TIMESTAMP('2016-11-29 14:57:36','YYYY-MM-DD HH24:MI:SS'),2,1,'N','N',212946,'D',426) +; + +-- Nov 29, 2016 2:58:35 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=220, IsDisplayed='Y', XPosition=2,Updated=TO_TIMESTAMP('2016-11-29 14:58:35','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=204351 +; + +-- Nov 29, 2016 2:58:36 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=230,Updated=TO_TIMESTAMP('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5677 +; + +-- Nov 29, 2016 2:58:36 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=240,Updated=TO_TIMESTAMP('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5761 +; + +-- Nov 29, 2016 2:58:36 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=250,Updated=TO_TIMESTAMP('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5690 +; + +-- Nov 29, 2016 2:58:36 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=260,Updated=TO_TIMESTAMP('2016-11-29 14:58:36','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5681 +; + +-- Nov 29, 2016 2:58:37 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=270,Updated=TO_TIMESTAMP('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5669 +; + +-- Nov 29, 2016 2:58:37 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=280,Updated=TO_TIMESTAMP('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5804 +; + +-- Nov 29, 2016 2:58:37 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=290,Updated=TO_TIMESTAMP('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5763 +; + +-- Nov 29, 2016 2:58:37 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=300,Updated=TO_TIMESTAMP('2016-11-29 14:58:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5695 +; + +-- Nov 29, 2016 2:58:38 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=310,Updated=TO_TIMESTAMP('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5691 +; + +-- Nov 29, 2016 2:58:38 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=320,Updated=TO_TIMESTAMP('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5685 +; + +-- Nov 29, 2016 2:58:38 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=330,Updated=TO_TIMESTAMP('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5673 +; + +-- Nov 29, 2016 2:58:38 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=340,Updated=TO_TIMESTAMP('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5678 +; + +-- Nov 29, 2016 2:58:38 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=350,Updated=TO_TIMESTAMP('2016-11-29 14:58:38','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5805 +; + +-- Nov 29, 2016 2:58:39 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=360,Updated=TO_TIMESTAMP('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11023 +; + +-- Nov 29, 2016 2:58:39 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=370,Updated=TO_TIMESTAMP('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5689 +; + +-- Nov 29, 2016 2:58:39 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=380,Updated=TO_TIMESTAMP('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5688 +; + +-- Nov 29, 2016 2:58:39 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=390,Updated=TO_TIMESTAMP('2016-11-29 14:58:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11021 +; + +-- Nov 29, 2016 2:58:40 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=400,Updated=TO_TIMESTAMP('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5682 +; + +-- Nov 29, 2016 2:58:40 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=410,Updated=TO_TIMESTAMP('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5686 +; + +-- Nov 29, 2016 2:58:40 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=420,Updated=TO_TIMESTAMP('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=11020 +; + +-- Nov 29, 2016 2:58:40 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=430,Updated=TO_TIMESTAMP('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5693 +; + +-- Nov 29, 2016 2:58:40 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=440,Updated=TO_TIMESTAMP('2016-11-29 14:58:40','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5674 +; + +-- Nov 29, 2016 2:58:41 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=450,Updated=TO_TIMESTAMP('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200001 +; + +-- Nov 29, 2016 2:58:41 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=460,Updated=TO_TIMESTAMP('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5694 +; + +-- Nov 29, 2016 2:58:41 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=470,Updated=TO_TIMESTAMP('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5676 +; + +-- Nov 29, 2016 2:58:41 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=480,Updated=TO_TIMESTAMP('2016-11-29 14:58:41','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5680 +; + +-- Nov 29, 2016 2:58:42 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=490,Updated=TO_TIMESTAMP('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8294 +; + +-- Nov 29, 2016 2:58:42 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=500,Updated=TO_TIMESTAMP('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5757 +; + +-- Nov 29, 2016 2:58:42 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=510,Updated=TO_TIMESTAMP('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8293 +; + +-- Nov 29, 2016 2:58:42 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=520,Updated=TO_TIMESTAMP('2016-11-29 14:58:42','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8295 +; + +-- Nov 29, 2016 2:58:43 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=530,Updated=TO_TIMESTAMP('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8292 +; + +-- Nov 29, 2016 2:58:43 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=540,Updated=TO_TIMESTAMP('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=5758 +; + +-- Nov 29, 2016 2:58:43 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=550,Updated=TO_TIMESTAMP('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8604 +; + +-- Nov 29, 2016 2:58:43 PM GMT+08:00 +UPDATE AD_Field SET SeqNo=560,Updated=TO_TIMESTAMP('2016-11-29 14:58:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=8605 +; + +UPDATE AD_PrintFormatItem SET IsPrintBarcodeText='N' WHERE BarcodeType='USP' +; + +SELECT register_migration_script('201611301200_Ticket_1006829.sql') FROM dual +; + diff --git a/migration/i6.2/postgresql/201705231845_Ticket_1007781.sql b/migration/i6.2/postgresql/201705231845_Ticket_1007781.sql new file mode 100644 index 0000000000..f6b545a20d --- /dev/null +++ b/migration/i6.2/postgresql/201705231845_Ticket_1007781.sql @@ -0,0 +1,11 @@ +-- May 23, 2017 6:42:29 PM SGT +-- 1007781 Fix barcode text bug +INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Ref_List_UU,Name,Value,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created,Updated,EntityType,AD_Reference_ID) VALUES (200374,'af593ade-94ff-47bf-9b4e-a60c278d3541','Code 39 with Checksum','39C','Y',100,100,0,0,TO_TIMESTAMP('2017-05-23 18:42:28','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2017-05-23 18:42:28','YYYY-MM-DD HH24:MI:SS'),'D',377) +; + +-- May 23, 2017 6:42:30 PM SGT +INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Ref_List_UU,Name,Value,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,AD_Org_ID,Created,Updated,EntityType,AD_Reference_ID) VALUES (200375,'918c6018-41f7-40ba-965b-65512ec99808','Code 39 w/o Checksum','39c','Y',100,100,0,0,TO_TIMESTAMP('2017-05-23 18:42:29','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2017-05-23 18:42:29','YYYY-MM-DD HH24:MI:SS'),'D',377) +; + +SELECT register_migration_script('201705231845_Ticket_1007781.sql') FROM dual +; diff --git a/migration/i6.2/postgresql/201805221235_Ticket_1009003.sql b/migration/i6.2/postgresql/201805221235_Ticket_1009003.sql new file mode 100644 index 0000000000..a0a1285691 --- /dev/null +++ b/migration/i6.2/postgresql/201805221235_Ticket_1009003.sql @@ -0,0 +1,7 @@ +-- May 17, 2018 12:24:17 PM SGT +-- 1009003 add QR Code as Barcode Type for Print Formats +INSERT INTO AD_Ref_List (AD_Ref_List_ID,Created,Updated,EntityType,AD_Client_ID,AD_Org_ID,CreatedBy,UpdatedBy,Value,Name,IsActive,AD_Ref_List_UU,AD_Reference_ID) VALUES (200396,TO_TIMESTAMP('2018-05-17 12:24:15','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2018-05-17 12:24:15','YYYY-MM-DD HH24:MI:SS'),'D',0,0,100,100,'QRC','QR Code','Y','702f344c-557a-4a34-aaae-578cb1b2d137',377) +; + +SELECT register_migration_script('201805221235_Ticket_1009003.sql') FROM dual +; \ No newline at end of file diff --git a/org.adempiere.base/.classpath b/org.adempiere.base/.classpath index 6810efafe5..f962245014 100644 --- a/org.adempiere.base/.classpath +++ b/org.adempiere.base/.classpath @@ -6,12 +6,13 @@ - + + diff --git a/org.adempiere.base/META-INF/MANIFEST.MF b/org.adempiere.base/META-INF/MANIFEST.MF index 54b0acb668..69242b3e9d 100644 --- a/org.adempiere.base/META-INF/MANIFEST.MF +++ b/org.adempiere.base/META-INF/MANIFEST.MF @@ -9,7 +9,8 @@ Bundle-ClassPath: ., lib/cron4j.jar, lib/jnlp.jar, lib/jython-engine.jar, - lib/jython.jar + lib/jython.jar, + lib/avalon-framework-api.jar Export-Package: bsh, bsh.classpath, bsh.collection, @@ -58,7 +59,10 @@ Export-Package: bsh, org.idempiere.model Comment: Bundle-RequiredExecutionEnvironment: JavaSE-11 Require-Capability: osgi.ee;filter:="(&(osgi.ee=JavaSE)(version>=1.11))" -Import-Package: com.sun.mail.smtp;version="1.5", +Import-Package: com.google.zxing, + com.google.zxing.qrcode.decoder, + com.google.zxing.qrcode.encoder, + com.sun.mail.smtp;version="1.5", javax.jms;version="1.1.0", javax.mail;version="1.5", javax.mail.internet;version="1.5", diff --git a/org.adempiere.base/build.properties b/org.adempiere.base/build.properties index d9c0e50348..0012e60786 100644 --- a/org.adempiere.base/build.properties +++ b/org.adempiere.base/build.properties @@ -20,6 +20,7 @@ bin.includes = plugin.xml,\ schema/,\ .,\ META-INF/,\ + lib/avalon-framework-api.jar,\ lib/bsh.jar,\ lib/commons-validator.jar,\ lib/cron4j.jar,\ diff --git a/org.adempiere.base/pom.xml b/org.adempiere.base/pom.xml index 5b6cf50b4d..96ba477762 100644 --- a/org.adempiere.base/pom.xml +++ b/org.adempiere.base/pom.xml @@ -53,6 +53,11 @@ jnlp 1.5.0 + + org.apache.avalon.framework + avalon-framework-api + 4.3.1 + lib true diff --git a/org.adempiere.base/src/org/compiere/model/I_AD_PrintFormatItem.java b/org.adempiere.base/src/org/compiere/model/I_AD_PrintFormatItem.java index 4c388377f8..0ac2d907f8 100644 --- a/org.adempiere.base/src/org/compiere/model/I_AD_PrintFormatItem.java +++ b/org.adempiere.base/src/org/compiere/model/I_AD_PrintFormatItem.java @@ -502,6 +502,19 @@ public interface I_AD_PrintFormatItem */ public boolean isPageBreak(); + /** Column name IsPrintBarcodeText */ + public static final String COLUMNNAME_IsPrintBarcodeText = "IsPrintBarcodeText"; + + /** Set Print Barcode Text. + * Print barcode text at the bottom of barcode + */ + public void setIsPrintBarcodeText (boolean IsPrintBarcodeText); + + /** Get Print Barcode Text. + * Print barcode text at the bottom of barcode + */ + public boolean isPrintBarcodeText(); + /** Column name IsPrinted */ public static final String COLUMNNAME_IsPrinted = "IsPrinted"; diff --git a/org.adempiere.base/src/org/compiere/model/X_AD_PrintFormatItem.java b/org.adempiere.base/src/org/compiere/model/X_AD_PrintFormatItem.java index 2eb160ce7c..f36ce02186 100644 --- a/org.adempiere.base/src/org/compiere/model/X_AD_PrintFormatItem.java +++ b/org.adempiere.base/src/org/compiere/model/X_AD_PrintFormatItem.java @@ -30,7 +30,7 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_ /** * */ - private static final long serialVersionUID = 20190106L; + private static final long serialVersionUID = 20190403L; /** Standard Constructor */ public X_AD_PrintFormatItem (Properties ctx, int AD_PrintFormatItem_ID, String trxName) @@ -64,6 +64,8 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_ setIsNextPage (false); setIsOrderBy (false); setIsPageBreak (false); + setIsPrintBarcodeText (true); +// Y setIsPrinted (true); // Y setIsRelativePosition (true); @@ -399,6 +401,12 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_ public static final String BARCODETYPE_EAN13 = "E13"; /** UPC-A = UPA */ public static final String BARCODETYPE_UPC_A = "UPA"; + /** Code 39 with Checksum = 39C */ + public static final String BARCODETYPE_Code39WithChecksum = "39C"; + /** Code 39 w/o Checksum = 39c */ + public static final String BARCODETYPE_Code39WOChecksum = "39c"; + /** QR Code = QRC */ + public static final String BARCODETYPE_QRCode = "QRC"; /** Set Barcode Type. @param BarcodeType Type of barcode @@ -909,6 +917,30 @@ public class X_AD_PrintFormatItem extends PO implements I_AD_PrintFormatItem, I_ return false; } + /** Set Print Barcode Text. + @param IsPrintBarcodeText + Print barcode text at the bottom of barcode + */ + public void setIsPrintBarcodeText (boolean IsPrintBarcodeText) + { + set_Value (COLUMNNAME_IsPrintBarcodeText, Boolean.valueOf(IsPrintBarcodeText)); + } + + /** Get Print Barcode Text. + @return Print barcode text at the bottom of barcode + */ + public boolean isPrintBarcodeText () + { + Object oo = get_Value(COLUMNNAME_IsPrintBarcodeText); + if (oo != null) + { + if (oo instanceof Boolean) + return ((Boolean)oo).booleanValue(); + return "Y".equals(oo); + } + return false; + } + /** Set Printed. @param IsPrinted Indicates if this document / line is printed diff --git a/org.adempiere.base/src/org/compiere/print/layout/BarcodeElement.java b/org.adempiere.base/src/org/compiere/print/layout/BarcodeElement.java index 634b54a4c3..a782f13f63 100644 --- a/org.adempiere.base/src/org/compiere/print/layout/BarcodeElement.java +++ b/org.adempiere.base/src/org/compiere/print/layout/BarcodeElement.java @@ -22,19 +22,22 @@ import java.awt.geom.Point2D; import java.awt.image.BufferedImage; import java.util.Properties; -import net.sourceforge.barbecue.Barcode; -import net.sourceforge.barbecue.BarcodeFactory; -import net.sourceforge.barbecue.BarcodeImageHandler; -import net.sourceforge.barbecue.linear.ean.UCCEAN128Barcode; - import org.compiere.print.MPrintFont; import org.compiere.print.MPrintFormatItem; import org.krysalis.barcode4j.BarcodeDimension; import org.krysalis.barcode4j.ChecksumMode; import org.krysalis.barcode4j.HumanReadablePlacement; +import org.krysalis.barcode4j.impl.AbstractBarcodeBean; +import org.krysalis.barcode4j.impl.code39.Code39Bean; +import org.krysalis.barcode4j.impl.qr.QRCodeBean; import org.krysalis.barcode4j.impl.upcean.UPCABean; import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider; +import net.sourceforge.barbecue.Barcode; +import net.sourceforge.barbecue.BarcodeFactory; +import net.sourceforge.barbecue.BarcodeImageHandler; +import net.sourceforge.barbecue.linear.ean.UCCEAN128Barcode; + /** * Barcode Print Element * @@ -49,7 +52,12 @@ public class BarcodeElement extends PrintElement /** * */ - private static final long serialVersionUID = -935853466496345172L; + private static final long serialVersionUID = -6825913765885213717L; + + /** + * + */ + /** * Barcode Element Constructor @@ -65,7 +73,7 @@ public class BarcodeElement extends PrintElement m_valid = false; createBarcode(code, item); - if (m_barcode == null && m_upc == null) + if (m_barcode == null && m_barcodeBean == null) m_valid = false; m_allowOverflow = item.isHeightOneLine(); // teo_sarca, [ 1673590 ] } // BarcodeElement @@ -78,7 +86,7 @@ public class BarcodeElement extends PrintElement private boolean m_allowOverflow = true; private float m_scaleFactor = 1; - private UPCABean m_upc = null; + private AbstractBarcodeBean m_barcodeBean = null; private String m_code; /** @@ -139,17 +147,48 @@ public class BarcodeElement extends PrintElement m_barcode = BarcodeFactory.createUCC128(UCCEAN128Barcode.EAN128_AI, code); else if (type.equals(MPrintFormatItem.BARCODETYPE_EAN13)) //@Trifon m_barcode = BarcodeFactory.createEAN13(code); //@Trifon - else if (type.equals(MPrintFormatItem.BARCODETYPE_UPC_A )) { - m_upc = new UPCABean(); - m_upc.setChecksumMode(ChecksumMode.CP_AUTO); - m_upc.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + else if (type.equals(MPrintFormatItem.BARCODETYPE_UPC_A)) { + m_barcodeBean = new UPCABean(); + ((UPCABean)m_barcodeBean).setChecksumMode(ChecksumMode.CP_AUTO); + if (item.isPrintBarcodeText()) + m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + else + m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_NONE); m_code = code; } + else if (type.equals(MPrintFormatItem.BARCODETYPE_Code39WithChecksum)) + { + m_barcodeBean = new Code39Bean(); + ((Code39Bean)m_barcodeBean).setChecksumMode(ChecksumMode.CP_AUTO); + if (item.isPrintBarcodeText()) + m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + else + m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_NONE); + m_code = code; + } + else if (type.equals(MPrintFormatItem.BARCODETYPE_Code39WOChecksum)) + { + m_barcodeBean = new Code39Bean(); + ((Code39Bean)m_barcodeBean).setChecksumMode(ChecksumMode.CP_IGNORE); + if (item.isPrintBarcodeText()) + m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + else + m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_NONE); + m_code = code; + } // http://www.usps.com/cpim/ftp/pubs/pub97/97apxs_006.html#_Toc481397331 else if (type.equals(MPrintFormatItem.BARCODETYPE_USPostalServiceUCCEAN128)) { m_barcode = BarcodeFactory.createUSPS(code); - m_barcode.setDrawingText(false); + } + else if (type.equals(MPrintFormatItem.BARCODETYPE_QRCode)) + { + m_barcodeBean = new QRCodeBean(); + if (item.isPrintBarcodeText()) + m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_BOTTOM); + else + m_barcodeBean.setMsgPosition(HumanReadablePlacement.HRP_NONE); + m_code = code; } else log.warning("Invalid Type" + type); @@ -168,6 +207,7 @@ public class BarcodeElement extends PrintElement if (mFont != null) m_barcode.setFont(mFont.getFont()); } + m_barcode.setDrawingText(item.isPrintBarcodeText()); } } // createBarcode @@ -189,7 +229,7 @@ public class BarcodeElement extends PrintElement { p_width = 0; p_height = 0; - if (m_barcode == null && m_upc == null) + if (m_barcode == null && m_barcodeBean == null) return true; if (m_barcode != null) @@ -205,14 +245,14 @@ public class BarcodeElement extends PrintElement } else { - BarcodeDimension t = m_upc.calcDimensions(m_code); + BarcodeDimension t = m_barcodeBean.calcDimensions(m_code); //convert from mm to point/inch p_width = (float) (t.getWidthPlusQuiet() / 25.4f * 72f); p_height = (float) (t.getHeight() / 25.4f * 72f); - // * 3 for resolution of 216 dpi ( 72 * 3 ) - p_width *= 3f; - p_height *=3f; + // * 6 for resolution of 432 dpi ( 72 * 6 ) + p_width *= 6f; + p_height *= 6f; } if (p_width * p_height == 0) @@ -223,6 +263,8 @@ public class BarcodeElement extends PrintElement m_scaleFactor = p_maxWidth / p_width; if (p_maxHeight != 0 && p_height > p_maxHeight && p_maxHeight/p_height < m_scaleFactor) m_scaleFactor = p_maxHeight / p_height; + else if (p_maxHeight != 0 && (m_scaleFactor * p_height) > p_maxHeight) + m_scaleFactor = p_maxHeight / p_height; p_width = (float) m_scaleFactor * p_width; p_height = (float) m_scaleFactor * p_height; @@ -255,7 +297,7 @@ public class BarcodeElement extends PrintElement public void paint (Graphics2D g2D, int pageNo, Point2D pageStart, Properties ctx, boolean isView) { - if (!m_valid || (m_barcode == null && m_upc == null )) + if (!m_valid || (m_barcode == null && m_barcodeBean == null )) return; // Position @@ -283,9 +325,9 @@ public class BarcodeElement extends PrintElement } else { - //use resolution of 216 dpi (72 * 3) for better output - BitmapCanvasProvider provider = new BitmapCanvasProvider(72*3, BufferedImage.TYPE_INT_ARGB, true, 0); - m_upc.generateBarcode(provider, m_code); + //use resolution of 432 dpi (72 * 6) for better output + BitmapCanvasProvider provider = new BitmapCanvasProvider(72*6, BufferedImage.TYPE_INT_ARGB, true, 0); + m_barcodeBean.generateBarcode(provider, m_code); provider.finish(); image = provider.getBufferedImage(); } @@ -293,7 +335,8 @@ public class BarcodeElement extends PrintElement // scale barcode and paint AffineTransform transform = new AffineTransform(); transform.translate(x,y); - transform.scale(m_scaleFactor, m_scaleFactor); + float scaleFactor = m_scaleFactor * 3f / 4f; + transform.scale(scaleFactor, scaleFactor); g2D.drawImage(image, transform, this); } catch (Exception e) { diff --git a/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRCode.java b/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRCode.java new file mode 100644 index 0000000000..4f72d481d7 --- /dev/null +++ b/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRCode.java @@ -0,0 +1,97 @@ +/* + * Copyright 2012 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id: QRCode.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $ */ + +package org.krysalis.barcode4j.impl.qr; + +import java.awt.Dimension; + +import org.krysalis.barcode4j.impl.ConfigurableBarcodeGenerator; +import org.krysalis.barcode4j.tools.Length; + +import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; + +/** + * This class is an implementation of QR Code. + * + * @version $Id: QRCode.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $ + */ +public class QRCode extends ConfigurableBarcodeGenerator + implements Configurable { + + /** Create a new instance. */ + public QRCode() { + this.bean = new QRCodeBean(); + } + + /** + * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration) + */ + public void configure(Configuration cfg) throws ConfigurationException { + //Module width (MUST ALWAYS BE FIRST BECAUSE QUIET ZONE MAY DEPEND ON IT) + String mws = cfg.getChild("module-width").getValue(null); + if (mws != null) { + Length mw = new Length(mws, "mm"); + getQRBean().setModuleWidth(mw.getValueAsMillimeter()); + } + + super.configure(cfg); + + String encoding = cfg.getChild("encoding").getValue(null); + if (encoding != null) { + getQRBean().setEncoding(encoding); + } + + String ecLevel = cfg.getChild("ec-level").getValue(null); + if (ecLevel != null && ecLevel.length() > 0) { + getQRBean().setErrorCorrectionLevel(ecLevel.charAt(0)); + } + + String size; + size = cfg.getChild("min-symbol-size").getValue(null); + if (size != null) { + getQRBean().setMinSize(parseSymbolSize(size)); + } + size = cfg.getChild("max-symbol-size").getValue(null); + if (size != null) { + getQRBean().setMaxSize(parseSymbolSize(size)); + } + } + + private Dimension parseSymbolSize(String size) { + int idx = size.indexOf('x'); + Dimension dim; + if (idx > 0) { + dim = new Dimension(Integer.parseInt(size.substring(0, idx)), + Integer.parseInt(size.substring(idx + 1))); + } else { + int extent = Integer.parseInt(size); + dim = new Dimension(extent, extent); + } + return dim; + } + + /** + * @return the underlying DataMatrix bean + */ + public QRCodeBean getQRBean() { + return (QRCodeBean)getBean(); + } + +} \ No newline at end of file diff --git a/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRCodeBean.java b/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRCodeBean.java new file mode 100644 index 0000000000..d11e66af7a --- /dev/null +++ b/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRCodeBean.java @@ -0,0 +1,229 @@ +/* + * Copyright 2012 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id: QRCodeBean.java,v 1.3 2012-02-08 12:59:41 jmaerki Exp $ */ + +package org.krysalis.barcode4j.impl.qr; + +import java.awt.Dimension; + +import org.krysalis.barcode4j.BarcodeDimension; +import org.krysalis.barcode4j.TwoDimBarcodeLogicHandler; +import org.krysalis.barcode4j.impl.AbstractBarcodeBean; +import org.krysalis.barcode4j.impl.DefaultTwoDimCanvasLogicHandler; +import org.krysalis.barcode4j.output.Canvas; +import org.krysalis.barcode4j.output.CanvasProvider; +import org.krysalis.barcode4j.tools.ECIUtil; +import org.krysalis.barcode4j.tools.UnitConv; + +import com.google.zxing.WriterException; +import com.google.zxing.qrcode.encoder.ByteMatrix; +import com.google.zxing.qrcode.encoder.Encoder; +import com.google.zxing.qrcode.encoder.QRCode; + +/** + * This class is an implementation of QR Code (ISO 18004:2006(E)). + * + * @version $Id: QRCodeBean.java,v 1.3 2012-02-08 12:59:41 jmaerki Exp $ + */ +public class QRCodeBean extends AbstractBarcodeBean { + + /** The default module width (dot size) for DataMatrix. */ + protected static final double DEFAULT_MODULE_WIDTH = UnitConv.in2mm(1.0 / 72); //1px at 72dpi + + /** Error correction level */ + private char errorCorrectionLevel = QRConstants.ERROR_CORRECTION_LEVEL_L; + /** Message encoding */ + private String encoding = "ISO-8859-1"; //ECI 000003 + /** Optional: the minimum size of the symbol. */ + private Dimension minSize; + /** Optional: the maximum size of the symbol. */ + private Dimension maxSize; + + /** Create a new instance. */ + public QRCodeBean() { + this.height = 0.0; //not used by DataMatrix + this.moduleWidth = DEFAULT_MODULE_WIDTH; + setQuietZone(QRConstants.QUIET_ZONE_SIZE * moduleWidth); + } + + /** + * Sets the error correction level. + * @param level the error correction level (one of L, M, Q and H) + */ + public void setErrorCorrectionLevel(char level) { + switch (level) { + case QRConstants.ERROR_CORRECTION_LEVEL_L: + case QRConstants.ERROR_CORRECTION_LEVEL_M: + case QRConstants.ERROR_CORRECTION_LEVEL_Q: + case QRConstants.ERROR_CORRECTION_LEVEL_H: + this.errorCorrectionLevel = level; + break; + default: + throw new IllegalArgumentException( + "Invalid error correction level. Valid levels are: L, M, Q and H"); + } + } + + /** + * Returns the selected error correction level. + * @return the error correction level (one of L, M, Q and H) + */ + public char getErrorCorrectionLevel() { + return this.errorCorrectionLevel; + } + + /** + * Sets the message encoding. The value must conform to one of Java's encodings and + * have a mapping in the ECI registry. + * @param encoding the message encoding + */ + public void setEncoding(String encoding) { + if (ECIUtil.getECIForEncoding(encoding) < 0) { + throw new IllegalArgumentException("Not a valid encoding: " + encoding); + } + this.encoding = encoding; + } + + /** + * Returns the message encoding. + * @return the message encoding (default is "ISO-8859-1") + */ + public String getEncoding() { + return this.encoding; + } + + /** + * Sets the minimum symbol size that is to be produced. + * @param minSize the minimum size (in pixels), or null for no constraint + */ + public void setMinSize(Dimension minSize) { + this.minSize = (minSize != null ? new Dimension(minSize) : null); + } + + /** + * Returns the minimum symbol size that is to be produced. If the method returns null, + * there's no constraint on the symbol size. + * @return the minimum symbol size (in pixels), or null if there's no size constraint + */ + public Dimension getMinSize() { + if (this.minSize != null) { + return new Dimension(this.minSize); + } else { + return null; + } + } + + /** + * Sets the maximum symbol size that is to be produced. + * @param maxSize the maximum size (in pixels), or null for no constraint + */ + public void setMaxSize(Dimension maxSize) { + this.maxSize = (maxSize != null ? new Dimension(maxSize) : null); + } + + /** + * Returns the maximum symbol size that is to be produced. If the method returns null, + * there's no constraint on the symbol size. + * @return the maximum symbol size (in pixels), or null if there's no size constraint + */ + public Dimension getMaxSize() { + if (this.maxSize != null) { + return new Dimension(this.maxSize); + } else { + return null; + } + } + + /** {@inheritDoc} */ + public void generateBarcode(CanvasProvider canvas, String msg) { + if ((msg == null) + || (msg.length() == 0)) { + throw new NullPointerException("Parameter msg must not be empty"); + } + + TwoDimBarcodeLogicHandler handler = + new DefaultTwoDimCanvasLogicHandler(this, new Canvas(canvas)); + + QRLogicImpl impl = new QRLogicImpl(); + impl.generateBarcodeLogic(handler, msg, encoding, errorCorrectionLevel, + getMinSize(), getMaxSize()); + } + + /** {@inheritDoc} */ + public BarcodeDimension calcDimensions(String msg) { + QRCode code = new QRCode(); + try { + code = Encoder.encode(msg, + QRLogicImpl.getZXingErrorLevel(errorCorrectionLevel), + QRLogicImpl.createHints(encoding)); + } catch (WriterException e) { + throw new RuntimeException(e.getMessage()); + } + ByteMatrix matrix = code.getMatrix(); + int effWidth = matrix.getWidth(); + int effHeight = matrix.getHeight(); + checkSizeConstraints(effWidth, effHeight); + + double width = effWidth * getModuleWidth(); + double height = effHeight * getBarHeight(); + double qzh = (hasQuietZone() ? getQuietZone() : 0); + double qzv = (hasQuietZone() ? getVerticalQuietZone() : 0); + return new BarcodeDimension(width, height, + width + (2 * qzh), height + (2 * qzv), + qzh, qzv); + } + + private void checkSizeConstraints(int width, int height) { + //Note: we're only checking the constraints, we can't currently influence ZXing's encoder. + if (this.minSize != null) { + if (width < this.minSize.width || height < this.minSize.height) { + throw new IllegalArgumentException( + "The given message would result in a smaller symbol than required." + + " Requested minimum: " + + this.minSize.width + " x " + this.minSize.height + + ", effective: " + + width + " x " + height); + } + } + if (this.maxSize != null) { + if (width > this.maxSize.width || height > this.maxSize.height) { + throw new IllegalArgumentException( + "The given message would result in a larger symbol than required." + + " Requested maximum: " + + this.maxSize.width + " x " + this.maxSize.height + + ", effective: " + + width + " x " + height); + } + } + } + + /** {@inheritDoc} */ + public double getVerticalQuietZone() { + return getQuietZone(); + } + + /** {@inheritDoc} */ + public double getBarWidth(int width) { + return moduleWidth; + } + + /** {@inheritDoc} */ + public double getBarHeight() { + return moduleWidth; + } + +} \ No newline at end of file diff --git a/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRConstants.java b/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRConstants.java new file mode 100644 index 0000000000..bee186b73b --- /dev/null +++ b/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRConstants.java @@ -0,0 +1,49 @@ +/* + * Copyright 2012 Jeremias Maerki, Switzerland + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id: QRConstants.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $ */ + +package org.krysalis.barcode4j.impl.qr; + +/** + * Constants for QR Code. + * + * @version $Id: QRConstants.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $ + */ +public interface QRConstants { + + char ERROR_CORRECTION_LEVEL_L = 'L'; + char ERROR_CORRECTION_LEVEL_M = 'M'; + char ERROR_CORRECTION_LEVEL_Q = 'Q'; + char ERROR_CORRECTION_LEVEL_H = 'H'; + + int QUIET_ZONE_SIZE = 4; + int QUIET_ZONE_SIZE_MICRO = 2; + + int NUMERIC = 0; + int ALPHANUMERIC = 1; + int BINARY = 2; + + int[] ALPHANUMERIC_TABLE = { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //0x00-0x0f + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //0x10-0x1f + 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, //0x20-0x2f + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, //0x30-0x3f + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, //0x40-0x4f + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, //0x50-0x5f + }; + +} diff --git a/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRHighLevelEncoder.java b/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRHighLevelEncoder.java new file mode 100644 index 0000000000..661866da0d --- /dev/null +++ b/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRHighLevelEncoder.java @@ -0,0 +1,64 @@ +/* + * Copyright 2012 Jeremias Maerki, Switzerland + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id: QRHighLevelEncoder.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $ */ + +package org.krysalis.barcode4j.impl.qr; + +/** + * High-level encoder for QR Code. + * + * @version $Id: QRHighLevelEncoder.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $ + */ +public class QRHighLevelEncoder implements QRConstants { + + private final String msg; + private int encodingMode; + + public QRHighLevelEncoder(String msg) { + this.msg = msg; + this.encodingMode = analyzeMessage(msg); + } + + public int getEncodingMode() { + return this.encodingMode; + } + + private int analyzeMessage(String msg) { + int mode = NUMERIC; + for (int i = 0, c = msg.length(); i < c; i++) { + char ch = msg.charAt(i); + if (isDigit(ch)) { + //nop + } else if (mode == NUMERIC && isAlphanumeric(ch)) { + mode = ALPHANUMERIC; + } else { + mode = BINARY; + break; + } + } + return mode; + } + + private static final boolean isDigit(char ch) { + return ch >= '0' && ch <= '9'; + } + + private static final boolean isAlphanumeric(char ch) { + return ALPHANUMERIC_TABLE[ch] >= 0; + } + +} diff --git a/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRLogicImpl.java b/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRLogicImpl.java new file mode 100644 index 0000000000..047d5a8fa2 --- /dev/null +++ b/org.adempiere.base/src/org/krysalis/barcode4j/impl/qr/QRLogicImpl.java @@ -0,0 +1,116 @@ +/* + * Copyright 2012 Jeremias Maerki. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id: QRLogicImpl.java,v 1.3 2012-02-08 12:59:41 jmaerki Exp $ */ + +package org.krysalis.barcode4j.impl.qr; + +import java.awt.Dimension; +import java.util.Hashtable; + +import org.krysalis.barcode4j.TwoDimBarcodeLogicHandler; + +import com.google.zxing.EncodeHintType; +import com.google.zxing.WriterException; +import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; +import com.google.zxing.qrcode.encoder.ByteMatrix; +import com.google.zxing.qrcode.encoder.Encoder; +import com.google.zxing.qrcode.encoder.QRCode; + +/** + * Top-level class for the logic part of the DataMatrix implementation. + * + * @version $Id: QRLogicImpl.java,v 1.3 2012-02-08 12:59:41 jmaerki Exp $ + */ +public class QRLogicImpl implements QRConstants { + + /** + * Generates the barcode logic. + * @param logic the logic handler to receive generated events + * @param msg the message to encode + * @param errorCorrectionLevel the error correction level (one of L, M, Q, H) + * @param encoding the message encoding + * @param minSize the minimum symbol size constraint or null for no constraint + * @param maxSize the maximum symbol size constraint or null for no constraint + */ + public void generateBarcodeLogic(TwoDimBarcodeLogicHandler logic, String msg, + String encoding, + char errorCorrectionLevel, + Dimension minSize, Dimension maxSize) { + + //TODO ZXing doesn't allow to set minSize/maxSize through its API + + ErrorCorrectionLevel zxingErrLevel = getZXingErrorLevel(errorCorrectionLevel); + Hashtable hints = createHints(encoding); + + QRCode code = new QRCode(); + try { + code = Encoder.encode(msg, zxingErrLevel, hints); + } catch (WriterException e) { + throw new RuntimeException(e.getMessage(), e); + } + ByteMatrix matrix = code.getMatrix(); + + //finally, paint the barcode + logic.startBarcode(msg, msg); + encodeLowLevel(logic, matrix); + logic.endBarcode(); + } + + static Hashtable createHints(String encoding) { + Hashtable hints = null; + if (!"ISO-8859-1".equals(encoding)) { + hints = new Hashtable(); + hints.put(EncodeHintType.CHARACTER_SET, encoding); + } + return hints; + } + + static ErrorCorrectionLevel getZXingErrorLevel(char errorCorrectionLevel) { + ErrorCorrectionLevel zxingErrLevel; + switch (errorCorrectionLevel) { + case ERROR_CORRECTION_LEVEL_L: + zxingErrLevel = ErrorCorrectionLevel.L; + break; + case ERROR_CORRECTION_LEVEL_M: + zxingErrLevel = ErrorCorrectionLevel.M; + break; + case ERROR_CORRECTION_LEVEL_Q: + zxingErrLevel = ErrorCorrectionLevel.Q; + break; + case ERROR_CORRECTION_LEVEL_H: + zxingErrLevel = ErrorCorrectionLevel.H; + break; + default: + throw new IllegalArgumentException( + "Invalid error correction level: " + errorCorrectionLevel); + } + return zxingErrLevel; + } + + private void encodeLowLevel(TwoDimBarcodeLogicHandler logic, ByteMatrix matrix) { + int symbolWidth = matrix.getWidth(); + int symbolHeight = matrix.getHeight(); + for (int y = 0; y < symbolHeight; y++) { + logic.startRow(); + for (int x = 0; x < symbolWidth; x++) { + logic.addBar(matrix.get(x, y) == 1, 1); + } + logic.endRow(); + } + } + +} diff --git a/org.adempiere.base/src/org/krysalis/barcode4j/tools/ECIUtil.java b/org.adempiere.base/src/org/krysalis/barcode4j/tools/ECIUtil.java new file mode 100644 index 0000000000..61a10e9f40 --- /dev/null +++ b/org.adempiere.base/src/org/krysalis/barcode4j/tools/ECIUtil.java @@ -0,0 +1,82 @@ +/* + * Copyright 2012 Jeremias Maerki, Switzerland + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Id: ECIUtil.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $ */ + +package org.krysalis.barcode4j.tools; + +import java.util.Map; + +/** + * Utilities around ECI (extended channel interpretation). + * + * @version $Id: ECIUtil.java,v 1.1 2012-01-27 14:36:35 jmaerki Exp $ + */ +public class ECIUtil { + + /** ECI code for 8-bit binary data */ + public static final int ECI_BINARY = 899; + + private static final Map encodingToECI = new java.util.HashMap(); + + static { + mapEncoding("Cp437", 2); + mapEncoding("ISO-8859-1", 3); + mapEncoding("ISO-8859-2", 4); + mapEncoding("ISO-8859-3", 5); + mapEncoding("ISO-8859-4", 6); + mapEncoding("ISO-8859-5", 7); + mapEncoding("ISO-8859-6", 8); + mapEncoding("ISO-8859-7", 9); + mapEncoding("ISO-8859-8", 10); + mapEncoding("ISO-8859-9", 11); + mapEncoding("ISO-8859-10", 12); + mapEncoding("ISO-8859-11", 13); + mapEncoding("ISO-8859-13", 15); + mapEncoding("ISO-8859-14", 16); + mapEncoding("ISO-8859-15", 17); + mapEncoding("ISO-8859-16", 18); + mapEncoding("SJIS", 20); + mapEncoding("Cp1250", 21); + mapEncoding("Cp1251", 22); + mapEncoding("Cp1252", 23); + mapEncoding("Cp1256", 24); + mapEncoding("UnicodeBigUnmarked", 25); + mapEncoding("UTF-8", 26); + mapEncoding("US-ASCII", 27); + mapEncoding("Big5", 28); + mapEncoding("GB18030", 29); + } + + private static void mapEncoding(String encoding, int eci) { + encodingToECI.put(encoding, new Integer(eci)); + } + + /** + * Returns the ECI code for a given encoding. + * @param encoding the encoding + * @return the corresponding ECI code + */ + public static int getECIForEncoding(String encoding) { + Integer code = (Integer)encodingToECI.get(encoding); + if (code != null) { + return code.intValue(); + } else { + return -1; //undefined + } + } + +}