on 08-27-2009 1:38 PM
Hi,
I need to retrieve videos from the MDM repository.
I've written the following code.
String MultimediaName = "barsandtone_flv";
String TableName = "Videos";
String SCon =null;
TableId TbId = null;
RecordId Id = null;
RetrieveBlobCommand retrieveBlobCommand = null;
MdmValue MmData = null;
RepositorySchema repository;
MDMConnector myConnector = new MDMConnector();
UserSessionContext UsrCxt = null;
String userName = "Admin";
myConnector.init();
UsrCxt = myConnector.getUserSessionContext(userName);
if (SCon == null)
{
SCon = myConnector.getUserSession(UsrCxt);
}
repository = myConnector.getRepository(UsrCxt);
TbId = repository.getTableId(TableName);
try {
retrieveBlobCommand = new RetrieveBlobCommand(UsrCxt);
retrieveBlobCommand.setTableId(TbId);
retrieveBlobCommand.setRecordId();
retrieveBlobCommand.execute();
MmData = retrieveBlobCommand.getBlob();
if(MmData !=null)
System.out.println("Blob retrieved");
else
System.out.println("Blob not found");
}
catch (Exception e) {
}
}
The issue i'm facing is how do I get the RecordId which needs to be set of my video file barsandtone_flv which is present in the MDM repository.
Can anyone please help??
Edited by: Srikantha B on Aug 27, 2009 2:38 PM
Hi Srikantha,
There is a blog corresponding to How to retrieve Images from MDM Repository.
Please refer this as given below:
/people/walter.kahn/blog/2005/12/29/mdm-55-api-tips-and-tricks--image-retrieval
Hope it will help you also in some manner to retrieve Videos from MDM Repository...
Thanks and Regards,
Mandeep Saini
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mandeep,
I've tried out the code in the blog mentioned. But it doesn't help. I want the sample code which uses RetrieveBlobCommand to retrieve Videos. In order to use that command, we need to set the TableId which we seach for and RecordId which are trying to retrieve. But how to get the RecordId by using Video name is my question.
Hi Mandeep,
I've tried out the code in the blog mentioned. But it doesn't help. I want the sample code which uses RetrieveBlobCommand to retrieve Videos. In order to use that command, we need to set the TableId which we seach for and RecordId which are trying to retrieve. But how to get the RecordId by using Video name is my question.
Use this code snippet in your Multimedihandler class to get the videos/images from the respective tables.
// Get table Id for Videos Table
TbId = repository.getTableId(TableName);
// Get List of fields for the Videos Table
GetFieldListCommand getFieldListCommand = new GetFieldListCommand(
UsrCxt);
getFieldListCommand.setSession(SCon);
getFieldListCommand.setTableId(TbId);
getFieldListCommand.execute();
FieldProperties[] fields = getFieldListCommand.getFields();
// Defining the Result Set , using the Table Id.
ResultDefinition rdMain = new ResultDefinition(TbId);
for (int i = 0; i < fields.length; i++) {
rdMain.addSelectField(fields<i>.getId());
}
rdMain.setLoadAttributes(true);
// Create empty search on main table
Search ssearch = new Search(TbId);
// To retrieve Record ID. Set blank search on Videos Table and get
// all the records.
RetrieveLimitedRecordsCommand recordsCommand = new RetrieveLimitedRecordsCommand(
UsrCxt);
recordsCommand.setSession(SCon);
recordsCommand.setSearch(ssearch);
recordsCommand.setResultDefinition(rdMain);
recordsCommand.execute();
Record[] recs = recordsCommand.getRecords().getRecords();
FieldId[]flds = recs[0].getFields();
Boolean value;
// To get the record id of the specific video passed as argument
for(int i=0;i<recs.length;i++){
value = recs<i>.getFieldValue(flds[1]).toString().equals(MultimediaCode);
if(value ){
Id = recs<i>.getId();
//To get Field properties of the Record
String[] MmProperty = null;
for(int j=0;j<flds.length;j++){
MmProperty[j] = recs<i>.getFieldValue(flds[j]).toString();
}
}
}
Edited by: Srikantha B on Sep 2, 2009 1:05 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
continued..
retrieveBlobCommand = new RetrieveBlobCommand(UsrCxt);
retrieveBlobCommand.setTableId(TbId);
retrieveBlobCommand.setRecordId(Id);
retrieveBlobCommand.execute();
// }
// Got blob in MdmData type.
MmData = retrieveBlobCommand.getBlob();
// Convert to binary
RegionProperties region = new RegionProperties();
MultiregionValue multiRegionValue = (MultiregionValue) MmData;
BinaryValue binaryValue = (BinaryValue) multiRegionValue
.getValue(getRegion(UsrCxt).getRegionCode());
// Get bytes
byte[] btMMfile = binaryValue.getBytes();
// Write to physical file.
FileOutputStream out = null;
out = new FileOutputStream("c:
grandma.wmv");
for (int i = 0; i < btMMfile.length; i++) {
out.write(btMMfile<i>);
}
out.close();
if (MmData != null)
System.out.println("Blob retrieved");
else
System.out.println("Blob not found");
} catch (Exception e) {
}
}
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.