Search in sources :

Example 1 with SAPConnection

use of org.talend.core.model.metadata.builder.connection.SAPConnection in project tdi-studio-se by Talend.

the class SAPParametersUtils method getSAPIDocParams.

/**
     * DOC zli Comment method "getSAPIDocParams".
     * 
     * @param elem
     * @param connection
     * @param param
     * @param sapIDocName
     */
public static void getSAPIDocParams(final IElement elem, final Connection connection, final IElementParameter param, final String sapIDocName) {
    if (param.getRepositoryValue() == null) {
        return;
    }
    if (connection != null && sapIDocName != null) {
        SAPConnection sapConnection = (SAPConnection) connection;
        SAPIDocUnit iDocUnit = SAPConnectionUtils.findExistIDocUnit(sapConnection, sapIDocName);
        if (param.getFieldType().equals(EParameterFieldType.TEXT) && param.getRepositoryValue().equals("GATEWAYSERVICE")) {
            //$NON-NLS-1$
            if (iDocUnit != null) {
                param.setValue(TalendTextUtils.addQuotes(iDocUnit.getGatewayService()));
                param.setRepositoryValueUsed(true);
                param.setReadOnly(true);
            } else {
                param.setRepositoryValueUsed(false);
                param.setReadOnly(false);
            }
        }
        if (param.getFieldType().equals(EParameterFieldType.TEXT) && param.getRepositoryValue().equals("PROGRAMID")) {
            //$NON-NLS-1$
            if (iDocUnit != null) {
                param.setValue(TalendTextUtils.addQuotes(iDocUnit.getProgramId()));
                param.setRepositoryValueUsed(true);
                param.setReadOnly(true);
            } else {
                param.setRepositoryValueUsed(false);
                param.setReadOnly(false);
            }
        }
        if (param.getFieldType().equals(EParameterFieldType.CHECK) && param.getRepositoryValue().equals("FORMAT_XML")) {
            //$NON-NLS-1$
            if (iDocUnit != null) {
                param.setValue(iDocUnit.isUseXmlOutput());
                param.setRepositoryValueUsed(true);
                param.setReadOnly(true);
            } else {
                param.setRepositoryValueUsed(false);
                param.setReadOnly(false);
            }
        }
        if (param.getFieldType().equals(EParameterFieldType.FILE) && param.getRepositoryValue().equals("FILE_IDOC_XML")) {
            //$NON-NLS-1$
            if (iDocUnit != null) {
                param.setValue(TalendTextUtils.addQuotes(iDocUnit.getXmlFile()));
                param.setRepositoryValueUsed(true);
                param.setReadOnly(true);
            } else {
                param.setRepositoryValueUsed(false);
                param.setReadOnly(false);
            }
        }
        if (param.getFieldType().equals(EParameterFieldType.CHECK) && param.getRepositoryValue().equals("FORMAT_HTML")) {
            //$NON-NLS-1$
            if (iDocUnit != null) {
                param.setValue(iDocUnit.isUseHtmlOutput());
                param.setRepositoryValueUsed(true);
                param.setReadOnly(true);
            } else {
                param.setRepositoryValueUsed(false);
                param.setReadOnly(false);
            }
        }
        if (param.getFieldType().equals(EParameterFieldType.FILE) && param.getRepositoryValue().equals("FILE_IDOC_HTML")) {
            //$NON-NLS-1$
            if (iDocUnit != null) {
                param.setValue(TalendTextUtils.addQuotes(iDocUnit.getHtmlFile()));
                param.setRepositoryValueUsed(true);
                param.setReadOnly(true);
            } else {
                param.setRepositoryValueUsed(false);
                param.setReadOnly(false);
            }
        }
    }
}
Also used : SAPConnection(org.talend.core.model.metadata.builder.connection.SAPConnection) SAPIDocUnit(org.talend.core.model.metadata.builder.connection.SAPIDocUnit)

Example 2 with SAPConnection

use of org.talend.core.model.metadata.builder.connection.SAPConnection in project tdi-studio-se by Talend.

the class SAPParametersUtils method retrieveSAPParams.

/**
     * DOC xye Comment method "retrieveSAPParams".
     * 
     * @param param
     */
@SuppressWarnings("unchecked")
public static void retrieveSAPParams(final IElement elem, final Connection connection, final IElementParameter param, final String sapFunctionLabel) {
    if (param.getRepositoryValue() == null || !(connection instanceof SAPConnection)) {
        return;
    }
    if (param.getFieldType().equals(EParameterFieldType.TEXT) && param.getRepositoryValue().equals("SAP_FUNCTION")) {
        //$NON-NLS-1$
        if (connection != null && sapFunctionLabel != null) {
            SAPFunctionUnit unit = null;
            for (int i = 0; i < ((SAPConnection) connection).getFuntions().size(); i++) {
                SAPFunctionUnit tmp = ((SAPConnection) connection).getFuntions().get(i);
                if (tmp.getLabel().equals(sapFunctionLabel)) {
                    unit = tmp;
                    break;
                }
            }
            if (unit == null) {
                return;
            }
            param.setValue(TalendTextUtils.addQuotes(unit.getName()));
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        } else {
            param.setRepositoryValueUsed(false);
            param.setReadOnly(false);
        }
    } else if (param.getFieldType().equals(EParameterFieldType.TABLE)) {
        if (param.getRepositoryValue().equals("INPUT_PARAMS")) {
            //$NON-NLS-1$
            if (connection != null && sapFunctionLabel != null) {
                List<Map<String, Object>> table = (List<Map<String, Object>>) elem.getPropertyValue(param.getName());
                RepositoryToComponentProperty.getSAPInputAndOutputValue((SAPConnection) connection, table, sapFunctionLabel, true);
                param.setRepositoryValueUsed(true);
                param.setReadOnly(true);
            } else {
                param.setRepositoryValueUsed(false);
                param.setReadOnly(false);
            }
        }
        if ("SAP_PROPERTIES".equals(param.getRepositoryValue())) {
            //$NON-NLS-1$
            //$NON-NLS-1$
            Object value = RepositoryToComponentProperty.getValue(connection, "SAP_PROPERTIES", null);
            param.setValue(value);
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        }
    } else if (param.getFieldType().equals(EParameterFieldType.TABLE) && param.getRepositoryValue().equals("OUTPUT_PARAMS")) {
        //$NON-NLS-1$
        if (connection != null && sapFunctionLabel != null) {
            List<Map<String, Object>> table = (List<Map<String, Object>>) elem.getPropertyValue(param.getName());
            RepositoryToComponentProperty.getSAPInputAndOutputValue((SAPConnection) connection, table, sapFunctionLabel, false);
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        } else {
            param.setRepositoryValueUsed(false);
            param.setReadOnly(false);
        }
    } else if (param.getRepositoryValue().equals("SAP_ITERATE_OUT_TYPE")) {
        //$NON-NLS-1$
        if (connection != null && sapFunctionLabel != null) {
            param.setValue(RepositoryToComponentProperty.getSAPValuesForFunction((SAPConnection) connection, sapFunctionLabel, //$NON-NLS-1$
            "SAP_ITERATE_OUT_TYPE"));
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        } else {
            param.setRepositoryValueUsed(false);
            param.setReadOnly(false);
        }
    } else if (param.getRepositoryValue().equals("SAP_ITERATE_OUT_TABLENAME")) {
        //$NON-NLS-1$
        if (connection != null && sapFunctionLabel != null) {
            param.setValue(RepositoryToComponentProperty.getSAPValuesForFunction((SAPConnection) connection, sapFunctionLabel, //$NON-NLS-1$
            "SAP_ITERATE_OUT_TABLENAME"));
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        } else {
            param.setRepositoryValueUsed(false);
            param.setReadOnly(false);
        }
    }
}
Also used : SAPConnection(org.talend.core.model.metadata.builder.connection.SAPConnection) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) List(java.util.List) Map(java.util.Map)

Example 3 with SAPConnection

use of org.talend.core.model.metadata.builder.connection.SAPConnection in project tdi-studio-se by Talend.

the class SAPParametersUtils method retrieveSAPIDocParams.

/**
     * DOC zli Comment method "retrieveSAPIDocParams".
     * 
     * @param elem
     * @param connection
     * @param param
     * @param sapFunctionName
     */
public static void retrieveSAPIDocParams(final Element elem, final Connection connection, final IElementParameter param, final String sapFunctionName) {
    if (param.getRepositoryValue() == null) {
        return;
    }
    SAPIDocUnit iDocUnit = null;
    if (connection != null && sapFunctionName != null) {
        SAPConnection sapConnection = (SAPConnection) connection;
        iDocUnit = SAPConnectionUtils.findExistIDocUnit(sapConnection, sapFunctionName);
    }
    if (param.getRepositoryValue().equals("SAPIDOC")) {
        //$NON-NLS-1$
        if (connection != null && sapFunctionName != null) {
            param.setValue(TalendTextUtils.addQuotes(sapFunctionName));
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        } else {
            param.setRepositoryValueUsed(false);
            param.setReadOnly(false);
        }
    }
    if (param.getFieldType().equals(EParameterFieldType.TEXT) && param.getRepositoryValue().equals("GATEWAYSERVICE")) {
        //$NON-NLS-1$
        if (iDocUnit != null) {
            param.setValue(TalendTextUtils.addQuotes(iDocUnit.getGatewayService()));
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        } else {
            param.setRepositoryValueUsed(false);
            param.setReadOnly(false);
        }
    }
    if (param.getFieldType().equals(EParameterFieldType.TEXT) && param.getRepositoryValue().equals("PROGRAMID")) {
        //$NON-NLS-1$
        if (iDocUnit != null) {
            param.setValue(TalendTextUtils.addQuotes(iDocUnit.getProgramId()));
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        } else {
            param.setRepositoryValueUsed(false);
            param.setReadOnly(false);
        }
    }
    if (param.getFieldType().equals(EParameterFieldType.CHECK) && param.getRepositoryValue().equals("FORMAT_XML")) {
        //$NON-NLS-1$
        if (iDocUnit != null) {
            param.setValue(iDocUnit.isUseXmlOutput());
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        } else {
            param.setRepositoryValueUsed(false);
            param.setReadOnly(false);
        }
    }
    if (param.getFieldType().equals(EParameterFieldType.FILE) && param.getRepositoryValue().equals("FILE_IDOC_XML")) {
        //$NON-NLS-1$
        if (iDocUnit != null) {
            param.setValue(TalendTextUtils.addQuotes(iDocUnit.getXmlFile()));
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        } else {
            param.setRepositoryValueUsed(false);
            param.setReadOnly(false);
        }
    }
    if (param.getFieldType().equals(EParameterFieldType.CHECK) && param.getRepositoryValue().equals("FORMAT_HTML")) {
        //$NON-NLS-1$
        if (iDocUnit != null) {
            param.setValue(iDocUnit.isUseHtmlOutput());
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        } else {
            param.setRepositoryValueUsed(false);
            param.setReadOnly(false);
        }
    }
    if (param.getFieldType().equals(EParameterFieldType.FILE) && param.getRepositoryValue().equals("FILE_IDOC_HTML")) {
        //$NON-NLS-1$
        if (iDocUnit != null) {
            param.setValue(TalendTextUtils.addQuotes(iDocUnit.getHtmlFile()));
            param.setRepositoryValueUsed(true);
            param.setReadOnly(true);
        } else {
            param.setRepositoryValueUsed(false);
            param.setReadOnly(false);
        }
    }
}
Also used : SAPIDocUnit(org.talend.core.model.metadata.builder.connection.SAPIDocUnit) SAPConnection(org.talend.core.model.metadata.builder.connection.SAPConnection)

Example 4 with SAPConnection

use of org.talend.core.model.metadata.builder.connection.SAPConnection in project tdi-studio-se by Talend.

the class RepositoryService method setInternalNodeHTMLMap.

@Override
public void setInternalNodeHTMLMap(INode node, Map<String, Object> internalNodeHTMLMap) {
    IElementParameter propertyParam = null;
    IElementParameter functionParam = null;
    for (IElementParameter param : node.getElementParameters()) {
        if ("PROPERTY".equals(param.getName())) {
            //$NON-NLS-1$
            //$NON-NLS-1$
            propertyParam = param.getChildParameters().get("REPOSITORY_PROPERTY_TYPE");
        }
        if ("SAP_FUNCTION".equals(param.getName())) {
            //$NON-NLS-1$
            functionParam = param;
        }
    }
    if (propertyParam != null && functionParam != null) {
        try {
            IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion((String) propertyParam.getValue());
            if (lastVersion != null) {
                Item item = lastVersion.getProperty().getItem();
                if (item instanceof SAPConnectionItem) {
                    SAPConnectionItem sapItem = (SAPConnectionItem) item;
                    SAPConnection connection = (SAPConnection) sapItem.getConnection();
                    connection.getFuntions();
                    for (Object obj : connection.getFuntions()) {
                        if (obj instanceof SAPFunctionUnit) {
                            SAPFunctionUnit function = (SAPFunctionUnit) obj;
                            String functionName = (String) functionParam.getValue();
                            if (function.getName().equals(functionName.substring(1, functionName.length() - 1))) {
                                if (!function.getDocument().isEmpty()) {
                                    String document = ModelElementHelper.getFirstDocument(function).getReference();
                                    if (document != null && !"".equals(document)) {
                                        //$NON-NLS-1$
                                        internalNodeHTMLMap.put(node.getUniqueName(), //$NON-NLS-1$ //$NON-NLS-2$
                                        document.substring(document.indexOf("<font"), document.indexOf("</body>")));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) RulesItem(org.talend.core.model.properties.RulesItem) SAPConnection(org.talend.core.model.metadata.builder.connection.SAPConnection) SAPFunctionUnit(org.talend.core.model.metadata.builder.connection.SAPFunctionUnit) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) JSONObject(org.talend.utils.json.JSONObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject)

Aggregations

SAPConnection (org.talend.core.model.metadata.builder.connection.SAPConnection)4 SAPFunctionUnit (org.talend.core.model.metadata.builder.connection.SAPFunctionUnit)2 SAPIDocUnit (org.talend.core.model.metadata.builder.connection.SAPIDocUnit)2 List (java.util.List)1 Map (java.util.Map)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 IElementParameter (org.talend.core.model.process.IElementParameter)1 ContextItem (org.talend.core.model.properties.ContextItem)1 Item (org.talend.core.model.properties.Item)1 ProcessItem (org.talend.core.model.properties.ProcessItem)1 RulesItem (org.talend.core.model.properties.RulesItem)1 SAPConnectionItem (org.talend.core.model.properties.SAPConnectionItem)1 SQLPatternItem (org.talend.core.model.properties.SQLPatternItem)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 SalesforceModuleRepositoryObject (org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject)1 JSONObject (org.talend.utils.json.JSONObject)1