cancel
Showing results for 
Search instead for 
Did you mean: 

I am not able to add images into Catalog thru java API

Former Member
0 Kudos

I have done most of the work,but i should get the record id for getting some iMage Info.

First i am adding fields into products then adding image.

is this approachright.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Narayan/Nimrod,

Plz share us the implementation for getDataGroupIdByName(dataGroupName) method.

Thanks in advance,

Ananth

Former Member
0 Kudos

Hi Narayan/Ananth,

You can get the datagroup id with this code:

int datagroupid = -1;

A2iStringArray values = new A2iStringArray();

//provide actual group name defined in using MDME Client

values.Add("datagroupname");

//Now do not change any value from the code below

ResultSetDefinition rsd = new ResultSetDefinition("DataGroup");

rsd.AddField("DataGroupField");

A2iResultSet rs = null;

rs = catalogData.GetRecordsByValue(values, rsd, "DataGroupField");

if (rs.GetRecordCount() > 0) {

datagroupid = rs.GetRecordIDAt(0);

}

If you still have any problem while importing images then feel free to discuss that.

Regards

Shahid Nadeem

Message was edited by: Shahid Nadeem

Former Member
0 Kudos

Hi Shahid Nadeem,

Thanks a lot !!

Regards,

Ananth

Former Member
0 Kudos

Hello Babu,

Please look at the following code example, if you are facing with additional problems, please write detailed description, thanks.

A2iFields mdmFields = new A2iFields();

// adding the "DataObject" - read the the bytes from the

// file then store it in variable

String filePath = "C:
temp
image.jpg";

File file = new File(filePath);

byte[] bytes = new byte[(int) file.length()];

// read byte from file, and set the large data

FileInputStream inputStream = new FileInputStream(file);

inputStream.read(bytes);

mdmFields.Add(new A2iField("DataObject", new Value(bytes)));

// adding the "DataGroupId"

String dataGroupName = "DataGroup for testing images";

// get the id of the dataGroupId, if the dataGroupName

//doesn't exist it will be added by the method

int dataGroupId = getDataGroupIdByName(dataGroupName);

mdmFields.Add(new A2iField("DataGroupId", new Value(dataGroupId)));

// adding the name

mdmFields.Add(new A2iField("Name", new Value(file.getName())));

mdmFields.Add(new A2iField("OrigName", new Value(file.getName())));

// adding OrigLocationId

int origLocationId = this.catalogData.AddDataLocation(filePath, 0, DataLocationType.RemovableMediaLocation);

mdmFields.Add(new A2iField("OrigLocationId", new Value(origLocationId)));

// adding the image to the "Images" table

int newImageId = this.catalogData.AddRecord("Images", mdmFields, 0, 0);

Good luck.

Former Member
0 Kudos

Hi,

i Still didnt get idea as how to implement getDataGroupIDByName,Could plz help in this regard.

Thank you very much,

Narayan.

Former Member
0 Kudos

Hello Narayan,

Data Group is a group which contains BLOBs.

Loading Image to MDM requires to define the Data Group ID.

getDataGroupIDByName returns you the Data Group ID by name, if the Data Group name doesn't exist, the method will create it.

For example:

//the following example code will return "My Images" Data

//Group id, if "My Images" not exist, it will create it.

//

String dataGroupName = "My Images";

int dataGroupId = getDataGroupIdByName(dataGroupName);

Good luck, Nimrod.

Former Member
0 Kudos

Hi Nimrodh,

I have tried to get the id by name just like getrecord id,i have also tried to add into data group table so that i could get id,but it didnt seem to work.

Actually how can i get the id ,can u give the implementation.

Thanks And Regards,

Narayan.

Former Member
0 Kudos

Hi Nimod

Plz help me out regarding the following issue while adding image..

I am trying to add image in to repository, I have set Name, original name , data grp ID, original location ID, but how to set the image blob... i am not able to find any field named <i>DataObject</i> or a similar feild which can store the byte array.

Note- I am using MDM SP04.

Thanks in advance

swati