on 04-25-2007 9:21 PM
How to check out records using the Java API 2?
How to check in records using the Java API 2?
How to determine the Check out status of the record using the Java API 2?
Any code snippet is appreciated.
check if this will help you out :
1)create a record
TableId mainTableId = new TableId(mdmTable.getTableId
(MdmTable.PRODUCTS));
CreateRecordCommand createRecord = new CreateRecordCommand(conn);#
Record rec = RecordFactory.createEmptyRecord(mainTableId);
StringValue numberValue = new StringValue("Test ");
createRecord.setRecord(rec);
createRecord.setSession(session);
try {
createRecord.execute();
recordId = createRecord.getRecord().getId();
recordId = setCheckOut(recordId);
} catch (CommandException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
2)check out the newly created record
private RecordId setCheckOut(RecordId recordId){
RecordId recordCheck = null;
TableId table = new TableId( mdmTable.getTableId
(MdmTable.PRODUCTS));
RecordId[] records = new RecordId[1];
records[0] = recordId;
CheckoutRecordsCommand checkoutCommand = new
CheckoutRecordsCommand(conn);
checkoutCommand.setSession(session);
checkoutCommand.setTableId(table);
checkoutCommand.setExclusive(false);
checkoutCommand.setRecordIds(records);
try {
checkoutCommand.execute();
RecordId[] recs = checkoutCommand.getCheckOutRecordIds
();
recordCheck = recs[0];
} catch (CommandException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return recordCheck;
3)Modify the checked out record (the CheckoutRecordCommand returns an
array of Ids , we then use these ids to modify the checked out record)
ModifyRecordCommand modifyRecord = new ModifyRecordCommand(conn);
modifyRecord.setSession(session);
modifyRecord.setRecord(record);
modifyRecord.setModifyAnyway(false);
modifyRecord.execute();
4)then we can go ahead an check in / rollback the record
RollbackRecordsCommand rollbackCommand = new RollbackRecordsCommand
(conn);
rollbackCommand.setSession(session);
rollbackCommand.setTableId(tableId);
rollbackCommand.setRecordIds(recs);
rollbackCommand.execute();
or
CheckinRecordsCommand checkinCommand = new CheckinRecordsCommand(conn);
checkinCommand.setSession(session);
checkinCommand.setRecordIds(recs);
checkinCommand.setTableId(tableId);
checkinCommand.execute()
cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I get an exception when using CheckoutRecordsCommand:
ServerException: "Not yet implemented"
Has this been working once?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Amol,
I have the Java Docs.
I am looking if someone has done checking out using the new API.
The examples in the java doc are insufficient to the cause.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.