Creating data sources

You need to create a data source so that users are able to retrieve data.

Before you begin

Ensure that you have approval authority.

About this task

A data source is an entity that defines how data is imported into IBM® Product Master.

External data can originate from various locations or databases and can also be accessed in a number of different ways. For example, you can import data from a database, a file found on an FTP server, or data from your local file system. Each of these options requires specific configuration parameters to access the data. A data source encapsulates these parameters, and lets them be manipulated as a single named entity so that after the source details are set up it can be reused throughout the product.

Based on the business or data integration requirement, data that is fed into Product Master is considered a data source. The following descriptions relate to a data source design:
  • The mechanism for how the data was fed into Product Master
  • The mapping perspective for where the data is inserted into Product Master
  • The types of data source; full data load or delta data load.

Procedure

Use any one of the following methods to create a data source: User interface, Java™ API, or script API.
Option Description
User interface
  1. Click Collaboration Manager > Data Sources > Data Source Console.
  2. Click the new, and provide the required details for creating a data source.
  3. Click Save.
Java API
Sample 1: The following sample Java API code creates a data source to upload data by using a Web browser.
import com.ibm.pim.context.Context;
import com.ibm.pim.context.PIMContextFactory;
import com.ibm.pim.utils.DataSource;
import com.ibm.pim.utils.RoutingManager;
import com.ibm.pim.common.exceptions.PIMInternalException;



public class WebUploadDataSource
{
    public static void main(String args[]) 
    {
        createDataSource();
    }

    public static void createDataSource() 
    {
        try
        {
            Context context =PIMContextFactory.getContext("Admin", "trinitron","MyCompany");
            RoutingManager  manager = context.getRoutingManager();

            String sDSName = "webuploadDS";
            DataSource  ds = manager.createDataSource(sDSName, DataSource.Type.PUSH_WWW);
            ds.save();
        }
        catch(PIMInternalException pe )
        {
            pe.printStackTrace();
        }
        catch(Exception e )
        {
            e.printStackTrace();
        }
    }
}


Sample 2: The following sample Java API code creates a data source to retrieve data by using FTP.
import com.ibm.pim.context.Context;
import com.ibm.pim.context.PIMContextFactory;
import com.ibm.pim.utils.DataSource;
import com.ibm.pim.utils.RoutingManager;
import com.ibm.pim.common.exceptions.PIMInternalException;



public class FTPRetrieveDataSource
{
    public static void main(String args[]) 
    {
        createFTPDataSource();
    }

    public static void createFTPDataSource() 
    {
        try
        {
            Context context =PIMContextFactory.getContext("Admin", "trinitron","MyCompany");
            RoutingManager  manager = context.getRoutingManager();

            String sDSName = "FTPdataSource";

            //create FTP Type DataSource
            DataSource  ds = manager.createDataSource(sDSName, DataSource.Type.PULL_FTP);

            //set properties
            
ds.setProperty(DataSource.Property.SERVER_ADDRESS, "ftp.server.com");
            
ds.setProperty(DataSource.Property.SERVER_PORT, "21");
            
ds.setProperty(DataSource.Property.USERNAME, "username");
            
ds.setProperty(DataSource.Property.PASSWORD, "*****");
            
ds.setProperty(DataSource.Property.FILENAME, "file");
            
ds.setProperty(DataSource.Property.DIRECTORY, "/path/to/directory");

            //save
            ds.save();

        }
        catch(PIMInternalException pe )
        {
            pe.printStackTrace();
        }
        catch(Exception e )
        {
            e.printStackTrace();
        }
    }
}
Script API Sample 1: The following sample script API creates a data source to upload data by using a Web browser.
var res = createDataSource(
      “browser”,    //Name of thesource
      "PUSH_WWW");  //Type
Sample 2: The following sample script API creates a data source to retrieve data by using FTP.
var attr_Name = "ftp_source";
var extraAttribs = [];
extraAttribs["SERVER_ADDRESS"] = 	"9.10.84.139";
extraAttribs["SERVER_PORT"] = "80";
extraAttribs["USERNAME"] = "user";
extraAttribs["PASSWORD"] = "password";
extraAttribs["FILENAME"] = "getFtp.txt";
extraAttribs["DIRECTORY"] = "ftp_dir";
extraAttribs["DOC_STORE_PATH"] = 	"/archives/ftp_folder";
var res = createDataSource(
attr_Name,       //Name of the source
"PULL_FTP", 	   //Type
extraAttribs);	 //Optional attributes