Using a custom mashup merger
You can define and register a custom mashup merger by following the procedure provided in this topic.
Procedure
-
Create a custom mashup merger class to create a map of repeating element names and
unique identifiers. Refer to the following sample code:
SCUIXAPICustomMashupMerger.java ------------------------------ package com.ibm.custom.extensions.mashup; import org.w3c.dom.Element; import com.sterlingcommerce.framework.utils.SCXmlUtils; import com.sterlingcommerce.ui.web.framework.extensions.ISCUIMashupMerger; public class SCUIXAPICustomMashupMerger implements ISCUIMashupMerger { public void mergeMashupElement(Element parentMashupElement, Element extnMashupElement) { // dbMap Contains, Key is the repeating element node name and Value is the unique key attribute name of that node name under to/target Element. HashMap<String, String> dbMap = new HashMap<String, String>(); dbMap.put("Exp", "Name"); dbMap.put("Modification", "ModificationType"); SCXmlUtils.mergeElement(extnMashupElement, parentMashupElement, false, dbMap); } }
-
Create a servlet to load and register it as the default mashup merger class for XAPI.
Refer to the following sample code:
MashupMergerInitServlet.java ----------------------------- package com.ibm.custom.extensions; import com.sterlingcommerce.ui.web.framework.helpers.SCUIMashupHelper; import javax.servlet.ServletConfig; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; public class MashupMergerInitServlet extends HttpServlet { private static final long serialVersionUID = 2693427927837832487L; public synchronized void init(ServletConfig config) throws ServletException { SCUIMashupHelper.addMashupMerger("XAPI", "com.ibm.custom.extensions.mashup.SCUIXAPICustomMashupMerger", config.getServletContext()); } }
-
Compile the classes and package them into a JAR file. Place the JAR file in the
<INSTALL_DIR>/repository/eardata/<package-name>/extn/WEB-INF/lib
folder. You may need to create theWEB-INF/lib
folders. -
Navigate to
<INSTALL_DIR>/repository/eardata/<package-name>/extn
folder. -
Rename the
web.xml.sample
file toweb.xml
and add the following entry only:<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <servlet> <description>MashupMergerInitServlet</description> <display-name>MashupMergerInitServlet</display-name> <servlet-name>MashupMergerInitServlet</servlet-name> <servlet-class>com.ibm.custom.extensions.MashupMergerInitServlet</servlet-class> <load-on-startup>400</load-on-startup> </servlet> </web-app>
- Rebuild the application EAR or WAR.