cancel
Showing results for 
Search instead for 
Did you mean: 

Standalone Program for Accessing MDM Table

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi,

I am trying access to MDM table using standalone java program but it is giving error. Is it possible?

If it is possible means tell me the steps or post sample codes.

Thanks in advance

Regards

Suresh

Accepted Solutions (0)

Answers (3)

Answers (3)

suresh_krishnamoorthy
Active Contributor
0 Kudos

Found on my own long back

Former Member
0 Kudos

Hello:

I have a piece of code here, even tough I believe it would be easier if you could explain a little more about your problem.

First I create properties for connection. I'm using strings however this can be done also setting properties directly:

String server = "MDMServer";

int port = 2005;

String user = "admin";

String password = "thePassword";

String language = "Spanish [MX]"; // languaje and local you want to use

// THen you choose the region and attempt to login. Please note that even tough I choose region US, I log as a MX user, as provided by the language property

CatalogData mdmBridge = new CatalogData();

mdmBridge.SetCodeRegion("English [US]"); mdmBridge.Login(server,port,user,password,language);

// also note that the catalogData object is the main entrance, now create an array for MDMTables:

CMTableInfoArray tables = null;

// and attempt to get them:

AttributeInfoArray fields = mdmBridge.GetLinkedAttributesForTaxonomy("Categories",6,false);

System.out.println("Counts: " + fields.GetCount());

// Traverse:

for (int i = 0; i < fields.GetCount(); i++)

{

AttributeInfo att = fields.GetAttributeInfoAt(i);

System.out.println("NAME: " + att.GetName());

}

// In this case I'm getting a taxonomy table, such as "Categories". However you could use any other type of tables. Finally I get the contents of this table:

// Attempt to get the categories A2iStringArray array = new A2iStringArray();

array.Add("Filter");

ResultSetDefinition rsd = new ResultSetDefinition("Categories");

rsd.AddField("Id");

A2iResultSet rs = mdmBridge.GetRecordsByValue(array,rsd,"Id");

for(int i = 0; i < rs.GetRecordCount(); i++) {

Value v = rs.GetValueAt(i,0);

System.out.println(v.GetStringValue());

}

Please review the MDM API for java for further info.

I hope that helps

Alejandro

suresh_krishnamoorthy
Active Contributor
0 Kudos

Thanks Subbu and Alejandro....

I am able retrieve data from MDM table.......

Regards

Suresh Kb

Former Member
0 Kudos

Hi,

Plese find the sample code to get the data from the MDM Table.

CatalogData catalog = new CatalogData();

catalog.Login(hostname, port, uname, pwd, language, mincon, maxcon, timeout, logfile);

Search search = new Search();

search.SetSearchTable(<Table Name>);

ResultSetDefinition rsd = new ResultSetDefinition(<Table Name>);

rsd.AddField(<Field1 Name>);

rsd.AddField(<Field2 Name>);

rsd.AddField(<Field3 Name>);

rsd.SetSize(5);

String sortField = <Sort Field Name>

boolean sortAscending = true;

int page = 0; //page number

A2iResultSet rs = this.catalog.GetResultSet(search, rsd, sortField, sortAscending, page);

for (int i = 0; i < rs.GetRecordCount(); i++)

{

Value value1 = rs.GetValueAt(i, <Field1 Name>);

System.out.println("Value: " + value1.GetStringValue());

}

But make sure you are using the correct MDM5.5 Java API jar file.

Please let me know if you have any problems.

Thanks and Regards

Subbu