use of io.clownfish.clownfish.beans.JsonFormParameter in project Clownfish by rawdog71.
the class ClownfishUtil method getJsonFormParameterList.
public static List<JsonFormParameter> getJsonFormParameterList(Map parameterlist) {
List<JsonFormParameter> jsonlist = new ArrayList<>();
if (null != parameterlist) {
for (Object param : parameterlist.keySet()) {
JsonFormParameter jsfp = new JsonFormParameter();
jsfp.setName((String) param);
jsfp.setValue((String) parameterlist.get(param));
jsonlist.add(jsfp);
}
}
return jsonlist;
}
use of io.clownfish.clownfish.beans.JsonFormParameter in project Clownfish by rawdog71.
the class ClownfishUtil method getDatatableproperties.
/*
getDatatableproperties
Setzt die Properties für ein DB READ Aufruf
*/
public HashMap<String, DatatableProperties> getDatatableproperties(List<JsonFormParameter> postmap) {
HashMap<String, DatatableProperties> datatableproperties = new HashMap<>();
if (postmap != null) {
for (JsonFormParameter jfp : postmap) {
// Datenbank READ Parameter
if (jfp.getName().compareToIgnoreCase("db$table") == 0) {
if (datatableproperties.get(jfp.getValue()) == null) {
DatatableProperties dtp = new DatatableProperties();
dtp.setTablename(jfp.getValue());
datatableproperties.put(jfp.getValue(), dtp);
}
}
if (jfp.getName().startsWith("db$table$")) {
String rest = jfp.getName().substring(9);
String[] values = rest.split("\\$");
if (values[1].compareToIgnoreCase("orderby") == 0) {
if (datatableproperties.isEmpty()) {
DatatableProperties dtp = new DatatableProperties();
dtp.setTablename(values[0]);
datatableproperties.put(values[0], dtp);
}
datatableproperties.get(values[0]).setOrderby(jfp.getValue());
}
if (values[1].compareToIgnoreCase("orderdir") == 0) {
if (datatableproperties.isEmpty()) {
DatatableProperties dtp = new DatatableProperties();
dtp.setTablename(values[0]);
datatableproperties.put(values[0], dtp);
}
datatableproperties.get(values[0]).setOrderdir(jfp.getValue());
}
if (values[1].compareToIgnoreCase("pagination") == 0) {
if (datatableproperties.isEmpty()) {
DatatableProperties dtp = new DatatableProperties();
dtp.setTablename(values[0]);
datatableproperties.put(values[0], dtp);
}
datatableproperties.get(values[0]).setPagination(Integer.parseInt(jfp.getValue()));
}
if (values[1].compareToIgnoreCase("page") == 0) {
if (datatableproperties.isEmpty()) {
DatatableProperties dtp = new DatatableProperties();
dtp.setTablename(values[0]);
datatableproperties.put(values[0], dtp);
}
datatableproperties.get(values[0]).setPage(Integer.parseInt(jfp.getValue()));
}
if (values[1].compareToIgnoreCase("groupbycount") == 0) {
if (datatableproperties.isEmpty()) {
DatatableProperties dtp = new DatatableProperties();
dtp.setTablename(values[0]);
datatableproperties.put(values[0], dtp);
}
datatableproperties.get(values[0]).setGroupbycount(jfp.getValue());
}
if (values[1].compareToIgnoreCase("groupby") == 0) {
if (datatableproperties.isEmpty()) {
DatatableProperties dtp = new DatatableProperties();
dtp.setTablename(values[0]);
datatableproperties.put(values[0], dtp);
}
datatableproperties.get(values[0]).getGroupbylist().add(jfp.getValue());
}
if (values[1].compareToIgnoreCase("condition") == 0) {
DatatableCondition dtc = new DatatableCondition();
dtc.setField(values[2]);
dtc.setOperand(values[3]);
dtc.setValue(jfp.getValue());
if (datatableproperties.isEmpty()) {
DatatableProperties dtp = new DatatableProperties();
dtp.setTablename(values[0]);
datatableproperties.put(values[0], dtp);
}
datatableproperties.get(values[0]).getConditionlist().add(dtc);
}
}
}
}
return datatableproperties;
}
use of io.clownfish.clownfish.beans.JsonFormParameter in project Clownfish by rawdog71.
the class ClownfishUtil method getDatatableupdateproperties.
/*
getDatatableupdateproperties
Setzt die Properties für ein DB UPDATE Aufruf
*/
public HashMap<String, DatatableUpdateProperties> getDatatableupdateproperties(List<JsonFormParameter> postmap) {
HashMap<String, DatatableUpdateProperties> datatableupdateproperties = new HashMap<>();
if (postmap != null) {
postmap.stream().map((jfp) -> {
// Datenbank UPDATE Parameter
if (jfp.getName().compareToIgnoreCase("db$tableupdate") == 0) {
DatatableUpdateProperties dtup = new DatatableUpdateProperties();
dtup.setTablename(jfp.getValue());
datatableupdateproperties.put(jfp.getValue(), dtup);
}
return jfp;
}).filter((jfp) -> (jfp.getName().startsWith("db$tableupdate$"))).forEach((jfp) -> {
String rest = jfp.getName().substring(15);
String[] values = rest.split("\\$");
if (values[1].compareToIgnoreCase("condition") == 0) {
DatatableCondition dtc = new DatatableCondition();
dtc.setField(values[2]);
dtc.setOperand(values[3]);
dtc.setValue(jfp.getValue());
datatableupdateproperties.get(values[0]).getConditionlist().add(dtc);
} else {
DatatableNewValue dtnv = new DatatableNewValue();
dtnv.setField(values[1]);
dtnv.setValue(jfp.getValue());
datatableupdateproperties.get(values[0]).getValuelist().add(dtnv);
}
});
}
return datatableupdateproperties;
}
use of io.clownfish.clownfish.beans.JsonFormParameter in project Clownfish by rawdog71.
the class ClownfishUtil method getDatatablenewproperties.
/*
getDatatablenewproperties
Setzt die Properties für ein DB INSERT Aufruf
*/
public HashMap<String, DatatableNewProperties> getDatatablenewproperties(List<JsonFormParameter> postmap) {
HashMap<String, DatatableNewProperties> datatablenewproperties = new HashMap<>();
if (postmap != null) {
postmap.stream().map((jfp) -> {
// Datenbank INSERT Parameter
if (jfp.getName().compareToIgnoreCase("db$tablenew") == 0) {
DatatableNewProperties dtnp = new DatatableNewProperties();
dtnp.setTablename(jfp.getValue());
datatablenewproperties.put(jfp.getValue(), dtnp);
}
return jfp;
}).filter((jfp) -> (jfp.getName().startsWith("db$tablenew$"))).forEach((jfp) -> {
String rest = jfp.getName().substring(12);
String[] values = rest.split("\\$");
DatatableNewValue dtnv = new DatatableNewValue();
dtnv.setField(values[1]);
dtnv.setValue(jfp.getValue());
datatablenewproperties.get(values[0]).getValuelist().add(dtnv);
});
}
return datatablenewproperties;
}
use of io.clownfish.clownfish.beans.JsonFormParameter in project Clownfish by rawdog71.
the class SAPUtility method getSapExport.
/*
getSapExport
Übergibt die POST Parameter und ruft SAP RFC auf
Setzt die Ergebnisse in eine Hashmap zur Ausgabe in Freemarker
*/
public static HashMap<String, HashMap> getSapExport(List<CfSitesaprfc> sitesaprfclist, HashMap<String, List> saprfcfunctionparamMap, List<JsonFormParameter> postmap, RPY_TABLE_READ rpytableread) {
JCoTable functions_table = null;
HashMap<String, HashMap> sapexport = new HashMap<>();
for (CfSitesaprfc cfsitesaprfc : sitesaprfclist) {
try {
HashMap<String, Object> sapvalues = new HashMap<>();
List<RfcFunctionParam> paramlist = saprfcfunctionparamMap.get(cfsitesaprfc.getCfSitesaprfcPK().getRfcfunction());
// Setze die Import Parameter des SAP RFC mit den Werten aus den POST Parametern
JCoFunction function = sapc.getDestination().getRepository().getFunction(cfsitesaprfc.getCfSitesaprfcPK().getRfcfunction());
for (RfcFunctionParam rfcfunctionparam : paramlist) {
if (rfcfunctionparam.getParamclass().compareToIgnoreCase("I") == 0) {
if (null != postmap) {
for (JsonFormParameter jfp : postmap) {
if (jfp.getName().compareToIgnoreCase(rfcfunctionparam.getParameter()) == 0) {
function.getImportParameterList().setValue(rfcfunctionparam.getParameter(), jfp.getValue());
}
}
}
}
}
// SAP RFC ausführen
function.execute(sapc.getDestination());
HashMap<String, ArrayList> saptables = new HashMap<>();
for (RfcFunctionParam rfcfunctionparam : paramlist) {
String tablename = rfcfunctionparam.getTabname();
String paramname = rfcfunctionparam.getParameter();
if (rfcfunctionparam.getParamclass().compareToIgnoreCase("E") == 0) {
sapvalues.put(rfcfunctionparam.getParameter(), function.getExportParameterList().getString(rfcfunctionparam.getParameter()));
}
if (rfcfunctionparam.getParamclass().compareToIgnoreCase("T") == 0) {
ArrayList<HashMap> tablevalues = new ArrayList<>();
functions_table = function.getTableParameterList().getTable(paramname);
List<RpyTableRead> rpytablereadlist = rpytableread.getRpyTableReadList(tablename);
for (int i = 0; i < functions_table.getNumRows(); i++) {
HashMap<String, String> sapexportvalues = new HashMap<>();
functions_table.setRow(i);
for (RpyTableRead rpytablereadentry : rpytablereadlist) {
if ((rpytablereadentry.getDatatype().compareToIgnoreCase(SAPDATATYPE.CHAR) == 0) || (rpytablereadentry.getDatatype().compareToIgnoreCase(SAPDATATYPE.NUMC) == 0) || (rpytablereadentry.getDatatype().compareToIgnoreCase(SAPDATATYPE.UNIT) == 0)) {
String value = functions_table.getString(rpytablereadentry.getFieldname());
sapexportvalues.put(rpytablereadentry.getFieldname(), value);
continue;
}
if ((rpytablereadentry.getDatatype().compareToIgnoreCase(SAPDATATYPE.DATS) == 0) || (rpytablereadentry.getDatatype().compareToIgnoreCase(SAPDATATYPE.TIMS) == 0)) {
Date value = functions_table.getDate(rpytablereadentry.getFieldname());
String datum = "";
if (null != value) {
if (rpytablereadentry.getDatatype().compareToIgnoreCase(SAPDATATYPE.DATS) == 0) {
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
datum = sdf.format(value);
} else {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
datum = sdf.format(value);
}
}
sapexportvalues.put(rpytablereadentry.getFieldname(), datum);
continue;
}
if (rpytablereadentry.getDatatype().compareToIgnoreCase(SAPDATATYPE.QUAN) == 0) {
double value = functions_table.getDouble(rpytablereadentry.getFieldname());
sapexportvalues.put(rpytablereadentry.getFieldname(), String.valueOf(value));
continue;
}
if ((rpytablereadentry.getDatatype().compareToIgnoreCase(SAPDATATYPE.INT1) == 0) || (rpytablereadentry.getDatatype().compareToIgnoreCase(SAPDATATYPE.INT2) == 0) || (rpytablereadentry.getDatatype().compareToIgnoreCase(SAPDATATYPE.INT4) == 0) || (rpytablereadentry.getDatatype().compareToIgnoreCase(SAPDATATYPE.INT8) == 0)) {
int value = functions_table.getInt(rpytablereadentry.getFieldname());
sapexportvalues.put(rpytablereadentry.getFieldname(), String.valueOf(value));
}
}
tablevalues.add(sapexportvalues);
}
saptables.put(paramname, tablevalues);
}
}
sapvalues.put("table", saptables);
sapexport.put(cfsitesaprfc.getCfSitesaprfcPK().getRfcfunction(), sapvalues);
} catch (JCoException ex) {
LOGGER.error(ex.getMessage());
}
}
return sapexport;
}
Aggregations