Ciommit
This commit is contained in:
parent
34d2c7b1d5
commit
ecd0b51fb9
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>andromedia.midsuit.feature</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.FeatureBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.FeatureNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
@ -0,0 +1 @@
|
|||
bin.includes = feature.xml
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<feature
|
||||
id="andromedia.midsuit.feature"
|
||||
label="Feature"
|
||||
version="1.0.0.qualifier">
|
||||
|
||||
<description url="http://www.example.com/description">
|
||||
[Enter Feature Description here.]
|
||||
</description>
|
||||
|
||||
<copyright url="http://www.example.com/copyright">
|
||||
[Enter Copyright Description here.]
|
||||
</copyright>
|
||||
|
||||
<license url="http://www.example.com/license">
|
||||
[Enter License Description here.]
|
||||
</license>
|
||||
|
||||
<plugin
|
||||
id="andromedia.midsuit.project"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
</feature>
|
||||
|
|
@ -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<Object> keySetMass= Data.keySet();
|
||||
Iterator<Object> 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<Object> whereParams = params.keySet();
|
||||
// Iterator<Object> keysWhereParams = whereParams.iterator();
|
||||
// List<Object> parameters = new ArrayList<Object>();
|
||||
// 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<Object> keySetMass= Data.keySet();
|
||||
// Iterator<Object> 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<Object> keySet= Data.keySet();
|
||||
Iterator<Object> 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 !";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue