Test Export Model in Export Format do not work
https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2910176&group_id=176962 Test Import Model do not work ADempiere Client https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2910169&group_id=176962 finish the implementation of Export Format Generator https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2910179&group_id=176962
This commit is contained in:
parent
ffbdd8f3ee
commit
4481f00b5d
|
@ -32,6 +32,7 @@ package org.adempiere.process;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Text;
|
import org.w3c.dom.Text;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Trifon Trifonov
|
* @author Trifon Trifonov
|
||||||
|
@ -214,20 +216,21 @@ public class Export extends SvrProcess
|
||||||
*/
|
*/
|
||||||
private void generateExportFormat(Element rootElement, MEXPFormat exportFormat, ResultSet rs, PO masterPO, int masterID, HashMap<String, Integer> variableMap) throws SQLException, Exception
|
private void generateExportFormat(Element rootElement, MEXPFormat exportFormat, ResultSet rs, PO masterPO, int masterID, HashMap<String, Integer> variableMap) throws SQLException, Exception
|
||||||
{
|
{
|
||||||
MEXPFormatLine[] formatLines = (MEXPFormatLine[]) exportFormat.getFormatLines();
|
Collection<MEXPFormatLine> formatLines = exportFormat.getFormatLines();
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
boolean elementHasValue = false;
|
boolean elementHasValue = false;
|
||||||
|
|
||||||
for (int i = 0; i < formatLines.length; i++) {
|
for (MEXPFormatLine formatLine : formatLines)
|
||||||
if ( formatLines[i].getType().equals(X_EXP_FormatLine.TYPE_XMLElement) ) {
|
{
|
||||||
|
if ( formatLine.getType().equals(X_EXP_FormatLine.TYPE_XMLElement) ) {
|
||||||
// process single XML Attribute
|
// process single XML Attribute
|
||||||
// Create new element
|
// Create new element
|
||||||
Element newElement = outDocument.createElement(formatLines[i].getValue());
|
Element newElement = outDocument.createElement(formatLine.getValue());
|
||||||
|
|
||||||
if (formatLines[i].getAD_Column_ID() == 0) {
|
if (formatLine.getAD_Column_ID() == 0) {
|
||||||
throw new Exception(Msg.getMsg (getCtx(), "EXPColumnMandatory"));
|
throw new Exception(Msg.getMsg (getCtx(), "EXPColumnMandatory"));
|
||||||
}
|
}
|
||||||
MColumn column = MColumn.get(getCtx(), formatLines[i].getAD_Column_ID());
|
MColumn column = MColumn.get(getCtx(), formatLine.getAD_Column_ID());
|
||||||
if (column == null) {
|
if (column == null) {
|
||||||
throw new Exception(Msg.getMsg (getCtx(), "EXPColumnMandatory"));
|
throw new Exception(Msg.getMsg (getCtx(), "EXPColumnMandatory"));
|
||||||
}
|
}
|
||||||
|
@ -241,7 +244,7 @@ public class Export extends SvrProcess
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
valueString = value.toString();
|
valueString = value.toString();
|
||||||
} else {
|
} else {
|
||||||
if (formatLines[i].isMandatory()) {
|
if (formatLine.isMandatory()) {
|
||||||
throw new Exception(Msg.getMsg (getCtx(), "EXPFieldMandatory"));
|
throw new Exception(Msg.getMsg (getCtx(), "EXPFieldMandatory"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,17 +281,17 @@ public class Export extends SvrProcess
|
||||||
} else {
|
} else {
|
||||||
// Empty field.
|
// Empty field.
|
||||||
}
|
}
|
||||||
} else if ( formatLines[i].getType().equals(X_EXP_FormatLine.TYPE_XMLAttribute) ) {
|
} else if ( formatLine.getType().equals(X_EXP_FormatLine.TYPE_XMLAttribute) ) {
|
||||||
// process single XML Attribute
|
// process single XML Attribute
|
||||||
/* // Create new element
|
/* // Create new element
|
||||||
Element newElement = outDocument.createElement(formatLines[i].getValue());
|
Element newElement = outDocument.createElement(formatLines[i].getValue());
|
||||||
if (hasContent) {
|
if (hasContent) {
|
||||||
rootElement.appendChild(newElement);
|
rootElement.appendChild(newElement);
|
||||||
}*/
|
}*/
|
||||||
if (formatLines[i].getAD_Column_ID() == 0) {
|
if (formatLine.getAD_Column_ID() == 0) {
|
||||||
throw new Exception(Msg.getMsg (getCtx(), "EXPColumnMandatory"));
|
throw new Exception(Msg.getMsg (getCtx(), "EXPColumnMandatory"));
|
||||||
}
|
}
|
||||||
MColumn column = MColumn.get(getCtx(), formatLines[i].getAD_Column_ID());
|
MColumn column = MColumn.get(getCtx(), formatLine.getAD_Column_ID());
|
||||||
if (column == null) {
|
if (column == null) {
|
||||||
throw new Exception(Msg.getMsg (getCtx(), "EXPColumnMandatory"));
|
throw new Exception(Msg.getMsg (getCtx(), "EXPColumnMandatory"));
|
||||||
}
|
}
|
||||||
|
@ -302,7 +305,7 @@ public class Export extends SvrProcess
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
valueString = value.toString();
|
valueString = value.toString();
|
||||||
} else {
|
} else {
|
||||||
if (formatLines[i].isMandatory()) {
|
if (formatLine.isMandatory()) {
|
||||||
throw new Exception(Msg.getMsg (getCtx(), "EXPFieldMandatory"));
|
throw new Exception(Msg.getMsg (getCtx(), "EXPFieldMandatory"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -330,17 +333,17 @@ public class Export extends SvrProcess
|
||||||
}*/
|
}*/
|
||||||
log.info("EXP Field - column=["+column.getColumnName()+"]; value=" + value);
|
log.info("EXP Field - column=["+column.getColumnName()+"]; value=" + value);
|
||||||
if (valueString != null && !"".equals(valueString) && !"null".equals(valueString)) {
|
if (valueString != null && !"".equals(valueString) && !"null".equals(valueString)) {
|
||||||
rootElement.setAttribute(formatLines[i].getValue(), valueString);
|
rootElement.setAttribute(formatLine.getValue(), valueString);
|
||||||
elementHasValue = true;
|
elementHasValue = true;
|
||||||
//increaseVariable(variableMap, formatLines[i].getVariableName()); // Increase value of Variable if any Variable
|
//increaseVariable(variableMap, formatLines[i].getVariableName()); // Increase value of Variable if any Variable
|
||||||
//increaseVariable(variableMap, TOTAL_SEGMENTS);
|
//increaseVariable(variableMap, TOTAL_SEGMENTS);
|
||||||
} else {
|
} else {
|
||||||
// Empty field.
|
// Empty field.
|
||||||
}
|
}
|
||||||
} else if ( formatLines[i].getType().equals(X_EXP_FormatLine.TYPE_EmbeddedEXPFormat) ) {
|
} else if ( formatLine.getType().equals(X_EXP_FormatLine.TYPE_EmbeddedEXPFormat) ) {
|
||||||
// process Embedded Export Format
|
// process Embedded Export Format
|
||||||
|
|
||||||
int embeddedFormat_ID = formatLines[i].getEXP_EmbeddedFormat_ID();
|
int embeddedFormat_ID = formatLine.getEXP_EmbeddedFormat_ID();
|
||||||
MEXPFormat embeddedFormat = new MEXPFormat(getCtx(), embeddedFormat_ID, get_TrxName());
|
MEXPFormat embeddedFormat = new MEXPFormat(getCtx(), embeddedFormat_ID, get_TrxName());
|
||||||
|
|
||||||
MTable tableEmbedded = MTable.get(getCtx(), embeddedFormat.getAD_Table_ID());
|
MTable tableEmbedded = MTable.get(getCtx(), embeddedFormat.getAD_Table_ID());
|
||||||
|
@ -366,8 +369,8 @@ public class Export extends SvrProcess
|
||||||
int embeddedID = rsEmbedded.getInt(tableEmbedded.getTableName() + "_ID");
|
int embeddedID = rsEmbedded.getInt(tableEmbedded.getTableName() + "_ID");
|
||||||
PO poEmbedded = tableEmbedded.getPO (embeddedID, get_TrxName());
|
PO poEmbedded = tableEmbedded.getPO (embeddedID, get_TrxName());
|
||||||
|
|
||||||
Element embeddedElement = outDocument.createElement(formatLines[i].getValue());
|
Element embeddedElement = outDocument.createElement(formatLine.getValue());
|
||||||
embeddedElement.appendChild(outDocument.createComment(formatLines[i].getDescription()));
|
embeddedElement.appendChild(outDocument.createComment(formatLine.getDescription()));
|
||||||
generateExportFormat(embeddedElement, embeddedFormat, rsEmbedded, poEmbedded, embeddedID, variableMap);
|
generateExportFormat(embeddedElement, embeddedFormat, rsEmbedded, poEmbedded, embeddedID, variableMap);
|
||||||
rootElement.appendChild(embeddedElement);
|
rootElement.appendChild(embeddedElement);
|
||||||
}
|
}
|
||||||
|
|
2
serverRoot/src/main/server/org/adempiere/server/rpl/XMLHelper.java → base/src/org/adempiere/process/rpl/XMLHelper.java
Normal file → Executable file
2
serverRoot/src/main/server/org/adempiere/server/rpl/XMLHelper.java → base/src/org/adempiere/process/rpl/XMLHelper.java
Normal file → Executable file
|
@ -26,7 +26,7 @@
|
||||||
* Sponsors: *
|
* Sponsors: *
|
||||||
* - E-evolution (http://www.e-evolution.com) *
|
* - E-evolution (http://www.e-evolution.com) *
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.adempiere.server.rpl;
|
package org.adempiere.process.rpl;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
|
@ -34,6 +34,7 @@ import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Text;
|
import org.w3c.dom.Text;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Trifon N. Trifonov
|
* @author Trifon N. Trifonov
|
||||||
* @author Antonio Cañaveral, e-Evolution
|
* @author Antonio Cañaveral, e-Evolution
|
||||||
|
@ -232,7 +234,7 @@ public class ExportHelper {
|
||||||
|
|
||||||
for (int id : ids)
|
for (int id : ids)
|
||||||
{
|
{
|
||||||
PO po = table.getPO(id, null);
|
PO po = table.getPO(id, exportFormat.get_TrxName());
|
||||||
log.info("Client = " + client.toString());
|
log.info("Client = " + client.toString());
|
||||||
log.finest("po.getAD_Org_ID() = " + po.getAD_Org_ID());
|
log.finest("po.getAD_Org_ID() = " + po.getAD_Org_ID());
|
||||||
log.finest("po.get_TrxName() = " + po.get_TrxName());
|
log.finest("po.get_TrxName() = " + po.get_TrxName());
|
||||||
|
@ -302,20 +304,22 @@ public class ExportHelper {
|
||||||
*/
|
*/
|
||||||
private void generateExportFormat(Element rootElement, MEXPFormat exportFormat, ResultSet rs, PO masterPO, int masterID, HashMap<String, Integer> variableMap) throws SQLException, Exception
|
private void generateExportFormat(Element rootElement, MEXPFormat exportFormat, ResultSet rs, PO masterPO, int masterID, HashMap<String, Integer> variableMap) throws SQLException, Exception
|
||||||
{
|
{
|
||||||
MEXPFormatLine[] formatLines = (MEXPFormatLine[]) exportFormat.getFormatLines();
|
Collection<MEXPFormatLine> formatLines = exportFormat.getFormatLines();
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
boolean elementHasValue = false;
|
boolean elementHasValue = false;
|
||||||
|
|
||||||
for (int i = 0; i < formatLines.length; i++) {
|
//for (int i = 0; i < formatLines.length; i++) {
|
||||||
if ( formatLines[i].getType().equals(X_EXP_FormatLine.TYPE_XMLElement) ) {
|
for (MEXPFormatLine formatLine : formatLines)
|
||||||
|
{
|
||||||
|
if ( formatLine.getType().equals(X_EXP_FormatLine.TYPE_XMLElement) ) {
|
||||||
// process single XML Attribute
|
// process single XML Attribute
|
||||||
// Create new element
|
// Create new element
|
||||||
Element newElement = outDocument.createElement(formatLines[i].getValue());
|
Element newElement = outDocument.createElement(formatLine.getValue());
|
||||||
|
|
||||||
if (formatLines[i].getAD_Column_ID() == 0) {
|
if (formatLine.getAD_Column_ID() == 0) {
|
||||||
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
|
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
|
||||||
}
|
}
|
||||||
MColumn column = MColumn.get(masterPO.getCtx(), formatLines[i].getAD_Column_ID());
|
MColumn column = MColumn.get(masterPO.getCtx(), formatLine.getAD_Column_ID());
|
||||||
if (column == null) {
|
if (column == null) {
|
||||||
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
|
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
|
||||||
}
|
}
|
||||||
|
@ -330,14 +334,14 @@ public class ExportHelper {
|
||||||
valueString = value.toString();
|
valueString = value.toString();
|
||||||
} else {
|
} else {
|
||||||
// Could remove this exception and create empty XML Element when column do not have value.
|
// Could remove this exception and create empty XML Element when column do not have value.
|
||||||
if (formatLines[i].isMandatory()) {
|
if (formatLine.isMandatory()) {
|
||||||
//throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPFieldMandatory"));
|
//throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPFieldMandatory"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (column.getAD_Reference_ID() == DisplayType.Date) {
|
if (column.getAD_Reference_ID() == DisplayType.Date) {
|
||||||
if (valueString != null) {
|
if (valueString != null) {
|
||||||
if (formatLines[i].getDateFormat() != null && !"".equals(formatLines[i].getDateFormat())) {
|
if (formatLine.getDateFormat() != null && !"".equals(formatLine.getDateFormat())) {
|
||||||
m_customDateFormat = new SimpleDateFormat( formatLines[i].getDateFormat() ); // "MM/dd/yyyy"
|
m_customDateFormat = new SimpleDateFormat( formatLine.getDateFormat() ); // "MM/dd/yyyy"
|
||||||
//Date date = m_customDateFormat.parse ( valueString );
|
//Date date = m_customDateFormat.parse ( valueString );
|
||||||
valueString = m_customDateFormat.format(Timestamp.valueOf (valueString));
|
valueString = m_customDateFormat.format(Timestamp.valueOf (valueString));
|
||||||
newElement.setAttribute("DateFormat", m_customDateFormat.toPattern()); // Add "DateForamt attribute"
|
newElement.setAttribute("DateFormat", m_customDateFormat.toPattern()); // Add "DateForamt attribute"
|
||||||
|
@ -351,8 +355,8 @@ public class ExportHelper {
|
||||||
}
|
}
|
||||||
} else if (column.getAD_Reference_ID() == DisplayType.DateTime) {
|
} else if (column.getAD_Reference_ID() == DisplayType.DateTime) {
|
||||||
if (valueString != null) {
|
if (valueString != null) {
|
||||||
if (formatLines[i].getDateFormat() != null && !"".equals(formatLines[i].getDateFormat())) {
|
if (formatLine.getDateFormat() != null && !"".equals(formatLine.getDateFormat())) {
|
||||||
m_customDateFormat = new SimpleDateFormat( formatLines[i].getDateFormat() ); // "MM/dd/yyyy"
|
m_customDateFormat = new SimpleDateFormat( formatLine.getDateFormat() ); // "MM/dd/yyyy"
|
||||||
//Date date = m_customDateFormat.parse ( valueString );
|
//Date date = m_customDateFormat.parse ( valueString );
|
||||||
valueString = m_customDateFormat.format(Timestamp.valueOf (valueString));
|
valueString = m_customDateFormat.format(Timestamp.valueOf (valueString));
|
||||||
newElement.setAttribute("DateFormat", m_customDateFormat.toPattern()); // Add "DateForamt attribute"
|
newElement.setAttribute("DateFormat", m_customDateFormat.toPattern()); // Add "DateForamt attribute"
|
||||||
|
@ -374,19 +378,19 @@ public class ExportHelper {
|
||||||
//increaseVariable(variableMap, TOTAL_SEGMENTS);
|
//increaseVariable(variableMap, TOTAL_SEGMENTS);
|
||||||
} else {
|
} else {
|
||||||
// Empty field.
|
// Empty field.
|
||||||
if (formatLines[i].isMandatory()) {
|
if (formatLine.isMandatory()) {
|
||||||
Text newText = outDocument.createTextNode("");
|
Text newText = outDocument.createTextNode("");
|
||||||
newElement.appendChild(newText);
|
newElement.appendChild(newText);
|
||||||
rootElement.appendChild(newElement);
|
rootElement.appendChild(newElement);
|
||||||
elementHasValue = true;
|
elementHasValue = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ( formatLines[i].getType().equals(X_EXP_FormatLine.TYPE_XMLAttribute) ) {
|
} else if ( formatLine.getType().equals(X_EXP_FormatLine.TYPE_XMLAttribute) ) {
|
||||||
// process single XML Attribute
|
// process single XML Attribute
|
||||||
if (formatLines[i].getAD_Column_ID() == 0) {
|
if (formatLine.getAD_Column_ID() == 0) {
|
||||||
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
|
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
|
||||||
}
|
}
|
||||||
MColumn column = MColumn.get(masterPO.getCtx(), formatLines[i].getAD_Column_ID());
|
MColumn column = MColumn.get(masterPO.getCtx(), formatLine.getAD_Column_ID());
|
||||||
if (column == null) {
|
if (column == null) {
|
||||||
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
|
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
|
||||||
}
|
}
|
||||||
|
@ -400,7 +404,7 @@ public class ExportHelper {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
valueString = value.toString();
|
valueString = value.toString();
|
||||||
} else {
|
} else {
|
||||||
if (formatLines[i].isMandatory()) {
|
if (formatLine.isMandatory()) {
|
||||||
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPFieldMandatory"));
|
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPFieldMandatory"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -428,17 +432,19 @@ public class ExportHelper {
|
||||||
}*/
|
}*/
|
||||||
log.info("EXP Field - column=["+column.getColumnName()+"]; value=" + value);
|
log.info("EXP Field - column=["+column.getColumnName()+"]; value=" + value);
|
||||||
if (valueString != null && !"".equals(valueString) && !"null".equals(valueString)) {
|
if (valueString != null && !"".equals(valueString) && !"null".equals(valueString)) {
|
||||||
rootElement.setAttribute(formatLines[i].getValue(), valueString);
|
rootElement.setAttribute(formatLine.getValue(), valueString);
|
||||||
elementHasValue = true;
|
elementHasValue = true;
|
||||||
//increaseVariable(variableMap, formatLines[i].getVariableName()); // Increase value of Variable if any Variable
|
//increaseVariable(variableMap, formatLines[i].getVariableName()); // Increase value of Variable if any Variable
|
||||||
//increaseVariable(variableMap, TOTAL_SEGMENTS);
|
//increaseVariable(variableMap, TOTAL_SEGMENTS);
|
||||||
} else {
|
} else {
|
||||||
// Empty field.
|
// Empty field.
|
||||||
}
|
}
|
||||||
} else if ( formatLines[i].getType().equals(X_EXP_FormatLine.TYPE_EmbeddedEXPFormat) ) {
|
}
|
||||||
|
else if ( formatLine.getType().equals(X_EXP_FormatLine.TYPE_EmbeddedEXPFormat) )
|
||||||
|
{
|
||||||
// process Embedded Export Format
|
// process Embedded Export Format
|
||||||
|
|
||||||
int embeddedFormat_ID = formatLines[i].getEXP_EmbeddedFormat_ID();
|
int embeddedFormat_ID = formatLine.getEXP_EmbeddedFormat_ID();
|
||||||
MEXPFormat embeddedFormat = new MEXPFormat(masterPO.getCtx(), embeddedFormat_ID, masterPO.get_TrxName());
|
MEXPFormat embeddedFormat = new MEXPFormat(masterPO.getCtx(), embeddedFormat_ID, masterPO.get_TrxName());
|
||||||
|
|
||||||
MTable tableEmbedded = MTable.get(masterPO.getCtx(), embeddedFormat.getAD_Table_ID());
|
MTable tableEmbedded = MTable.get(masterPO.getCtx(), embeddedFormat.getAD_Table_ID());
|
||||||
|
@ -465,9 +471,9 @@ public class ExportHelper {
|
||||||
int embeddedID = rsEmbedded.getInt(tableEmbedded.getTableName() + "_ID");
|
int embeddedID = rsEmbedded.getInt(tableEmbedded.getTableName() + "_ID");
|
||||||
PO poEmbedded = tableEmbedded.getPO (embeddedID, masterPO.get_TrxName());
|
PO poEmbedded = tableEmbedded.getPO (embeddedID, masterPO.get_TrxName());
|
||||||
|
|
||||||
Element embeddedElement = outDocument.createElement(formatLines[i].getValue());
|
Element embeddedElement = outDocument.createElement(formatLine.getValue());
|
||||||
if (formatLines[i].getDescription() != null && !"".equals(formatLines[i].getDescription())) {
|
if (formatLine.getDescription() != null && !"".equals(formatLine.getDescription())) {
|
||||||
embeddedElement.appendChild(outDocument.createComment(formatLines[i].getDescription()));
|
embeddedElement.appendChild(outDocument.createComment(formatLine.getDescription()));
|
||||||
}
|
}
|
||||||
generateExportFormat(embeddedElement, embeddedFormat, rsEmbedded, poEmbedded, embeddedID, variableMap);
|
generateExportFormat(embeddedElement, embeddedFormat, rsEmbedded, poEmbedded, embeddedID, variableMap);
|
||||||
rootElement.appendChild(embeddedElement);
|
rootElement.appendChild(embeddedElement);
|
||||||
|
@ -482,10 +488,12 @@ public class ExportHelper {
|
||||||
pstmt = null;
|
pstmt = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ( formatLines[i].getType().equals(X_EXP_FormatLine.TYPE_ReferencedEXPFormat) ) {
|
}
|
||||||
|
else if ( formatLine.getType().equals(X_EXP_FormatLine.TYPE_ReferencedEXPFormat) )
|
||||||
|
{
|
||||||
// process Referenced Export Format
|
// process Referenced Export Format
|
||||||
|
|
||||||
int embeddedFormat_ID = formatLines[i].getEXP_EmbeddedFormat_ID();
|
int embeddedFormat_ID = formatLine.getEXP_EmbeddedFormat_ID();
|
||||||
MEXPFormat embeddedFormat = new MEXPFormat(masterPO.getCtx(), embeddedFormat_ID, masterPO.get_TrxName());
|
MEXPFormat embeddedFormat = new MEXPFormat(masterPO.getCtx(), embeddedFormat_ID, masterPO.get_TrxName());
|
||||||
|
|
||||||
MTable tableEmbedded = MTable.get(masterPO.getCtx(), embeddedFormat.getAD_Table_ID());
|
MTable tableEmbedded = MTable.get(masterPO.getCtx(), embeddedFormat.getAD_Table_ID());
|
||||||
|
@ -499,10 +507,10 @@ public class ExportHelper {
|
||||||
sql.append(" AND ").append(embeddedFormat.getWhereClause());
|
sql.append(" AND ").append(embeddedFormat.getWhereClause());
|
||||||
}
|
}
|
||||||
log.info(sql.toString());
|
log.info(sql.toString());
|
||||||
if (formatLines[i].getAD_Column_ID() == 0) {
|
if (formatLine.getAD_Column_ID() == 0) {
|
||||||
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
|
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
|
||||||
}
|
}
|
||||||
MColumn column = MColumn.get(masterPO.getCtx(), formatLines[i].getAD_Column_ID());
|
MColumn column = MColumn.get(masterPO.getCtx(), formatLine.getAD_Column_ID());
|
||||||
if (column == null) {
|
if (column == null) {
|
||||||
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
|
throw new Exception(Msg.getMsg (masterPO.getCtx(), "EXPColumnMandatory"));
|
||||||
}
|
}
|
||||||
|
@ -532,9 +540,9 @@ public class ExportHelper {
|
||||||
int embeddedID = rsEmbedded.getInt(tableEmbedded.getTableName() + "_ID");
|
int embeddedID = rsEmbedded.getInt(tableEmbedded.getTableName() + "_ID");
|
||||||
PO poEmbedded = tableEmbedded.getPO (embeddedID, masterPO.get_TrxName());
|
PO poEmbedded = tableEmbedded.getPO (embeddedID, masterPO.get_TrxName());
|
||||||
|
|
||||||
Element embeddedElement = outDocument.createElement(formatLines[i].getValue());
|
Element embeddedElement = outDocument.createElement(formatLine.getValue());
|
||||||
if (formatLines[i].getDescription() != null && !"".equals(formatLines[i].getDescription())) {
|
if (formatLine.getDescription() != null && !"".equals(formatLine.getDescription())) {
|
||||||
embeddedElement.appendChild(outDocument.createComment(formatLines[i].getDescription()));
|
embeddedElement.appendChild(outDocument.createComment(formatLine.getDescription()));
|
||||||
}
|
}
|
||||||
generateExportFormat(embeddedElement, embeddedFormat, rsEmbedded, poEmbedded, embeddedID, variableMap);
|
generateExportFormat(embeddedElement, embeddedFormat, rsEmbedded, poEmbedded, embeddedID, variableMap);
|
||||||
rootElement.appendChild(embeddedElement);
|
rootElement.appendChild(embeddedElement);
|
||||||
|
|
|
@ -0,0 +1,165 @@
|
||||||
|
/******************************************************************************
|
||||||
|
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||||
|
* 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. *
|
||||||
|
* For the text or an alternative of this public license, you may reach us *
|
||||||
|
* Contributor(s): Victor Perez www.e-evolution.com *
|
||||||
|
* Copyright (C) 2003-2007 e-Evolution,SC. All Rights Reserved. *
|
||||||
|
*****************************************************************************/
|
||||||
|
package org.adempiere.process.rpl.exp;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.xml.transform.OutputKeys;
|
||||||
|
import javax.xml.transform.Result;
|
||||||
|
import javax.xml.transform.Source;
|
||||||
|
import javax.xml.transform.Transformer;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import javax.xml.transform.TransformerFactory;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
|
import org.compiere.Adempiere;
|
||||||
|
import org.compiere.model.MEXPFormat;
|
||||||
|
import org.compiere.model.MReplicationStrategy;
|
||||||
|
import org.compiere.model.ModelValidator;
|
||||||
|
import org.compiere.model.X_AD_ReplicationTable;
|
||||||
|
import org.compiere.process.ProcessInfo;
|
||||||
|
import org.compiere.process.ProcessInfoParameter;
|
||||||
|
import org.compiere.process.SvrProcess;
|
||||||
|
import org.compiere.util.CLogMgt;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author victor.perez@e-evolution.com
|
||||||
|
* FB [1963487 ] Is necessary new process to export and import with an Export
|
||||||
|
* @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1963487&group_id=176962
|
||||||
|
* @version $Id:$
|
||||||
|
*/
|
||||||
|
public class ModelExporter extends SvrProcess {
|
||||||
|
|
||||||
|
/** Client Parameter */
|
||||||
|
protected int p_AD_Client_ID = 0;
|
||||||
|
|
||||||
|
/** Document Type Parameter */
|
||||||
|
protected int p_C_DocType_ID = 0;
|
||||||
|
|
||||||
|
/** Record ID */
|
||||||
|
protected int p_Record_ID = 0;
|
||||||
|
/** EXP_Format_ID */
|
||||||
|
protected int p_EXP_Format_ID = 0;
|
||||||
|
/** File Name **/
|
||||||
|
protected String p_FileName = "";
|
||||||
|
|
||||||
|
/** Table ID */
|
||||||
|
int AD_Table_ID = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Parameters
|
||||||
|
*/
|
||||||
|
protected void prepare() {
|
||||||
|
|
||||||
|
p_Record_ID = getRecord_ID();
|
||||||
|
if (p_AD_Client_ID == 0)
|
||||||
|
p_AD_Client_ID = Env.getAD_Client_ID(getCtx());
|
||||||
|
AD_Table_ID = getTable_ID();
|
||||||
|
|
||||||
|
StringBuffer sb = new StringBuffer("AD_Table_ID=").append(AD_Table_ID);
|
||||||
|
sb.append("; Record_ID=").append(getRecord_ID());
|
||||||
|
// Parameter
|
||||||
|
ProcessInfoParameter[] paras = getParameter();
|
||||||
|
for (ProcessInfoParameter para : paras)
|
||||||
|
{
|
||||||
|
String name = para.getParameterName();
|
||||||
|
if (para.getParameter() == null)
|
||||||
|
;
|
||||||
|
else if (name.equals("EXP_Format_ID"))
|
||||||
|
p_EXP_Format_ID = para.getParameterAsInt();
|
||||||
|
else if (name.equals("FileName"))
|
||||||
|
p_FileName = (String)para.getParameter();
|
||||||
|
else
|
||||||
|
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(p_EXP_Format_ID == 0)
|
||||||
|
p_EXP_Format_ID = p_Record_ID;
|
||||||
|
if(p_FileName == null)
|
||||||
|
{
|
||||||
|
// Load XML file and parse it
|
||||||
|
String fileNameOr = org.compiere.util.Ini.findAdempiereHome()
|
||||||
|
+ System.getProperty("file.separator")
|
||||||
|
+ "data"
|
||||||
|
+ System.getProperty("file.separator")
|
||||||
|
+ "ExportFile.xml";
|
||||||
|
p_FileName = fileNameOr;
|
||||||
|
}
|
||||||
|
log.info(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process
|
||||||
|
*
|
||||||
|
* @return info
|
||||||
|
*/
|
||||||
|
protected String doIt() throws Exception
|
||||||
|
{
|
||||||
|
ExportHelper expHelper = new ExportHelper(getCtx(),p_AD_Client_ID);
|
||||||
|
MEXPFormat exportFormat = new MEXPFormat (getCtx(), p_EXP_Format_ID, get_TrxName() );
|
||||||
|
File file = new File(p_FileName);
|
||||||
|
Document doc = expHelper.exportRecord(exportFormat,"", MReplicationStrategy.REPLICATION_TABLE, X_AD_ReplicationTable.REPLICATIONTYPE_Merge,ModelValidator.TYPE_AFTER_CHANGE);
|
||||||
|
// Save the document to the disk file
|
||||||
|
TransformerFactory tranFactory = TransformerFactory.newInstance();
|
||||||
|
|
||||||
|
tranFactory.setAttribute("indent-number", 4);
|
||||||
|
|
||||||
|
Transformer aTransformer = tranFactory.newTransformer();
|
||||||
|
aTransformer.setOutputProperty(OutputKeys.METHOD, "xml");
|
||||||
|
aTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||||
|
Source src = new DOMSource(doc);
|
||||||
|
|
||||||
|
// =================================== Write to String
|
||||||
|
Writer writer = new StringWriter();
|
||||||
|
Result dest2 = new StreamResult(writer);
|
||||||
|
aTransformer.transform(src, dest2);
|
||||||
|
// =================================== Write to Disk
|
||||||
|
try {
|
||||||
|
Result dest = new StreamResult(file);
|
||||||
|
aTransformer.transform(src, dest);
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
|
||||||
|
} catch (TransformerException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
return "Exported";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
CLogMgt.setLoggerLevel(Level.INFO, null);
|
||||||
|
CLogMgt.setLevel(Level.INFO);
|
||||||
|
|
||||||
|
Adempiere.startupEnvironment(true);
|
||||||
|
ProcessInfo pi = new ProcessInfo("Test Import Model", 1000000);
|
||||||
|
pi.setAD_Client_ID(11);
|
||||||
|
pi.setAD_User_ID(100);
|
||||||
|
|
||||||
|
ModelExporter modelExporter = new ModelExporter();
|
||||||
|
modelExporter.startProcess(Env.getCtx(), pi, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
49
serverRoot/src/main/server/org/adempiere/server/rpl/imp/ImportHelper.java → base/src/org/adempiere/process/rpl/imp/ImportHelper.java
Normal file → Executable file
49
serverRoot/src/main/server/org/adempiere/server/rpl/imp/ImportHelper.java → base/src/org/adempiere/process/rpl/imp/ImportHelper.java
Normal file → Executable file
|
@ -26,20 +26,22 @@
|
||||||
* Sponsors: *
|
* Sponsors: *
|
||||||
* - E-evolution (http://www.e-evolution.com/) *
|
* - E-evolution (http://www.e-evolution.com/) *
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.adempiere.server.rpl.imp;
|
package org.adempiere.process.rpl.imp;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.xml.xpath.XPathExpressionException;
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
|
|
||||||
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.adempiere.process.rpl.exp.ExportHelper;
|
import org.adempiere.process.rpl.exp.ExportHelper;
|
||||||
import org.adempiere.server.rpl.XMLHelper;
|
import org.adempiere.process.rpl.XMLHelper;
|
||||||
import org.compiere.model.I_AD_Client;
|
import org.compiere.model.I_AD_Client;
|
||||||
import org.compiere.model.MClient;
|
import org.compiere.model.MClient;
|
||||||
import org.compiere.model.MColumn;
|
import org.compiere.model.MColumn;
|
||||||
|
@ -266,8 +268,8 @@ public class ImportHelper {
|
||||||
StringBuffer orderBy = new StringBuffer(MEXPFormatLine.COLUMNNAME_IsMandatory).append(" DESC ")
|
StringBuffer orderBy = new StringBuffer(MEXPFormatLine.COLUMNNAME_IsMandatory).append(" DESC ")
|
||||||
.append(", ").append(MEXPFormatLine.COLUMNNAME_Position);
|
.append(", ").append(MEXPFormatLine.COLUMNNAME_Position);
|
||||||
|
|
||||||
MEXPFormatLine[] formatLines = expFormat.getFormatLinesOrderedBy(orderBy.toString());
|
Collection<MEXPFormatLine> formatLines = expFormat.getFormatLinesOrderedBy(orderBy.toString());
|
||||||
if (formatLines == null || formatLines.length < 1)
|
if (formatLines == null || formatLines.size() < 1)
|
||||||
{
|
{
|
||||||
throw new Exception(Msg.getMsg(ctx, "EXPFormatNoLines"));
|
throw new Exception(Msg.getMsg(ctx, "EXPFormatNoLines"));
|
||||||
}
|
}
|
||||||
|
@ -472,8 +474,7 @@ public class ImportHelper {
|
||||||
//
|
//
|
||||||
if (!Util.isEmpty(value.toString()))
|
if (!Util.isEmpty(value.toString()))
|
||||||
{
|
{
|
||||||
double doubleValue = Double.parseDouble(value.toString());
|
value = new Integer(value.toString());
|
||||||
value = new BigDecimal(doubleValue);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -567,22 +568,25 @@ public class ImportHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get list with all Unique columns!
|
// Get list with all Unique columns!
|
||||||
MEXPFormatLine[] uniqueFormatLines = expFormat.getUniqueColumns();
|
Collection<MEXPFormatLine> uniqueFormatLines = expFormat.getUniqueColumns();
|
||||||
if (uniqueFormatLines == null || uniqueFormatLines.length < 1)
|
if (uniqueFormatLines == null || uniqueFormatLines.size() < 1)
|
||||||
{
|
{
|
||||||
throw new Exception(Msg.getMsg(ctx, "EXPFormatLineNoUniqueColumns"));
|
throw new AdempiereException(Msg.getMsg(ctx, "EXPFormatLineNoUniqueColumns"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Object[] cols = new Object[uniqueFormatLines.length];
|
Object[] cols = new Object[uniqueFormatLines.size()];
|
||||||
Object[] params = new Object[uniqueFormatLines.length];
|
Object[] params = new Object[uniqueFormatLines.size()];
|
||||||
StringBuffer whereClause= new StringBuffer("");
|
StringBuffer whereClause= new StringBuffer("");
|
||||||
int col = 0;
|
int col = 0;
|
||||||
|
String formatLines = "";
|
||||||
for (MEXPFormatLine uniqueFormatLine : uniqueFormatLines)
|
for (MEXPFormatLine uniqueFormatLine : uniqueFormatLines)
|
||||||
{
|
{
|
||||||
MColumn column = MColumn.get(ctx, uniqueFormatLine.getAD_Column_ID());
|
MColumn column = MColumn.get(ctx, uniqueFormatLine.getAD_Column_ID());
|
||||||
log.info("column = ["+column+"]");
|
log.info("column = ["+column+"]");
|
||||||
String valuecol=column.getColumnName();
|
String valuecol=column.getColumnName();
|
||||||
|
|
||||||
|
formatLines = formatLines + "|"+ valuecol;
|
||||||
|
|
||||||
if (MEXPFormatLine.TYPE_XMLElement.equals(uniqueFormatLine.getType()))
|
if (MEXPFormatLine.TYPE_XMLElement.equals(uniqueFormatLine.getType()))
|
||||||
{
|
{
|
||||||
// XML Element
|
// XML Element
|
||||||
|
@ -626,10 +630,23 @@ public class ImportHelper {
|
||||||
{
|
{
|
||||||
params[col] = (String)cols[col];
|
params[col] = (String)cols[col];
|
||||||
}
|
}
|
||||||
else if( DisplayType.Amount == column.getAD_Reference_ID()
|
else if ( DisplayType.isID(column.getAD_Reference_ID())
|
||||||
|| DisplayType.Number == column.getAD_Reference_ID()
|
|| DisplayType.Integer == column.getAD_Reference_ID())
|
||||||
|| DisplayType.CostPrice == column.getAD_Reference_ID()
|
{
|
||||||
|| DisplayType.Quantity == column.getAD_Reference_ID())
|
Object value = cols[col];
|
||||||
|
if (!Util.isEmpty(value.toString()))
|
||||||
|
{
|
||||||
|
//double doubleValue = Double.parseDouble(value.toString());
|
||||||
|
value = new Integer(value.toString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value=null;
|
||||||
|
}
|
||||||
|
|
||||||
|
params[col] = value;
|
||||||
|
}
|
||||||
|
else if( DisplayType.isNumeric(column.getAD_Reference_ID()))
|
||||||
{
|
{
|
||||||
valuecol="Round("+valuecol+",2)";
|
valuecol="Round("+valuecol+",2)";
|
||||||
params[col] = new BigDecimal((String)cols[col]).setScale(2, BigDecimal.ROUND_HALF_UP);
|
params[col] = new BigDecimal((String)cols[col]).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||||
|
@ -653,7 +670,7 @@ public class ImportHelper {
|
||||||
|
|
||||||
if(values.size()>1)//The Return Object must be always one
|
if(values.size()>1)//The Return Object must be always one
|
||||||
{
|
{
|
||||||
throw new Exception(Msg.getMsg(ctx, "EXPFormatIncorrectFormatDefinition"));
|
throw new AdempiereException(Msg.getMsg(ctx, "EXPFormatLineNoUniqueColumns") + " : " +expFormat.getName() + "(" +formatLines+")");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(values.size()<=0)//Means that is a new record
|
if(values.size()<=0)//Means that is a new record
|
|
@ -26,11 +26,11 @@
|
||||||
* Sponsors: *
|
* Sponsors: *
|
||||||
* - E-evolution (http://www.e-evolution.com/) *
|
* - E-evolution (http://www.e-evolution.com/) *
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
package org.adempiere.server.rpl.imp;
|
package org.adempiere.process.rpl.imp;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.server.rpl.XMLHelper;
|
import org.adempiere.process.rpl.XMLHelper;
|
||||||
import org.compiere.Adempiere;
|
import org.compiere.Adempiere;
|
||||||
import org.compiere.process.ProcessInfo;
|
import org.compiere.process.ProcessInfo;
|
||||||
import org.compiere.process.ProcessInfoParameter;
|
import org.compiere.process.ProcessInfoParameter;
|
|
@ -30,19 +30,13 @@
|
||||||
|
|
||||||
package org.compiere.model;
|
package org.compiere.model;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.compiere.model.MTable;
|
|
||||||
import org.compiere.model.Query;
|
|
||||||
import org.compiere.util.CCache;
|
import org.compiere.util.CCache;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Trifon N. Trifonov
|
* @author Trifon N. Trifonov
|
||||||
|
@ -51,10 +45,11 @@ import org.compiere.util.DB;
|
||||||
* <li>http://sourceforge.net/tracker/index.php?func=detail&aid=2195090&group_id=176962&atid=879335
|
* <li>http://sourceforge.net/tracker/index.php?func=detail&aid=2195090&group_id=176962&atid=879335
|
||||||
*/
|
*/
|
||||||
public class MEXPFormat extends X_EXP_Format {
|
public class MEXPFormat extends X_EXP_Format {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 1070027055056912752L;
|
private static final long serialVersionUID = 1455411275338766608L;
|
||||||
|
|
||||||
/** Static Logger */
|
/** Static Logger */
|
||||||
private static CLogger s_log = CLogger.getCLogger (MEXPFormat.class);
|
private static CLogger s_log = CLogger.getCLogger (MEXPFormat.class);
|
||||||
|
@ -69,87 +64,30 @@ public class MEXPFormat extends X_EXP_Format {
|
||||||
super (ctx, rs, trxName);
|
super (ctx, rs, trxName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MEXPFormatLine[] getFormatLines() {
|
public Collection<MEXPFormatLine> getFormatLines() {
|
||||||
return getFormatLinesOrderedBy(X_EXP_FormatLine.COLUMNNAME_Position);
|
return getFormatLinesOrderedBy(X_EXP_FormatLine.COLUMNNAME_Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MEXPFormatLine[] getFormatLinesOrderedBy(String orderBy) {
|
public Collection<MEXPFormatLine> getFormatLinesOrderedBy(String orderBy)
|
||||||
List<MEXPFormatLine> resultList = new ArrayList<MEXPFormatLine>();
|
{
|
||||||
|
final String clauseWhere = X_EXP_FormatLine.COLUMNNAME_EXP_Format_ID + "=?";
|
||||||
StringBuffer sql = new StringBuffer("SELECT * ")
|
return new Query(getCtx() , I_EXP_FormatLine.Table_Name, clauseWhere , get_TrxName())
|
||||||
.append(" FROM ").append(X_EXP_FormatLine.Table_Name)
|
.setOnlyActiveRecords(true)
|
||||||
.append(" WHERE ").append(X_EXP_FormatLine.COLUMNNAME_EXP_Format_ID).append("=?")
|
.setParameters(new Object[]{getEXP_Format_ID()})
|
||||||
.append(" AND IsActive = ?")
|
.setOrderBy(orderBy)
|
||||||
.append(" ORDER BY ").append(orderBy);
|
.list();
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
MEXPFormatLine exportLine = null;
|
|
||||||
try {
|
|
||||||
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
|
||||||
pstmt.setInt(1, getEXP_Format_ID());
|
|
||||||
pstmt.setString(2, "Y");
|
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
|
||||||
while ( rs.next() ) {
|
|
||||||
exportLine = new MEXPFormatLine (getCtx(), rs, get_TrxName());
|
|
||||||
resultList.add(exportLine);
|
|
||||||
}
|
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
} catch (SQLException e) {
|
|
||||||
s_log.log(Level.SEVERE, sql.toString(), e);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (pstmt != null) pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
} catch (Exception e) { pstmt = null; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MEXPFormatLine[] result = (MEXPFormatLine[])resultList.toArray( new MEXPFormatLine[0]);
|
public Collection<MEXPFormatLine> getUniqueColumns() throws SQLException {
|
||||||
return result;
|
final String clauseWhere = X_EXP_FormatLine.COLUMNNAME_EXP_Format_ID+"= ?"
|
||||||
|
+ " AND " + X_EXP_FormatLine.COLUMNNAME_IsPartUniqueIndex +"= ?";
|
||||||
|
return new Query(getCtx(), I_EXP_FormatLine.Table_Name, clauseWhere, get_TrxName())
|
||||||
|
.setOnlyActiveRecords(true)
|
||||||
|
.setParameters(new Object[]{getEXP_Format_ID(), "Y"})
|
||||||
|
.setOrderBy(X_EXP_FormatLine.COLUMNNAME_Position)
|
||||||
|
.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MEXPFormatLine[] getUniqueColumns() throws SQLException {
|
|
||||||
List<MEXPFormatLine> resultList = new ArrayList<MEXPFormatLine>();
|
|
||||||
|
|
||||||
StringBuffer sql = new StringBuffer("SELECT * ")
|
|
||||||
.append(" FROM ").append(X_EXP_FormatLine.Table_Name)
|
|
||||||
.append(" WHERE ").append(X_EXP_FormatLine.COLUMNNAME_EXP_Format_ID).append("= ?")
|
|
||||||
.append(" AND IsActive = ?")
|
|
||||||
.append(" AND ").append(X_EXP_FormatLine.COLUMNNAME_IsPartUniqueIndex).append("= ?")
|
|
||||||
.append(" ORDER BY ").append(X_EXP_FormatLine.COLUMNNAME_Position);
|
|
||||||
PreparedStatement pstmt = null;
|
|
||||||
MEXPFormatLine exportLine = null;
|
|
||||||
log.info(sql.toString());
|
|
||||||
|
|
||||||
log.info("pstmt.setInt(1, getEXP_Format_ID() = " + getEXP_Format_ID());
|
|
||||||
try {
|
|
||||||
pstmt = DB.prepareStatement (sql.toString(), get_TrxName());
|
|
||||||
pstmt.setInt(1, getEXP_Format_ID());
|
|
||||||
pstmt.setString(2, "Y");
|
|
||||||
pstmt.setString(3, "Y");
|
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
|
||||||
while ( rs.next() ) {
|
|
||||||
exportLine = new MEXPFormatLine (getCtx(), rs, get_TrxName());
|
|
||||||
resultList.add(exportLine);
|
|
||||||
}
|
|
||||||
rs.close ();
|
|
||||||
pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
} catch (SQLException e) {
|
|
||||||
s_log.log(Level.SEVERE, sql.toString(), e);
|
|
||||||
throw e;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
if (pstmt != null) pstmt.close ();
|
|
||||||
pstmt = null;
|
|
||||||
} catch (Exception e) { pstmt = null; }
|
|
||||||
}
|
|
||||||
|
|
||||||
MEXPFormatLine[] result = (MEXPFormatLine[])resultList.toArray( new MEXPFormatLine[0]);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static MEXPFormat getFormatByValueAD_Client_IDAndVersion(Properties ctx, String value, int AD_Client_ID, String version, String trxName)
|
public static MEXPFormat getFormatByValueAD_Client_IDAndVersion(Properties ctx, String value, int AD_Client_ID, String version, String trxName)
|
||||||
throws SQLException
|
throws SQLException
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,9 +15,11 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
package org.eevolution.process;
|
package org.eevolution.process;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.compiere.model.MColumn;
|
import org.compiere.model.MColumn;
|
||||||
import org.compiere.model.MEXPFormat;
|
import org.compiere.model.MEXPFormat;
|
||||||
import org.compiere.model.MEXPFormatLine;
|
import org.compiere.model.MEXPFormatLine;
|
||||||
|
@ -45,30 +47,33 @@ public class ExportFormatGenerator extends SvrProcess
|
||||||
private boolean p_IsMandatory = false;
|
private boolean p_IsMandatory = false;
|
||||||
private boolean p_IsInsertRecord= false;
|
private boolean p_IsInsertRecord= false;
|
||||||
private Hashtable m_formats = new Hashtable();
|
private Hashtable m_formats = new Hashtable();
|
||||||
|
private String version = "3.2.0";
|
||||||
private String m_parent_table = null;
|
private String m_parent_table = null;
|
||||||
private String m_format_value = null;
|
private String m_format_value = null;
|
||||||
private int m_level = -1;
|
private int m_level = -1;
|
||||||
|
private MTab currentTab = null;
|
||||||
|
private MWindow window = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare - e.g., get Parameters.
|
* Prepare - e.g., get Parameters.
|
||||||
*/
|
*/
|
||||||
protected void prepare()
|
protected void prepare()
|
||||||
{
|
{
|
||||||
ProcessInfoParameter[] para = getParameter();
|
ProcessInfoParameter[] paras = getParameter();
|
||||||
for (int i = 0; i < para.length; i++)
|
for (ProcessInfoParameter para : paras)
|
||||||
{
|
{
|
||||||
String name = para[i].getParameterName();
|
String name = para.getParameterName();
|
||||||
if (para[i].getParameter() == null)
|
if (para.getParameter() == null)
|
||||||
;
|
;
|
||||||
else if (name.equals("AD_Window_ID"))
|
else if (name.equals("AD_Window_ID"))
|
||||||
p_AD_Window_ID = para[i].getParameterAsInt();
|
p_AD_Window_ID = para.getParameterAsInt();
|
||||||
else if (name.equals("IsMandatory"))
|
else if (name.equals("IsMandatory"))
|
||||||
{
|
{
|
||||||
p_IsMandatory = "Y".equals(para[i].getParameter());
|
p_IsMandatory = "Y".equals(para.getParameter());
|
||||||
}
|
}
|
||||||
else if (name.equals("IsInsertRecord"))
|
else if (name.equals("IsInsertRecord"))
|
||||||
{
|
{
|
||||||
p_IsInsertRecord = "Y".equals(para[i].getParameter());
|
p_IsInsertRecord = "Y".equals(para.getParameter());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
log.log(Level.SEVERE, "Unknown Parameter: " + name);
|
||||||
|
@ -82,7 +87,7 @@ public class ExportFormatGenerator extends SvrProcess
|
||||||
*/
|
*/
|
||||||
protected String doIt () throws Exception
|
protected String doIt () throws Exception
|
||||||
{
|
{
|
||||||
MWindow window = new MWindow(getCtx(),p_AD_Window_ID, get_TrxName());
|
window = new MWindow(getCtx(),p_AD_Window_ID, get_TrxName());
|
||||||
MTab[] tabs = window.getTabs(true, get_TrxName());
|
MTab[] tabs = window.getTabs(true, get_TrxName());
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,7 +149,7 @@ public class ExportFormatGenerator extends SvrProcess
|
||||||
return format.getValue();
|
return format.getValue();
|
||||||
|
|
||||||
String where=" value = ? ";
|
String where=" value = ? ";
|
||||||
Query sql = new Query(getCtx(),MEXPFormat.Table_Name,where,null).setParameters(new Object[]{formatValue});
|
Query sql = new Query(getCtx(),MEXPFormat.Table_Name,where,get_TrxName()).setParameters(new Object[]{formatValue});
|
||||||
if(sql.match())
|
if(sql.match())
|
||||||
{
|
{
|
||||||
format = (MEXPFormat) sql.first();
|
format = (MEXPFormat) sql.first();
|
||||||
|
@ -152,17 +157,17 @@ public class ExportFormatGenerator extends SvrProcess
|
||||||
return format.getValue();
|
return format.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
format = MEXPFormat.getFormatByValueAD_Client_IDAndVersion(getCtx(), formatValue, getAD_Client_ID(), "1", get_TrxName());
|
format = MEXPFormat.getFormatByValueAD_Client_IDAndVersion(getCtx(), formatValue, getAD_Client_ID(), version, get_TrxName());
|
||||||
if(format == null)
|
if(format == null)
|
||||||
format = new MEXPFormat(getCtx(), 0 , get_TrxName());
|
format = new MEXPFormat(getCtx(), 0 , get_TrxName());
|
||||||
|
format.setAD_Org_ID(0);
|
||||||
format.setValue(formatValue);
|
format.setValue(formatValue);
|
||||||
format.setName(table.getName());
|
format.setName(table.getName());
|
||||||
format.setAD_Table_ID(table.getAD_Table_ID());
|
format.setAD_Table_ID(table.getAD_Table_ID());
|
||||||
format.setDescription(table.getDescription());
|
format.setDescription(table.getDescription());
|
||||||
format.setHelp(table.getHelp());
|
format.setHelp(table.getHelp());
|
||||||
format.setVersion("1");
|
format.setVersion(version);
|
||||||
format.save();
|
format.saveEx();
|
||||||
if (format != null)
|
if (format != null)
|
||||||
m_formats.put(format.getValue(), format);
|
m_formats.put(format.getValue(), format);
|
||||||
|
|
||||||
|
@ -184,41 +189,54 @@ public class ExportFormatGenerator extends SvrProcess
|
||||||
private int createFormatLine(MEXPFormat format, MTable table, MColumn col, int position,boolean force) throws Exception
|
private int createFormatLine(MEXPFormat format, MTable table, MColumn col, int position,boolean force) throws Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
MEXPFormatLine format_line =null;
|
MEXPFormatLine formatLine =null;
|
||||||
String formatlinevalue= col.getColumnName();
|
String formatlinevalue= col.getColumnName();
|
||||||
format_line = MEXPFormatLine.getFormatLineByValue(getCtx(),formatlinevalue ,format.getEXP_Format_ID(),get_TrxName());
|
formatLine = MEXPFormatLine.getFormatLineByValue(getCtx(),formatlinevalue ,format.getEXP_Format_ID(),get_TrxName());
|
||||||
if(format_line==null)
|
if(formatLine==null)
|
||||||
format_line = new MEXPFormatLine(getCtx(),0,get_TrxName());
|
formatLine = new MEXPFormatLine(getCtx(),0,get_TrxName());
|
||||||
|
|
||||||
format_line.setEXP_Format_ID(format.getEXP_Format_ID());
|
|
||||||
format_line.setValue(formatlinevalue);
|
formatLine.setAD_Org_ID(0);
|
||||||
format_line.setName(col.getName());
|
formatLine.setEXP_Format_ID(format.getEXP_Format_ID());
|
||||||
format_line.setDescription(col.getDescription());
|
formatLine.setValue(formatlinevalue);
|
||||||
format_line.setHelp(col.getHelp());
|
formatLine.setName(col.getName());
|
||||||
format_line.setPosition(position);
|
formatLine.setDescription(col.getDescription());
|
||||||
format_line.setIsMandatory(col.isMandatory());
|
formatLine.setHelp(col.getHelp());
|
||||||
if(force||col.isIdentifier())
|
formatLine.setPosition(position);
|
||||||
|
formatLine.setIsMandatory(col.isMandatory());
|
||||||
|
if(force
|
||||||
|
|| (col.isIdentifier()
|
||||||
|
&& !col.isKey()))
|
||||||
{
|
{
|
||||||
format_line.setIsPartUniqueIndex(true);
|
formatLine.setIsPartUniqueIndex(true);
|
||||||
format_line.setIsActive(true);
|
formatLine.setIsActive(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
format_line.setIsActive(false);
|
{
|
||||||
|
formatLine.setIsActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
MTable tabledir = null;
|
MTable tabledir = null;
|
||||||
|
|
||||||
if(col.getColumnName().equals(m_parent_table+"_ID")&(col.getAD_Reference_ID()==DisplayType.Search|col.getAD_Reference_ID()==DisplayType.TableDir))
|
if(col.getColumnName().equals(m_parent_table+"_ID")
|
||||||
|
&& DisplayType.isID(col.getAD_Reference_ID()))
|
||||||
{
|
{
|
||||||
MEXPFormat referenceFormat = null;
|
MEXPFormat referenceFormat = null;
|
||||||
referenceFormat = MEXPFormat.getFormatByValueAD_Client_IDAndVersion(getCtx(), m_parent_table+"_Key", getAD_Client_ID(), "1", get_TrxName());
|
referenceFormat = MEXPFormat.getFormatByValueAD_Client_IDAndVersion(getCtx(), m_parent_table+"_Key", getAD_Client_ID(), version, get_TrxName());
|
||||||
|
|
||||||
if(referenceFormat == null)
|
if(referenceFormat == null)
|
||||||
|
{
|
||||||
referenceFormat = new MEXPFormat(getCtx(), 0 , get_TrxName());
|
referenceFormat = new MEXPFormat(getCtx(), 0 , get_TrxName());
|
||||||
|
}
|
||||||
|
|
||||||
|
referenceFormat.setAD_Org_ID(0);
|
||||||
referenceFormat.setValue(m_parent_table+"_Key");
|
referenceFormat.setValue(m_parent_table+"_Key");
|
||||||
referenceFormat.setName(m_parent_table+"_Key");
|
referenceFormat.setName(m_parent_table+"_Key");
|
||||||
referenceFormat.setAD_Table_ID(table.getAD_Table_ID());
|
referenceFormat.setAD_Table_ID(MTable.getTable_ID(m_parent_table));
|
||||||
referenceFormat.setDescription(table.getDescription());
|
referenceFormat.setDescription(table.getDescription());
|
||||||
referenceFormat.setHelp(table.getHelp());
|
referenceFormat.setHelp(table.getHelp());
|
||||||
referenceFormat.setVersion("1");
|
referenceFormat.setVersion(version);
|
||||||
referenceFormat.save();
|
referenceFormat.saveEx();
|
||||||
|
|
||||||
int AD_Column_ID=DB.getSQLValue(get_TrxName(), "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID=(SELECT AD_Table_ID FROM AD_Table WHERE TableName=?) AND UPPER(ColumnName)='DOCUMENTNO'",m_parent_table);
|
int AD_Column_ID=DB.getSQLValue(get_TrxName(), "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID=(SELECT AD_Table_ID FROM AD_Table WHERE TableName=?) AND UPPER(ColumnName)='DOCUMENTNO'",m_parent_table);
|
||||||
if(AD_Column_ID>0)
|
if(AD_Column_ID>0)
|
||||||
|
@ -229,57 +247,86 @@ public class ExportFormatGenerator extends SvrProcess
|
||||||
AD_Column_ID=DB.getSQLValue(get_TrxName(), "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID=(SELECT AD_Table_ID FROM AD_Table WHERE TableName=?) AND UPPER(ColumnName)='C_DOCTYPE_ID'",m_parent_table);
|
AD_Column_ID=DB.getSQLValue(get_TrxName(), "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID=(SELECT AD_Table_ID FROM AD_Table WHERE TableName=?) AND UPPER(ColumnName)='C_DOCTYPE_ID'",m_parent_table);
|
||||||
if(AD_Column_ID>0)
|
if(AD_Column_ID>0)
|
||||||
createFormatLine(referenceFormat, table, new MColumn(getCtx(),AD_Column_ID,get_TrxName()), 20,true);
|
createFormatLine(referenceFormat, table, new MColumn(getCtx(),AD_Column_ID,get_TrxName()), 20,true);
|
||||||
|
formatLine.setValue(m_parent_table+"_Key");
|
||||||
|
formatLine.setName("Key DocumentNo_C_DocType");
|
||||||
|
formatLine.setAD_Column_ID(col.getAD_Column_ID());
|
||||||
|
formatLine.setType(MEXPFormatLine.TYPE_ReferencedEXPFormat);
|
||||||
|
formatLine.setEXP_EmbeddedFormat_ID(referenceFormat.getEXP_Format_ID());
|
||||||
|
formatLine.saveEx();
|
||||||
|
|
||||||
format_line.setValue(m_parent_table+"_DocumentNo_C_DocType_Key");
|
if(m_parent_table != null)
|
||||||
format_line.setName("Key DocumentNo_C_DocType");
|
{
|
||||||
format_line.setAD_Column_ID(col.getAD_Column_ID());
|
if (col.isParent() && col.getColumnName().contains(m_parent_table))
|
||||||
format_line.setType(MEXPFormatLine.TYPE_ReferencedEXPFormat);
|
{
|
||||||
format_line.setEXP_EmbeddedFormat_ID(referenceFormat.getEXP_Format_ID());
|
|
||||||
format_line.save();
|
int reference = ((MEXPFormat)m_formats.get(m_format_value)).getEXP_Format_ID();
|
||||||
return format_line.getEXP_FormatLine_ID();
|
MEXPFormatLine embededformatLine = new MEXPFormatLine(getCtx(), 0 , get_TrxName());
|
||||||
}else
|
embededformatLine.setAD_Org_ID(0);
|
||||||
|
embededformatLine.setValue(format.getValue()+"_Embedded");
|
||||||
|
embededformatLine.setName("Embedded "+ format.getName());
|
||||||
|
embededformatLine.setEXP_EmbeddedFormat_ID(formatLine.getEXP_Format_ID());
|
||||||
|
embededformatLine.setEXP_Format_ID(reference);
|
||||||
|
embededformatLine.setType(MEXPFormatLine.TYPE_EmbeddedEXPFormat);
|
||||||
|
embededformatLine.setAD_Column_ID(col.getAD_Column_ID());
|
||||||
|
embededformatLine.saveEx();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("Export Format Line:"+formatLine.getName());
|
||||||
|
return formatLine.getEXP_FormatLine_ID();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
AD_Column_ID=DB.getSQLValue(get_TrxName(), "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID=(SELECT AD_Table_ID FROM AD_Table WHERE TableName=?) AND UPPER(ColumnName)='NAME'",m_parent_table);
|
AD_Column_ID=DB.getSQLValue(get_TrxName(), "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID=(SELECT AD_Table_ID FROM AD_Table WHERE TableName=?) AND UPPER(ColumnName)='NAME'",m_parent_table);
|
||||||
if(AD_Column_ID>0)
|
if(AD_Column_ID>0)
|
||||||
|
{
|
||||||
createFormatLine(referenceFormat, table, new MColumn(getCtx(),AD_Column_ID,get_TrxName()), 10,true);
|
createFormatLine(referenceFormat, table, new MColumn(getCtx(),AD_Column_ID,get_TrxName()), 10,true);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AD_Column_ID=DB.getSQLValue(get_TrxName(), "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID=(SELECT AD_Table_ID FROM AD_Table WHERE TableName=?) AND UPPER(ColumnName)='VALUE'",m_parent_table);
|
AD_Column_ID=DB.getSQLValue(get_TrxName(), "SELECT AD_Column_ID FROM AD_Column WHERE AD_Table_ID=(SELECT AD_Table_ID FROM AD_Table WHERE TableName=?) AND UPPER(ColumnName)='VALUE'",m_parent_table);
|
||||||
if(AD_Column_ID>0)
|
if(AD_Column_ID>0)
|
||||||
|
{
|
||||||
createFormatLine(referenceFormat, table, new MColumn(getCtx(),AD_Column_ID,get_TrxName()), 10,true);
|
createFormatLine(referenceFormat, table, new MColumn(getCtx(),AD_Column_ID,get_TrxName()), 10,true);
|
||||||
else
|
|
||||||
throw new Exception("Table without name or value column");
|
|
||||||
}
|
}
|
||||||
format_line.setValue(m_parent_table+"_Key");
|
else
|
||||||
format_line.setName("Key "+ col.getColumnName());
|
{
|
||||||
format_line.setAD_Column_ID(col.getAD_Column_ID());
|
throw new AdempiereException("Table without name or value column");
|
||||||
format_line.setType(MEXPFormatLine.TYPE_ReferencedEXPFormat);
|
}
|
||||||
format_line.setEXP_EmbeddedFormat_ID(referenceFormat.getEXP_Format_ID());
|
}
|
||||||
format_line.save();
|
formatLine.setValue(m_parent_table+"_Key");
|
||||||
return format_line.getEXP_FormatLine_ID();
|
formatLine.setName("Key "+ col.getColumnName());
|
||||||
|
formatLine.setAD_Column_ID(col.getAD_Column_ID());
|
||||||
|
formatLine.setType(MEXPFormatLine.TYPE_ReferencedEXPFormat);
|
||||||
|
formatLine.setEXP_EmbeddedFormat_ID(referenceFormat.getEXP_Format_ID());
|
||||||
|
formatLine.saveEx();
|
||||||
|
return formatLine.getEXP_FormatLine_ID();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if((col.getAD_Reference_ID()==DisplayType.Table||col.getAD_Reference_ID()==DisplayType.Search)&col.getAD_Reference_Value_ID()>0)
|
if(DisplayType.isID(col.getAD_Reference_ID()) && col.getAD_Reference_Value_ID()>0)
|
||||||
{
|
{
|
||||||
int AD_Table_ID = DB.getSQLValue(get_TrxName(), "SELECT rt.AD_Table_ID FROM AD_Reference r INNER JOIN AD_Ref_Table rt ON (r.AD_Reference_ID=rt.AD_Reference_ID) WHERE r.AD_Reference_ID=?", col.getAD_Reference_Value_ID());
|
int AD_Table_ID = DB.getSQLValue(get_TrxName(), "SELECT rt.AD_Table_ID FROM AD_Reference r INNER JOIN AD_Ref_Table rt ON (r.AD_Reference_ID=rt.AD_Reference_ID) WHERE r.AD_Reference_ID=?", col.getAD_Reference_Value_ID());
|
||||||
if (AD_Table_ID > 0)
|
if (AD_Table_ID > 0)
|
||||||
{
|
{
|
||||||
tabledir = MTable.get(getCtx(), AD_Table_ID);
|
tabledir = MTable.get(getCtx(), AD_Table_ID);
|
||||||
format_line.setValue(col.getColumnName()+"_Reference");
|
formatLine.setValue(col.getColumnName()+"_Reference");
|
||||||
format_line.setName("Referenced "+ tabledir.getTableName());
|
formatLine.setName("Referenced "+ tabledir.getTableName());
|
||||||
format_line.setAD_Column_ID(col.getAD_Column_ID());
|
formatLine.setAD_Column_ID(col.getAD_Column_ID());
|
||||||
String format_value = createFormat(tabledir);
|
String format_value = createFormat(tabledir);
|
||||||
int embedded = ((MEXPFormat)m_formats.get(format_value)).getEXP_Format_ID();
|
int embedded = ((MEXPFormat)m_formats.get(format_value)).getEXP_Format_ID();
|
||||||
format_line.setType(MEXPFormatLine.TYPE_ReferencedEXPFormat);
|
formatLine.setType(MEXPFormatLine.TYPE_ReferencedEXPFormat);
|
||||||
format_line.setEXP_EmbeddedFormat_ID(embedded);
|
formatLine.setEXP_EmbeddedFormat_ID(embedded);
|
||||||
format_line.save();
|
formatLine.saveEx();
|
||||||
return format_line.getEXP_FormatLine_ID();
|
return formatLine.getEXP_FormatLine_ID();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if(DisplayType.isID(col.getAD_Reference_ID())
|
||||||
if((col.getAD_Reference_ID()==DisplayType.TableDir & col.isKey()== false) || (col.getAD_Reference_ID()==DisplayType.TableDir & col.isParent() == true))
|
&& col.isKey() == false
|
||||||
|
&& DisplayType.ID
|
||||||
|
!= col.getAD_Reference_ID()
|
||||||
|
&& DisplayType.Image
|
||||||
|
!= col.getAD_Reference_ID())
|
||||||
{
|
{
|
||||||
|
|
||||||
String tableName = col.getColumnName().substring(0, col.getColumnName().lastIndexOf("_ID"));
|
String tableName = col.getColumnName().substring(0, col.getColumnName().lastIndexOf("_ID"));
|
||||||
|
@ -292,42 +339,51 @@ public class ExportFormatGenerator extends SvrProcess
|
||||||
if(tabledir==null)
|
if(tabledir==null)
|
||||||
throw new Exception ("Ilegal Table Name");
|
throw new Exception ("Ilegal Table Name");
|
||||||
|
|
||||||
format_line.setValue(tabledir.getTableName()+"_Reference");
|
formatLine.setValue(tabledir.getTableName()+"_Reference");
|
||||||
format_line.setName("Referenced "+ tabledir.getTableName());
|
formatLine.setName("Referenced "+ tabledir.getTableName());
|
||||||
|
|
||||||
|
//formatLine.setType(MEXPFormatLine.TYPE_XMLElement);
|
||||||
if (tabledir!=null)
|
if (tabledir!=null)
|
||||||
{
|
{
|
||||||
if(m_parent_table != null)
|
|
||||||
{
|
|
||||||
if (col.isParent() && col.getColumnName().contains(m_parent_table))
|
|
||||||
{
|
|
||||||
|
|
||||||
int embedded = ((MEXPFormat)m_formats.get(m_format_value)).getEXP_Format_ID();
|
|
||||||
format_line.setValue(format.getValue()+"_Embedded");
|
|
||||||
format_line.setName("Embedded "+ format.getName());
|
|
||||||
format_line.setEXP_EmbeddedFormat_ID(format_line.getEXP_Format_ID());
|
|
||||||
format_line.setEXP_Format_ID(embedded);
|
|
||||||
format_line.setType(MEXPFormatLine.TYPE_EmbeddedEXPFormat);
|
|
||||||
format_line.setAD_Column_ID(col.getAD_Column_ID());
|
|
||||||
format_line.save();
|
|
||||||
log.info("Export Format Line:"+format_line.getName());
|
|
||||||
return format_line.getEXP_FormatLine_ID();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String format_value = createFormat(tabledir);
|
String format_value = createFormat(tabledir);
|
||||||
int embedded = ((MEXPFormat)m_formats.get(format_value)).getEXP_Format_ID();
|
int embedded = ((MEXPFormat)m_formats.get(format_value)).getEXP_Format_ID();
|
||||||
format_line.setType(MEXPFormatLine.TYPE_ReferencedEXPFormat);
|
formatLine.setType(MEXPFormatLine.TYPE_ReferencedEXPFormat);
|
||||||
format_line.setEXP_EmbeddedFormat_ID(embedded);
|
formatLine.setEXP_EmbeddedFormat_ID(embedded);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
format_line.setType(MEXPFormatLine.TYPE_XMLElement);
|
formatLine.setType(MEXPFormatLine.TYPE_XMLElement);
|
||||||
|
}
|
||||||
|
formatLine.setAD_Column_ID(col.getAD_Column_ID());
|
||||||
|
formatLine.saveEx();
|
||||||
|
log.info("Export Format Line:"+formatLine.getName());
|
||||||
|
return formatLine.getEXP_FormatLine_ID();
|
||||||
|
}
|
||||||
|
private void createEmbededFormat(MTable table, MColumn col,boolean force) throws Exception
|
||||||
|
{
|
||||||
|
if(col.isParent() && getTab().getTabLevel() > 0)
|
||||||
|
{
|
||||||
|
String tableName = col.getColumnName().substring(0, col.getColumnName().lastIndexOf("_ID"));
|
||||||
|
|
||||||
|
MEXPFormat format = MEXPFormat.getFormatByValueAD_Client_IDAndVersion(getCtx(), tableName, getAD_Client_ID(), version, get_TrxName());
|
||||||
|
if (format != null)
|
||||||
|
{
|
||||||
|
createFormatLine(format, MTable.get(col.getCtx(), tableName), col, 0 , force);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
format_line.setAD_Column_ID(col.getAD_Column_ID());
|
private MTab getTab()
|
||||||
format_line.save();
|
{
|
||||||
log.info("Export Format Line:"+format_line.getName());
|
return currentTab;
|
||||||
return format_line.getEXP_FormatLine_ID();
|
}
|
||||||
|
|
||||||
|
private MWindow getWindow()
|
||||||
|
{
|
||||||
|
return window;
|
||||||
|
}
|
||||||
|
private void setTab(MTab tab)
|
||||||
|
{
|
||||||
|
currentTab = tab;
|
||||||
}
|
}
|
||||||
} // Generate Export Format
|
} // Generate Export Format
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
-- Dec 1, 2009 10:41:32 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Process SET IsActive='Y', IsBetaFunctionality='N',Updated=TO_DATE('2009-12-01 22:41:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_ID=53085
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:41:33 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Menu SET Description='Create multiple Export Format based in a Window', IsActive='Y', Name='Export Format Generator',Updated=TO_DATE('2009-12-01 22:41:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Menu_ID=53125
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:42:43 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Menu SET IsActive='Y',Updated=TO_DATE('2009-12-01 22:42:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Menu_ID=53130
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:43:39 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Process SET IsActive='Y',Updated=TO_DATE('2009-12-01 22:43:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_ID=53089
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:44:32 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Process SET Classname='org.adempiere.process.rpl.imp.ModelImporter',Updated=TO_DATE('2009-12-01 22:44:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_ID=53074
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:44:50 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Window SET IsBetaFunctionality='N',Updated=TO_DATE('2009-12-01 22:44:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Window_ID=53025
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:44:58 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Window SET IsSOTrx='N',Updated=TO_DATE('2009-12-01 22:44:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Window_ID=53025
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:45:26 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Field SET IsActive='Y',Updated=TO_DATE('2009-12-01 22:45:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=55417
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:58:44 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=55417
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:58:44 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=54570
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:58:51 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Field SET Included_Tab_ID=53086,Updated=TO_DATE('2009-12-01 22:58:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=54570
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:59:21 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Tab SET IsSingleRow='N',Updated=TO_DATE('2009-12-01 22:59:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Tab_ID=53086
|
||||||
|
;
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
-- Dec 1, 2009 10:41:32 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Process SET IsActive='Y', IsBetaFunctionality='N',Updated=TO_TIMESTAMP('2009-12-01 22:41:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_ID=53085
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:41:33 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Menu SET Description='Create multiple Export Format based in a Window', IsActive='Y', Name='Export Format Generator',Updated=TO_TIMESTAMP('2009-12-01 22:41:33','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Menu_ID=53125
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:42:43 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Menu SET IsActive='Y',Updated=TO_TIMESTAMP('2009-12-01 22:42:43','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Menu_ID=53130
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:43:39 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Process SET IsActive='Y',Updated=TO_TIMESTAMP('2009-12-01 22:43:39','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_ID=53089
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:44:32 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Process SET Classname='org.adempiere.process.rpl.imp.ModelImporter',Updated=TO_TIMESTAMP('2009-12-01 22:44:32','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Process_ID=53074
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:44:50 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Window SET IsBetaFunctionality='N',Updated=TO_TIMESTAMP('2009-12-01 22:44:50','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Window_ID=53025
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:44:58 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Window SET IsSOTrx='N',Updated=TO_TIMESTAMP('2009-12-01 22:44:58','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Window_ID=53025
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:45:26 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Field SET IsActive='Y',Updated=TO_TIMESTAMP('2009-12-01 22:45:26','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=55417
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:58:44 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Field SET SeqNo=120,IsDisplayed='Y' WHERE AD_Field_ID=55417
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:58:44 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Field SET SeqNo=130,IsDisplayed='Y' WHERE AD_Field_ID=54570
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:58:51 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Field SET Included_Tab_ID=53086,Updated=TO_TIMESTAMP('2009-12-01 22:58:51','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Field_ID=54570
|
||||||
|
;
|
||||||
|
|
||||||
|
-- Dec 1, 2009 10:59:21 PM CST
|
||||||
|
-- Replication Stabilization
|
||||||
|
UPDATE AD_Tab SET IsSingleRow='N',Updated=TO_TIMESTAMP('2009-12-01 22:59:21','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=0 WHERE AD_Tab_ID=53086
|
||||||
|
;
|
||||||
|
|
|
@ -30,8 +30,9 @@ package org.adempiere.server.rpl.imp;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.adempiere.process.rpl.imp.ImportHelper;
|
||||||
|
import org.adempiere.process.rpl.XMLHelper;
|
||||||
import org.adempiere.server.rpl.IImportProcessor;
|
import org.adempiere.server.rpl.IImportProcessor;
|
||||||
import org.adempiere.server.rpl.XMLHelper;
|
|
||||||
import org.compiere.model.MIMPProcessor;
|
import org.compiere.model.MIMPProcessor;
|
||||||
import org.compiere.model.X_IMP_ProcessorParameter;
|
import org.compiere.model.X_IMP_ProcessorParameter;
|
||||||
import org.compiere.server.ReplicationProcessor;
|
import org.compiere.server.ReplicationProcessor;
|
||||||
|
|
|
@ -41,7 +41,8 @@ import javax.jms.Session;
|
||||||
import javax.jms.TextMessage;
|
import javax.jms.TextMessage;
|
||||||
import javax.jms.Topic;
|
import javax.jms.Topic;
|
||||||
|
|
||||||
import org.adempiere.server.rpl.XMLHelper;
|
import org.adempiere.process.rpl.imp.ImportHelper;
|
||||||
|
import org.adempiere.process.rpl.XMLHelper;
|
||||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||||
import org.compiere.server.ReplicationProcessor;
|
import org.compiere.server.ReplicationProcessor;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
|
|
Loading…
Reference in New Issue