Mass Update Change Strcuture
This commit is contained in:
parent
b2bc6d615d
commit
865a5603fe
|
|
@ -40,7 +40,7 @@ public class MID_CompleteRecord extends SvrProcess{
|
|||
case "C_Order" :
|
||||
MOrder o = new MOrder(getCtx(), record_ID, get_TrxName());
|
||||
if(!o.processIt(DocAct))
|
||||
return "Failed to Complete Document !!!";
|
||||
return o.getProcessMsg();
|
||||
o.saveEx();
|
||||
break;
|
||||
case "M_InOut" :
|
||||
|
|
|
|||
|
|
@ -69,10 +69,32 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
|||
Iterator<Object> keysWhereParams = whereParams.iterator();
|
||||
List<Object> parameters = new ArrayList<Object>();
|
||||
while (keysWhereParams.hasNext()){
|
||||
parameters.add(params.get(keysWhereParams.next()));
|
||||
String paramsColumn = keysWhereParams.next().toString();
|
||||
String forSplit = params.get(paramsColumn).toString();
|
||||
Object p = params.get(paramsColumn);
|
||||
if(forSplit.split("-").length==3 && forSplit.split(":").length==3)
|
||||
parameters.add((Timestamp) params.get(paramsColumn));
|
||||
else{
|
||||
if(paramsColumn.contains("Date") || paramsColumn.contains("Time"))
|
||||
parameters.add((Timestamp) params.get(paramsColumn));
|
||||
else{
|
||||
try {
|
||||
parameters.add(Integer.parseInt(params.get(paramsColumn).toString()));
|
||||
continue;
|
||||
} catch (NumberFormatException e) {}
|
||||
|
||||
try{
|
||||
parameters.add(new BigDecimal(params.get(paramsColumn).toString()));
|
||||
continue;
|
||||
}catch (Exception e){}
|
||||
|
||||
parameters.add(params.get(paramsColumn));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Object[] paramValues = parameters.toArray(new Object[parameters.size()]);
|
||||
String r="";
|
||||
|
||||
int[] IDs = new Query(getCtx(), tableName, whereClause,get_TrxName())
|
||||
.setParameters(paramValues)
|
||||
|
|
@ -87,9 +109,25 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
|||
while(keysMass.hasNext()) {
|
||||
String columnInsert = keysMass.next().toString();
|
||||
obj.set_ValueNoCheck(columnInsert, Data.get(columnInsert).toString());
|
||||
if(columnInsert.equals("Record_ID"))
|
||||
continue;
|
||||
else if (columnInsert.contains("Date") || columnInsert.contains("Time"))
|
||||
{
|
||||
Timestamp time = Timestamp.valueOf(Data.get(columnInsert).toString());
|
||||
obj.set_ValueOfColumn(columnInsert, time);
|
||||
}
|
||||
else{
|
||||
if(obj.set_ValueOfColumnReturningBoolean(columnInsert, Data.get(columnInsert))){ }
|
||||
else if(obj.set_ValueOfColumnReturningBoolean(columnInsert, new BigDecimal(Data.get(columnInsert).toString()))){ }
|
||||
else{throw new AdempiereException("Cannot Fill Column "+columnInsert);}
|
||||
if(obj.get_Value(columnInsert)==null) throw new AdempiereException("Cannot Fill Column "+columnInsert);
|
||||
}
|
||||
// r = r+" "+columnInsert+":"+Data.get(columnInsert).toString();
|
||||
}
|
||||
if(!obj.save())
|
||||
throw new AdempiereException("Failed to Save the Data !");
|
||||
// if(r.length()>0) return r;
|
||||
if(!obj.save(get_TrxName())){
|
||||
throw new AdempiereException("Failed to Update !!!");
|
||||
}
|
||||
}
|
||||
return "Update Mass Data Success !!";
|
||||
}else {
|
||||
|
|
@ -119,27 +157,25 @@ public class MID_InsertIntoAllTable extends SvrProcess{
|
|||
|
||||
}
|
||||
}
|
||||
if(columnset.length()>0)
|
||||
return columnset;
|
||||
if(!po.save(get_TrxName()))
|
||||
throw new AdempiereException("Failed to Save the Data !");
|
||||
throw new AdempiereException(po.get_Logger().retrieveError().getName());
|
||||
|
||||
if(po.get_Value("DocAction")!=null) {
|
||||
Class<?> clazz = getClass(tableName);
|
||||
if (clazz == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Constructor<?> constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, ResultSet.class, String.class});
|
||||
Object classDocument = constructor.newInstance(new Object[] {Env.getCtx(), po.get_ID(), get_TrxName()});
|
||||
Method meth = clazz.getDeclaredMethod("processIt", String.class);
|
||||
try {
|
||||
meth.invoke(classDocument, po.get_ValueAsString("DocAction"));
|
||||
}catch(Exception e) {
|
||||
return "Failed to Process Document !!";
|
||||
}
|
||||
}
|
||||
// if(po.get_Value("DocAction")!=null) {
|
||||
// Class<?> clazz = getClass(tableName);
|
||||
// if (clazz == null)
|
||||
// {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// Constructor<?> constructor = clazz.getDeclaredConstructor(new Class[]{Properties.class, ResultSet.class, String.class});
|
||||
// Object classDocument = constructor.newInstance(new Object[] {Env.getCtx(), po.get_ID(), get_TrxName()});
|
||||
// Method meth = clazz.getDeclaredMethod("processIt", String.class);
|
||||
// try {
|
||||
// meth.invoke(classDocument, po.get_ValueAsString("DocAction"));
|
||||
// }catch(Exception e) {
|
||||
// return "Failed to Process Document !!";
|
||||
// }
|
||||
// }
|
||||
|
||||
if(Trx.get(get_TrxName(), false).commit()){
|
||||
return String.valueOf(po.get_ID());
|
||||
|
|
|
|||
Loading…
Reference in New Issue