Search in sources :

Example 1 with JsonFormParameter

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;
}
Also used : JsonFormParameter(io.clownfish.clownfish.beans.JsonFormParameter) ArrayList(java.util.ArrayList)

Example 2 with JsonFormParameter

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;
}
Also used : HashMap(java.util.HashMap) JsonFormParameter(io.clownfish.clownfish.beans.JsonFormParameter) DatatableProperties(io.clownfish.clownfish.jdbc.DatatableProperties) DatatableCondition(io.clownfish.clownfish.jdbc.DatatableCondition)

Example 3 with JsonFormParameter

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;
}
Also used : Setter(lombok.Setter) Accessors(lombok.experimental.Accessors) Getter(lombok.Getter) EmailProperties(io.clownfish.clownfish.mail.EmailProperties) HashMap(java.util.HashMap) DatatableNewValue(io.clownfish.clownfish.jdbc.DatatableNewValue) ArrayList(java.util.ArrayList) DatatableDeleteValue(io.clownfish.clownfish.jdbc.DatatableDeleteValue) DatatableUpdateProperties(io.clownfish.clownfish.jdbc.DatatableUpdateProperties) DatatableCondition(io.clownfish.clownfish.jdbc.DatatableCondition) DatatableProperties(io.clownfish.clownfish.jdbc.DatatableProperties) List(java.util.List) Component(org.springframework.stereotype.Component) RfcFunctionParam(io.clownfish.clownfish.sap.models.RfcFunctionParam) Map(java.util.Map) JsonFormParameter(io.clownfish.clownfish.beans.JsonFormParameter) RFC_GET_FUNCTION_INTERFACE(io.clownfish.clownfish.sap.RFC_GET_FUNCTION_INTERFACE) CfSitesaprfc(io.clownfish.clownfish.dbentities.CfSitesaprfc) DatatableNewProperties(io.clownfish.clownfish.jdbc.DatatableNewProperties) DatatableDeleteProperties(io.clownfish.clownfish.jdbc.DatatableDeleteProperties) HashMap(java.util.HashMap) DatatableCondition(io.clownfish.clownfish.jdbc.DatatableCondition) DatatableUpdateProperties(io.clownfish.clownfish.jdbc.DatatableUpdateProperties) DatatableNewValue(io.clownfish.clownfish.jdbc.DatatableNewValue)

Example 4 with JsonFormParameter

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;
}
Also used : DatatableNewProperties(io.clownfish.clownfish.jdbc.DatatableNewProperties) Setter(lombok.Setter) Accessors(lombok.experimental.Accessors) Getter(lombok.Getter) EmailProperties(io.clownfish.clownfish.mail.EmailProperties) HashMap(java.util.HashMap) DatatableNewValue(io.clownfish.clownfish.jdbc.DatatableNewValue) ArrayList(java.util.ArrayList) DatatableDeleteValue(io.clownfish.clownfish.jdbc.DatatableDeleteValue) DatatableUpdateProperties(io.clownfish.clownfish.jdbc.DatatableUpdateProperties) DatatableCondition(io.clownfish.clownfish.jdbc.DatatableCondition) DatatableProperties(io.clownfish.clownfish.jdbc.DatatableProperties) List(java.util.List) Component(org.springframework.stereotype.Component) RfcFunctionParam(io.clownfish.clownfish.sap.models.RfcFunctionParam) Map(java.util.Map) JsonFormParameter(io.clownfish.clownfish.beans.JsonFormParameter) RFC_GET_FUNCTION_INTERFACE(io.clownfish.clownfish.sap.RFC_GET_FUNCTION_INTERFACE) CfSitesaprfc(io.clownfish.clownfish.dbentities.CfSitesaprfc) DatatableNewProperties(io.clownfish.clownfish.jdbc.DatatableNewProperties) DatatableDeleteProperties(io.clownfish.clownfish.jdbc.DatatableDeleteProperties) HashMap(java.util.HashMap) DatatableNewValue(io.clownfish.clownfish.jdbc.DatatableNewValue)

Example 5 with JsonFormParameter

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;
}
Also used : JCoFunction(com.sap.conn.jco.JCoFunction) HashMap(java.util.HashMap) JsonFormParameter(io.clownfish.clownfish.beans.JsonFormParameter) ArrayList(java.util.ArrayList) Date(java.util.Date) CfSitesaprfc(io.clownfish.clownfish.dbentities.CfSitesaprfc) RfcFunctionParam(io.clownfish.clownfish.sap.models.RfcFunctionParam) JCoTable(com.sap.conn.jco.JCoTable) JCoException(com.sap.conn.jco.JCoException) SimpleDateFormat(java.text.SimpleDateFormat) RpyTableRead(io.clownfish.clownfish.sap.models.RpyTableRead)

Aggregations

JsonFormParameter (io.clownfish.clownfish.beans.JsonFormParameter)7 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 CfSitesaprfc (io.clownfish.clownfish.dbentities.CfSitesaprfc)5 RfcFunctionParam (io.clownfish.clownfish.sap.models.RfcFunctionParam)5 DatatableCondition (io.clownfish.clownfish.jdbc.DatatableCondition)4 DatatableProperties (io.clownfish.clownfish.jdbc.DatatableProperties)4 RFC_GET_FUNCTION_INTERFACE (io.clownfish.clownfish.sap.RFC_GET_FUNCTION_INTERFACE)4 List (java.util.List)4 Map (java.util.Map)4 Getter (lombok.Getter)4 Setter (lombok.Setter)4 Component (org.springframework.stereotype.Component)4 DatatableDeleteProperties (io.clownfish.clownfish.jdbc.DatatableDeleteProperties)3 DatatableDeleteValue (io.clownfish.clownfish.jdbc.DatatableDeleteValue)3 DatatableNewProperties (io.clownfish.clownfish.jdbc.DatatableNewProperties)3 DatatableNewValue (io.clownfish.clownfish.jdbc.DatatableNewValue)3 DatatableUpdateProperties (io.clownfish.clownfish.jdbc.DatatableUpdateProperties)3 EmailProperties (io.clownfish.clownfish.mail.EmailProperties)3 Accessors (lombok.experimental.Accessors)3