Trouble adding links with the Restlet OData Extentions

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Trouble adding links with the Restlet OData Extentions

Darryl Brown
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Trouble adding links with the Restlet OData Extentions

Jerome Louvel-2
Hi Darryl,

This looks like a bug to me. We should fix it and clarify the docs at the same time.

To move this forward, could you enter an issue in GitHub? Is there a way for us to do a live test?

Best regards,
Jerome
--
http://www.restlet.com
http://twitter.com/#!/jlouvel


-----Message d'origine-----
De : Darryl Brown [mailto:[hidden email]]
Envoyé : mardi 29 mai 2012 20:44
À : [hidden email]
Objet : Trouble adding links with the Restlet OData Extentions

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

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2968352
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Trouble adding links with the Restlet OData Extentions

digbert
This post has NOT been accepted by the mailing list yet.
Hi Jerome

This problem still exists in the current version.

are there any ways to work around this/ are you planning to fix this soon?


Digbert
Loading...