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);
}
}
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
}
Aggregations