You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by "Tomoloju, Ola" <ol...@atos.net> on 2014/03/13 14:21:38 UTC
RE: Isis AngularJS Client - Update NOT Working
Hello Dan,
I am trying to do an update against our Isis RO service.
But, I am getting the following error:
"invalidReason":"Expected a link (because this object's type is not a value) but found no 'href'"},"x-ro-invalidReason":"Van is mandatory"}
Any ideas what I am doing wrong?
Below is the method definition in the service:
/**
* Update the given van with details.
*
* @param card
* Given Van
*/
@Bookmarkable
@ActionSemantics(Of.IDEMPOTENT)
@MemberOrder(sequence = "4")
public final void updateVan(@Named("Van") final Van van) {
container.persist(van);
}
Should we update by passing in the object, as done above?
Or, should it be similar to createVan(@Named("van Number") final String vanNumber,
@Named("Category") final Constants.CATEGORY category,
@Named("van Type") final Constants.VAN_TYPES type,
@Named("van Status") final Constants.STATUS status,
@Named("Expiry Date") final LocalDate expiryDate,
@Named("van Id") final Integer vanId)
where the van details are passed as arguments to the method?
Below is the RO tree for updateVan:
{
"id" : "updateVan",
"memberType" : "action",
"links" : [ {
"rel" : "self",
"href" : "http://localhost:8080/xxxx-webapp-1.0-SNAPSHOT/restful/services/vans/actions/updateVan",
"method" : "GET",
"type" : "application/json;profile=\"urn:org.restfulobjects:repr-types/action-result\""
}, {
"rel" : "up",
"href" : "http://localhost:8080/xxxx-webapp-1.0-SNAPSHOT/restful/services/vans",
"method" : "GET",
"type" : "application/json;profile=\"urn:org.restfulobjects:repr-types/object\"",
"title" : "Top up my travel credit"
}, {
"rel" : "urn:org.restfulobjects:rels/invoke",
"href" : "http://localhost:8080/xxxx-webapp-1.0-SNAPSHOT/restful/services/vans/actions/updateVan/invoke",
"method" : "PUT",
"type" : "application/json;profile=\"urn:org.restfulobjects:repr-types/action-result\"",
"arguments" : {
"van" : {
"value" : null
}
}
}, {
"rel" : "describedby",
"href" : "http://localhost:8080/xxxx-webapp-1.0-SNAPSHOT/restful/domain-types/net.atos.xxxx.services.VanService/actions/updateVan",
"method" : "GET",
"type" : "application/json;profile=\"urn:org.restfulobjects:repr-types/action-description\""
} ],
"extensions" : {
"actionType" : "user",
"actionSemantics" : "idempotent"
},
"parameters" : {
"van" : {
"num" : 0,
"id" : "van",
"name" : "Van",
"description" : ""
}
}
}
Below is my update request JSON Object:
"van" : {
"id":"Van",
"href" : "http://localhost:8080/xxxx-webapp-1.0-SNAPSHOT/restful/objects/Van/L_0",
"value":
{ "vanNumber" : {
"id" : "vanNumber",
"memberType": "property",
"value" : formData.vanNumber
},
"category" : {
"id" : "category",
"memberType" : "property",
"value" : formData.category
},
"vanType" : {
id : "vanType",
memberType: "property",
value : formData.type
},
"vanStatus" : {
id : "vanStatus",
memberType : "property",
value : formData.status
},
"expiryDate" : {
id : "expiryDate",
memberType: "property",
value : formData.expiryDate
},
"vanId" : {
id : "vanId",
memberType : "property",
value : formData.vanId
} }
}
Ola Tomoloju
From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
Sent: Wednesday, March 12, 2014 5:31 PM
To: Tomoloju, Ola; users
Subject: Re: Isis AngularJS Client
Ola,
I'm cc'ing this to users@i.a.o<ma...@i.a.o>; happy to answer questions but prefer that they go on the users list where possible.
Thx
Dan
On 12 March 2014 16:43, Tomoloju, Ola <ol...@atos.net>> wrote:
Please, advice on the best practice rule:
CREATE - @ActionSemantics(Of.IDEMPOTENT)?
generally this would be non-idempotent ... calling create and then create again will give you two objects, not one.
Of course, it is possible an action that acts like an "upsert", (if exists update else insert), in which case it would be idempotent. The migration API that Estatio uses was written this way [1].
READ - @ActionSemantics(Of.SAFE)?
yes.
UPDATE - @ActionSemantics(Of.IDEMPOTENT) ?
depends ... more likely to be non-idempotent.
If its a simple update, then yes, idempotent.
But what about an action that transitions an object through its lifecycle (New -> Open -> Resolved -> Closed); invoking that action twice would move the object forward two states, not one.
DELETE - @ActionSemantics(Of.IDEMPOTENT)?
generally yes.
HTH
Dan
[1] https://github.com/estatio/estatio/blob/master/dom/src/main/java/org/estatio/api/Api.java#L238
RE: Isis AngularJS Client - Update NOT Working
Posted by "Tomoloju, Ola" <ol...@atos.net>.
Thanks a lot. Will do.
Ola Tomoloju
From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
Sent: Thursday, March 13, 2014 2:01 PM
To: Tomoloju, Ola; users
Subject: Re: Isis AngularJS Client - Update NOT Working
On 13 March 2014 13:52, Tomoloju, Ola <ol...@atos.net>> wrote:
Thanks Dan.
I guessed as much, it is a bit of a learning curve for the developers involved (included myself).
We will change the updateVan() definition and implementation as you've adviced.
Please, could you review the JSON request for me or better still, which JSON data will be required for the first argument (van reference) of the revised updateVan() method?
assuming:
updateVan(@Named("Van") *final* Van van,
@Named("van Number") *final* String vanNumber,
@Named("Category") *final* Constants.CATEGORY category,
@Named("van Type") *final* Constants.VAN_TYPES type,
@Named("van Status") *final* Constants.STATUS status,
@Named("Expiry Date") *final* LocalDate expiryDate,
@Named("van Id") *final* Integer vanId) { ... }
then the HTTP body will be something like:
{
"van": { "value": { "href": "..../Van/XXX" } },
"vanNumber": { "value": "1234" } },
"category": { "value": "..." },
"vanType": { "value": "..." },
"expiryDate": { "value": "2014-09-01" },
"vanId": { "value": 123 }
}
but test this in Chrome (Postman) first [1].
[1] http://isis.apache.org/components/viewers/restfulobjects/using-chrome-tools.html
Re: Isis AngularJS Client - Update NOT Working
Posted by Dan Haywood <da...@haywood-associates.co.uk>.
On 13 March 2014 13:52, Tomoloju, Ola <ol...@atos.net> wrote:
> Thanks Dan.
> I guessed as much, it is a bit of a learning curve for the developers
> involved (included myself).
>
> We will change the updateVan() definition and implementation as you've
> adviced.
>
> Please, could you review the JSON request for me or better still, which
> JSON data will be required for the first argument (van reference) of the
> revised updateVan() method?
>
assuming:
updateVan(@Named("Van") *final* Van van,
@Named("van Number") *final* String vanNumber,
@Named("Category") *final* Constants.CATEGORY category,
@Named("van Type") *final* Constants.VAN_TYPES type,
@Named("van Status") *final* Constants.STATUS status,
@Named("Expiry Date") *final* LocalDate expiryDate,
@Named("van Id") *final* Integer vanId) { ... }
then the HTTP body will be something like:
{
"van": { "value": { "href": "..../Van/XXX" } },
"vanNumber": { "value": "1234" } },
"category": { "value": "..." },
"vanType": { "value": "..." },
"expiryDate": { "value": "2014-09-01" },
"vanId": { "value": 123 }
}
but test this in Chrome (Postman) first [1].
[1]
http://isis.apache.org/components/viewers/restfulobjects/using-chrome-tools.html
RE: Isis AngularJS Client - Update NOT Working
Posted by "Tomoloju, Ola" <ol...@atos.net>.
Thanks Dan.
I guessed as much, it is a bit of a learning curve for the developers involved (included myself).
We will change the updateVan() definition and implementation as you've adviced.
Please, could you review the JSON request for me or better still, which JSON data will be required for the first argument (van reference) of the revised updateVan() method?
Below is my update request JSON Object:
"van" : {
"id":"Van",
"href" : "http://localhost:8080/xxxx-webapp-1.0-SNAPSHOT/restful/objects/Van/XXXXX", ???????
"value":
{ "vanNumber" : {
"id" : "vanNumber",
"memberType": "property",
"value" : formData.vanNumber
},
"category" : {
"id" : "category",
"memberType" : "property",
"value" : formData.category
},
"vanType" : {
id : "vanType",
memberType: "property",
value : formData.type
},
"vanStatus" : {
id : "vanStatus",
memberType : "property",
value : formData.status
},
"expiryDate" : {
id : "expiryDate",
memberType: "property",
value : formData.expiryDate
},
"vanId" : {
id : "vanId",
memberType : "property",
value : formData.vanId
} }
}
-----Original Message-----
From: Dan Haywood [mailto:dan@haywood-associates.co.uk]
Sent: Thursday, March 13, 2014 1:35 PM
To: users
Subject: Re: Isis AngularJS Client - Update NOT Working
I think you are confusing two separate concepts here... the updating of a reference to a van, vs the creation/update of the van itself.
Before we get into the RO stuff, can we just focus on the domain model.
The snippets of Java that you've pasted in don't make much sense to me; further comments below.
On 13 March 2014 13:21, Tomoloju, Ola <ol...@atos.net> wrote:
>
>
>
> Below is the method definition in the service:
>
>
>
> /**
>
> * Update the given van with details.
>
> *
>
> * *@param* card
>
> * Given Van
>
> */
>
> @Bookmarkable
>
> @ActionSemantics(Of.*IDEMPOTENT*)
>
> @MemberOrder(sequence = "4")
>
> *public* *final* *void* updateVan(@Named("Van") *final* Van van) {
>
> container.persist(van);
>
> }
>
>
>
> Should we update by passing in the object, as done above?
>
This doesn't make much sense to me (at least if it were to be invoked from RO); the Van argument would need to be a reference to an already-persisted object, but all the method is doing is attempting to then persist the object.
> Or, should it be similar to createVan(@Named("van Number")
> *final*String vanNumber,
>
> @Named("Category") *final* Constants.CATEGORY category,
>
> @Named("van Type") *final* Constants.VAN_TYPES type,
>
> @Named("van Status") *final* Constants.STATUS status,
>
> @Named("Expiry Date") *final* LocalDate expiryDate,
>
> @Named("van Id") *final* Integer vanId)
>
>
>
This handles only the creation of a van (I presume... you didn't include the body).
I suspect what you want is an action that combines these two:
updateVan(@Named("Van") *final* Van van,
@Named("van Number") *final* String vanNumber,
@Named("Category") *final* Constants.CATEGORY category,
@Named("van Type") *final* Constants.VAN_TYPES type,
@Named("van Status") *final* Constants.STATUS status,
@Named("Expiry Date") *final* LocalDate expiryDate,
@Named("van Id") *final* Integer vanId)
the first parameter would be a reference (href) to the existing van, the remaining 6 parameters are the new values. Probably annotate these other parameters with @Optional so that they don't all have to be specified...
Does that make sense?
Dan
Re: Isis AngularJS Client - Update NOT Working
Posted by Dan Haywood <da...@haywood-associates.co.uk>.
I think you are confusing two separate concepts here... the updating of a
reference to a van, vs the creation/update of the van itself.
Before we get into the RO stuff, can we just focus on the domain model.
The snippets of Java that you've pasted in don't make much sense to me;
further comments below.
On 13 March 2014 13:21, Tomoloju, Ola <ol...@atos.net> wrote:
>
>
>
> Below is the method definition in the service:
>
>
>
> /**
>
> * Update the given van with details.
>
> *
>
> * *@param* card
>
> * Given Van
>
> */
>
> @Bookmarkable
>
> @ActionSemantics(Of.*IDEMPOTENT*)
>
> @MemberOrder(sequence = "4")
>
> *public* *final* *void* updateVan(@Named("Van") *final* Van van) {
>
> container.persist(van);
>
> }
>
>
>
> Should we update by passing in the object, as done above?
>
This doesn't make much sense to me (at least if it were to be invoked from
RO); the Van argument would need to be a reference to an already-persisted
object, but all the method is doing is attempting to then persist the
object.
> Or, should it be similar to createVan(@Named("van Number") *final*String vanNumber,
>
> @Named("Category") *final* Constants.CATEGORY category,
>
> @Named("van Type") *final* Constants.VAN_TYPES type,
>
> @Named("van Status") *final* Constants.STATUS status,
>
> @Named("Expiry Date") *final* LocalDate expiryDate,
>
> @Named("van Id") *final* Integer vanId)
>
>
>
This handles only the creation of a van (I presume... you didn't include
the body).
I suspect what you want is an action that combines these two:
updateVan(@Named("Van") *final* Van van,
@Named("van Number") *final* String vanNumber,
@Named("Category") *final* Constants.CATEGORY category,
@Named("van Type") *final* Constants.VAN_TYPES type,
@Named("van Status") *final* Constants.STATUS status,
@Named("Expiry Date") *final* LocalDate expiryDate,
@Named("van Id") *final* Integer vanId)
the first parameter would be a reference (href) to the existing van, the
remaining 6 parameters are the new values. Probably annotate these other
parameters with @Optional so that they don't all have to be specified...
Does that make sense?
Dan