Using a custom mashup merger

You can define and register a custom mashup merger by following the procedure provided in this topic.

Procedure

  1. 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);
    	}
    }
  2. 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());
    	}
    }
  3. 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 the WEB-INF/lib folders.
  4. Navigate to <INSTALL_DIR>/repository/eardata/<package-name>/extn folder.
  5. Rename the web.xml.sample file to web.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>
  6. Rebuild the application EAR or WAR.