diff --git a/plugins/pipo/.classpath b/plugins/pipo/.classpath
deleted file mode 100644
index ad32c83a78..0000000000
--- a/plugins/pipo/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
diff --git a/plugins/pipo/.project b/plugins/pipo/.project
deleted file mode 100644
index 3c9fc47d88..0000000000
--- a/plugins/pipo/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
- pipo
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- org.eclipse.pde.ManifestBuilder
-
-
-
-
- org.eclipse.pde.SchemaBuilder
-
-
-
-
-
- org.eclipse.pde.PluginNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/plugins/pipo/.settings/org.eclipse.jdt.core.prefs b/plugins/pipo/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index ceb61221f1..0000000000
--- a/plugins/pipo/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,8 +0,0 @@
-#Fri Mar 12 08:48:46 CET 2010
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/pipo/.settings/org.eclipse.pde.core.prefs b/plugins/pipo/.settings/org.eclipse.pde.core.prefs
deleted file mode 100644
index 173c0ad34c..0000000000
--- a/plugins/pipo/.settings/org.eclipse.pde.core.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-#Fri Mar 12 15:16:08 CET 2010
-eclipse.preferences.version=1
-pluginProject.extensions=true
-resolve.requirebundle=false
diff --git a/plugins/pipo/META-INF/MANIFEST.MF b/plugins/pipo/META-INF/MANIFEST.MF
deleted file mode 100644
index 8908263f8d..0000000000
--- a/plugins/pipo/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,13 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: PiPo
-Bundle-SymbolicName: org.adempiere.pipo;singleton:=true
-Bundle-Version: 0.0.0.1
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Import-Package: org.adempiere.base,
- org.adempiere.pipo,
- org.compiere,
- org.compiere.util
-Export-Package: org.adempiere.pipo.srv
-Require-Bundle: org.adempiere.base;bundle-version="0.0.0",
- org.adempiere.tools;bundle-version="0.0.0"
diff --git a/plugins/pipo/build.properties b/plugins/pipo/build.properties
deleted file mode 100644
index e9863e281e..0000000000
--- a/plugins/pipo/build.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml
diff --git a/plugins/pipo/plugin.xml b/plugins/pipo/plugin.xml
deleted file mode 100644
index f3d7a1ee49..0000000000
--- a/plugins/pipo/plugin.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/plugins/pipo/schema/org.adempiere.pipo.Handlers.exsd b/plugins/pipo/schema/org.adempiere.pipo.Handlers.exsd
deleted file mode 100644
index 08af55b1a2..0000000000
--- a/plugins/pipo/schema/org.adempiere.pipo.Handlers.exsd
+++ /dev/null
@@ -1,109 +0,0 @@
-
-
-
-
-
-
-
-
- [Enter description of this extension point.]
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- element name like AD_Message, AD_Table, Code_Snippet, etc
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- [Enter the first release in which this extension point appears.]
-
-
-
-
-
-
-
-
- [Enter extension point usage example here.]
-
-
-
-
-
-
-
-
- [Enter API information here.]
-
-
-
-
-
-
-
-
- [Enter information about supplied implementation of this extension point.]
-
-
-
-
-
diff --git a/plugins/pipo/src/org/adempiere/pipo/srv/PipoDictionaryService.java b/plugins/pipo/src/org/adempiere/pipo/srv/PipoDictionaryService.java
deleted file mode 100644
index 130a47fa43..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo/srv/PipoDictionaryService.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.adempiere.pipo.srv;
-
-import java.io.File;
-import java.io.InputStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.adempiere.base.IDictionaryService;
-import org.adempiere.pipo2.PackIn;
-import org.compiere.Adempiere;
-import org.compiere.util.Env;
-import org.compiere.util.Trx;
-
-public class PipoDictionaryService implements IDictionaryService {
-
- Logger logger = Logger.getLogger(PipoDictionaryService.class.getName());
-
- @Override
- public void merge(InputStream model) throws Exception {
- if (model == null) {
- logger.info("No PackIn Model found");
- return;
- }
- String trxName = Trx.createTrxName();
- try {
- logger.info("starting " + trxName);
- PackIn packIn = new PackIn();
- packIn.setUpdateDictionary(true);
- packIn.setPackageDirectory(getPackageDir());
- packIn.importXML(model, Env.getCtx(), trxName);
- Trx.get(trxName, false).commit();
- logger.info("commit " + trxName);
- } catch (Exception e) {
- logger.log(Level.SEVERE, "importXML:", e);
- throw e;
- } finally {
- Trx.get(trxName, false).close();
- }
-
- }
-
- private String getPackageDir() {
-
- // Create Target directory if required
- String packageDirectory = Adempiere.getAdempiereHome();
- String result = packageDirectory + File.separator
- + "packages";
- File docDir = new File( result+File.separator+"doc");
-
- if (!docDir.exists()) {
- boolean success = docDir.mkdirs();
- if (!success) {
- logger.info("Target directory creation failed");
- }
- }
- return result;
- }
-
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/AbstractElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/AbstractElementHandler.java
deleted file mode 100644
index 18b9a47cfd..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/AbstractElementHandler.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com *
- * Contributor(s): Low Heng Sin hengsin@avantz.com *
- *****************************************************************************/
-package org.adempiere.pipo2;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.logging.Level;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.compiere.model.PO;
-import org.compiere.model.POInfo;
-import org.compiere.model.Query;
-import org.compiere.model.X_AD_Package_Imp_Backup;
-import org.compiere.model.X_AD_Package_Imp_Detail;
-import org.compiere.util.CLogger;
-import org.compiere.util.DB;
-import org.compiere.util.Env;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-import java.sql.ResultSet;
-import java.sql.PreparedStatement;
-
-import org.adempiere.pipo2.exception.DatabaseAccessException;
-
-/**
- *
- * @author hengsin
- *
- */
-public abstract class AbstractElementHandler implements ElementHandler {
-
- protected CLogger log = CLogger.getCLogger(getClass());
-
- /**
- * Get ID from Name for a table.
- *
- * @param tableName
- * @param name
- *
- */
- public int findIdByName (Properties ctx, String tableName, String name) {
- return IDFinder.findIdByName(tableName, name, getClientId(ctx), getTrxName(ctx));
- }
-
- /**
- * Get ID from column value for a table.
- *
- * @param tableName
- * @param columName
- * @param name
- */
- public int findIdByColumn (Properties ctx, String tableName, String columnName, Object value) {
- int id = 0;
- if ("AD_Table".equals(tableName) && "TableName".equals(columnName) && value != null) {
- id = getPackInProcess(ctx).getTableId(value.toString());
- if (id <= 0) {
- id = IDFinder.findIdByColumn(tableName, columnName, value, getClientId(ctx), getTrxName(ctx));
- if (id > 0) {
- getPackInProcess(ctx).addTable(value.toString(), id);
- }
- }
- } else {
- id = IDFinder.findIdByColumn(tableName, columnName, value, getClientId(ctx), getTrxName(ctx));
- }
- return id;
- }
-
- /**
- * @param ctx
- * @param type
- * @param tableName
- * @param tableId
- * @return X_AD_Package_Imp_Detail
- */
- public X_AD_Package_Imp_Detail createImportDetail(Properties ctx, String type, String tableName, int tableId) {
- X_AD_Package_Imp_Detail impDetail = new X_AD_Package_Imp_Detail(ctx, 0, getTrxName(ctx));
- impDetail.setAD_Package_Imp_ID(getPackageImpId(ctx));
- impDetail.setAD_Org_ID(Env.getAD_Org_ID(ctx) );
- impDetail.setType(type);
- impDetail.setName("");
- impDetail.setAction("");
- impDetail.setAD_Original_ID(1);
- impDetail.setTableName(tableName);
- impDetail.setAD_Table_ID(tableId);
- impDetail.saveEx(getTrxName(ctx));
-
- return impDetail;
- }
-
- /**
- * Write results to log and records in history table
- *
- * @param ctx
- * @param success
- * @param detail
- * @param objectName
- * @param objectID
- * @param action
- * @throws SAXException
- *
- */
- public void logImportDetail (Properties ctx, X_AD_Package_Imp_Detail detail, int success, String objectName, int objectID,
- String action) throws SAXException{
- StringBuffer recordLayout = new StringBuffer();
- TransformerHandler hd_document = getLogDocument(ctx);
- AttributesImpl attsOut = new AttributesImpl();
- String result = success == 1 ? "Success" : "Failure";
-
- //hd_documemt.startElement("","","Successful",attsOut);
- recordLayout.append("Type:")
- .append(detail.getType())
- .append(" - Name:")
- .append(objectName)
- .append(" - ID:")
- .append(objectID)
- .append(" - Action:")
- .append(action)
- .append(" - " + result);
-
- hd_document.startElement("","",result,attsOut);
- hd_document.characters(recordLayout.toString().toCharArray(),0,recordLayout.length());
- hd_document.endElement("","",result);
-
- detail.setName(objectName);
- detail.setAction(action);
- detail.setSuccess(result);
- detail.setAD_Original_ID(objectID);
- detail.saveEx(getTrxName(ctx));
- }
-
- /**
- * Get ID from Name for a table with a parent name reference.
- *
- * @param tableName
- * @param name
- * @param tableNameMaster
- * @param nameMaster
- */
- public int findIdByNameAndParentName (Properties ctx, String tableName, String name, String tableNameMaster, String nameMaster) {
- return IDFinder.findIdByNameAndParentName(tableName, name, tableNameMaster, nameMaster, getTrxName(ctx));
- }
-
- /**
- * Get ID from column value for a table with a parent id reference.
- *
- * @param tableName
- * @param name
- * @param tableNameMaster
- * @param nameMaster
- */
-
- public int findIdByColumnAndParentId (Properties ctx, String tableName, String columnName, String name, String tableNameMaster, int masterID) {
- return IDFinder.findIdByColumnAndParentId(tableName, columnName, name, tableNameMaster, masterID,
- getTrxName(ctx));
- }
-
- /**
- * Get ID from Name for a table with a parent reference ID.
- *
- * @param tableName
- * @param name
- * @param tableNameMaster
- * @param masterID
- */
- public int findIdByNameAndParentId (Properties ctx, String tableName, String name, String tableNameMaster, int masterID) {
- return IDFinder.findIdByNameAndParentId(tableName, name, tableNameMaster, masterID, getTrxName(ctx));
- }
-
- /**
- * Make backup copy of record.
- *
- * @param tablename
- *
- *
- *
- */
-
- public void backupRecord(Properties ctx, int AD_Package_Imp_Detail_ID, String tableName,PO from){
-
- // Create new record
- int tableID = findIdByColumn(ctx, "AD_Table", "TableName", tableName);
- POInfo poInfo = POInfo.getPOInfo(ctx, tableID, getTrxName(ctx));
-
- PreparedStatement pstmtReferenceId = DB.prepareStatement("SELECT AD_Reference_ID FROM AD_COLUMN WHERE AD_Column_ID = ?", getTrxName(ctx));
- ResultSet rs=null;
-
- try{
- for (int i = 0; i < poInfo.getColumnCount(); i++){
-
- int columnID =findIdByColumnAndParentId (ctx, "AD_Column", "ColumnName", poInfo.getColumnName(i), "AD_Table", tableID);
-
- int referenceID=0;
-
- pstmtReferenceId.setInt(1,columnID);
- rs = pstmtReferenceId.executeQuery();
-
- if (rs.next())
- referenceID = rs.getInt(1);
-
- X_AD_Package_Imp_Backup backup = new X_AD_Package_Imp_Backup(ctx, 0, getTrxName(ctx));
- backup.setAD_Org_ID(Env.getAD_Org_ID(ctx));
- backup.setAD_Package_Imp_ID(getPackageImpId(ctx));
- backup.setAD_Package_Imp_Detail_ID(AD_Package_Imp_Detail_ID);
- backup.setAD_Table_ID(tableID);
-
- backup.setAD_Column_ID(columnID);
- backup.setAD_Reference_ID(referenceID);
- Object value = from.get_ValueOld(i);
- backup.setColValue(value != null ? value.toString() : null);
-
- backup.saveEx(getTrxName(ctx));
- }
- }
- catch(Exception e)
- {
- throw new DatabaseAccessException(e);
- }
- finally
- {
- DB.close(rs, pstmtReferenceId);
- }
- }
-
- /**
- * Open input file for processing
- *
- * @param String file with path
- *
- */
- public FileInputStream OpenInputfile (String filePath) {
-
- FileInputStream fileTarget = null;
-
- try {
- fileTarget = new FileInputStream(filePath);
- }
- catch (FileNotFoundException e ) {
- System.out.println("File not found: " + filePath);
-
- return null;
- }
- return fileTarget;
- }
-
- /**
- * Open output file for processing
- *
- * @param String file with path
- *
- */
- public OutputStream OpenOutputfile (String filePath) {
-
- OutputStream fileTarget = null;
-
- try {
- fileTarget = new FileOutputStream(filePath);
- }
- catch (FileNotFoundException e ) {
- System.out.println("File not found: " + filePath);
-
- return null;
- }
- return fileTarget;
- }
-
- /**
- * Copyfile
- *
- * @param String file with path
- *
- */
- public int copyFile (InputStream source,OutputStream target) {
-
- int byteCount = 0;
- int success = 0;
- try {
- while (true) {
- int data = source.read();
- if (data < 0)
- break;
- target.write(data);
- byteCount++;
- }
- source.close();
- target.close();
- //System.out.println("Successfully copied " + byteCount + " bytes.");
- }
- catch (Exception e) {
- log.log(Level.SEVERE, e.getLocalizedMessage(), e);
- success = -1;
- }
- return success;
- }
-
- /**
- * Get client id
- * @param ctx
- * @return int
- */
- protected int getClientId(Properties ctx) {
- return Env.getContextAsInt(ctx, "AD_Client_ID");
- }
-
- /**
- * Get AD_Package_Imp_ID
- * @param ctx
- * @return int
- */
- protected int getPackageImpId(Properties ctx) {
- return Env.getContextAsInt(ctx, "AD_Package_Imp_ID");
- }
-
- /**
- * Get update system maintained dictionary flag
- * @param ctx
- * @return update mode
- */
- protected String getUpdateMode(Properties ctx) {
- return Env.getContext(ctx, "UpdateMode");
- }
-
- /**
- * Get current transaction name
- * @param ctx
- * @return transaction name
- */
- protected String getTrxName(Properties ctx) {
- return Env.getContext(ctx, "TrxName");
- }
-
- /**
- * Get share document
- * @param ctx
- * @return TransformerHandler
- */
- protected TransformerHandler getLogDocument(Properties ctx) {
- return (TransformerHandler)ctx.get("LogDocument");
- }
-
- /**
- * @param ctx
- * @return package directory
- */
- protected String getPackageDirectory(Properties ctx) {
- return Env.getContext(ctx, "PackageDirectory");
- }
-
- /**
- * Process element by entity type and user setting.
- * @param ctx
- * @param entityType
- * @return boolean
- */
- protected boolean isProcessElement(Properties ctx, String entityType) {
- if ("D".equals(entityType) || "C".equals(entityType)) {
- return "true".equalsIgnoreCase(getUpdateMode(ctx));
- } else {
- return true;
- }
- }
-
- /**
- * return null for empty string ("").
- * @param element
- * @param qName
- * @return string value
- */
- protected String getStringValue(Element element, String qName) {
- return getStringValue(element, qName, null);
- }
-
- /**
- * return null for empty string ("").
- * @param element
- * @param qName
- * @return string value
- */
- protected String getStringValue(Element element, String qName, List excludes) {
- String name = qName;
- String s = element.properties.get(qName).contents.toString();
-
- if (s != null && s.trim().length() > 0 && excludes != null) {
- excludes.add(name);
- }
- return ((s == null || s.trim().length() == 0) ? null : s.trim());
- }
-
- /**
- * @param element
- * @param qName
- * @param defaultValue
- * @return boolean
- */
- protected boolean getBooleanValue(Element element, String qName, boolean defaultValue) {
- String value = element.properties.get(qName).contents.toString();
- return value != null ? Boolean.valueOf(value).booleanValue() : defaultValue;
- }
-
- /**
- * @param element
- * @param qName
- * @return BigDecimal
- */
- protected BigDecimal getBigDecimal(Element element, String qName) {
- String value = element.properties.get(qName).contents.toString();
- return value != null ? new BigDecimal(value) : null;
- }
-
- /**
- * @param element
- * @param qName
- * @return int
- */
- protected int getIntValue(Element element, String qName) {
- Element pe = element.properties.get(qName);
- String value = pe != null ? pe.contents.toString() : null;
- return value != null ? Integer.parseInt(value) : 0;
- }
-
- /**
- * Returns option - Is export-import of AD translations is needed
- * @param ctx
- * @param entityType
- * @return boolean
- */
- protected boolean isHandleTranslations(Properties ctx) {
-
- return "true".equalsIgnoreCase(Env.getContext(ctx, "isHandleTranslations"));
- }
-
- protected List defaultExcludeList(String tableName) {
- List excludes = new ArrayList();
- excludes.add("ad_client_id");
- excludes.add("ad_org_id");
- excludes.add("created");
- excludes.add("createdby");
- excludes.add("updated");
- excludes.add("updatedby");
- excludes.add(tableName + "_ID");
- return excludes;
- }
-
- protected PackIn getPackInProcess(Properties ctx) {
- return (PackIn)ctx.get(PackInHandler.PACK_IN_PROCESS_CTX_KEY);
- }
-
- protected PackOut getPackOutProcess(Properties ctx) {
- return (PackOut) ctx.get(PackOut.PACK_OUT_PROCESS_CTX_KEY);
- }
-
- protected int getParentId(Element element, String expectedName) {
- if (element.parent != null && element.parent.getElementValue().equals(expectedName) &&
- element.parent.recordId > 0)
- return element.parent.recordId;
- else
- return 0;
- }
-
- protected boolean isParentDefer(Element element, String expectedName) {
- if (element.parent != null
- && (expectedName == null || element.parent.getElementValue().equals(expectedName))
- && element.parent.defer)
- return true;
- else
- return false;
- }
-
- protected boolean isParentSkip(Element element, String expectedName) {
- if (element.parent != null
- && (expectedName == null || element.parent.getElementValue().equals(expectedName))
- && element.parent.skip)
- return true;
- else
- return false;
- }
-
- protected boolean isOfficialId(Element element, String columnName) {
- int value = getIntValue(element, columnName);
- if (value > 0 && value <= PackOut.MAX_OFFICIAL_ID)
- return true;
- else
- return false;
- }
-
- protected void addTextProperty(TransformerHandler handler, String qName, String text) throws SAXException {
- AttributesImpl atts = new AttributesImpl();
- atts.addAttribute("", "", qName, "reference", "property");
- handler.startElement("", "", qName, atts);
- append(handler, text);
- handler.endElement("", "", qName);
- }
-
- protected void append(TransformerHandler document, String str) throws SAXException
- {
- char[] contents = str != null ? str.toCharArray() : new char[0];
- document.characters(contents,0,contents.length);
- }
-
- /**
- * Find po by uuid or id
- * @param
- * @param ctx
- * @param element
- * @return T
- */
- protected T findPO(Properties ctx, Element element) {
- T po = null;
- String tableName = element.getElementValue();
- String uuidColumn = tableName + "_UU";
- String idColumn = tableName + "_ID";
- if (element.properties.containsKey(uuidColumn)) {
- String uuid = element.properties.get(uuidColumn).contents.toString();
- if (uuid != null && uuid.trim().length() == 36) {
- Query query = new Query(ctx, tableName, uuidColumn+"=?", getTrxName(ctx));
- po = query.setParameters(uuid.trim()).firstOnly();
- }
- } else if (element.properties.containsKey(idColumn)) {
- String id = element.properties.get(idColumn).contents.toString();
- if (id != null && id.trim().length() > 0) {
- Query query = new Query(ctx, tableName, idColumn+"=?", getTrxName(ctx));
- po = query.setParameters(id.trim()).firstOnly();
- }
- }
- return po;
- }
-
- protected void addTypeName(AttributesImpl atts, String typeName) {
- atts.addAttribute("", "", "type", "CDATA", typeName);
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/Element.java b/plugins/pipo/src/org/adempiere/pipo2/Element.java
deleted file mode 100644
index 98e9b3b802..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/Element.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Low Heng Sin hengsin@avantz.com
- *****************************************************************************/
-package org.adempiere.pipo2;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.xml.sax.Attributes;
-
-/**
- * XML element structure
- * @author Low Heng Sin
- *
- */
-public class Element {
-
- public String uri;
- public String localName;
- public String qName;
- //element attributes
- public Attributes attributes;
- //defer for later reprocessing
- public boolean defer = false;
- //parent element
- public Element parent;
- //resolved db recordid, store for reference by child element
- public int recordId = 0;
- //unresolved dependency
- public String unresolved = "";
- //number of pass
- public int pass = 1;
- //skip this node
- public boolean skip = false;
-
- public boolean deferEnd = false;
-
- public Map properties = new LinkedHashMap();
-
- public List childrens = new ArrayList();
-
- public StringBuffer contents = new StringBuffer();
-
- /**
- * @param uri
- * @param localName
- * @param qName
- * @param attributes
- */
- public Element(String uri, String localName, String qName, Attributes attributes) {
- this.uri = uri;
- this.localName = localName;
- this.qName = qName;
- this.attributes = attributes;
- }
-
- /**
- * @return elementValue
- */
- public String getElementValue() {
- String elementValue = null;
- if ("".equals (uri))
- elementValue = qName;
- else
- elementValue = uri + localName;
- return elementValue;
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/ElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/ElementHandler.java
deleted file mode 100644
index bc7a86e416..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/ElementHandler.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Low Heng Sin hengsin@avantz.com
- *****************************************************************************/
-package org.adempiere.pipo2;
-
-import java.util.Properties;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.base.IService;
-import org.xml.sax.SAXException;
-
-/**
- * Interface for handling import and export of table data using xml
- * @author Low Heng Sin
- *
- */
-public interface ElementHandler extends IService {
-
- /**
- * Handle start of xml element ( import ).
- * @param ctx
- * @param element
- * @throws org.xml.sax.SAXException
- */
- public void startElement (Properties ctx, Element element)
- throws org.xml.sax.SAXException;
-
- /**
- * Handle closing of xml element ( import ).
- * @param ctx
- * @param element
- * @throws SAXException
- */
- public void endElement (Properties ctx, Element element) throws SAXException;
-
- /**
- * @param packout
- * @param packoutHandler
- * @param docHandler
- * @param recordId
- * @throws Exception
- */
- public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception;
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/IDFinder.java b/plugins/pipo/src/org/adempiere/pipo2/IDFinder.java
deleted file mode 100644
index 0e0c9820da..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/IDFinder.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Low Heng Sin hengsin@avantz.com
- *****************************************************************************/
-package org.adempiere.pipo2;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.adempiere.pipo2.exception.DatabaseAccessException;
-import org.compiere.util.CLogger;
-import org.compiere.util.DB;
-import org.compiere.util.Env;
-
-/**
- * Utility class for the looking up of record id.
- * @author Low Heng Sin
- *
- */
-public class IDFinder {
-
- private static CLogger log = CLogger.getCLogger(IDFinder.class);
-
- private static MapidCache = new HashMap();
-
- /**
- * Get ID from column value for a table.
- *
- * @param tableName
- * @param columName
- * @param value
- * @param AD_Client_ID
- * @param trxName
- */
- public static int findIdByColumn (String tableName, String columnName, Object value, int AD_Client_ID, String trxName) {
- int id = 0;
-
- if (value == null)
- return id;
-
- //construct cache key
- StringBuffer key = new StringBuffer();
- key.append(tableName)
- .append(".")
- .append(columnName)
- .append("=")
- .append(value.toString())
- .append(" AND AD_Client_ID=").append(AD_Client_ID);
-
- //check cache
- if (idCache.containsKey(key.toString()))
- return idCache.get(key.toString());
-
- StringBuffer sqlB = new StringBuffer ("SELECT ")
- .append(tableName)
- .append("_ID FROM ")
- .append(tableName)
- .append(" WHERE ")
- .append(columnName)
- .append(" = ?")
- .append(" AND AD_Client_ID IN (0, ?)")
- .append(" Order By AD_Client_ID Desc, ")
- .append(tableName)
- .append("_ID");
-
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- pstmt = DB.prepareStatement(sqlB.toString(), trxName);
- if (value instanceof String)
- pstmt.setString(1, (String)value);
- else if (value instanceof Integer)
- pstmt.setInt(1, ((Integer)value).intValue());
- else
- pstmt.setObject(1, value);
- pstmt.setInt(2, AD_Client_ID);
-
- rs = pstmt.executeQuery();
- if (rs.next())
- id = rs.getInt(1);
- }
- catch (Exception e) {
- throw new DatabaseAccessException(e);
- } finally {
- DB.close(rs, pstmt);
- }
-
- //update cache
- if (id > 0)
- idCache.put(key.toString(), id);
-
- return id;
- }
-
- /**
- * Get ID from Name for a table with a parent name reference.
- *
- * @param tableName
- * @param name
- * @param tableNameMaster
- * @param nameMaster
- * @param trxName
- */
- public static int findIdByNameAndParentName (String tableName, String name, String tableNameMaster, String nameMaster, String trxName) {
- int id = 0;
- //construct cache key
- StringBuffer key = new StringBuffer();
- key.append(tableName)
- .append(".Name=")
- .append(name)
- .append(" and ")
- .append(tableNameMaster)
- .append(".Name=")
- .append(nameMaster);
-
- //check cache
- if (idCache.containsKey(key.toString()))
- return idCache.get(key.toString());
-
- StringBuffer parentSql = new StringBuffer("SELECT ")
- .append(tableNameMaster)
- .append("_ID FROM ")
- .append(tableNameMaster)
- .append(" WHERE Name = ? AND AD_Client_ID IN (0, ?) ")
- .append("ORDER BY AD_Client_ID Desc");
- int parentId = DB.getSQLValue(trxName, parentSql.toString(), Env.getAD_Client_ID(Env.getCtx()));
-
- if (parentId > 0) {
- StringBuffer sqlB = new StringBuffer ("SELECT ")
- .append(tableName)
- .append("_ID FROM ")
- .append(tableName)
- .append(" WHERE Name = ? AND ")
- .append(tableNameMaster)
- .append("_ID = ?");
-
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- pstmt = DB.prepareStatement(sqlB.toString(), trxName);
- pstmt.setString(1, name);
- pstmt.setString(2, nameMaster);
- pstmt.setInt(3, parentId);
- rs = pstmt.executeQuery();
- if (rs.next())
- id = rs.getInt(1);
- } catch (Exception e) {
- throw new DatabaseAccessException(e);
- } finally {
- DB.close(rs, pstmt);
- }
- }
-
- //update cache
- if (id > 0)
- idCache.put(key.toString(), id);
-
- return id;
- }
-
- /**
- * Get ID from column value for a table with a parent id reference.
- *
- * @param tableName
- * @param name
- * @param tableNameMaster
- * @param masterID
- * @param trxName
- */
-
- public static int findIdByColumnAndParentId (String tableName, String columnName, String name, String tableNameMaster, int masterID, String trxName) {
- int id = 0;
-
- //check cache
- String key = tableName + "." + columnName + "=" + name + tableNameMaster + "=" + masterID;
-
- if (idCache.containsKey(key))
- return idCache.get(key);
-
- StringBuffer sqlB = new StringBuffer ("SELECT ")
- .append(tableName)
- .append("_ID FROM ")
- .append(tableName)
- .append(" WHERE ")
- .append(columnName)
- .append(" = ? and ")
- .append(tableNameMaster+"_ID = ? AND AD_Client_ID IN (0, ?) ")
- .append("ORDER BY AD_Client_ID Desc ");
-
- log.info(sqlB.toString());
-
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
-
- pstmt = DB.prepareStatement(sqlB.toString(), trxName);
- pstmt.setString(1, name);
- pstmt.setInt(2, masterID);
- pstmt.setInt(3, Env.getAD_Client_ID(Env.getCtx()));
- rs = pstmt.executeQuery();
- if (rs.next())
- {
- id = rs.getInt(1);
- }
- }
- catch (Exception e) {
- throw new DatabaseAccessException(e);
- } finally {
- DB.close(rs, pstmt);
- }
-
- //update cache
- if (id > 0)
- idCache.put(key, id);
-
- return id;
- }
-
- /**
- * Get ID from Name for a table with a parent reference ID.
- *
- * @param tableName
- * @param name
- * @param tableNameMaster
- * @param masterID
- * @param trxName
- */
- public static int findIdByNameAndParentId (String tableName, String name, String tableNameMaster, int masterID, String trxName) {
- int id = 0;
-
- //construct cache key
- StringBuffer key = new StringBuffer();
- key.append(tableName)
- .append(".Name=")
- .append(name)
- .append(" AND ")
- .append(tableNameMaster)
- .append(".")
- .append(tableNameMaster)
- .append("_ID=")
- .append(masterID);
-
- //check cache
- if (idCache.containsKey(key.toString()))
- return idCache.get(key.toString());
-
- StringBuffer sqlB = new StringBuffer ("SELECT ")
- .append(tableName)
- .append("_ID FROM ")
- .append(tableName)
- .append(" WHERE Name=? AND ")
- .append(tableNameMaster)
- .append("_ID=? AND AD_Client_ID IN (0, ?) ")
- .append("ORDER BY AD_Client_ID Desc");
-
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- pstmt = DB.prepareStatement(sqlB.toString(), trxName);
- pstmt.setString(1, name);
- pstmt.setInt(2, masterID);
- pstmt.setInt(3, Env.getAD_Client_ID(Env.getCtx()));
- rs = pstmt.executeQuery();
- if (rs.next())
- id = rs.getInt(1);
- }
- catch (Exception e) {
- throw new DatabaseAccessException(e);
- } finally {
- DB.close(rs, pstmt);
- }
-
- //update cache
- if (id > 0)
- idCache.put(key.toString(), id);
-
- return id;
- }
-
- /**
- * Get ID from Name for a table.
- *
- * @param tableName
- * @param name
- * @param AD_Client_ID
- * @param trxName
- */
- public static int findIdByName (String tableName, String name, int AD_Client_ID, String trxName) {
- int id = 0;
-
- //construct cache key
- StringBuffer key = new StringBuffer();
- key.append(tableName)
- .append(".Name=")
- .append(name);
- if (!tableName.startsWith("AD_"))
- key.append(" AND AD_Client_ID=").append(AD_Client_ID);
-
- //check cache
- if (idCache.containsKey(key.toString()))
- return idCache.get(key.toString());
-
- StringBuffer sql = new StringBuffer("SELECT ")
- .append(tableName)
- .append("_ID ")
- .append("FROM ")
- .append(tableName)
- .append(" ")
- .append("WHERE Name=? ")
- .append(" AND AD_Client_ID IN (0, ?) ")
- .append(" ORDER BY AD_Client_ID Desc");
-
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- pstmt = DB.prepareStatement(sql.toString(), trxName);
- pstmt.setString(1, name);
- pstmt.setInt(2, AD_Client_ID);
- rs = pstmt.executeQuery();
- if (rs.next())
- id = rs.getInt(1);
- }
- catch (Exception e) {
- throw new DatabaseAccessException(e);
- } finally {
- DB.close(rs, pstmt);
- }
-
- //update cache
- if (id > 0)
- idCache.put(key.toString(), id);
-
- return id;
- }
-
- public static void clearIDCache() {
- idCache.clear();
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/IHandlerRegistry.java b/plugins/pipo/src/org/adempiere/pipo2/IHandlerRegistry.java
deleted file mode 100644
index fd519f395f..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/IHandlerRegistry.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.adempiere.pipo2;
-
-public interface IHandlerRegistry {
-
- public static final String ELEMENT_TYPE_TRANSLATION = "translation";
- public static final String ELEMENT_TYPE_TABLE = "table";
- public static final String ELEMENT_TYPE_TASK = "task";
- public static final String ELEMENT_TYPE_PROPERTIES = "properties";
-
- public static final String TABLE_TRANSLATION_HANDLER = "table.translationHandler";
- public static final String TABLE_GENERIC_HANDLER = "table.genericHandler";
-
- /**
- * @param element
- * @return ElementHandler
- */
- public ElementHandler getHandler(Element element);
-
- /**
- * @param name
- * @return ElementHandler
- */
- public ElementHandler getHandler(String name);
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/OSGiHandlerRegistry.java b/plugins/pipo/src/org/adempiere/pipo2/OSGiHandlerRegistry.java
deleted file mode 100644
index 6268e8b04b..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/OSGiHandlerRegistry.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- *
- */
-package org.adempiere.pipo2;
-
-import org.adempiere.base.Service;
-import org.adempiere.base.ServiceQuery;
-
-/**
- * @author hengsin
- *
- */
-public class OSGiHandlerRegistry implements IHandlerRegistry {
-
- private final static String SERVICE_ID = "org.adempiere.pipo.Handlers";
- /**
- *
- */
- public OSGiHandlerRegistry() {
- // TODO Auto-generated constructor stub
- }
-
- /* (non-Javadoc)
- * @see org.adempiere.pipo2.IHandlerRegistry#getHandler(org.adempiere.pipo2.Element)
- */
- @Override
- public ElementHandler getHandler(Element element) {
- String id = null;
- ElementHandler handler = null;
- String type = element.attributes.getValue("type");
- if (ELEMENT_TYPE_TRANSLATION.equals(type)) {
- id = TABLE_TRANSLATION_HANDLER;
- } else {
- id = element.getElementValue();
- }
-
- ServiceQuery query = new ServiceQuery();
- query.put("id", id);
- handler = Service.locate(ElementHandler.class, SERVICE_ID, query);
- if (handler == null) {
- id = TABLE_GENERIC_HANDLER;
- query.put("id", id);
- handler = Service.locate(ElementHandler.class, SERVICE_ID, query);
- }
- return handler;
- }
-
- /* (non-Javadoc)
- * @see org.adempiere.pipo2.IHandlerRegistry#getHandler(java.lang.String)
- */
- @Override
- public ElementHandler getHandler(String name) {
- ElementHandler handler = null;
- ServiceQuery query = new ServiceQuery();
- query.put("id", name);
- handler = Service.locate(ElementHandler.class, SERVICE_ID, query);
- return handler;
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/PackIn.java b/plugins/pipo/src/org/adempiere/pipo2/PackIn.java
deleted file mode 100644
index ad5eb87290..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/PackIn.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert KLEIN. robeklein@hotmail.com
- *
- *****************************************************************************/
-
-package org.adempiere.pipo2;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.logging.Level;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.compiere.Adempiere;
-import org.compiere.db.CConnection;
-import org.compiere.model.X_AD_Package_Imp_Proc;
-import org.compiere.process.SvrProcess;
-import org.compiere.util.CLogMgt;
-import org.compiere.util.CLogger;
-import org.compiere.util.DB;
-import org.compiere.util.Env;
-import org.compiere.util.Ini;
-import org.compiere.util.Trx;
-
-/**
- * IntPackIn Tool.
- *
- * @author: Robert KLEIN. robeklein@hotmail.com
- */
-public class PackIn extends SvrProcess {
-
- /** Logger */
- private CLogger log = CLogger.getCLogger(getClass());
- //update system maintain dictionary, default to false
- private boolean m_UpdateDictionary = false;
- private String m_Database = "Oracle";
- private String m_Package_Dir = null;
- public int p_PackIn_ID = 0;
-
- private Map tableCache = new HashMap();
- private Map columnCache = new HashMap();
-
- public PackIn() {
- super();
- if (DB.isOracle())
- m_Database = "Oracle";
- else if (DB.isPostgreSQL())
- m_Database = "PostgreSQL";
- }
-
- /**
- * add to table id cache
- * @param tableName
- * @param tableId
- */
- public void addTable(String tableName, int tableId) {
- tableCache.put(tableName, tableId);
- }
-
- /**
- * Find table id from cache
- * @param tableName
- * @return tableId
- */
- public int getTableId(String tableName) {
- if (tableCache.containsKey(tableName))
- return tableCache.get(tableName).intValue();
- else
- return 0;
- }
-
- /**
- * add to column id cache
- * @param tableName
- * @param columnName
- * @param columnId
- */
- public void addColumn(String tableName, String columnName, int columnId) {
- columnCache.put(tableName+"."+columnName, columnId);
- }
-
- /**
- * find column id from cache
- * @param tableName
- * @param columnName
- * @return column id
- */
- public int getColumnId(String tableName, String columnName) {
- String key = tableName+"."+columnName;
- if (columnCache.containsKey(key))
- return columnCache.get(key).intValue();
- else
- return 0;
- }
-
- protected void prepare() {
-
- p_PackIn_ID = getRecord_ID();
- } // prepare
-
- /**
- * Uses PackInHandler to update AD.
- *
- * @param fileName
- * xml file to read
- * @return status message
- */
- public String importXML(String fileName, Properties ctx, String trxName) throws Exception {
- log.info("importXML:" + fileName);
- File in = new File(fileName);
- if (!in.exists()) {
- String msg = "File does not exist: " + fileName;
- log.info("importXML:" + msg);
- return msg;
- }
- try {
- FileInputStream input = new FileInputStream(in);
- return importXML(input, ctx, trxName);
- } catch (Exception e) {
- log.log(Level.SEVERE, "importXML:", e);
- throw e;
- }
- }
-
- public String importXML(InputStream input, Properties ctx, String trxName) {
- try {
- log.info("starting");
- System.setProperty("javax.xml.parsers.SAXParserFactory",
- "org.apache.xerces.jaxp.SAXParserFactoryImpl");
- PackInHandler handler = new PackInHandler();
- handler.set_TrxName(trxName);
- handler.setCtx(ctx);
- handler.setProcess(this);
- SAXParserFactory factory = SAXParserFactory.newInstance();
- SAXParser parser = factory.newSAXParser();
- String msg = "Start Parser";
- log.info(msg);
- parser.parse(input, handler);
- msg = "End Parser";
- log.info(msg);
- return "Processed="+handler.getElementsProcessed()+" Un-Resolved="+handler.getUnresolvedCount();
- } catch (Exception e) {
- log.log(Level.SEVERE, "importXML:", e);
- throw new RuntimeException(e.getLocalizedMessage(), e);
- }
- }
-
- /**
- * Doit
- *
- * @return ""
- *
- */
- protected String doIt() throws Exception {
-
- X_AD_Package_Imp_Proc adPackageImp = new X_AD_Package_Imp_Proc(getCtx(),
- p_PackIn_ID, null);
-
- // clear cache of previous runs
- IDFinder.clearIDCache();
-
- // Create Target directory if required
- String packageDirectory = adPackageImp.getAD_Package_Dir();
- if (packageDirectory == null || packageDirectory.trim().length() == 0) {
- packageDirectory = Adempiere.getAdempiereHome();
- }
-
- String targetDirName = packageDirectory + File.separator + "packages";
- File targetDir = new File(targetDirName);
-
- if (!targetDir.exists()) {
- boolean success = targetDir.mkdirs();
- if (!success) {
- log.warning("Failed to create target directory. " + targetDirName);
- }
- }
-
- // Unzip package
- File zipFilepath = new File(adPackageImp.getAD_Package_Source());
- log.info("zipFilepath->" + zipFilepath);
- String PackageName = Zipper.getParentDir(zipFilepath);
- Zipper.unpackFile(zipFilepath, targetDir);
-
- String dict_file = packageDirectory + File.separator
- + "packages" + File.separator + PackageName + File.separator
- + "dict" + File.separator + "PackOut.xml";
-
- log.info("dict file->" + dict_file);
-
- if (adPackageImp.isAD_Override_Dict() == true)
- m_UpdateDictionary = true;
- else
- m_UpdateDictionary = false;
-
- m_Package_Dir = packageDirectory + File.separator
- + "packages" + File.separator + PackageName + File.separator;
-
- // call XML Handler
- String msg = importXML(dict_file, getCtx(), get_TrxName());
-
- // Generate Model Classes
- // globalqss - don't call Generate Model must be done manual
- // String args[] =
- // {IntPackIn.getAD_Package_Dir()+"/dbPort/src/org/compiere/model/",
- // "org.compiere.model","'U'"};
- // org.compiere.util.GenerateModel.main(args) ;
-
- return msg;
- } // doIt
-
- public String getPackageDirectory() {
- return m_Package_Dir;
- }
-
- public void setPackageDirectory(String packageDirectory) {
- m_Package_Dir = packageDirectory;
- }
-
- public String getDatabaseType() {
- return m_Database;
- }
-
- public boolean isUpdateDictionary() {
- return m_UpdateDictionary;
- }
-
- public void setUpdateDictionary(boolean updateDictionary) {
- m_UpdateDictionary = updateDictionary;
- }
-
- public byte[] readBlob(String fileName) throws IOException {
- byte[] data = null;
- File file = new File(m_Package_Dir+File.separator+"blobs"+File.separator, fileName);
- FileInputStream fis = null;
-
- try {
- fis = new FileInputStream(file);
- BufferedInputStream bis = new BufferedInputStream(fis);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- while (true) {
- int b = bis.read();
- if (b == -1)
- break;
- else
- baos.write(b);
- }
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException e) {}
- }
- }
- return data;
- }
-
- /***************************************************************************
- *
- * @param args
- * XMLfile host port db username password
- */
- public static void main(String[] args) {
- if (args.length < 1) {
- System.out
- .println("Please give the file name to read as first parameter.");
- System.exit(1);
- }
-
- String file = args[0];
- org.compiere.Adempiere.startup(true);
-
- // globalqss - added argument 8 to generate system sequences
- if (args.length > 8 && args[8].equals(Ini.P_ADEMPIERESYS)) {
- System.out.println("**** WARNING: Working with system sequences "
- + Ini.P_ADEMPIERESYS + " ****");
- Ini.setProperty(Ini.P_ADEMPIERESYS, true);
- }
-
- PackIn packIn = new PackIn();
- // org.compiere.Compiere.startupEnvironment(true);
- // Force connection if there are enough parameters. Else we work with
- // Compiere.properties
- if (args.length >= 6) {
- // CConnection cc = CConnection.get("PostgreSQL", args[1],
- // Integer.valueOf(args[2]).intValue(), args[5], args[3], args[4]);
- CConnection cc = CConnection.get();
- // System.out.println("DB Connect String1:"+cc.getDbName());
- packIn.m_Database = cc.getType();
- DB.setDBTarget(cc);
- }
-
- // Level.OFF, Level.SEVERE, Level.WARNING, Level.INFO,
- // Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST, Level.ALL
-
- Level logLevel = Level.FINER;
-
- switch (Integer.parseInt(args[6])) {
- case 1:
- logLevel = Level.OFF;
- break;
- case 2:
- logLevel = Level.SEVERE;
- break;
- case 3:
- logLevel = Level.WARNING;
- break;
- case 4:
- logLevel = Level.INFO;
- break;
- case 5:
- logLevel = Level.CONFIG;
- break;
- case 6:
- logLevel = Level.FINE;
- break;
- case 7:
- logLevel = Level.FINER;
- break;
- case 8:
- logLevel = Level.FINEST;
- break;
- case 9:
- logLevel = Level.ALL;
- break;
- }
- CLogMgt.setLevel(logLevel);
- CLogMgt.setLoggerLevel(logLevel, null);
-
- if (args.length >= 8)
- packIn.m_UpdateDictionary = Boolean.valueOf(args[7]);
-
- String trxName = Trx.createTrxName("PackIn");
- try {
- packIn.importXML(file, Env.getCtx(), trxName);
- Trx trx = Trx.get(trxName, false);
- if (trx != null)
- trx.commit(true);
- } catch (Exception e) {
- System.out.println("Import Failed: " + e.getLocalizedMessage());
- Trx trx = Trx.get(trxName, false);
- if (trx != null)
- trx.rollback();
- }
-
- System.exit(0);
- } // main
-} // PackIn
diff --git a/plugins/pipo/src/org/adempiere/pipo2/PackInHandler.java b/plugins/pipo/src/org/adempiere/pipo2/PackInHandler.java
deleted file mode 100644
index 4af9648883..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/PackInHandler.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- * *
- * Copyright (C) 2004 Marco LOMBARDO. lombardo@mayking.com *
- * Contributor: Robert KLEIN. robeklein@hotmail.com *
- * Contributor: Tim Heath *
- * Contributor: Low Heng Sin hengsin@avantz.com *
- *****************************************************************************/
-
-package org.adempiere.pipo2;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-import java.util.Stack;
-import java.util.logging.Level;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-
-import org.adempiere.pipo2.exception.DatabaseAccessException;
-import org.compiere.model.X_AD_Package_Imp;
-import org.compiere.model.X_AD_Package_Imp_Inst;
-import org.compiere.util.CLogger;
-import org.compiere.util.DB;
-import org.compiere.util.Env;
-import org.compiere.util.Trx;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * SAX Handler for parsing XML description of the GUI.
- *
- * @author Marco LOMBARDO, lombardo@mayking.com
- * @author Robert KLEIN, robeklein@hotmailo
- *
- * Contributor: William G. Heath - Import of workflows and dynamic validations
- */
-public class PackInHandler extends DefaultHandler {
-
- public static final String PACK_IN_PROCESS_CTX_KEY = "PackInProcess";
-
- /**
- * PackInHandler Handler
- */
- public PackInHandler () {
- setupHandlers();
- } // PackInHandler
-
- /** Set this if you want to update Dictionary */
- private boolean m_updateDictionary = false;
- private String packageDirectory = null;
- private int AD_Package_Imp_ID=0;
- private int AD_Package_Imp_Inst_ID=0;
- private CLogger log = CLogger.getCLogger(PackInHandler.class);
- private OutputStream logOutputStream = null;
- private TransformerHandler logDocument = null;
- private StreamResult loStreamResult = null;
- private SAXTransformerFactory transformerFactory = null;
- private Transformer logTransformer = null;
- private boolean isInit = false;
- private String logDate = null;
- private String packageStatus = "Installing";
- // transaction name
- private String m_trxName = null;
- private Properties m_ctx = null;
-
- private IHandlerRegistry handlerRegistry = null;
- private List defer = new ArrayList();
- private Stack stack = new Stack();
- private PackIn packIn;
- private int elementProcessed = 0;
-
- private void init() throws SAXException {
-
- packageDirectory = packIn.getPackageDirectory();
- m_updateDictionary = packIn.isUpdateDictionary();
- SimpleDateFormat formatter_file = new SimpleDateFormat("yyMMddHHmmssZ");
- SimpleDateFormat formatter_log = new SimpleDateFormat("MM/dd/yy HH:mm:ss");
- Date today = new Date();
- String fileDate = formatter_file.format(today);
- logDate = formatter_log.format(today);
-
- String logFileName = packageDirectory+File.separator+"doc"+File.separator+"Importlog_"+fileDate+".xml";
- log.info("packin log file="+logFileName);
- try {
- logOutputStream = new FileOutputStream (logFileName, false);
- } catch (FileNotFoundException e1) {
- log.warning ("Failed to create log file. error="+e1+" file="+logFileName);
- }
- loStreamResult = new StreamResult(logOutputStream);
- transformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
-
- try {
- logDocument = transformerFactory.newTransformerHandler();
- } catch (TransformerConfigurationException e2) {
- log.info ("startElement:"+e2);
- }
- logTransformer = logDocument.getTransformer();
- logTransformer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
- logTransformer.setOutputProperty(OutputKeys.INDENT,"yes");
- logDocument.setResult(loStreamResult);
- logDocument.startDocument();
- logDocument.processingInstruction("xml-stylesheet","type=\"text/css\" href=\"adempiereDocument.css\"");
- Properties tmp = new Properties();
- if (m_ctx != null)
- tmp.putAll(m_ctx);
- else
- tmp.putAll(Env.getCtx());
- m_ctx = tmp;
- if (m_trxName == null)
- m_trxName = Trx.createTrxName("PackIn");
-
- isInit=true;
- }
-
- private void setupHandlers() {
- handlerRegistry = new PropertyHandlerRegistry();
- }
-
- /**
- * Receive notification of the start of an element.
- *
- * @param uri namespace
- * @param localName simple name
- * @param qName qualified name
- * @param atts attributes
- * @throws org.xml.sax.SAXException
- */
- public void startElement (String uri, String localName, String qName, Attributes atts)
- throws org.xml.sax.SAXException {
-
- // Initialize the handler
- if (isInit == false){
- init();
- }
-
- // adempiereAD.
- if (qName.equals("adempiereAD"))
- {
- log.info("adempiereAD updateMode="+m_updateDictionary);
-
- createLogHeader(atts);
-
- // Update Summary Package History Table
-
- int PK_preInstalled=0;
-
- PreparedStatement pstmt = null;
- ResultSet rs = null;
- try {
- pstmt = DB.prepareStatement("SELECT AD_PACKAGE_IMP_INST_ID FROM AD_PACKAGE_IMP_INST WHERE NAME =? AND PK_VERSION =?", null);
- pstmt.setString(1,atts.getValue("Name"));
- pstmt.setString(2,atts.getValue("Version"));
- rs = pstmt.executeQuery();
-
- if (rs.next())
- {
- PK_preInstalled = rs.getInt(1);
- }
- } catch (Exception e) {
- throw new DatabaseAccessException(e);
- } finally {
- DB.close(rs, pstmt);
- }
-
- X_AD_Package_Imp packageImp = new X_AD_Package_Imp(m_ctx, 0, null);
- packageImp.setAD_Org_ID(Env.getAD_Org_ID(m_ctx));
- packageImp.setReleaseNo(atts.getValue("CompVer"));
- packageImp.setPK_Version(atts.getValue("Version"));
- packageImp.setVersion(atts.getValue("DataBase"));
- packageImp.setDescription(atts.getValue("Description").replaceAll("'","''"));
- packageImp.setName(atts.getValue("Name"));
- packageImp.setCreator(atts.getValue("Creator"));
- packageImp.setCreatorContact(atts.getValue("CreatorContact"));
- packageImp.setPK_Status(packageStatus);
-
- packageImp.saveEx();
- AD_Package_Imp_ID = packageImp.getAD_Package_Imp_ID();
-
- if ( PK_preInstalled == -1){
- //Insert Package into package install log
-
- X_AD_Package_Imp_Inst packageInst = new X_AD_Package_Imp_Inst(m_ctx, 0, null);
- packageInst.setAD_Org_ID(Env.getAD_Org_ID(m_ctx));
- packageInst.setReleaseNo(atts.getValue("CompVer"));
- packageInst.setPK_Version(atts.getValue("Version"));
- packageInst.setVersion(atts.getValue("DataBase"));
- packageInst.setDescription(atts.getValue("Description").replaceAll("'","''"));
- packageInst.setName(atts.getValue("Name"));
- packageInst.setCreator(atts.getValue("Creator"));
- packageInst.setCreatorContact(atts.getValue("CreatorContact"));
- packageInst.setPK_Status(packageStatus);
- packageInst.saveEx();
- AD_Package_Imp_Inst_ID = packageInst.get_ID();
- } else {
- //Update package list with package status
- AD_Package_Imp_Inst_ID = PK_preInstalled;
-
- X_AD_Package_Imp_Inst packageInst = new X_AD_Package_Imp_Inst(m_ctx, AD_Package_Imp_Inst_ID, null);
- packageInst.setPK_Status(packageStatus);
- packageInst.saveEx();
- }
-
- Env.setContext(m_ctx, "AD_Package_Imp_ID", AD_Package_Imp_ID);
- Env.setContext(m_ctx, "UpdateMode", m_updateDictionary);
- Env.setContext(m_ctx, "TrxName", m_trxName);
- Env.setContext(m_ctx, "PackageDirectory", packageDirectory);
- m_ctx.put("LogDocument", logDocument);
- m_ctx.put(PACK_IN_PROCESS_CTX_KEY, packIn);
- } else {
- Element e = new Element(uri, localName, qName, new AttributesImpl(atts));
- if (stack.size() > 0)
- {
- e.parent = stack.peek();
- String reference = atts.getValue("type");
- if (!IHandlerRegistry.ELEMENT_TYPE_PROPERTIES.equals(reference))
- {
- e.parent.childrens.add(e);
- }
- else
- {
- e.parent.properties.put(qName, e);
- }
- }
- stack.push(e);
- }
- } // startElement
-
- private void processElement(Element element) throws SAXException
- {
- ElementHandler handler = handlerRegistry.getHandler(element);
- if (handler != null)
- handler.startElement(m_ctx, element);
- if (element.defer)
- {
- defer.add(new DeferEntry(element, true));
- }
-
- for (Element childElement : element.childrens)
- {
- processElement(childElement);
- if (element.defer) {
- defer.add(new DeferEntry(element, false));
- } else {
- if (handler != null)
- handler.endElement(m_ctx, element);
- if (element.defer || element.deferEnd)
- defer.add(new DeferEntry(element, false));
- else if (!element.skip) {
- if (log.isLoggable(Level.INFO))
- log.info("Processed: " + element.getElementValue() + " - " + element.attributes.getValue(0));
- elementProcessed++;
- }
- }
- }
-
- }
-
- private void createLogHeader(Attributes atts) throws SAXException {
- AttributesImpl attsOut = new AttributesImpl();
- logDocument.startElement("","","adempiereDocument",attsOut);
- PackOut.addTextElement(logDocument, "header", atts.getValue("Name")+" Install Log", attsOut);
- PackOut.addTextElement(logDocument, "H3", "Package Name:", attsOut);
- PackOut.addTextElement(logDocument, "packagename4log", atts.getValue("Name"), attsOut);
- PackOut.addTextElement(logDocument, "H3", "Version:", attsOut);
- PackOut.addTextElement(logDocument, "Version", atts.getValue("Version"), attsOut);
- PackOut.addTextElement(logDocument, "H3", "Package Install Date:", attsOut);
- PackOut.addTextElement(logDocument, "installDate", logDate, attsOut);
- PackOut.addTextElement(logDocument, "H3", "Min. Version:", attsOut);
- PackOut.addTextElement(logDocument, "AdempiereVersion", atts.getValue("AdempiereVersion"), attsOut);
- PackOut.addTextElement(logDocument, "H3", "Min. Database Date:", attsOut);
- PackOut.addTextElement(logDocument, "Database", atts.getValue("Database"), attsOut);
- }
-
- /**
- * @see org.xml.sax.helpers.DefaultHandler#characters(char[], int, int)
- */
- @Override
- public void characters(char[] ch, int start, int length)
- throws SAXException {
- if (stack.size() > 0 && length > 0)
- {
- Element e = stack.peek();
- e.contents.append(ch, start, length);
- }
- }
-
- /**
- * Receive notification of the end of an element.
- * @param uri namespace
- * @param localName simple name
- * @param qName qualified name
- * @throws SAXException
- */
- public void endElement (String uri, String localName, String qName) throws SAXException {
- // Check namespace.
-
- String elementValue = null;
- if ("".equals (uri))
- elementValue = qName;
- else
- elementValue = uri + localName;
-
- if (elementValue.equals("adempiereAD")){
- processDeferElements();
- if (!packageStatus.equals("Completed with errors"))
- packageStatus = "Completed successfully";
-
- //Update package history log with package status
- X_AD_Package_Imp packageImp = new X_AD_Package_Imp(m_ctx, AD_Package_Imp_ID, null);
- packageImp.setPK_Status(packageStatus);
- packageImp.saveEx();
-
- //Update package list with package status
- X_AD_Package_Imp_Inst packageInst = new X_AD_Package_Imp_Inst(m_ctx, AD_Package_Imp_Inst_ID, null);
- packageInst.setPK_Status(packageStatus);
- packageInst.saveEx();
-
- logDocument.endElement("","","adempiereDocument");
- logDocument.endDocument();
- try {
- logOutputStream.close();
- }
- catch (Exception e)
- {}
-
- //reset
- setupHandlers();
- } else {
- Element e = stack.pop();
- if (stack.isEmpty())
- {
- processElement(e);
- }
- }
- } // endElement
-
- private void processDeferElements() throws SAXException {
-
- if (defer.isEmpty()) return;
-
- do {
- int startSize = defer.size();
- List tmp = new ArrayList(defer);
- defer.clear();
- for (DeferEntry d : tmp) {
- if (d.startElement) {
- d.element.defer = false;
- d.element.unresolved = "";
- d.element.pass++;
- } else {
- if (d.element.deferEnd) {
- d.element.deferEnd = false;
- d.element.unresolved = "";
- }
- }
- if (log.isLoggable(Level.INFO)) {
- log.info("Processeing Element: " + d.element.getElementValue() + " - "
- + d.element.attributes.getValue(0));
- }
- ElementHandler handler = handlerRegistry.getHandler(d.element);
- if (handler != null) {
- if (d.startElement)
- handler.startElement(m_ctx, d.element);
- else
- handler.endElement(m_ctx, d.element);
- }
- if (d.element.defer)
- defer.add(d);
- else if (!d.startElement) {
- if (d.element.deferEnd)
- defer.add(d);
- else {
- if (log.isLoggable(Level.INFO))
- log.info("Imported Defer Element: " + d.element.getElementValue() + " - "
- + d.element.attributes.getValue(0));
- elementProcessed++;
- }
- }
- }
- int endSize = defer.size();
- if (startSize == endSize) break;
- } while (defer.size() > 0);
- }
-
- // globalqss - add support for trx in 3.1.2
- public void set_TrxName(String trxName) {
- m_trxName = trxName;
- }
-
- // globalqss - add support for trx in 3.1.2
- public void setCtx(Properties ctx) {
- m_ctx = ctx;
- }
-
- /**
- * @param packIn
- */
- public void setProcess(PackIn packIn) {
- this.packIn = packIn;
- }
-
- /**
- * @return number of elements that processed successfully
- */
- public int getElementsProcessed() {
- return elementProcessed;
- }
-
- /**
- * @return number of unresolved elements
- */
- public int getUnresolvedCount() {
- int count = 0;
- if (defer != null && !defer.isEmpty()) {
- for(DeferEntry entry : defer) {
- if (!entry.startElement)
- count++;
- }
- }
- return count;
- }
-
- class DeferEntry {
- Element element;
- boolean startElement = false;
-
- DeferEntry(Element e, boolean b) {
- element = e;
- startElement = b;
- }
- }
-} // PackInHandler
diff --git a/plugins/pipo/src/org/adempiere/pipo2/PackOut.java b/plugins/pipo/src/org/adempiere/pipo2/PackOut.java
deleted file mode 100644
index 1b152aadac..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/PackOut.java
+++ /dev/null
@@ -1,472 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- * *
- * Copyright (C) *
- * 2004 Robert KLEIN. robeklein@hotmail.com *
- * Contributor(s): Low Heng Sin hengsin@avantz.com *
- * Teo Sarca teo.sarca@arhipac.ro, SC ARHIPAC SERVICE SRL *
- *****************************************************************************/
-package org.adempiere.pipo2;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-import java.util.Properties;
-import java.util.logging.Level;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-
-import org.compiere.model.I_AD_Form;
-import org.compiere.model.I_AD_ImpFormat;
-import org.compiere.model.I_AD_Menu;
-import org.compiere.model.I_AD_Message;
-import org.compiere.model.I_AD_PrintFormat;
-import org.compiere.model.I_AD_Process;
-import org.compiere.model.I_AD_Reference;
-import org.compiere.model.I_AD_ReportView;
-import org.compiere.model.I_AD_Role;
-import org.compiere.model.I_AD_Table;
-import org.compiere.model.I_AD_Val_Rule;
-import org.compiere.model.I_AD_Window;
-import org.compiere.model.I_AD_Workflow;
-import org.compiere.model.MClient;
-import org.compiere.model.MPackageExp;
-import org.compiere.model.MPackageExpDetail;
-import org.compiere.model.MTable;
-import org.compiere.model.Query;
-import org.compiere.model.X_AD_Package_Exp_Detail;
-import org.compiere.process.SvrProcess;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-import org.adempiere.exceptions.AdempiereException;
-
-/**
- * Convert AD to XML
- *
- * @author Robert Klein
- * @version $Id: PackOut.java,v 1.0
- *
- * Contributor: William G. Heath - Export of workflows and dynamic validations
- *
- * @author Teo Sarca, SC ARHIPAC SERVICE SRL
- * BF [ 1819315 ] PackOut: fix xml indentation not working
- * BF [ 1819319 ] PackOut: use just active AD_Package_Exp_Detail lines
- */
-
-public class PackOut extends SvrProcess
-{
- private static final String TRX_NAME_CTX_KEY = "TrxName";
- public static final String PACK_OUT_PROCESS_CTX_KEY = "PackOutProcess";
- /** Record ID */
- private int p_PackOut_ID = 0;
- private String PackOutVer = "005";
-
- public final static int MAX_OFFICIAL_ID = 999999;
-
- private Properties localContext = null;
- private MPackageExp packageExp;
- private MPackageExpDetail packageExpDetail;
- private String packOutDir;
- private String packageDir;
- private int blobCount = 0;
-
- private IHandlerRegistry handlerRegistry = null;
-
- /**
- * Prepare - e.g., get Parameters.
- */
- protected void prepare()
- {
- p_PackOut_ID = getRecord_ID();
- } // prepare
-
- public static void addTextElement(TransformerHandler handler, String qName, String text, AttributesImpl atts) throws SAXException {
- handler.startElement("", "", qName, atts);
- append(handler, text);
- handler.endElement("", "", qName);
- }
-
- private static void append(TransformerHandler handler, String str) throws SAXException
- {
- char[] contents = str != null ? str.toCharArray() : new char[0];
- handler.characters(contents,0,contents.length);
- }
-
- /**
- * Start the transformation to XML
- * @return info
- * @throws Exception
- */
-
- protected String doIt() throws java.lang.Exception
- {
- initContext();
-
- handlerRegistry = new PropertyHandlerRegistry();
-
- OutputStream packageDocStream = null;
- OutputStream packOutDocStream = null;
- log.info("doIt - AD_PACKAGE_EXP_ID=" + p_PackOut_ID);
-
- if (p_PackOut_ID == 0)
- throw new IllegalArgumentException("No Record");
-
- int processedCount = 0;
- try {
-
- packageExp = new MPackageExp(getCtx(), p_PackOut_ID, get_TrxName());
-
- if (packageExp.getAD_Package_Exp_ID() == p_PackOut_ID){
- //Create the package documentation
- packOutDir = packageExp.getFile_Directory().trim();
- if (!packOutDir.endsWith("/") && !packOutDir.endsWith("\\"))
- packOutDir+= File.separator;
- packageDir = packOutDir+ packageExp.getName();
- File packageDocDirFile = new File(packageDir+File.separator+"doc"+File.separator);
- if (!packageDocDirFile.exists()) {
- boolean success = packageDocDirFile.mkdirs();
- if (!success) {
- throw new AdempiereException("Failed to create directory for pack out. " + packageDir+File.separator+"doc"+File.separator);
- }
- }
- String docFileName = packageDir+File.separator+"doc"+File.separator+packageExp.getName()+"Doc.xml";
- packageDocStream = new FileOutputStream (docFileName, false);
- TransformerHandler packageDocument = createPackageDoc(packageExp, packageDocStream);
-
- String packOutFileName = packageDir+File.separator+ "dict"+File.separator+"PackOut.xml";
- packOutDocStream = new FileOutputStream (packOutFileName, false);
- TransformerHandler packOutDocument = createPackOutDoc(packageExp, packOutDocStream);
-
- Query query = new Query(getCtx(), MTable.get(getCtx(), X_AD_Package_Exp_Detail.Table_ID), "AD_Package_Exp_ID = ?", get_TrxName());
- List packageExpDetails = query.setOnlyActiveRecords(true)
- .setOrderBy("Line")
- .setParameters(new Object[]{p_PackOut_ID})
- .list();
- for(MPackageExpDetail dtl : packageExpDetails){
- packageExpDetail = dtl;
- String type = packageExpDetail.getType();
- log.info(Integer.toString(packageExpDetail.getLine()));
-
- ElementHandler handler = handlerRegistry.getHandler(getTypeName(type));
- if (handler != null)
- handler.packOut(this,packOutDocument,packageDocument,dtl.getExpRecordId());
- else
- throw new IllegalArgumentException("Packout handler not found for type " + type);
-
- processedCount++;
- }
-
- packOutDocument.endElement("","","adempiereAD");
- packOutDocument.endDocument();
- packageDocument.endElement("","","adempiereDocument");
- packageDocument.endDocument();
-
- }
- }
- catch (Exception e)
- {
- log.log(Level.SEVERE,e.getLocalizedMessage(), e);
- throw e;
- }
- finally
- {
- // Close streams - teo_sarca [ 1704762 ]
- if (packageDocStream != null)
- try {
- packageDocStream.close();
- } catch (Exception e) {}
- if (packOutDocStream != null)
- try {
- packOutDocStream.close();
- } catch (Exception e) {}
- }
-
- //create compressed packages
- //set the files
- File srcFolder = new File(packOutDir);
- File destZipFile = new File(packageDir+".zip");
-
- //delete the old packages if necessary
- destZipFile.delete();
-
- //create the compressed packages
- String includesdir = packageExp.getName() + File.separator +"**";
- Zipper.zipFolder(srcFolder, destZipFile, includesdir);
-
- return "Exported="+processedCount + " File=" + destZipFile.getAbsolutePath();
- } // doIt
-
- private TransformerHandler createPackOutDoc(MPackageExp packageExp,
- OutputStream packOutDocStream) throws UnsupportedEncodingException, TransformerConfigurationException, SAXException {
- StreamResult packOutStreamResult = new StreamResult(new OutputStreamWriter(packOutDocStream,"utf-8"));
- SAXTransformerFactory packOutFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
- packOutFactory.setAttribute("indent-number", new Integer(4));
- TransformerHandler packOutDocument = packOutFactory.newTransformerHandler();
- Transformer packOutTransformer = packOutDocument.getTransformer();
- packOutTransformer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
- packOutTransformer.setOutputProperty(OutputKeys.INDENT,"yes");
- packOutDocument.setResult(packOutStreamResult);
- packOutDocument.startDocument();
- AttributesImpl atts = new AttributesImpl();
- atts.addAttribute("","","Name","CDATA",packageExp.getName());
- atts.addAttribute("","","Version","CDATA",packageExp.getPK_Version());
- atts.addAttribute("","","AdempiereVersion","CDATA",packageExp.getReleaseNo());
- atts.addAttribute("","","DataBase","CDATA",packageExp.getVersion());
- atts.addAttribute("","","Description","CDATA",packageExp.getDescription());
- atts.addAttribute("","","Creator","CDATA",packageExp.getUserName());
- atts.addAttribute("","","CreatorContact","CDATA",packageExp.getEMail());
- atts.addAttribute("","","CreatedDate","CDATA",packageExp.getCreated().toString());
- atts.addAttribute("","","UpdatedDate","CDATA",packageExp.getUpdated().toString());
- atts.addAttribute("","","PackOutVersion","CDATA",PackOutVer);
-
- MClient client = MClient.get(localContext);
- StringBuffer sb = new StringBuffer ()
- .append(client.get_ID())
- .append("-")
- .append(client.getValue())
- .append("-")
- .append(client.getName());
- atts.addAttribute("", "", "Client", "CDATA", sb.toString());
-
- packOutDocument.startElement("","","adempiereAD",atts);
- return packOutDocument;
- }
-
- private TransformerHandler createPackageDoc(MPackageExp packageExp, OutputStream packageDocStream) throws UnsupportedEncodingException, TransformerConfigurationException, SAXException {
- StreamResult docStreamResult = new StreamResult(new OutputStreamWriter(packageDocStream,"utf-8"));
- SAXTransformerFactory transformerFactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
- transformerFactory.setAttribute("indent-number", new Integer(4));
- TransformerHandler packageDocument = transformerFactory.newTransformerHandler();
- Transformer transformer = packageDocument.getTransformer();
- transformer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
- transformer.setOutputProperty(OutputKeys.INDENT,"yes");
- packageDocument.setResult(docStreamResult);
- packageDocument.startDocument();
- packageDocument.processingInstruction("xml-stylesheet","type=\"text/css\" href=\"adempiereDocument.css\"");
- AttributesImpl atts = new AttributesImpl();
- packageDocument.startElement("","","adempiereDocument",atts);
- addTextElement(packageDocument, "header", packageExp.getName()+" Package Description", atts);
- addTextElement(packageDocument, "H1", "Package Name:", atts);
- addTextElement(packageDocument, "packagename", packageExp.getName(), atts);
- addTextElement(packageDocument, "H1", "Author:", atts);
- addTextElement(packageDocument, "creator", packageExp.getUserName(), atts);
- addTextElement(packageDocument, "H1", "Email Address:", atts);
- addTextElement(packageDocument, "creatorcontact", packageExp.getEMail(), atts);
- addTextElement(packageDocument, "H1", "Created:", atts);
- addTextElement(packageDocument, "createddate", packageExp.getCreated().toString(), atts);
- addTextElement(packageDocument, "H1", "Updated:", atts);
- addTextElement(packageDocument, "updateddate", packageExp.getUpdated().toString(), atts);
- addTextElement(packageDocument, "H1", "Description:", atts);
- addTextElement(packageDocument, "description", packageExp.getDescription(), atts);
- addTextElement(packageDocument, "H1", "Instructions:", atts);
- addTextElement(packageDocument, "instructions", packageExp.getInstructions(), atts);
- addTextElement(packageDocument, "H1", "Files in Package:", atts);
- addTextElement(packageDocument, "file", "File: PackOut.xml", atts);
- addTextElement(packageDocument, "filedirectory", "Directory: \\dict\\", atts);
- addTextElement(packageDocument, "filenotes", "Notes: Contains all application/object settings for package", atts);
-
- MClient client = MClient.get(localContext);
- StringBuffer sb = new StringBuffer ()
- .append(client.get_ID())
- .append("-")
- .append(client.getValue())
- .append("-")
- .append(client.getName());
- addTextElement(packageDocument, "H1", "Client:", atts);
- addTextElement(packageDocument, "Client", sb.toString(), atts);
-
- File packageDictDirFile = new File(packageDir+File.separator+ "dict"+File.separator);
- if (!packageDictDirFile.exists()) {
- boolean success = packageDictDirFile.mkdirs();
- if (!success)
- throw new AdempiereException("Failed to create directory. " + packageDir+File.separator+ "dict"+File.separator);
- }
- return packageDocument;
- }
-
- private String getTypeName(String type) {
- if (X_AD_Package_Exp_Detail.TYPE_ApplicationOrModule.equals(type))
- return I_AD_Menu.Table_Name;
- else if (X_AD_Package_Exp_Detail.TYPE_CodeSnipit.equals(type))
- return "Code_Snipit";
- else if (X_AD_Package_Exp_Detail.TYPE_Data.equals(type))
- return IHandlerRegistry.TABLE_GENERIC_HANDLER;
- else if (X_AD_Package_Exp_Detail.TYPE_DynamicValidationRule.equals(type))
- return I_AD_Val_Rule.Table_Name;
- else if (X_AD_Package_Exp_Detail.TYPE_File_CodeOrOther.equals(type))
- return "Dist_File";
- else if (X_AD_Package_Exp_Detail.TYPE_Form.equals(type))
- return I_AD_Form.Table_Name;
- else if (X_AD_Package_Exp_Detail.TYPE_ImportFormat.equals(type))
- return I_AD_ImpFormat.Table_Name;
- else if (X_AD_Package_Exp_Detail.TYPE_Message.equals(type))
- return I_AD_Message.Table_Name;
- else if (X_AD_Package_Exp_Detail.TYPE_PrintFormat.equals(type))
- return I_AD_PrintFormat.Table_Name;
- else if (X_AD_Package_Exp_Detail.TYPE_ProcessReport.equals(type))
- return I_AD_Process.Table_Name;
- else if (X_AD_Package_Exp_Detail.TYPE_Reference.equals(type))
- return I_AD_Reference.Table_Name;
- else if (X_AD_Package_Exp_Detail.TYPE_ReportView.equals(type))
- return I_AD_ReportView.Table_Name;
- else if (X_AD_Package_Exp_Detail.TYPE_Role.equals(type))
- return I_AD_Role.Table_Name;
- else if (X_AD_Package_Exp_Detail.TYPE_SQLStatement.equals(type))
- return "SQL_Statement";
- else if (X_AD_Package_Exp_Detail.TYPE_Table.equals(type))
- return I_AD_Table.Table_Name;
- else if (X_AD_Package_Exp_Detail.TYPE_Window.equals(type))
- return I_AD_Window.Table_Name;
- else if (X_AD_Package_Exp_Detail.TYPE_Workflow.equals(type))
- return I_AD_Workflow.Table_Name;
-
- return type;
- }
-
- private void initContext() {
- Properties tmp = new Properties();
- if (getCtx() != null)
- tmp.putAll(getCtx());
- tmp.put(TRX_NAME_CTX_KEY, get_TrxName());
- tmp.put(PACK_OUT_PROCESS_CTX_KEY, this);
- localContext = tmp;
- }
-
- /**
- * @param sourceName
- * @param destName
- */
- public void copyFile (String sourceName, String destName ) {
- InputStream source = null; // Stream for reading from the source file.
- OutputStream copy= null; // Stream for writing the copy.
- boolean force; // This is set to true if the "-f" option
- // is specified on the command line.
- int byteCount; // Number of bytes copied from the source file.
-
- force = true;
- try {
- source = new FileInputStream(sourceName);
- } catch (FileNotFoundException e) {
- System.out.println("Can't find file \"" + sourceName + "\".");
- return;
- }
-
- try {
- File file = new File(destName);
- if (file.exists() && force == false) {
- System.out.println("Output file exists. Use the -f option to replace it.");
- return;
- }
- try {
- copy = new FileOutputStream(destName, false);
- } catch (IOException e) {
- System.out.println("Can't open output file \""
- + destName + "\".");
- return;
- }
- byteCount = 0;
- try {
- while (true) {
- int data = source.read();
- if (data < 0)
- break;
- copy.write(data);
- byteCount++;
- }
- source.close();
- copy.close();
- System.out.println("Successfully copied " + byteCount + " bytes.");
- } catch (Exception e) {
- System.out.println("Error occurred while copying. "+ byteCount + " bytes copied.");
- System.out.println(e.toString());
- }
- } finally {
- if (source != null) {
- try {
- source.close();
- } catch (IOException e) {}
- }
- if (copy != null) {
- try {
- copy.close();
- } catch (IOException e) {}
- }
- }
- }
-
- @Override
- public Properties getCtx() {
- return localContext != null ? localContext : super.getCtx();
- }
-
- /**
- * @param data
- * @return
- * @throws IOException
- */
- public String writeBlob(byte[] data) throws IOException {
- blobCount++;
- String fileName = blobCount + ".dat";
- File path = new File(packageDir+File.separator+"blobs"+File.separator);
- path.mkdirs();
- File file = new File(path, fileName);
- FileOutputStream os = null;
- try {
- os = new FileOutputStream(file);
- os.write(data);
- os.flush();
- } finally {
- if (os != null) {
- try {
- os.close();
- } catch (IOException e) {}
- }
- }
- return fileName;
- }
-
- /**
- * @return MPackageExp
- */
- public MPackageExp getPackageExp() {
- return packageExp;
- }
-
- /**
- * @return MPackageExpDetail
- */
- public MPackageExpDetail getPackageExpDetail() {
- return packageExpDetail;
- }
-
- /**
- * @param name
- * @return ElementHandler
- */
- public ElementHandler getHandler(String name) {
- return handlerRegistry.getHandler(name);
- }
-} // PackOut
diff --git a/plugins/pipo/src/org/adempiere/pipo2/PackRoll.java b/plugins/pipo/src/org/adempiere/pipo2/PackRoll.java
deleted file mode 100644
index 5ad6cebbb1..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/PackRoll.java
+++ /dev/null
@@ -1,423 +0,0 @@
-
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Carlos Ruiz - globalqss
- *****************************************************************************/
-package org.adempiere.pipo2;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.List;
-import java.util.logging.Level;
-
-import org.compiere.model.MTable;
-import org.compiere.model.Query;
-import org.compiere.model.X_AD_Package_Imp_Backup;
-import org.compiere.model.X_AD_Package_Imp_Detail;
-import org.compiere.process.ProcessInfoParameter;
-import org.compiere.process.SvrProcess;
-import org.compiere.util.DB;
-import org.compiere.util.Env;
-
-/**
- * Reverse Package Install.
- *
- * @author Robert Klein
- *
- */
-public class PackRoll extends SvrProcess {
- /** Package from Record */
- private int m_AD_Package_Imp_ID = 0;
- private String m_Processing = null;
- StringBuffer sql = null;
- StringBuffer sqlB = null;
- String columnIDName = null;
- StringBuffer sqlC = null;
- StringBuffer sqlD = null;
-
- /**
- * Prepare - e.g., get Parameters.
- */
- protected void prepare() {
- ProcessInfoParameter[] para = getParameter();
- for (int i = 0; i < para.length; i++) {
- String name = para[i].getParameterName();
- if (para[i].getParameter() == null)
- ;
- else if (name.equals("Processing"))
- m_Processing = (String) para[i].getParameter();
- else
- log.log(Level.SEVERE, "prepare - Unknown Parameter: " + name);
- }
- m_AD_Package_Imp_ID = getRecord_ID();
- } // prepare
-
- /**
- * Perform process.
- *
- * @return Message (translated text)
- * @throws Exception
- * if not successful
- */
- protected String doIt() throws Exception
- {
-
- DB.executeUpdateEx("UPDATE AD_Package_Imp SET PK_Status = 'Uninstalling' WHERE AD_Package_Imp_ID = ?", new Object[]{m_AD_Package_Imp_ID}, get_TrxName());
-
- log.info("Starting Package Reversal");
- // select all records that are new or have been updated by package
- // install
- try {
- Query query = new Query(getCtx(), X_AD_Package_Imp_Detail.Table_Name, "AD_Package_Imp_ID=?", get_TrxName());
- List packageImpDetails = query.setParameters(new Object[]{m_AD_Package_Imp_ID}).list();
- for (X_AD_Package_Imp_Detail packageImpDetail : packageImpDetails) {
-
- if (packageImpDetail.getType().equals("file")) {
-
- Query query2 = new Query(getCtx(), X_AD_Package_Imp_Backup.Table_Name, "AD_Package_Imp_Detail_ID=? AND AD_Package_Imp_ID=?", get_TrxName());
- List backups = query2.setParameters(new Object[]{packageImpDetail.getAD_Package_Imp_Detail_ID(), packageImpDetail.getAD_Package_Imp_ID()}).list();
-
- for (X_AD_Package_Imp_Backup backup : backups) {
- if (backup.getAD_Package_Imp_Bck_Dir() != null
- && backup.getAD_Package_Imp_Org_Dir() != null) {
- copyFile(backup.getAD_Package_Imp_Bck_Dir(),backup.getAD_Package_Imp_Org_Dir());
- }
-
- // Update uninstall field for column
- backup.setUninstall(true);
- backup.saveEx();
-
- // Update uninstall field for record
- packageImpDetail.setUninstall(true);
- packageImpDetail.saveEx();
- }
-
- } else {
-
- String tableName = packageImpDetail.getTableName();
-
- int recordID = packageImpDetail.getAD_Original_ID();
-
- // determine if record is an update to the original
- // if record is an update then update record with backup
- // settings
- // else inactivate record
- if (packageImpDetail.getAction().equalsIgnoreCase("update")) {
- // select all backed up columns for the record
-
- try {
- Query query2 = new Query(getCtx(), X_AD_Package_Imp_Backup.Table_Name, "AD_Package_Imp_Detail_ID=? AND AD_Package_Imp_ID=?", get_TrxName());
- List backups = query2.setParameters(new Object[]{packageImpDetail.getAD_Package_Imp_Detail_ID(), packageImpDetail.getAD_Package_Imp_ID()}).list();
-
- String IsKey = null;
- String columnName = null;
-
- for (X_AD_Package_Imp_Backup backup : backups) {
-
- PreparedStatement pstmt =null;
- ResultSet rs=null;
- try {
- pstmt = DB.prepareStatement("SELECT IsKey,ColumnName FROM AD_Column WHERE AD_Column_ID = ?",get_TrxName());
- pstmt.setInt(1,backup.getAD_Column_ID());
- rs = pstmt.executeQuery();
- if(rs.next())
- {
- IsKey = rs.getString(1);
- columnName = rs.getString(2);
- }
- } finally {
- DB.close(rs, pstmt);
- }
- // Get Table value
- tableName = MTable.getTableName(getCtx(), backup.getAD_Table_ID());
-
- // Get Column Name
- // Adjust for Column reference table
- if (tableName.equals("AD_Ref_Table"))
- {
- columnIDName = "AD_Reference_ID";
- }
- else if (tableName.equals("AD_TreeNodeMM"))
- {
- columnIDName = "Node_ID";
- }
- else
- {
- columnIDName = tableName + "_ID";
- }
-
- // Update columns for record
- // TODO make process more efficient!
-
- if (IsKey.equals("Y")
- || columnName.startsWith("Created"))
- ; // ignore is a Key Column or if it
- // references a Created(By) Column
- // Update "Updated" field with current date
- else if (columnName.equals("Updated"))
- {
- // Format Date
- sqlC = new StringBuffer("UPDATE "
- + tableName + " SET " + columnName
- + " = SYSDATE WHERE "
- + columnIDName + " = " + recordID);
-
- DB.executeUpdateEx(sqlC.toString(), get_TrxName());
- // Update uninstall field
- backup.setUninstall(true);
- backup.saveEx();
- }
- // Update "UpdatedBy" field with current user
- else if (columnName.equals("UpdatedBy")) {
-
- sqlC = new StringBuffer("UPDATE "
- + tableName + " SET " + columnName
- + " = '"
- + Env.getAD_User_ID(Env.getCtx())
- + "' WHERE " + columnIDName + " = "
- + recordID);
- DB.executeUpdateEx(sqlC.toString(), get_TrxName());
- backup.setUninstall(true);
- backup.saveEx();
- }
- // Update all other fields with backup
- // information
- else {
- Object[] parameters = null;
- int v_AD_Reference_ID = backup.getAD_Reference_ID();
- // Update columns that are Strings adjusting
- // for single quotes
- if (v_AD_Reference_ID == 10
- || v_AD_Reference_ID == 14
- || v_AD_Reference_ID == 34
- || v_AD_Reference_ID == 17
- // Carlos Ruiz globalqss, special
- // treatment for EntityType
- // it's a Table reference but must
- // be treated as String
- || (v_AD_Reference_ID == 18 && columnName
- .equalsIgnoreCase("EntityType"))) {
- if (backup.getColValue().toString().equals("null")) {
- ;// Ignore null values
- } else {
- sqlC = new StringBuffer("UPDATE "
- + tableName
- + " SET "
- + columnName
- + " = ?"
- + " WHERE " + columnIDName
- + " = " + recordID);
- parameters = new Object[]{backup.getColValue()};
- }
- // Update true/false columns
- } else if (v_AD_Reference_ID == 20
- || v_AD_Reference_ID == 28) {
-
- sqlC = new StringBuffer("UPDATE "
- + tableName
- + " SET "
- + columnName
- + " = ? "
- + " WHERE "
- + columnIDName + " = "
- + recordID);
- parameters = new Object[]{backup.getColValue().equals("true") ? "Y" : "N"};
- }
- // Update columns that are Strings adjusting
- // for single quotes
- else if (v_AD_Reference_ID == 13
- || v_AD_Reference_ID == 18
- || v_AD_Reference_ID == 19
- || v_AD_Reference_ID == 21
- || v_AD_Reference_ID == 25
- || v_AD_Reference_ID == 27
- || v_AD_Reference_ID == 30
- || v_AD_Reference_ID == 31
- || v_AD_Reference_ID == 35)
- {
-
- sqlC = new StringBuffer("UPDATE "
- + tableName
- + " SET "
- + columnName
- + " = ?"
- + " WHERE " + columnIDName
- + " = " + recordID);
- parameters = new Object[]{backup.getColValue()};
- }
- // Update columns that are numbers
- else if (v_AD_Reference_ID == 11
- || v_AD_Reference_ID == 12
- || v_AD_Reference_ID == 22
- || v_AD_Reference_ID == 29)
- {
- sqlC = new StringBuffer("UPDATE "
- + tableName
- + " SET "
- + columnName
- + " = ?"
- + " WHERE " + columnIDName
- + " = " + recordID);
- parameters = new Object[]{backup.getColValue()};
- }
- // Update columns that are dates
- else if (v_AD_Reference_ID == 15
- || v_AD_Reference_ID == 16)
- // TODO Develop portable code to update
- // date columns
- ;// ignore
- else
- // 23-Binary, 24-Radio, 26-RowID,
- // 32-Image not supported
- ;// ignore
- // execute update
-
- if(sqlC!=null)
- {
- DB.executeUpdateEx(sqlC.toString(), parameters, get_TrxName());
- }
-
- // Update uninstall field for column
- backup.setUninstall(true);
- backup.saveEx();
-
- // Update uninstall field for record
- packageImpDetail.setUninstall(true);
- packageImpDetail.saveEx();
- }
- }
-
- } catch (Exception e) {
- log.log(Level.SEVERE, "doIt", e);
- //System.exit(0);
- }
- } // ********* Update Loop
- // Inactivate new records
- else if (packageImpDetail.getAction().equalsIgnoreCase("new")) {
- if (tableName.equals("AD_Ref_Table"))
- columnIDName = "AD_Reference_ID";
- else if (tableName.equals("AD_TreeNodeMM"))
- columnIDName = "Node_ID";
- else
- columnIDName = tableName + "_ID";
- sqlC=new StringBuffer(" UPDATE ")
- .append(tableName)
- .append(" SET IsActive = 'N' WHERE ")
- .append(columnIDName)
- .append(" = ? ");
- DB.executeUpdateEx(sqlC.toString(), new Object[]{recordID}, get_TrxName());
-
- // Update uninstall field for record
- packageImpDetail.setUninstall(true);
- packageImpDetail.saveEx();
- }
- }
-
- }
- } catch (Exception e) {
- log.log(Level.SEVERE, "doIt", e);
- }
-
- // Update uninstall field for package
- DB.executeUpdateEx("UPDATE AD_Package_Imp SET Uninstall = 'Y', PK_Status = 'Uninstalled' WHERE AD_Package_Imp_ID = ?", new Object[]{m_AD_Package_Imp_ID}, get_TrxName());
-
- log.info("Package Reversal Completed");
- return "";
- } // doIt
-
- /**
- * Open input file for processing
- *
- * @param String
- * file with path
- *
- */
- public FileInputStream OpenInputfile(String filePath) {
-
- FileInputStream fileTarget = null;
-
- try {
- fileTarget = new FileInputStream(filePath);
- } catch (FileNotFoundException e) {
- System.out.println("Can't find file ");
-
- return null;
- }
- return fileTarget;
- }
-
- /**
- * Open output file for processing
- *
- * @param String
- * file with path
- *
- */
- public OutputStream OpenOutputfile(String filePath) {
-
- OutputStream fileTarget = null;
-
- try {
- fileTarget = new FileOutputStream(filePath);
- } catch (FileNotFoundException e) {
- System.out.println("Can't find file ");
-
- return null;
- }
- return fileTarget;
- }
-
- /**
- * Copyfile
- *
- * @param String
- * file with path
- *
- */
- public int copyFile(String sourceFile, String targetFile) {
-
- OutputStream target = OpenOutputfile(targetFile);
- InputStream source = OpenInputfile(sourceFile);
-
- int byteCount = 0;
- int success = 0;
- try {
- while (true) {
- int data = source.read();
- if (data < 0)
- break;
- target.write(data);
- byteCount++;
- }
- source.close();
- target.close();
-
- System.out.println("Successfully copied " + byteCount + " bytes.");
- } catch (Exception e) {
- System.out.println("Error occurred while copying. " + byteCount
- + " bytes copied.");
- System.out.println(e.toString());
-
- success = -1;
- }
- return success;
- }
-
-} // PackRoll
diff --git a/plugins/pipo/src/org/adempiere/pipo2/PoExporter.java b/plugins/pipo/src/org/adempiere/pipo2/PoExporter.java
deleted file mode 100644
index 2af7887451..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/PoExporter.java
+++ /dev/null
@@ -1,321 +0,0 @@
-package org.adempiere.pipo2;
-
-import java.math.BigDecimal;
-import java.util.List;
-import java.util.Properties;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.exceptions.AdempiereException;
-import org.compiere.model.I_AD_Client;
-import org.compiere.model.I_AD_Org;
-import org.compiere.model.MTable;
-import org.compiere.model.PO;
-import org.compiere.model.POInfo;
-import org.compiere.util.CLogger;
-import org.compiere.util.DisplayType;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class PoExporter {
-
- private PO po = null;
-
- @SuppressWarnings("unused")
- private CLogger log = CLogger.getCLogger(getClass());
- private Properties ctx;
-
- private TransformerHandler transformerHandler;
-
- private void addTextElement(String qName, String text, AttributesImpl atts) {
- try {
- transformerHandler.startElement("", "", qName, atts);
- append(text);
- transformerHandler.endElement("", "", qName);
- } catch (SAXException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void append(String str) throws SAXException
- {
- char[] contents = str != null ? str.toCharArray() : new char[0];
- transformerHandler.characters(contents,0,contents.length);
- }
-
- /**
- * @param ctx
- * @param po
- */
- public PoExporter(Properties ctx, TransformerHandler handler, PO po){
- this.ctx = ctx;
- this.po = po;
- transformerHandler = handler;
- }
-
- /**
- *
- * @param name
- * @param value
- */
- public void addUnchecked(String name, String value, AttributesImpl atts){
- addTextElement(name, value, atts);
- }
-
- /**
- *
- * @param name
- * @param stringValue
- * @param atts
- */
- public void addString(String name, String stringValue, AttributesImpl atts){
- addString(name, stringValue, "", atts);
- }
-
- /**
- *
- * @param name
- * @param defaultValue
- * @param stringValue
- */
- public void addString(String name, String stringValue, String defaultValue, AttributesImpl atts){
- addTextElement(name, stringValue != null ? stringValue : defaultValue, atts);
- }
-
- /**
- *
- * @param name
- * @param boolValue
- */
- public void addBoolean(String name, boolean boolValue, AttributesImpl atts){
- addTextElement(name, boolValue == true ? "true" : "false", atts);
- }
-
-
- /**
- *
- * @param name
- * @param columnName
- */
- public void add(String columnName, AttributesImpl atts) {
- add(columnName, "", atts);
- }
-
- /**
- *
- * @param name
- * @param columnName
- * @param defaultValue
- */
- public void add(String columnName, String defaultValue, AttributesImpl atts) {
- Object value = po.get_Value(columnName);
-
- if(value == null){
- addTextElement(columnName, defaultValue, atts);
- return;
- }
-
- if(value instanceof String){
- addTextElement(columnName, (String)value, atts);
- } else if(value instanceof Boolean) {
- addTextElement(columnName, (Boolean)value == true ? "true" : "false", atts);
- } else if(value instanceof Integer) {
- addTextElement(columnName, value.toString(), atts);
- } else if(value instanceof BigDecimal) {
- addTextElement(columnName, value.toString(), atts);
- } else{
- addTextElement(columnName, value.toString(), atts);
- }
- }
-
- /**
- * @param columnName
- * @param defaultValue
- */
- public void add(String columnName, boolean defaultValue, AttributesImpl atts) {
- Object oo = po.get_Value(columnName);
- boolean value = defaultValue;
- if (oo != null)
- {
- if (oo instanceof Boolean)
- value = ((Boolean)oo).booleanValue();
- else
- value = "Y".equals(oo);
- }
- addBoolean(columnName, value, atts);
- }
-
- /**
- *
- *
- */
- public void addIsActive(AttributesImpl atts){
- addTextElement("IsActive", (Boolean)po.isActive() == true ? "true" : "false", atts);
- }
-
- public void addTableReference(String tableName, String searchColumn, AttributesImpl atts) {
- String columnName = tableName + "_ID";
- addTableReference(columnName, tableName, searchColumn, atts);
- }
-
- public void addTableReference(String columnName, String tableName, String searchColumn, AttributesImpl atts) {
- int id = po.get_Value(columnName) != null ? (Integer)po.get_Value(columnName) : 0;
- addTableReference(columnName, tableName, searchColumn, id, atts);
- }
-
- public void addTableReference(String columnName, String tableName, String searchColumn, int id, AttributesImpl atts) {
- String value = ReferenceUtils.getTableReference(tableName, searchColumn, id, atts);
- addString(columnName, value, atts);
- }
-
- public void export(List excludes) {
- export(excludes, false);
- }
-
- public void export(List excludes, boolean preservedOrg) {
- POInfo info = POInfo.getPOInfo(po.getCtx(), po.get_Table_ID());
- int count = info.getColumnCount();
- //special treatment for ad_org_id
- int AD_Client_ID = po.getAD_Client_ID();
- if (AD_Client_ID == 0)
- {
- addString("AD_Org_ID", "0", new AttributesImpl());
- }
- else
- {
- int AD_Org_ID = po.getAD_Org_ID();
- if (AD_Org_ID == 0)
- {
- addString("AD_Org_ID", "0", new AttributesImpl());
- }
- else
- {
- if (!preservedOrg)
- addString("AD_Org_ID", "@AD_Org_ID@", new AttributesImpl());
- else {
- addTableReference(I_AD_Client.Table_Name, I_AD_Client.COLUMNNAME_Value, new AttributesImpl());
- addTableReference(I_AD_Org.Table_Name, I_AD_Org.COLUMNNAME_Value, new AttributesImpl());
- }
- }
- }
-
- for(int i = 0; i < count; i++) {
- String columnName = info.getColumnName(i);
- if (excludes != null) {
- boolean exclude = false;
- for(String ex : excludes)
- {
- if (ex.equalsIgnoreCase(columnName))
- {
- exclude = true;
- break;
- }
- }
- if (exclude)
- continue;
- }
-
- int displayType = info.getColumnDisplayType(i);
- if (DisplayType.YesNo == displayType) {
- add(columnName, false, new AttributesImpl());
- } else if (DisplayType.TableDir == displayType || DisplayType.ID == displayType) {
- String tableName = null;
- String searchColumn = null;
- if ("Record_ID".equalsIgnoreCase(columnName) && po.get_ColumnIndex("AD_Table_ID") >= 0) {
- int AD_Table_ID = po.get_Value(po.get_ColumnIndex("AD_Table_ID")) != null
- ? (Integer)po.get_Value(po.get_ColumnIndex("AD_Table_ID")) : 0;
- tableName = MTable.getTableName(ctx, AD_Table_ID);
- searchColumn = tableName + "_ID";
- } else {
- //remove _ID
- searchColumn = columnName;
- tableName = columnName.substring(0, columnName.length() - 3);
- if (tableName.equalsIgnoreCase("ad_table")) {
- searchColumn = "TableName";
- } else if (tableName.equalsIgnoreCase("ad_column")) {
- searchColumn = "ColumnName";
- }
- }
- if (searchColumn.endsWith("_ID")) {
- int AD_Table_ID = MTable.getTable_ID(tableName);
- POInfo pInfo = POInfo.getPOInfo(po.getCtx(), AD_Table_ID);
- if (pInfo.getColumnIndex("Value") >= 0) {
- searchColumn = "Value";
- } else if (pInfo.getColumnIndex("Name") >= 0) {
- searchColumn = "Name";
- } else if (pInfo.getColumnIndex("DocumentNo") >= 0) {
- searchColumn = "DocumentNo";
- }
- }
- addTableReference(columnName, tableName, searchColumn, new AttributesImpl());
- } else if (DisplayType.List == displayType) {
- add(columnName, "", new AttributesImpl());
- } else if (DisplayType.isLookup(displayType)) {
- String searchColumn = null;
- String tableName = null;
- if ("Record_ID".equalsIgnoreCase(columnName) && po.get_ColumnIndex("AD_Table_ID") >= 0) {
- int AD_Table_ID = po.get_Value(po.get_ColumnIndex("AD_Table_ID")) != null
- ? (Integer)po.get_Value(po.get_ColumnIndex("AD_Table_ID")) : 0;
- tableName = MTable.getTableName(ctx, AD_Table_ID);
- searchColumn = tableName + "_ID";
- } else if (info.getColumnLookup(i) != null){
- searchColumn = info.getColumnLookup(i).getColumnName();
- tableName = searchColumn.substring(0, searchColumn.indexOf("."));
- searchColumn = searchColumn.substring(searchColumn.indexOf(".")+1);
- } else {
- searchColumn = columnName;
- }
- if (searchColumn.endsWith("_ID")) {
- if (tableName.equalsIgnoreCase("ad_table")) {
- searchColumn = "TableName";
- } else if (tableName.equalsIgnoreCase("ad_column")){
- searchColumn = "ColumnName";
- } else {
- int AD_Table_ID = MTable.getTable_ID(tableName);
- POInfo pInfo = POInfo.getPOInfo(po.getCtx(), AD_Table_ID);
- if (pInfo.getColumnIndex("Value") >= 0) {
- searchColumn = "Value";
- } else if (pInfo.getColumnIndex("Name") >= 0) {
- searchColumn = "Name";
- } else if (pInfo.getColumnIndex("DocumentNo") >= 0) {
- searchColumn = "DocumentNo";
- }
- }
- }
- addTableReference(columnName, tableName, searchColumn, new AttributesImpl());
- } else if (DisplayType.isLOB(displayType)) {
- addBlob(columnName);
- } else {
- add(columnName, "", new AttributesImpl());
- }
- }
- }
-
- public void addBlob(String columnName) {
- Object value = po.get_Value(columnName);
- if (value == null) {
- addString(columnName, "", new AttributesImpl());
- return;
- }
-
- PackOut packOut = (PackOut) ctx.get(PackOut.PACK_OUT_PROCESS_CTX_KEY);
- byte[] data = null;
- String dataType = null;
- String fileName = null;
- try {
- if (value instanceof String) {
- data = ((String)value).getBytes("UTF-8");
- dataType = "string";
- } else {
- data = (byte[]) value;
- dataType = "byte[]";
- }
-
- fileName = packOut.writeBlob(data);
- } catch (Exception e) {
- throw new AdempiereException(e.getLocalizedMessage(), e);
- }
-
- addString(columnName, fileName + "|" + dataType, new AttributesImpl());
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/PoFiller.java b/plugins/pipo/src/org/adempiere/pipo2/PoFiller.java
deleted file mode 100644
index 4f3851739a..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/PoFiller.java
+++ /dev/null
@@ -1,251 +0,0 @@
-package org.adempiere.pipo2;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import org.adempiere.exceptions.AdempiereException;
-import org.compiere.model.PO;
-import org.compiere.model.POInfo;
-import org.compiere.util.DisplayType;
-import org.compiere.util.Env;
-
-public class PoFiller{
-
- PO po = null;
- private AbstractElementHandler handler;
- private Properties ctx;
- private Element element;
-
- /**
- *
- * @param po
- * @param atts
- * @param handler
- */
- public PoFiller(Properties ctx, PO po, Element element, AbstractElementHandler handler){
-
- this.ctx = ctx;
- this.po = po;
- this.element = element;
- this.handler = handler;
- }
-
- /**
- *
- * @param columnName
- */
- public void setString(String columnName){
-
- Element e = element.properties.get(columnName);
- String value = e != null ? e.contents.toString() : null;
-
- value = "".equals(value) ? null : value;
-
- po.set_ValueOfColumn(columnName, value);
- }
-
- /**
- *
- * @param columnName
- */
- public void setBoolean(String columnName){
-
- Element e = element.properties.get(columnName);
- String value = e != null ? e.contents.toString() : null;
-
- boolean bool = "true".equals(value) ? true : false;
-
- po.set_ValueOfColumn(columnName, bool);
- }
-
- /**
- *
- * @param qName
- */
- public void setTimestamp(String qName) {
- Element e = element.properties.get(qName);
- String value = e != null ? e.contents.toString() : null;
-
- if (value.trim().length() == 0)
- value = null;
- Timestamp ts = value != null ? Timestamp.valueOf(value) : null;
-
- po.set_ValueOfColumn(qName, ts);
- }
-
- /**
- *
- * @param qName
- */
- public void setInteger(String qName) {
- Element e = element.properties.get(qName);
- String value = e != null ? e.contents.toString() : null;
-
- if (value.trim().length() == 0)
- value = null;
- Integer i = value != null ? new Integer(value) : null;
-
- po.set_ValueOfColumn(qName, i);
- }
-
- /**
- *
- * @param qName
- */
- public void setBigDecimal(String qName) {
- Element e = element.properties.get(qName);
- String value = e != null ? e.contents.toString() : null;
-
- if (value.trim().length() == 0)
- value = null;
- BigDecimal bd = value != null ? new BigDecimal(value) : null;
-
- po.set_ValueOfColumn(qName, bd);
- }
-
- public static int findTableReference(Properties ctx, AbstractElementHandler handler, Element element, String qName) {
- Element propertyElement = element.properties.get(qName);
- if (propertyElement == null)
- return 0;
-
- int id = 0;
- String value = propertyElement.contents.toString();
- if (value != null && value.trim().length() > 0)
- {
- String[] names = qName.split("[.]");
- if (names.length < 2)
- return 0;
- String columnName = names[0];
- if (names.length != 3)
- columnName = columnName + "_ID";
- String tableName = names.length == 3 ? names[1] : names[0];
- String searchColumn = names.length == 3 ? names[2] : names[1];
-
- id = handler.findIdByColumn(ctx, tableName, searchColumn, value.trim());
- }
- return id;
- }
-
- /**
- *
- * @param qName
- */
- public int setTableReference(String qName) {
- Element e = element.properties.get(qName);
- if (e == null)
- return 0;
-
- String value = e.contents.toString();
- String columnName = qName;
- if (value != null && value.trim().length() > 0) {
- int id = ReferenceUtils.resolveReference(ctx, e);
- if (columnName.equals("AD_Client_ID") && id > 0) {
- if (id != Env.getAD_Client_ID(ctx)) {
- return -1;
- }
- }
- if (po.get_ColumnIndex(columnName) >= 0) {
- if (id > 0) {
- po.set_ValueOfColumn(columnName, id);
- return id;
- }
- return -1;
- } else {
- return 0;
- }
- } else {
- return 0;
- }
- }
-
- /**
- * process all attributes
- * @param excludes list of attribute to exclude
- */
- public List autoFill(List excludes) {
- POInfo info = POInfo.getPOInfo(po.getCtx(), po.get_Table_ID());
- ListnotFounds = new ArrayList();
-
- //special treatment for ad_org_id
- Element orgElement = element.properties.get("AD_Org_ID");
- String sAD_Org_ID = orgElement != null ? orgElement.contents.toString() : null;
- if (sAD_Org_ID != null && sAD_Org_ID.equals("0"))
- po.setAD_Org_ID(0);
- else if (sAD_Org_ID != null && sAD_Org_ID.equals("@AD_Org_ID@"))
- po.setAD_Org_ID(Env.getAD_Org_ID(ctx));
- else {
- if (setTableReference("AD_Client_ID") >= 0)
- setTableReference("AD_Org_ID");
- }
-
- for(String qName : element.properties.keySet()) {
- if (excludes != null ){
- boolean exclude = false;
- for(String ex : excludes)
- {
- if (ex.equalsIgnoreCase(qName))
- {
- exclude = true;
- break;
- }
- }
- if (exclude)
- continue;
- }
- Element e = element.properties.get(qName);
- if ("table".equalsIgnoreCase(e.attributes.getValue("reference"))) {
- int id = setTableReference(qName);
- if (id < 0) {
- notFounds.add(qName);
- }
- } else {
- int index = info.getColumnIndex(qName);
- if (index < 0)
- continue;
- if (info.getColumnClass(index) == Boolean.class) {
- setBoolean(qName);
- } else if (info.getColumnClass(index) == BigDecimal.class){
- setBigDecimal(qName);
- } else if (info.getColumnClass(index) == Integer.class) {
- setInteger(qName);
- } else if (info.getColumnClass(index) == Timestamp.class) {
- setTimestamp(qName);
- } else if (DisplayType.isLOB(info.getColumnDisplayType(index))) {
- setBlob(qName);
- } else {
- setString(qName);
- }
- }
- }
- return notFounds;
- }
-
- private void setBlob(String qName) {
- Element pe = element.properties.get(qName);
- String value = pe != null ? pe.contents.toString() : null;
- Object data = null;
- if (value != null && value.trim().length() > 0) {
- String[] component = value.split("[|]");
- if (component.length == 2) {
- String fileName = component[0];
- String dataType = component[1];
- PackIn packIn = handler.getPackInProcess(ctx);
- try {
- byte[] bytes = packIn.readBlob(fileName);
- if ("byte[]".equals(dataType)) {
- data = bytes;
- } else {
- data = new String(bytes, "UTF-8");
- }
- } catch (IOException e) {
- throw new AdempiereException(e.getLocalizedMessage(), e);
- }
- }
- }
- po.set_ValueOfColumn(qName, data);
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/PropertyHandlerRegistry.java b/plugins/pipo/src/org/adempiere/pipo2/PropertyHandlerRegistry.java
deleted file mode 100644
index 31161a1fa3..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/PropertyHandlerRegistry.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- *
- */
-package org.adempiere.pipo2;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-import org.adempiere.exceptions.AdempiereException;
-import org.adempiere.pipo2.handler.CommonTranslationHandler;
-import org.adempiere.pipo2.handler.GenericPOElementHandler;
-
-/**
- * @author hengsin
- *
- */
-public class PropertyHandlerRegistry implements IHandlerRegistry {
-
- private static Properties handlerRegistry;
-
- static {
- handlerRegistry = new Properties();
- try {
- handlerRegistry.load((PackInHandler.class.getResourceAsStream("pipo-handler.properties")));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- private Maphandlers = null;
-
- /**
- * default constructor
- */
- public PropertyHandlerRegistry() {
- handlers = new HashMap();
- handlers.put(TABLE_GENERIC_HANDLER, new GenericPOElementHandler());
- handlers.put(TABLE_TRANSLATION_HANDLER, new CommonTranslationHandler());
- }
-
- /**
- * @see org.adempiere.pipo2.IHandlerRegistry#getHandler(org.adempiere.pipo2.Element)
- */
- @Override
- public ElementHandler getHandler(Element element) {
- ElementHandler handler = null;
- String type = element.attributes.getValue("type");
- if (ELEMENT_TYPE_TRANSLATION.equals(type))
- handler = handlers.get(TABLE_TRANSLATION_HANDLER);
- else
- handler = handlers.get(element.getElementValue());
- if (handler == null)
- {
- String className = handlerRegistry.getProperty(element.getElementValue());
- if (className != null)
- {
- try
- {
- Class> clazz = getClass().getClassLoader().loadClass(className);
- handler = (ElementHandler) clazz.newInstance();
- }
- catch (Exception e)
- {
- throw new AdempiereException(e.getLocalizedMessage(), e);
- }
- handlers.put(element.getElementValue(), handler);
- }
- else
- {
- handler = handlers.get(TABLE_GENERIC_HANDLER);
- }
- }
- return handler;
- }
-
- /**
- * @see org.adempiere.pipo2.IHandlerRegistry#getHandler(java.lang.String)
- */
- @Override
- public ElementHandler getHandler(String name) {
- String className = handlerRegistry.getProperty(name);
- ElementHandler handler = className != null ? handlers.get(className) : null;
- if (handler == null && className != null)
- {
- try
- {
- Class> clazz = getClass().getClassLoader().loadClass(className);
- handler = (ElementHandler)clazz.newInstance();
- handlers.put(className, handler);
- } catch (Exception e)
- {
- throw new AdempiereException(e.getLocalizedMessage(), e);
- }
- }
- return handler;
- }
-
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/ReferenceUtils.java b/plugins/pipo/src/org/adempiere/pipo2/ReferenceUtils.java
deleted file mode 100644
index cfa9c1ed04..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/ReferenceUtils.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package org.adempiere.pipo2;
-
-import java.util.Properties;
-
-import org.compiere.model.MTable;
-import org.compiere.util.DB;
-import org.compiere.util.Env;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class ReferenceUtils {
-
- public static int resolveReference(Properties ctx, Element e)
- {
- String value = e.contents.toString();
- String referenceKey = e.attributes.getValue("reference-key");
- if (value != null && value.trim().length() > 0)
- {
- if (isTableLookup(e))
- {
- String[] names = referenceKey.split("[.]");
- if (names.length < 2)
- return 0;
- String tableName = names[0];
- String searchColumn = names[1];
-
- return IDFinder.findIdByColumn(tableName, searchColumn, value.trim(), Env.getAD_Client_ID(ctx), null);
- }
- else if (isIDLookup(e))
- {
- int id = Integer.parseInt(value);
- return id;
- }
- else if (isUUIDLookup(e))
- {
- return IDFinder.findIdByColumn(referenceKey, referenceKey + "_UU", value.trim(), Env.getAD_Client_ID(ctx), null);
- }
- else
- {
- throw new IllegalArgumentException("Unknown table reference type="+e.attributes.getValue("reference"));
- }
- }
- else
- {
- return 0;
- }
- }
-
- public static boolean isLookup(Element element)
- {
- if (isIDLookup(element) || isUUIDLookup(element) || isTableLookup(element))
- return true;
- else
- return false;
- }
-
- public static boolean isIDLookup(Element element)
- {
- return "id".equals(element.properties.get("reference"));
- }
-
- public static boolean isUUIDLookup(Element element)
- {
- return "uuid".equals(element.properties.get("reference"));
- }
-
- public static boolean isTableLookup(Element element)
- {
- return "table".equals(element.properties.get("reference"));
- }
-
- public static String getTableReference(String tableName, String searchColumn, int id, AttributesImpl atts)
- {
- String keyColumn = tableName + "_ID";
- String sql = "SELECT " + searchColumn + " FROM "
- + tableName + " WHERE " + keyColumn + " = ?";
- if (id > 0 && id <= PackOut.MAX_OFFICIAL_ID)
- {
- atts.addAttribute("", "", "reference", "CDATA", "id");
- String value = Integer.toString(id);
- return value;
- }
- else if (id == 0)
- {
- atts.addAttribute("", "", "reference", "CDATA", "id");
- return "";
- }
- else
- {
- MTable table = MTable.get(Env.getCtx(), tableName);
- if (table.get_ColumnIndex(tableName + "_UU") >= 0 )
- {
- sql = "SELECT " + tableName + "_UU" + " FROM "
- + tableName + " WHERE " + keyColumn + " = ?";
- String value = DB.getSQLValueString(null, sql, id);
- if (value != null && value.trim().length() > 0)
- {
- atts.addAttribute("", "", "reference", "CDATA", "uuid");
- atts.addAttribute("", "", "reference-key", "CDATA", tableName);
- return value.trim();
- }
- }
-
- String value = DB.getSQLValueString(null, sql, id);
- StringBuffer buffer = new StringBuffer();
- buffer.append(tableName).append(".").append(searchColumn);
- atts.addAttribute("", "", "reference", "CDATA", "table");
- atts.addAttribute("", "", "reference-key", "CDATA", buffer.toString());
- return value;
- }
- }
-}
-
-
diff --git a/plugins/pipo/src/org/adempiere/pipo2/Zipper.java b/plugins/pipo/src/org/adempiere/pipo2/Zipper.java
deleted file mode 100644
index be9ca8b5f8..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/Zipper.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * _____________________________________________
- *****************************************************************************/
-package org.adempiere.pipo2;
-
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Target;
-import org.apache.tools.ant.taskdefs.Expand;
-import org.apache.tools.ant.taskdefs.GZip;
-import org.apache.tools.ant.taskdefs.Tar;
-import org.apache.tools.ant.taskdefs.Zip;
-/**
- * Compress package
- *
- * @author Rob Klein
- * @version $Id: ImportFAJournal2.java,v 1.0 $
- *
- */
-public class Zipper {
-
-
- /**
- * Zip the srcFolder into the destFileZipFile. All the folder subtree of the src folder is added to the destZipFile
- * archive.
- *
- *
- * @param srcFolder File, the path of the srcFolder
- * @param destZipFile File, the path of the destination zipFile. This file will be created or erased.
- */
- static public void zipFolder(File srcFolder, File destZipFile, String includesdir)
- {
- Zip zipper = new Zip();
- zipper.setDestFile(destZipFile);
- zipper.setBasedir(srcFolder);
- zipper.setIncludes(includesdir.replace(" ", "*"));
- zipper.setUpdate(true);
- zipper.setCompress(true);
- zipper.setCaseSensitive(false);
- zipper.setFilesonly(false);
- zipper.setTaskName("zip");
- zipper.setTaskType("zip");
- zipper.setProject(new Project());
- zipper.setOwningTarget(new Target());
- zipper.execute();
- System.out.println(destZipFile);
- }
- static public void tarFolder(File srcFolder, File destTarFile, String includesdir)
- {
- Tar tarer = new Tar();
- tarer.setDestFile(destTarFile);
- tarer.setBasedir(srcFolder);
- tarer.setIncludes(includesdir);
- tarer.setCaseSensitive(false);
- tarer.setTaskName("tar");
- tarer.setTaskType("tar");
- tarer.setProject(new Project());
- tarer.setOwningTarget(new Target());
- tarer.execute();
- }
- static public void gzipFile(File srcFile, File destFile)
- {
- GZip GZiper = new GZip();
- GZiper.setDestfile(destFile);
- GZiper.setSrc(srcFile);
- GZiper.setTaskName("gzip");
- GZiper.setTaskType("gzip");
- GZiper.setProject(new Project());
- GZiper.setOwningTarget(new Target());
- GZiper.execute();
- }
- static public void unpackFile(File zipFilepath, File destinationDir)
- {
- Expand Unzipper = new Expand();
- Unzipper.setDest(destinationDir);
- Unzipper.setSrc(zipFilepath);
- Unzipper.setTaskType ("unzip");
- Unzipper.setTaskName ("unzip");
- Unzipper.setProject(new Project());
- Unzipper.setOwningTarget(new Target());
- Unzipper.execute();
- }
- static public String getParentDir(File zipFilepath)
- {
- try {
- ZipFile zipFile = new ZipFile(zipFilepath);
- Enumeration extends ZipEntry> entries = zipFile.entries();
- ZipEntry entry = entries.nextElement();
- File tempfile = new File(entry.getName());
- while (tempfile.getParent()!=null)
- tempfile = tempfile.getParentFile();
- return tempfile.getName();
- } catch (IOException ioe) {
- System.err.println("Unhandled exception:");
- ioe.printStackTrace();
- return "";
- }
- }
- }// CreateZipFile
-
-
diff --git a/plugins/pipo/src/org/adempiere/pipo2/exception/DatabaseAccessException.java b/plugins/pipo/src/org/adempiere/pipo2/exception/DatabaseAccessException.java
deleted file mode 100644
index 07269f5c4e..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/exception/DatabaseAccessException.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package org.adempiere.pipo2.exception;
-
-public class DatabaseAccessException extends RuntimeException {
-
- /**
- *
- */
- private static final long serialVersionUID = -8834711100842625706L;
-
- public DatabaseAccessException() {
- super();
- }
-
- public DatabaseAccessException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public DatabaseAccessException(String message) {
- super(message);
- }
-
- public DatabaseAccessException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/exception/POSaveFailedException.java b/plugins/pipo/src/org/adempiere/pipo2/exception/POSaveFailedException.java
deleted file mode 100644
index ea5699c852..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/exception/POSaveFailedException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.adempiere.pipo2.exception;
-
-public class POSaveFailedException extends RuntimeException {
-
- /**
- *
- */
- private static final long serialVersionUID = 8325708851137221459L;
-
- public POSaveFailedException() {
- super();
- }
-
- public POSaveFailedException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public POSaveFailedException(String message) {
- super(message);
- }
-
- public POSaveFailedException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/handler/AdElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/handler/AdElementHandler.java
deleted file mode 100644
index 612ae824a0..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/handler/AdElementHandler.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Low Heng Sin hengsin@avantz.com
- *****************************************************************************/
-package org.adempiere.pipo2.handler;
-
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.pipo2.AbstractElementHandler;
-import org.adempiere.pipo2.PoExporter;
-import org.adempiere.pipo2.Element;
-import org.adempiere.pipo2.PackOut;
-import org.adempiere.pipo2.PoFiller;
-import org.adempiere.pipo2.exception.POSaveFailedException;
-import org.compiere.model.M_Element;
-import org.compiere.model.X_AD_Element;
-import org.compiere.model.X_AD_Package_Imp_Detail;
-
-import org.compiere.util.Env;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class AdElementHandler extends AbstractElementHandler {
-
- private List processedElements = new ArrayList();
-
- private final String AD_ELEMENT = "AD_Element";
-
-
- public void startElement(Properties ctx, Element element)
- throws SAXException {
- String action = null;
-
- String entitytype = getStringValue(element, "EntityType");
- String ColumnName = getStringValue(element, "ColumnName");
-
- if (isProcessElement(ctx, entitytype)) {
-
- M_Element mElement = findPO(ctx, element);
- if (mElement == null) {
- int id = findIdByColumn(ctx, X_AD_Element.Table_Name, X_AD_Element.COLUMNNAME_ColumnName, ColumnName);
- mElement = new M_Element(ctx, id, getTrxName(ctx));
- }
- List excludes = defaultExcludeList(X_AD_Element.Table_Name);
- if (mElement.getAD_Element_ID() == 0 && isOfficialId(element, "AD_Element_ID"))
- mElement.setAD_Element_ID(getIntValue(element, "AD_Element_ID"));
-
- if (processedElements.contains(mElement.getAD_Element_ID())) {
- element.skip = true;
- return;
- }
-
- PoFiller pf = new PoFiller(ctx, mElement, element, this);
- List notfounds = pf.autoFill(excludes);
- if (notfounds.size() > 0) {
- element.defer = true;
- return;
- }
-
- if (mElement.is_new() || mElement.is_Changed()) {
- X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Element.Table_Name, X_AD_Element.Table_ID);
- if (!mElement.is_new()) {
- backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), AD_ELEMENT, mElement);
- action = "Update";
- } else {
- action = "New";
- }
-
- if (mElement.save(getTrxName(ctx)) == true) {
- logImportDetail(ctx, impDetail, 1, mElement.getName(),
- mElement.get_ID(), action);
-
- element.recordId = mElement.getAD_Element_ID();
-
- processedElements.add(mElement.getAD_Element_ID());
-
- } else {
- logImportDetail(ctx, impDetail, 0, mElement.getName(),
- mElement.get_ID(), action);
- throw new POSaveFailedException("Reference");
- }
- }
- } else {
- element.skip = true;
- }
- }
-
- public void endElement(Properties ctx, Element element) throws SAXException {
- }
-
- protected void create(Properties ctx, TransformerHandler document)
- throws SAXException {
-
-
- int adElement_id = Env.getContextAsInt(ctx,
- X_AD_Element.COLUMNNAME_AD_Element_ID);
-
- if (processedElements.contains(adElement_id))
- return;
-
- processedElements.add(adElement_id);
-
- X_AD_Element m_AdElement = new X_AD_Element(ctx, adElement_id, null);
-
- AttributesImpl atts = new AttributesImpl();
- addTypeName(atts, "table");
- document.startElement("", "", "AD_Element", atts);
- createAdElementBinding(ctx, document, m_AdElement);
-
- PackOut packOut = (PackOut)ctx.get("PackOutProcess");
-
-
- try{
- new CommonTranslationHandler().packOut(packOut,document,null,m_AdElement.get_ID());
- }
- catch(Exception e)
- {
- log.info(e.toString());
- }
-
- document.endElement("", "", "AD_Element");
- }
-
-
- private void createAdElementBinding(Properties ctx, TransformerHandler document,
- X_AD_Element m_AdElement) {
-
- PoExporter filler = new PoExporter(ctx, document, m_AdElement);
- if (m_AdElement.getAD_Element_ID() <= PackOut.MAX_OFFICIAL_ID)
- filler.add(X_AD_Element.COLUMNNAME_AD_Element_ID, new AttributesImpl());
-
- List excludes = defaultExcludeList(X_AD_Element.Table_Name);
- filler.export(excludes);
- }
-
- public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception
- {
- Env.setContext(packout.getCtx(), X_AD_Element.COLUMNNAME_AD_Element_ID, recordId);
- this.create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(X_AD_Element.COLUMNNAME_AD_Element_ID);
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/handler/CodeSnippetElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/handler/CodeSnippetElementHandler.java
deleted file mode 100644
index ee26684a09..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/handler/CodeSnippetElementHandler.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Low Heng Sin hengsin@avantz.com
- *****************************************************************************/
-package org.adempiere.pipo2.handler;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Properties;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-
-import org.compiere.Adempiere;
-import org.compiere.model.MPackageExpDetail;
-import org.compiere.model.X_AD_Package_Exp_Detail;
-import org.compiere.model.X_AD_Package_Imp_Backup;
-import org.compiere.model.X_AD_Package_Imp_Detail;
-
-import org.compiere.util.Env;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-import org.adempiere.pipo2.AbstractElementHandler;
-import org.adempiere.pipo2.Element;
-import org.adempiere.pipo2.PackOut;
-
-public class CodeSnippetElementHandler extends AbstractElementHandler {
-
- public void startElement(Properties ctx, Element element) throws SAXException {
- String action = null;
- action = "Update";
- String releaseNumber = getStringValue(element, "ReleaseNo");
- //Check Release Number
- if(Adempiere.MAIN_VERSION.equals(releaseNumber)||releaseNumber.equals("all")){
- String sourceName = getStringValue(element, "filename");
- String targetDirectory = getStringValue(element, "filedir");
- String oldCode = getStringValue(element, "oldcode");
- String newCode = getStringValue(element, "newcode");
-
- InputStream source; // Stream for reading from the source file.
- OutputStream copy; // Stream for writing the copy.
-
- String packagePath=null;
- String sourcePath=null;
-
- //get adempiere-all directory
- try {
- packagePath = getPackageDirectory(ctx);
- File parentDirectory = new File(packagePath);
- while (!parentDirectory.getName().equals("packages")){
- parentDirectory = parentDirectory.getParentFile();
- }
- parentDirectory = parentDirectory.getParentFile();
- sourcePath = parentDirectory.getCanonicalPath();
- } catch (IOException e1) {
- System.out.println("Can't find adempiere-all directory.");
- }
-
- // Create backup directory if required
- File backupDir = new File(packagePath+File.separator+"backup"+File.separator);
- if (!backupDir.exists()){
- boolean success = (new File(packagePath+File.separator+"backup"+File.separator)).mkdirs();
- if (!success) {
- log.info("Backup directory creation failed");
- }
- }
-
- //Correct target directory for proper file seperator
- String fullDirectory = sourcePath+targetDirectory;
- String targetDirectoryModified=null;
- String fileDate = null;
- char slash1 = '\\';
- char slash2 = '/';
- if (File.separator.equals("/"))
- targetDirectoryModified = fullDirectory.replace(slash1,slash2);
- else
- targetDirectoryModified = fullDirectory.replace(slash2,slash1);
-
- File file = new File(targetDirectoryModified+sourceName);
- log.info(targetDirectoryModified+sourceName);
- //TODO: derived force from user parameter
- boolean force = true;
- // check to see if overwrites are allowed
- if (file.exists()) {
- if (!force) {
- System.out.println("Output file exists. Use the -f option to replace it.");
- return;
- }
- //backup file to package directory
- else {
- action = "Update";
- log.info("Target Backup:"+targetDirectoryModified+sourceName);
- source = OpenInputfile(targetDirectoryModified+sourceName);
- SimpleDateFormat formatter_file = new SimpleDateFormat("yyMMddHHmmssSSSSZ");
- Date today = new Date();
- fileDate = formatter_file.format(today);
- copy = OpenOutputfile(packagePath+File.separator+"backup"+File.separator+fileDate+"_"+sourceName);
- log.info("Source Backup:"+packagePath+File.separator+"backup"+File.separator+fileDate+"_"+sourceName);
- copyFile (source,copy);
- log.info("Backup Complete");
- }
- }
-
- int success = readReplace(targetDirectoryModified+sourceName, oldCode, newCode);
-
- X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, "codesnipit", sourceName, 0);
- // Record in log
- if (success != -1){
- try {
- logImportDetail (ctx, impDetail, 1, sourceName, 0, action);
- } catch (SAXException e) {
- log.info ("setfile:"+e);
- }
- }
- else{
- try {
- logImportDetail (ctx, impDetail, 0, sourceName, 0, action);
- } catch (SAXException e) {
- log.info ("setfile:"+e);
- }
- }
-
- //Record in transaction file
- X_AD_Package_Imp_Backup backup = new X_AD_Package_Imp_Backup(ctx, 0, getTrxName(ctx));
- backup.setAD_Org_ID(Env.getAD_Org_ID(ctx));
- backup.setAD_Package_Imp_ID(getPackageImpId(ctx));
- backup.setAD_Package_Imp_Org_Dir(targetDirectoryModified+sourceName );
- backup.setAD_Package_Imp_Bck_Dir(packagePath+File.separator+"backup"+File.separator+fileDate+"_"+sourceName);
- backup.saveEx();
-
- }
- }
-
-
- /**
- * Find and replace code
- *
- * @param file name
- * @param old string
- * @param new string
- *
- */
- public static int readReplace(String fname, String oldPattern, String replPattern){
- String line;
- StringBuffer sb = new StringBuffer();
-
- try {
-
- FileInputStream fis = new FileInputStream(fname);
- BufferedReader reader=new BufferedReader ( new InputStreamReader(fis));
- while((line = reader.readLine()) != null) {
- line = line.replaceAll(oldPattern, replPattern);
- System.err.println(line);
- sb.append(line+"\n");
- }
- reader.close();
- BufferedWriter out=new BufferedWriter ( new FileWriter(fname));
- out.write(sb.toString());
- out.close();
- }
- catch (Throwable e) {
- System.err.println("error replacing codesnipit "+e);
- return -1;
- }
- return 0;
- }
-
-
- public void endElement(Properties ctx, Element element)
- throws SAXException {
- }
-
-
- public void create(Properties ctx, TransformerHandler document)
- throws SAXException {
- String FileDir = Env.getContext(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_File_Directory);
- String FileName = Env.getContext(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_FileName);
- String OldCode = Env.getContext(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_Old);
- String NewCode = Env.getContext(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_New);
- String ReleaseNo = Env.getContext(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo);
- AttributesImpl atts = new AttributesImpl();
- addTypeName(atts, "custom");
- createSnipitBinding(atts, FileDir, FileName, OldCode, NewCode, ReleaseNo);
- document.startElement("","","Code_Snipit",atts);
- document.endElement("","","Code_Snipit");
- }
-
- private AttributesImpl createSnipitBinding( AttributesImpl atts, String FileDir, String FileName, String OldCode, String NewCode, String ReleaseNo)
- {
- atts.clear();
- atts.addAttribute("","","filedir","CDATA",FileDir);
- atts.addAttribute("","","filename","CDATA",FileName);
- String preOldCode = OldCode.toString();
- String preNewCode = NewCode.toString();
- String modOldCode = preOldCode.replaceAll("\\$","\\\\\\$").replaceAll("\\.","\\\\.")
- .replaceAll("\\^","\\\\^").replaceAll("\\(","\\\\(").replaceAll("\\)","\\\\)")
- .replaceAll("\\[","\\\\[").replaceAll("\\/","\\\\/").replaceAll("\\+","\\\\+")
- .replaceAll("\\*","\\\\*").replaceAll("\\|","\\\\|");
- String modNewCode = preNewCode.replaceAll("\\$","\\\\\\$").replaceAll("\\.","\\\\.")
- .replaceAll("\\^","\\\\^").replaceAll("\\(","\\\\(").replaceAll("\\)","\\\\)")
- .replaceAll("\\[","\\\\[").replaceAll("\\/","\\\\/").replaceAll("\\+","\\\\+")
- .replaceAll("\\*","\\\\*").replaceAll("\\|","\\\\|");
- atts.addAttribute("","","oldcode","CDATA",modOldCode);
- atts.addAttribute("","","newcode","CDATA",modNewCode);
- atts.addAttribute("","","ReleaseNo","CDATA",ReleaseNo);
- return atts;
- }
-
- public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception
- {
- MPackageExpDetail detail = packout.getPackageExpDetail();
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_Destination_Directory, detail.getDestination_Directory());
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_FileName, detail.getDestination_FileName());
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_Old, detail.getAD_Package_Code_Old());
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_New, detail.getAD_Package_Code_New());
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo,detail.getReleaseNo());
- this.create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_File_Directory);
- packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_FileName);
- packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_Old);
- packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Package_Code_New);
- packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo);
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/handler/ColumnElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/handler/ColumnElementHandler.java
deleted file mode 100644
index 13c54b90b5..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/handler/ColumnElementHandler.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Low Heng Sin hengsin@avantz.com
- *****************************************************************************/
-package org.adempiere.pipo2.handler;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-import java.util.Properties;
-import java.util.logging.Level;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.pipo2.AbstractElementHandler;
-import org.adempiere.pipo2.PoExporter;
-import org.adempiere.pipo2.Element;
-import org.adempiere.pipo2.PackOut;
-import org.adempiere.pipo2.PoFiller;
-import org.adempiere.pipo2.exception.DatabaseAccessException;
-import org.adempiere.pipo2.exception.POSaveFailedException;
-import org.compiere.model.I_AD_Column;
-import org.compiere.model.I_AD_Table;
-import org.compiere.model.MColumn;
-import org.compiere.model.MTable;
-import org.compiere.model.X_AD_Column;
-import org.compiere.model.X_AD_Element;
-import org.compiere.model.X_AD_Package_Imp_Detail;
-import org.compiere.util.DB;
-import org.compiere.util.DisplayType;
-import org.compiere.util.Env;
-import org.compiere.util.Trx;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class ColumnElementHandler extends AbstractElementHandler {
-
- public void startElement(Properties ctx, Element element)
- throws SAXException {
- int success = 0;
- String entitytype = getStringValue(element, "EntityType");
- if (isProcessElement(ctx, entitytype)) {
- if (isParentDefer(element, I_AD_Table.Table_Name)) {
- element.defer = true;
- return;
- }
-
- List excludes = defaultExcludeList(X_AD_Column.Table_Name);
- String columnName = getStringValue(element, "ColumnName", excludes);
-
- MColumn mColumn = findPO(ctx, element);
- if (mColumn == null) {
- int tableid = 0;
- if (getParentId(element, I_AD_Table.Table_Name) > 0) {
- tableid = getParentId(element, "table");
- } else {
- mColumn = new MColumn(ctx, 0, getTrxName(ctx));
- PoFiller filler = new PoFiller(ctx, mColumn, element, this);
- filler.setTableReference("AD_Table_ID");
- tableid = mColumn.getAD_Table_ID();
- }
- int AD_Column_ID = findIdByColumnAndParentId(ctx, "AD_Column", "ColumnName", columnName, "AD_Table", tableid);
- mColumn = new MColumn(ctx, AD_Column_ID > 0 ? AD_Column_ID : 0, getTrxName(ctx));
- if (mColumn.getAD_Column_ID() == 0 && isOfficialId(element, "AD_Column_ID")) {
- mColumn.setAD_Column_ID(getIntValue(element, "AD_Column_ID"));
- }
- }
-
- mColumn.setColumnName(columnName);
- mColumn.setIsSyncDatabase(getStringValue(element, "IsSyncDatabase", excludes));
-
- PoFiller filler = new PoFiller(ctx, mColumn, element, this);
- List notfounds = filler.autoFill(excludes);
- if (notfounds.size() > 0) {
- element.defer = true;
- return;
- }
-
- if (!mColumn.is_new() && !mColumn.is_Changed())
- return;
-
- X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Column.Table_Name, X_AD_Column.Table_ID);
- String action = null;
- if (!mColumn.is_new()) {
- backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), "AD_Column", mColumn);
- action = "Update";
- } else {
- action = "New";
- }
-
- // Setup Element.
- if (mColumn.getAD_Element_ID() == 0) {
- X_AD_Element adElement = new X_AD_Element(ctx, 0, getTrxName(ctx));
- adElement.setColumnName(mColumn.getColumnName());
- adElement.setEntityType(mColumn.getEntityType());
- adElement.setPrintName(mColumn.getColumnName());
- adElement.setName(mColumn.getColumnName());
- adElement.saveEx();
- X_AD_Package_Imp_Detail eleDetail = createImportDetail(ctx, "Element", X_AD_Element.Table_Name,
- X_AD_Element.Table_ID);
- logImportDetail(ctx, eleDetail, 1, mColumn.getColumnName(), adElement
- .getAD_Element_ID(), "New");
- mColumn.setAD_Element_ID(adElement.getAD_Element_ID());
- }
-
- boolean recreateColumn = (mColumn.is_new()
- || mColumn.is_ValueChanged("AD_Reference_ID")
- || mColumn.is_ValueChanged("FieldLength")
- || mColumn.is_ValueChanged("ColumnName") || mColumn
- .is_ValueChanged("IsMandatory"));
-
- //ignore fieldlength change for clob and lob
- if (!mColumn.is_ValueChanged("AD_Reference_ID") && mColumn.is_ValueChanged("FieldLength")) {
- if (DisplayType.isLOB(mColumn.getAD_Reference_ID())) {
- recreateColumn = false;
- }
- }
-
- // changed default ??
- // m_Column.is_ValueChanged("DefaultValue") doesn't work well with
- // nulls
- if (!recreateColumn) {
- String oldDefault = (String) mColumn
- .get_ValueOld("DefaultValue");
- String newDefault = mColumn.getDefaultValue();
- if (oldDefault != null && oldDefault.length() == 0)
- oldDefault = null;
- if (newDefault != null && newDefault.length() == 0)
- newDefault = null;
- if ((oldDefault == null && newDefault != null)
- || (oldDefault != null && newDefault == null)) {
- recreateColumn = true;
- } else if (oldDefault != null && newDefault != null) {
- if (!oldDefault.equals(newDefault))
- recreateColumn = true;
- }
- }
-
- // Don't create database column for virtual columns
- boolean syncDatabase = "Y".equalsIgnoreCase(getStringValue(element, "IsSyncDatabase"));
- if (recreateColumn) {
- if (mColumn.isVirtualColumn() || !syncDatabase)
- recreateColumn = false;
- }
-
- if (mColumn.save(getTrxName(ctx)) == true) {
- logImportDetail(ctx, impDetail, 1, mColumn.getName(), mColumn
- .get_ID(), action);
- element.recordId = mColumn.getAD_Column_ID();
- } else {
- logImportDetail(ctx, impDetail, 0, mColumn.getName(), mColumn
- .get_ID(), action);
- throw new POSaveFailedException("Failed to import column.");
- }
-
- if (recreateColumn || syncDatabase) {
- MTable table = new MTable(ctx, mColumn.getAD_Table_ID(), getTrxName(ctx));
- if (!table.isView() && !mColumn.isVirtualColumn()) {
- success = createColumn(ctx, table, mColumn, recreateColumn);
-
- X_AD_Package_Imp_Detail dbDetail = createImportDetail(ctx, "dbColumn", X_AD_Column.Table_Name, X_AD_Column.Table_ID);
- if (success == 1) {
- logImportDetail(ctx, dbDetail, 1, mColumn.getColumnName(),
- mColumn.get_ID(), action);
- } else {
- logImportDetail(ctx, dbDetail, 0, mColumn.getColumnName(),
- mColumn.get_ID(), action);
- throw new DatabaseAccessException("Failed to create column or related constraint for " + mColumn.getColumnName());
- }
- }
- }
- } else {
- element.skip = true;
- }
- }
-
- /**
- * Check if column exists in database and modify. If not create column.
- *
- * @param tablename
- * @param columnname
- * @param v_AD_Reference_ID
- * @param v_FieldLength
- * @param v_DefaultValue
- * @param v_IsMandatory
- *
- */
- private int createColumn(Properties ctx, MTable table, MColumn column, boolean doAlter) {
-
- int no = 0;
-
- String sql = null;
- ResultSet rst = null;
- ResultSet rsc = null;
- Connection conn = null;
- Trx trx = Trx.get(getTrxName(ctx), true);
- if (!trx.commit())
- return 0;
-
- try {
- // Find Column in Database
- conn = trx.getConnection();
- DatabaseMetaData md = conn.getMetaData();
- String catalog = DB.getDatabase().getCatalog();
- String schema = DB.getDatabase().getSchema();
- String tableName = table.getTableName();
- String columnName = column.getColumnName();
- if (DB.isOracle()) {
- tableName = tableName.toUpperCase();
- columnName = columnName.toUpperCase();
- } else if (DB.isPostgreSQL()) {
- tableName = tableName.toLowerCase();
- columnName = columnName.toLowerCase();
- }
-
- rst = md.getTables(catalog, schema, tableName,
- new String[] { "TABLE" });
- if (!rst.next()) {
- // table doesn't exist
- sql = table.getSQLCreate();
- } else {
- //
- rsc = md.getColumns(catalog, schema, tableName, columnName);
- if (rsc.next()) {
- if (doAlter) {
- // update existing column
- boolean notNull = DatabaseMetaData.columnNoNulls == rsc
- .getInt("NULLABLE");
- sql = column.getSQLModify(table,
- column.isMandatory() != notNull);
- }
- } else {
- // No existing column
- sql = column.getSQLAdd(table);
- }
- rsc.close();
- rsc = null;
- }
-
- rst.close();
- rst = null;
- //execute modify or add if needed
- if (sql != null && sql.trim().length() > 0) {
- log.info(sql);
-
- if (sql.indexOf(DB.SQLSTATEMENT_SEPARATOR) == -1) {
- no = DB.executeUpdate(sql, false, trx.getTrxName());
- if (no == -1)
- return 0;
- } else {
- String statements[] = sql.split(DB.SQLSTATEMENT_SEPARATOR);
- for (int i = 0; i < statements.length; i++) {
- int count = DB.executeUpdate(statements[i], false,
- trx.getTrxName());
- if (count == -1) {
- return 0;
- }
- no += count;
- }
- }
- }
- trx.commit(true);
- } catch (SQLException e) {
- log.log(Level.SEVERE, e.getLocalizedMessage(), e);
- if (rsc != null) {
- try {
- rsc.close();
- } catch (SQLException e1) {
- }
- rsc = null;
- }
- if (rst != null) {
- try {
- rst.close();
- } catch (SQLException e1) {
- }
- rst = null;
- }
- trx.rollback();
- return 0;
- }
-
- return 1;
- }
-
- public void endElement(Properties ctx, Element element) throws SAXException {
- }
-
- public void create(Properties ctx, TransformerHandler document)
- throws SAXException {
- int AD_Column_ID = Env.getContextAsInt(ctx,
- X_AD_Column.COLUMNNAME_AD_Column_ID);
- AttributesImpl atts = new AttributesImpl();
- X_AD_Column m_Column = new X_AD_Column(ctx, AD_Column_ID,
- getTrxName(ctx));
- addTypeName(atts, "table");
- document.startElement("", "", I_AD_Column.Table_Name, atts);
- createColumnBinding(ctx, document, m_Column);
- document.endElement("", "", I_AD_Column.Table_Name);
- }
-
- private void createColumnBinding(Properties ctx, TransformerHandler document,
- X_AD_Column m_Column) {
-
- PoExporter filler = new PoExporter(ctx, document, m_Column);
- Listexcludes = defaultExcludeList(X_AD_Column.Table_Name);
-
- if (m_Column.getAD_Column_ID() <= PackOut.MAX_OFFICIAL_ID)
- filler.add("AD_Column_ID", new AttributesImpl());
-
- filler.addString("IsSyncDatabase", "Y", new AttributesImpl());
- filler.addTableReference("AD_Table", "TableName", new AttributesImpl());
- filler.addTableReference("AD_Reference_Value_ID", "AD_Reference", "Name", new AttributesImpl());
-
- excludes.add("IsSyncDatabase");
- excludes.add("AD_Table_ID");
- excludes.add("AD_Reference_Value_ID");
-
- filler.export(excludes);
- }
-
- @Override
- public void packOut(PackOut packout, TransformerHandler packoutHandler,
- TransformerHandler docHandler,
- int recordId) throws Exception {
- Env.setContext(packout.getCtx(), I_AD_Column.COLUMNNAME_AD_Column_ID, recordId);
- create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(I_AD_Column.COLUMNNAME_AD_Column_ID);
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/handler/CommonTranslationHandler.java b/plugins/pipo/src/org/adempiere/pipo2/handler/CommonTranslationHandler.java
deleted file mode 100644
index 427b883ced..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/handler/CommonTranslationHandler.java
+++ /dev/null
@@ -1,301 +0,0 @@
-package org.adempiere.pipo2.handler;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Properties;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.exceptions.DBException;
-import org.adempiere.pipo2.AbstractElementHandler;
-import org.adempiere.pipo2.PoExporter;
-import org.adempiere.pipo2.Element;
-import org.adempiere.pipo2.ElementHandler;
-import org.adempiere.pipo2.PackOut;
-import org.compiere.util.DB;
-import org.compiere.util.Env;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-import org.compiere.model.X_AD_Element;
-
-public class CommonTranslationHandler extends AbstractElementHandler implements ElementHandler {
-
- public static final String CONTEXT_KEY_PARENT_TABLE = "currentParentTableForTranslation";
- public static final String CONTEXT_KEY_PARENT_RECORD_ID = "currentParentTableRecordID_ForTranslation";
-
- private HashMap> cacheColumns = new HashMap>();//Key: table name. Value: set of PIPO columns
-
-
- public void startElement(Properties ctx, Element element) throws SAXException {
-
- if(! isHandleTranslations(ctx)){
- return;//translation import option is disabled
- }
-
- if(isParentSkip(element, null)){
- return;
- }
-
- if(isParentDefer(element, null)){
- element.defer = true;
- return;
- }
-
- String elementValue = element.getElementValue();
- int parentID = element.parent.recordId;
-
- if(parentID ==0)
- throw new SAXException();
-
- String language = getStringValue(element, "AD_Language");
-
- log.info(elementValue+" "+getStringValue(element, "Name"));
-
- if(isRecordExists(elementValue, parentID, language, ctx)){
- updateTranslation(elementValue, parentID, ctx, element);
- }else{
- insertTranslation(elementValue, parentID, ctx, element);
- }
- }
-
-
- private boolean isRecordExists(String tableName, int parentID,
- String language, Properties ctx) {
-
- String sql =
- "SELECT AD_Client_ID FROM " + tableName +" WHERE " +
- tableName.substring(0, tableName.length()-4) + "_ID = ? AND AD_Language = ?";
-
- if(DB.getSQLValue(getTrxName(ctx), sql, parentID, language) == -1){
- return false;
- }else{
- return true;
- }
- }
-
-
- private void insertTranslation(String tableName, int parentID,
- Properties ctx, Element element) throws SAXException{
-
- String parentTable = tableName.substring(0, tableName.length()-4);
- ArrayList columns = getTranslatedColumns(parentTable);
- StringBuffer sql = new StringBuffer();
- sql.append("INSERT INTO ")
- .append(tableName)
- .append(" (")
- .append(parentTable)
- .append("_ID, ")
- .append(" AD_Client_ID, AD_Org_ID, CreatedBy, UpdatedBy, ")
- .append(cast(columns))
- .append(") values ( ?, ?, ?, ?, ? ");
-
- for (int i = 0; i columns = getTranslatedColumns(parentTable);
- StringBuffer buffer = new StringBuffer("UPDATE "+tableName+" SET ");
- for (String columnName : columns) {
- buffer.append(columnName).append("=?,");
- }
-
- String sql = buffer.substring(0, buffer.length()-1);
- sql += " WHERE AD_Language = '"+getStringValue(element, "AD_Language")+
- "' AND "+parentTable+"_ID="+parentID;
-
- PreparedStatement pstm = null;
- try {
- pstm = DB.prepareStatement(sql,getTrxName(ctx));
- int i=0;
- for (String columnName : columns) {
- String value = getStringValue(element, columnName);
- i++;
-
- if(columnName.equalsIgnoreCase("IsActive") ||
- columnName.equalsIgnoreCase("IsTranslated")){
-
- value = "true".equals(value) ? "Y" : "N";
- }
-
- pstm.setString(i, value);
- }
-
- if(pstm.executeUpdate()<0){
- throw new SAXException();
- }
- } catch (Exception e) {
- throw new DBException(e);
- } finally {
- DB.close(pstm);
- }
- }
-
-
- public void endElement(Properties ctx, Element element) throws SAXException {
-
- }
-
-
- public void create(Properties ctx, TransformerHandler document) throws SAXException {
-
- String parenTableName = Env.getContext(ctx, CONTEXT_KEY_PARENT_TABLE);
-
- int parentRecordID = Env.getContextAsInt(ctx, CONTEXT_KEY_PARENT_RECORD_ID);
-
- createTranslationTags(ctx, parenTableName, parentRecordID, document);
- }
-
-
- private void createTranslationTags(Properties ctx, String parentTable,
- int parentRecordID, TransformerHandler document) throws SAXException {
-
- ArrayList translatedColumns = getTranslatedColumns(parentTable);
-
- String sql =
- "select "+cast(translatedColumns)+" from "+parentTable+"_trl where "+
- parentTable+"_ID="+parentRecordID;
-
- PreparedStatement pstm = null;
- ResultSet rs = null;
- try {
-
- pstm = DB.prepareStatement(sql, null);
- rs = pstm.executeQuery();
-
- String elementName = parentTable + "_Trl";
- while(rs.next()){
- AttributesImpl atts = new AttributesImpl();
- addTypeName(atts, "translation");
- document.startElement("", "", elementName, atts);
- exportRow(ctx, document, translatedColumns, rs);
- document.endElement("", "", elementName);
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- throw new SAXException();
- } finally {
- DB.close(rs, pstm);
- }
- }
-
- private void exportRow(Properties ctx, TransformerHandler document, ArrayList columns,
- ResultSet rs) throws Exception {
-
- PoExporter af = new PoExporter(ctx, document, null);
-
- for (String columnName : columns) {
- if(columnName.equalsIgnoreCase("IsActive")||
- columnName.equalsIgnoreCase("IsTranslated")) {
- af.addBoolean(columnName, rs.getString(columnName).equalsIgnoreCase("Y"), new AttributesImpl());
- } else{
- af.addString(columnName, rs.getString(columnName), new AttributesImpl());
- }
- }
- }
-
- /**
- *
- * @param parentTable
- * @return
- * @throws SAXException
- */
- private ArrayList getTranslatedColumns(String parentTable) throws SAXException {
-
-
- ArrayList pipolColumns = cacheColumns.get(parentTable);
- if(pipolColumns != null){
- return pipolColumns;
- }
-
- ArrayList columns = new ArrayList();
- String sql = "select * from ad_column where ad_table_id = " +
- "(select ad_table_id from ad_table where tableName = ?)" +
- "and isTranslated='Y'";
-
- PreparedStatement pstm = null;
- ResultSet rs = null;
- try {
- pstm = DB.prepareStatement(sql, null);
- pstm.setString(1, parentTable);
-
- rs = pstm.executeQuery();
- while(rs.next()){
- columns.add(rs.getString("columnName"));
- }
- } catch (SQLException e) {
- e.printStackTrace();
- throw new SAXException();
- } finally {
- DB.close(rs, pstm);
- }
-
- columns.add("AD_Language");
- columns.add("IsActive");
- columns.add("IsTranslated");
-
- //Putting in cache
- cacheColumns.put(parentTable, columns);
-
- return columns;
- }
-
- private String cast(ArrayList arg){
- String str = arg.toString();
- return str.substring(1, str.length()-1);
- }
-
- public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception
- {
- if("true".equals(packout.getCtx().getProperty("isHandleTranslations"))){
- Env.setContext(packout.getCtx(), CommonTranslationHandler.CONTEXT_KEY_PARENT_TABLE,X_AD_Element.Table_Name);
- Env.setContext(packout.getCtx(), CommonTranslationHandler.CONTEXT_KEY_PARENT_RECORD_ID,recordId);
- this.create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(CommonTranslationHandler.CONTEXT_KEY_PARENT_TABLE);
- packout.getCtx().remove(CommonTranslationHandler.CONTEXT_KEY_PARENT_RECORD_ID);
-
- }
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/handler/DistFileElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/handler/DistFileElementHandler.java
deleted file mode 100644
index f61387ef80..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/handler/DistFileElementHandler.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Low Heng Sin hengsin@avantz.com
- *****************************************************************************/
-package org.adempiere.pipo2.handler;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Properties;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.pipo2.AbstractElementHandler;
-import org.adempiere.pipo2.Element;
-import org.adempiere.pipo2.PackOut;
-import org.compiere.Adempiere;
-import org.compiere.model.MPackageExp;
-import org.compiere.model.MPackageExpDetail;
-import org.compiere.model.X_AD_Package_Exp_Detail;
-import org.compiere.model.X_AD_Package_Imp_Backup;
-import org.compiere.model.X_AD_Package_Imp_Detail;
-import org.compiere.util.Env;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class DistFileElementHandler extends AbstractElementHandler {
-
- String fileDest;
-
- public DistFileElementHandler()
- {
-
- }
-
- public DistFileElementHandler(String fileDest)
- {
- this.fileDest=fileDest;
- }
-
- public void startElement(Properties ctx, Element element) throws SAXException {
- String action = null;
-
- String releaseNumber = getStringValue(element,"ReleaseNo");
- //Check Release Number
- if(releaseNumber==null||Adempiere.MAIN_VERSION.equals(releaseNumber)||releaseNumber.equals("all")){
- String fileName = getStringValue(element, "filename");
- String sourceDirectory = getStringValue(element, "sourceDirectory");
- String targetDirectory = getStringValue(element, "targetDirectory");
-
- action = "New";
- InputStream inputStream; // Stream for reading from the source file.
- OutputStream outputStream; // Stream for writing the copy.
-
- String packagePath=null;
- String adempiereSourcePath=null;
-
- //get adempiere-all directory
- try {
- packagePath = getPackageDirectory(ctx);
- File parentDirectory = new File(packagePath);
- while (!parentDirectory.getName().equals("packages")){
- parentDirectory = parentDirectory.getParentFile();
- }
- parentDirectory = parentDirectory.getParentFile();
- adempiereSourcePath = parentDirectory.getCanonicalPath();
- } catch (IOException e1) {
- System.out.println("Can't find adempiere-all directory.");
- }
-
-
- // Create backup directory if required
- File backupDir = new File(packagePath+File.separator+"backup"+File.separator);
- if (!backupDir.exists()){
- boolean success = (new File(packagePath+File.separator+"backup"+File.separator)).mkdirs();
- if (!success) {
- log.info("Backup directory creation failed");
- }
- }
-
- //Correct target directory for proper file seperator
- String fullTargetPath = adempiereSourcePath+targetDirectory;
- char slash1 = '\\';
- char slash2 = '/';
- if (File.separator.equals("/"))
- fullTargetPath = fullTargetPath.replace(slash1,slash2);
- else
- fullTargetPath = fullTargetPath.replace(slash2,slash1);
-
- File file = new File(fullTargetPath+fileName);
- //TODO: derive force from user parameter
- boolean force = true;
- String fileDate = null;
- //check to see if overwrites are allowed
- if (file.exists())
- {
- if (!force) {
- System.out.println(
- "Output file exists. Use the -f option to replace it.");
- return;
- }
- //backup file to package directory
- else {
- action = "Update";
- log.info("Target Backup:"+fullTargetPath+fileName);
- inputStream = OpenInputfile(fullTargetPath+fileName);
- SimpleDateFormat formatter_file = new SimpleDateFormat("yyMMddHHmmssSSSSZ");
- Date today = new Date();
- fileDate = formatter_file.format(today);
- outputStream = OpenOutputfile(packagePath+File.separator+"backup"+File.separator+fileDate+"_"+fileName);
- log.info("Source Backup:"+packagePath+File.separator+"backup"+File.separator+fileDate+"_"+fileName);
- copyFile (inputStream, outputStream);
- log.info("Backup Complete");
- }
- }
-
-// Correct dist directory for proper file seperator
- String fullSourcePath=null;
- if (File.separator.equals("/"))
- fullSourcePath = sourceDirectory.replace(slash1,slash2);
- else
- fullSourcePath = sourceDirectory.replace(slash2,slash1);
- inputStream = OpenInputfile(packagePath+fullSourcePath+fileName);
-
-// Create Target directory if required
- File targetDir = new File(fullTargetPath);
- if (!targetDir.exists()){
- boolean success = (new File(fullTargetPath)).mkdirs();
- if (!success) {
- log.info("Target directory creation failed");
- }
- }
- outputStream = OpenOutputfile(fullTargetPath+fileName);
- //Copy File
- int success = copyFile (inputStream,outputStream);
- //Record in log
- X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, "file", fileName, 0);
- if (success != -1){
- try {
- logImportDetail (ctx, impDetail, 1, fileName, 0, action);
- } catch (SAXException e) {
- log.info ("setfile:"+e);
- }
- }
- else{
- try {
- logImportDetail (ctx, impDetail, 0, fileName, 0, action);
- } catch (SAXException e) {
- log.info ("setfile:"+e);
- }
- }
- //Record in transaction file
- X_AD_Package_Imp_Backup backup = new X_AD_Package_Imp_Backup(ctx, 0, getTrxName(ctx));
- backup.setAD_Org_ID(Env.getAD_Org_ID(ctx));
- backup.setAD_Package_Imp_Org_Dir(fullTargetPath+fileName);
- backup.setAD_Package_Imp_Bck_Dir(packagePath+File.separator+"backup"+File.separator+fileDate+"_"+fileName);
- backup.setAD_Package_Imp_ID(getPackageImpId(ctx));
- backup.saveEx();
-
- }
- }
-
- public void endElement(Properties ctx, Element element) throws SAXException {
- }
-
- public void create(Properties ctx, TransformerHandler document)
- throws SAXException {
- String FileName = Env.getContext(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_FileName);
- String Source_Directory = Env.getContext(ctx, "Source_Directory");
- String Target_Directory = Env.getContext(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory);
- String ReleaseNo = Env.getContext(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo);
- AttributesImpl atts = new AttributesImpl();
- addTypeName(atts, "custom");
- document.startElement("","","Dist_File",atts);
- addTextProperty(document,"filename",FileName);
- addTextProperty(document,"sourceDirectory",Source_Directory);
- addTextProperty(document,"targetDirectory",Target_Directory);
- addTextProperty(document,"ReleaseNo",ReleaseNo);
- atts.addAttribute("","","ReleaseNo","CDATA",ReleaseNo);
- document.endElement("","","Dist_File");
- }
-
- public void doPackout(PackOut packout, MPackageExp header, MPackageExpDetail detail,TransformerHandler packOutDocument,TransformerHandler packageDocument,AttributesImpl atts,int recordId) throws Exception
- {
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_FileName, detail.getFileName());
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo, detail.getReleaseNo());
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory, detail.getTarget_Directory());
- Env.setContext(packout.getCtx(), "Source_Directory", fileDest);
- this.create(packout.getCtx(), packOutDocument);
- packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_FileName);
- packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_ReleaseNo);
- packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_Target_Directory);
- packout.getCtx().remove("Source_Directory");
- }
-
- @Override
- public void packOut(PackOut packout, TransformerHandler packoutHandler,
- TransformerHandler docHandler,
- int recordId) throws Exception {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/handler/DynValRuleElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/handler/DynValRuleElementHandler.java
deleted file mode 100644
index 1e640e73a6..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/handler/DynValRuleElementHandler.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Low Heng Sin hengsin@avantz.com
- *****************************************************************************/
-package org.adempiere.pipo2.handler;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.pipo2.AbstractElementHandler;
-import org.adempiere.pipo2.PoExporter;
-import org.adempiere.pipo2.Element;
-import org.adempiere.pipo2.PackOut;
-import org.adempiere.pipo2.PoFiller;
-import org.adempiere.pipo2.exception.POSaveFailedException;
-import org.compiere.model.I_AD_Val_Rule;
-import org.compiere.model.X_AD_Package_Exp_Detail;
-import org.compiere.model.X_AD_Package_Imp_Detail;
-import org.compiere.model.X_AD_Val_Rule;
-import org.compiere.util.Env;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class DynValRuleElementHandler extends AbstractElementHandler {
-
- private List rules = new ArrayList();
-
- public void startElement(Properties ctx, Element element) throws SAXException {
- String entitytype = getStringValue(element, "EntityType");
- if (isProcessElement(ctx, entitytype)) {
- String name = getStringValue(element, "Name");
-
- X_AD_Val_Rule mValRule = findPO(ctx, element);
- if (mValRule == null)
- {
- int id = findIdByColumn(ctx, "AD_Val_Rule", "Name", name);
- mValRule = new X_AD_Val_Rule(ctx, id > 0 ? id : 0, getTrxName(ctx));
- }
- if (mValRule.getAD_Val_Rule_ID() == 0 && isOfficialId(element, "AD_Val_Rule_ID"))
- mValRule.setAD_Val_Rule_ID(getIntValue(element, "AD_Val_Rule_ID"));
-
- List excludes = defaultExcludeList(X_AD_Val_Rule.Table_Name);
-
- PoFiller filler = new PoFiller(ctx, mValRule, element, this);
- List notfounds = filler.autoFill(excludes);
- if (notfounds.size() > 0) {
- element.defer = true;
- return;
- }
-
- if (mValRule.is_new() || mValRule.is_Changed()) {
- X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Val_Rule.Table_Name,
- X_AD_Val_Rule.Table_ID);
- String action = null;
- if (!mValRule.is_new()){
- backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), X_AD_Val_Rule.Table_Name, mValRule);
- action = "Update";
- }
- else{
- action = "New";
- }
-
- if (mValRule.save(getTrxName(ctx)) == true){
- logImportDetail (ctx, impDetail, 1, mValRule.getName(), mValRule.get_ID(),action);
- }
- else{
- logImportDetail (ctx, impDetail, 0, mValRule.getName(), mValRule.get_ID(),action);
- throw new POSaveFailedException("Failed to save dynamic validation rule.");
- }
- }
- } else {
- element.skip = true;
- }
-
- }
-
- public void endElement(Properties ctx, Element element) throws SAXException {
- }
-
- protected void create(Properties ctx, TransformerHandler document)
- throws SAXException {
- int AD_Val_Rule_ID = Env.getContextAsInt(ctx, X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID);
- if (rules.contains(AD_Val_Rule_ID))
- return;
- rules.add(AD_Val_Rule_ID);
- X_AD_Val_Rule m_ValRule = new X_AD_Val_Rule (ctx, AD_Val_Rule_ID, null);
- AttributesImpl atts = new AttributesImpl();
- addTypeName(atts, "table");
- document.startElement("","",I_AD_Val_Rule.Table_Name, atts);
- createDynamicValidationRuleBinding(ctx,document,m_ValRule);
- document.endElement("","",I_AD_Val_Rule.Table_Name);
-
- }
-
- private void createDynamicValidationRuleBinding(Properties ctx, TransformerHandler document, X_AD_Val_Rule m_ValRule)
- {
- PoExporter filler = new PoExporter(ctx, document, m_ValRule);
- Listexcludes = defaultExcludeList(X_AD_Val_Rule.Table_Name);
-
- if (m_ValRule.getAD_Val_Rule_ID() <= PackOut.MAX_OFFICIAL_ID)
- filler.add("AD_Val_Rule_ID", new AttributesImpl());
-
- filler.export(excludes);
- }
-
-
- public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception
- {
-
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID, recordId);
-
- this.create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Val_Rule_ID);
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/handler/FieldElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/handler/FieldElementHandler.java
deleted file mode 100644
index e6f4087916..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/handler/FieldElementHandler.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Low Heng Sin hengsin@avantz.com
- *****************************************************************************/
-package org.adempiere.pipo2.handler;
-
-import java.util.List;
-import java.util.Properties;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.pipo2.AbstractElementHandler;
-import org.adempiere.pipo2.ElementHandler;
-import org.adempiere.pipo2.PoExporter;
-import org.adempiere.pipo2.Element;
-import org.adempiere.pipo2.PackOut;
-import org.adempiere.pipo2.PoFiller;
-import org.adempiere.pipo2.ReferenceUtils;
-import org.adempiere.pipo2.exception.POSaveFailedException;
-import org.compiere.model.I_AD_Field;
-import org.compiere.model.I_AD_Tab;
-import org.compiere.model.MField;
-import org.compiere.model.X_AD_Field;
-import org.compiere.model.X_AD_Package_Imp_Detail;
-import org.compiere.util.DB;
-import org.compiere.util.Env;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class FieldElementHandler extends AbstractElementHandler {
-
- public void startElement(Properties ctx, Element element)
- throws SAXException {
- String entitytype = getStringValue(element, "EntityType");
- if (isProcessElement(ctx, entitytype)) {
- if (isParentDefer(element, I_AD_Tab.Table_Name)) {
- element.defer = true;
- return;
- }
-
- Listexcludes = defaultExcludeList(X_AD_Field.Table_Name);
-
- int tabid = getParentId(element, I_AD_Tab.Table_Name) ;
- if (tabid <= 0) {
- element.defer = true;
- return;
- }
-
- MField mField = findPO(ctx, element);
- if (mField == null)
- {
- int AD_Table_ID = ReferenceUtils.resolveReference(ctx, element.parent.properties.get("AD_Table_ID"));
- Element columnElement = element.parent.properties.get("AD_Column_ID");
- int AD_Column_ID = 0;
- if (ReferenceUtils.isIDLookup(columnElement) || ReferenceUtils.isUUIDLookup(columnElement))
- {
- AD_Column_ID = ReferenceUtils.resolveReference(ctx, columnElement);
- }
- else
- {
- String colname = getStringValue(element, "AD_Column_ID", excludes);
- AD_Column_ID = findIdByColumnAndParentId(ctx, "AD_Column", "ColumnName", colname, "AD_Table", AD_Table_ID);
- }
-
-
- StringBuffer sqlB = new StringBuffer(
- "select AD_Field_ID from AD_Field where AD_Column_ID = ")
- .append(AD_Column_ID)
- .append(" and AD_Tab_ID = ?");
- int id = DB.getSQLValue(getTrxName(ctx), sqlB.toString(), tabid);
- mField = new MField(ctx, id > 0 ? id : 0, getTrxName(ctx));
- if (mField.is_new()) {
- mField.setAD_Column_ID(AD_Column_ID);
- mField.setAD_Tab_ID(tabid);
- }
- }
- PoFiller filler = new PoFiller(ctx, mField, element, this);
- if (mField.getAD_Field_ID() == 0 && isOfficialId(element, "AD_Field_ID"))
- {
- filler.setInteger("AD_Field_ID");
- }
-
- List notfounds = filler.autoFill(excludes);
- if (notfounds.size() > 0) {
- element.defer = true;
- return;
- }
-
- if (mField.is_new() || mField.is_Changed()) {
- X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Field.Table_Name,
- X_AD_Field.Table_ID);
- String action = null;
- if (!mField.is_new()){
- backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), I_AD_Field.Table_Name, mField);
- action = "Update";
- }
- else{
- action = "New";
- }
-
- if (mField.save(getTrxName(ctx)) == true) {
- logImportDetail(ctx, impDetail, 1, mField.getName(), mField
- .get_ID(), action);
- element.recordId = mField.getAD_Field_ID();
- } else {
- logImportDetail(ctx, impDetail, 0, mField.getName(), mField
- .get_ID(), action);
- throw new POSaveFailedException("Failed to save field definition.");
- }
- }
- } else {
- element.skip = true;
- }
- }
-
- public void endElement(Properties ctx, Element element) throws SAXException {
- }
-
- public void create(Properties ctx, TransformerHandler document)
- throws SAXException {
- int AD_Field_ID = Env.getContextAsInt(ctx,
- X_AD_Field.COLUMNNAME_AD_Field_ID);
- X_AD_Field m_Field = new X_AD_Field(ctx, AD_Field_ID, null);
- AttributesImpl atts = new AttributesImpl();
- addTypeName(atts, "table");
- document.startElement("", "", I_AD_Field.Table_Name, atts);
- createFieldBinding(ctx, document, m_Field);
-
- PackOut packOut = (PackOut)ctx.get("PackOutProcess");
-
- try
- {
- if(m_Field.getAD_FieldGroup_ID() > 0)
- {
- ElementHandler handler = packOut.getHandler("FG");
- handler.packOut(packOut,document,null,m_Field.getAD_FieldGroup_ID());
- }
-
- if (m_Field.getAD_Reference_ID()>0)
- {
- ElementHandler handler = packOut.getHandler("REF");
- handler.packOut(packOut,document,null,m_Field.getAD_Reference_ID());
- }
-
- if (m_Field.getAD_Reference_Value_ID()>0)
- {
- ElementHandler handler = packOut.getHandler("REF");
- handler.packOut(packOut,document,null,m_Field.getAD_Reference_Value_ID());
- }
-
- if (m_Field.getAD_Val_Rule_ID()>0)
- {
- ElementHandler handler = packOut.getHandler("V");
- handler.packOut(packOut,document,null,m_Field.getAD_Val_Rule_ID());
- }
- }
- catch(Exception e)
- {
- log.info(e.toString());
- }
-
- document.endElement("", "", I_AD_Field.Table_Name);
- }
-
- private void createFieldBinding(Properties ctx, TransformerHandler document,
- X_AD_Field m_Field) {
-
- List excludes = defaultExcludeList(X_AD_Field.Table_Name);
- PoExporter filler = new PoExporter(ctx, document, m_Field);
- if (m_Field.getAD_Field_ID() <= PackOut.MAX_OFFICIAL_ID) {
- filler.add("AD_Field_ID", new AttributesImpl());
- }
-
- filler.export(excludes);
- }
-
- @Override
- public void packOut(PackOut packout, TransformerHandler packoutHandler,
- TransformerHandler docHandler,
- int recordId) throws Exception {
- Env.setContext(packout.getCtx(), I_AD_Field.COLUMNNAME_AD_Field_ID, recordId);
- create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(I_AD_Field.COLUMNNAME_AD_Field_ID);
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/handler/FieldGroupElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/handler/FieldGroupElementHandler.java
deleted file mode 100644
index b4080fb3a1..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/handler/FieldGroupElementHandler.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Igor G. - progerpro@gmail.com
- *****************************************************************************/
-package org.adempiere.pipo2.handler;
-
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.pipo2.AbstractElementHandler;
-import org.adempiere.pipo2.PoExporter;
-import org.adempiere.pipo2.Element;
-import org.adempiere.pipo2.PackOut;
-import org.adempiere.pipo2.PoFiller;
-import org.adempiere.pipo2.exception.POSaveFailedException;
-import org.compiere.model.I_AD_FieldGroup;
-import org.compiere.model.X_AD_FieldGroup;
-import org.compiere.model.X_AD_Package_Imp_Detail;
-import org.compiere.util.Env;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class FieldGroupElementHandler extends AbstractElementHandler {
-
-
- private List processedFieldGroups = new ArrayList();
-
-
- public void startElement(Properties ctx, Element element)
- throws SAXException {
- String elementValue = element.getElementValue();
- String action = null;
-
- log.info(elementValue + " " + getStringValue(element, "Name"));
-
- String entitytype = getStringValue(element, "EntityType");
- String name = getStringValue(element, "Name");
-
- if (isProcessElement(ctx, entitytype)) {
-
- X_AD_FieldGroup fieldGroup = findPO(ctx, element);
- if (fieldGroup == null)
- {
- int id = findIdByColumn(ctx, X_AD_FieldGroup.Table_Name, X_AD_FieldGroup.COLUMNNAME_Name, name);
- fieldGroup = new X_AD_FieldGroup(ctx, id > 0 ? id : 0, getTrxName(ctx));
- }
- PoFiller pf = new PoFiller(ctx, fieldGroup, element, this);
- List excludes = defaultExcludeList(X_AD_FieldGroup.Table_Name);
- if (fieldGroup.getAD_FieldGroup_ID() == 0 && isOfficialId(element, "AD_FieldGroup_ID"))
- {
- pf.setInteger("AD_FieldGroup_ID");
- }
-
- if (processedFieldGroups.contains(fieldGroup.getAD_FieldGroup_ID())) {
- element.skip = true;
- return;
- }
-
- List notfounds = pf.autoFill(excludes);
- if (notfounds.size() > 0) {
- element.defer = true;
- return;
- }
-
- if (fieldGroup.is_new() || fieldGroup.is_Changed()) {
- X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_FieldGroup.Table_Name,
- X_AD_FieldGroup.Table_ID);
- if (!fieldGroup.is_new()) {
- backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), X_AD_FieldGroup.Table_Name, fieldGroup);
- action = "Update";
- } else {
- action = "New";
- }
-
- if (fieldGroup.save(getTrxName(ctx)) == true) {
- logImportDetail(ctx, impDetail, 1, fieldGroup.getName(),
- fieldGroup.get_ID(), action);
-
- element.recordId = fieldGroup.getAD_FieldGroup_ID();
-
- processedFieldGroups.add(fieldGroup.getAD_FieldGroup_ID());
-
- } else {
- logImportDetail(ctx, impDetail, 0, fieldGroup.getName(),
- fieldGroup.get_ID(), action);
- throw new POSaveFailedException("Reference");
- }
- }
- } else {
- element.skip = true;
- }
- }
-
- public void endElement(Properties ctx, Element element) throws SAXException {
- }
-
- protected void create(Properties ctx, TransformerHandler document)
- throws SAXException {
-
-
- int fieldGroup_id = Env.getContextAsInt(ctx,
- X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID);
-
- if (processedFieldGroups.contains(fieldGroup_id))
- return;
-
- processedFieldGroups.add(fieldGroup_id);
-
- X_AD_FieldGroup fieldGroup = new X_AD_FieldGroup(ctx, fieldGroup_id, null);
-
- AttributesImpl atts = new AttributesImpl();
- addTypeName(atts, "table");
- document.startElement("", "", I_AD_FieldGroup.Table_Name, atts);
-
- createAdElementBinding(ctx, document, fieldGroup);
-
- PackOut packOut = (PackOut)ctx.get("PackOutProcess");
-
- try{
- new CommonTranslationHandler().packOut(packOut,document,null,fieldGroup.get_ID());
- }
- catch(Exception e)
- {
- log.info(e.toString());
- }
- document.endElement("", "", I_AD_FieldGroup.Table_Name);
- }
-
-
- private void createAdElementBinding(Properties ctx, TransformerHandler document,
- X_AD_FieldGroup fieldGroup) {
-
- PoExporter filler = new PoExporter(ctx, document, fieldGroup);
- List excludes = defaultExcludeList(X_AD_FieldGroup.Table_Name);
- if (fieldGroup.getAD_FieldGroup_ID() <= PackOut.MAX_OFFICIAL_ID) {
- filler.add(X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID, new AttributesImpl());
- }
-
- filler.export(excludes);
- }
-
- public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception
- {
- Env.setContext(packout.getCtx(), X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID, recordId);
-
- this.create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(X_AD_FieldGroup.COLUMNNAME_AD_FieldGroup_ID);
- }
-}
\ No newline at end of file
diff --git a/plugins/pipo/src/org/adempiere/pipo2/handler/FileElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/handler/FileElementHandler.java
deleted file mode 100644
index 176b1ae8fd..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/handler/FileElementHandler.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package org.adempiere.pipo2.handler;
-
-import java.io.File;
-import java.util.Properties;
-import java.util.logging.Level;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.exceptions.AdempiereException;
-import org.adempiere.pipo2.Element;
-import org.adempiere.pipo2.ElementHandler;
-import org.adempiere.pipo2.PackOut;
-import org.compiere.model.MPackageExp;
-import org.compiere.model.MPackageExpDetail;
-import org.compiere.util.CLogger;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class FileElementHandler implements ElementHandler {
-
- private CLogger log = CLogger.getCLogger(FileElementHandler.class);
-
- public void packOut(PackOut packout, TransformerHandler packoutHandler,
- TransformerHandler docHandler, int recordId) throws Exception {
- MPackageExp header = packout.getPackageExp();
- MPackageExpDetail detail = packout.getPackageExpDetail();
- log.log(Level.INFO,
- "In PackOut.java handling Code or Other 2pack module creation");
- String fileDirectory = header.getFile_Directory() + header.getName()
- + detail.getTarget_Directory();
- log.log(Level.INFO, "targetDirectory" + fileDirectory);
- String targetDirectory = null;
- char fileseperator1 = '/';
- char fileseperator2 = '\\';
- // Correct package for proper file seperator
- if (File.separator.equals("/")) {
- targetDirectory = fileDirectory.replace(fileseperator2,
- fileseperator1);
- } else
- targetDirectory = fileDirectory.replace(fileseperator1,
- fileseperator2);
-
- String sourceDirectory = null;
- fileDirectory = detail.getFile_Directory();
- // Correct package for proper file seperator
- if (File.separator.equals("/")) {
- sourceDirectory = fileDirectory.replace(fileseperator2,
- fileseperator1);
- } else
- sourceDirectory = fileDirectory.replace(fileseperator2,
- fileseperator1);
-
- packout.copyFile(sourceDirectory + detail.getFileName(),
- targetDirectory + detail.getFileName());
-
- AttributesImpl atts = new AttributesImpl();
-
- if (detail.getDestination_Directory() != null) {
-
- fileDirectory = detail.getDestination_Directory();
- String destinationDirectory = null;
-
- // Correct package for proper file seperator
- if (File.separator.equals("/")) {
- destinationDirectory = fileDirectory.replace(fileseperator2,
- fileseperator1);
- } else
- destinationDirectory = fileDirectory.replace(fileseperator2,
- fileseperator1);
-
- try {
- new DistFileElementHandler(destinationDirectory).doPackout(
- packout, null, detail, packoutHandler, null, null, 0);
- } catch (Exception e) {
- throw new AdempiereException(e.getLocalizedMessage(), e);
- }
- }
-
- if (detail.getFileName() != null) {
- PackOut.addTextElement(docHandler, "file",
- "File: " + detail.getFileName(), atts);
- }
- PackOut.addTextElement(docHandler, "filedirectory", "Directory: "
- + detail.getTarget_Directory(), atts);
- PackOut.addTextElement(docHandler, "filenotes",
- "Notes: " + detail.getDescription(), atts);
- }
-
- @Override
- public void startElement(Properties ctx, Element element)
- throws SAXException {
- }
-
- @Override
- public void endElement(Properties ctx, Element element) throws SAXException {
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/handler/FormAccessElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/handler/FormAccessElementHandler.java
deleted file mode 100644
index de5cb266ea..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/handler/FormAccessElementHandler.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Low Heng Sin hengsin@avantz.com
- *****************************************************************************/
-package org.adempiere.pipo2.handler;
-
-import java.util.List;
-import java.util.Properties;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.pipo2.AbstractElementHandler;
-import org.adempiere.pipo2.PackOut;
-import org.adempiere.pipo2.PoExporter;
-import org.adempiere.pipo2.Element;
-import org.adempiere.pipo2.PoFiller;
-import org.adempiere.pipo2.ReferenceUtils;
-import org.compiere.model.I_AD_Form_Access;
-import org.compiere.model.I_AD_Role;
-import org.compiere.model.MFormAccess;
-import org.compiere.model.Query;
-import org.compiere.model.X_AD_Form;
-import org.compiere.model.X_AD_Form_Access;
-import org.compiere.model.X_AD_Role;
-import org.compiere.util.Env;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class FormAccessElementHandler extends AbstractElementHandler {
-
- public void startElement(Properties ctx, Element element) throws SAXException {
- List excludes = defaultExcludeList(X_AD_Form_Access.Table_Name);
-
- MFormAccess po = findPO(ctx, element);
- if (po == null) {
- int AD_Role_ID = 0;
- if (getParentId(element, I_AD_Role.Table_Name) > 0) {
- AD_Role_ID = getParentId(element, I_AD_Role.Table_Name);
- } else {
- AD_Role_ID = ReferenceUtils.resolveReference(ctx, element.properties.get("AD_Role_ID"));
- }
- if (AD_Role_ID <= 0)
- {
- element.defer = true;
- return;
- }
-
- int AD_Form_ID = ReferenceUtils.resolveReference(ctx, element.properties.get("AD_Form_ID"));
- if (AD_Form_ID <= 0)
- {
- element.defer = true;
- return;
- }
-
- Query query = new Query(ctx, "AD_Form_Access", "AD_Form_ID = ? AND AD_Role_ID = ?", getTrxName(ctx));
- po = query.setParameters(new Object[]{AD_Form_ID, AD_Role_ID})
- .setClient_ID()
- .first();
- if (po == null)
- {
- po = new MFormAccess(ctx, 0, null);
- po.setAD_Form_ID(AD_Form_ID);
- po.setAD_Role_ID(AD_Role_ID);
- }
-
- excludes.add("AD_Form_ID");
- excludes.add("AD_Role_ID");
- }
-
- PoFiller filler = new PoFiller(ctx, po, element, this);
- List notfounds = filler.autoFill(excludes);
- if (notfounds.size() > 0) {
- element.defer = true;
- return;
- }
- po.saveEx();
- }
-
- public void endElement(Properties ctx, Element element) throws SAXException {
- }
-
- public void create(Properties ctx, TransformerHandler document)
- throws SAXException {
- int AD_Form_ID = Env.getContextAsInt(ctx, X_AD_Form.COLUMNNAME_AD_Form_ID);
- int AD_Role_ID = Env.getContextAsInt(ctx, X_AD_Role.COLUMNNAME_AD_Role_ID);
- AttributesImpl atts = new AttributesImpl();
- addTypeName(atts, "table");
- document.startElement("", "", I_AD_Form_Access.Table_Name, atts);
- createFormAccessBinding(ctx, document, AD_Form_ID, AD_Role_ID);
- document.endElement("", "", I_AD_Form_Access.Table_Name);
- }
-
- private void createFormAccessBinding(Properties ctx, TransformerHandler document,
- int formId, int roleId) {
- MFormAccess po = null;
- Query query = new Query(ctx, "AD_Form_Access", "AD_Form_ID = ? AND AD_Role_ID = ?", getTrxName(ctx));
- po = query.setParameters(new Object[]{formId, roleId}).first();
- if (po != null) {
- PoExporter filler = new PoExporter(ctx, document, po);
- List excludes = defaultExcludeList(X_AD_Form_Access.Table_Name);
- filler.export(excludes);
- }
- }
-
- @Override
- public void packOut(PackOut packout, TransformerHandler packoutHandler,
- TransformerHandler docHandler,
- int recordId) throws Exception {
- // TODO Auto-generated method stub
-
- }
-
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/handler/FormElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/handler/FormElementHandler.java
deleted file mode 100644
index f838389294..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/handler/FormElementHandler.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com
- * Contributor(s): Low Heng Sin hengsin@avantz.com
- *****************************************************************************/
-package org.adempiere.pipo2.handler;
-
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.pipo2.AbstractElementHandler;
-import org.adempiere.pipo2.PoExporter;
-import org.adempiere.pipo2.Element;
-import org.adempiere.pipo2.PackOut;
-import org.adempiere.pipo2.PoFiller;
-import org.adempiere.pipo2.exception.POSaveFailedException;
-import org.compiere.model.I_AD_Form;
-import org.compiere.model.MForm;
-import org.compiere.model.X_AD_Form;
-import org.compiere.model.X_AD_Package_Exp_Detail;
-import org.compiere.model.X_AD_Package_Imp_Detail;
-import org.compiere.util.Env;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-public class FormElementHandler extends AbstractElementHandler {
-
- private List forms = new ArrayList();
-
- public void startElement(Properties ctx, Element element) throws SAXException {
- List excludes = defaultExcludeList(X_AD_Form.Table_Name);
-
- String entitytype = getStringValue(element, "EntityType");
- if (isProcessElement(ctx, entitytype)) {
- MForm mForm = findPO(ctx, element);
- if (mForm == null) {
- String name = getStringValue(element, "Name");
- int id = findIdByName(ctx, "AD_Form", name);
- mForm = new MForm(ctx, id > 0 ? id : 0, getTrxName(ctx));
- }
- PoFiller filler = new PoFiller(ctx, mForm, element, this);
-
- if (mForm.getAD_Form_ID() == 0 && isOfficialId(element, "AD_Form_ID"))
- {
- filler.setInteger("AD_Form_ID");
- }
-
- List notfounds = filler.autoFill(excludes);
- if (notfounds.size() > 0) {
- element.defer = true;
- return;
- }
-
- if (mForm.is_new() || mForm.is_Changed()) {
- X_AD_Package_Imp_Detail impDetail = createImportDetail(ctx, element.qName, X_AD_Form.Table_Name,
- X_AD_Form.Table_ID);
- String action = null;
- if (!mForm.is_new()){
- backupRecord(ctx, impDetail.getAD_Package_Imp_Detail_ID(), X_AD_Form.Table_Name, mForm);
- action = "Update";
- }
- else{
- action = "New";
- }
-
- if (mForm.save(getTrxName(ctx)) == true){
- logImportDetail (ctx, impDetail, 1, mForm.getName(), mForm.get_ID(), action);
- }
- else{
- logImportDetail (ctx, impDetail, 0, mForm.getName(), mForm.get_ID(), action);
- throw new POSaveFailedException("Failed to save form definition");
- }
- }
- } else {
- element.skip = true;
- }
- }
-
- public void endElement(Properties ctx, Element element) throws SAXException {
- }
-
- protected void create(Properties ctx, TransformerHandler document)
- throws SAXException {
- int AD_Form_ID = Env.getContextAsInt(ctx, "AD_Form_ID");
- if (forms.contains(AD_Form_ID)) return;
-
- forms.add(AD_Form_ID);
- X_AD_Form m_Form = new X_AD_Form (ctx, AD_Form_ID, null);
- AttributesImpl atts = new AttributesImpl();
- addTypeName(atts, "table");
- document.startElement("","",I_AD_Form.Table_Name,atts);
- createFormBinding(ctx, document, m_Form);
- document.endElement("","",I_AD_Form.Table_Name);
- }
-
- private void createFormBinding(Properties ctx, TransformerHandler document, X_AD_Form m_Form)
- {
- PoExporter filler = new PoExporter(ctx, document, m_Form);
- List excludes = defaultExcludeList(X_AD_Form.Table_Name);
- if (m_Form.getAD_Form_ID() <= PackOut.MAX_OFFICIAL_ID) {
- filler.add("AD_Form_ID", new AttributesImpl());
- }
- filler.export(excludes);
- }
-
-
- public void packOut(PackOut packout, TransformerHandler packoutHandler, TransformerHandler docHandler,int recordId) throws Exception
- {
- Env.setContext(packout.getCtx(), X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID, recordId);
- this.create(packout.getCtx(), packoutHandler);
- packout.getCtx().remove(X_AD_Package_Exp_Detail.COLUMNNAME_AD_Form_ID);
- }
-}
diff --git a/plugins/pipo/src/org/adempiere/pipo2/handler/GenericPOElementHandler.java b/plugins/pipo/src/org/adempiere/pipo2/handler/GenericPOElementHandler.java
deleted file mode 100644
index 91ee290fba..0000000000
--- a/plugins/pipo/src/org/adempiere/pipo2/handler/GenericPOElementHandler.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/******************************************************************************
- * Product: Adempiere ERP & CRM Smart Business Solution *
- * Copyright (C) 1999-2006 Adempiere, Inc. All Rights Reserved. *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms version 2 of the GNU General Public License as published *
- * by the Free Software Foundation. This program is distributed in the hope *
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
- * See the GNU General Public License for more details. *
- * You should have received a copy of the GNU General Public License along *
- * with this program; if not, write to the Free Software Foundation, Inc., *
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
- * *
- * Copyright (C) 2005 Robert Klein. robeklein@hotmail.com *
- * Contributor(s): Low Heng Sin hengsin@avantz.com *
- *****************************************************************************/
-package org.adempiere.pipo2.handler;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-import javax.xml.transform.sax.TransformerHandler;
-
-import org.adempiere.exceptions.AdempiereException;
-import org.adempiere.model.GenericPO;
-import org.adempiere.pipo2.AbstractElementHandler;
-import org.adempiere.pipo2.PoExporter;
-import org.adempiere.pipo2.Element;
-import org.adempiere.pipo2.PackOut;
-import org.adempiere.pipo2.PoFiller;
-import org.compiere.model.MColumn;
-import org.compiere.model.MPackageExpDetail;
-import org.compiere.model.MRole;
-import org.compiere.model.MTable;
-import org.compiere.model.PO;
-import org.compiere.model.POInfo;
-import org.compiere.model.Query;
-import org.compiere.model.X_AD_Package_Exp_Detail;
-import org.compiere.util.DB;
-import org.compiere.util.DisplayType;
-import org.compiere.util.Env;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-/**
- *
- * @author Robert Klein.
- * @author Low Heng Sin
- *
- */
-public class GenericPOElementHandler extends AbstractElementHandler {
-
- public GenericPOElementHandler() {
- }
-
- public void startElement(Properties ctx, Element element) throws SAXException {
- String tableName = element.getElementValue();
-
- PO po = findPO(ctx, element);
- if (po == null) {
- MTable table = MTable.get(ctx, tableName);
- POInfo info = POInfo.getPOInfo(ctx, table.getAD_Table_ID());
- MColumn columns[] = table.getColumns(false);
- StringBuffer whereClause = new StringBuffer();
- List