I am looking to writing to an existing OData service from an Android device. 
Our existing .Net client is currently using this service and I am having 
trouble with addLink/setLink methods on the ext.OData library from restlet.org. 
I have created my classes from our OData service as recommended on the 
restlet.org site and reading the data works fine. When I try to write I have 
issues if I try to write more than a single entity; for instance if I try to 
add a link. I have a customer object that contains orders so I am attempting to 
use the following code:

private static List<Customer> customers = new Vector<Customer>();
private static DbAdapter helper = null;
private static DataService ds = new DataService();

public static processOutboundData(Context ctx) {
helper=new DbAdapter(mCtx);
helper.open();

// Get the outbound customers from SQLite DB
customers = helper.readCustomers(WhereExtra, null);
helper.close();

for (Customer myCustomer : customers{
if (myCustomer.getCustomerId()==0) {
try {
// add the customer details
ds.addLink(myCustomer, "Detail", myCustomer.getDetail());

// Add this customers orders
for (Order thisOrder : myCustomer.getOrder()) {
ds.addLink(myCustomer, "Order", thisOrder);
ds.setLink(thisOrder, "Customer", myCustomer);
}
ds.addEntity(myCustomer);

} catch (Exception addEx) {
Log.w(TAG, "The Add Entity Failed Due To " + addEx.toString());
}
} else {
try {
ds.updateEntity(myCustomer);
} catch (Exception updEx) {
Log.w(TAG, "The Update entity Failed Due To " + updEx.toString());
}
}
}
}

When this code executes I get a error (405) Method Not Allowed Can’t add entity 
to this set Message. What am I doing wrong here? I thought I would need to 
set/add the link before I did an add or update on the entity (I did not 
complete the update code because I wanted to finish create first).

The other part of my questions is on the parameters of addLink/setLink 
Parameters:

source The source entity to update. (I understand this one)
sourceProperty The name of the property of the source entity. (What exactly is 
this)
target The entity to add to the source entity. (I understand this one)

Being that there are no examples that I could find and the documentation is 
ambiguous I thought I would ask directly. What is the sourceProperty? Is it the 
Table/Entity name or the foreign key column name? or something else entirely?

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2967554

Reply via email to