diff --git a/andromedia.midsuit.feature/.project b/andromedia.midsuit.feature/.project new file mode 100644 index 0000000..4a93db2 --- /dev/null +++ b/andromedia.midsuit.feature/.project @@ -0,0 +1,17 @@ + + + andromedia.midsuit.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/andromedia.midsuit.feature/build.properties b/andromedia.midsuit.feature/build.properties new file mode 100644 index 0000000..82ab19c --- /dev/null +++ b/andromedia.midsuit.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/andromedia.midsuit.feature/feature.xml b/andromedia.midsuit.feature/feature.xml new file mode 100644 index 0000000..2cc5415 --- /dev/null +++ b/andromedia.midsuit.feature/feature.xml @@ -0,0 +1,26 @@ + + + + + [Enter Feature Description here.] + + + + [Enter Copyright Description here.] + + + + [Enter License Description here.] + + + + + diff --git a/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_InsertIntoAllTable.java b/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_InsertIntoAllTable.java index b17a6e4..d656cd2 100644 --- a/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_InsertIntoAllTable.java +++ b/andromeida.midsuit.project/src/andromedia/midsuit/process/MID_InsertIntoAllTable.java @@ -5,7 +5,9 @@ import java.lang.reflect.Constructor; import java.math.BigDecimal; import java.sql.ResultSet; import java.sql.Timestamp; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; @@ -27,6 +29,7 @@ import org.compiere.process.SvrProcess; import org.compiere.util.CCache; import org.compiere.util.CLogger; import org.compiere.util.Env; +import org.compiere.util.Trx; import org.compiere.util.Util; import org.zkoss.json.JSONArray; import org.zkoss.json.JSONObject; @@ -63,44 +66,74 @@ public class MID_InsertIntoAllTable extends SvrProcess{ String whereClause = JSON.get("WhereClause").toString(); if(Mode.equals("I")) { po = getPO(tableName, 0, get_TrxName()); - }else if (Mode.equals("U")) { - if(whereClause.length()>0) { - int[] IDs = new Query(getCtx(), tableName, whereClause,get_TrxName()) - .setOnlyActiveRecords(true) - .getIDs(); - - for(int ID : IDs) { - PO obj = null; - obj = getPO(tableName, ID, get_TrxName()); - Set keySetMass= Data.keySet(); - Iterator keysMass = keySetMass.iterator(); - while(keysMass.hasNext()) { - String columnInsert = keysMass.next().toString(); - obj.set_ValueNoCheck(columnInsert, Data.get(columnInsert).toString()); - } - if(!obj.save()) - throw new AdempiereException("Failed to Save the Data !"); - - } - return "Update Mass Data Success !!"; - }else { - int Record_ID = Integer.parseInt(Data.get("Record_ID").toString()); - po = getPO(tableName, Record_ID, get_TrxName()); - } + } +// else if (Mode.equals("U")) { +// if(whereClause.length()>0) { +// JSONObject params = (JSONObject) JSON.get("Params"); +// Set whereParams = params.keySet(); +// Iterator keysWhereParams = whereParams.iterator(); +// List parameters = new ArrayList(); +// while (keysWhereParams.hasNext()){ +// parameters.add(params.get(keysWhereParams.next())); +// } +// +// Object[] paramValues = parameters.toArray(new Object[parameters.size()]); +// +// int[] IDs = new Query(getCtx(), tableName, whereClause,get_TrxName()) +// .setParameters(paramValues) +// .setOnlyActiveRecords(true) +// .getIDs(); +// +// for(int ID : IDs) { +// PO obj = null; +// obj = getPO(tableName, ID, get_TrxName()); +// Set keySetMass= Data.keySet(); +// Iterator keysMass = keySetMass.iterator(); +// while(keysMass.hasNext()) { +// String columnInsert = keysMass.next().toString(); +// obj.set_ValueNoCheck(columnInsert, Data.get(columnInsert).toString()); +// } +// if(!obj.save()) +// throw new AdempiereException("Failed to Save the Data !"); +// } +// return "Update Mass Data Success !!"; +// }else { +// int Record_ID = Integer.parseInt(Data.get("Record_ID").toString()); +// po = getPO(tableName, Record_ID, get_TrxName()); +// } +// } Set keySet= Data.keySet(); Iterator keys = keySet.iterator(); - if(whereClause.length()==0) + if(whereClause.length()==0){ + String columnset = ""; while(keys.hasNext()) { String columnInsert = keys.next().toString(); - if(columnInsert.equals("Record_ID")) - continue; - po.set_ValueNoCheck(columnInsert, Data.get(columnInsert).toString()); - if(!po.save()) - throw new AdempiereException("Failed to Save the Data !"); - return String.valueOf(po.get_ID()); + if(columnInsert.equals("Record_ID")) + continue; + else if (columnInsert.contains("Date") || columnInsert.contains("Time")) + { + Timestamp time = Timestamp.valueOf(Data.get(columnInsert).toString()); + po.set_ValueOfColumn(columnInsert, time); + } + else{ + if(po.set_ValueOfColumnReturningBoolean(columnInsert, Data.get(columnInsert))){ } + else if(po.set_ValueOfColumnReturningBoolean(columnInsert, new BigDecimal(Data.get(columnInsert).toString()))){ } + else{throw new AdempiereException("Cannot Fill Column "+columnInsert);} + + if(po.get_Value(columnInsert)==null) throw new AdempiereException("Cannot Fill Column "+columnInsert); + } } + if(columnset.length()>0) + return columnset; + if(!po.save(get_TrxName())) + throw new AdempiereException("Failed to Save the Data !"); + if(Trx.get(get_TrxName(), false).commit()){ + return String.valueOf(po.get_ID()); + }else + return "Failed to Save the Data !!!"; + } }else { return "No JSON to be processed !"; }