Skip to content

Commit

Permalink
pmt37: prepare for preliminary release of import feature
Browse files Browse the repository at this point in the history
  • Loading branch information
lugipfupf committed Feb 15, 2017
1 parent e0cb1bb commit 218dc22
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 31 deletions.
80 changes: 54 additions & 26 deletions src/main/java/com/openbravo/pos/customers/DataLogicCustomers.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.openbravo.format.Formats;
import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.forms.BeanFactoryDataSingle;
import com.openbravo.pos.forms.DataLogicSales;

/**
* @author JG uniCenta
Expand All @@ -48,6 +49,36 @@ public class DataLogicCustomers extends BeanFactoryDataSingle {
Datas.BOOLEAN,
Datas.STRING};

private static final String[] fields = new String[]
{
"ID",
"TAXID",
"SEARCHKEY",
"NAME",
"NOTES",
"VISIBLE",
"CARD",
"MAXDEBT",
"CURDATE",
"CURDEBT",
"FIRSTNAME",
"LASTNAME",
"EMAIL",
"PHONE",
"PHONE2",
"FAX",
"ADDRESS",
"ADDRESS2",
"POSTAL",
"CITY",
"REGION",
"COUNTRY",
"TAXCATEGORY",
"IMAGE"
};

private static String baseSentence;

/**
*
* @param s
Expand All @@ -58,31 +89,7 @@ public void init(Session s){
this.s = s;
tcustomers = new TableDefinition(s
, "CUSTOMERS"
, new String[] {
"ID",
"TAXID",
"SEARCHKEY",
"NAME",
"NOTES",
"VISIBLE",
"CARD",
"MAXDEBT",
"CURDATE",
"CURDEBT",
"FIRSTNAME",
"LASTNAME",
"EMAIL",
"PHONE",
"PHONE2",
"FAX",
"ADDRESS",
"ADDRESS2",
"POSTAL",
"CITY",
"REGION",
"COUNTRY",
"TAXCATEGORY",
"IMAGE" }
, fields
, new String[] {
"ID",
AppLocal.getIntString("label.taxid"),
Expand Down Expand Up @@ -160,6 +167,14 @@ public void init(Session s){
Formats.NULL }
, new int[] {0}
);

StringBuilder sqlBuilder = new StringBuilder("SELECT ");
for (int i = 0; i < fields.length; i++) {
sqlBuilder.append(fields[i]);
sqlBuilder.append(", ");
}
sqlBuilder.append(" FROM CUSTOMERS");
this.baseSentence = sqlBuilder.toString();
}

// JG 20 Sept 12 extended for Postal - CustomerList list
Expand Down Expand Up @@ -299,5 +314,18 @@ public int execInTransaction(Object params) throws BasicException {
*/
public final TableDefinition getTableCustomers() {
return tcustomers;
}
}

public CustomerInfoExt findCustomersBy(String field, Object value) {

StringBuilder sqlBuilder = new StringBuilder(this.baseSentence);
sqlBuilder.append(" WHERE ");
sqlBuilder.append(field);
sqlBuilder.append(" = ?");

PreparedSentence sentence = new PreparedSentence(this.s, sqlBuilder.toString());

// will be implemented for next release
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,12 @@
*/
package com.openbravo.pos.imports;

import com.openbravo.basic.BasicException;
import com.openbravo.data.loader.SentenceExec;
import com.openbravo.pos.customers.JPanelCustomerFields;
import com.openbravo.data.user.EditorRecord;
import com.openbravo.data.user.SaveProvider;
import com.openbravo.pos.customers.DataLogicCustomers;
import com.openbravo.pos.customers.JPanelCustomerFields;
import com.openbravo.pos.customers.JPanelCustomerList;
import com.unicenta.pozapps.forms.AppLocal;
import java.util.logging.Level;
import java.util.logging.Logger;

public class CustomersImportPanel extends JPanelCsvImporter {
@Override
Expand Down

0 comments on commit 218dc22

Please sign in to comment.